lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <de7cc23f9d8b3f28dd69c1e0a029587d563a16b3.camel@collabora.com>
Date: Thu, 18 Apr 2024 16:33:36 -0400
From: Nicolas Dufresne <nicolas.dufresne@...labora.com>
To: Yunfei Dong <yunfei.dong@...iatek.com>, Nícolas "F .
 R . A . Prado" <nfraprado@...labora.com>, Hans Verkuil
 <hverkuil-cisco@...all.nl>, AngeloGioacchino Del Regno
 <angelogioacchino.delregno@...labora.com>, Benjamin Gaignard
 <benjamin.gaignard@...labora.com>, Nathan Hebert <nhebert@...omium.org>, 
 Sebastian Fricke <sebastian.fricke@...labora.com>
Cc: Hsin-Yi Wang <hsinyi@...omium.org>, Fritz Koenig
 <frkoenig@...omium.org>,  Daniel Vetter <daniel@...ll.ch>, Steve Cho
 <stevecho@...omium.org>, linux-media@...r.kernel.org, 
 devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-arm-kernel@...ts.infradead.org, linux-mediatek@...ts.infradead.org, 
 Project_Global_Chrome_Upstream_Group@...iatek.com
Subject: Re: [PATCH v2,5/5] media: mediatek: vcodec: fix incorrect
 sizeimage for 10bit bitstream

Le mardi 09 avril 2024 à 14:44 +0800, Yunfei Dong a écrit :
> The sizeimage of each plane is calculated the same way for 8bit and
> 10bit bitstream. Using v4l2 common interface v4l2_fill_pixfmt_mp to
> separate.
> 
> Fixes: 9d86be9bda6c ("media: mediatek: vcodec: Add driver to support 10bit")
> Signed-off-by: Yunfei Dong <yunfei.dong@...iatek.com>
> ---
>  .../mediatek/vcodec/decoder/mtk_vcodec_dec.c  | 28 ++++++-------------
>  1 file changed, 8 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
> index 9107707de6c4..fbfba69682ea 100644
> --- a/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
> +++ b/drivers/media/platform/mediatek/vcodec/decoder/mtk_vcodec_dec.c
> @@ -262,40 +262,28 @@ static int vidioc_try_fmt(struct mtk_vcodec_dec_ctx *ctx, struct v4l2_format *f,
>  		int tmp_w, tmp_h;
>  
>  		/*
> -		 * Find next closer width align 64, height align 64, size align
> -		 * 64 rectangle
> +		 * Find next closer width align 64, heign align 64, size align 64 rectangle
>  		 * Note: This only get default value, the real HW needed value
>  		 *       only available when ctx in MTK_STATE_HEADER state
>  		 */
>  		tmp_w = pix_fmt_mp->width;
>  		tmp_h = pix_fmt_mp->height;
> +
>  		v4l_bound_align_image(&pix_fmt_mp->width, MTK_VDEC_MIN_W, frmsize->max_width, 6,
>  				      &pix_fmt_mp->height, MTK_VDEC_MIN_H, frmsize->max_height, 6,
>  				      9);
>  
> -		if (pix_fmt_mp->width < tmp_w &&
> -		    (pix_fmt_mp->width + 64) <= frmsize->max_width)
> +		if (pix_fmt_mp->width < tmp_w && (pix_fmt_mp->width + 64) <= frmsize->max_width)
>  			pix_fmt_mp->width += 64;
> -		if (pix_fmt_mp->height < tmp_h &&
> -		    (pix_fmt_mp->height + 64) <= frmsize->max_height)
> +		if (pix_fmt_mp->height < tmp_h && (pix_fmt_mp->height + 64) <= frmsize->max_height)
>  			pix_fmt_mp->height += 64;

This seems overlay complicated, make sure your frmsize is valid (with
step_width/height set to 64 from your Mali requirement) and then simply call:

	v4l2_apply_frmsize_constraints(...)

All this hand written clamping code with hardcoded values should go away.

>  
> +		v4l2_fill_pixfmt_mp(pix_fmt_mp, fmt->fourcc, pix_fmt_mp->width, pix_fmt_mp->height);
>  		mtk_v4l2_vdec_dbg(0, ctx,
> -				  "before resize wxh=%dx%d, after resize wxh=%dx%d, sizeimage=%d",
> +				  "before resize:%dx%d, after resize:%dx%d, sizeimage=0x%x_0x%x",
>  				  tmp_w, tmp_h, pix_fmt_mp->width, pix_fmt_mp->height,
> -				  pix_fmt_mp->width * pix_fmt_mp->height);
> -
> -		pix_fmt_mp->num_planes = fmt->num_planes;
> -		pix_fmt_mp->plane_fmt[0].sizeimage =
> -				pix_fmt_mp->width * pix_fmt_mp->height;
> -		pix_fmt_mp->plane_fmt[0].bytesperline = pix_fmt_mp->width;
> -
> -		if (pix_fmt_mp->num_planes == 2) {
> -			pix_fmt_mp->plane_fmt[1].sizeimage =
> -				(pix_fmt_mp->width * pix_fmt_mp->height) / 2;
> -			pix_fmt_mp->plane_fmt[1].bytesperline =
> -				pix_fmt_mp->width;
> -		}
> +				  pix_fmt_mp->plane_fmt[0].sizeimage,
> +				  pix_fmt_mp->plane_fmt[1].sizeimage);
>  	}
>  
>  	pix_fmt_mp->flags = 0;


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ