From patchwork Wed Dec 22 03:25:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 32821 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp6022358iog; Tue, 21 Dec 2021 19:25:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAjyQ1KlhabWlTCwFgdoU4LQ288jXKRDdrmuwndHXKbC6GuLhnb0aSn7Wecwf7jl3l3iZD X-Received: by 2002:a17:907:6ea8:: with SMTP id sh40mr916475ejc.585.1640143554239; Tue, 21 Dec 2021 19:25:54 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id t8si391929edr.634.2021.12.21.19.25.53; Tue, 21 Dec 2021 19:25:54 -0800 (PST) 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=nH7S9jO9; 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 9D45F68AFDC; Wed, 22 Dec 2021 05:25:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-oln040092074084.outbound.protection.outlook.com [40.92.74.84]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D154368AFAA for ; Wed, 22 Dec 2021 05:25:34 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TRe+wS6oy3lpermeZU8mCC0iFcKXTObcahXmjinhtc7cf5K7rmC2ya/7lJg/ieXjABd1zL59H3XdD3LKXh3VIqnSJksdbTKEcS0vTlRBtJRfhWFB7DXLVNaYXv8ZAhK478txvW9ScQa9g38fGaYK4WSmghUzvBn1kpqGVhixeeWXosVKW/lzBdfSZy2wgZEwIZZIkHyQIjRkKOTPta7C7ztYPoAT2ABlQXNfMHr5MmK0Zof1p/FvCFAHVoSYOLOsEiHAsBTHAI1L63KypmbF9qTfTgkxjw9jUJZnEWocDP2325Y7ZZoioEaoH4X62COI8qiiVoBvN4WMrVC3EYYdDA== 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=jRONIuMzsDSJs32n8GUXwP2bMDLcurU+ef6D1Dr9zig=; b=jKAfumXwEqtcZJ/HUxwEhXajdGt1ng7eeWiQq0eNgcagsPt+s9MN82VWpohtBPKjArA91kpC83znEyQ7YPGMzmVddxVtL/C28EBHwQtTb2xHh5U4EiT3g1Dlag8Hq27RR994Tm8/YWlnxLq+DT3aaLzXpic4J+xjvoTvxVh6A1iwxp8mOoqE4+PjvW5YqTmyCG3yaIz49ErsUrI1OTsJiJ0dnSSVd1xBvRxzh/FQ6K3jJbqQvY40cf/uDH/6tPlWaYwtWcJgEOFc/45G3N14Zw1a1DFXH9Jt8fuxX2esNXF5cACJtPVe3Rtlh1Gd9jXaXljFK1hItMrRkGlkHogCVw== 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=jRONIuMzsDSJs32n8GUXwP2bMDLcurU+ef6D1Dr9zig=; b=nH7S9jO9pYMHv16cDHxIRbhgOfi9FISBohyr9eAVlO3AMy2v4+wk6lSaE+g3duFpYKm+jHNfdL8w5hf3ki3ddU5Egs7Cik6mRO3zK6rtgEcZvlK2bVV4JuvJf7r/mBxtk4MekZjkgWTYSuqxbIKfvwOWmwDMNI357sGLDOs+woHvxp6m2TDA+/j8hwEEJXB1Uy+vaohotE91gi4cp5pDIfkhbrwOz529IJlIu0mtmlLQLmBLpdT9Ce5wd4BlPa+LfitjwiTLMg2z2oxc+5JsB8fbZxciYo3RdA7UdUNXSDJ/MEk6Od0Co1bhZxLOyH/vFdClegU3A9MKBgxXheJs9A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4104.eurprd03.prod.outlook.com (2603:10a6:20b:18::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.15; Wed, 22 Dec 2021 03:25:26 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::f0dc:92f5:6bc2:45ca%6]) with mapi id 15.20.4801.022; Wed, 22 Dec 2021 03:25:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 22 Dec 2021 04:25:05 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [fRJtdLUjvMQLrm8j/KgyrrY4tf3x3ES1] X-ClientProxiedBy: AS9PR06CA0323.eurprd06.prod.outlook.com (2603:10a6:20b:45b::19) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20211222032514.896794-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 61076dd9-f90f-4514-b61c-08d9c4fab222 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UJ+cHfC79vTguh6WqLpD1ah2ciYuTsDc9sEbzpmCnpNtOyFuBhkfChRw7TSlM4gyd10nqKTwdIl8XcBCEUBmQJuEL1q7jqOTo/uzwCJQ4LWB9Jr/7U65SyKfzseXx5Hv/9Hh5uTwQ8QkDBEex6BK3O1B1J+WV8KLf08x5xpvncWxqATUSu/q7U6lH4kEjL0m+auU8dRHxyBeJQG4WZEfLkYyTKhaPHIxsiX/090OB1lM/s4K4ldd72xaffuXWWOiv/W+AHAo4F3iz33tyblXf4m9tde8POo8PNdXBUpv6m0moWnBwyfw2oLnQL2Hgg9Rn3HxSzm9sEY/1qwpZ/ybHZKHKlB+hBxzjPUL4ua+JXMUXV8W7YJoqsEuk0eR5JRBKBgKphaJQypC4nk2G/Ns6fK/4wstl1ESIqCiovB+bmnHUALZ89nnXBAO9ccabbzf/Swmysa323HMuozFS3Hgc9PBKaXsysUsWTEdnTYN2hv/kp6X84iBL+uBRgmDNibpvgHTj1jIpuFu45aNNzHSG9CIaTH9J/pkvzdAv2THVTgzqlPGPkc0R9W5Q//KNRT49g3WjdXKG5RPvC9H+dXk1wPaM2S8kYnfsjICS3E4xgL009ZdD682Qn1oI1LvhtTF4ixhdutQBLLhH56y+wkdOZVELXSLJTgSlQMSl/6XDWb0iWSAUg1D4pGKpxy+93KXSTuBilvPjm7YA== X-MS-TrafficTypeDiagnostic: AM6PR03MB4104:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HXZsHKAO+CRyETxvVndow2bOezHXokPiyc8b+eTiLE4NyGG7bR46nYm4nqoVW90wkbHR7ZZTMjQwSNnqEu0uI1oaLDKw8lY9wntTPVTpi1xyO9rTltUgpC7ixrfzn7VHkF5WlbCxt8tKiP/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hq84JSiPTQgb78zv70jrWKWkhLG2HXnwkwu2+7IjobI2SDhEMNt5Xg7KmzEvrOageXM3Ob8HDJep1sCcw+Z1WLeLH/wzxQ2bADl0Kf7QieVlWfW1TZOb/Q4ZsRs/Zq4bV+a8CUHGulAR1iUl7w1TZxviS6WiGcA9FwJm8cmQY4toj3Eq1+Jd1ylCb/kqXP7oh7siVQPYiYXIX2h0zO55q5d7Qq7/clGNnDVeYyGp2not1bHgygZL3SPUrty5c8EQF9VyPvD2fq9mNpHLTKJ8FZDujHnfH+rtVAO7M24SDDQjHK8/6n6uEi37e45GbaIXzEGnTPsDnrk9GAQNOZPcO3Vd1JNTEkWaqFKtHGwGmpbcRMsQFhx8iOvkTw/AOCP2zUJtI+s2bSoIUuOHAeE9K9CIP5g8odwjDETHLqrZfX7vhcxda+3mys6lg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61076dd9-f90f-4514-b61c-08d9c4fab222 X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Dec 2021 03:25:26.1154 (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: AM6PR03MB4104 Subject: [FFmpeg-devel] [PATCH 05/14] avcodec/mjpegenc: Add wrapper for ff_mjpeg_encode_picture_header() 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: Y9t1NezgaDFC This factors the translation from MpegEncContext out and will enable further optimizations in the next commits. Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegenc.c | 16 ++++++++++++++-- libavcodec/mjpegenc.h | 1 + libavcodec/mpegvideo_enc.c | 5 +---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 8b51058f5d..b682036f87 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -74,6 +74,19 @@ static av_cold void init_uni_ac_vlc(const uint8_t huff_size_ac[256], } } +static void mjpeg_encode_picture_header(MpegEncContext *s) +{ + ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable, + s->pred, s->intra_matrix, s->chroma_intra_matrix); +} + +void ff_mjpeg_amv_encode_picture_header(MpegEncContext *s) +{ + /* s->huffman == HUFFMAN_TABLE_OPTIMAL can only be true for MJPEG. */ + if (!CONFIG_MJPEG_ENCODER || s->huffman != HUFFMAN_TABLE_OPTIMAL) + mjpeg_encode_picture_header(s); +} + #if CONFIG_MJPEG_ENCODER /** * Encodes and outputs the entire frame in the JPEG format. @@ -213,8 +226,7 @@ int ff_mjpeg_encode_stuffing(MpegEncContext *s) s->intra_chroma_ac_vlc_length = s->intra_chroma_ac_vlc_last_length = m->uni_chroma_ac_vlc_len; - ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable, - s->pred, s->intra_matrix, s->chroma_intra_matrix); + mjpeg_encode_picture_header(s); mjpeg_encode_picture_frame(s); } #endif diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h index bc9b017e7a..555677e69a 100644 --- a/libavcodec/mjpegenc.h +++ b/libavcodec/mjpegenc.h @@ -105,6 +105,7 @@ static inline void put_marker(PutBitContext *p, enum JpegMarker code) } int ff_mjpeg_encode_init(MpegEncContext *s); +void ff_mjpeg_amv_encode_picture_header(MpegEncContext *s); void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]); int ff_mjpeg_encode_stuffing(MpegEncContext *s); diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 23e8a41a86..9807e491e5 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -3702,10 +3702,7 @@ static int encode_picture(MpegEncContext *s, int picture_number) switch(s->out_format) { #if CONFIG_MJPEG_ENCODER || CONFIG_AMV_ENCODER case FMT_MJPEG: - /* s->huffman == HUFFMAN_TABLE_OPTIMAL can only be true for MJPEG. */ - if (!CONFIG_MJPEG_ENCODER || s->huffman != HUFFMAN_TABLE_OPTIMAL) - ff_mjpeg_encode_picture_header(s->avctx, &s->pb, &s->intra_scantable, - s->pred, s->intra_matrix, s->chroma_intra_matrix); + ff_mjpeg_amv_encode_picture_header(s); break; #endif case FMT_SPEEDHQ: