diff options
author | Paul B Mahol <onemda@gmail.com> | 2018-05-02 13:10:10 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2018-05-03 21:43:57 +0200 |
commit | f43fd68f28079c49e9237894a294968d841babc7 (patch) | |
tree | 57500147d680b2d5f6b77bf7a25310eda7d2a002 /libavfilter/drawutils.c | |
parent | 177133a0f4b41b3c98b9cbc7f8f45755412c537b (diff) | |
download | ffmpeg-f43fd68f28079c49e9237894a294968d841babc7.tar.gz |
avfilter/drawutils: add support for full range
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter/drawutils.c')
-rw-r--r-- | libavfilter/drawutils.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c index db8c7a6226..650ef25aba 100644 --- a/libavfilter/drawutils.c +++ b/libavfilter/drawutils.c @@ -181,6 +181,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) const AVComponentDescriptor *c; unsigned i, nb_planes = 0; int pixelstep[MAX_PLANES] = { 0 }; + int full_range = 0; if (!desc || !desc->name) return AVERROR(EINVAL); @@ -188,6 +189,9 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) return AVERROR(ENOSYS); if (format == AV_PIX_FMT_P010LE || format == AV_PIX_FMT_P010BE || format == AV_PIX_FMT_P016LE || format == AV_PIX_FMT_P016BE) return AVERROR(ENOSYS); + if (format == AV_PIX_FMT_YUVJ420P || format == AV_PIX_FMT_YUVJ422P || format == AV_PIX_FMT_YUVJ444P || + format == AV_PIX_FMT_YUVJ411P || format == AV_PIX_FMT_YUVJ440P) + full_range = 1; for (i = 0; i < desc->nb_components; i++) { c = &desc->comp[i]; /* for now, only 8-16 bits formats */ @@ -214,6 +218,7 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags) draw->format = format; draw->nb_planes = nb_planes; draw->flags = flags; + draw->full_range = full_range; memcpy(draw->pixelstep, pixelstep, sizeof(draw->pixelstep)); draw->hsub[1] = draw->hsub[2] = draw->hsub_max = desc->log2_chroma_w; draw->vsub[1] = draw->vsub[2] = draw->vsub_max = desc->log2_chroma_h; @@ -249,9 +254,9 @@ void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4 } else if (draw->nb_planes >= 2) { /* assume YUV */ const AVPixFmtDescriptor *desc = draw->desc; - color->comp[desc->comp[0].plane].u8[desc->comp[0].offset] = RGB_TO_Y_CCIR(rgba[0], rgba[1], rgba[2]); - color->comp[desc->comp[1].plane].u8[desc->comp[1].offset] = RGB_TO_U_CCIR(rgba[0], rgba[1], rgba[2], 0); - color->comp[desc->comp[2].plane].u8[desc->comp[2].offset] = RGB_TO_V_CCIR(rgba[0], rgba[1], rgba[2], 0); + color->comp[desc->comp[0].plane].u8[desc->comp[0].offset] = draw->full_range ? RGB_TO_Y_JPEG(rgba[0], rgba[1], rgba[2]) : RGB_TO_Y_CCIR(rgba[0], rgba[1], rgba[2]); + color->comp[desc->comp[1].plane].u8[desc->comp[1].offset] = draw->full_range ? RGB_TO_U_JPEG(rgba[0], rgba[1], rgba[2]) : RGB_TO_U_CCIR(rgba[0], rgba[1], rgba[2], 0); + color->comp[desc->comp[2].plane].u8[desc->comp[2].offset] = draw->full_range ? RGB_TO_V_JPEG(rgba[0], rgba[1], rgba[2]) : RGB_TO_V_CCIR(rgba[0], rgba[1], rgba[2], 0); color->comp[3].u8[0] = rgba[3]; #define EXPAND(compn) \ if (desc->comp[compn].depth > 8) \ |