[FFmpeg-devel] [PATCH 3/5] avformat/mxfdec: guess wrapping of tracks by other tracks with the same body sid

Marton Balint cus at passwd.hu
Sun Apr 14 20:29:23 EEST 2019



On Sun, 14 Apr 2019, Tomas Härdin wrote:

> fre 2019-04-12 klockan 01:09 +0200 skrev Marton Balint:
>> This affects the following samples:
>> 
>> samples/ffmpeg-bugs/roundup/issue1775/av_seek_frame_failure.mxf
>> samples/ffmpeg-bugs/trac/ticket1957/16ch.mxf
>> samples/ffmpeg-bugs/trac/ticket5016/r0.mxf
>> samples/ffmpeg-bugs/trac/ticket5016/r1.mxf
>> samples/ffmpeg-bugs/trac/ticket5316/hq.MXF
>> samples/ffmpeg-bugs/trac/ticket5316/hqx.MXF
>> 
>> Some AVPacket->pos values are changed because for frame wrapped tracks we point
>> to the KLV offset and not the data.
>> 
>> > Signed-off-by: Marton Balint <cus at passwd.hu>
>> ---
>>  libavformat/mxfdec.c | 26 ++++++++++++++++----------
>>  1 file changed, 16 insertions(+), 10 deletions(-)
>> 
>> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
>> index 18c038c3f6..236294880e 100644
>> --- a/libavformat/mxfdec.c
>> +++ b/libavformat/mxfdec.c
>> @@ -2144,6 +2144,16 @@ static int mxf_add_metadata_stream(MXFContext *mxf, MXFTrack *track)
>>      return 0;
>>  }
>>  
>> +static MXFWrappingScheme mxf_get_wrapping_by_body_sid(AVFormatContext *s, int body_sid)
>> +{
>> +    for (int i = 0; i < s->nb_streams; i++) {
>> +        MXFTrack *track = s->streams[i]->priv_data;
>> +        if (track && track->body_sid == body_sid && track->wrapping != UnknownWrapped)
>> +            return track->wrapping;
>
> Maybe print a warning? Especially if, god forbid, the file mixes
> ClipWrapping and FrameWrapping..
>
> But now I see this function was merely moved further up, so that could
> be a separate patch..
>
>> @@ -2553,6 +2563,12 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
>>          }
>>      }
>>  
>> +    for (int i = 0; i < mxf->fc->nb_streams; i++) {
>> +        MXFTrack *track = mxf->fc->streams[i]->priv_data;
>> +        if (track && track->body_sid && track->wrapping == UnknownWrapped)
>> +            track->wrapping = mxf_get_wrapping_by_body_sid(mxf->fc, track->body_sid);
>> +    }
>
> Or maybe put a warning here instead. Vendors should fix their dang MXF
> muxers..

We already have a warning (info) if we encounter a stream with unknown 
wrapping in mxf_structural_metadata.

Based on the samples that are affected by this, wrapping is assumed 
unknown for some GrassValley HQ/HQX files, probably we should fix 
our own demuxer here and assume frame wrapped. Although we have no idea if 
clip wrapped HQ/HQX exists...

The other one is some Omneon files with uncompressed audio in "AAF 
AIFF-AIFC Audio Container". This can just as easily be frame wrapped as 
clip wrapped, no?

Thanks,
Marton


More information about the ffmpeg-devel mailing list