From patchwork Fri Oct 28 14:49:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 39032 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:85a8:b0:a2:d5a7:ad9d with SMTP id s40csp836334pzd; Fri, 28 Oct 2022 07:49:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6bIDtdMLjp/lg468wOXXN09fNoa0cdDtbtBdNcgMU6d0kDOzy+Nwb9Ovp59LCZ1Dyxx8lo X-Received: by 2002:a17:906:eeca:b0:730:6880:c398 with SMTP id wu10-20020a170906eeca00b007306880c398mr47716454ejb.706.1666968592690; Fri, 28 Oct 2022 07:49:52 -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 i20-20020a508714000000b00461b84a010fsi4452219edb.295.2022.10.28.07.49.51; Fri, 28 Oct 2022 07:49:52 -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=P+6SthKH; 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 7610168BC88; Fri, 28 Oct 2022 17:49:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2028.outbound.protection.outlook.com [40.92.90.28]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0271F68BC88 for ; Fri, 28 Oct 2022 17:49:43 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fPkAg+0pAjVEwyxFxABMnCosJDY8lCHur0hcGRcE7k9vpbVZcfh7q0xh9eoCZ/oyo2mVcpoPjCfU5i+Sia1jmwcJCPeDUrQ+VUFVpu3ZIzzFi+5JyKXP9xQICGlZ0Ny7fYZXJdlEtD2ew0/FXWFgWNPry7yAoGjHHx7HJ+sagAfNoB5EwJGNie2VC7lFHXq8V0yJWPEncJWms3p+IXzPcms4FKfZ2Lox4VOz6a61/hczKxShJiTiIwtIPhcC8ozSw/EGvNq8ywgc2gcOkd7/w/TSTD81N9nbwD8O1fszufJT/qRz9PdLJDmyL2nzX38bKMKqJpJvGWPrOrjFu07T8g== 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=u2264SEc9W2NmVI56StcJNmzPl5gdK5LFZ1TCH43Ff8=; b=Ny/V5+9SmOxx/Br45sVsOCrLcnnO8TAkex0qz8QEkhFc2f+BP2yoMf5WZFM2dv5sSPOjFkDgBGkTcNVmpTwKPJqYJlx5EVwMOvDtWp6cP8Zl7WzrdsNJZRACdvE3plDpMWgIXceJJ9u+N5rZS8XkYdEsHuZmsChoJjV95LoN09X/eyYsydwXRvlqnM5qWjz4nxTmMWJpvO11XXGHxkJIFO3WkBgdXyECM7QWH+ZcXanc79cox3C9XEtqOnTbAl7yWXcxnSRBonF/1GEyfxCrKOV0ylo/pxCsjGAvde124zor9bRamZ2lzhugAPkwiPb4Q75TBTdoWOTapsZsFysfuQ== 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=u2264SEc9W2NmVI56StcJNmzPl5gdK5LFZ1TCH43Ff8=; b=P+6SthKHdfLEyGo3aNN0SaPe0jas2HU5cuObvYkuEGxvKEEp56IBj5tz+aeRaIh98Aox5bU05/3YaDh9it4NtYyIlxOrUNQuDY2oua9km5NWeUDgykeNAMgwI4LJMzI9QGoGvb3DrBs5Iw0oTtCxUdnUn3augc4haoDgUvj3HRyx7klHe55ouWPZKjhDBKnXSim8ewswFDETuPCQuJ1+GFDGhC92cV6NSFnrLO5KOBTHjauzbO5RAaJepb2bOtAldmlw0Y0CVVSg0JcnaWdLMwvp0Zo5qJCZYtMRxCQLx8rHvexmOexFJ6O8CZ90ikjkervvRTsUsHAcpoIKUAo+Yw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0289.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17c::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.15; Fri, 28 Oct 2022 14:49:41 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::f9d7:680f:70c4:44fe%9]) with mapi id 15.20.5709.015; Fri, 28 Oct 2022 14:49:41 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 28 Oct 2022 16:49:42 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [O1cNZ9NbvF3eBUCkIPtvpmGbuwG9vNxKYpVmKGd9sZo=] X-ClientProxiedBy: AM7PR04CA0001.eurprd04.prod.outlook.com (2603:10a6:20b:110::11) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20221028144946.1518249-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0289:EE_ X-MS-Office365-Filtering-Correlation-Id: 3b83b613-9763-45ee-5564-08dab8f3a4df X-MS-Exchange-SLBlob-MailProps: AZnQBsB9XmponRFq0U3/v5vCEJI3BD4xIorDB51vGZdXEvAUEGPcRzZFNn9DZ/C9F78VuQfTKRJkqlH3x8SNqmzr0akbfirliteJelA9gO4TILq8JaKBsGWtYs1ZX7N7bsunAg6j2EF3sn8g/8Q2Xym39AST22JXt92tTut4IVAwjqcmy1BjD08EMMVzHtp230S9TA1NQzXPYjBjAfx9Qkn3CvEJIZEDj5f08XDi30FwzYru9qA/rw5BeZiFa6vvSPVURPO+8p6pZ6fLzcTAFuvBro+cS85qn4Wi1qJHUut1otwW2CyLnPiWeeGzm+pHqvsJDfLza3+F7pN4i/dfeeV2k0sS6KpKhTAnx8p5RNn0btzp6bvxtUWOfw+99eBktRJ4hjAm7LwnsrZoKwEpzGmqcG9qmDNJu2+dtVCYtjliXAFyl29PoVt+paTXllRj4nxkAafgNkbHv512CEPM9CrFHvP78JeXuieZI/iGBOY10hJIoRy5M01/yM+J831iXnOO5ml9Vblu0KKApjwHvFy1QbB9fGpRnjMITl/DeYlrmeJnOJspaBYhpnoBh5KKIkRGzOxRoHFi+Ti7Yp4a8ZBWE8gAp2c88kobMa0LB1KMXpD0IoR6iTbTViCE7BaIj5P7YHgbiclDa0L9TV4H+roUFDsj+h1Zq0/v/rlbup58bcHH8j/Hj+OqMnc3jhUk0ZRA+0yCfXfYYgj3Blmj2aEGYWqe2oac3VeuaN280xGqi8hcmzHRmQV4cAQAHC1GpZA6f76dxdY= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message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ee-5564-08dab8f3a4df X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2022 14:49:41.0884 (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: PR3P250MB0289 Subject: [FFmpeg-devel] [PATCH 2/6] avcodec/mpegvideodata: Join mpeg1/2 dc scale tables 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: qzi4E7vBVGn1 Avoids relocations. Signed-off-by: Andreas Rheinhardt --- libavcodec/mpeg12enc.c | 2 +- libavcodec/mpegvideo_enc.c | 4 ++-- libavcodec/mpegvideodata.c | 26 +++++++++----------------- libavcodec/mpegvideodata.h | 4 ++-- libavcodec/speedhqenc.c | 2 +- 5 files changed, 15 insertions(+), 23 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 2db1d93d0e..3ad1cd84a1 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -1148,7 +1148,7 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s) static AVOnce init_static_once = AV_ONCE_INIT; s->y_dc_scale_table = - s->c_dc_scale_table = ff_mpeg2_dc_scale_table[s->intra_dc_precision]; + s->c_dc_scale_table = ff_mpeg12_dc_scale_table[s->intra_dc_precision]; s->me.mv_penalty = mv_penalty; s->fcode_tab = fcode_tab; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index ce363a585d..46be4aad26 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3736,9 +3736,9 @@ static int encode_picture(MpegEncContext *s, int picture_number) s-> intra_matrix[j] = av_clip_uint8(( luma_matrix[i] * s->qscale) >> 3); } s->y_dc_scale_table= - s->c_dc_scale_table= ff_mpeg2_dc_scale_table[s->intra_dc_precision]; + s->c_dc_scale_table = ff_mpeg12_dc_scale_table[s->intra_dc_precision]; s->chroma_intra_matrix[0] = - s->intra_matrix[0] = ff_mpeg2_dc_scale_table[s->intra_dc_precision][8]; + s->intra_matrix[0] = ff_mpeg12_dc_scale_table[s->intra_dc_precision][8]; ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16, s->intra_matrix, s->intra_quant_bias, 8, 8, 1); ff_convert_matrix(s, s->q_chroma_intra_matrix, s->q_chroma_intra_matrix16, diff --git a/libavcodec/mpegvideodata.c b/libavcodec/mpegvideodata.c index b98e90cf43..68ad84276e 100644 --- a/libavcodec/mpegvideodata.c +++ b/libavcodec/mpegvideodata.c @@ -30,31 +30,23 @@ const uint8_t ff_mpeg2_non_linear_qscale[32] = { 56, 64, 72, 80, 88, 96, 104, 112, }; -const uint8_t ff_mpeg1_dc_scale_table[32] = { +const uint8_t ff_mpeg12_dc_scale_table[4][32] = { +{ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const uint8_t mpeg2_dc_scale_table1[32] = { +}, +{ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -}; - -static const uint8_t mpeg2_dc_scale_table2[32] = { +}, +{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -}; - -static const uint8_t mpeg2_dc_scale_table3[32] = { +}, +{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -}; - -const uint8_t *const ff_mpeg2_dc_scale_table[4] = { - ff_mpeg1_dc_scale_table, - mpeg2_dc_scale_table1, - mpeg2_dc_scale_table2, - mpeg2_dc_scale_table3, +}, }; const uint8_t ff_alternate_horizontal_scan[64] = { diff --git a/libavcodec/mpegvideodata.h b/libavcodec/mpegvideodata.h index cf783ef31c..7264b434ae 100644 --- a/libavcodec/mpegvideodata.h +++ b/libavcodec/mpegvideodata.h @@ -25,8 +25,8 @@ extern const uint8_t ff_alternate_horizontal_scan[64]; extern const uint8_t ff_alternate_vertical_scan[64]; -extern const uint8_t ff_mpeg1_dc_scale_table[32]; -extern const uint8_t * const ff_mpeg2_dc_scale_table[4]; +extern const uint8_t ff_mpeg12_dc_scale_table[4][32]; +static const uint8_t *const ff_mpeg1_dc_scale_table = ff_mpeg12_dc_scale_table[0]; extern const uint8_t ff_mpeg2_non_linear_qscale[32]; diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c index 65e66afae4..7269e345d3 100644 --- a/libavcodec/speedhqenc.c +++ b/libavcodec/speedhqenc.c @@ -115,7 +115,7 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s) s->intra_chroma_ac_vlc_last_length = uni_speedhq_ac_vlc_len; s->y_dc_scale_table = - s->c_dc_scale_table = ff_mpeg2_dc_scale_table[3]; + s->c_dc_scale_table = ff_mpeg12_dc_scale_table[3]; switch (s->avctx->pix_fmt) { case AV_PIX_FMT_YUV420P: