From patchwork Mon Apr 8 20:13:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47942 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3f98:b0:1a7:a0dc:8de5 with SMTP id ay24csp135611pzb; Mon, 8 Apr 2024 13:15:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVfOB5ValnOKmyI0r6TMUo6EaF23D3J/YNcLYyT6Y+NgKhbGPmcrmfUokDHAm4ssuQwvLWtuBFQLwEpDR/LbuujuiSbs0gIt+sGvQ== X-Google-Smtp-Source: AGHT+IG5qbw1O4bOIUNZhkQIySZ57gazId75x92kAeWzb85/AvnMhZ6TCGneEzVK850ztLt3CvRS X-Received: by 2002:a50:d557:0:b0:56e:2cb1:c517 with SMTP id f23-20020a50d557000000b0056e2cb1c517mr6719918edj.19.1712607299937; Mon, 08 Apr 2024 13:14:59 -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 30-20020a508e1e000000b0056e2abf021asi3897390edw.256.2024.04.08.13.14.59; Mon, 08 Apr 2024 13:14:59 -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="uy7g+8/b"; 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 13A6F68D342; Mon, 8 Apr 2024 23:14:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01olkn2085.outbound.protection.outlook.com [40.92.66.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D199B68D307 for ; Mon, 8 Apr 2024 23:14:54 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E8QTryyEu1rCDw8MxPCBx26lXj9cDu1MNwLOLy6khwCX1AOWQtbcpUqJCXOYtgevGO8jtOk0PWXjwMfbbickl2r83Gb+A95RHpuOt0GmbLYUyL05+OJJTUubMoGWqGiQHj1Q0eZ0ewNur+LGidcVcNvXOywuuxfwmEGONkLM04gayrZQI4zALafWsjEVbF0u41CNemHAPz76mJ+Hn5MBekxzipsrEeuARcDlgyWMYOfZWeXn2b37ROu1sCYsyqldrrnJSjLSrFxXCGYNiycsF7nGLbnhvSMoVIPVzfjHtkyOYqLXC60sg/cfcT3X+6KCge3XND/UGzWLkRLvhpROfA== 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=l0wIHKxGzWp80D2O+OLXIrsdhN+pBoe3RX0Dktd+OmU=; b=DfqF6KHZMLVeI+ApqL1IdgoUqs41TMBO+9gDvkdB/FqnYzup+kaCY74xrmEqh+/dRooHkDLHeyz47NLQG73KiFQOoFQX21mzw8oeZueeKx2BNRiZ4h4rMXxStWsRqie/EaRfcKIN3wqLc/wag/E67FQ0PHFvehAta63yC/3fPNsYwEGMVNdjhGpuNwBh1+868NjewQeUCoga/EJJWhOFrIlPjqUH+fjYtUCUm1r/SVfqDYj6IAwL6y3Jkc2I3l1JeFcqLp201slAanaKfTWt2yMnHGyf+Uzbcnc5KElRvGF7UdrKVvtE9hq2ysW9mcRQImM+tgVhPysMWejA7FAGZw== 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=l0wIHKxGzWp80D2O+OLXIrsdhN+pBoe3RX0Dktd+OmU=; b=uy7g+8/bdpNFvbbaRsJwOgZP1nXLcbJYiRwv1AKAihkoMifyvteIEMjBcfIXIQT+46wJXNFYHyjY8INJIY8cBWh7mHeNL5IYAAceY+PuA2yCP+iD39oywBhzYRuWo7llX/itwmytOeyRPv8/E8lZdzTowShywWbvtcKDFGX6uxZsDE566nu50uDyTNSEkrLMzsqsGXEXcVQWyce3dtLsdi5hPc6NGdQXrJ0E9bLDwUoDTWAXD+lhI/LTn2X3uNovGupAGIGhUyGS6DDV+9ko17OColnCYZ7hKotgd3lx6w58sbzgJndNGErUCcgvee8U/J4wtN0eSECJPVLk3oTy+A== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PAXP250MB0494.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:28d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Mon, 8 Apr 2024 20:14:53 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7409.042; Mon, 8 Apr 2024 20:14:53 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 Apr 2024 22:13:42 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [I+kppMV6QFOBMMoE++Da0PWY0B/NsKxdWXdYyPHQp6g=] X-ClientProxiedBy: ZR0P278CA0124.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:20::21) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240408201405.2136840-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PAXP250MB0494:EE_ X-MS-Office365-Filtering-Correlation-Id: f11a6b30-a180-4c24-9773-08dc58088cff X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /HjswZpTmBnHB4Ut/Zf4Efn/ZGETKrI+7MrwFUTyXM5XvHDgQc8ptBnKsfLwhwSV9vQexuGvZFCW+/z3lbWdX16yjb0tBrAhQRqHzKZpd1dkN3vzWRsiIhmQDiKOjTUG53rXm18HxE4dRPeOcAmJiIX5ji9wx/c034UUJxp/2JgJcvcYgmSGVpaOZqfGRrVlIPVqYj8/hh1JT1vlZddA2vnK0CgLDTgm75PMPZHHc75H8V4lxbG4bvEuwS9W/AEVJlPC8KHHeFFrIUiZ8idVKQUbXczwUqgMokQLtk/u/6lJcZyZusp10w/kV4U40pKp13q7UKvMMrGle6iPZCvLh6jT9KS54Pu2r92x5A/DL9toFdkcXRbsgPN7o71HUtvGkLgQWw84mQ0QaSq5MASYpYmdUu/dGZspYzlpD6ah5XHUdf3AtnMZcvQqqHCtHwFua9VlsF5F7dn70jmbHEUMrn/xf/PsuZx7J9nTQ5tuGDS2KlLpQYYmxfZkR2yJQVo41jL4S9+wuf0WcOpZmTrdx3jFjyD+X7Mh6+kaR8T+nxlD35xaq/oOSOCR1ohYPH9AuAywZj2PA+8Y2uyyRH4WnTmP3PblMxrI82pccMc1WdtSVsp16Xm1WmuPMfbBkNYf X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: H861duFLVKk0k3aOBQZ/Hhk1uiocz7DLFi52rzN/WbZWyZ1Lv0LWVUENzb0+ryS5rWJUAVWUNZ53gkNFNfGPrEFJU3F9sYfvLtPpBbQuWDL8AOX2rBHnugpQuWJ2zCAMUBj6K44fQg4lPuhLt6VNCKPACvPjDn+s8HqFU3Nrgnf5WNfxSWl6xoXLZpVSmsFAmNmfTTIu98IjzMy3dIl6dvzRlz54eyqLNphi0lK0ekSdYbVDZbYDTbg+1fMf72803ZBLLujpTLYV3vN1NWMxaPoRH+/vYEDL+2u75maQPM30nAA5EL1sytg3zy2So4tLLKFW5TK6CzbfDKrpblqUq+nX//i9GQuQsCi3RkJYK3TS1QO/XVlr6uj9ZHQz79Oha+6v6/AUzkcgziWWiwkmnU8ler8GU/L7bmzH1GxTsKSR88+Wh0o8AWEh46sA5nJqijtUdyQgob8NAN2ey+KGukX7e9qLAefv5C2aKmqRdMnU+30onvIqWqDMxKdI5pe4XwklBFM7jGqE8+FkyJG7fShnndHI/O6td9ZkHSdOB5z/sFCsmYQVCKwBl+Ottp1cpVuQIndELEHjfGAkxMLkLwNcGZAFL5ec3kW2YsBoap8xCEJ2ZqvFZPb+t/lDvT0NL3dp+zL9D0jc4WNZmIdeTZzNZbVJ3xzhulSj2OyY7sHm7D5gj4V24lJocxJ5JAaHX7WzoqTReNn66PrxBEL862WFMrI+FSXtMXMPs923S32lXTgR0mmmliWr6DAjzKdcQgutiptk6Rof/l3aMAHPemmdFau8sCjlHSgnji+Umfk29Nh3ssr9xuKISqYTyd/20JrXVxWcM4hXmo790BzpXcKRrna8jwuMHK8c3jSbLHqjREdAXNS2HBm3K0Z8GbDxC/QhGjd2QH4hZxJFVbg7rTn8ZJ2PuZTPItzcb9GpF6rPh5z89uTeSHvPm/i/sUQO5yVorofGWPKhFmvz3VR7OfZ7dQgIiAITA+yuiNphXoCyDGPbEbZZrOjd2hDS2W0hS1WRQgmNBsseFbyvKjDca42qNegRYNGGiLcvbVx0MKD9TNF+iXJXIkldyt18oRhSAMufd9ukncxp1T5pAQjcbVhnJGlWy4PL4fksJL9R/PVJaoAZvBt6XPV0ebqxbOyADzQUeGCsjW/Sfw6x+O6VzXnfOrvOYnhJ4UsP0rUi7hx7g4xGUC19dBcGcdVSA6pzj6smAwq8ff2TITNKQCkZn9wR2BmKTbkIOVb56YlnPSjh85j6t5TYszcKSnD/Zw8o3BnwU+sME1gfqQr3ZoAvrw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f11a6b30-a180-4c24-9773-08dc58088cff X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2024 20:14:53.0032 (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: PAXP250MB0494 Subject: [FFmpeg-devel] [PATCH v2 04/27] avcodec/vp3: Switch to ProgressFrames 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: Anton Khirnov , Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Yy2fJEnpKZ0L Avoids implicit av_frame_ref() and therefore allocations and error checks. It also avoids explicitly allocating the AVFrames (done implicitly when getting the buffer) and it also allows to reuse the flushing code for freeing the ProgressFrames. Reviewed-by: Anton Khirnov Signed-off-by: Andreas Rheinhardt --- libavcodec/vp3.c | 147 +++++++++++++++++------------------------------ 1 file changed, 53 insertions(+), 94 deletions(-) diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 201bab0e32..2a5f68dfa8 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -49,9 +49,9 @@ #include "internal.h" #include "jpegquanttables.h" #include "mathops.h" +#include "progressframe.h" #include "refstruct.h" #include "thread.h" -#include "threadframe.h" #include "videodsp.h" #include "vp3data.h" #include "vp4data.h" @@ -201,9 +201,9 @@ typedef struct Vp3DecodeContext { int version; int width, height; int chroma_x_shift, chroma_y_shift; - ThreadFrame golden_frame; - ThreadFrame last_frame; - ThreadFrame current_frame; + ProgressFrame golden_frame; + ProgressFrame last_frame; + ProgressFrame current_frame; int keyframe; uint8_t idct_permutation[64]; uint8_t idct_scantable[64]; @@ -353,12 +353,9 @@ static void vp3_decode_flush(AVCodecContext *avctx) { Vp3DecodeContext *s = avctx->priv_data; - if (s->golden_frame.f) - ff_thread_release_ext_buffer(&s->golden_frame); - if (s->last_frame.f) - ff_thread_release_ext_buffer(&s->last_frame); - if (s->current_frame.f) - ff_thread_release_ext_buffer(&s->current_frame); + ff_progress_frame_unref(&s->golden_frame); + ff_progress_frame_unref(&s->last_frame); + ff_progress_frame_unref(&s->current_frame); } static av_cold int vp3_decode_end(AVCodecContext *avctx) @@ -372,9 +369,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx) /* release all frames */ vp3_decode_flush(avctx); - av_frame_free(&s->current_frame.f); - av_frame_free(&s->last_frame.f); - av_frame_free(&s->golden_frame.f); ff_refstruct_unref(&s->coeff_vlc); @@ -1908,10 +1902,9 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y) /* At the end of the frame, report INT_MAX instead of the height of * the frame. This makes the other threads' ff_thread_await_progress() * calls cheaper, because they don't have to clip their values. */ - ff_thread_report_progress(&s->current_frame, - y_flipped == s->height ? INT_MAX - : y_flipped - 1, - 0); + ff_progress_frame_report(&s->current_frame, + y_flipped == s->height ? INT_MAX + : y_flipped - 1); } if (!s->avctx->draw_horiz_band) @@ -1942,7 +1935,7 @@ static void vp3_draw_horiz_band(Vp3DecodeContext *s, int y) static void await_reference_row(Vp3DecodeContext *s, const Vp3Fragment *fragment, int motion_y, int y) { - const ThreadFrame *ref_frame; + const ProgressFrame *ref_frame; int ref_row; int border = motion_y & 1; @@ -1955,7 +1948,7 @@ static void await_reference_row(Vp3DecodeContext *s, const Vp3Fragment *fragment ref_row = y + (motion_y >> 1); ref_row = FFMAX(FFABS(ref_row), ref_row + 8 + border); - ff_thread_await_progress(ref_frame, ref_row, 0); + ff_progress_frame_await(ref_frame, ref_row); } #if CONFIG_VP4_DECODER @@ -2066,12 +2059,12 @@ static void render_slice(Vp3DecodeContext *s, int slice) int16_t *block = s->block; int motion_x = 0xdeadbeef, motion_y = 0xdeadbeef; /* When decoding keyframes, the earlier frames may not be available, - * so to avoid using undefined pointer arithmetic on them we just - * use the current frame instead. Nothing is ever read from these - * frames in case of a keyframe. */ - const AVFrame *last_frame = s->last_frame.f->data[0] ? + * so we just use the current frame in this case instead; + * it also avoid using undefined pointer arithmetic. Nothing is + * ever read from these frames in case of a keyframe. */ + const AVFrame *last_frame = s->last_frame.f ? s->last_frame.f : s->current_frame.f; - const AVFrame *golden_frame = s->golden_frame.f->data[0] ? + const AVFrame *golden_frame = s->golden_frame.f ? s->golden_frame.f : s->current_frame.f; int motion_halfpel_index; int first_pixel; @@ -2353,17 +2346,6 @@ static av_cold int allocate_tables(AVCodecContext *avctx) return 0; } -static av_cold int init_frames(Vp3DecodeContext *s) -{ - s->current_frame.f = av_frame_alloc(); - s->last_frame.f = av_frame_alloc(); - s->golden_frame.f = av_frame_alloc(); - - if (!s->current_frame.f || !s->last_frame.f || !s->golden_frame.f) - return AVERROR(ENOMEM); - - return 0; -} static av_cold void free_vlc_tables(FFRefStructOpaque unused, void *obj) { @@ -2382,10 +2364,6 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx) int c_height; int y_fragment_count, c_fragment_count; - ret = init_frames(s); - if (ret < 0) - return ret; - if (avctx->codec_tag == MKTAG('V', 'P', '4', '0')) { s->version = 3; #if !CONFIG_VP4_DECODER @@ -2524,61 +2502,42 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx) } /// Release and shuffle frames after decode finishes -static int update_frames(AVCodecContext *avctx) +static void update_frames(AVCodecContext *avctx) { Vp3DecodeContext *s = avctx->priv_data; - int ret = 0; - if (s->keyframe) { - ff_thread_release_ext_buffer(&s->golden_frame); - ret = ff_thread_ref_frame(&s->golden_frame, &s->current_frame); - } - /* shuffle frames */ - ff_thread_release_ext_buffer(&s->last_frame); - FFSWAP(ThreadFrame, s->last_frame, s->current_frame); + if (s->keyframe) + ff_progress_frame_replace(&s->golden_frame, &s->current_frame); - return ret; + /* shuffle frames */ + ff_progress_frame_unref(&s->last_frame); + FFSWAP(ProgressFrame, s->last_frame, s->current_frame); } #if HAVE_THREADS -static int ref_frame(ThreadFrame *dst, const ThreadFrame *src) +static void ref_frames(Vp3DecodeContext *dst, const Vp3DecodeContext *src) { - ff_thread_release_ext_buffer(dst); - if (src->f->data[0]) - return ff_thread_ref_frame(dst, src); - return 0; -} - -static int ref_frames(Vp3DecodeContext *dst, const Vp3DecodeContext *src) -{ - int ret; - if ((ret = ref_frame(&dst->current_frame, &src->current_frame)) < 0 || - (ret = ref_frame(&dst->golden_frame, &src->golden_frame)) < 0 || - (ret = ref_frame(&dst->last_frame, &src->last_frame)) < 0) - return ret; - return 0; + ff_progress_frame_replace(&dst->current_frame, &src->current_frame); + ff_progress_frame_replace(&dst->golden_frame, &src->golden_frame); + ff_progress_frame_replace(&dst->last_frame, &src->last_frame); } static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { Vp3DecodeContext *s = dst->priv_data; const Vp3DecodeContext *s1 = src->priv_data; - int qps_changed = 0, err; + int qps_changed = 0; ff_refstruct_replace(&s->coeff_vlc, s1->coeff_vlc); - if (!s1->current_frame.f->data[0] || + // copy previous frame data + ref_frames(s, s1); + if (!s1->current_frame.f || s->width != s1->width || s->height != s1->height) { - if (s != s1) - ref_frames(s, s1); return -1; } if (s != s1) { - // copy previous frame data - if ((err = ref_frames(s, s1)) < 0) - return err; - s->keyframe = s1->keyframe; // copy qscale data if necessary @@ -2600,7 +2559,8 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext * } } - return update_frames(dst); + update_frames(dst); + return 0; } #endif @@ -2691,15 +2651,19 @@ static int vp3_decode_frame(AVCodecContext *avctx, AVFrame *frame, if (avctx->skip_frame >= AVDISCARD_NONKEY && !s->keyframe) return buf_size; + ret = ff_progress_frame_get_buffer(avctx, &s->current_frame, + AV_GET_BUFFER_FLAG_REF); + if (ret < 0) { + // Don't goto error here, as one can't report progress on or + // unref a non-existent frame. + return ret; + } s->current_frame.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; if (s->keyframe) s->current_frame.f->flags |= AV_FRAME_FLAG_KEY; else s->current_frame.f->flags &= ~AV_FRAME_FLAG_KEY; - if ((ret = ff_thread_get_ext_buffer(avctx, &s->current_frame, - AV_GET_BUFFER_FLAG_REF)) < 0) - goto error; if (!s->edge_emu_buffer) { s->edge_emu_buffer = av_malloc(9 * FFABS(s->current_frame.f->linesize[0])); @@ -2757,19 +2721,16 @@ static int vp3_decode_frame(AVCodecContext *avctx, AVFrame *frame, #endif } } else { - if (!s->golden_frame.f->data[0]) { + if (!s->golden_frame.f) { av_log(s->avctx, AV_LOG_WARNING, "vp3: first frame not a keyframe\n"); - s->golden_frame.f->pict_type = AV_PICTURE_TYPE_I; - if ((ret = ff_thread_get_ext_buffer(avctx, &s->golden_frame, - AV_GET_BUFFER_FLAG_REF)) < 0) + if ((ret = ff_progress_frame_get_buffer(avctx, &s->golden_frame, + AV_GET_BUFFER_FLAG_REF)) < 0) goto error; - ff_thread_release_ext_buffer(&s->last_frame); - if ((ret = ff_thread_ref_frame(&s->last_frame, - &s->golden_frame)) < 0) - goto error; - ff_thread_report_progress(&s->last_frame, INT_MAX, 0); + s->golden_frame.f->pict_type = AV_PICTURE_TYPE_I; + ff_progress_frame_replace(&s->last_frame, &s->golden_frame); + ff_progress_frame_report(&s->golden_frame, INT_MAX); } } ff_thread_finish_setup(avctx); @@ -2847,16 +2808,13 @@ static int vp3_decode_frame(AVCodecContext *avctx, AVFrame *frame, *got_frame = 1; - if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) { - ret = update_frames(avctx); - if (ret < 0) - return ret; - } + if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) + update_frames(avctx); return buf_size; error: - ff_thread_report_progress(&s->current_frame, INT_MAX, 0); + ff_progress_frame_report(&s->current_frame, INT_MAX); if (!HAVE_THREADS || !(s->avctx->active_thread_type & FF_THREAD_FRAME)) av_frame_unref(s->current_frame.f); @@ -3206,7 +3164,8 @@ const FFCodec ff_theora_decoder = { .flush = vp3_decode_flush, UPDATE_THREAD_CONTEXT(vp3_update_thread_context), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_EXPORTS_CROPPING | FF_CODEC_CAP_ALLOCATE_PROGRESS, + FF_CODEC_CAP_EXPORTS_CROPPING | + FF_CODEC_CAP_USES_PROGRESSFRAMES, }; #endif @@ -3224,7 +3183,7 @@ const FFCodec ff_vp3_decoder = { .flush = vp3_decode_flush, UPDATE_THREAD_CONTEXT(vp3_update_thread_context), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_ALLOCATE_PROGRESS, + FF_CODEC_CAP_USES_PROGRESSFRAMES, }; #if CONFIG_VP4_DECODER @@ -3242,6 +3201,6 @@ const FFCodec ff_vp4_decoder = { .flush = vp3_decode_flush, UPDATE_THREAD_CONTEXT(vp3_update_thread_context), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_ALLOCATE_PROGRESS, + FF_CODEC_CAP_USES_PROGRESSFRAMES, }; #endif