[FFmpeg-cvslog] avformat/iamf_writer: Avoid using dynamic buffer
Andreas Rheinhardt
git at videolan.org
Sat Feb 3 01:38:21 EET 2024
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Wed Jan 31 09:15:57 2024 +0100| [b9596daafbc7b262d07c5571f20bab255a399991] | committer: Andreas Rheinhardt
avformat/iamf_writer: Avoid using dynamic buffer
Reviewed-by: James Almer <jamrial at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b9596daafbc7b262d07c5571f20bab255a399991
---
libavformat/iamf_writer.c | 28 ++++++----------------------
1 file changed, 6 insertions(+), 22 deletions(-)
diff --git a/libavformat/iamf_writer.c b/libavformat/iamf_writer.c
index 99602ae204..f665f45b7a 100644
--- a/libavformat/iamf_writer.c
+++ b/libavformat/iamf_writer.c
@@ -807,31 +807,15 @@ static int iamf_write_mixing_presentation(const IAMFContext *iamf,
int ff_iamf_write_descriptors(const IAMFContext *iamf, AVIOContext *pb, void *log_ctx)
{
- uint8_t header[MAX_IAMF_OBU_HEADER_SIZE];
- PutBitContext pbc;
- AVIOContext *dyn_bc;
- uint8_t *dyn_buf = NULL;
- int dyn_size;
-
- int ret = avio_open_dyn_buf(&dyn_bc);
- if (ret < 0)
- return ret;
+ int ret;
// Sequence Header
- init_put_bits(&pbc, header, sizeof(header));
- put_bits(&pbc, 5, IAMF_OBU_IA_SEQUENCE_HEADER);
- put_bits(&pbc, 3, 0);
- flush_put_bits(&pbc);
+ avio_w8(pb, IAMF_OBU_IA_SEQUENCE_HEADER << 3);
- avio_write(dyn_bc, header, put_bytes_count(&pbc, 1));
- ffio_write_leb(dyn_bc, 6);
- avio_wb32(dyn_bc, MKBETAG('i','a','m','f'));
- avio_w8(dyn_bc, iamf->nb_audio_elements > 1); // primary_profile
- avio_w8(dyn_bc, iamf->nb_audio_elements > 1); // additional_profile
-
- dyn_size = avio_close_dyn_buf(dyn_bc, &dyn_buf);
- avio_write(pb, dyn_buf, dyn_size);
- av_free(dyn_buf);
+ ffio_write_leb(pb, 6);
+ avio_wb32(pb, MKBETAG('i','a','m','f'));
+ avio_w8(pb, iamf->nb_audio_elements > 1); // primary_profile
+ avio_w8(pb, iamf->nb_audio_elements > 1); // additional_profile
for (int i = 0; i < iamf->nb_codec_configs; i++) {
ret = iamf_write_codec_config(iamf, iamf->codec_configs[i], pb);
More information about the ffmpeg-cvslog
mailing list