Revert "movenc: simplify handling of pcm vs. adpcm vs. other compressed codecs"

This reverts commit 8e8c51318c.

Fixes Ticket873

Conflicts:

	tests/ref/acodec/pcm_s16be
	tests/ref/acodec/pcm_s24be
	tests/ref/acodec/pcm_s32be
	tests/ref/acodec/pcm_s8
	tests/ref/lavf/mov

Approved-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
release/0.10
Michael Niedermayer 13 years ago
parent 9c909e8e79
commit 89ddff92a3
  1. 61
      libavformat/movenc.c
  2. 4
      tests/ref/acodec/pcm_s16be
  3. 4
      tests/ref/acodec/pcm_s24be
  4. 4
      tests/ref/acodec/pcm_s32be
  5. 4
      tests/ref/acodec/pcm_s8
  6. 4
      tests/ref/lavf/mov

@ -464,9 +464,15 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
uint32_t tag = track->tag;
if (track->mode == MODE_MOV) {
if (mov_get_lpcm_flags(track->enc->codec_id))
tag = AV_RL32("lpcm");
version = 2;
if (track->timescale > UINT16_MAX) {
if (mov_get_lpcm_flags(track->enc->codec_id))
tag = AV_RL32("lpcm");
version = 2;
} else if (track->audio_vbr || mov_pcm_le_gt16(track->enc->codec_id) ||
track->enc->codec_id == CODEC_ID_ADPCM_MS ||
track->enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
version = 1;
}
}
avio_wb32(pb, 0); /* size */
@ -493,18 +499,34 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
avio_wb32(pb, av_get_bits_per_sample(track->enc->codec_id));
avio_wb32(pb, mov_get_lpcm_flags(track->enc->codec_id));
avio_wb32(pb, track->sampleSize);
avio_wb32(pb, track->audio_vbr ? track->enc->frame_size : 1);
avio_wb32(pb, track->enc->frame_size);
} else {
/* reserved for mp4/3gp */
avio_wb16(pb, 2);
avio_wb16(pb, 16);
avio_wb16(pb, 0);
if (track->mode == MODE_MOV) {
avio_wb16(pb, track->enc->channels);
if (track->enc->codec_id == CODEC_ID_PCM_U8 ||
track->enc->codec_id == CODEC_ID_PCM_S8)
avio_wb16(pb, 8); /* bits per sample */
else
avio_wb16(pb, 16);
avio_wb16(pb, track->audio_vbr ? -2 : 0); /* compression ID */
} else { /* reserved for mp4/3gp */
avio_wb16(pb, 2);
avio_wb16(pb, 16);
avio_wb16(pb, 0);
}
avio_wb16(pb, 0); /* packet size (= 0) */
avio_wb16(pb, track->timescale); /* Time scale */
avio_wb16(pb, 0); /* Reserved */
}
if(version == 1) { /* SoundDescription V1 extended info */
avio_wb32(pb, track->enc->frame_size); /* Samples per packet */
avio_wb32(pb, track->sampleSize / track->enc->channels); /* Bytes per packet */
avio_wb32(pb, track->sampleSize); /* Bytes per frame */
avio_wb32(pb, 2); /* Bytes per sample */
}
if(track->mode == MODE_MOV &&
(track->enc->codec_id == CODEC_ID_AAC ||
track->enc->codec_id == CODEC_ID_AC3 ||
@ -2279,6 +2301,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n");
return -1;
}
} else if (enc->codec_id == CODEC_ID_ADPCM_MS ||
enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) {
samplesInChunk = enc->frame_size;
} else if (trk->sampleSize)
samplesInChunk = size/trk->sampleSize;
else
@ -2520,21 +2545,21 @@ static int mov_write_header(AVFormatContext *s)
"or choose different container.\n");
}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
track->timescale = st->codec->sample_rate;
/* set sampleSize for PCM and ADPCM */
if (av_get_bits_per_sample(st->codec->codec_id)) {
if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i);
goto error;
}else if(st->codec->codec_id == CODEC_ID_ADPCM_MS ||
st->codec->codec_id == CODEC_ID_ADPCM_IMA_WAV){
if (!st->codec->block_align) {
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set\n", i);
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);
goto error;
}
track->sampleSize = st->codec->block_align;
}
/* set audio_vbr for compressed audio */
if (av_get_bits_per_sample(st->codec->codec_id) < 8) {
if (!st->codec->frame_size) {
av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i);
goto error;
}
}else if(st->codec->frame_size > 1){ /* assume compressed audio */
track->audio_vbr = 1;
}else{
st->codec->frame_size = 1;
track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
}
if (track->mode != MODE_MOV) {
if (track->timescale > UINT16_MAX) {

@ -1,4 +1,4 @@
4529713e8b744edb3e62c4e688a3f987 *./tests/data/acodec/pcm_s16be.mov
1059065 ./tests/data/acodec/pcm_s16be.mov
96079f7b65fdbe991e69bb96a3188217 *./tests/data/acodec/pcm_s16be.mov
1059029 ./tests/data/acodec/pcm_s16be.mov
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s16be.acodec.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400

@ -1,4 +1,4 @@
8a7b79317738f91a137c7f6519c3df72 *./tests/data/acodec/pcm_s24be.mov
1588265 ./tests/data/acodec/pcm_s24be.mov
74465b486afddaf802300cdbf3b59a11 *./tests/data/acodec/pcm_s24be.mov
1588229 ./tests/data/acodec/pcm_s24be.mov
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s24be.acodec.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400

@ -1,4 +1,4 @@
c9f29c97890f69796faa227c3c08c3d8 *./tests/data/acodec/pcm_s32be.mov
2117465 ./tests/data/acodec/pcm_s32be.mov
ac3822c11273a25005dfd6aa64b255df *./tests/data/acodec/pcm_s32be.mov
2117429 ./tests/data/acodec/pcm_s32be.mov
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s32be.acodec.out.wav
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400

@ -1,4 +1,4 @@
bfd442109b661daf8ee7a468d9d6b944 *./tests/data/acodec/pcm_s8.mov
529865 ./tests/data/acodec/pcm_s8.mov
111d465266385298fde83005402ac171 *./tests/data/acodec/pcm_s8.mov
529829 ./tests/data/acodec/pcm_s8.mov
651d4eb8d98dfcdda96ae6c43d8f156b *./tests/data/pcm_s8.acodec.out.wav
stddev: 147.89 PSNR: 52.93 MAXDIFF: 255 bytes: 1058400/ 1058400

@ -1,3 +1,3 @@
37c9c1272d9c524b44692e9192d82033 *./tests/data/lavf/lavf.mov
357857 ./tests/data/lavf/lavf.mov
9a0b239ff596da58debcf210dece3985 *./tests/data/lavf/lavf.mov
357821 ./tests/data/lavf/lavf.mov
./tests/data/lavf/lavf.mov CRC=0x2f6a9b26

Loading…
Cancel
Save