[FFmpeg-devel] [PATCH 2/2] avformat: parse iTunes gapless information

James Almer jamrial at gmail.com
Sat Jul 23 17:07:11 EEST 2016


On 7/23/2016 8:25 AM, Michael Niedermayer wrote:
> On Fri, Jul 22, 2016 at 05:19:14PM -0700, kode54 at gmail.com wrote:
>> From: Chris Moeller <kode54 at gmail.com>
>>
>> ---
>>  libavformat/mp3dec.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++-
>>  1 file changed, 63 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
>> index 56c7f8c..3055e2c 100644
>> --- a/libavformat/mp3dec.c
>> +++ b/libavformat/mp3dec.c
>> @@ -295,6 +295,53 @@ static void mp3_parse_vbri_tag(AVFormatContext *s, AVStream *st, int64_t base)
>>      }
>>  }
>>  
>> +static void mp3_parse_itunes_tag(AVFormatContext *s, AVStream *st, MPADecodeHeader *c, int64_t base, int vbrtag_size, unsigned int *size, uint64_t *duration)
>> +{
>> +    uint32_t v;
>> +    AVDictionaryEntry *de;
>> +    MP3DecContext *mp3 = s->priv_data;
>> +    size_t length;
>> +    uint32_t zero, start_pad, end_pad;
>> +    uint64_t last_eight_frames_offset;
>> +    int i;
>> +
>> +    if (!s->metadata || !(de = av_dict_get(s->metadata, "iTunSMPB", NULL, 0)))
>> +      return;
>> +
>> +    length = strlen(de->value);
>> +
>> +    /* Minimum length is one digit per field plus the whitespace, maximum length should depend on field type
>> +     * There are four fields we need in the first six, the rest are currently zero padding */
>> +    if (length < (12 + 11) || length > (10 * 8 + 2 * 16 + 11))
>> +        return;
>> +
> 
>> +    if (sscanf(de->value, "%x %x %x %llx %x %llx", &zero, &start_pad, &end_pad, duration, &zero, &last_eight_frames_offset) < 6) {
> 
> %llx mismatches the type

Also please use the SCN* macros, which work like the PRI* macros from printf.


More information about the ffmpeg-devel mailing list