Commit e5991e1f authored by Nicolas Dufresne's avatar Nicolas Dufresne Committed by Mauro Carvalho Chehab

media: h264: Store all fields into the unordered list

When the current picture is a field, store each field into the
unordered_list and preserve both top and bottom picture order
count.
Signed-off-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
Reviewed-by: default avatarSebastian Fricke <sebastian.fricke@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent adc8a8d6
...@@ -820,7 +820,7 @@ static int tegra_vde_h264_setup_frames(struct tegra_ctx *ctx, ...@@ -820,7 +820,7 @@ static int tegra_vde_h264_setup_frames(struct tegra_ctx *ctx,
if (err) if (err)
return err; return err;
if (b.refs[dpb_idx].pic_order_count < b.cur_pic_order_count) if (b.refs[dpb_idx].top_field_order_cnt < b.cur_pic_order_count)
h264->dpb_ref_frames_with_earlier_poc_nb++; h264->dpb_ref_frames_with_earlier_poc_nb++;
} }
......
...@@ -47,8 +47,6 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b, ...@@ -47,8 +47,6 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
} }
for (i = 0; i < V4L2_H264_NUM_DPB_ENTRIES; i++) { for (i = 0; i < V4L2_H264_NUM_DPB_ENTRIES; i++) {
u32 pic_order_count;
if (!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) if (!(dpb[i].flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE))
continue; continue;
...@@ -59,8 +57,6 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b, ...@@ -59,8 +57,6 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
/* /*
* Handle frame_num wraparound as described in section * Handle frame_num wraparound as described in section
* '8.2.4.1 Decoding process for picture numbers' of the spec. * '8.2.4.1 Decoding process for picture numbers' of the spec.
* TODO: This logic will have to be adjusted when we start
* supporting interlaced content.
* For long term references, frame_num is set to * For long term references, frame_num is set to
* long_term_frame_idx which requires no wrapping. * long_term_frame_idx which requires no wrapping.
*/ */
...@@ -70,24 +66,57 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b, ...@@ -70,24 +66,57 @@ v4l2_h264_init_reflist_builder(struct v4l2_h264_reflist_builder *b,
else else
b->refs[i].frame_num = dpb[i].frame_num; b->refs[i].frame_num = dpb[i].frame_num;
if (dpb[i].fields == V4L2_H264_FRAME_REF) b->refs[i].top_field_order_cnt = dpb[i].top_field_order_cnt;
pic_order_count = min(dpb[i].top_field_order_cnt, b->refs[i].bottom_field_order_cnt = dpb[i].bottom_field_order_cnt;
dpb[i].bottom_field_order_cnt);
else if (dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF) if (b->cur_pic_fields == V4L2_H264_FRAME_REF) {
pic_order_count = dpb[i].bottom_field_order_cnt; u8 fields = V4L2_H264_FRAME_REF;
else
pic_order_count = dpb[i].top_field_order_cnt; b->unordered_reflist[b->num_valid].index = i;
b->unordered_reflist[b->num_valid].fields = fields;
b->num_valid++;
continue;
}
if (dpb[i].fields & V4L2_H264_TOP_FIELD_REF) {
u8 fields = V4L2_H264_TOP_FIELD_REF;
b->unordered_reflist[b->num_valid].index = i;
b->unordered_reflist[b->num_valid].fields = fields;
b->num_valid++;
}
if (dpb[i].fields & V4L2_H264_BOTTOM_FIELD_REF) {
u8 fields = V4L2_H264_BOTTOM_FIELD_REF;
b->refs[i].pic_order_count = pic_order_count;
b->unordered_reflist[b->num_valid].index = i; b->unordered_reflist[b->num_valid].index = i;
b->unordered_reflist[b->num_valid].fields = fields;
b->num_valid++; b->num_valid++;
} }
}
for (i = b->num_valid; i < ARRAY_SIZE(b->unordered_reflist); i++) for (i = b->num_valid; i < ARRAY_SIZE(b->unordered_reflist); i++)
b->unordered_reflist[i].index = i; b->unordered_reflist[i].index = i;
} }
EXPORT_SYMBOL_GPL(v4l2_h264_init_reflist_builder); EXPORT_SYMBOL_GPL(v4l2_h264_init_reflist_builder);
static s32 v4l2_h264_get_poc(const struct v4l2_h264_reflist_builder *b,
const struct v4l2_h264_reference *ref)
{
switch (ref->fields) {
case V4L2_H264_FRAME_REF:
return min(b->refs[ref->index].top_field_order_cnt,
b->refs[ref->index].bottom_field_order_cnt);
case V4L2_H264_TOP_FIELD_REF:
return b->refs[ref->index].top_field_order_cnt;
case V4L2_H264_BOTTOM_FIELD_REF:
return b->refs[ref->index].bottom_field_order_cnt;
}
/* not reached */
return 0;
}
static int v4l2_h264_p_ref_list_cmp(const void *ptra, const void *ptrb, static int v4l2_h264_p_ref_list_cmp(const void *ptra, const void *ptrb,
const void *data) const void *data)
{ {
...@@ -150,8 +179,8 @@ static int v4l2_h264_b0_ref_list_cmp(const void *ptra, const void *ptrb, ...@@ -150,8 +179,8 @@ static int v4l2_h264_b0_ref_list_cmp(const void *ptra, const void *ptrb,
builder->refs[idxb].pic_num ? builder->refs[idxb].pic_num ?
-1 : 1; -1 : 1;
poca = builder->refs[idxa].pic_order_count; poca = v4l2_h264_get_poc(builder, ptra);
pocb = builder->refs[idxb].pic_order_count; pocb = v4l2_h264_get_poc(builder, ptrb);
/* /*
* Short term pics with POC < cur POC first in POC descending order * Short term pics with POC < cur POC first in POC descending order
...@@ -195,8 +224,8 @@ static int v4l2_h264_b1_ref_list_cmp(const void *ptra, const void *ptrb, ...@@ -195,8 +224,8 @@ static int v4l2_h264_b1_ref_list_cmp(const void *ptra, const void *ptrb,
builder->refs[idxb].pic_num ? builder->refs[idxb].pic_num ?
-1 : 1; -1 : 1;
poca = builder->refs[idxa].pic_order_count; poca = v4l2_h264_get_poc(builder, ptra);
pocb = builder->refs[idxb].pic_order_count; pocb = v4l2_h264_get_poc(builder, ptrb);
/* /*
* Short term pics with POC > cur POC first in POC ascending order * Short term pics with POC > cur POC first in POC ascending order
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
/** /**
* struct v4l2_h264_reflist_builder - Reference list builder object * struct v4l2_h264_reflist_builder - Reference list builder object
* *
* @refs.pic_order_count: reference picture order count * @refs.top_field_order_cnt: top 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.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
...@@ -32,7 +33,8 @@ ...@@ -32,7 +33,8 @@
*/ */
struct v4l2_h264_reflist_builder { struct v4l2_h264_reflist_builder {
struct { struct {
s32 pic_order_count; s32 top_field_order_cnt;
s32 bottom_field_order_cnt;
int frame_num; int frame_num;
u32 pic_num; u32 pic_num;
u16 longterm : 1; u16 longterm : 1;
......
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