Commit 6a796df0 authored by François Cartegnie's avatar François Cartegnie 🤞

packetizer: hxxx: store prefixed in both and fix double prefix

generated double prefix in h264 extra in prev commit
parent d29d1440
...@@ -246,16 +246,14 @@ static void ActivateSets( decoder_t *p_dec, const h264_sequence_parameter_set_t ...@@ -246,16 +246,14 @@ static void ActivateSets( decoder_t *p_dec, const h264_sequence_parameter_set_t
if( p_spsblock && p_ppsblock ) if( p_spsblock && p_ppsblock )
{ {
size_t i_alloc = p_ppsblock->i_buffer + p_spsblock->i_buffer + 8; size_t i_alloc = p_ppsblock->i_buffer + p_spsblock->i_buffer;
p_dec->fmt_out.p_extra = malloc( i_alloc ); p_dec->fmt_out.p_extra = malloc( i_alloc );
if( p_dec->fmt_out.p_extra ) if( p_dec->fmt_out.p_extra )
{ {
uint8_t*p_buf = p_dec->fmt_out.p_extra; uint8_t*p_buf = p_dec->fmt_out.p_extra;
p_dec->fmt_out.i_extra = i_alloc; p_dec->fmt_out.i_extra = i_alloc;
memcpy( &p_buf[0], annexb_startcode4, 4 ); memcpy( &p_buf[0], p_spsblock->p_buffer, p_spsblock->i_buffer );
memcpy( &p_buf[4], p_spsblock->p_buffer, p_spsblock->i_buffer ); memcpy( &p_buf[p_spsblock->i_buffer], p_ppsblock->p_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 ); p_ppsblock->i_buffer );
} }
} }
......
...@@ -430,12 +430,6 @@ static bool InsertXPS(decoder_t *p_dec, uint8_t i_nal_type, uint8_t i_id, ...@@ -430,12 +430,6 @@ static bool InsertXPS(decoder_t *p_dec, uint8_t i_nal_type, uint8_t i_id,
} }
*pp_nal = block_Duplicate((block_t *)p_nalb); *pp_nal = block_Duplicate((block_t *)p_nalb);
if(*pp_nal)
{
size_t off = p_nalb->i_buffer - i_buffer;
(*pp_nal)->p_buffer += off;
(*pp_nal)->i_buffer -= off;
}
return true; return true;
} }
...@@ -466,16 +460,14 @@ static bool XPSReady(decoder_sys_t *p_sys) ...@@ -466,16 +460,14 @@ static bool XPSReady(decoder_sys_t *p_sys)
static void AppendAsAnnexB(const block_t *p_block, static void AppendAsAnnexB(const block_t *p_block,
uint8_t **pp_dst, size_t *pi_dst) uint8_t **pp_dst, size_t *pi_dst)
{ {
if(SIZE_MAX - p_block->i_buffer < *pi_dst || if(SIZE_MAX - p_block->i_buffer < *pi_dst )
SIZE_MAX - 4 < *pi_dst + p_block->i_buffer)
return; return;
size_t i_realloc = p_block->i_buffer + 4 + *pi_dst; size_t i_realloc = p_block->i_buffer + *pi_dst;
uint8_t *p_realloc = realloc(*pp_dst, i_realloc); uint8_t *p_realloc = realloc(*pp_dst, i_realloc);
if(p_realloc) if(p_realloc)
{ {
memcpy(&p_realloc[*pi_dst], annexb_startcode4, 4); memcpy(&p_realloc[*pi_dst], p_block->p_buffer, p_block->i_buffer);
memcpy(&p_realloc[*pi_dst + 4], p_block->p_buffer, p_block->i_buffer);
*pi_dst = i_realloc; *pi_dst = i_realloc;
*pp_dst = p_realloc; *pp_dst = p_realloc;
} }
......
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