From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 823B14A37F for ; Mon, 29 Apr 2024 21:19:46 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E5C9F68D5F2; Tue, 30 Apr 2024 00:16:50 +0300 (EEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2086.outbound.protection.outlook.com [40.92.91.86]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 75C5E68D5E0 for ; Tue, 30 Apr 2024 00:16:49 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G0kT7PhaKZxEY2sPspd6LyCgSasvnYrgtjGYpaXG8KEcX3jXnYjwFldnwK5yVEXWKxDgCrFU293MWzFGL5KHvX/fCXJJrvOhptjfj9se/HRHSpHd2gT7BWd6XBZi4LLRhBPBVoPCAXdWl2G6p7jyZs74vRe/lKJgPBSdtdfx/lTYo8H89SmU1pQR1q4o9pBiUG1N8KgXRVkDZJcvZgsQqyE4fM3q1cIzP7PdP8TawOtPPzNlU88DeGCmALRi3T9cWTsCWUWT+vXVr1k5W/GwE9F/KAHZ2rEZHcUQ2J1UuNiQJXi8Q5QC8zD4w3oBv0lnk397qtOSDXesQB6Y3ldPJA== 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=RTjCANA/ttW3ho2/1v4uVD3oRzV31fQifEwtY4UI0Tg=; b=kJVJ3JHgUyrvnhego9KO0vL+TjnIJcAKbg+V1FKx8pD6IfbdxeWSVy+F0XzDbe+u6uSWsZ9wYMtzy3BBXplg8D3oR6oaujilMG9J7qLUkVWCmhPc9WU4+bDZOoo4lZtj9JEXoOuCJ/W5SZ6elBPB6sOyyKrudKRWQ5yquHpdRGHd7ob7KOhkhheBTPAOW9Afn8ltCMaEuxd46RURH5hu3W7V8kE1dkv7RL5QOJpx8u7gt4RQQB8zcFzHX65Bf2q1130E5SOtSRg+CzHk7VGOXnmfuLzMolX607Px6bEPWa2FTS4JeNp2JuDVa0dfToojbsV1EQnUQNfRqnLMncl/0w== 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=RTjCANA/ttW3ho2/1v4uVD3oRzV31fQifEwtY4UI0Tg=; b=Ibd3d53dVaqMjp9PsKU35iW5DbC7sCKjY2TxrZJDAA8puizoY1lJz48fzF+i15WobMxV1TH01TG24BLIaMkv30mfoXU+HRiFOVEMI636jwbqU59ACnCkOA5nVUnCsrGX7n0hFsBy9LTvGSJZelhS1H1qZjnJkadVH6Gg/hVl6Lu31fHgQtuCbw2hF5UY5rGg5gjEnBMI47aQspBbl6lLUpjvZ2vTTWx4yBsiSmlyFbiPa/3JVpI9iaLonCzOrZAGAVQvPCoWUc7s2mOstQbSoydqr/AUEQedHY/CWtoHLIySQZ//FztQNZd5tHF2ehyBCqJEGeecKaVdkC0gUen0bg== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PRAP250MB0616.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:297::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 21:16:47 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7519.031; Mon, 29 Apr 2024 21:16:46 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 29 Apr 2024 23:14:26 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [cQZwZuzPD5Nf46nojybnO0YtXZJ04HyAdZBsaCOkaB4=] X-ClientProxiedBy: ZR0P278CA0199.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:6a::21) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240429211438.3274834-31-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PRAP250MB0616:EE_ X-MS-Office365-Filtering-Correlation-Id: 09efff0e-8ab7-4a29-10a3-08dc6891ad51 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|3412199016|440099019|1710799017; X-Microsoft-Antispam-Message-Info: /ISA+DVptDsfHpvNAbfNwxNC1cKwZsrzKOa4GYE9QCPqHOGAvOrpPz8SvWSajx3PKc+E7aD9ekBqNKqvC4Wrrpxt59S5E1AFNoLynjbSdZdG2ApzZwXlGxwfQQeo/oft/VHEYvC/xcdM6WcWTsV+4AxsUWaGOCKo6ojjifisCZdLCsdgW4Au+t9iH816MgMZ2iDWbrAp4FXp3ObRIdlcT8hYC1HzsSCFoKzD+/oB2mGNlq02CJCW9ocH2LdFjgT1r3aYFQWshmNcWgiCoW6dc+s9HcNoe1rDnfLH6r21VGREjr4GO1RwxGh4Me44DCQTvD0eWuK+gLvb6/KrCjDjz83nmAHHsMOEqCNxNTz/cEwhCtRNxMRYJHtAZYmFFjo5SViYru0DQMCd6Yo13Pvv9DzSjfopYC3SsWXYvmR/wuuwUvkP+xQ7A0iWXAnSEgBDuUdrmvG4xbcXo6ujwqQ0qOO0hwwm/eMbvbUq5lkxdWaSIBzHoUugw8Hr5RzYJuVkkvsytqryLY6btiSFNH92/1sJuASeFjzqbfWIKMUbHKS76EVlpEJvyUPfF+Y8h11WY5RWeLkqRKui5mYc0r2oqxsIKy0F0Bl3pRx5+7Md96vty7I+DL+9ExDTJZlFrd79 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?4g50PuPm/Y1nkIzqXXztBiVn6e5TYF0PllAd2C206Eh1HQYmutCoy9TXgE5v?= =?us-ascii?Q?3KsKNt5sp/Ropf9w75rb0z/KNWutmlD0VSWHCdQew3JiX1GQ+ign7bhrkr1v?= =?us-ascii?Q?sctQoRtxR0rcLGQegvMfmIbBuOt4xLBFA4jUGzuh1M7IgyFE1EhXmKL18FfX?= =?us-ascii?Q?ahFSa6dWADcZwcwU7ZMhbYGusZOrNL3mjPX0Z8g4AvY08aYI7CGjyDWja7Vf?= =?us-ascii?Q?33o5r8PWSYC8l64U6U8+DqH2I5kyKipRj5fwxIEGXWTbYBR/qqMEBifWNAW0?= =?us-ascii?Q?FZWeDb/8/8Z3uHMcEyw6mlliw/ahdPTmR1tVMGZXzXwIU230FlU++azkStFh?= =?us-ascii?Q?ArELub2CfvnuH7k5R1Ag62abL6jdj664L4Q0Kgu1uI+Ecx8ppmvKEbsXyk6x?= =?us-ascii?Q?WzksgQF/zUPgG4omWzQvQTBxI7+RNwQVGsPX4wAX6g5NF9R8wDIKltCi8SLN?= =?us-ascii?Q?ciaADWTa88lKi3ylTjvmaH0yieTL6lPjNMl3Vcv/bn14qdq1C41GcGVdLJaw?= =?us-ascii?Q?IdM/dE+8YeraGeivPPiX3IfMuc3AwrtD0XfU8dQJIHs2UAWdrU4Wmb3umILb?= =?us-ascii?Q?dq5cfMWH9m4rjl1G0rpDKEqH6bexlYTt3c49ZBHAyGdZoXz4QxjB+HIFB7Ql?= =?us-ascii?Q?MvHcpjM6W1heTKoOtOOyladTL63AxpJlt//EWEVbsqXy8u8jTXp+4mOa2i4R?= =?us-ascii?Q?8btIfodoX0xJ1tLfZ9AP1iINQpyXeS0WQKbSGBLVi1nvLzYaUapLRt/+4R9N?= =?us-ascii?Q?R6pmGvI8wI9ThUYfoz7WR5Bk7MbkNlY5H1gja2+tmlum5F46UFMXlviAou/V?= =?us-ascii?Q?FWVvqIkfNmGEf50DnkMdYdVmIFCteVljc6e7qzPOxgyTyYszwZnFHRiXzLp7?= =?us-ascii?Q?C+00opbI57xcLt4qXbmFrL797Y8xEoJPAtoOnPF0wAJv//D5S0iEVFu07tYw?= =?us-ascii?Q?H9tNNe0eS333vEFehcM7KMGgeyAlE7a3+Y4Iow9IHmgfZhaAlEwm2n2/vXPe?= =?us-ascii?Q?OKqW77UtYWOdN0x2g5dAhNXSB8dZp7NF/efUgo2kn2FVUFkZKNyeQnUbogWE?= =?us-ascii?Q?ArnHy9I1Q4bLIk79I0okorNUhbwntXatF++urySi1XqtjkqArCVwL+flKlTp?= =?us-ascii?Q?YvC8Lkf40gtG6W2gS1mRufa9V7+wCCi415Om5kLyOHXuth8vlflN/V4z5aSF?= =?us-ascii?Q?r5UB/jshB8+Ouzt80/AVNDe6m0dGGBE3504/fYEA6/FwPu7l2HSjRHsMX8Q1?= =?us-ascii?Q?UX5ZNkQxV5X32R21FO3spek3zkLyYkyonp8pfhKz0w=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09efff0e-8ab7-4a29-10a3-08dc6891ad51 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 21:16:46.8900 (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: PRAP250MB0616 Subject: [FFmpeg-devel] [PATCH 45/57] avcodec/mpegpicture: Use ThreadProgress instead of ThreadFrame API 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Given that MPVPictures are already directly shared between threads in case of frame-threaded decoding, one can simply use it to pass decoding progress information between threads. This allows to avoid one level of indirection; it also means avoids allocations (of the ThreadFrameProgress structure) in case of frame-threading and indeed makes ff_thread_release_ext_buffer() decoder-only (actually, H.264-decoder-only). Signed-off-by: Andreas Rheinhardt --- libavcodec/error_resilience.c | 13 ++++++++---- libavcodec/error_resilience.h | 1 + libavcodec/mpeg4videodec.c | 8 ++++---- libavcodec/mpeg_er.c | 2 +- libavcodec/mpegpicture.c | 19 ++++++++++++------ libavcodec/mpegpicture.h | 6 +++--- libavcodec/mpegvideo_dec.c | 25 +++++++++++++----------- libavcodec/mpegvideo_enc.c | 2 +- libavcodec/mpv_reconstruct_mb_template.c | 8 ++++---- libavcodec/pthread_frame.c | 5 ----- libavcodec/rv34.c | 16 +++++++-------- 11 files changed, 58 insertions(+), 47 deletions(-) diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c index 66d03987b6..56844d5084 100644 --- a/libavcodec/error_resilience.c +++ b/libavcodec/error_resilience.c @@ -34,6 +34,7 @@ #include "mpegutils.h" #include "mpegvideo.h" #include "threadframe.h" +#include "threadprogress.h" /** * @param stride the number of MVs to get to the next row @@ -409,8 +410,12 @@ static void guess_mv(ERContext *s) set_mv_strides(s, &mot_step, &mot_stride); num_avail = 0; - if (s->last_pic.motion_val[0]) - ff_thread_await_progress(s->last_pic.tf, mb_height-1, 0); + if (s->last_pic.motion_val[0]) { + if (s->last_pic.tf) + ff_thread_await_progress(s->last_pic.tf, mb_height-1, 0); + else + ff_thread_progress_await(s->last_pic.progress, mb_height - 1); + } for (i = 0; i < mb_width * mb_height; i++) { const int mb_xy = s->mb_index2xy[i]; int f = 0; @@ -763,7 +768,7 @@ static int is_intra_more_likely(ERContext *s) if (s->avctx->codec_id == AV_CODEC_ID_H264) { // FIXME } else { - ff_thread_await_progress(s->last_pic.tf, mb_y, 0); + ff_thread_progress_await(s->last_pic.progress, mb_y); } is_intra_likely += s->sad(NULL, last_mb_ptr, mb_ptr, linesize[0], 16); @@ -1198,7 +1203,7 @@ void ff_er_frame_end(ERContext *s, int *decode_error_flags) int time_pb = s->pb_time; av_assert0(s->avctx->codec_id != AV_CODEC_ID_H264); - ff_thread_await_progress(s->next_pic.tf, mb_y, 0); + ff_thread_progress_await(s->next_pic.progress, mb_y); s->mv[0][0][0] = s->next_pic.motion_val[0][xy][0] * time_pb / time_pp; s->mv[0][0][1] = s->next_pic.motion_val[0][xy][1] * time_pb / time_pp; diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h index 1346639c3c..a1b9b9ec1a 100644 --- a/libavcodec/error_resilience.h +++ b/libavcodec/error_resilience.h @@ -40,6 +40,7 @@ typedef struct ERPicture { AVFrame *f; const struct ThreadFrame *tf; + const struct ThreadProgress *progress; // it is the caller's responsibility to allocate these buffers int16_t (*motion_val[2])[2]; diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index b07d016a8b..a1ae86bbe0 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -45,7 +45,7 @@ #include "internal.h" #include "profiles.h" #include "qpeldsp.h" -#include "threadframe.h" +#include "threadprogress.h" #include "xvididct.h" #include "unary.h" @@ -1807,7 +1807,7 @@ static int mpeg4_decode_mb(MpegEncContext *s, int16_t block[6][64]) s->last_mv[i][1][1] = 0; } - ff_thread_await_progress(&s->next_pic.ptr->tf, s->mb_y, 0); + ff_thread_progress_await(&s->next_pic.ptr->progress, s->mb_y); } /* if we skipped it in the future P-frame than skip it now too */ @@ -2012,10 +2012,10 @@ end: if (s->pict_type == AV_PICTURE_TYPE_B) { const int delta = s->mb_x + 1 == s->mb_width ? 2 : 1; - ff_thread_await_progress(&s->next_pic.ptr->tf, + ff_thread_progress_await(&s->next_pic.ptr->progress, (s->mb_x + delta >= s->mb_width) ? FFMIN(s->mb_y + 1, s->mb_height - 1) - : s->mb_y, 0); + : s->mb_y); if (s->next_pic.mbskip_table[xy + delta]) return SLICE_OK; } diff --git a/libavcodec/mpeg_er.c b/libavcodec/mpeg_er.c index f9421ec91f..e7b3197bb1 100644 --- a/libavcodec/mpeg_er.c +++ b/libavcodec/mpeg_er.c @@ -34,7 +34,7 @@ static void set_erpic(ERPicture *dst, const MPVPicture *src) } dst->f = src->f; - dst->tf = &src->tf; + dst->progress = &src->progress; for (i = 0; i < 2; i++) { dst->motion_val[i] = src->motion_val[i]; diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index caba4ea2e9..d175bbc924 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -28,13 +28,13 @@ #include "motion_est.h" #include "mpegpicture.h" #include "refstruct.h" -#include "threadframe.h" static void mpv_pic_reset(FFRefStructOpaque unused, void *obj) { MPVPicture *pic = obj; - ff_thread_release_ext_buffer(&pic->tf); + av_frame_unref(pic->f); + ff_thread_progress_reset(&pic->progress); ff_refstruct_unref(&pic->hwaccel_picture_private); @@ -66,14 +66,18 @@ static void mpv_pic_reset(FFRefStructOpaque unused, void *obj) pic->coded_picture_number = 0; } -static int av_cold mpv_pic_init(FFRefStructOpaque unused, void *obj) +static int av_cold mpv_pic_init(FFRefStructOpaque opaque, void *obj) { MPVPicture *pic = obj; + int ret, init_progress = (uintptr_t)opaque.nc; + + ret = ff_thread_progress_init(&pic->progress, init_progress); + if (ret < 0) + return ret; pic->f = av_frame_alloc(); if (!pic->f) return AVERROR(ENOMEM); - pic->tf.f = pic->f; return 0; } @@ -81,12 +85,15 @@ static void av_cold mpv_pic_free(FFRefStructOpaque unused, void *obj) { MPVPicture *pic = obj; + ff_thread_progress_destroy(&pic->progress); av_frame_free(&pic->f); } -av_cold FFRefStructPool *ff_mpv_alloc_pic_pool(void) +av_cold FFRefStructPool *ff_mpv_alloc_pic_pool(int init_progress) { - return ff_refstruct_pool_alloc_ext(sizeof(MPVPicture), 0, NULL, + return ff_refstruct_pool_alloc_ext(sizeof(MPVPicture), + FF_REFSTRUCT_POOL_FLAG_FREE_ON_INIT_ERROR, + (void*)(uintptr_t)init_progress, mpv_pic_init, mpv_pic_reset, mpv_pic_free, NULL); } diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h index 63cf092806..b66fedc132 100644 --- a/libavcodec/mpegpicture.h +++ b/libavcodec/mpegpicture.h @@ -26,7 +26,7 @@ #include "avcodec.h" #include "motion_est.h" -#include "threadframe.h" +#include "threadprogress.h" #define MPV_MAX_PLANES 3 #define EDGE_WIDTH 16 @@ -55,7 +55,7 @@ typedef struct BufferPoolContext { */ typedef struct MPVPicture { struct AVFrame *f; - ThreadFrame tf; + ThreadProgress progress; int8_t *qscale_table_base; int8_t *qscale_table; @@ -112,7 +112,7 @@ typedef struct MPVWorkPicture { /** * Allocate a pool of MPVPictures. */ -struct FFRefStructPool *ff_mpv_alloc_pic_pool(void); +struct FFRefStructPool *ff_mpv_alloc_pic_pool(int init_progress); /** * Allocate an MPVPicture's accessories (but not the AVFrame's buffer itself) diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c index d596f94df3..b7f72ad460 100644 --- a/libavcodec/mpegvideo_dec.c +++ b/libavcodec/mpegvideo_dec.c @@ -40,11 +40,13 @@ #include "mpeg4videodec.h" #include "refstruct.h" #include "thread.h" -#include "threadframe.h" +#include "threadprogress.h" #include "wmv2dec.h" int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx) { + enum ThreadingStatus thread_status; + ff_mpv_common_defaults(s); s->avctx = avctx; @@ -59,9 +61,12 @@ int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx) ff_mpv_idct_init(s); ff_h264chroma_init(&s->h264chroma, 8); //for lowres - if (!s->picture_pool && // VC-1 can call this multiple times - ff_thread_sync_ref(avctx, offsetof(MpegEncContext, picture_pool))) { - s->picture_pool = ff_mpv_alloc_pic_pool(); + if (s->picture_pool) // VC-1 can call this multiple times + return 0; + + thread_status = ff_thread_sync_ref(avctx, offsetof(MpegEncContext, picture_pool)); + if (thread_status != FF_THREAD_IS_COPY) { + s->picture_pool = ff_mpv_alloc_pic_pool(thread_status != FF_THREAD_NO_FRAME_THREADING); if (!s->picture_pool) return AVERROR(ENOMEM); } @@ -229,7 +234,6 @@ static int alloc_picture(MpegEncContext *s, MPVWorkPicture *dst, int reference) dst->ptr = pic; - pic->tf.f = pic->f; pic->reference = reference; /* WM Image / Screen codecs allocate internal buffers with different @@ -237,8 +241,8 @@ static int alloc_picture(MpegEncContext *s, MPVWorkPicture *dst, int reference) if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE && avctx->codec_id != AV_CODEC_ID_VC1IMAGE && avctx->codec_id != AV_CODEC_ID_MSS2) { - ret = ff_thread_get_ext_buffer(avctx, &pic->tf, - reference ? AV_GET_BUFFER_FLAG_REF : 0); + ret = ff_thread_get_buffer(avctx, pic->f, + reference ? AV_GET_BUFFER_FLAG_REF : 0); } else { pic->f->width = avctx->width; pic->f->height = avctx->height; @@ -281,8 +285,7 @@ static int av_cold alloc_dummy_frame(MpegEncContext *s, MPVWorkPicture *dst) pic = dst->ptr; pic->dummy = 1; - ff_thread_report_progress(&pic->tf, INT_MAX, 0); - ff_thread_report_progress(&pic->tf, INT_MAX, 1); + ff_thread_progress_report(&pic->progress, INT_MAX); return 0; } @@ -418,7 +421,7 @@ void ff_mpv_frame_end(MpegEncContext *s) emms_c(); if (s->cur_pic.reference) - ff_thread_report_progress(&s->cur_pic.ptr->tf, INT_MAX, 0); + ff_thread_progress_report(&s->cur_pic.ptr->progress, INT_MAX); } void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict) @@ -484,7 +487,7 @@ void ff_mpeg_flush(AVCodecContext *avctx) void ff_mpv_report_decode_progress(MpegEncContext *s) { if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame && !s->er.error_occurred) - ff_thread_report_progress(&s->cur_pic.ptr->tf, s->mb_y, 0); + ff_thread_progress_report(&s->cur_pic.ptr->progress, s->mb_y); } diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index e65a30f96f..a7e9a3d443 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -823,7 +823,7 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_B_FRAMES + 1) || !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_B_FRAMES + 1) || !(s->new_pic = av_frame_alloc()) || - !(s->picture_pool = ff_mpv_alloc_pic_pool())) + !(s->picture_pool = ff_mpv_alloc_pic_pool(0))) return AVERROR(ENOMEM); /* Allocate MV tables; the MV and MB tables will be copied diff --git a/libavcodec/mpv_reconstruct_mb_template.c b/libavcodec/mpv_reconstruct_mb_template.c index 0b7a6a6d31..502e66faea 100644 --- a/libavcodec/mpv_reconstruct_mb_template.c +++ b/libavcodec/mpv_reconstruct_mb_template.c @@ -124,12 +124,12 @@ void mpv_reconstruct_mb_internal(MpegEncContext *s, int16_t block[12][64], if (HAVE_THREADS && is_mpeg12 != DEFINITELY_MPEG12 && s->avctx->active_thread_type & FF_THREAD_FRAME) { if (s->mv_dir & MV_DIR_FORWARD) { - ff_thread_await_progress(&s->last_pic.ptr->tf, - lowest_referenced_row(s, 0), 0); + ff_thread_progress_await(&s->last_pic.ptr->progress, + lowest_referenced_row(s, 0)); } if (s->mv_dir & MV_DIR_BACKWARD) { - ff_thread_await_progress(&s->next_pic.ptr->tf, - lowest_referenced_row(s, 1), 0); + ff_thread_progress_await(&s->next_pic.ptr->progress, + lowest_referenced_row(s, 1)); } } diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 67f09c1f48..fd7819f52d 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -985,11 +985,6 @@ int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags) int ret; f->owner[0] = f->owner[1] = avctx; - /* Hint: It is possible for this function to be called with codecs - * that don't support frame threading at all, namely in case - * a frame-threaded decoder shares code with codecs that are not. - * This currently affects non-MPEG-4 mpegvideo codecs. - * The following check will always be true for them. */ if (!(avctx->active_thread_type & FF_THREAD_FRAME)) return ff_get_buffer(avctx, f->f, flags); diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index 94d5ee30df..d3816df059 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -43,7 +43,7 @@ #include "qpeldsp.h" #include "rectangle.h" #include "thread.h" -#include "threadframe.h" +#include "threadprogress.h" #include "rv34vlc.h" #include "rv34data.h" @@ -719,8 +719,8 @@ static inline void rv34_mc(RV34DecContext *r, const int block_type, if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) { /* wait for the referenced mb row to be finished */ int mb_row = s->mb_y + ((yoff + my + 5 + 8 * height) >> 4); - const ThreadFrame *f = dir ? &s->next_pic.ptr->tf : &s->last_pic.ptr->tf; - ff_thread_await_progress(f, mb_row, 0); + const ThreadProgress *p = dir ? &s->next_pic.ptr->progress : &s->last_pic.ptr->progress; + ff_thread_progress_await(p, mb_row); } dxy = ly*4 + lx; @@ -899,7 +899,7 @@ static int rv34_decode_mv(RV34DecContext *r, int block_type) //surprisingly, it uses motion scheme from next reference frame /* wait for the current mb row to be finished */ if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) - ff_thread_await_progress(&s->next_pic.ptr->tf, FFMAX(0, s->mb_y-1), 0); + ff_thread_progress_await(&s->next_pic.ptr->progress, FFMAX(0, s->mb_y-1)); next_bt = s->next_pic.mb_type[s->mb_x + s->mb_y * s->mb_stride]; if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){ @@ -1483,8 +1483,8 @@ static int rv34_decode_slice(RV34DecContext *r, int end, const uint8_t* buf, int r->loop_filter(r, s->mb_y - 2); if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) - ff_thread_report_progress(&s->cur_pic.ptr->tf, - s->mb_y - 2, 0); + ff_thread_progress_report(&s->cur_pic.ptr->progress, + s->mb_y - 2); } if(s->mb_x == s->resync_mb_x) @@ -1582,7 +1582,7 @@ static int finish_frame(AVCodecContext *avctx, AVFrame *pict) s->mb_num_left = 0; if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) - ff_thread_report_progress(&s->cur_pic.ptr->tf, INT_MAX, 0); + ff_thread_progress_report(&s->cur_pic.ptr->progress, INT_MAX); if (s->pict_type == AV_PICTURE_TYPE_B) { if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0) @@ -1810,7 +1810,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict, ff_er_frame_end(&s->er, NULL); ff_mpv_frame_end(s); s->mb_num_left = 0; - ff_thread_report_progress(&s->cur_pic.ptr->tf, INT_MAX, 0); + ff_thread_progress_report(&s->cur_pic.ptr->progress, INT_MAX); return AVERROR_INVALIDDATA; } } -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".