[FFmpeg-devel] [PATCH] avformat/movenc: add EAC3 muxing support.
Michael Niedermayer
michaelni at gmx.at
Fri Oct 10 12:53:45 CEST 2014
On Fri, Oct 10, 2014 at 10:28:51AM +0200, Benoit Fouet wrote:
> Hi,
>
> ----- Mail original -----
> > Hi,
> >
> > ----- Mail original -----
> > > 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/movenc.c b/libavformat/movenc.c
> > > > index bfee866..18c5955 100644
> > > > --- a/libavformat/movenc.c
> > > > +++ b/libavformat/movenc.c
> >
> > [...]
> >
> > > > @@ -292,6 +293,178 @@ static int mov_write_ac3_tag(AVIOContext
> > > > *pb,
> > > > MOVTrack *track)
> >
> > [...]
> >
> > > > +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
> > >
> >
> > True.
> >
> > > 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 true, though I'm not sure how to handle this. Dropping the
> > packet would presumably be a way of dealing with this.
> > Please note that the E-AC-3 stream passes through the E-AC-3 parser
> > before muxing, so these errors shouldn't really happen in practice,
> > except for the first frame (or maybe I missed something in the way
> > the parser works?).
> > A solution here could be to drop the packet if it is the first one,
> > and error out if not (with an AV_ error code), what do you think?
> >
> > > also how can this patch be tested ?
> > > carls testcase from the ticket does not seem to work
> > >
> >
> > If we drop the erroneous packet instead of erroring out, the testcase
> > works fine.
> >
>
> New patch attached, as reference.
>
> --
> Ben
> isom.c | 1
> movenc.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> movenc.h | 2
> 3 files changed, 191 insertions(+)
> 14e19b18c41710cc7a79c0c94e6f180d3c97dd69 0001-avformat-movenc-add-EAC3-muxing-support.patch
> From 067c95cdab127612019a50c3f6c8485a132cac18 Mon Sep 17 00:00:00 2001
> From: Benoit Fouet <benoit.fouet at free.fr>
> Date: Tue, 7 Oct 2014 14:57:19 +0200
> Subject: [PATCH] avformat/movenc: add EAC3 muxing support.
>
> Support only one independent substream right now, and only syncframes
> containing 6 blocks.
>
> Fixes part of ticket #3074
> ---
> libavformat/isom.c | 1 +
> libavformat/movenc.c | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++
> libavformat/movenc.h | 2 +
> 3 files changed, 191 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..f592c9c 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,182 @@ 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;
[...]
> + info->data_rate = FFMAX(info->data_rate, hdr->bit_rate);
[...]
> + put_bits(&pbc, 13, info->data_rate);
something is wrong here, a bit_rate of 128000 (128k) wont fit in a
uint16_t nor in 13 bits
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141010/ad320a2e/attachment.asc>
More information about the ffmpeg-devel
mailing list