Skip to content

Commit 3630e49

Browse files
Kwiboomchehab
authored andcommitted
media: hantro: h264: Make dpb entry management more robust
The driver maintains stable slot locations for reference pictures. This change makes the code more robust by using the reference_ts as key and by marking all entries invalid right from the start. Signed-off-by: Jonas Karlman <[email protected]> Signed-off-by: Nicolas Dufresne <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 8314107 commit 3630e49

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/staging/media/hantro/hantro_h264.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,7 @@ static void prepare_table(struct hantro_ctx *ctx)
258258
static bool dpb_entry_match(const struct v4l2_h264_dpb_entry *a,
259259
const struct v4l2_h264_dpb_entry *b)
260260
{
261-
return a->top_field_order_cnt == b->top_field_order_cnt &&
262-
a->bottom_field_order_cnt == b->bottom_field_order_cnt;
261+
return a->reference_ts == b->reference_ts;
263262
}
264263

265264
static void update_dpb(struct hantro_ctx *ctx)
@@ -273,13 +272,13 @@ static void update_dpb(struct hantro_ctx *ctx)
273272

274273
/* Disable all entries by default. */
275274
for (i = 0; i < ARRAY_SIZE(ctx->h264_dec.dpb); i++)
276-
ctx->h264_dec.dpb[i].flags &= ~V4L2_H264_DPB_ENTRY_FLAG_ACTIVE;
275+
ctx->h264_dec.dpb[i].flags = 0;
277276

278277
/* Try to match new DPB entries with existing ones by their POCs. */
279278
for (i = 0; i < ARRAY_SIZE(dec_param->dpb); i++) {
280279
const struct v4l2_h264_dpb_entry *ndpb = &dec_param->dpb[i];
281280

282-
if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE))
281+
if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_VALID))
283282
continue;
284283

285284
/*
@@ -290,8 +289,7 @@ static void update_dpb(struct hantro_ctx *ctx)
290289
struct v4l2_h264_dpb_entry *cdpb;
291290

292291
cdpb = &ctx->h264_dec.dpb[j];
293-
if (cdpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE ||
294-
!dpb_entry_match(cdpb, ndpb))
292+
if (!dpb_entry_match(cdpb, ndpb))
295293
continue;
296294

297295
*cdpb = *ndpb;

0 commit comments

Comments
 (0)