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

packetizer: h264: fix recovery point test

(cherry picked from commit 910d0112)
parent e8e25425
...@@ -114,6 +114,7 @@ struct decoder_sys_t ...@@ -114,6 +114,7 @@ struct decoder_sys_t
int i_next_block_flags; int i_next_block_flags;
bool b_recovered; bool b_recovered;
unsigned i_recoveryfnum; unsigned i_recoveryfnum;
unsigned i_recoverystartfnum;
/* POC */ /* POC */
h264_poc_context_t pocctx; h264_poc_context_t pocctx;
...@@ -789,6 +790,7 @@ static block_t *OutputPicture( decoder_t *p_dec ) ...@@ -789,6 +790,7 @@ static block_t *OutputPicture( decoder_t *p_dec )
p_sys->i_recoveryfnum == UINT_MAX ) p_sys->i_recoveryfnum == UINT_MAX )
{ {
p_sys->i_recoveryfnum = p_sys->slice.i_frame_num + p_sys->i_recovery_frame_cnt; p_sys->i_recoveryfnum = p_sys->slice.i_frame_num + p_sys->i_recovery_frame_cnt;
p_sys->i_recoverystartfnum = p_sys->slice.i_frame_num;
b_need_sps_pps = true; /* SPS/PPS must be inserted for SEI recovery */ b_need_sps_pps = true; /* SPS/PPS must be inserted for SEI recovery */
msg_Dbg( p_dec, "Recovering using SEI, prerolling %u reference pics", p_sys->i_recovery_frame_cnt ); msg_Dbg( p_dec, "Recovering using SEI, prerolling %u reference pics", p_sys->i_recovery_frame_cnt );
} }
...@@ -797,10 +799,12 @@ static block_t *OutputPicture( decoder_t *p_dec ) ...@@ -797,10 +799,12 @@ static block_t *OutputPicture( decoder_t *p_dec )
{ {
assert(p_sys->b_recovered == false); assert(p_sys->b_recovered == false);
const unsigned maxFrameNum = 1 << (p_sps->i_log2_max_frame_num + 4); const unsigned maxFrameNum = 1 << (p_sps->i_log2_max_frame_num + 4);
if( (p_sys->i_recoveryfnum > maxFrameNum &&
(unsigned)p_sys->slice.i_frame_num <= maxFrameNum / 2 && if( ( p_sys->i_recoveryfnum > maxFrameNum &&
(unsigned)p_sys->slice.i_frame_num >= p_sys->i_recoveryfnum % maxFrameNum ) || p_sys->slice.i_frame_num < p_sys->i_recoverystartfnum &&
(unsigned)p_sys->slice.i_frame_num >= p_sys->i_recoveryfnum ) p_sys->slice.i_frame_num >= p_sys->i_recoveryfnum % maxFrameNum ) ||
( p_sys->i_recoveryfnum <= maxFrameNum &&
p_sys->slice.i_frame_num >= p_sys->i_recoveryfnum ) )
{ {
p_sys->i_recoveryfnum = UINT_MAX; p_sys->i_recoveryfnum = UINT_MAX;
p_sys->b_recovered = true; p_sys->b_recovered = true;
......
...@@ -270,7 +270,7 @@ void h264_compute_poc( const h264_sequence_parameter_set_t *p_sps, ...@@ -270,7 +270,7 @@ void h264_compute_poc( const h264_sequence_parameter_set_t *p_sps,
if( p_slice->i_nal_type == H264_NAL_SLICE_IDR ) if( p_slice->i_nal_type == H264_NAL_SLICE_IDR )
frameNumOffset = 0; frameNumOffset = 0;
else if( p_ctx->prevFrameNum > (unsigned) p_slice->i_frame_num ) else if( p_ctx->prevFrameNum > p_slice->i_frame_num )
frameNumOffset = p_ctx->prevFrameNumOffset + maxFrameNum; frameNumOffset = p_ctx->prevFrameNumOffset + maxFrameNum;
else else
frameNumOffset = p_ctx->prevFrameNumOffset; frameNumOffset = p_ctx->prevFrameNumOffset;
......
...@@ -37,7 +37,7 @@ typedef struct ...@@ -37,7 +37,7 @@ typedef struct
enum h264_slice_type_e type; enum h264_slice_type_e type;
int i_pic_parameter_set_id; int i_pic_parameter_set_id;
int i_frame_num; unsigned i_frame_num;
int i_field_pic_flag; int i_field_pic_flag;
int i_bottom_field_flag; int i_bottom_field_flag;
...@@ -59,7 +59,7 @@ static inline void h264_slice_init( h264_slice_t *p_slice ) ...@@ -59,7 +59,7 @@ static inline void h264_slice_init( h264_slice_t *p_slice )
p_slice->i_nal_type = -1; p_slice->i_nal_type = -1;
p_slice->i_nal_ref_idc = -1; p_slice->i_nal_ref_idc = -1;
p_slice->i_idr_pic_id = -1; p_slice->i_idr_pic_id = -1;
p_slice->i_frame_num = -1; p_slice->i_frame_num = 0;
p_slice->type = H264_SLICE_TYPE_UNKNOWN; p_slice->type = H264_SLICE_TYPE_UNKNOWN;
p_slice->i_pic_parameter_set_id = -1; p_slice->i_pic_parameter_set_id = -1;
p_slice->i_field_pic_flag = 0; p_slice->i_field_pic_flag = 0;
......
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