[FFmpeg-devel] [PATCH] Parse bext metadata in wav (BWF)

Tomas Härdin tomas.hardin
Fri Mar 4 09:20:34 CET 2011


Michael Niedermayer skrev 2011-03-03 00:44:
> On Wed, Mar 02, 2011 at 05:52:22PM +0100, Benjamin Larsson wrote:
>> On 03/02/2011 04:14 PM, Tomas H?rdin wrote:
>>> Hi
>>>
>>> The following patch set makes the wav demuxer parse the bext tag used in
>>> the Broadcast Wave Format (BWF). Doing so requires reworking the wav
>>> demuxer a bit, since it stops parsing the file once the data tag has
>>> been found. I have a sample where said tag is in the footer.
>>>
>>> In short, it'll parse the entire file if the file is seekable. If it's
>>> non-seekable then only the header is parsed. Any tags encountered are
>>> handled by the same switch statement, so tags before the fmt tag won't
>>> get ignored.
>>>
>>> I have no idea how to git-send-mail work on Windows, so mailing all
>>> patches might take a minute or two.
>>>
>>> /Tomas
>>
>
>> @@ -258,7 +265,21 @@ static int wav_read_header(AVFormatContext *s,
>>                   return AVERROR_INVALIDDATA;
>>               }
>>
>> +    if (!rf64)
>> +        data_size = size;
>> +    if (!data_size) {
>> +        wav->data_end = INT64_MAX;
>> +    } else
>> +        wav->data_end= url_ftell(pb) + data_size;
>> +
>> +            /* we can't look for metadata past the data tag if streaming, so stop parsing */
>> +            if (pb->is_streamed)
>>               goto break_loop;
>> +
>> +            /* keep going in order to parse footer metadata chunks */
>> +            data_ofs = url_ftell(pb);
>> +            next_tag_ofs = wav->data_end;
>> +            break;
>>           case MKTAG('f','a','c','t'):
>>               if(!sample_count)
>>               sample_count = avio_rl32(pb);
> [...]
>> Looks ok.
>
> no comment

Someone pointed out to me that this can lead to seeking to INT64_MAX. I 
decided to refactor this patch.

I also added another patch that sanity checks data_size and sample_count 
in the "if (rf64)" block further up.

Finally, I modified the bext patch to use avio_seek() instead of 
url_fskip().

/Tomas



More information about the ffmpeg-devel mailing list