1 From 9b0eddfd7341525e0e3074a7f6202f5ccd431b05 Mon Sep 17 00:00:00 2001
2 From: John Cox <jc@kynesim.co.uk>
3 Date: Thu, 6 May 2021 13:48:05 +0100
4 Subject: [PATCH] media: rpivid: Only create aux entries for H265 if
7 Only create aux entries of mv info for frames where that info might
8 be used by a later frame. This saves some memory bandwidth and
9 potentially some memory.
11 Signed-off-by: John Cox <jc@kynesim.co.uk>
13 drivers/staging/media/rpivid/rpivid_h265.c | 38 +++++++++++++---------
14 1 file changed, 23 insertions(+), 15 deletions(-)
16 --- a/drivers/staging/media/rpivid/rpivid_h265.c
17 +++ b/drivers/staging/media/rpivid/rpivid_h265.c
18 @@ -246,6 +246,8 @@ struct rpivid_dec_state {
20 unsigned int slice_idx;
21 bool slice_temporal_mvp; /* Slice flag but constant for frame */
25 // Temp vars per run - don't actually need to persist
27 @@ -1657,7 +1659,7 @@ static u32 mk_config2(const struct rpivi
29 if (sps->flags & V4L2_HEVC_SPS_FLAG_STRONG_INTRA_SMOOTHING_ENABLED)
31 - if (sps->flags & V4L2_HEVC_SPS_FLAG_SPS_TEMPORAL_MVP_ENABLED)
33 c |= BIT(15); /* Write motion vectors to external memory */
34 c |= (pps->log2_parallel_merge_level_minus2 + 2) << 16;
35 if (s->slice_temporal_mvp)
36 @@ -1669,6 +1671,14 @@ static u32 mk_config2(const struct rpivi
40 +static inline bool is_ref_unit_type(const unsigned int nal_unit_type)
43 + * True for 1, 3, 5, 7, 9, 11, 13, 15
45 + return (nal_unit_type & ~0xe) != 0;
48 static void rpivid_h265_setup(struct rpivid_ctx *ctx, struct rpivid_run *run)
50 struct rpivid_dev *const dev = ctx->dev;
51 @@ -1685,7 +1695,6 @@ static void rpivid_h265_setup(struct rpi
52 struct rpivid_dec_env *de = ctx->dec0;
57 bool slice_temporal_mvp;
59 @@ -1828,6 +1837,16 @@ static void rpivid_h265_setup(struct rpi
61 s->slice_temporal_mvp = slice_temporal_mvp;
64 + * Need Aux ents for all (ref) DPB ents if temporal MV could
65 + * be enabled for any pic
67 + s->use_aux = ((s->sps.flags &
68 + V4L2_HEVC_SPS_FLAG_SPS_TEMPORAL_MVP_ENABLED) != 0);
69 + s->mk_aux = s->use_aux &&
70 + (s->sps.sps_max_sub_layers_minus1 >= sh0->nuh_temporal_id_plus1 ||
71 + is_ref_unit_type(sh0->nal_unit_type));
73 // Phase 2 reg pre-calc
74 de->rpi_config2 = mk_config2(s);
75 de->rpi_framesize = (s->sps.pic_height_in_luma_samples << 16) |
76 @@ -1952,15 +1971,6 @@ static void rpivid_h265_setup(struct rpi
79 sizeof(*dpb_q_aux) * V4L2_HEVC_DPB_ENTRIES_NUM_MAX);
81 - * Need Aux ents for all (ref) DPB ents if temporal MV could
82 - * be enabled for any pic
83 - * ** At the moment we create aux ents for all pics whether or not
84 - * they are ref - they should then be discarded by the DPB-aux
85 - * garbage collection code
87 - use_aux = ((s->sps.flags &
88 - V4L2_HEVC_SPS_FLAG_SPS_TEMPORAL_MVP_ENABLED) != 0);
91 // At least in the current implementation this is constant across all
92 @@ -1994,7 +2004,7 @@ static void rpivid_h265_setup(struct rpi
98 dpb_q_aux[i] = aux_q_ref_idx(ctx, buffer_index);
100 v4l2_warn(&dev->v4l2_dev,
101 @@ -2016,9 +2026,7 @@ static void rpivid_h265_setup(struct rpi
103 aux_q_release(ctx, &s->frame_aux);
106 - // New frame so new aux ent
107 - // ??? Do we need this if non-ref ??? can we tell
109 s->frame_aux = aux_q_new(ctx, run->dst->vb2_buf.index);