[FFmpeg-devel] [PATCH 1/2] In mov muxer, mux adpcm_ms and adpcm_ima_wav the way quicktime supports it. In mov demuxer, set adpcm_ms and adpcm_ima_wav frame size to stsd samples per packet.

Baptiste Coudurier baptiste.coudurier
Wed Jan 26 21:57:17 CET 2011


On 01/25/2011 08:24 PM, Alex Converse wrote:
> On Tue, Jan 25, 2011 at 8:08 AM, Mans Rullgard<mans at mansr.com>  wrote:
>> From: Baptiste Coudurier<baptiste.coudurier at gmail.com>
>>
>> ---
>>   libavformat/mov.c    |    1 +
>>   libavformat/movenc.c |   29 ++++++++++++++++++++++++++++-
>>   2 files changed, 29 insertions(+), 1 deletions(-)
>>
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index 4370b48..6c1985d 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -1227,6 +1227,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, ByteIOContext *pb, int entries)
>>      case CODEC_ID_GSM:
>>      case CODEC_ID_ADPCM_MS:
>>      case CODEC_ID_ADPCM_IMA_WAV:
>> +        st->codec->frame_size = sc->samples_per_frame;
>>          st->codec->block_align = sc->bytes_per_frame;
>>          break;
>>      case CODEC_ID_ALAC:
>> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
>> index 5230938..6fe5da7 100644
>> --- a/libavformat/movenc.c
>> +++ b/libavformat/movenc.c
>> @@ -314,6 +314,16 @@ static int mov_pcm_le_gt16(enum CodecID codec_id)
>>             codec_id == CODEC_ID_PCM_F64LE;
>>   }
>>
>> +static int mov_write_ms_tag(ByteIOContext *pb, MOVTrack *track)
>> +{
>> +    int64_t pos = url_ftell(pb);
>> +    put_be32(pb, 0);
>> +    put_le32(pb, track->tag);
>> +    track->enc->codec_tag = track->tag>>  16;
>> +    ff_put_wav_header(pb, track->enc);
>
> I'm seeing an endian mismatch here vs quicktime.

Oh, that's right, quicktime still play the file though, I guess it 
ignores it.

I just looked at your patch, but I had this one since a long time in my 
tree. I guess your av_be2me solution is good here. Good catch.

>> +    return updateSize(pb, pos);
>> +}
>> +
>>   static int mov_write_wave_tag(ByteIOContext *pb, MOVTrack *track)
>>   {
>>      int64_t pos = url_ftell(pb);
>> @@ -339,6 +349,9 @@ static int mov_write_wave_tag(ByteIOContext *pb, MOVTrack *track)
>>          mov_write_ac3_tag(pb, track);
>>      } else if (track->enc->codec_id == CODEC_ID_ALAC) {
>>          mov_write_extradata_tag(pb, track);
>> +    } else if (track->enc->codec_id == CODEC_ID_ADPCM_MS ||
>> +               track->enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
>
> rather than checking this same condition everywhere perhaps we are
> better off with a acm(_(ad)pcm) flag?

Well ima4 does not have to be muxed this way (quicktime supports the new 
better way of muxing), I guess this way is limited to legacy adpcm 
avi/wav formats.

-- 
Baptiste COUDURIER
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer                                  http://www.ffmpeg.org



More information about the ffmpeg-devel mailing list