Commit c64dd089 authored by François Cartegnie's avatar François Cartegnie 🤞

packetizer: h264: fill missing extradata on sets activation

avoids arbitratry configuration from annexb -> avc
parent 68fa58bc
......@@ -231,6 +231,35 @@ static void ActivateSets( decoder_t *p_dec, const h264_sequence_parameter_set_t
&p_dec->fmt_out.video.space,
&p_dec->fmt_out.video.b_color_range_full );
}
if( p_dec->fmt_out.i_extra == 0 && p_pps )
{
const block_t *p_spsblock = NULL;
const block_t *p_ppsblock = NULL;
for( size_t i=0; i<=H264_SPS_ID_MAX && !p_spsblock; i++ )
if( p_sps == p_sys->sps[i].p_sps )
p_spsblock = p_sys->sps[i].p_block;
for( size_t i=0; i<=H264_PPS_ID_MAX && !p_ppsblock; i++ )
if( p_pps == p_sys->pps[i].p_pps )
p_ppsblock = p_sys->pps[i].p_block;
if( p_spsblock && p_ppsblock )
{
size_t i_alloc = p_ppsblock->i_buffer + p_spsblock->i_buffer + 8;
p_dec->fmt_out.p_extra = malloc( i_alloc );
if( p_dec->fmt_out.p_extra )
{
uint8_t*p_buf = p_dec->fmt_out.p_extra;
p_dec->fmt_out.i_extra = i_alloc;
memcpy( &p_buf[0], annexb_startcode4, 4 );
memcpy( &p_buf[4], p_spsblock->p_buffer, p_spsblock->i_buffer );
memcpy( &p_buf[4 + p_spsblock->i_buffer], annexb_startcode4, 4 );
memcpy( &p_buf[8 + p_spsblock->i_buffer], p_ppsblock->p_buffer,
p_ppsblock->i_buffer );
}
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment