X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2Fffmpeg%2Flibavformat%2Fcafenc.c;h=1708275e11f69843099ea7c73fe5e48038de82fd;hb=4a1a0bdd01eef90b0826a0e761d3379d3715c10f;hp=f94101ab020d29c44fbc6d80929a31748b2614ff;hpb=b1be5ca53587d23e7aeb77b26861fdc0a181ffd8;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/ffmpeg/libavformat/cafenc.c b/src/third_party/ffmpeg/libavformat/cafenc.c index f94101a..1708275 100644 --- a/src/third_party/ffmpeg/libavformat/cafenc.c +++ b/src/third_party/ffmpeg/libavformat/cafenc.c @@ -51,7 +51,7 @@ static uint32_t codec_flags(enum AVCodecID codec_id) { } } -static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels) { +static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int block_align) { switch (codec_id) { case AV_CODEC_ID_PCM_S8: case AV_CODEC_ID_PCM_S16LE: @@ -91,9 +91,9 @@ static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels) { case AV_CODEC_ID_ALAC: return 4096; case AV_CODEC_ID_ADPCM_IMA_WAV: - return (1024 - 4 * channels) * 8 / (4 * channels) + 1; + return (block_align - 4 * channels) * 8 / (4 * channels) + 1; case AV_CODEC_ID_ADPCM_MS: - return (1024 - 7 * channels) * 2 / channels + 2; + return (block_align - 7 * channels) * 2 / channels + 2; default: return 0; } @@ -107,6 +107,7 @@ static int caf_write_header(AVFormatContext *s) AVDictionaryEntry *t = NULL; unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, enc->codec_id); int64_t chunk_size = 0; + int frame_size = enc->frame_size; if (s->nb_streams != 1) { av_log(s, AV_LOG_ERROR, "CAF files have exactly one stream\n"); @@ -131,8 +132,6 @@ static int caf_write_header(AVFormatContext *s) case AV_CODEC_ID_PCM_F32BE: case AV_CODEC_ID_PCM_F64LE: case AV_CODEC_ID_PCM_F64BE: - case AV_CODEC_ID_PCM_ALAW: - case AV_CODEC_ID_PCM_MULAW: codec_tag = MKTAG('l','p','c','m'); } @@ -146,6 +145,9 @@ static int caf_write_header(AVFormatContext *s) return AVERROR_INVALIDDATA; } + if (enc->codec_id != AV_CODEC_ID_MP3 || frame_size != 576) + frame_size = samples_per_packet(enc->codec_id, enc->channels, enc->block_align); + ffio_wfourcc(pb, "caff"); //< mFileType avio_wb16(pb, 1); //< mFileVersion avio_wb16(pb, 0); //< mFileFlags @@ -156,7 +158,7 @@ static int caf_write_header(AVFormatContext *s) avio_wl32(pb, codec_tag); //< mFormatID avio_wb32(pb, codec_flags(enc->codec_id)); //< mFormatFlags avio_wb32(pb, enc->block_align); //< mBytesPerPacket - avio_wb32(pb, samples_per_packet(enc->codec_id, enc->channels)); //< mFramesPerPacket + avio_wb32(pb, frame_size); //< mFramesPerPacket avio_wb32(pb, enc->channels); //< mChannelsPerFrame avio_wb32(pb, av_get_bits_per_sample(enc->codec_id)); //< mBitsPerChannel @@ -257,7 +259,7 @@ static int caf_write_trailer(AVFormatContext *s) ffio_wfourcc(pb, "pakt"); avio_wb64(pb, caf->size_entries_used + 24); avio_wb64(pb, caf->packets); ///< mNumberPackets - avio_wb64(pb, caf->packets * samples_per_packet(enc->codec_id, enc->channels)); ///< mNumberValidFrames + avio_wb64(pb, caf->packets * samples_per_packet(enc->codec_id, enc->channels, enc->block_align)); ///< mNumberValidFrames avio_wb32(pb, 0); ///< mPrimingFrames avio_wb32(pb, 0); ///< mRemainderFrames avio_write(pb, caf->pkt_sizes, caf->size_entries_used);