From 60b433d905c582ed3656c120b3ffffd0119d5377 Mon Sep 17 00:00:00 2001 From: Tim Nicholson Date: Tue, 2 Oct 2012 11:18:04 +0100 Subject: [PATCH] movenc.c: Add support for >16bit BE flavours Currently only LE handled correctly Updated fate checksums to reflect new headers Signed-off-by: Michael Niedermayer --- libavformat/movenc.c | 26 +++++++++++++++++++++++--- tests/ref/fate/acodec-pcm-s24be | 4 ++-- tests/ref/fate/acodec-pcm-s32be | 4 ++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 1a618498e6..d456c4fc1d 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -288,6 +288,14 @@ static int mov_write_enda_tag(AVIOContext *pb) return 10; } +static int mov_write_enda_tag_be(AVIOContext *pb) +{ + avio_wb32(pb, 10); + ffio_wfourcc(pb, "enda"); + avio_wb16(pb, 0); /* big endian */ + return 10; +} + static void put_descr(AVIOContext *pb, int tag, unsigned int size) { int i = 3; @@ -369,6 +377,14 @@ static int mov_pcm_le_gt16(enum AVCodecID codec_id) codec_id == AV_CODEC_ID_PCM_F64LE; } +static int mov_pcm_be_gt16(enum AVCodecID codec_id) +{ + return codec_id == AV_CODEC_ID_PCM_S24BE || + codec_id == AV_CODEC_ID_PCM_S32BE || + codec_id == AV_CODEC_ID_PCM_F32BE || + codec_id == AV_CODEC_ID_PCM_F64BE; +} + static int mov_write_ms_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); @@ -432,8 +448,10 @@ static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track) ffio_wfourcc(pb, "mp4a"); avio_wb32(pb, 0); mov_write_esds_tag(pb, track); - } else if (mov_pcm_le_gt16(track->enc->codec_id)) { - mov_write_enda_tag(pb); + } else if (mov_pcm_le_gt16(track->enc->codec_id)) { + mov_write_enda_tag(pb); + } else if (mov_pcm_be_gt16(track->enc->codec_id)) { + mov_write_enda_tag_be(pb); } else if (track->enc->codec_id == AV_CODEC_ID_AMR_NB) { mov_write_amr_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_AC3) { @@ -629,6 +647,7 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track) tag = AV_RL32("lpcm"); version = 2; } else if (track->audio_vbr || mov_pcm_le_gt16(track->enc->codec_id) || + mov_pcm_be_gt16(track->enc->codec_id) || track->enc->codec_id == AV_CODEC_ID_ADPCM_MS || track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV || track->enc->codec_id == AV_CODEC_ID_QDM2) { @@ -697,7 +716,8 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track) track->enc->codec_id == AV_CODEC_ID_ADPCM_MS || track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV || track->enc->codec_id == AV_CODEC_ID_QDM2 || - (mov_pcm_le_gt16(track->enc->codec_id) && version==1))) + (mov_pcm_le_gt16(track->enc->codec_id) && version==1) || + (mov_pcm_be_gt16(track->enc->codec_id) && version==1))) mov_write_wave_tag(pb, track); else if(track->tag == MKTAG('m','p','4','a')) mov_write_esds_tag(pb, track); diff --git a/tests/ref/fate/acodec-pcm-s24be b/tests/ref/fate/acodec-pcm-s24be index c89e086630..4d82b3eeca 100644 --- a/tests/ref/fate/acodec-pcm-s24be +++ b/tests/ref/fate/acodec-pcm-s24be @@ -1,4 +1,4 @@ -5d843e1f56796aae3185016f164b16b7 *tests/data/fate/acodec-pcm-s24be.mov -1588269 tests/data/fate/acodec-pcm-s24be.mov +cbf0bd68d21099335e197ae812834110 *tests/data/fate/acodec-pcm-s24be.mov +1588323 tests/data/fate/acodec-pcm-s24be.mov 64151e4bcc2b717aa5a8454d424d6a1f *tests/data/fate/acodec-pcm-s24be.out.wav stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400 diff --git a/tests/ref/fate/acodec-pcm-s32be b/tests/ref/fate/acodec-pcm-s32be index f7dbc52d47..bfd2797521 100644 --- a/tests/ref/fate/acodec-pcm-s32be +++ b/tests/ref/fate/acodec-pcm-s32be @@ -1,4 +1,4 @@ -b34c66c56df1b1e75688929cf20670b9 *tests/data/fate/acodec-pcm-s32be.mov -2117473 tests/data/fate/acodec-pcm-s32be.mov +856b157d3ab505f0859b0de692e6a8bc *tests/data/fate/acodec-pcm-s32be.mov +2117527 tests/data/fate/acodec-pcm-s32be.mov 64151e4bcc2b717aa5a8454d424d6a1f *tests/data/fate/acodec-pcm-s32be.out.wav stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400