From 116e99de153e3bde08b5e2c0848d93d62a5b1048 Mon Sep 17 00:00:00 2001 From: Torsten Jager Date: Mon, 29 Oct 2012 10:01:04 +0200 Subject: input_test: added full range color test video --- src/demuxers/demux_yuv4mpeg2.c | 17 +++++++++++++++++ src/input/input_test.c | 15 +++++++++------ src/video_dec/yuv.c | 8 +++++++- 3 files changed, 33 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_yuv4mpeg2.c b/src/demuxers/demux_yuv4mpeg2.c index e8877057c..f06201d74 100644 --- a/src/demuxers/demux_yuv4mpeg2.c +++ b/src/demuxers/demux_yuv4mpeg2.c @@ -69,6 +69,7 @@ typedef struct { int aspect_d; int progressive; int top_field_first; + int color_matrix; unsigned int frame_pts_inc; unsigned int frame_size; @@ -89,6 +90,8 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { this->aspect_n = this->aspect_d = this->progressive = this->top_field_first = this->data_start = 0; + this->color_matrix = 4; /* undefined, mpeg range */ + if (_x_demux_read_header(this->input, header, Y4M_HEADER_BYTES) != Y4M_HEADER_BYTES) return 0; @@ -179,6 +182,17 @@ static int open_yuv4mpeg2_file(demux_yuv4mpeg2_t *this) { header_ptr = header_endptr; break; + case 'X': + /* private extra info */ + if (!strncasecmp (header_ptr + 1, "XINE_CM=", 8)) { + int i = strtol(header_ptr + 9, &header_endptr, 10); + if (header_endptr > header_ptr + 9) { + this->color_matrix = i; + header_ptr = header_endptr; + break; + } + } + /* fall through */ default: /* skip whatever this is */ while ((*header_ptr != ' ') && (header_ptr < header_end)) @@ -257,6 +271,9 @@ static int demux_yuv4mpeg2_send_chunk(demux_plugin_t *this_gen) { buf->extra_info->input_time = pts / 90; buf->pts = pts; + buf->decoder_flags |= BUF_FLAG_COLOR_MATRIX; + buf->decoder_info[4] = this->color_matrix; + buf->size = MIN(bytes_remaining, buf->max_size); bytes_remaining -= buf->size; diff --git a/src/input/input_test.c b/src/input/input_test.c index d00486145..3d672eae8 100644 --- a/src/input/input_test.c +++ b/src/input/input_test.c @@ -58,11 +58,12 @@ static const char * const test_names[] = { "test://saturation_levels.y4m", "test://uv_square.y4m", "test://y_resolution.y4m", + "test://rgb_levels_fullrange.y4m", NULL }; -static const char test_type[] = {2, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5}; -static const char test_is_yuv[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}; -static const char test_is_mpeg_range[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1}; +static const char test_type[] = {2, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 2}; +static const char test_is_yuv[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1}; +static const char test_is_mpeg_range[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0}; #define TEST_FILES ((sizeof (test_names) / sizeof (char *)) - 1) @@ -246,7 +247,7 @@ static int test_make (test_input_plugin_t * this) { a = 54 + pitch * height; if (yuv) { if (height >= 720) hdtv = 1; - a += 80 + width * height * 3 / 2; + a += 88 + width * height * 3 / 2; } if (this->buf && (a != this->bufsize)) { free (this->buf); @@ -265,9 +266,11 @@ static int test_make (test_input_plugin_t * this) { if (yuv) { p += 54 + pitch * height; this->y4m_head = p; + /* use inofficial extension to announce color matrix here ;-) */ this->headsize = sprintf (p, - "YUV4MPEG2 W%d H%d F25:1 Ip A0:0 C420mpeg2 XYSCSS=420MPEG2\n", width, height); - p += 74; + "YUV4MPEG2 W%d H%d F25:1 Ip A0:0 C420mpeg2 XYSCSS=420MPEG2 XXINE_CM=%d\n", + width, height, (hdtv ? 2 : 10) | !mpeg); + p += 82; this->y4m_frame = p; memcpy (p, "FRAME\n", 6); this->framesize = 6 + width * height * 3 / 2; diff --git a/src/video_dec/yuv.c b/src/video_dec/yuv.c index db7d01d91..91f8ed2b8 100644 --- a/src/video_dec/yuv.c +++ b/src/video_dec/yuv.c @@ -65,6 +65,7 @@ typedef struct yuv_decoder_s { int progressive; int top_field_first; + int color_matrix; } yuv_decoder_t; @@ -108,6 +109,8 @@ static void yuv_decode_data (video_decoder_t *this_gen, this->progressive = buf->decoder_info[3]; this->top_field_first = buf->decoder_info[4]; + this->color_matrix = 4; /* undefined, mpeg range */ + free (this->buf); this->buf = NULL; @@ -180,6 +183,9 @@ static void yuv_decode_data (video_decoder_t *this_gen, src = this->buf; } + if (buf->decoder_flags & BUF_FLAG_COLOR_MATRIX) + this->color_matrix = buf->decoder_info[4]; + if (buf->decoder_flags & BUF_FLAG_FRAME_END) { if (buf->type == BUF_VIDEO_YUY2) { @@ -281,7 +287,7 @@ static void yuv_decode_data (video_decoder_t *this_gen, } - VO_SET_FLAGS_CM (this->height >= 720 ? 2 : 10, img->flags); + VO_SET_FLAGS_CM (this->color_matrix, img->flags); img->duration = this->video_step; img->pts = buf->pts; -- cgit v1.2.3