From patchwork Tue Mar 22 17:47:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Unterweger X-Patchwork-Id: 34905 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:ab0:5fda:0:0:0:0:0 with SMTP id g26csp717357uaj; Tue, 22 Mar 2022 10:47:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrXYo4rjdmRg3nLO0V8Dp3P7zNbs+PqpAjPYbG+1O94MhAPO3vjLW2clK5smmZ6faGvy3E X-Received: by 2002:a50:baa8:0:b0:415:b0bc:6353 with SMTP id x37-20020a50baa8000000b00415b0bc6353mr30144367ede.220.1647971269772; Tue, 22 Mar 2022 10:47:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647971269; cv=none; d=google.com; s=arc-20160816; b=nB7NnLMdvMDpxSfy45UMuwgYjl4rHo/5EjlcFkzfk1tor/pAWUT3xdDkO9D+lmKcaD kI1sn3PfXuHKiVUe8P6HHpTtPeO9yOmsxcDNRZPvocGrhW4y7cQGqRXL3jT7lve2cB81 AgBmAD7dqD0j0oXl1WtwYkYwkU1EAiHrGJsyBKwCLPKV7GC+Ca4Yw3a0OhRrXas/naxb 0lSFq5YK3foXq86XCbxnGHoylGE3IHSFCXvENpjp2Dp6E2VGLDc3OxWuCqa3i1hRcbX9 bxqcYe98lqbWM43QxXZ0bK/6EkQJLGYTNQx9FsQS0+fbLaOXv0jUzSbhUzgz6dMsoilY UfLA== 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:content-language:to:from:user-agent:mime-version :date:message-id:dkim-signature:delivered-to; bh=6DXiYyWYSfJPWAGP8Zydwqy40lMODMs+xbP9TXCbOjk=; b=IwDIcRXmRfxSoiysII0VXZi0MXPRTCyR80RPvSDvVQYsXG6nPwnN6Vk2RI3BmoT2y1 OKr1n1dva6s8Vrqoo5TpSWbGxqn/GQe1NIVt7bGwpTYoxdn1Owd58MkzZ046gIMczHt/ SuITZ5kvk3Hi2EFaVt05aPGmWX2qhMou0NW/tP3C6LCJwXGuEMp4XzN7CT4vTxLjea5G tLjqvUbwtGT22fb3W74aj0yV9iiHSclt4CxAaVU90hs8kfyoKofXqkm/QlKAsYBz2Uij IG64oQWIQ041l7xyle9qjmZvnKO0FMIDaKjIuxK46CEhsv0HMdNY/wzA5t9NOol45ssM RYHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=HxbYcvMR; 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 bi20-20020a170906a25400b006df76385e6bsi10411165ejb.779.2022.03.22.10.47.49; Tue, 22 Mar 2022 10:47:49 -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=HxbYcvMR; 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 05F1F68B16B; Tue, 22 Mar 2022 19:47:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BBD1F68B11B for ; Tue, 22 Mar 2022 19:47:38 +0200 (EET) Received: by mail-wr1-f49.google.com with SMTP id h23so23887074wrb.8 for ; Tue, 22 Mar 2022 10:47:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to :content-language:content-transfer-encoding; bh=2N+bysiJ0nSWEnSRA2udPKZW6AExKkGTTJFuDaxkv14=; b=HxbYcvMRTGLGXxAKBr8kMSa4ZszoToy7r2IgbmRf7UKCjglKxEdsiglA+jsxdM3B3H nql20yJfiuoTnnV5gEsxeqwV81e92dcXc9M7dtVRSuTr4xz5uAtkSUg+anXm5XYlXFzw eUTWIRJkIhG5qxWGFpEGw6V9moWgymJ8BohKwctobOTVFRRgqP45uIbZWL78W22pQJq+ dPsEtwiBiSJnh4J2+q8QORwLmoXrd4t7SSXe7DTfQxuYxOBJv5DDH+FU+USNsiwkBnlG Hrzi/rmItDMUkux5NeDshU1ra/fQCNr2zxb+Eu7piCGBaTOz+Hl2jDyIpMC8Go3eFaIg uk2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:content-language:content-transfer-encoding; bh=2N+bysiJ0nSWEnSRA2udPKZW6AExKkGTTJFuDaxkv14=; b=ZlAgtta+AgwMdXIJ3H3qEx3iJe0SO0413Tt1WTQIUgjIUGnkMwsp4E6qFu4G+npBaE gSzR+pSg+P8Py71FXsS+c9AZT67c+LOlJvxPu50r0dNGzElwH41c9WPULOu41t0MCrVb MijKZKRuBv3rJcZF2NYkj7ojF+uvqFFd2GONBXRnC8Ck4VAWy8EWLte7CL0pN0st0VTI 8nQb7siYYzY/trwr4mTzdlwsw2Iac+PPakkL0V242tJ47Omc5yi0avob4ExvyJ/S6ret lWJWqaODmPsMCFI+NrIYz749LtMkJse7Wjy1/HBoMKRXM0ujrHaY87DgHD99fNP1xNVL RcDQ== X-Gm-Message-State: AOAM531RMvjTFmu2V8rURsdKdTl81uH9qzjcYb4MTy3cVZpkNjJJJGQB y6j37F6Z2D4hSxgtLEzVSoDjg1kOIRk= X-Received: by 2002:a05:6000:1547:b0:204:213:ae28 with SMTP id 7-20020a056000154700b002040213ae28mr13262501wry.114.1647971258175; Tue, 22 Mar 2022 10:47:38 -0700 (PDT) Received: from ?IPV6:2001:871:242:8728:1cf3:1aa8:df01:4a15? ([2001:871:242:8728:1cf3:1aa8:df01:4a15]) by smtp.gmail.com with ESMTPSA id z18-20020a5d6412000000b0020400dde72esm8928037wru.37.2022.03.22.10.47.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Mar 2022 10:47:37 -0700 (PDT) Message-ID: <8fd28808-07f8-9458-b032-8792c67a38fd@gmail.com> Date: Tue, 22 Mar 2022 18:47:34 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 From: Andreas Unterweger To: ffmpeg-devel@ffmpeg.org Content-Language: de-AT Subject: [FFmpeg-devel] [PATCH v2 1/2] 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: Tam+FPwYv+5b 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(-) 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; /* 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;