2014-10-02 19:39 GMT+09:00 Benoit Fouet <benoit.fo...@free.fr>: > Fixes ticket #3074 > --- > libavformat/isom.c | 1 + > libavformat/movenc.c | 44 +++++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 44 insertions(+), 1 deletion(-) > > diff --git a/libavformat/isom.c b/libavformat/isom.c > index d768c32..1509021 100644 > --- a/libavformat/isom.c > +++ b/libavformat/isom.c > @@ -57,6 +57,7 @@ const AVCodecTag ff_mp4_obj_type[] = { > { AV_CODEC_ID_VC1 , 0xA3 }, > { AV_CODEC_ID_DIRAC , 0xA4 }, > { AV_CODEC_ID_AC3 , 0xA5 }, > + { AV_CODEC_ID_EAC3 , 0xA6 }, > { AV_CODEC_ID_DTS , 0xA9 }, /* mp4ra.org */ > { AV_CODEC_ID_VORBIS , 0xDD }, /* non standard, gpac uses it */ > { AV_CODEC_ID_DVD_SUBTITLE, 0xE0 }, /* non standard, see > unsupported-embedded-subs-2.mp4 */ > diff --git a/libavformat/movenc.c b/libavformat/movenc.c > index bfee866..62b2d4b 100644 > --- a/libavformat/movenc.c > +++ b/libavformat/movenc.c > @@ -31,6 +31,7 @@ > #include "avio.h" > #include "isom.h" > #include "avc.h" > +#include "libavcodec/ac3_parser.h" > #include "libavcodec/get_bits.h" > #include "libavcodec/put_bits.h" > #include "libavcodec/vc1_common.h" > @@ -292,6 +293,40 @@ static int mov_write_ac3_tag(AVIOContext *pb, > MOVTrack *track) > return 11; > } > > +static int mov_write_eac3_tag(AVIOContext *pb, MOVTrack *track) > +{ > + GetBitContext gbc; > + PutBitContext pbc; > + uint8_t buf[5]; > + AC3HeaderInfo tmp, *hdr = &tmp; > + > + if (!track->vos_len) > + return -1; > + > + init_get_bits(&gbc, track->vos_data, track->vos_len * 8); > + if (avpriv_ac3_parse_header2(&gbc, &hdr) != 0) > + return -1; > + > + avio_wb32(pb, 13); > + ffio_wfourcc(pb, "dec3"); > + > + init_put_bits(&pbc, buf, sizeof(buf)); > + put_bits(&pbc, 13, hdr->bit_rate); > + put_bits(&pbc, 3, 0); /* consider there is only one independent > substream present */ > + put_bits(&pbc, 2, hdr->sr_code); > + put_bits(&pbc, 5, hdr->bitstream_id); > + put_bits(&pbc, 5, hdr->bitstream_mode); > + put_bits(&pbc, 3, hdr->channel_mode); > + put_bits(&pbc, 1, hdr->lfe_on); > + put_bits(&pbc, 5, 0); /* reserved */ > + put_bits(&pbc, 4, 0); /* no dependent substream */ > + put_bits(&pbc, 1, 0); /* reserved */ > + flush_put_bits(&pbc); > + avio_write(pb, buf, sizeof(buf)); > + > + return 13; > +} > + > /** > * This function writes extradata "as is". > * Extradata must be formatted like a valid atom (with size and tag). > @@ -486,6 +521,8 @@ static int mov_write_wave_tag(AVIOContext *pb, > MOVTrack *track) > mov_write_amr_tag(pb, track); > } else if (track->enc->codec_id == AV_CODEC_ID_AC3) { > mov_write_ac3_tag(pb, track); > + } else if (track->enc->codec_id == AV_CODEC_ID_EAC3) { > + mov_write_eac3_tag(pb, track); > } else if (track->enc->codec_id == AV_CODEC_ID_ALAC || > track->enc->codec_id == AV_CODEC_ID_QDM2) { > mov_write_extradata_tag(pb, track); > @@ -756,6 +793,7 @@ static int mov_write_audio_tag(AVIOContext *pb, > MOVTrack *track) > if (track->mode == MODE_MOV && > (track->enc->codec_id == AV_CODEC_ID_AAC || > track->enc->codec_id == AV_CODEC_ID_AC3 || > + track->enc->codec_id == AV_CODEC_ID_EAC3 || > track->enc->codec_id == AV_CODEC_ID_AMR_NB || > track->enc->codec_id == AV_CODEC_ID_ALAC || > track->enc->codec_id == AV_CODEC_ID_ADPCM_MS || > @@ -770,6 +808,8 @@ static int mov_write_audio_tag(AVIOContext *pb, > MOVTrack *track) > mov_write_amr_tag(pb, track); > else if (track->enc->codec_id == AV_CODEC_ID_AC3) > mov_write_ac3_tag(pb, track); > + else if (track->enc->codec_id == AV_CODEC_ID_EAC3) > + mov_write_eac3_tag(pb, track); > else if (track->enc->codec_id == AV_CODEC_ID_ALAC) > mov_write_extradata_tag(pb, track); > else if (track->enc->codec_id == AV_CODEC_ID_WMAPRO) > @@ -877,6 +917,7 @@ static int mp4_get_codec_tag(AVFormatContext *s, > MOVTrack *track) > if (track->enc->codec_id == AV_CODEC_ID_H264) tag = > MKTAG('a','v','c','1'); > else if (track->enc->codec_id == AV_CODEC_ID_HEVC) tag = > MKTAG('h','e','v','1'); > else if (track->enc->codec_id == AV_CODEC_ID_AC3) tag = > MKTAG('a','c','-','3'); > + else if (track->enc->codec_id == AV_CODEC_ID_EAC3) tag = > MKTAG('e','c','-','3'); > else if (track->enc->codec_id == AV_CODEC_ID_DIRAC) tag = > MKTAG('d','r','a','c'); > else if (track->enc->codec_id == AV_CODEC_ID_MOV_TEXT) tag = > MKTAG('t','x','3','g'); > else if (track->enc->codec_id == AV_CODEC_ID_VC1) tag = > MKTAG('v','c','-','1'); > @@ -3605,7 +3646,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket > *pkt) > } > > if ((enc->codec_id == AV_CODEC_ID_DNXHD || > - enc->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) { > + enc->codec_id == AV_CODEC_ID_AC3 || > + enc->codec_id == AV_CODEC_ID_EAC3) && !trk->vos_len) { > /* copy frame to create needed atoms */ > trk->vos_len = size; > trk->vos_data = av_malloc(size); > -- > 2.1.0.127.g0c72b98 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
Sorry, multiple and consecutive posts. But I found another issue in this patch. This patch does not pack syncframes into a sample in order to pack 6 blocks. The spec requires a sample consists of 6 blocks to make samle_delta in stts equal to 1536. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel