From patchwork Sun Jun 9 08:25:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49725 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1911548vqo; Sun, 9 Jun 2024 01:25:26 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3vGJzyhB/HcSASvGngc43F/IuLLQcDFEW0NWIphal0Cf3CNsyL8sh9chcnwwBi+tziD+ETuWmAlT3WEGCidWVVgMBbGKk9O7+XA== X-Google-Smtp-Source: AGHT+IHNi4jiNMI4+WP/u/4+k7zCwdHWbYtDlNr/WiZ2qqEFQEgRA7e664azaqYSIOWInEseifzJ X-Received: by 2002:a17:906:f1ca:b0:a6e:7720:7e39 with SMTP id a640c23a62f3a-a6e772086a4mr402367666b.8.1717921526335; Sun, 09 Jun 2024 01:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717921526; cv=none; d=google.com; s=arc-20160816; b=QC5ZWYi0KNXozz3yF33m/3ChHKRNXqz38zGI5XEgppFPvMp8aDGANyLGVC0VsTX/Cm nLfjbEFCDmMly8KYE7YSD46No3onVZPft0uTJGd5zqoHsE8zcJI3p/EQEvvAXVn3gbYZ q5HSBxbOxj1n9++OP9xLwlWNkoiImRLbiUUAtoMCmj3SCAE16xqzXgBFH4i2N3piC7Y/ Pa1OooZ7JGDgpvW3wVPOJpw7Z57w2oxP6yOqf6+cDGDOVCYltuOhca5tujifnwZtEhcO bJXjhiUe7b4riWzx+mTLqPdM1CibGg6FdqHUZzTISzc3x3mcmZL8psYr3p4RTsG9ft6v gyqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=T3/lJ1r1DSz9bD7Q0y4dZwOaOxzwtOj12KcTKBM7Yp4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=q94oo8Qpymynva9JI2pVgDmbcc45QoJw+cZRxAegl1Fs9kw297pUC+n1e0fJiZg1qz T7Wt84T6QWf0prJmQLSwxTCLtko+i3fq9vKqR4SHjSGj8x/fv5zDsb8a4dykOTb/J5Js s2NjMzGZxTpfE2n/8RBcEC9Fu4LIsbObDZ/d3GMMUAEoPu1gX8+00TNIM2TKXUVaVnEp ohLso6cee4Oj/r3QX6YtxFhEdKPIKjn5GQcqXaOYq8l4un0HsVj5SBGkS6ZcjhsQMAKv w6VoJYWANwcej3NwpIBcOqONruQDADp/CxUdXUMMu8rvgn2VkleMHAI1nItYsJWKI8vT zVhQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-57aae0c6114si3604587a12.116.2024.06.09.01.25.25; Sun, 09 Jun 2024 01:25:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3A8E068D72B; Sun, 9 Jun 2024 11:25:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CCE2A68D6C0 for ; Sun, 9 Jun 2024 11:25:15 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 50608C006F for ; Sun, 9 Jun 2024 11:25:15 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Jun 2024 11:25:12 +0300 Message-ID: <20240609082515.1325134-1-remi@remlab.net> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] lavc/dnxhdenc: eliminate dead code X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VuV1rKszCfEV dct_quantize cannot be NULL here. The call to ff_dct_encode_init() would initialized it to a non-NULL value already. --- libavcodec/dnxhdenc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 0cb25d7714..681fb738c0 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -430,9 +430,6 @@ static av_cold int dnxhd_encode_init(AVCodecContext *avctx) if (ctx->profile != AV_PROFILE_DNXHD) ff_videodsp_init(&ctx->m.vdsp, ctx->bit_depth); - if (!ctx->m.dct_quantize) - ctx->m.dct_quantize = ff_dct_quantize_c; - if (ctx->is_444 || ctx->profile == AV_PROFILE_DNXHR_HQX) { ctx->m.dct_quantize = dnxhd_10bit_dct_quantize_444; ctx->get_pixels_8x4_sym = dnxhd_10bit_get_pixels_8x4_sym; From patchwork Sun Jun 9 08:25:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49726 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1911603vqo; Sun, 9 Jun 2024 01:25:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXsjPiWBh3IBj14H2kiZBurho2UFgW7WQKLcT1FqHyGTNw8S2ODgVtqwXNbK0fjUPR96nZ6SUial9P0qMcb9B08c7Z8QC726p25zA== X-Google-Smtp-Source: AGHT+IHRR+g/wzIUkatjNPich2cpKdnmJjvSj4gEGuf+2z2jVvdicpnk7lTedbGb+Upu7ck6k392 X-Received: by 2002:a17:906:8419:b0:a6f:1cf1:f13b with SMTP id a640c23a62f3a-a6f1cf1f395mr25578066b.61.1717921536267; Sun, 09 Jun 2024 01:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717921536; cv=none; d=google.com; s=arc-20160816; b=donpKmVUBKJMcrAcTI1dmh9HujReKbo1dMhTfF8v36KF+EuulWtPTHp8K46yIx92Sg NxAUnZsVbbX7OgbCEsq515UkxqPHYdca5Vu8Zq1HBuiv8tVruTxgiul298IvCU15xrv1 7aWwRvvVZzMitvB1//abntGvnlwlqDrjYKe/Sku8mMoyGJQ4BLzgH+hXbV83/kfHM/d9 XFpGMtMtaPxF/B9O2FROcEjvGBPEvPJtLdfoaFQHYHJ5tVLtOCSzl2beWDI8/Zkl69fu 5nR3UxFAzJRq3A95OhOezrUylAXvdiRkgFZO302RtvvVxtedG1QUNJL+MXdXqNn+wJnO zupQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=TpmctuK2MqwkwO2TJZgKy5tC2y/NLmJzFldlyfBv1nk=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=BOMAflGPfJxmM3CsAlX4gUcbA23fU62RqOLGOdSec8gN6UKsa3aec+EuGO2DQQq+GR Y/ELRaRCYFoqPsNbNyyth87pS09lXLl5BqL/lIbhO82x6todTMOP4G+Xn8qiCwYm9PA0 lNyhG3eIm2euJHe1IUP+uIDa3JZ7xQRB26HVjg721EtC90phoYSYn289jn/E40hbuzrl jb/IKDRqLSqUsnazjnOsLmCYYT1MGiwz4SofxVH1s5/cFQvh6T3saYAah0BDlbtmFizy a9wEOtZe1X4J/qja1shxbpDN0hqKfbE2ZwSSECSc8r21J438vKKz5XV1g/4s+FDtjusm QU9Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-57c6b0a4257si1503209a12.169.2024.06.09.01.25.35; Sun, 09 Jun 2024 01:25:36 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 74BC968D757; Sun, 9 Jun 2024 11:25:23 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1F90168D6C0 for ; Sun, 9 Jun 2024 11:25:16 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 85638C009A for ; Sun, 9 Jun 2024 11:25:15 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Jun 2024 11:25:13 +0300 Message-ID: <20240609082515.1325134-2-remi@remlab.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240609082515.1325134-1-remi@remlab.net> References: <20240609082515.1325134-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] lavc/mpvenc: reorder code X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: H9AeO5rxIXz5 No functional changes. --- libavcodec/mpegvideo_enc.c | 166 ++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 82bab43e14..dd92f0a3af 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -246,6 +246,89 @@ void ff_init_qscale_tab(MpegEncContext *s) } } +int ff_dct_quantize_c(MpegEncContext *s, + int16_t *block, int n, + int qscale, int *overflow) +{ + int i, j, level, last_non_zero, q, start_i; + const int *qmat; + const uint8_t *scantable; + int bias; + int max=0; + unsigned int threshold1, threshold2; + + s->fdsp.fdct(block); + + if(s->dct_error_sum) + s->denoise_dct(s, block); + + if (s->mb_intra) { + scantable= s->intra_scantable.scantable; + if (!s->h263_aic) { + if (n < 4) + q = s->y_dc_scale; + else + q = s->c_dc_scale; + q = q << 3; + } else + /* For AIC we skip quant/dequant of INTRADC */ + q = 1 << 3; + + /* note: block[0] is assumed to be positive */ + block[0] = (block[0] + (q >> 1)) / q; + start_i = 1; + last_non_zero = 0; + qmat = n < 4 ? s->q_intra_matrix[qscale] : s->q_chroma_intra_matrix[qscale]; + bias= s->intra_quant_bias*(1<<(QMAT_SHIFT - QUANT_BIAS_SHIFT)); + } else { + scantable= s->inter_scantable.scantable; + start_i = 0; + last_non_zero = -1; + qmat = s->q_inter_matrix[qscale]; + bias= s->inter_quant_bias*(1<<(QMAT_SHIFT - QUANT_BIAS_SHIFT)); + } + threshold1= (1<=start_i;i--) { + j = scantable[i]; + level = block[j] * qmat[j]; + + if(((unsigned)(level+threshold1))>threshold2){ + last_non_zero = i; + break; + }else{ + block[j]=0; + } + } + for(i=start_i; i<=last_non_zero; i++) { + j = scantable[i]; + level = block[j] * qmat[j]; + +// if( bias+level >= (1<= (1<threshold2){ + if(level>0){ + level= (bias + level)>>QMAT_SHIFT; + block[j]= level; + }else{ + level= (bias - level)>>QMAT_SHIFT; + block[j]= -level; + } + max |=level; + }else{ + block[j]=0; + } + } + *overflow= s->max_qcoeff < max; //overflow might have happened + + /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */ + if (s->idsp.perm_type != FF_IDCT_PERM_NONE) + ff_block_permute(block, s->idsp.idct_permutation, + scantable, last_non_zero); + + return last_non_zero; +} + static void update_duplicate_context_after_me(MpegEncContext *dst, const MpegEncContext *src) { @@ -4565,86 +4648,3 @@ void ff_block_permute(int16_t *block, uint8_t *permutation, block[perm_j] = temp[j]; } } - -int ff_dct_quantize_c(MpegEncContext *s, - int16_t *block, int n, - int qscale, int *overflow) -{ - int i, j, level, last_non_zero, q, start_i; - const int *qmat; - const uint8_t *scantable; - int bias; - int max=0; - unsigned int threshold1, threshold2; - - s->fdsp.fdct(block); - - if(s->dct_error_sum) - s->denoise_dct(s, block); - - if (s->mb_intra) { - scantable= s->intra_scantable.scantable; - if (!s->h263_aic) { - if (n < 4) - q = s->y_dc_scale; - else - q = s->c_dc_scale; - q = q << 3; - } else - /* For AIC we skip quant/dequant of INTRADC */ - q = 1 << 3; - - /* note: block[0] is assumed to be positive */ - block[0] = (block[0] + (q >> 1)) / q; - start_i = 1; - last_non_zero = 0; - qmat = n < 4 ? s->q_intra_matrix[qscale] : s->q_chroma_intra_matrix[qscale]; - bias= s->intra_quant_bias*(1<<(QMAT_SHIFT - QUANT_BIAS_SHIFT)); - } else { - scantable= s->inter_scantable.scantable; - start_i = 0; - last_non_zero = -1; - qmat = s->q_inter_matrix[qscale]; - bias= s->inter_quant_bias*(1<<(QMAT_SHIFT - QUANT_BIAS_SHIFT)); - } - threshold1= (1<=start_i;i--) { - j = scantable[i]; - level = block[j] * qmat[j]; - - if(((unsigned)(level+threshold1))>threshold2){ - last_non_zero = i; - break; - }else{ - block[j]=0; - } - } - for(i=start_i; i<=last_non_zero; i++) { - j = scantable[i]; - level = block[j] * qmat[j]; - -// if( bias+level >= (1<= (1<threshold2){ - if(level>0){ - level= (bias + level)>>QMAT_SHIFT; - block[j]= level; - }else{ - level= (bias - level)>>QMAT_SHIFT; - block[j]= -level; - } - max |=level; - }else{ - block[j]=0; - } - } - *overflow= s->max_qcoeff < max; //overflow might have happened - - /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */ - if (s->idsp.perm_type != FF_IDCT_PERM_NONE) - ff_block_permute(block, s->idsp.idct_permutation, - scantable, last_non_zero); - - return last_non_zero; -} From patchwork Sun Jun 9 08:25:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49727 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1911641vqo; Sun, 9 Jun 2024 01:25:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVREqbKHlg+Ayp8IQovxaXA6X1WtpXP8V/defaIsibfaNs3H1E3hlCEMU8oD38F6QpDJRL1ignAyk2whrsl1g7HIW9O8Bzv1N7H2w== X-Google-Smtp-Source: AGHT+IHELUexHg2EWOymhxf0/KPFIpat1cm+kvsjY4DJPR8XErJY6ZeN4YDqAtlcWRbqLCilrC3i X-Received: by 2002:a17:906:13c8:b0:a6f:127e:f31 with SMTP id a640c23a62f3a-a6f127e0faamr85309066b.47.1717921544542; Sun, 09 Jun 2024 01:25:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717921544; cv=none; d=google.com; s=arc-20160816; b=Hh53VXbEl+mzL5tgY3M3KMijJUhTn34mV/uZcXcuzTG2dTx75No6gQsfiJCQ8EYyJ+ cQoyMFN0+tfeiXcl5B28Fo1D7km7JdETSZAw3q5xPs8nbd+FMG+a+3JDOxz2gTDIsz6p JF2+e3xiImSi9tHBvJRVJlumj3NpqOVCBmVuFZGOG25fvNXe9HdIGAD6PM09xxVWqzz/ UH8wXQ7psB6JxNbHR6L1pRGv6ErLqql8rCCz3HtnbR4ITIc3TvnKb5nySy5xUMMD9EiW PZgR2Twh65j5bbLeNoBaO1ZsK1uHihkN9lr+ANH/iWGAkse0vStPj2U5JNMAtpX5ElNw gvuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=zD35u5/oXB7gG/507Y/1Zyrxpq2eWXZFqI64ydvDF7E=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=frf7pcp6ny7Eu8nmTfOAaFPqvbZAPSGaP2LR86h5+u8jIRRMH/sF5Ge2h1FjiRc++k STTcIBgY7oa6kyGvv9Owmx42oz/ZNI9oTHmClCH8Msyac/i6lH9nQdXMNbnekw9LH4O3 /1N+xoPkMNlwnMqjxBOtFTrM5cfiWdEPBr8CQ+ejGlRxmfS+9uhPX49jOmfzL+SqQRKA REMYbhot6N7YL74RGcnLbfRssP9skAQUY8LwFzojqa6u4LWrPl/p87SwiNI03phon/Fb whytJhBSfSKmUJefa9gcJiGV5uc/+ssLmipS+TK7hG3BE6EmxOVS68vvfCVRIXAJ1DNU vwyg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a6f003cf59dsi135504266b.181.2024.06.09.01.25.44; Sun, 09 Jun 2024 01:25:44 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B06F068D758; Sun, 9 Jun 2024 11:25:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2912268D72B for ; Sun, 9 Jun 2024 11:25:16 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id B91EBC02F8 for ; Sun, 9 Jun 2024 11:25:15 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Jun 2024 11:25:14 +0300 Message-ID: <20240609082515.1325134-3-remi@remlab.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240609082515.1325134-1-remi@remlab.net> References: <20240609082515.1325134-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] lavc/mpv_enc: privatize ff_dct_quantize_c X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IzASzE+v8LYR --- libavcodec/mpegvideo_enc.c | 9 ++++----- libavcodec/mpegvideoenc.h | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index dd92f0a3af..af04db70d8 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -246,9 +246,8 @@ void ff_init_qscale_tab(MpegEncContext *s) } } -int ff_dct_quantize_c(MpegEncContext *s, - int16_t *block, int n, - int qscale, int *overflow) +static int dct_quantize_c(MpegEncContext *s, int16_t *block, int n, + int qscale, int *overflow) { int i, j, level, last_non_zero, q, start_i; const int *qmat; @@ -379,7 +378,7 @@ av_cold int ff_dct_encode_init(MpegEncContext *s) if (CONFIG_H263_ENCODER) ff_h263dsp_init(&s->h263dsp); if (!s->dct_quantize) - s->dct_quantize = ff_dct_quantize_c; + s->dct_quantize = dct_quantize_c; if (!s->denoise_dct) s->denoise_dct = denoise_dct_c; s->fast_dct_quantize = s->dct_quantize; @@ -2527,7 +2526,7 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, } // non c quantize code returns incorrect block_last_index FIXME - if (s->alternate_scan && s->dct_quantize != ff_dct_quantize_c) { + if (s->alternate_scan && s->dct_quantize != dct_quantize_c) { for (i = 0; i < mb_block_count; i++) { int j; if (s->block_last_index[i] > 0) { diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index c20ea500eb..169ed1dc3b 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -148,7 +148,6 @@ void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); int ff_dct_encode_init(MpegEncContext *s); void ff_dct_encode_init_x86(MpegEncContext *s); -int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow); void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra); From patchwork Sun Jun 9 08:25:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 49728 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c209:0:b0:460:55fa:d5ed with SMTP id d9csp1911687vqo; Sun, 9 Jun 2024 01:25:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWpket9Lw8U1Y1EC0nePLvI2T+Fp8waf3cZuKnl7SdAHzizMs1Om5lEA3Dd4zcg/p6oqdDxYBoHvOBVhz0u9u2vt6kvVvA3qsFqGg== X-Google-Smtp-Source: AGHT+IF+aNzz8rqOO3uR6AfO4kCfT4CNZYHnvReLvpcrkFnsEos/dNUULIrY1G9aDBhUgXe7yLX4 X-Received: by 2002:a2e:bc10:0:b0:2ea:7688:4e97 with SMTP id 38308e7fff4ca-2eadced2797mr48509661fa.5.1717921554903; Sun, 09 Jun 2024 01:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1717921554; cv=none; d=google.com; s=arc-20160816; b=vqmq04BS5SXoeZjNNWKS9Xq00hgb7lUEMAIsU+PF9QpuyHcRXXvsWcGyutcLuKWNXR okOxpkyRENxDCXv2EPnCRfN3UxBjcAiXCQiviAjZkVCcOCI0u5+uDAt01LJMeIXKhSVc mrvsJZH/p6441RnUfSij8fkfuJvuUvn0uceu6Nbfu+1JtQdusgc21SYe+Xrt7ikvj1/y Y5xaX/g0ljt5a1Pg86ybuPgoxkcYGvAPoTCbJjg92SagOovpo2tbmw5p7V3/qu3+QRdE 8QlEB8mJVEnGjPbPQYOK6BRf3mctNBYX1CeZLO6AQn3B4s9mjOXmkybNm7t/rcTEBarC 4woQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=vged55ONiNm8jExkhjPVKF1FhKK6uhtpaG339gHMS5w=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=LGoqkF8FtmjCRPIc6cphWmlhqBqZ93YNLTjimgjzbAwvZVQ02T00kQC6GZ37Qu4Lvr ukocGlRP+Te3WVEaQSbif5zjz3PNx2UJTR+p+MdZ+HGC+fOkBO4An2ew+471RndJjAxJ kms9LHLGdJrlXoNbQROak2FNsWShVs/1XjG1eB0hTEBStOrTL/puVfbvZV/IwJ+QHP4y dqenXT4x9hNUN6pBwj0VbwCFjO2dYt/XkVZa5dwu+m1vI9BlUvegiJqgNqcnD76CpaLW vt+oaZe+xkoRal/Qem2c3QxYYMSxOL/TQaURtzw7ylTZ5H/YZXgO3lmv91w3jRb+oISJ rYvQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 38308e7fff4ca-2eae204cd84si12928041fa.275.2024.06.09.01.25.54; Sun, 09 Jun 2024 01:25:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2AD1A68D764; Sun, 9 Jun 2024 11:25:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 43F5C68D73D for ; Sun, 9 Jun 2024 11:25:16 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id E100EC02F9 for ; Sun, 9 Jun 2024 11:25:15 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Jun 2024 11:25:15 +0300 Message-ID: <20240609082515.1325134-4-remi@remlab.net> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240609082515.1325134-1-remi@remlab.net> References: <20240609082515.1325134-1-remi@remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] lavc/mpv_enc: rationalize dct_quantize init X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zzIpWhTfY2Dt On entry the function pointer is always NULL. We just need to set the pointer before probing x86 CPU optimisations. Note that there is a third code path setting this function pointer, but it does so *after* calling this function: the DNxHD encoder. --- libavcodec/mpegvideo_enc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index af04db70d8..49eed6301b 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -371,14 +371,13 @@ static void mpv_encode_defaults(MpegEncContext *s) av_cold int ff_dct_encode_init(MpegEncContext *s) { + s->dct_quantize = dct_quantize_c; #if ARCH_X86 ff_dct_encode_init_x86(s); #endif if (CONFIG_H263_ENCODER) ff_h263dsp_init(&s->h263dsp); - if (!s->dct_quantize) - s->dct_quantize = dct_quantize_c; if (!s->denoise_dct) s->denoise_dct = denoise_dct_c; s->fast_dct_quantize = s->dct_quantize;