[FFmpeg-devel] [PATCH v2 2/7] avformat/apm: prepare extradata handling for muxer

Zane van Iperen zane at zanevaniperen.com
Thu Jun 11 09:37:11 EEST 2020


On Thu, 11 Jun 2020 04:12:46 +0200
"Andreas Rheinhardt" <andreas.rheinhardt at gmail.com> wrote:

> So in this and the next patch you change the format of the extradata.
> This patch here breaks fate (every patch of a patchset is supposed to
> pass fate, not only the last one) which is unacceptable.

It's fixed immediately in the next patch. Wanted to keep the
avcodec/avformat changes separate. Is a moot point anyway.

> But there is
> a more serious problem: Updating the extradata stuff affects more
> than one library, namely libavcodec and libavformat. And it is
> allowed to update libavcodec alone (as long as the major version
> doesn't change) without updating libavformat. So one could come into
> a situation where one uses a libavformat exporting the old extradata
> format and libavcodec only accepting the new one. A solution for this
> would be to accept both formats in libavcodec (they can easily be
> distinguished by the extradata size). The patch for libavcodec would
> have to go in first. That way fate wouldn't need any update.

This is a *very* fringe format, so risk of breakage is virtually none,
but I see the point regardless. Have changed it to this:

if (avctx->extradata) {
    if (avctx->extradata_size >= 28) {
        /* new */
    } else if (avctx->extradata_size >= 16) {
        /* old */
    }
}

> 
> Furthermore, why are you parsing (i.e. copying around) the unk1-3 (I
> guess it means "unknown"?) when you don't use it at all?

Honestly, just so there's some documentation of the format somewhere.
I'd be happy to remove them from apm_parse_extradata(), but I'd like to
keep them in the struct, just to show the layout.

> And given
> that you now simply use the extradata as it has been read, it might
> be better to use ff_get_extradata directly.
> 

There's actually two "extradata"s here. The "file" extradata, and the
"codec" extradata.

The "file" extradata is the extradata field of the WAVEFORMATEX (the
APMExtraData structure). This contains info which is obviously not
meant/useful for the codec.

A subsection of this is the APMState structure, which is what I give to
the codec.

I didn't use ff_get_extradata() beacuse I don't want to give the entire
APMExtraData structure to the codec. As I use fields both before and
after the APMState, I thought it better to read the entire thing, then
memcpy() out the needed subsection.


And from your other email:

> > +    case AV_CODEC_ID_ADPCM_IMA_APM:
> > +        avctx->frame_size = BLKSIZE * 2 / avctx->channels;
> > +        avctx->block_align = BLKSIZE;
> > +
> > +        if (!(avctx->extradata = av_mallocz(28)))  
> 
> Missing padding. And zero-initializing the extradata is really enough?

Have added the padding. And yep, it's the APMState structure, so zero'd
everything is fine.






More information about the ffmpeg-devel mailing list