media: h264: Sort p/b reflist using frame_num
In the reference list builder, frame_num refers to FrameNumWrap in the spec, which is the same as the pic_num for frame decoding. The same applies for long_term_pic_num and long_term_frame_idx. Sort all type of references by frame_num so the sort can be reused for fields reflist were the sorting is done using frame_num instead. In short, pic_num is never actually used for building reference lists. Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com> Reviewed-by: Sebastian Fricke <sebastian.fricke@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
parent
d3f756ad62
commit
6cafdc8cc0
|
@ -56,7 +56,6 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
|
||||||
if (!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE))
|
if (!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
b->refs[i].pic_num = dpb[i].pic_num;
|
|
||||||
if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
|
if (dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM)
|
||||||
b->refs[i].longterm = true;
|
b->refs[i].longterm = true;
|
||||||
|
|
||||||
|
@ -145,15 +144,19 @@ static int v4l2_h264_p_ref_list_cmp(const void *ptra, const void *ptrb,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Short term pics in descending pic num order, long term ones in
|
* For frames, short term pics are in descending pic num order and long
|
||||||
* ascending order.
|
* term ones in ascending order. For fields, the same direction is used
|
||||||
|
* but with frame_num (wrapped). For frames, the value of pic_num and
|
||||||
|
* frame_num are the same (see formula (8-28) and (8-29)). For this
|
||||||
|
* reason we can use frame_num only and share this function between
|
||||||
|
* frames and fields reflist.
|
||||||
*/
|
*/
|
||||||
if (!builder->refs[idxa].longterm)
|
if (!builder->refs[idxa].longterm)
|
||||||
return builder->refs[idxb].frame_num <
|
return builder->refs[idxb].frame_num <
|
||||||
builder->refs[idxa].frame_num ?
|
builder->refs[idxa].frame_num ?
|
||||||
-1 : 1;
|
-1 : 1;
|
||||||
|
|
||||||
return builder->refs[idxa].pic_num < builder->refs[idxb].pic_num ?
|
return builder->refs[idxa].frame_num < builder->refs[idxb].frame_num ?
|
||||||
-1 : 1;
|
-1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,10 +182,10 @@ static int v4l2_h264_b0_ref_list_cmp(const void *ptra, const void *ptrb,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Long term pics in ascending pic num order. */
|
/* Long term pics in ascending frame num order. */
|
||||||
if (builder->refs[idxa].longterm)
|
if (builder->refs[idxa].longterm)
|
||||||
return builder->refs[idxa].pic_num <
|
return builder->refs[idxa].frame_num <
|
||||||
builder->refs[idxb].pic_num ?
|
builder->refs[idxb].frame_num ?
|
||||||
-1 : 1;
|
-1 : 1;
|
||||||
|
|
||||||
poca = v4l2_h264_get_poc(builder, ptra);
|
poca = v4l2_h264_get_poc(builder, ptra);
|
||||||
|
@ -224,10 +227,10 @@ static int v4l2_h264_b1_ref_list_cmp(const void *ptra, const void *ptrb,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Long term pics in ascending pic num order. */
|
/* Long term pics in ascending frame num order. */
|
||||||
if (builder->refs[idxa].longterm)
|
if (builder->refs[idxa].longterm)
|
||||||
return builder->refs[idxa].pic_num <
|
return builder->refs[idxa].frame_num <
|
||||||
builder->refs[idxb].pic_num ?
|
builder->refs[idxb].frame_num ?
|
||||||
-1 : 1;
|
-1 : 1;
|
||||||
|
|
||||||
poca = v4l2_h264_get_poc(builder, ptra);
|
poca = v4l2_h264_get_poc(builder, ptra);
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
* @refs.top_field_order_cnt: top field order count
|
* @refs.top_field_order_cnt: top field order count
|
||||||
* @refs.bottom_field_order_cnt: bottom field order count
|
* @refs.bottom_field_order_cnt: bottom field order count
|
||||||
* @refs.frame_num: reference frame number
|
* @refs.frame_num: reference frame number
|
||||||
* @refs.pic_num: reference picture number
|
|
||||||
* @refs.longterm: set to true for a long term reference
|
* @refs.longterm: set to true for a long term reference
|
||||||
* @refs: array of references
|
* @refs: array of references
|
||||||
* @cur_pic_order_count: picture order count of the frame being decoded
|
* @cur_pic_order_count: picture order count of the frame being decoded
|
||||||
|
@ -36,7 +35,6 @@ struct v4l2_h264_reflist_builder {
|
||||||
s32 top_field_order_cnt;
|
s32 top_field_order_cnt;
|
||||||
s32 bottom_field_order_cnt;
|
s32 bottom_field_order_cnt;
|
||||||
int frame_num;
|
int frame_num;
|
||||||
u32 pic_num;
|
|
||||||
u16 longterm : 1;
|
u16 longterm : 1;
|
||||||
} refs[V4L2_H264_NUM_DPB_ENTRIES];
|
} refs[V4L2_H264_NUM_DPB_ENTRIES];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue