Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: hantro: Use H264_SCALING_MATRIX only when required

Baseline, Main and Extended profiles are specified to
not support a scaling matrix. Also, High profiles
can optionally specify a scaling matrix, using
SPS and PPS NAL units.

To meet this expectation, applications are required to
set the V4L2_CID_MPEG_VIDEO_H264_SCALING_MATRIX control
and set the V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT
flag only when a scaling matrix is specified for a picture.

Implement this on hantro, which has hardware support for this
case.

Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
Tested-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Ezequiel Garcia and committed by
Mauro Carvalho Chehab
e6de6b3f fd902918

+6 -3
+2 -3
drivers/staging/media/hantro/hantro_g1_h264_dec.c
··· 59 59 reg = G1_REG_DEC_CTRL2_CH_QP_OFFSET(pps->chroma_qp_index_offset) | 60 60 G1_REG_DEC_CTRL2_CH_QP_OFFSET2(pps->second_chroma_qp_index_offset); 61 61 62 - /* always use the matrix sent from userspace */ 63 - reg |= G1_REG_DEC_CTRL2_TYPE1_QUANT_E; 64 - 62 + if (pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT) 63 + reg |= G1_REG_DEC_CTRL2_TYPE1_QUANT_E; 65 64 if (!(sps->flags & V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY)) 66 65 reg |= G1_REG_DEC_CTRL2_FIELDPIC_FLAG_E; 67 66 vdpu_write_relaxed(vpu, reg, G1_REG_DEC_CTRL2);
+4
drivers/staging/media/hantro/hantro_h264.c
··· 197 197 { 198 198 const struct hantro_h264_dec_ctrls *ctrls = &ctx->h264_dec.ctrls; 199 199 const struct v4l2_ctrl_h264_scaling_matrix *scaling = ctrls->scaling; 200 + const struct v4l2_ctrl_h264_pps *pps = ctrls->pps; 200 201 const size_t num_list_4x4 = ARRAY_SIZE(scaling->scaling_list_4x4); 201 202 const size_t list_len_4x4 = ARRAY_SIZE(scaling->scaling_list_4x4[0]); 202 203 const size_t list_len_8x8 = ARRAY_SIZE(scaling->scaling_list_8x8[0]); ··· 205 204 u32 *dst = (u32 *)tbl->scaling_list; 206 205 const u32 *src; 207 206 int i, j; 207 + 208 + if (!(pps->flags & V4L2_H264_PPS_FLAG_SCALING_MATRIX_PRESENT)) 209 + return; 208 210 209 211 for (i = 0; i < num_list_4x4; i++) { 210 212 src = (u32 *)&scaling->scaling_list_4x4[i];