On Tue, Oct 07, 2014 at 03:02:38PM +0200, Benoit Fouet wrote: > Support only one independent substream right now, and only syncframes > containing 6 blocks. > > Fixes part of ticket #3074 > --- > > Right now, this produces the same output as the previous patch for supported > streams, and rejects the unsupported ones. > Support for syncframes concatenation will come afterwards. > > libavformat/isom.c | 1 + > libavformat/movenc.c | 184 > +++++++++++++++++++++++++++++++++++++++++++++++++++ > libavformat/movenc.h | 2 + > 3 files changed, 187 insertions(+) > > 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..18c5955 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,178 @@ static int mov_write_ac3_tag(AVIOContext *pb, MOVTrack > *track) > return 11; > } > > +struct eac3_info { > + uint8_t ec3_done; > + > + /* Layout of the EC3SpecificBox */ > + /* maximum bitrate */ > + uint16_t data_rate; > + /* number of independent substreams */ > + uint8_t num_ind_sub; > + struct { > + /* sample rate code (see ff_ac3_sample_rate_tab) 2 bits */ > + uint8_t fscod; > + /* bit stream identification 5 bits */ > + uint8_t bsid; > + /* one bit reserved */ > + /* audio service mixing (not supported yet) 1 bit */ > + /* bit stream mode 3 bits */ > + uint8_t bsmod; > + /* audio coding mode 3 bits */ > + uint8_t acmod; > + /* sub woofer on 1 bit */ > + uint8_t lfeon; > + /* 3 bits reserved */ > + /* number of dependent substreams associated with this substream 4 > bits */ > + uint8_t num_dep_sub; > + /* channel locations of the dependent substream(s), if any, 9 bits */ > + uint16_t chan_loc; > + /* if there is no dependent substream, then one bit reserved instead > */ > + } substream[1]; /* TODO: support 8 independent substreams */ > +}; > + > +static int handle_eac3(AVPacket *pkt, MOVTrack *track) > +{ > + GetBitContext gbc; > + AC3HeaderInfo tmp, *hdr = &tmp; > + struct eac3_info *info; > + int ret, num_blocks; > + > + if (!track->eac3_priv && !(track->eac3_priv = av_mallocz(sizeof(*info)))) > + return AVERROR(ENOMEM); > + info = track->eac3_priv; > +
> + init_get_bits(&gbc, pkt->data, pkt->size * 8); > + if ((ret = avpriv_ac3_parse_header2(&gbc, &hdr)) < 0) > + return ret; [...] > + if ((ret = avpriv_ac3_parse_header2(&gbc, &hdr)) < 0) > + return ret; these forward internal error codes like AAC_AC3_PARSE_ERROR_FRAME_TYPE to the lib user av_strerror() for example will not be able to interpret these also this would prevent remuxing a stream that contains a single damaged packet if i understand correctly, this may be annoying for sources recoded over somewhat noisy channels also how can this patch be tested ? carls testcase from the ticket does not seem to work [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel