From patchwork Thu Apr 28 13:57:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Unterweger X-Patchwork-Id: 35474 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp3606724pzh; Thu, 28 Apr 2022 06:58:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFruGnGwFOW9hOC+Z/JscRfMk6JIK5p4lAIopm8V1QpVi6/VEFZWp0ZvezMdUZEYf/ElQB X-Received: by 2002:aa7:d609:0:b0:425:d94b:4119 with SMTP id c9-20020aa7d609000000b00425d94b4119mr25409408edr.282.1651154307076; Thu, 28 Apr 2022 06:58:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651154307; cv=none; d=google.com; s=arc-20160816; b=ifQWpaEtQnVGVn64BYb/CrFShgtUBL3LozM8LwC1rZpV7r4VON7ZP176yRXaFD0Fgc JRpDGTK0H2Vk8zUgFpSLgskkoGqWxqgVjwxnYVrr4jkqdwE38hu025EuLglYQ+fbjMLg u6UgJI9ElKCNjHVn2MHgH/PrIvmAF1KQbSguIq8HN8mOVQSlEw3xJ7CGAzMvCGnRjYce aEMZts0xFa8u5rphv0L4yIf07TS3lrUeuRbiBWUAE1n4oZh32IzbtTPQ+42rQltzgcm1 55fz+kqq+YibCTlWPBzN+EXr1XSVYoDt7UliRsE9zj2sXQ+Dv54OKE97F5uAf++ibIOa YYmg== 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=HubUoqffyr5lpTZXtAGwHDib3fRlZmxznEA0/DQ7Pac=; b=yfiGYAnwk7fs5LB0b0nFr7MdH55fB7xJ3H37coWI5hKQGHCv2NRGB2+jps8gbDdktw 6PsGpWN/SVKKi+rlT7R+DfNMUTki+1X8mf70ub/n9xrbz2Ooc2LRX+w2XgbNXP3eFY/n hwnBnEjScxw7rWzetEBi7YvoPI2Xgua/izq5XIv5zVdLL3O1S0SUANc3qts6YDvGq9I7 9nPdCowryFQfn3eLHN9Wz1vs6MENcNQGOC4SMFYbeUvodC9Vl/cr9plaBTIoa8m5M3oO ZAg2O/yYTbUvsq2WCnSH56Jh9krSs3VXhdued7LVLyoPsKNPF/DCm5EiOwFlWEMAkiil frPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=HbRkwPh+; 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 j5-20020a170906474500b006df76385cd5si3789188ejs.373.2022.04.28.06.58.21; Thu, 28 Apr 2022 06:58:27 -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=HbRkwPh+; 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 ADF8968B3F2; Thu, 28 Apr 2022 16:57:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6888B68B101 for ; Thu, 28 Apr 2022 16:57:49 +0300 (EEST) Received: by mail-lf1-f53.google.com with SMTP id p12so8790997lfs.5 for ; Thu, 28 Apr 2022 06:57:49 -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=6FZH9QYuX9HtNcVJgfaYwPHuzhfVUQbAkXgeGVT8C4s=; b=HbRkwPh+aQDkDVL0dE2rr8lTmCLDWju9Rv/wkBDV1gvliU5x5f+9ecMFzwwLjSdhuI trpaZjQiS8PkT3gKu0xerEbqk42OdrTXvr9Cm3+7uh6mTHAgZtL3ckiT1pYTiUd1GOHE WtjmFqnhB3B+gO/H8PA5jOQo6LhDkEgnA0kfuKAUxJHe0iHXzm41OibV+0wmc/sVOVmk tuFkABXcPQxF+TtiWLcucUkuT8cKfj8iopLfba8ZTwmmP5gDf/QUax5RYcMsBQuqdvyG gHsdOQwthehMI0tiaLpwRUEvXEtUI5B0VYowhwXhCPSx6TywVOmiKC6YHXcT+bbqzJMI fYdA== 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=6FZH9QYuX9HtNcVJgfaYwPHuzhfVUQbAkXgeGVT8C4s=; b=iD3KFL/OWjRDk05+1WAOr66GKaNe2AjxtV0mYt2cFE8tgMItWfl3aDGEEOgUlymMBS mPvS/iiC8ioNRmxRzP8n2B8ih6lhm+rm0W/jfnofYvje3UrCO1Z+IIuwYDo+Azx42dv2 SMCKRWqT7yQkthpMEAkjwVHyyQlUUNJxYx5YsArAU3+4qm4+5BooszYbK2uPmTaaD5/H LjcerI4HtQ2brNvi9czx9KUgqQd+Ry1OlhH6YsMXft3KHeUKrpPdQ9EL4cdcXJEazOjO +LUdY7bkzRcTcgDT8hWtJQUWzZ4gDX/uUIiqgeI7nYhNHF3xho9TgmzhuoUtmIEwwdfh 9whw== X-Gm-Message-State: AOAM530hgt9I4wvk3BjxKCnXv0q0+UUTO8w5ibgRNKIHmRrYFvp4Xk5L GbqCetG2B2rrWmlPLPdElmqvPacVxVF5VG2JWxFbZucJAL7GTA== X-Received: by 2002:a19:8c4b:0:b0:44a:b6a4:4873 with SMTP id i11-20020a198c4b000000b0044ab6a44873mr24049748lfj.549.1651154268637; Thu, 28 Apr 2022 06:57:48 -0700 (PDT) MIME-Version: 1.0 From: Andreas Unterweger Date: Thu, 28 Apr 2022 15:57:38 +0200 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v6 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: VDEivuhPKh47 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;