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 122BB45435 for ; Wed, 31 May 2023 14:56:22 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 205A868C2D5; Wed, 31 May 2023 17:55:21 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3697168B649 for ; Wed, 31 May 2023 17:55:13 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 577F12406CC for ; Wed, 31 May 2023 16:55:10 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id k3JP1ozvIZzj for ; Wed, 31 May 2023 16:55:09 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (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 "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id F117B2406CE for ; Wed, 31 May 2023 16:55:05 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 755383A0BDC for ; Wed, 31 May 2023 16:55:00 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 31 May 2023 16:54:45 +0200 Message-Id: <20230531145453.20994-15-anton@khirnov.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230531145453.20994-1-anton@khirnov.net> References: <20230531145453.20994-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/23] fftools/ffmpeg: factor out attaching FrameData to a frame 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: Will be useful in following commits. --- fftools/ffmpeg.c | 11 +++++++++++ fftools/ffmpeg.h | 6 ++++++ fftools/ffmpeg_dec.c | 5 ++--- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index bcda7570e9..9997881572 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -431,6 +431,17 @@ InputStream *ist_iter(InputStream *prev) return NULL; } +FrameData *frame_data(AVFrame *frame) +{ + if (!frame->opaque_ref) { + frame->opaque_ref = av_buffer_allocz(sizeof(FrameData)); + if (!frame->opaque_ref) + return NULL; + } + + return (FrameData*)frame->opaque_ref->data; +} + void remove_avoptions(AVDictionary **a, AVDictionary *b) { const AVDictionaryEntry *t = NULL; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 0e9ad5f9f7..6f71e85658 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -737,6 +737,12 @@ int init_complex_filtergraph(FilterGraph *fg); int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src); +/** + * Get our axiliary frame data attached to the frame, allocating it + * if needed. + */ +FrameData *frame_data(AVFrame *frame); + int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame, int keep_reference); int ifilter_send_eof(InputFilter *ifilter, int64_t pts, AVRational tb); int ifilter_sub2video(InputFilter *ifilter, const AVSubtitle *sub); diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index 30959c64b7..799be63215 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -499,12 +499,11 @@ int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof) FrameData *fd; av_assert0(!frame->opaque_ref); - frame->opaque_ref = av_buffer_allocz(sizeof(*fd)); - if (!frame->opaque_ref) { + fd = frame_data(frame); + if (!fd) { av_frame_unref(frame); report_and_exit(AVERROR(ENOMEM)); } - fd = (FrameData*)frame->opaque_ref->data; fd->pts = frame->pts; fd->tb = dec->pkt_timebase; fd->idx = dec->frame_num - 1; -- 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".