[FFmpeg-devel] [PATCH 2/3] avformat: Support s337m in mxf/wav/w64

Tomas Härdin tjoppen at acc.umu.se
Tue Jul 30 15:02:26 EEST 2019


fre 2019-07-26 klockan 18:45 +0200 skrev Nicolas Gaullier:
> @@ -1951,6 +1951,13 @@ typedef struct AVFormatContext {
>       * - decoding: set by user
>       */
>      int skip_estimate_duration_from_pts;
> +
> +    /**
> +     * Probe dolby_e in PCM streams
> +     * - encoding: unused
> +     * - decoding: set by user
> +     */
> +    int dolby_e_probe;

This probably belongs in MXFContext and WAVDemuxContext

>  } AVFormatContext;
>  
>  #if FF_API_FORMAT_GET_SET
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index bb72fb9841..5b6eb9d756 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -56,6 +56,7 @@
>  #include "avformat.h"
>  #include "internal.h"
>  #include "mxf.h"
> +#include "s337m.h"
>  
>  #define MXF_MAX_CHUNK_SIZE (32 << 20)
>  
> @@ -302,6 +303,8 @@ typedef struct MXFMetadataReadTableEntry {
>      enum MXFMetadataSetType type;
>  } MXFMetadataReadTableEntry;
>  
> +static int mxf_read_packet_init = 0;

This definitely belongs in MXFContext

> @@ -3247,6 +3250,19 @@ static int mxf_read_header(AVFormatContext *s)
>      if ((ret = mxf_parse_structural_metadata(mxf)) < 0)
>          goto fail;
>  
> +    if (mxf->fc->dolby_e_probe)
> +    {
> +        int i;
> +        AVPacket *pkt = av_packet_alloc();
> +        av_init_packet(pkt);
> +        mxf_read_packet_init = 1;
> +        for (i = 0; i < mxf->fc->nb_streams; i++)
> +            mxf_read_packet(mxf->fc, pkt);

mxf_read_packet() has a whole bunch of side effects. I'm not so sure
you want to use it here.

> @@ -3539,7 +3555,9 @@ static int mxf_read_packet(AVFormatContext *s,
> AVPacket *pkt)
>                      return ret;
>                  }
>              } else {
> -                ret = av_get_packet(s->pb, pkt, klv.length);
> +                if (mxf_read_packet_init)
> +                    s337m_probe_stream(mxf->fc, &st);
> +                ret = st->codecpar->codec_id == AV_CODEC_ID_DOLBY_E
> ? s337m_read_packet(s, pkt) : av_get_packet(s->pb, pkt, klv.length);

Are you sure there's no UL for this? Did you poke the company who
created the files to have them fix their encoder?

> diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
> index 52194f54ef..501c21f220 100644
> --- a/libavformat/wavdec.c
> +++ b/libavformat/wavdec.c
> @@ -41,6 +41,7 @@
>  #include "riff.h"
>  #include "w64.h"
>  #include "spdif.h"
> +#include "s337m.h"
>  
>  typedef struct WAVDemuxContext {
>      const AVClass *class;
> @@ -593,6 +594,8 @@ break_loop:
>      } else if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_MS && st-
> >codecpar->channels > 2) {
>          st->codecpar->block_align *= st->codecpar->channels;
>      }
> +    if (s->dolby_e_probe)
> +        s337m_probe_stream(s, &st);

The same goes here - these codecs should have corresponding TwoCCs.
Send angry emails to your vendor.

/Tomas



More information about the ffmpeg-devel mailing list