[FFmpeg-devel] [PATCH v2 7/7] avformat/audiointerleave: use a fixed frame duration for non-audio packets

Marton Balint cus at passwd.hu
Fri Mar 6 23:06:35 EET 2020



On Fri, 6 Mar 2020, Andreas Rheinhardt wrote:

> Marton Balint:
>> The packet durations might not be set properly which can cause the MXF muxer
>> to write more than one packet of a stream to an edit unit messing up the
>> constant byte per element index...
>> 
>> Also use nb_samples directly to calculate dts of audio packets because adding
>> packet durations might not be precise.
>> 
>> Signed-off-by: Marton Balint <cus at passwd.hu>
>> ---
>>  libavformat/audiointerleave.c | 12 +++++++++---
>>  libavformat/audiointerleave.h |  3 ++-
>>  libavformat/gxfenc.c          |  2 +-
>>  libavformat/mxfenc.c          |  2 +-
>>  4 files changed, 13 insertions(+), 6 deletions(-)
>> 
>> diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c
>> index 2e83031bd6..0643159770 100644
>> --- a/libavformat/audiointerleave.c
>> +++ b/libavformat/audiointerleave.c
>> @@ -40,6 +40,7 @@ void ff_audio_interleave_close(AVFormatContext *s)
>>
>>  int ff_audio_interleave_init(AVFormatContext *s,
>>                               const int samples_per_frame,
>> +                             const int frame_duration,
>>                               AVRational time_base)
>>  {
>>      int i;
>> @@ -48,6 +49,10 @@ int ff_audio_interleave_init(AVFormatContext *s,
>>          av_log(s, AV_LOG_ERROR, "timebase not set for audio interleave\n");
>>          return AVERROR(EINVAL);
>>      }
>> +    if (!frame_duration) {
>> +        av_log(s, AV_LOG_ERROR, "frame_duration not set for audio interleave\n");
>> +        return AVERROR(EINVAL);
>> +    }
>
> Shouldn't this be an assert given that we know that it is known at
> compiletime that this error can't be triggered?

It depends on how you _define_ the audiointerleave API. Just because it is 
impossible to trigger in current code does not mean that it should be 
an assert.

The main reason I prefer it this way is that there are similar checks for 
other parameters of the init function.

Regards,
Marton


More information about the ffmpeg-devel mailing list