[FFmpeg-devel] [PATCH 1/3] avformat/iamf_writer: Avoid using dynamic buffer

James Almer jamrial at gmail.com
Fri Feb 2 14:32:00 EET 2024


On 2/2/2024 8:30 AM, Andreas Rheinhardt wrote:
> Andreas Rheinhardt:
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
>> ---
>>   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);
> 
> Will apply this patchset tomorrow unless there are objections.
> 
> - Andreas

Set LGTM, thanks.


More information about the ffmpeg-devel mailing list