mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-13 02:20:07 +01:00
Merge remote-tracking branch 'qatar/master'
* qatar/master: isom: sort and pretty-print codec_movaudio_tags[] isom: remove pointless comments in codec_movaudio_tags[] isom: remove commented-out tag for vorbis movenc: write 'chan' tag for AC-3 in MOV mov: add support for reading and writing the 'chan' tag audioconvert: add some additional channel and channel layout macros audioconvert: change 7.1 "wide" layout to use side surround channels movenc: simplify handling of pcm vs. adpcm vs. other compressed codecs doc: update documentation to use avconv doc: update demuxers section doc: extend external library coverage doc: split platform specific information doc: port the git-howto to texinfo doc: provide fallback css and customize @float doc: document fate in a texinfo doxy: change hue value to match our green Conflicts: doc/fate.txt doc/ffserver.texi doc/general.texi doc/muxers.texi doc/protocols.texi doc/t2h.init libavformat/isom.c libavformat/mov.c libavutil/avutil.h tests/ref/acodec/pcm_s16be tests/ref/acodec/pcm_s24be tests/ref/acodec/pcm_s32be tests/ref/acodec/pcm_s8 tests/ref/lavf/mov Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "libavutil/opt.h"
|
||||
#include "libavutil/dict.h"
|
||||
#include "rtpenc.h"
|
||||
#include "mov_chan.h"
|
||||
|
||||
#undef NDEBUG
|
||||
#include <assert.h>
|
||||
@@ -354,6 +355,31 @@ static int mov_write_ms_tag(AVIOContext *pb, MOVTrack *track)
|
||||
return updateSize(pb, pos);
|
||||
}
|
||||
|
||||
static int mov_write_chan_tag(AVIOContext *pb, MOVTrack *track)
|
||||
{
|
||||
uint32_t layout_tag, bitmap;
|
||||
int64_t pos = avio_tell(pb);
|
||||
|
||||
layout_tag = ff_mov_get_channel_layout_tag(track->enc->codec_id,
|
||||
track->enc->channel_layout,
|
||||
&bitmap);
|
||||
if (!layout_tag) {
|
||||
av_log(track->enc, AV_LOG_WARNING, "not writing 'chan' tag due to "
|
||||
"lack of channel information\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
avio_wb32(pb, 0); // Size
|
||||
ffio_wfourcc(pb, "chan"); // Type
|
||||
avio_w8(pb, 0); // Version
|
||||
avio_wb24(pb, 0); // Flags
|
||||
avio_wb32(pb, layout_tag); // mChannelLayoutTag
|
||||
avio_wb32(pb, bitmap); // mChannelBitmap
|
||||
avio_wb32(pb, 0); // mNumberChannelDescriptions
|
||||
|
||||
return updateSize(pb, pos);
|
||||
}
|
||||
|
||||
static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
|
||||
{
|
||||
int64_t pos = avio_tell(pb);
|
||||
@@ -376,6 +402,7 @@ static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
|
||||
} else if (track->enc->codec_id == CODEC_ID_AMR_NB) {
|
||||
mov_write_amr_tag(pb, track);
|
||||
} else if (track->enc->codec_id == CODEC_ID_AC3) {
|
||||
mov_write_chan_tag(pb, track);
|
||||
mov_write_ac3_tag(pb, track);
|
||||
} else if (track->enc->codec_id == CODEC_ID_ALAC) {
|
||||
mov_write_extradata_tag(pb, track);
|
||||
@@ -434,15 +461,9 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
|
||||
uint32_t tag = track->tag;
|
||||
|
||||
if (track->mode == MODE_MOV) {
|
||||
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;
|
||||
}
|
||||
if (mov_get_lpcm_flags(track->enc->codec_id))
|
||||
tag = AV_RL32("lpcm");
|
||||
version = 2;
|
||||
}
|
||||
|
||||
avio_wb32(pb, 0); /* size */
|
||||
@@ -469,34 +490,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, mov_get_lpcm_flags(track->enc->codec_id));
|
||||
avio_wb32(pb, track->sampleSize);
|
||||
avio_wb32(pb, track->enc->frame_size);
|
||||
avio_wb32(pb, track->audio_vbr ? track->enc->frame_size : 1);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
/* 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 ||
|
||||
@@ -2226,9 +2231,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");
|
||||
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
|
||||
@@ -2458,21 +2460,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;
|
||||
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){
|
||||
/* set sampleSize for PCM and ADPCM */
|
||||
if (av_get_bits_per_sample(st->codec->codec_id)) {
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}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) {
|
||||
|
||||
Reference in New Issue
Block a user