Skip to content
Snippets Groups Projects
Commit 3b1c3c37 authored by Jonas Karlman's avatar Jonas Karlman Committed by Nicolas Dufresne
Browse files

media: hantro: h264: Make dpb entry management more robust


The driver maintains stable slot location 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: default avatarJonas Karlman <jonas@kwiboo.se>
Signed-off-by: default avatarNicolas Dufresne <nicolas.dufresne@collabora.com>
parent 09f25df1
Branches
Tags
No related merge requests found
...@@ -258,8 +258,7 @@ static void prepare_table(struct hantro_ctx *ctx) ...@@ -258,8 +258,7 @@ static void prepare_table(struct hantro_ctx *ctx)
static bool dpb_entry_match(const struct v4l2_h264_dpb_entry *a, static bool dpb_entry_match(const struct v4l2_h264_dpb_entry *a,
const struct v4l2_h264_dpb_entry *b) const struct v4l2_h264_dpb_entry *b)
{ {
return a->top_field_order_cnt == b->top_field_order_cnt && return a->reference_ts == b->reference_ts;
a->bottom_field_order_cnt == b->bottom_field_order_cnt;
} }
static void update_dpb(struct hantro_ctx *ctx) static void update_dpb(struct hantro_ctx *ctx)
...@@ -273,13 +272,13 @@ static void update_dpb(struct hantro_ctx *ctx) ...@@ -273,13 +272,13 @@ static void update_dpb(struct hantro_ctx *ctx)
/* Disable all entries by default. */ /* Disable all entries by default. */
for (i = 0; i < ARRAY_SIZE(ctx->h264_dec.dpb); i++) for (i = 0; i < ARRAY_SIZE(ctx->h264_dec.dpb); i++)
ctx->h264_dec.dpb[i].flags &= ~V4L2_H264_DPB_ENTRY_FLAG_ACTIVE; ctx->h264_dec.dpb[i].flags = 0;
/* Try to match new DPB entries with existing ones by their POCs. */ /* Try to match new DPB entries with existing ones by their POCs. */
for (i = 0; i < ARRAY_SIZE(dec_param->dpb); i++) { for (i = 0; i < ARRAY_SIZE(dec_param->dpb); i++) {
const struct v4l2_h264_dpb_entry *ndpb = &dec_param->dpb[i]; const struct v4l2_h264_dpb_entry *ndpb = &dec_param->dpb[i];
if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) if (!(ndpb->flags & V4L2_H264_DPB_ENTRY_FLAG_VALID))
continue; continue;
/* /*
...@@ -290,8 +289,7 @@ static void update_dpb(struct hantro_ctx *ctx) ...@@ -290,8 +289,7 @@ static void update_dpb(struct hantro_ctx *ctx)
struct v4l2_h264_dpb_entry *cdpb; struct v4l2_h264_dpb_entry *cdpb;
cdpb = &ctx->h264_dec.dpb[j]; cdpb = &ctx->h264_dec.dpb[j];
if (cdpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE || if (!dpb_entry_match(cdpb, ndpb))
!dpb_entry_match(cdpb, ndpb))
continue; continue;
*cdpb = *ndpb; *cdpb = *ndpb;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment