diff options
author | Wang Cao <doubleecao@gmail.com> | 2018-06-28 16:32:01 +0800 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-06-30 00:41:35 +0200 |
commit | 5a99e00023c057555697c73b2119f378b019c5fa (patch) | |
tree | 347378aad30892d24304552aa07894713de74096 /libavformat/yuv4mpegdec.c | |
parent | 27662ed681cbc74e9492cecf86ead8946679fd23 (diff) | |
download | ffmpeg-5a99e00023c057555697c73b2119f378b019c5fa.tar.gz |
libavformat/yuv4mpeg: Add color range support for Y4M Add color_range support in Y4M.
Set pixel format and color_range for YUVJ pixel formats. Also set
color_range based on AVFormatContext.
Signed-off-by: Wang Cao <wangcao@google.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/yuv4mpegdec.c')
-rw-r--r-- | libavformat/yuv4mpegdec.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c index eff7fc518e..855fadbb31 100644 --- a/libavformat/yuv4mpegdec.c +++ b/libavformat/yuv4mpegdec.c @@ -41,6 +41,7 @@ static int yuv4_read_header(AVFormatContext *s) enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE, alt_pix_fmt = AV_PIX_FMT_NONE; enum AVChromaLocation chroma_sample_location = AVCHROMA_LOC_UNSPECIFIED; enum AVFieldOrder field_order = AV_FIELD_UNKNOWN; + enum AVColorRange color_range = AVCOL_RANGE_UNSPECIFIED; AVStream *st; for (i = 0; i < MAX_YUV4_HEADER; i++) { @@ -220,6 +221,12 @@ static int yuv4_read_header(AVFormatContext *s) alt_pix_fmt = AV_PIX_FMT_YUV422P; else if (strncmp("444", tokstart, 3) == 0) alt_pix_fmt = AV_PIX_FMT_YUV444P; + } else if (strncmp("COLORRANGE=", tokstart, 11) == 0) { + tokstart += 11; + if (strncmp("FULL",tokstart, 4) == 0) + color_range = AVCOL_RANGE_JPEG; + else if (strncmp("LIMITED", tokstart, 7) == 0) + color_range = AVCOL_RANGE_MPEG; } while (tokstart < header_end && *tokstart != 0x20) tokstart++; @@ -263,6 +270,7 @@ static int yuv4_read_header(AVFormatContext *s) st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; st->sample_aspect_ratio = (AVRational){ aspectn, aspectd }; st->codecpar->chroma_location = chroma_sample_location; + st->codecpar->color_range = color_range; st->codecpar->field_order = field_order; s->packet_size = av_image_get_buffer_size(st->codecpar->format, width, height, 1) + Y4M_FRAME_MAGIC_LEN; if ((int) s->packet_size < 0) |