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 8B8F147713 for ; Fri, 20 Oct 2023 17:00:16 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6E99668CAC2; Fri, 20 Oct 2023 20:00:13 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A2A2C68CA27 for ; Fri, 20 Oct 2023 20:00:06 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 34559240498 for ; Fri, 20 Oct 2023 19:00:06 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id YtVXCJX3lRwE for ; Fri, 20 Oct 2023 19:00:05 +0200 (CEST) Received: from lain.khirnov.net (lain.khirnov.net [IPv6:2001:67c:1138:4306::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "lain.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 9964F2400FF for ; Fri, 20 Oct 2023 19:00:05 +0200 (CEST) Received: by lain.khirnov.net (Postfix, from userid 1000) id 7F3601601B9; Fri, 20 Oct 2023 18:59:59 +0200 (CEST) From: Anton Khirnov To: FFmpeg development discussions and patches In-Reply-To: References: <169781540929.30698.17624996838550323031@lain.khirnov.net> Mail-Followup-To: FFmpeg development discussions and patches Date: Fri, 20 Oct 2023 18:59:59 +0200 Message-ID: <169782119949.23937.14840894747163481007@lain.khirnov.net> User-Agent: alot/0.8.1 MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec/pthread_frame: Remove ff_thread_release_buffer() 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 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: Quoting Andreas Rheinhardt (2023-10-20 17:41:17) > Anton Khirnov: > > Quoting Andreas Rheinhardt (2023-10-20 16:33:06) > >> diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c > >> index c02408548c..1a4339b346 100644 > >> --- a/libavcodec/av1dec.c > >> +++ b/libavcodec/av1dec.c > >> @@ -636,9 +636,9 @@ static int get_pixel_format(AVCodecContext *avctx) > >> return 0; > >> } > >> > >> -static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f) > >> +static void av1_frame_unref(AV1Frame *f) > >> { > >> - ff_thread_release_buffer(avctx, f->f); > >> + av_frame_unref(f->f); > >> ff_refstruct_unref(&f->hwaccel_picture_private); > >> ff_refstruct_unref(&f->header_ref); > >> f->raw_frame_header = NULL; > >> @@ -689,7 +689,7 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s > >> return 0; > >> > >> fail: > >> - av1_frame_unref(avctx, dst); > >> + av1_frame_unref(dst); > >> return AVERROR(ENOMEM); > >> } > >> > >> @@ -699,12 +699,15 @@ static av_cold int av1_decode_free(AVCodecContext *avctx) > >> AV1RawMetadataITUTT35 itut_t35; > >> > >> for (int i = 0; i < FF_ARRAY_ELEMS(s->ref); i++) { > >> - av1_frame_unref(avctx, &s->ref[i]); > >> - av_frame_free(&s->ref[i].f); > >> + if (s->ref[i].f) { > > > > Wouldn't it be simpler and more consistent to check for the frame's > > existence in av1_frame_unref()? > > > > The frame being NULL is a very exceptional scenario: It can only happen > if init failed. In this case it is clear that the AV1Frame is blank and > need not be unreferenced at all. Given that av1_frame_unref() is not > called infrequently, why should it check all the time for this > exceptional scenario? It seems better to handle this case in the only > codepath that needs to handle this. Ok, as you prefer. -- Anton Khirnov _______________________________________________ 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".