Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp666019pxb; Tue, 5 Apr 2022 17:57:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy96H7dSuoWh/+C5haH2x+jrq/f32xvknpAa2ti8EZzlBCEN2TZn1vYKdqZlL/JfOkQcYqq X-Received: by 2002:a17:907:7f8c:b0:6e0:614f:f13e with SMTP id qk12-20020a1709077f8c00b006e0614ff13emr6058093ejc.488.1649206659079; Tue, 05 Apr 2022 17:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206659; cv=none; d=google.com; s=arc-20160816; b=E1C1DVruo8pO9YEGlUVbhMLFTlGE/HBmZ7VyTZyTTe0Tr3fWkb+gAAKXW4OPKI0poe NCK/9VJeGXPAFZAK6VtLAtKyYRsQ6vSM1kzo4vXCoFI0xXdUVTOT98vOpSqQaIpZyxY5 7b6n3asCuznkIrA5PuS1DVeepTY6+F01yhCHdMNYhfpg1CTtj2UvY2W+FuUQNHWvCHdk 3mHzWcX8xIJs3jAb8vzuaJOjynSzZt2l2px4ZnriBxFkgi37Bui5BD9qfCnKoTTTy2jh 27SlXQqJ1of7I1se7o4TsaiBDCxHimu1mkVULvqu9mZ92VNeR8UnUd+fw+Q9qu/9SIQ+ uNYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=y/5DMQisangzE8Vfbb0GDbRxo/2CIHtGpuF1KKVEsfg=; b=OLsxvzzVxubFk9tWRYC29TeqLuSgcnccb4Br1QzcJI6qFHZcneCpyejEPUfZYNhhQG qsz6OmtpymPGbARJCp1Qyqhig3H6llZGlr6jOSqMokVMspMm9ST/tBW2nvybIB4IoV6y f7wUf4pQY28aw6KEN3mx2uOxRh5WAKU60lYAPbApk6NBJ+TqSmuHvHytnpJhXJZF75mc 4Uu1t2Ukuti/34xGRazC09FdHLvCl8tkO0KLRZbfEscGa6Plp41DBKaBUHnKsVyxqIMp uj8d9KwSEXL6wlK3sFhZ+hXyomyHmY2PlaF7cVrqqIQtLpwtvpk8yhaFyrfjMdW/rqHd BfAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l7bI+vEM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v13-20020a1709061dcd00b006df76385ec0si10762736ejh.864.2022.04.05.17.57.12; Tue, 05 Apr 2022 17:57:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l7bI+vEM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236099AbiDEIQ1 (ORCPT + 99 others); Tue, 5 Apr 2022 04:16:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235552AbiDEH7v (ORCPT ); Tue, 5 Apr 2022 03:59:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E9D63FBF7; Tue, 5 Apr 2022 00:55:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CF68E615CD; Tue, 5 Apr 2022 07:55:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4220C340EE; Tue, 5 Apr 2022 07:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145328; bh=zU+CWYBYU/8pJUNeNTS9RmWcQvumA7Jb/SBfIxAI/3I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l7bI+vEMcXxCu5wuspnoxZgFUsUPtndkDMSqrzvVoljeR4bxQP82LQsK7jjc0vdXS As3mnTSxBSBxAtuRexe3nbXwj7ZLVwuwTPuMOXea0YMWQiZlzdxzDDn4PnrdF02Sf1 1N1/WSXxR9iJFjRw8WW+gX6jUoSBd0V2BdaT22uk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Dufresne , AngeloGioacchino Del Regno , Hans Verkuil , Sasha Levin Subject: [PATCH 5.17 0365/1126] media: v4l2-core: Initialize h264 scaling matrix Date: Tue, 5 Apr 2022 09:18:32 +0200 Message-Id: <20220405070418.341509882@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nicolas Dufresne [ Upstream commit 0f6146d476fc99862899e70f2554ee77b444b7b9 ] In the final H264 API, it is not required to set scaling matrix if they are not present in the bitstream. A flag was added in order to let the driver know. The downside is that it leaves the default control value to 0, which isn't valid. As per the spec (see formulas 7-8/7-9), when the scaling matrix are absent from the bitstream, flat values of 16 should be used. This improves this control semantic in a way that the control value are always valid. Drivers can then use the scaling_matrix control values without having to check its presence. Same method was employed for MPEG2_QUANTISATION. This fixes issues with MTK VCODEC H264 decoder when using GStreamer. GStreamer does not set this control if its not present in the bitstream. As MTK VDCODEC was using the initialized to 0 values, the frames ended up completely gray. Fixes: 54889c51b833d236 ("media: uapi: h264: Rename and clarify PPS_FLAG_SCALING_MATRIX_PRESENT") Signed-off-by: Nicolas Dufresne Tested-by: AngeloGioacchino Del Regno Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/v4l2-core/v4l2-ctrls-core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls-core.c b/drivers/media/v4l2-core/v4l2-ctrls-core.c index b25c77b8a445..df8cff47a7fb 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -114,6 +114,7 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, struct v4l2_ctrl_vp8_frame *p_vp8_frame; struct v4l2_ctrl_vp9_frame *p_vp9_frame; struct v4l2_ctrl_fwht_params *p_fwht_params; + struct v4l2_ctrl_h264_scaling_matrix *p_h264_scaling_matrix; void *p = ptr.p + idx * ctrl->elem_size; if (ctrl->p_def.p_const) @@ -168,6 +169,15 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, p_fwht_params->flags = V4L2_FWHT_FL_PIXENC_YUV | (2 << V4L2_FWHT_FL_COMPONENTS_NUM_OFFSET); break; + case V4L2_CTRL_TYPE_H264_SCALING_MATRIX: + p_h264_scaling_matrix = p; + /* + * The default (flat) H.264 scaling matrix when none are + * specified in the bitstream, this is according to formulas + * (7-8) and (7-9) of the specification. + */ + memset(p_h264_scaling_matrix, 16, sizeof(*p_h264_scaling_matrix)); + break; } } -- 2.34.1