From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/libfdk-aaceenc: add a flush callback
Date: Mon, 27 Mar 2023 17:09:56 -0300
Message-ID: <20230327200956.2138-2-jamrial@gmail.com> (raw)
In-Reply-To: <20230327200956.2138-1-jamrial@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
---
libavcodec/libfdk-aacenc.c | 40 ++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/libavcodec/libfdk-aacenc.c b/libavcodec/libfdk-aacenc.c
index eb97e0fb41..6d6462d951 100644
--- a/libavcodec/libfdk-aacenc.c
+++ b/libavcodec/libfdk-aacenc.c
@@ -132,6 +132,44 @@ static int aac_encode_close(AVCodecContext *avctx)
return 0;
}
+static void aac_encode_flush(AVCodecContext *avctx)
+{
+ AACContext *s = avctx->priv_data;
+ AACENC_BufDesc in_buf = { 0 }, out_buf = { 0 };
+ AACENC_InArgs in_args = { 0 };
+ AACENC_OutArgs out_args;
+ int64_t pts, duration;
+ uint8_t dummy_in[1], dummy_out[1];
+ int in_buffer_identifiers[] = { IN_AUDIO_DATA, IN_METADATA_SETUP };
+ int in_buffer_element_sizes[] = { 2, sizeof(AACENC_MetaData) };
+ int in_buffer_sizes[] = { 0, sizeof(s->metaDataSetup) };
+ int out_buffer_identifier = OUT_BITSTREAM_DATA;
+ int out_buffer_size = sizeof(dummy_out), out_buffer_element_size = 1;
+ void* inBuffer[] = { dummy_in, &s->metaDataSetup };
+ void *out_ptr = dummy_out;
+ AACENC_ERROR err;
+
+ ff_af_queue_remove(&s->afq, s->afq.frame_count, &pts, &duration);
+
+ in_buf.bufs = (void **)inBuffer;
+ in_buf.numBufs = s->metadata_mode == 0 ? 1 : 2;
+ in_buf.bufferIdentifiers = in_buffer_identifiers;
+ in_buf.bufSizes = in_buffer_sizes;
+ in_buf.bufElSizes = in_buffer_element_sizes;
+
+ out_buf.numBufs = 1;
+ out_buf.bufs = &out_ptr;
+ out_buf.bufferIdentifiers = &out_buffer_identifier;
+ out_buf.bufSizes = &out_buffer_size;
+ out_buf.bufElSizes = &out_buffer_element_size;
+
+ err = aacEncEncode(s->handle, &in_buf, &out_buf, &in_args, &out_args);
+ if (err != AACENC_OK) {
+ av_log(avctx, AV_LOG_ERROR, "Unexpected error while flushing: %s\n",
+ aac_get_error(err));
+ }
+}
+
static av_cold int aac_encode_init(AVCodecContext *avctx)
{
AACContext *s = avctx->priv_data;
@@ -561,11 +599,13 @@ const FFCodec ff_libfdk_aac_encoder = {
.p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_AAC,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
+ AV_CODEC_CAP_ENCODER_FLUSH |
AV_CODEC_CAP_SMALL_LAST_FRAME,
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE,
.priv_data_size = sizeof(AACContext),
.init = aac_encode_init,
FF_CODEC_ENCODE_CB(aac_encode_frame),
+ .flush = aac_encode_flush,
.close = aac_encode_close,
.p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
--
2.40.0
_______________________________________________
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".
next prev parent reply other threads:[~2023-03-27 20:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 20:09 [FFmpeg-devel] [PATCH 1/2] avcodec/libx264: " James Almer
2023-03-27 20:09 ` James Almer [this message]
2023-03-27 20:33 ` Andreas Rheinhardt
2023-03-27 20:40 ` James Almer
2023-03-28 21:12 ` Michael Niedermayer
2023-03-28 21:25 ` [FFmpeg-devel] [PATCH v2 " James Almer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230327200956.2138-2-jamrial@gmail.com \
--to=jamrial@gmail.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git