From patchwork Wed Apr 27 13:35:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Unterweger X-Patchwork-Id: 35447 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp2984353pzh; Wed, 27 Apr 2022 06:35:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxH+3Hp3BbeQu/2x86kj1t3ipjkTLXj27AWImBK3bgLdAg8Nima7RiYFdlYXuZNKou8yXjk X-Received: by 2002:a17:906:58d5:b0:6f2:7235:ed08 with SMTP id e21-20020a17090658d500b006f27235ed08mr24279016ejs.444.1651066530117; Wed, 27 Apr 2022 06:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651066530; cv=none; d=google.com; s=arc-20160816; b=bg/C5qnqPaxndupk4/WK7iJQeN0nyPCmDbz7FM8m3G8Yyz0k/8b0fNe8banHd8jOp7 kMIYWQS2ayhcpyxfgry07idoZouhcOrGSWtZwbjsOrTaqlNlcPFVJZJTyWsBtueyujnF knOzIkUqDcY+KgZo8XMIxbyIEcLuafIRPrYMCYBlvLmCWcIlfP/mfaIl+PigNCFpu1O3 P+OeAvd+/Hzw+S03hh0VOVJDCmYR2FuLq86/wSCJh2gbFkuNZ6kXk8T9cDkraTmfwU5l l4EzhDPPt/pO/3Ct+CHTAj1dJtxf4VxZWb4XiMA0y/jUXMKmnKYXRttIGb6JLkXrBUYK kZNw== 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:from:user-agent:mime-version:date:message-id :dkim-signature:delivered-to; bh=mPYT3d92cKfS0PIrMXuRGbqT21OGD8Dq+FmGP2dJoPg=; b=edV+ZoPWjnUEsDjAk86EnTo2uIsTJDjWJjqSIrIUGaqDfg4JJ7PBHavFXZqxge8gM7 LPf91FQRIpAf4tkhV3UjCDy6Ml0/5S78gtL9siW154QovrRyTnURaHf8/7ML/eDtd9cg PdHP3vnOBGp0+2jo6o66W9j0O92FWS2GCgCbiCyOVz7dYI/2LhRtCN/ScW6zTGQMDn3p q7H912tfB5hDImB0G6N4I36P7TNNm9AohmgyGRtylUiNEQmpFvMSI/iPObvBQ/Y34uhv RtxpSP8qTPLn36ET8Q2YUjoicXXRz4IiJ/gwV9TCQkqu903s9npCjlx+Y4Dcv4sFJTMt pP1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Ujp+QZmA; 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 oq6-20020a170906cc8600b006f37fa72a71si1178420ejb.537.2022.04.27.06.35.29; Wed, 27 Apr 2022 06:35:30 -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=Ujp+QZmA; 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 E094E68B41B; Wed, 27 Apr 2022 16:35:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A4A2068B40F for ; Wed, 27 Apr 2022 16:35:20 +0300 (EEST) Received: by mail-ed1-f47.google.com with SMTP id k27so1972966edk.4 for ; Wed, 27 Apr 2022 06:35:20 -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-transfer-encoding; bh=QW7bGq8d3l8RRqWPFKxHnZaYNke5nXz0NPEwiDCvSBE=; b=Ujp+QZmA6PxExA9ZpFnaEbRXUfR9keHED9rnw0Xdg/GO4qvmZ9EXOPqqI2JKyF54EH mJ3XX0bX2ejcs/16dzEjstL7+9F82Fq2hjrp/vJBOW4OsOjKLMheVF/WEiPfOpAtDAGQ Kj0+cI4+fXHccIQZxqMUvRzypoiDdtUfC9NRwaxopSLL+9/jnpT8UD7zh8fQyBFU/xEQ ydxaPHgm9SoXQLk/70sDvO3F4DUN2Di/UUTatz5rhIVHqAm/rJTQ43zKbduS9mg0VQeT ZKlu2K+S8V+aURFNJmdYmbbJWIDBaFken14tkwjb/yj19vqMYt5I8QxpiFmCxqMpTnaV k9sw== 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-transfer-encoding; bh=QW7bGq8d3l8RRqWPFKxHnZaYNke5nXz0NPEwiDCvSBE=; b=eEyZ41lKb3wL6eVD8cnhizH1ZaGOtcXHxkJg0pN6zOZgCJvh4ijsVuu0BgSeCSpf9I mOd8zqYMaV0clmYgv9yTwtatDwXo9KsIur+5NxyEzd5TDrRISs3aTRRISmlL4phk8+MK kjLYxKpeHLdKn/8ahapzmBB5KWnG6rCmOrJOrugS3kleO9Nocd5ig7JfB8Uo+Uc9Z2n0 pF9h3jQ9ZpVwGmBp6c3wpHUZ0a8wmRvlOY5i+fSV2x7wPILGzKOTe5MGSrz22uPflz5L mzfaz1lIv3Ys7hrEz3eOy8wgx2mp4OZPAS4Khwi/c2kvZmNLK3SdBmu+R4CrpTXwwgYl x1BQ== X-Gm-Message-State: AOAM533qsWv8ecRvmCv7aMOqSFIPWDAKH04UQxTss79dxJoQSNr49fAR z0ddRLJrGPUIZgaXd8et7EoPx+UUMC8sog== X-Received: by 2002:a05:6402:270f:b0:425:f061:bab9 with SMTP id y15-20020a056402270f00b00425f061bab9mr14288264edd.262.1651066520060; Wed, 27 Apr 2022 06:35:20 -0700 (PDT) Received: from [172.16.222.185] (195-192-17-253.stat.cablelink.at. [195.192.17.253]) by smtp.gmail.com with ESMTPSA id le4-20020a170906ae0400b006f38734cadbsm4987602ejb.136.2022.04.27.06.35.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 06:35:19 -0700 (PDT) Message-ID: <7e5dab1f-b5b2-d70d-c219-d89e89f752a7@gmail.com> Date: Wed, 27 Apr 2022 15:35:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 From: Andreas Unterweger To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v3 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: Co3XqN+YDZOi 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(-) 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; /* 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) From patchwork Wed Apr 27 13:35:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Unterweger X-Patchwork-Id: 35448 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b9e:b0:7d:cfb5:dc7c with SMTP id b30csp2984466pzh; Wed, 27 Apr 2022 06:35:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQScRUT2IzYwXARuAQswADL44vMKS/Ro2wdYKDCGdQqNoga+NoHtfQYZBFl7HCbPeoGfD1 X-Received: by 2002:aa7:cd7c:0:b0:425:e59d:7353 with SMTP id ca28-20020aa7cd7c000000b00425e59d7353mr17384065edb.365.1651066541377; Wed, 27 Apr 2022 06:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651066541; cv=none; d=google.com; s=arc-20160816; b=G7QoGBm4vsS/8j5kKdXgw8j2DP5iB0qarj/FBqE9KyWLRg+NY1U8TkAp+Gxy0kb6eH 5o8iDrIJym88Qugpv7YWe5SqhxzRmtQPTsnBPFIR3VBpuTf7D+to52V4qXNZ/At4mhHa b+XiqWIror1/wCMP6rJxV5dM3kiMHUp4DeAd/InHPKDYFni3RjtbnfeTKr9zRdeIIfAP iv1uykNJ/CsJvPsxKvWGVxOUwNF5pg6FyNVh9+R21UlUo+nZD4EMcuA5qD4W5zkPIl6j PgenM0VJ1tafcQfG02PDV/N6HvdPDQ+y8Ud9hkgnGFwc8DJFHnGL/531tRNB5rxPoi1V G6cQ== 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:from:user-agent:mime-version:date:message-id :dkim-signature:delivered-to; bh=Z5jjbQCSCDXMLqFR2hoDVeuFMmRcWgqkFck/5hCTPCs=; b=b50ynmF1cWvPojfbSABUq/wmsrmp3lOUyPsYGpLfqY822c1IEsaciXneGxVPiDceVR 3zzT6qbmOl67HC6BBNvvI8/PDHuqBrRWOldghQverevUsytLa+MRx7PAvYxBlZLbMr1v 5GfGX2gZz34m+CtOGZzrmySIQhsNFfr8ZkbFR+YgLSv7x9baKp6tlbZDyp+SM7h/hTLZ 34mXGgzMhkt0AHeatQ6Itx6e2EmWDrVHg5cON8Pn8phumukLMImLDAPCmIXJC0hXgJea jKMz39nkV68/0ujKVdpdDaoTH7oqKAnzuROlSPmjw0wwWUtDpn+LKBdVBffIKWmQHhWT ANSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Bu+4kMBV; 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 gf25-20020a170906e21900b006e48d161aaasi1190618ejb.213.2022.04.27.06.35.40; Wed, 27 Apr 2022 06:35:41 -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=Bu+4kMBV; 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 C542368B428; Wed, 27 Apr 2022 16:35:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 700BB68B3F5 for ; Wed, 27 Apr 2022 16:35:31 +0300 (EEST) Received: by mail-ed1-f44.google.com with SMTP id d6so1964112ede.8 for ; Wed, 27 Apr 2022 06:35:31 -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-transfer-encoding; bh=gZclkIT3RGQlS5RfBrbeVcIfKPbYH/qLa8NBVsGg1G4=; b=Bu+4kMBVZrHt/aAK4HnwOFBKntin79don935PZa/Okg9IYgFK96Pa44QdGD0yLeQXv DDm83X2f5KJqZO5/6tRbk9WTQUh9u0hNFETgzlL6Fbyn07z0Hd2zKoeSGo+6HAj+Ag1Q wCzadzWuvXaY58dFm/XReIzfPedK6Gem3/5t33dSk9BRtS33QnebCZb1WPWDoREoEygE AE177T4Cedc3+QJKJCzYpSPSRd7ApXrZjTi/NgNzU6XZ1WSA82t/eEreq2OCZvnp6y6/ T0UpMRkikIxP5IjgIGxDfCBAn/OckFGspwGQKawb0F61yAuaF/Jwcvj3CcKHnC4P/Bdh jQjw== 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-transfer-encoding; bh=gZclkIT3RGQlS5RfBrbeVcIfKPbYH/qLa8NBVsGg1G4=; b=VcAunmbFKiwPAdfp8SxQwZQqe2VruTyR/lrZqxi+G+rUKxS9Vs75PTKohIrX52m/2N 9klp9CgVvtqpfYw9MzM2ql9HZiqzJtkJtxfZWjYzW4Emc+MPGQMbOVoVX7mCPqY7nuW6 nwG+n1G988HvA01QQbv9BzjN3htgFMZ0KAGSCr6WRUmkzsEtjKkz7IX1IaUov3mF5M0L KYrd4e2QmkEvt/l5xowueOKVF1QIzdi5Bt4Dzwn9Fqp1IWkdQNMC2Miii7sPjUCOV1n7 jwpVTVqy+BE3f4hOQzneaArZqUpaiNjErw4M0YKxbRoEgcQzQDUHm48Nnq+lMmLh3qhd mNng== X-Gm-Message-State: AOAM531Kp/w/V8yOBBufS++qcBkRBpgZIn7zBSY1c3MYnCUHRlBA7AKd 9teTNxMvu/0MwOLnZriLNqVh4/ZKYw1Vxw== X-Received: by 2002:a05:6402:5255:b0:425:e40a:c927 with SMTP id t21-20020a056402525500b00425e40ac927mr17378671edd.308.1651066530935; Wed, 27 Apr 2022 06:35:30 -0700 (PDT) Received: from [172.16.222.185] (195-192-17-253.stat.cablelink.at. [195.192.17.253]) by smtp.gmail.com with ESMTPSA id bo14-20020a170906d04e00b006ce98d9c3e3sm6782372ejb.194.2022.04.27.06.35.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Apr 2022 06:35:30 -0700 (PDT) Message-ID: <72590313-f19e-8154-c596-c5b5efc2b82e@gmail.com> Date: Wed, 27 Apr 2022 15:35:31 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 From: Andreas Unterweger To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v3 2/2] doc/examples/transcode_aac: Set decoder packet timebase 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: REWwO/mtOSsQ Previously, the default timebase caused two warnings during decoding about not being able to update timestamps for skipped and discarded samples, respectively. Signed-off-by: Andreas Unterweger --- doc/examples/transcode_aac.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c index c9b93f6439..6197369756 100644 --- a/doc/examples/transcode_aac.c +++ b/doc/examples/transcode_aac.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2018 Andreas Unterweger + * Copyright (c) 2013-2022 Andreas Unterweger * * This file is part of FFmpeg. * @@ -120,6 +120,10 @@ static int open_input_file(const char *filename, avformat_close_input(input_format_context); return error; } + + /* Set the packet timebase for the decoder. The input file's sample + * rate is used as the denominator for simplicity. */ + avctx->pkt_timebase = (AVRational) { 1, avctx->sample_rate }; /* Save the decoder context for easier access later. */ *input_codec_context = avctx; -- 2.30.2