From patchwork Mon Oct 30 13:11:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 44438 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dd83:b0:15d:8365:d4b8 with SMTP id kw3csp1411674pzb; Mon, 30 Oct 2023 06:10:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIjXmP73JlJNIg2B1lZcqtbO8aBue+7DP/G5YvRRyPyNh2oEzPr+IGNATUnmx52GNJoOCX X-Received: by 2002:a05:6402:651:b0:533:520:a5a8 with SMTP id u17-20020a056402065100b005330520a5a8mr7290244edx.29.1698671427203; Mon, 30 Oct 2023 06:10:27 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h5-20020a056402280500b005432fcb3b03si725795ede.429.2023.10.30.06.10.26; Mon, 30 Oct 2023 06:10:27 -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; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=cQR+Nh2T; arc=fail (body hash mismatch); 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9800168CC5B; Mon, 30 Oct 2023 15:10:22 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2067.outbound.protection.outlook.com [40.92.89.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4012D68CC50 for ; Mon, 30 Oct 2023 15:10:16 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R6rwS/iGgSXwMJhXvcWB7z8YGaIyPNI7OGfzowz+JrDlABpO1MM7D2/Wxcj2jYj0WFBccB97PPfG+epmDaSJpAS+ITzSR3VzHGVMKjKRf1pxF3530JLSWOrnfav5C/MnD7e55/RzB1FHiCBUdbmyYipasv7ol7ROlUe6OXiK2kpu1RLCCrNQeKQaMv78Aki1X7Ij5brLHfbvd5IKa6l4WcgUszlPqmOh54LleoaXpw3WsiKTmi69VJ8/W2WQkCsW1D5DqBYUa4ByQZo7GkPEI8HK6SvFpNF5FCDEN3wI0GlzzMVc2UHgYyz7JmlUhzpIq5jodcYETzk1I+Ud8PpnDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=34bYfYtHkW28ah1gyQtrnhvOyHJ/4RBlTedk5HmHptw=; b=CR1KrqDoGfZFqLiOXAUZobOBH11L+T5HqVmhF7wQiLbmSM0LDJc3dbDR5GIj8D795oQIfeFnaOJRsi37OoU9jMbYlKJ/I6AiLLOYC7NkpvYDUhTkyi46zqVIeCBGzOUyLRTakg/qo3zIKWkU/VYUDuJJn2qrw+ccIGSpQXYpxw0QPkBqygQNY7ZQ04TJRoMf9AUu0OMdOJL8maVSswadr29d40gyd/O9D0+gSpXZOScCA96YhjGlkE3fI2c6MLK9DHZOapvS5042yvqkWJtS10DgGYpuG2I+ij4GAlcjNXg6M0SCKm0PCUynGzzDMvAw1GU9xKYTo1b4evsErgcnoA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=34bYfYtHkW28ah1gyQtrnhvOyHJ/4RBlTedk5HmHptw=; b=cQR+Nh2Te6z2JyywW9a59T3CoRBcky89qMrfTqUj9L0jL/O5Ss9mi0nSeAjcHTjujCG/SGY62HFuyxKwgmmcsW82468ANMLFWVN0SyQCEcsdLD3xFYm3g0jXVg5Pasqqa7t6gLtKTv3fmdqmxVcpO6Xwpc9Wrfv406suk4r3MNQ/xhBLJYrRjsLwMsBc9j7eCCaFrrLebMq677LIW2UlVNnZYYFjg5RT1ZxckkXBnUBOtQr7fLga76t/3iGAnMHrzmGZSNfsd7XUbRiSN5YcroHPcOkOm3BQkiZdpHjxnIOuoL3xCvmDKpFeqz3t75Cy0RonR3EnSDhuU/vnP0gIww== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0151.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:176::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6933.27; Mon, 30 Oct 2023 13:10:13 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f59c:9cff:a42d:bde%3]) with mapi id 15.20.6907.030; Mon, 30 Oct 2023 13:10:13 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 30 Oct 2023 14:11:27 +0100 Message-ID: X-Mailer: git-send-email 2.34.1 X-TMN: [/zzYe1IyRCW0URRRsi4FGNy6BToSbSaAJ5sc3HY6skc=] X-ClientProxiedBy: ZR2P278CA0044.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:47::6) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20231030131127.2054226-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0151:EE_ X-MS-Office365-Filtering-Correlation-Id: 3bd3ca27-cb5d-4b5e-786c-08dbd9498d87 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hInOM2S+xQ0tnZWBcdLDWlhHiAipapPeFcfhDfc6NzLHHAcI3vaUg+s2NvJEHlamzSwogASx6XuhEzUlLG5dT+kJUbOv/cWWSOID0A7o4WGXNWeeRUi60jCz7jlYB37SFXJPlUWA5ir3zqLJpT1dVI8QHAxy2tRNfc5NENOujTVJmLSgEHVqTj2/PlsxIWBpMKTCw1C1/74b02ACdJ5oQro+Q0BHX2Zx8+58AMsqx+bIwbgAnXQI0iFDxfEAz0WslOlpmq94CmlRvq4zriwWKNA6as2pcdJcazN4oPOxnvGu9u5u/mQYk/hIUiyk3mInEA30sLecWCo+qHa62TPmYtmCerkwe2zwX3hxbYbg2YjdbW5H5iEnwyOQ4mcdVGHrmH3L7JBVJ2Tu+MzOxJV4MGoWdm3zd1i54LNAC+6s2ikNHh4pb2auON/RgOn1PDciqiKmS0FU+3oxnHCRfqUHz6KnhK/RcFJzaJOcymeK5dZ1A4ISMWztRK4c0o37fmTU/rXkZZGhEYlrW7e0pJL7dLSTfc8g0YxJGzlfmuRpyPCZpiL441qbdC56HB8sJm5U3GIJNKIgn2SXhdaTSSmH8EJZ97T1QFWeMgVIvdEGJ09NOhQiwlPCzQCXIgXooT3I X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kdc1zfXgO5vECP/460L7Y+2juojRZR5b0h+CTm8T4wpchJT2de6bOg1QRj0SnEcU96Byiy25+LFQZJMf62UGoD0pmT2bFEMIn8pyhJ48AhL6qgcVbIkwuGTn7KORN4UhUONlcz0zqly5h2wP2PSXLW5yMTkUbyM/aIoeIP31swwU+71cnqicpZJHR4/9pPzQ5c/I65fGew4ieqPiP+bdZ31GMuJ96SYwhM96SRYzcCLemSEaGWK9MD1QKSLyWIdiJx7puKJDJdkUNB6DmmEFnHIhpM7Rcxb+z7xctGsqj5IZaX58D1ti813llaHztuwnZJDgj+axWVI1OqOq+Be62F0mOgHWLsgTtBn/MB4qDqu7rcuq0kCpTRcg70geWWb/jldiucl4Z4SzdwL05xCEvnk616VEP8HOriIJeI2PITLHU2bjfNTtKHn/hthURkO6OLmuscwotckilpV3RRXa+2rp5vtFia7jU2J/FsqCKO167DM1+7jWuBUL9Pie9gxcqdWba9HKosSJAAIk2EN3fu3Nf7JG5+EfvFsEjdmQrC+ELY8LMlajGeAPj8Q5+npdcd7PeZxuPn6Dn3Sp+GDhCWEuiMXsn004B5fT/Hd6gbX8pcwEsRRBx0UEkyb3jd2E2LIazVJzbcMqe5esqlmyWEK8IPWTX0qtueYXBoTYv8kwzDub6HLnYbWL4iIUWwDQLuLGfypupS9LB7QbZccxwQJU5TwW1QQbrY1rrxu+ykjfG82hb/m0Avh5hEp6/iuu+fl1z8Y6vSbthRrj/WyxLstRrU48ti9YNzZWr5Rt6Yn4jmGEe9a4mprlkP0BKvZ6AQ0VLm/OPHAqZbBT8sCCw6Wh16Xf8ny6Zr58hWD6CT/Ol3HCNoR5aaIkFdLaScX31F5QltoYdv4NkadhymNocEJD8BdXKesbDJvPFDtPAEMLNasYjEJ1VUt24SQm1I0fmQqpXLD2t1YFEEp8NL2EHUY1capZSscUx/yhKpQMeFvKJmueom1bx1zjlpfgxlR0hL9vGuzQscef43q/8Ka2Fo/rDDd7qrnfvx7KociffzJlxCA62myvnKNrPnzFb2LBpb9F8xioYlmNY7FbKt8fKie9BlPN6JuJSKNVQEDFddESEqj4SFx1vkUiefGs0s4hQ/ThprZRZEL8wTc2fcwxieYtz5EukjO+mf4D+Avnv6Lj0R6uLBAmX8ROffMEb03gBT6l6ju+gBAvwtkzEEYUtmDXAsc3K5x5w/2RjIkN5a0McjlLF26c/WIkOoTEMrde X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3bd3ca27-cb5d-4b5e-786c-08dbd9498d87 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2023 13:10:13.6467 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0151 Subject: [FFmpeg-devel] [PATCH] avcodec/mpegvideo: Remove spec-incompliant inverse quantisation 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: fJrZH+EGqCgQ Section 7.4.4 of the MPEG-2 specifications requires that the last bit of the last coefficient be toggled so that the sum of all coefficients is odd; both our decoder and encoder did this only if the bitexact flag has been set (although stuff like this should be behind AV_CODEC_FLAG2_FAST). This patch changes this by removing the spec-incompliant functions. Signed-off-by: Andreas Rheinhardt --- libavcodec/mips/mpegvideo_init_mips.c | 4 -- libavcodec/mips/mpegvideo_mips.h | 2 - libavcodec/mips/mpegvideo_mmi.c | 93 --------------------------- libavcodec/mpegvideo.c | 32 --------- libavcodec/x86/mpegvideo.c | 72 --------------------- 5 files changed, 203 deletions(-) diff --git a/libavcodec/mips/mpegvideo_init_mips.c b/libavcodec/mips/mpegvideo_init_mips.c index f687ad18f1..1b383ee3f5 100644 --- a/libavcodec/mips/mpegvideo_init_mips.c +++ b/libavcodec/mips/mpegvideo_init_mips.c @@ -33,10 +33,6 @@ av_cold void ff_mpv_common_init_mips(MpegEncContext *s) s->dct_unquantize_mpeg1_intra = ff_dct_unquantize_mpeg1_intra_mmi; s->dct_unquantize_mpeg1_inter = ff_dct_unquantize_mpeg1_inter_mmi; - if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT)) - if (!s->q_scale_type) - s->dct_unquantize_mpeg2_intra = ff_dct_unquantize_mpeg2_intra_mmi; - s->denoise_dct= ff_denoise_dct_mmi; } diff --git a/libavcodec/mips/mpegvideo_mips.h b/libavcodec/mips/mpegvideo_mips.h index 760d7b3295..0bc0e375bd 100644 --- a/libavcodec/mips/mpegvideo_mips.h +++ b/libavcodec/mips/mpegvideo_mips.h @@ -31,8 +31,6 @@ void ff_dct_unquantize_mpeg1_intra_mmi(MpegEncContext *s, int16_t *block, int n, int qscale); void ff_dct_unquantize_mpeg1_inter_mmi(MpegEncContext *s, int16_t *block, int n, int qscale); -void ff_dct_unquantize_mpeg2_intra_mmi(MpegEncContext *s, int16_t *block, - int n, int qscale); void ff_denoise_dct_mmi(MpegEncContext *s, int16_t *block); #endif /* AVCODEC_MIPS_MPEGVIDEO_MIPS_H */ diff --git a/libavcodec/mips/mpegvideo_mmi.c b/libavcodec/mips/mpegvideo_mmi.c index 3d5b5e20ab..d0bf1a3c10 100644 --- a/libavcodec/mips/mpegvideo_mmi.c +++ b/libavcodec/mips/mpegvideo_mmi.c @@ -342,99 +342,6 @@ void ff_dct_unquantize_mpeg1_inter_mmi(MpegEncContext *s, int16_t *block, ); } -void ff_dct_unquantize_mpeg2_intra_mmi(MpegEncContext *s, int16_t *block, - int n, int qscale) -{ - uint64_t nCoeffs; - const uint16_t *quant_matrix; - int block0; - double ftmp[10]; - uint64_t tmp[1]; - mips_reg addr[1]; - DECLARE_VAR_ALL64; - DECLARE_VAR_ADDRT; - - assert(s->block_last_index[n]>=0); - - if (s->alternate_scan) - nCoeffs = 63; - else - nCoeffs = s->intra_scantable.raster_end[s->block_last_index[n]]; - - if (n < 4) - block0 = block[0] * s->y_dc_scale; - else - block0 = block[0] * s->c_dc_scale; - - quant_matrix = s->intra_matrix; - - __asm__ volatile ( - "dli %[tmp0], 0x0f \n\t" - "pcmpeqh %[ftmp0], %[ftmp0], %[ftmp0] \n\t" - "mtc1 %[tmp0], %[ftmp3] \n\t" - "mtc1 %[qscale], %[ftmp9] \n\t" - "psrlh %[ftmp0], %[ftmp0], %[ftmp3] \n\t" - "packsswh %[ftmp9], %[ftmp9], %[ftmp9] \n\t" - "packsswh %[ftmp9], %[ftmp9], %[ftmp9] \n\t" - "or %[addr0], %[nCoeffs], $0 \n\t" - ".p2align 4 \n\t" - - "1: \n\t" - MMI_LDXC1(%[ftmp1], %[addr0], %[block], 0x00) - MMI_LDXC1(%[ftmp2], %[addr0], %[block], 0x08) - "mov.d %[ftmp3], %[ftmp1] \n\t" - "mov.d %[ftmp4], %[ftmp2] \n\t" - MMI_LDXC1(%[ftmp5], %[addr0], %[quant], 0x00) - MMI_LDXC1(%[ftmp6], %[addr0], %[quant], 0x08) - "pmullh %[ftmp5], %[ftmp5], %[ftmp9] \n\t" - "pmullh %[ftmp6], %[ftmp6], %[ftmp9] \n\t" - "pxor %[ftmp7], %[ftmp7], %[ftmp7] \n\t" - "pxor %[ftmp8], %[ftmp8], %[ftmp8] \n\t" - "pcmpgth %[ftmp7], %[ftmp7], %[ftmp1] \n\t" - "pcmpgth %[ftmp8], %[ftmp8], %[ftmp2] \n\t" - "pxor %[ftmp1], %[ftmp1], %[ftmp7] \n\t" - "pxor %[ftmp2], %[ftmp2], %[ftmp8] \n\t" - "psubh %[ftmp1], %[ftmp1], %[ftmp7] \n\t" - "psubh %[ftmp2], %[ftmp2], %[ftmp8] \n\t" - "pmullh %[ftmp1], %[ftmp1], %[ftmp5] \n\t" - "pmullh %[ftmp2], %[ftmp2], %[ftmp6] \n\t" - "pxor %[ftmp5], %[ftmp5], %[ftmp5] \n\t" - "pxor %[ftmp6], %[ftmp6], %[ftmp6] \n\t" - "pcmpeqh %[ftmp5], %[ftmp5], %[ftmp3] \n\t" - "dli %[tmp0], 0x03 \n\t" - "pcmpeqh %[ftmp6] , %[ftmp6], %[ftmp4] \n\t" - "mtc1 %[tmp0], %[ftmp3] \n\t" - "psrah %[ftmp1], %[ftmp1], %[ftmp3] \n\t" - "psrah %[ftmp2], %[ftmp2], %[ftmp3] \n\t" - "pxor %[ftmp1], %[ftmp1], %[ftmp7] \n\t" - "pxor %[ftmp2], %[ftmp2], %[ftmp8] \n\t" - "psubh %[ftmp1], %[ftmp1], %[ftmp7] \n\t" - "psubh %[ftmp2], %[ftmp2], %[ftmp8] \n\t" - "pandn %[ftmp5], %[ftmp5], %[ftmp1] \n\t" - "pandn %[ftmp6], %[ftmp6], %[ftmp2] \n\t" - MMI_SDXC1(%[ftmp5], %[addr0], %[block], 0x00) - MMI_SDXC1(%[ftmp6], %[addr0], %[block], 0x08) - PTR_ADDIU "%[addr0], %[addr0], 0x10 \n\t" - "blez %[addr0], 1b \n\t" - : [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), - [ftmp2]"=&f"(ftmp[2]), [ftmp3]"=&f"(ftmp[3]), - [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]), - [ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]), - [ftmp8]"=&f"(ftmp[8]), [ftmp9]"=&f"(ftmp[9]), - [tmp0]"=&r"(tmp[0]), - RESTRICT_ASM_ALL64 - RESTRICT_ASM_ADDRT - [addr0]"=&r"(addr[0]) - : [block]"r"((mips_reg)(block+nCoeffs)), - [quant]"r"((mips_reg)(quant_matrix+nCoeffs)), - [nCoeffs]"r"((mips_reg)(2*(-nCoeffs))), - [qscale]"r"(qscale) - : "memory" - ); - - block[0]= block0; -} - void ff_denoise_dct_mmi(MpegEncContext *s, int16_t *block) { const int intra = s->mb_intra; diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 81796e42bb..dadb8462e1 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -104,36 +104,6 @@ static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s, { int i, level, nCoeffs; const uint16_t *quant_matrix; - - if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; - else qscale <<= 1; - - if(s->alternate_scan) nCoeffs= 63; - else nCoeffs= s->block_last_index[n]; - - block[0] *= n < 4 ? s->y_dc_scale : s->c_dc_scale; - quant_matrix = s->intra_matrix; - for(i=1;i<=nCoeffs;i++) { - int j= s->intra_scantable.permutated[i]; - level = block[j]; - if (level) { - if (level < 0) { - level = -level; - level = (int)(level * qscale * quant_matrix[j]) >> 4; - level = -level; - } else { - level = (int)(level * qscale * quant_matrix[j]) >> 4; - } - block[j] = level; - } - } -} - -static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s, - int16_t *block, int n, int qscale) -{ - int i, level, nCoeffs; - const uint16_t *quant_matrix; int sum=-1; if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; @@ -295,8 +265,6 @@ static av_cold int dct_init(MpegEncContext *s) s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_c; s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_c; s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_c; - if (s->avctx->flags & AV_CODEC_FLAG_BITEXACT) - s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_bitexact; s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_c; #if HAVE_INTRINSICS_NEON diff --git a/libavcodec/x86/mpegvideo.c b/libavcodec/x86/mpegvideo.c index 73967cafda..f3384dfaa5 100644 --- a/libavcodec/x86/mpegvideo.c +++ b/libavcodec/x86/mpegvideo.c @@ -23,7 +23,6 @@ #include "libavutil/cpu.h" #include "libavutil/x86/asm.h" #include "libavutil/x86/cpu.h" -#include "libavcodec/avcodec.h" #include "libavcodec/mpegvideo.h" #include "libavcodec/mpegvideodata.h" @@ -300,75 +299,6 @@ __asm__ volatile( ); } -static void dct_unquantize_mpeg2_intra_mmx(MpegEncContext *s, - int16_t *block, int n, int qscale) -{ - x86_reg nCoeffs; - const uint16_t *quant_matrix; - int block0; - - av_assert2(s->block_last_index[n]>=0); - - if (s->q_scale_type) qscale = ff_mpeg2_non_linear_qscale[qscale]; - else qscale <<= 1; - - if(s->alternate_scan) nCoeffs= 63; //FIXME - else nCoeffs= s->intra_scantable.raster_end[ s->block_last_index[n] ]; - - if (n < 4) - block0 = block[0] * s->y_dc_scale; - else - block0 = block[0] * s->c_dc_scale; - quant_matrix = s->intra_matrix; -__asm__ volatile( - "pcmpeqw %%mm7, %%mm7 \n\t" - "psrlw $15, %%mm7 \n\t" - "movd %2, %%mm6 \n\t" - "packssdw %%mm6, %%mm6 \n\t" - "packssdw %%mm6, %%mm6 \n\t" - "mov %3, %%"FF_REG_a" \n\t" - ".p2align 4 \n\t" - "1: \n\t" - "movq (%0, %%"FF_REG_a"), %%mm0 \n\t" - "movq 8(%0, %%"FF_REG_a"), %%mm1\n\t" - "movq (%1, %%"FF_REG_a"), %%mm4 \n\t" - "movq 8(%1, %%"FF_REG_a"), %%mm5\n\t" - "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] - "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] - "pxor %%mm2, %%mm2 \n\t" - "pxor %%mm3, %%mm3 \n\t" - "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 - "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 - "pxor %%mm2, %%mm0 \n\t" - "pxor %%mm3, %%mm1 \n\t" - "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) - "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) - "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q - "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q - "pxor %%mm4, %%mm4 \n\t" - "pxor %%mm5, %%mm5 \n\t" // FIXME slow - "pcmpeqw (%0, %%"FF_REG_a"), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 - "pcmpeqw 8(%0, %%"FF_REG_a"), %%mm5\n\t" // block[i] == 0 ? -1 : 0 - "psraw $4, %%mm0 \n\t" - "psraw $4, %%mm1 \n\t" - "pxor %%mm2, %%mm0 \n\t" - "pxor %%mm3, %%mm1 \n\t" - "psubw %%mm2, %%mm0 \n\t" - "psubw %%mm3, %%mm1 \n\t" - "pandn %%mm0, %%mm4 \n\t" - "pandn %%mm1, %%mm5 \n\t" - "movq %%mm4, (%0, %%"FF_REG_a") \n\t" - "movq %%mm5, 8(%0, %%"FF_REG_a")\n\t" - - "add $16, %%"FF_REG_a" \n\t" - "jng 1b \n\t" - ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "rm" (qscale), "g" (-2*nCoeffs) - : "%"FF_REG_a, "memory" - ); - block[0]= block0; - //Note, we do not do mismatch control for intra as errors cannot accumulate -} - static void dct_unquantize_mpeg2_inter_mmx(MpegEncContext *s, int16_t *block, int n, int qscale) { @@ -461,8 +391,6 @@ av_cold void ff_mpv_common_init_x86(MpegEncContext *s) s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_mmx; s->dct_unquantize_mpeg1_intra = dct_unquantize_mpeg1_intra_mmx; s->dct_unquantize_mpeg1_inter = dct_unquantize_mpeg1_inter_mmx; - if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT)) - s->dct_unquantize_mpeg2_intra = dct_unquantize_mpeg2_intra_mmx; s->dct_unquantize_mpeg2_inter = dct_unquantize_mpeg2_inter_mmx; } #endif /* HAVE_MMX_INLINE */