From patchwork Tue Feb 1 13:06:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34029 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2c4e:0:0:0:0 with SMTP id x14csp611870iov; Tue, 1 Feb 2022 05:21:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXxNVW7ksCUZzwSb4KDfR2m9KVflYFZgBdUDcL3s8hlKHr1RUu8m+d+n423cYV2ww1Aznw X-Received: by 2002:a17:907:72c6:: with SMTP id du6mr21766620ejc.224.1643721710799; Tue, 01 Feb 2022 05:21:50 -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 p17si8977917edx.495.2022.02.01.05.21.50; Tue, 01 Feb 2022 05:21:50 -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=Pvv+r1Cl; 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 E98AF68B445; Tue, 1 Feb 2022 15:09:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2076.outbound.protection.outlook.com [40.92.91.76]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D54F68B3E5 for ; Tue, 1 Feb 2022 15:08:50 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MEpM7wcnEc5eZh8SDWQYb7ffwXhJOY5Q+xGkI0mzFr2LnpM7D9FM0Ajb1YDEzyLPC4Vo12NceGNe6g42YohMqe5Omb8hpwVJt8OMLDLeYF6yfJeHRsAGaoV8KjeXk3zHWlXUYhDjxaweWgjSSauyySdVi+C2rWO3AzgPg4onEx+6iOkHpwtl0bScXKtRy/4/auogjHPdyVUM0RHuLgxvElsDrG4StypOGVUIAsavdljbjjagQJWjTHZo0UWVC5uWtx6E8B26sWtz3VUgG9iWKNEV2zDA1/UCHHYXHeRIzjhz7HPPa4PFqGk2WqzDGbrDv4ShYSUVaQugaamHSBEk8g== 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=jbdspMP6qUkCfj2j6a27v7eU2SZNoIzNVBtE4OYxoC4=; b=HPJEMjmtCwRbnLvpaD3czpjV2zPMHy5rYY+qduLrXTFRIckFr6AEn4gxnbv5dQX/jkj4u70yRnyuoO+LlqNOMQ8BjfD/GkvGDLDg5RiZp3xRlNdN0vLBO00lMWQ1c39AWa68XxOj0ktJHuaov3jsg3OEom/vdRo8X2dwSgvTqeXv1mOlLQf0NEQl7jzS+3dN5O/aLZ5R/nkSqV3WIeDHknDAG7xwBHAoqKooIdcILmuZNRPE149boCEprDmIhdr9AHTbasxF/RmxUaMJngl2sZVgjcnlpJOoGJ86Q9GOG7+ZD70Nt9aQNKC0VTlJogqTUxEFR8NlBQ4dHeyf6mgHZQ== 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=jbdspMP6qUkCfj2j6a27v7eU2SZNoIzNVBtE4OYxoC4=; b=Pvv+r1Cl19wtquNmwM4a2yyzNOe7vJNnXdlZvgUuVj7pkftUBFnwM4LfXfdvTf2aBoiEsig81AOIGvaIER8xABR9xTsIBVM+mSsA4Us/yx3UlXtPF5ouvr072mtD1hd8Fpq8Za8XpUWadEUQEu7Vsx6dCRrTIarBWoXQfZj6CV5m6KO+sNgCumODy35/8/I5lw5skMgMYyy2kmkIvt6i/8maFSpAHHu6Yw05WbmzWehN9Tm1+95sOJW7A1s5wUGpBtZGAiIpY+cqpwPI6t8nsjCq9XnbKi/Ww7mrVvw4+oeHl4JNI0P5FlvaT/8n2VS19vWJ9/XnI6qZfCQACqlcMg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM9PR03MB7962.eurprd03.prod.outlook.com (2603:10a6:20b:439::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.22; Tue, 1 Feb 2022 13:08:48 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ac56:2ff4:d304:ab22%6]) with mapi id 15.20.4951.011; Tue, 1 Feb 2022 13:08:48 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 1 Feb 2022 14:06:57 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [1KSEKsXxXR5opeUu93R12ZdJQbUl0TPT] X-ClientProxiedBy: AM6P195CA0092.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::33) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220201130706.1420875-59-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eae15c4f-e9eb-488b-d834-08d9e583fc3a X-MS-TrafficTypeDiagnostic: AM9PR03MB7962:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5Q8uHVixix3k1UrTA7RhlElsMSfyaUZj7qOxs81etvLMYFK3nfTQO0yapk3CmiytfEnbbQe+ukPvHz5tcHf6sS+JtRn8h5K9XSrNKKB79ao036hpvF4ijLK9xy4jBuqAJQVH8OW4BsuUUlY//F7l0VV5G1/3Pk4nTxSz1c/86t0TbUnVosyayeSZnWj0o4W5bnloC4aT+r8OQHJ0MkHiWZJ1Y3YVqvCS3IOjQuNvXvVvVbq4/Cg3o4+1hDle/gjz9zq3tj+8qY/zp24b/Mq9HfTXUhJV5Lym8yZ67vW9jFNENh0HZIG+B9SqVVRPKNViF5w1MDrk4KUjYzhzZAbhlxlC6lx8Yryl8Hk+kjKYnwIjQuEd30oGiTvVvL4J6qDL8AK++pVhJIeib950DDSUA6n/pTDLgoH8Nso80BX0ohFpKPylio17cNsaSMavrSjgX1LNICjlzSpatlYLYIeqv/yEs5ZFyp7AP+i5Wy6wj7WRW2ejK2Cctg+kNVgrhkLaGs/fkWdCP5hx8tQw4UNK8V34f6cBnhvyh7xOVLGtNM0fzlR0rpYI0eEHWb46+H9q X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UAyNQWiY7ILqKN9hRQFqglzjm+UL7QHxTzeStUAocCzd0p45hDi59eTrrJQhQl+O/qOe+A7ky00hYq44mJ1fMHITp4S7O5j3p4JF9F2UZFTbbVCtHkSO+8y868RDJF6lXamDauOj826SuQ4vCB3CdAkHFGsUfXUC/WsbxkgH7WZt0mlT7M/ATG8PCfA5Qo/pevXjbKfVvE7daEL+54X3WlH89cPth9ufd36BakAfrsA56K01+Ql8hKsyPFaqUrRM9UCbUbpcIUk+3ViL4/u9Qo7uUt0rZ6hk6Gd88PYoVftVTDM0CGyLT5AMPb0lXhElhrR6MSKBPi010aLAg0URT5Qs/6wbVxvFy7bZncaLq7e26h1WXtkP1z/9FcbFvQycKixqkMYw2TpSX3xrCbGyEAE3Eb2dN7KeFtO1K+tLolDIone7Na7bZL5TXujotOuzKbBTmWMjcnbsKpNidw7KD/7TGUrR2tLGFoxNIyofR1ijoNK3/n5MeAkJKKAgpLu7z0q+Y9WWf1YDgn5MEC4jzJ43+U7hSy8TUehzkDQqIcikHF9lYoKTrXZ5mgWVc9hhQKGr+SEY8zdxmMt59iwzqnNEHeMbGWoyTX/vsXe3mYC5XyyOHLLobvoPnypOupM1rcal2RJkSK2TEYU/dj3pN2FIThQEhiqOvjouBV1ZQsyPrfva9MHT4uBtrizPCdjWKsNZgdNWlqqls5g77LYHjhMc+i8L+cC9FFd8OzrrtQJDtHHGstNH5aCYpo1RRkGmq/Jg+KLlLd8kpBpYOPnTTjATBFiH26JSEs1Au+bbHDlknadWLrjz3Z3MDVaIFQ1rTP/siQ16FIx7BtoMOxbk0qOYtiwZd8PQ6tmWWpRGxy1RAs7EIrIcazgpwA7DIB0P5S1VxOzmgH3Ha1ZFaYtvvRLeX9rdCYf6aCpkf8S40hBeNk/D3CtHZXYsyeeTd4Av4qioKS7sH/zMx+y8UCGYNg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: eae15c4f-e9eb-488b-d834-08d9e583fc3a X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Feb 2022 13:08:48.5921 (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: AM9PR03MB7962 Subject: [FFmpeg-devel] [PATCH v2 60/69] avcodec/mpegvideo: Move slice_context_count to MPVMainContext 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: 204R6htPJpvx Signed-off-by: Andreas Rheinhardt --- libavcodec/mjpegenc.c | 6 +++--- libavcodec/mpeg12dec.c | 4 ++-- libavcodec/mpeg4video_parser.c | 2 +- libavcodec/mpegvideo.c | 13 ++++++------- libavcodec/mpegvideo.h | 3 ++- libavcodec/mpegvideo_enc.c | 8 ++++---- libavcodec/vc1_parser.c | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 70636ffc91..bf6371768a 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -82,10 +82,10 @@ static void mjpeg_encode_picture_header(MPVMainEncContext *m) ff_mjpeg_encode_picture_header(s->avctx, &s->pb, s->mjpeg_ctx, &s->intra_scantable, 0, s->intra_matrix, s->chroma_intra_matrix, - s->slice_context_count > 1); + m2->slice_context_count > 1); s->esc_pos = put_bytes_count(&s->pb, 0); - for (int i = 1; i < s->slice_context_count; i++) + for (int i = 1; i < m2->slice_context_count; i++) m2->thread_context[i]->esc_pos = 0; } @@ -255,7 +255,7 @@ int ff_mjpeg_encode_stuffing(MPVEncContext *s) ff_mjpeg_escape_FF(pbc, s->esc_pos); - if (s->slice_context_count > 1 && mb_y < s->mb_height - 1) + if (s->parent_ctx->slice_context_count > 1 && mb_y < s->mb_height - 1) put_marker(pbc, RST0 + (mb_y&7)); s->esc_pos = put_bytes_count(pbc, 0); diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 925c72e8ff..69d0bb809b 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -2770,8 +2770,8 @@ static int decode_chunks(AVCodecContext *avctx, AVFrame *picture, (avctx->active_thread_type & FF_THREAD_SLICE) && !avctx->hwaccel) { int threshold = (s2->mb_height * s->slice_count + - s2->slice_context_count / 2) / - s2->slice_context_count; + m2->slice_context_count / 2) / + m2->slice_context_count; av_assert0(avctx->thread_count > 1); if (threshold <= mb_y) { MPVDecContext *const thread_context = m2->thread_context[s->slice_count]; diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c index adc2409953..a7909d92ec 100644 --- a/libavcodec/mpeg4video_parser.c +++ b/libavcodec/mpeg4video_parser.c @@ -132,7 +132,7 @@ static av_cold int mpeg4video_parse_init(AVCodecParserContext *s) pc->first_picture = 1; pc->dec_ctx.m.s.quant_precision = 5; - pc->dec_ctx.m.s.slice_context_count = 1; + pc->dec_ctx.m.slice_context_count = 1; pc->dec_ctx.showed_packed_warning = 1; return 0; } diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 4b22eb746a..0e98680056 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -394,7 +394,7 @@ static int init_duplicate_context(MPVContext *s) int ff_mpv_init_duplicate_contexts(MPVMainContext *m) { MPVContext *const s = &m->s; - int nb_slices = s->slice_context_count, ret; + int nb_slices = m->slice_context_count, ret; s->parent_ctx = m; @@ -443,7 +443,7 @@ static void free_duplicate_contexts(MPVMainContext *m) { MPVContext *const s = &m->s; - for (int i = 1; i < s->slice_context_count; i++) { + for (int i = 1; i < m->slice_context_count; i++) { free_duplicate_context(m->thread_context[i]); av_freep(&m->thread_context[i]); } @@ -525,7 +525,7 @@ void ff_mpv_common_defaults(MPVMainContext *m) s->f_code = 1; s->b_code = 1; - s->slice_context_count = 1; + m->slice_context_count = 1; s->parent_ctx = m; } @@ -625,7 +625,6 @@ static void clear_context(MPVMainContext *m) memset(&s->current_picture, 0, sizeof(s->current_picture)); memset(&s->new_picture, 0, sizeof(s->new_picture)); - s->slice_context_count = 1; s->me.map = NULL; s->me.score_map = NULL; s->dct_error_sum = NULL; @@ -740,7 +739,7 @@ av_cold int ff_mpv_common_init(MPVMainContext *m) s->context_initialized = 1; m->thread_context[0] = s; - s->slice_context_count = nb_slices; + m->slice_context_count = nb_slices; // if (s->width && s->height) { ret = ff_mpv_init_duplicate_contexts(m); @@ -791,8 +790,8 @@ void ff_mpv_common_end(MPVMainContext *m) s = &m->s; ff_mpv_free_context_frame(m); - if (s->slice_context_count > 1) - s->slice_context_count = 1; + if (m->slice_context_count > 1) + m->slice_context_count = 1; #if FF_API_FLAG_TRUNCATED av_freep(&s->parse_context.buffer); diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 1c44e9be2f..4a03cde7fe 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -122,7 +122,6 @@ typedef struct MPVContext { int start_mb_y; ///< start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) int end_mb_y; ///< end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) - int slice_context_count; ///< number of used thread_contexts /** * copy of the previous picture structure. @@ -507,6 +506,8 @@ typedef struct MPVContext { */ typedef struct MPVMainContext { MPVContext s; + + int slice_context_count; ///< number of used thread_contexts /* The first entry of this array points to the above MPVContext. */ MPVContext *thread_context[MAX_THREADS]; } MPVMainContext; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 735c9d322f..aef4de0fe6 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -885,7 +885,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant) s->chroma_qscale_table = ff_h263_chroma_qscale_table; - if (s->slice_context_count > 1) { + if (m2->slice_context_count > 1) { s->rtp_mode = 1; if (avctx->codec_id == AV_CODEC_ID_H263P) @@ -1749,7 +1749,7 @@ int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, MPVMainContext *const m2 = &m->common; MPVEncContext *const s = &m2->s; int i, stuffing_count, ret; - int context_count = s->slice_context_count; + int context_count = m2->slice_context_count; s->vbv_ignore_qmax = 0; @@ -2795,7 +2795,7 @@ static void update_mb_info(MPVEncContext *s, int startcode) int ff_mpv_reallocate_putbitbuffer(MPVEncContext *s, size_t threshold, size_t size_increase) { if (put_bytes_left(&s->pb, 0) < threshold - && s->slice_context_count == 1 + && s->parent_ctx->slice_context_count == 1 && s->pb.buf == s->avctx->internal->byte_buffer) { int lastgob_pos = s->ptr_lastgob - s->pb.buf; @@ -3561,7 +3561,7 @@ static int encode_picture(MPVMainEncContext *m, int picture_number) MPVEncContext *const s = &m2->s; int i, ret; int bits; - int context_count = s->slice_context_count; + int context_count = m2->slice_context_count; s->picture_number = picture_number; diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c index b320826e5b..af5ff5028a 100644 --- a/libavcodec/vc1_parser.c +++ b/libavcodec/vc1_parser.c @@ -259,7 +259,7 @@ static int vc1_parse(AVCodecParserContext *s, static av_cold int vc1_parse_init(AVCodecParserContext *s) { VC1ParseContext *vpc = s->priv_data; - vpc->v.s.s.slice_context_count = 1; + vpc->v.s.slice_context_count = 1; vpc->v.first_pic_header_flag = 1; vpc->prev_start_code = 0; vpc->bytes_to_skip = 0;