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 68BC2455B1 for ; Mon, 8 May 2023 09:18:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1B5A368C12B; Mon, 8 May 2023 12:18:08 +0300 (EEST) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 27E5B68C0C2 for ; Mon, 8 May 2023 12:18:00 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id E2BD72405B5 for ; Mon, 8 May 2023 11:17:59 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id O878byoX5y_w for ; Mon, 8 May 2023 11:17:57 +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 32B222404F5 for ; Mon, 8 May 2023 11:17:57 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id E4C113A11DB for ; Mon, 8 May 2023 11:17:56 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 May 2023 11:17:20 +0200 Message-Id: <20230508091738.20813-4-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230508091738.20813-1-anton@khirnov.net> References: <20230508091738.20813-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/22] fftools/ffmpeg_demux: move preparing DemuxMsg to separate function 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, which will move more code into this function. --- fftools/ffmpeg_demux.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 1872e87d57..b16a20a87b 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -257,6 +257,26 @@ static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict) SHOW_TS_DEBUG("demuxer+tsfixup"); } +// process an input packet into a message to send to the consumer thread +// src is always cleared by this function +static int input_packet_process(Demuxer *d, DemuxMsg *msg, AVPacket *src) +{ + AVPacket *pkt; + + pkt = av_packet_alloc(); + if (!pkt) { + av_packet_unref(src); + return AVERROR(ENOMEM); + } + av_packet_move_ref(pkt, src); + + ts_fixup(d, pkt, &msg->repeat_pict); + + msg->pkt = pkt; + + return 0; +} + static void thread_set_name(InputFile *f) { char name[16]; @@ -336,15 +356,10 @@ static void *input_thread(void *arg) } } - ts_fixup(d, pkt, &msg.repeat_pict); - - msg.pkt = av_packet_alloc(); - if (!msg.pkt) { - av_packet_unref(pkt); - ret = AVERROR(ENOMEM); + ret = input_packet_process(d, &msg, pkt); + if (ret < 0) break; - } - av_packet_move_ref(msg.pkt, pkt); + ret = av_thread_message_queue_send(d->in_thread_queue, &msg, flags); if (flags && ret == AVERROR(EAGAIN)) { flags = 0; -- 2.39.2 _______________________________________________ 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".