mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-24 19:59:46 +00:00
movenc: simplify handling of pcm vs. adpcm vs. other compressed codecs
Use Sound Sample Description Version 2 for all MOV files. Updated FATE references accordingly. Note that ADPCM is treated as compressed audio in version 2.
This commit is contained in:
parent
d5837d7fe9
commit
8e8c51318c
@ -418,15 +418,9 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
|
|||||||
uint32_t tag = track->tag;
|
uint32_t tag = track->tag;
|
||||||
|
|
||||||
if (track->mode == MODE_MOV) {
|
if (track->mode == MODE_MOV) {
|
||||||
if (track->timescale > UINT16_MAX) {
|
if (mov_get_lpcm_flags(track->enc->codec_id))
|
||||||
if (mov_get_lpcm_flags(track->enc->codec_id))
|
tag = AV_RL32("lpcm");
|
||||||
tag = AV_RL32("lpcm");
|
version = 2;
|
||||||
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 */
|
avio_wb32(pb, 0); /* size */
|
||||||
@ -453,34 +447,18 @@ 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, av_get_bits_per_sample(track->enc->codec_id));
|
||||||
avio_wb32(pb, mov_get_lpcm_flags(track->enc->codec_id));
|
avio_wb32(pb, mov_get_lpcm_flags(track->enc->codec_id));
|
||||||
avio_wb32(pb, track->sampleSize);
|
avio_wb32(pb, track->sampleSize);
|
||||||
avio_wb32(pb, track->enc->frame_size);
|
avio_wb32(pb, track->audio_vbr ? track->enc->frame_size : 1);
|
||||||
} else {
|
} else {
|
||||||
if (track->mode == MODE_MOV) {
|
/* reserved for mp4/3gp */
|
||||||
avio_wb16(pb, track->enc->channels);
|
avio_wb16(pb, 2);
|
||||||
if (track->enc->codec_id == CODEC_ID_PCM_U8 ||
|
avio_wb16(pb, 16);
|
||||||
track->enc->codec_id == CODEC_ID_PCM_S8)
|
avio_wb16(pb, 0);
|
||||||
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, 0); /* packet size (= 0) */
|
||||||
avio_wb16(pb, track->timescale); /* Time scale */
|
avio_wb16(pb, track->timescale); /* Time scale */
|
||||||
avio_wb16(pb, 0); /* Reserved */
|
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 &&
|
if(track->mode == MODE_MOV &&
|
||||||
(track->enc->codec_id == CODEC_ID_AAC ||
|
(track->enc->codec_id == CODEC_ID_AAC ||
|
||||||
track->enc->codec_id == CODEC_ID_AC3 ||
|
track->enc->codec_id == CODEC_ID_AC3 ||
|
||||||
@ -2015,9 +1993,6 @@ 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");
|
av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n");
|
||||||
return -1;
|
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)
|
} else if (trk->sampleSize)
|
||||||
samplesInChunk = size/trk->sampleSize;
|
samplesInChunk = size/trk->sampleSize;
|
||||||
else
|
else
|
||||||
@ -2224,21 +2199,21 @@ static int mov_write_header(AVFormatContext *s)
|
|||||||
"or choose different container.\n");
|
"or choose different container.\n");
|
||||||
}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
|
}else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
|
||||||
track->timescale = st->codec->sample_rate;
|
track->timescale = st->codec->sample_rate;
|
||||||
if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
|
/* set sampleSize for PCM and ADPCM */
|
||||||
av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i);
|
if (av_get_bits_per_sample(st->codec->codec_id)) {
|
||||||
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) {
|
if (!st->codec->block_align) {
|
||||||
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i);
|
av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set\n", i);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
track->sampleSize = st->codec->block_align;
|
track->sampleSize = st->codec->block_align;
|
||||||
}else if(st->codec->frame_size > 1){ /* assume compressed audio */
|
}
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
track->audio_vbr = 1;
|
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->mode != MODE_MOV) {
|
||||||
if (track->timescale > UINT16_MAX) {
|
if (track->timescale > UINT16_MAX) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
a4e18d1ca9ef5b8132a84d43625ddc47 *./tests/data/acodec/pcm_s16be.mov
|
dd832e23156643becce8e9d2c24cb31d *./tests/data/acodec/pcm_s16be.mov
|
||||||
1060037 ./tests/data/acodec/pcm_s16be.mov
|
1060073 ./tests/data/acodec/pcm_s16be.mov
|
||||||
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s16be.acodec.out.wav
|
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s16be.acodec.out.wav
|
||||||
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
|
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
971d2d2633e41a0326fe2d04a2d0350f *./tests/data/acodec/pcm_s24be.mov
|
1b570c296bce03e36e1dfb369190ffb6 *./tests/data/acodec/pcm_s24be.mov
|
||||||
1589237 ./tests/data/acodec/pcm_s24be.mov
|
1589273 ./tests/data/acodec/pcm_s24be.mov
|
||||||
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s24be.acodec.out.wav
|
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s24be.acodec.out.wav
|
||||||
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
|
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
fc4f4e3e195bbde037ed31021d229f12 *./tests/data/acodec/pcm_s32be.mov
|
249c2ca88e2d8cdaed345e3d446e5bc3 *./tests/data/acodec/pcm_s32be.mov
|
||||||
2118437 ./tests/data/acodec/pcm_s32be.mov
|
2118473 ./tests/data/acodec/pcm_s32be.mov
|
||||||
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s32be.acodec.out.wav
|
64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/pcm_s32be.acodec.out.wav
|
||||||
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
|
stddev: 0.00 PSNR:999.99 MAXDIFF: 0 bytes: 1058400/ 1058400
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
760f85fb9f4e8aba326fb44ae84c9507 *./tests/data/acodec/pcm_s8.mov
|
f467f8899b2bd11c736d0f4e61efb1c4 *./tests/data/acodec/pcm_s8.mov
|
||||||
530837 ./tests/data/acodec/pcm_s8.mov
|
530873 ./tests/data/acodec/pcm_s8.mov
|
||||||
651d4eb8d98dfcdda96ae6c43d8f156b *./tests/data/pcm_s8.acodec.out.wav
|
651d4eb8d98dfcdda96ae6c43d8f156b *./tests/data/pcm_s8.acodec.out.wav
|
||||||
stddev: 147.89 PSNR: 52.93 MAXDIFF: 255 bytes: 1058400/ 1058400
|
stddev: 147.89 PSNR: 52.93 MAXDIFF: 255 bytes: 1058400/ 1058400
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
4a3ad13f0355cb5d119109778d555207 *./tests/data/lavf/lavf.mov
|
8dc82a08a0abb47c822d03a6e408383b *./tests/data/lavf/lavf.mov
|
||||||
357681 ./tests/data/lavf/lavf.mov
|
357717 ./tests/data/lavf/lavf.mov
|
||||||
./tests/data/lavf/lavf.mov CRC=0x2f6a9b26
|
./tests/data/lavf/lavf.mov CRC=0x2f6a9b26
|
||||||
|
Loading…
Reference in New Issue
Block a user