Commit 986ba8fe authored by Laurent Aimar's avatar Laurent Aimar

Fixed SPS/PPS transmissions in H264 packetizer.

It closes the other part of #3161.
parent 26ae73ad
...@@ -93,6 +93,8 @@ struct decoder_sys_t ...@@ -93,6 +93,8 @@ struct decoder_sys_t
/* */ /* */
bool b_slice; bool b_slice;
block_t *p_frame; block_t *p_frame;
bool b_frame_sps;
bool b_frame_pps;
bool b_header; bool b_header;
bool b_sps; bool b_sps;
...@@ -205,6 +207,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -205,6 +207,9 @@ static int Open( vlc_object_t *p_this )
p_sys->b_slice = false; p_sys->b_slice = false;
p_sys->p_frame = NULL; p_sys->p_frame = NULL;
p_sys->b_frame_sps = false;
p_sys->b_frame_pps = false;
p_sys->b_header= false; p_sys->b_header= false;
p_sys->b_sps = false; p_sys->b_sps = false;
p_sys->b_pps = false; p_sys->b_pps = false;
...@@ -502,6 +507,8 @@ static void PacketizeReset( void *p_private, bool b_broken ) ...@@ -502,6 +507,8 @@ static void PacketizeReset( void *p_private, bool b_broken )
if( p_sys->p_frame ) if( p_sys->p_frame )
block_ChainRelease( p_sys->p_frame ); block_ChainRelease( p_sys->p_frame );
p_sys->p_frame = NULL; p_sys->p_frame = NULL;
p_sys->b_frame_sps = false;
p_sys->b_frame_pps = false;
p_sys->slice.i_frame_type = 0; p_sys->slice.i_frame_type = 0;
p_sys->b_slice = false; p_sys->b_slice = false;
} }
...@@ -612,6 +619,8 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_used_ts, block_t *p_fr ...@@ -612,6 +619,8 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_used_ts, block_t *p_fr
/* Reset context */ /* Reset context */
p_sys->slice.i_frame_type = 0; p_sys->slice.i_frame_type = 0;
p_sys->p_frame = NULL; p_sys->p_frame = NULL;
p_sys->b_frame_sps = false;
p_sys->b_frame_pps = false;
p_sys->b_slice = false; p_sys->b_slice = false;
cc_Flush( &p_sys->cc_next ); cc_Flush( &p_sys->cc_next );
} }
...@@ -641,6 +650,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_used_ts, block_t *p_fr ...@@ -641,6 +650,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_used_ts, block_t *p_fr
{ {
if( p_sys->b_slice ) if( p_sys->b_slice )
p_pic = OutputPicture( p_dec ); p_pic = OutputPicture( p_dec );
p_sys->b_frame_sps = true;
PutSPS( p_dec, p_frag ); PutSPS( p_dec, p_frag );
...@@ -651,6 +661,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_used_ts, block_t *p_fr ...@@ -651,6 +661,7 @@ static block_t *ParseNALBlock( decoder_t *p_dec, bool *pb_used_ts, block_t *p_fr
{ {
if( p_sys->b_slice ) if( p_sys->b_slice )
p_pic = OutputPicture( p_dec ); p_pic = OutputPicture( p_dec );
p_sys->b_frame_pps = true;
PutPPS( p_dec, p_frag ); PutPPS( p_dec, p_frag );
...@@ -706,7 +717,10 @@ static block_t *OutputPicture( decoder_t *p_dec ) ...@@ -706,7 +717,10 @@ static block_t *OutputPicture( decoder_t *p_dec )
if( !p_sys->b_header && p_sys->slice.i_frame_type != BLOCK_FLAG_TYPE_I) if( !p_sys->b_header && p_sys->slice.i_frame_type != BLOCK_FLAG_TYPE_I)
return NULL; return NULL;
if( p_sys->slice.i_frame_type == BLOCK_FLAG_TYPE_I && p_sys->b_sps && p_sys->b_pps ) const bool b_sps_pps_i = p_sys->slice.i_frame_type == BLOCK_FLAG_TYPE_I &&
p_sys->b_sps &&
p_sys->b_pps;
if( b_sps_pps_i || p_sys->b_frame_sps || p_sys->b_frame_pps )
{ {
block_t *p_head = NULL; block_t *p_head = NULL;
if( p_sys->p_frame->i_flags & BLOCK_FLAG_PRIVATE_AUD ) if( p_sys->p_frame->i_flags & BLOCK_FLAG_PRIVATE_AUD )
...@@ -716,17 +730,17 @@ static block_t *OutputPicture( decoder_t *p_dec ) ...@@ -716,17 +730,17 @@ static block_t *OutputPicture( decoder_t *p_dec )
} }
block_t *p_list = NULL; block_t *p_list = NULL;
for( int i = 0; i < SPS_MAX; i++ ) for( int i = 0; i < SPS_MAX && (b_sps_pps_i || p_sys->b_frame_sps); i++ )
{ {
if( p_sys->pp_sps[i] ) if( p_sys->pp_sps[i] )
block_ChainAppend( &p_list, block_Duplicate( p_sys->pp_sps[i] ) ); block_ChainAppend( &p_list, block_Duplicate( p_sys->pp_sps[i] ) );
} }
for( int i = 0; i < PPS_MAX; i++ ) for( int i = 0; i < PPS_MAX && (b_sps_pps_i || p_sys->b_frame_pps); i++ )
{ {
if( p_sys->pp_pps[i] ) if( p_sys->pp_pps[i] )
block_ChainAppend( &p_list, block_Duplicate( p_sys->pp_pps[i] ) ); block_ChainAppend( &p_list, block_Duplicate( p_sys->pp_pps[i] ) );
} }
if( p_list ) if( b_sps_pps_i && p_list )
p_sys->b_header = true; p_sys->b_header = true;
if( p_head ) if( p_head )
...@@ -751,6 +765,8 @@ static block_t *OutputPicture( decoder_t *p_dec ) ...@@ -751,6 +765,8 @@ static block_t *OutputPicture( decoder_t *p_dec )
p_sys->p_frame = NULL; p_sys->p_frame = NULL;
p_sys->i_frame_dts = VLC_TS_INVALID; p_sys->i_frame_dts = VLC_TS_INVALID;
p_sys->i_frame_pts = VLC_TS_INVALID; p_sys->i_frame_pts = VLC_TS_INVALID;
p_sys->b_frame_sps = false;
p_sys->b_frame_pps = false;
p_sys->b_slice = false; p_sys->b_slice = false;
/* CC */ /* CC */
......
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