Skip to content

Commit

Permalink
packetizer: mpegvideo: move colorspace checking to correct place
Browse files Browse the repository at this point in the history
This way we will parse sequence extensions and picture extensions also if they
happen to be in same fragment.

fixes #17212
  • Loading branch information
ilkka-ollakka committed Sep 30, 2016
1 parent 7126070 commit d9ea89a
Showing 1 changed file with 60 additions and 60 deletions.
120 changes: 60 additions & 60 deletions modules/packetizer/mpegvideo.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,66 +538,6 @@ 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 )
{
uint8_t color_primaries = p_frag->p_buffer[5];
uint8_t color_transfer = p_frag->p_buffer[6];
uint8_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 */
Expand Down Expand Up @@ -699,6 +639,66 @@ static block_t *ParseMPEGBlock( decoder_t *p_dec, block_t *p_frag )
p_sys->i_repeat_first_field= (p_frag->p_buffer[7]>>1)&0x01;
p_sys->i_progressive_frame = p_frag->p_buffer[8] >> 7;
}
if( 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 )
{
uint8_t color_primaries = p_frag->p_buffer[5];
uint8_t color_transfer = p_frag->p_buffer[6];
uint8_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] == 0xb2 && p_frag->i_buffer > 4 )
{
Expand Down

0 comments on commit d9ea89a

Please sign in to comment.