From patchwork Mon May 2 07:29:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Unterweger X-Patchwork-Id: 35539 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp1676903pzb; Mon, 2 May 2022 00:29:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy53iKfJFYNlZKzokv8AgmV9iQ/f9MBy5uG5vmSre9cvhNNoffKFolLy2WUZ4u/Xgn6tOvj X-Received: by 2002:a17:907:6e16:b0:6f4:5681:23a0 with SMTP id sd22-20020a1709076e1600b006f4568123a0mr2769235ejc.739.1651476583764; Mon, 02 May 2022 00:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651476583; cv=none; d=google.com; s=arc-20160816; b=qxO7zv4B+itHfhc65SUktdzSV4uJhTXlGE1SddeP7LeqEbmz53AaermfknqDnQi7ky BZZ2neAH0FkRwBltrco72h2EXK+pS9PnyKzJsa8N2NTMRsHmRRGO82F76gq+crp57+s/ pyve5NVQL9HLvpipJXC/g5tjT4oMTb3/6ypGdx7Y3u1l7+7rxUtUmkEB6Rpf4BKIS2zA gnw7lz+kNZ520lvz5vpp0AOgi/V4BkXGp2Qv+T7wGylSqaWidtrtGZkvDfhhW+Y6hVtU zZlZNH/PAhzYsMQJuXyE6ql0gB6TkYYbxGY6E/HOLuX7S2AUGhBWzwkrI7H4a4k1gDpG C28g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:to:message-id:date:from:mime-version :dkim-signature:delivered-to; bh=vQhfsoVah5v7eDBCqgktbJwmfKSCi+CSxl4YkPQ1G8k=; b=fhF7YBst94eI0JCNS9u31edBF4GW55i9aJ3g5ciIC9eG2NIgghzPnZuVe0EvbUGqJm 2fPz2enWV/XpDWpCdS4ggcKQ8RkPWKvdbVs2JdnxBxhWKFRXYeZBY+qZI4w+W+zFhHdA 7Udvx257drc6PrG59gD0/+ZHnhjeCqQmNwUArV2GnjeJIXxyAmknWOjuxJduZOJmkn/z +GQNTD2xrlt1M4jf6CTDi40OLY9z4teSVT1pqXjNbYIB3bqTrQt7GN+z3CPZdKw12f5+ z9tHdd4zXD5CZ9/NAMMOjeFYEtjWtebD37H4ko6YTUNT8rpdByckdNjfA1RERPe0zrb5 w1eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="dp7iOd/3"; 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=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a19-20020a1709065f9300b006df846edd5fsi11657923eju.998.2022.05.02.00.29.43; Mon, 02 May 2022 00:29:43 -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=@gmail.com header.s=20210112 header.b="dp7iOd/3"; 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=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5098268B2A5; Mon, 2 May 2022 10:29:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 829FB680264 for ; Mon, 2 May 2022 10:29:33 +0300 (EEST) Received: by mail-lf1-f43.google.com with SMTP id w19so23838158lfu.11 for ; Mon, 02 May 2022 00:29:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=j1Sh4lAx0ZgScIMCd5weLCZI6jByjLRJsw1OJHdXrfA=; b=dp7iOd/37m/34zn4MVtesIJrmEVTMHyyUSbwrn+8nP1ycKrqdLhxJ6FY6XCevlk99L HkrjtBaLRuudmU/n3mXr6UASi5Kw2TMcqQZqhPNoN0j9d2qoNt9LupPovJfWKaXRqdmA TNDlwrMUjJtqIRUXLVGf99cHunaYwS7KDKUS9GF1fXr+EdUJINZV6LIf3txFr8TcNPE/ 2uYPhVMx/UcwBhw/HSh+Nxj6wsbdMlKmEjuEnZ5ijxnAIj/CUjHgcBAQ2eC3AmuilfIh vdjp4u21Hpx5mbPc8CbmObS/OXhTBYvIH5l71HT9OUpm7JYIjyUVQHqTDlajP6AvgCBV jlhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=j1Sh4lAx0ZgScIMCd5weLCZI6jByjLRJsw1OJHdXrfA=; b=hdD1P7KHo8KF9ci8M8X+C0ArtSWSyL4coSTS+kp4M511jRtjnEGOA8O3Tjdyx8zR9M zqwvoihKKdJv7yjtYk+ExYwnyPil5VGlNlxgVVbOaMHK74cJgF9djLI2yhOtjypi60XU BYXPTrwf4bCFD9pmgNuq76uAjlj3wOiiHqxjVBC3WQR8VZe/DTorWcHcelIEoKk6Neef +xZgBi9qGXvmJUxyADxBr7ynXeqWr7iBNHeezZ1FqAEMgl+8I6OvFhIQOx4ytqvqoVC1 Dd+YS7fUaYVME+4NG4HUw8p+gacb/HiQSSR9z4HWWhgldGkwy/K9gI4dkip2TrP9PloJ RSrA== X-Gm-Message-State: AOAM530IHb9VOpMCT3X23WXd61Kmunrs0ENepQJxkd3E9PASBGrzVIvd AGPxcN1HSzwl70j5dMc7FNBM6gz1I4ltEsz38TKyj+sfN7ZhJw== X-Received: by 2002:a05:6512:448:b0:472:3c0e:cf7f with SMTP id y8-20020a056512044800b004723c0ecf7fmr8170851lfk.279.1651476572610; Mon, 02 May 2022 00:29:32 -0700 (PDT) MIME-Version: 1.0 From: Andreas Unterweger Date: Mon, 2 May 2022 09:29:22 +0200 Message-ID: To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH v7 1/4] doc/examples/transcode_aac: Don't ignore last encoded 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: esNMeQ5XISXr The last encoded frame is now fetched on EOF. It was previously left in the encoder and caused a "1 frame left in queue" warning. Signed-off-by: Andreas Unterweger --- doc/examples/transcode_aac.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) /* Initialize temporary storage for one input frame. */ @@ -675,18 +677,17 @@ static int encode_audio_frame(AVFrame *frame, frame->pts = pts; pts += frame->nb_samples; } - + + *data_present = 0; /* Send the audio frame stored in the temporary packet to the encoder. * The output audio stream encoder is used to do this. */ error = avcodec_send_frame(output_codec_context, frame); - /* The encoder signals that it has nothing more to encode. */ - if (error == AVERROR_EOF) { - error = 0; - goto cleanup; - } else if (error < 0) { - fprintf(stderr, "Could not send packet for encoding (error '%s')\n", - av_err2str(error)); - goto cleanup; + /* Check for errors, but proceed with fetching encoded samples if the + * encoder signals that it has nothing more to encode. */ + if (error < 0 && error != AVERROR_EOF) { + fprintf(stderr, "Could not send packet for encoding (error '%s')\n", + av_err2str(error)); + goto cleanup; } /* Receive one encoded frame from the encoder. */ @@ -857,7 +858,6 @@ int main(int argc, char **argv) int data_written; /* Flush the encoder as it may have delayed frames. */ do { - data_written = 0; if (encode_audio_frame(NULL, output_format_context, output_codec_context, &data_written)) goto cleanup; diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c index 9102e55f16..c9b93f6439 100644 --- a/doc/examples/transcode_aac.c +++ b/doc/examples/transcode_aac.c @@ -377,6 +377,8 @@ static int decode_audio_frame(AVFrame *frame, if (error < 0) return error; + *data_present = 0; + *finished = 0; /* Read one audio frame from the input file into a temporary packet. */ if ((error = av_read_frame(input_format_context, input_packet)) < 0) { /* If we are at the end of the file, flush the decoder below. */ @@ -555,7 +557,7 @@ static int read_decode_convert_and_store(AVAudioFifo *fifo, AVFrame *input_frame = NULL; /* Temporary storage for the converted input samples. */ uint8_t **converted_input_samples = NULL; - int data_present = 0; + int data_present; int ret = AVERROR_EXIT;