vlc | branch: master | Ilkka Ollakka <[email protected]> | Mon Apr 18 11:18:29 2016 +0300| [24ba5629bd3aae8e650883b54af3a9708bf4a39e] | committer: Ilkka Ollakka
packetizer: mpegvideo: parse color details if present > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=24ba5629bd3aae8e650883b54af3a9708bf4a39e --- modules/packetizer/mpegvideo.c | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/modules/packetizer/mpegvideo.c b/modules/packetizer/mpegvideo.c index 070a3aa..769a7b2 100644 --- a/modules/packetizer/mpegvideo.c +++ b/modules/packetizer/mpegvideo.c @@ -538,6 +538,66 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag ) p_sys->i_seq_old = 0; } } + else if( p_frag->p_buffer[3] == 0xb5 && p_frag->i_buffer >= 10 ) + { + /* Sequence display extension */ + bool contains_color_description = (p_frag->p_buffer[4] & 0x01); + //uint8_t video_format = (p_frag->p_buffer[4] & 0x0f) >> 1; + + if( contains_color_description ) + { + int8_t color_primaries = p_frag->p_buffer[5]; + int8_t color_transfer = p_frag->p_buffer[6]; + int8_t color_matrix = p_frag->p_buffer[7]; + switch( color_primaries ) + { + case 1: + p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT709; + break; + case 4: /* BT.470M */ + case 5: /* BT.470BG */ + p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT601_625; + break; + case 6: /* SMPTE 170M */ + case 7: /* SMPTE 240M */ + p_dec->fmt_out.video.primaries = COLOR_PRIMARIES_BT601_525; + break; + default: + break; + } + switch( color_transfer ) + { + case 1: + p_dec->fmt_out.video.transfer = TRANSFER_FUNC_BT709; + break; + case 4: /* BT.470M assumed gamma 2.2 */ + p_dec->fmt_out.video.transfer = TRANSFER_FUNC_SRGB; + break; + case 5: /* BT.470BG */ + case 6: /* SMPTE 170M */ + p_dec->fmt_out.video.transfer = TRANSFER_FUNC_BT2020; + break; + case 8: /* Linear */ + p_dec->fmt_out.video.transfer = TRANSFER_FUNC_LINEAR; + break; + default: + break; + } + switch( color_matrix ) + { + case 1: + p_dec->fmt_out.video.space = COLOR_SPACE_BT709; + break; + case 5: /* BT.470BG */ + case 6: /* SMPTE 170 M */ + p_dec->fmt_out.video.space = COLOR_SPACE_BT601; + break; + default: + break; + } + } + + } else if( p_frag->p_buffer[3] == 0xb3 && p_frag->i_buffer >= 8 ) { /* Sequence header code */ @@ -578,6 +638,7 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag ) p_sys->b_seq_progressive = true; p_sys->b_low_delay = true; + if ( !p_sys->b_inited ) { msg_Dbg( p_dec, "size %dx%d fps=%.3f", _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
