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

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Fri Mar 6 05:19:06 EET 2020


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?

- Andreas


More information about the ffmpeg-devel mailing list