Changeset 1007

Show
Ignore:
Timestamp:
12/29/08 08:24:20 (1 year ago)
Author:
gbooker
Message:

Set the mFramesPerPacket for linear PCM audio formats. This fixes lPCM in flv files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ff_private.c

    r989 r1007  
    219219         
    220220        memset(&asbd,0,sizeof(asbd)); 
    221         map_avi_to_mov_tag(codec->codec_id, &asbd, map); 
     221        map_avi_to_mov_tag(codec->codec_id, &asbd, map, codec->channels); 
    222222        if(asbd.mFormatID == 0) /* no know codec, use the ms tag */ 
    223223                asbd.mFormatID = 'ms\0\0' + codec->codec_tag; /* the number is stored in the last byte => big endian */ 
     
    235235        asbd.mSampleRate = codec->sample_rate; 
    236236        asbd.mChannelsPerFrame = codec->channels; 
    237         if(!map->vbr) /* This works for all the tested codecs. but is there any better way? */ 
     237        if(!map->vbr && asbd.mBytesPerPacket == 0) /* This works for all the tested codecs. but is there any better way? */ 
    238238                asbd.mBytesPerPacket = codec->block_align; /* this is tested for alaw/mulaw/msadpcm */ 
    239239        asbd.mFramesPerPacket = codec->frame_size; /* works for mp3, all other codecs this is 0 anyway */ 
     
    354354 
    355355/* maps the codec_id tag of libavformat to a constant the AudioToolbox can work with */ 
    356 void map_avi_to_mov_tag(enum CodecID codec_id, AudioStreamBasicDescription *asbd, NCStream *map
     356void map_avi_to_mov_tag(enum CodecID codec_id, AudioStreamBasicDescription *asbd, NCStream *map, int channels
    357357{ 
    358358        switch(codec_id) { 
     
    370370                        asbd->mFormatID = kAudioFormatLinearPCM; 
    371371                        asbd->mFormatFlags = kLinearPCMFormatFlagIsSignedInteger; 
     372                        asbd->mBytesPerPacket = 2 * channels; 
    372373                        break; 
    373374                case CODEC_ID_PCM_U8: 
    374375                        asbd->mFormatID = kAudioFormatLinearPCM; 
    375376                        asbd->mFormatFlags = kLinearPCMFormatFlagIsBigEndian; 
     377                        asbd->mBytesPerPacket = channels; 
    376378                        break; 
    377379                case CODEC_ID_PCM_ALAW: 
  • trunk/ff_private.h

    r984 r1007  
    109109OSType map_video_codec_to_mov_tag(enum CodecID codec_id); 
    110110OSType forced_map_video_codec_to_mov_tag(enum CodecID codec_id); 
    111 void map_avi_to_mov_tag(enum CodecID codec_id, AudioStreamBasicDescription *asbd, NCStream *map); 
     111void map_avi_to_mov_tag(enum CodecID codec_id, AudioStreamBasicDescription *asbd, NCStream *map, int channels); 
    112112uint8_t *create_cookie(AVCodecContext *codec, size_t *cookieSize, UInt32 formatID, int vbr); 
    113113Handle create_strf_ext(AVCodecContext *codec);