[FFmpeg-devel] How to satisfy two codecs with one decoder?
Roger Pack
rogerdpack2 at gmail.com
Tue Apr 28 09:32:00 EEST 2020
On Fri, Apr 17, 2020 at 4:53 PM James Almer <jamrial at gmail.com> wrote:
>
> On 4/17/2020 7:40 PM, Roger Pack wrote:
> > I want to add to the closed caption libavcodec/ccaption_dec.c decoder
> > to be able to handle both 608 "over CEA 708" (which it already does)
> > and also "raw EIA 608 byte pairs" which it doesn't.
> >
> > My idea was to introduce a new codec id for the raw 608 pairs.
> > AV_CODEC_ID_EIA_RAW_608 or the like.
> >
> > The decoding shares a lot of functionality.
> >
> > Currently the decoder code is set up like this:
> >
> > AVCodec ff_ccaption_decoder = {
> > .name = "cc_dec",
> > .long_name = NULL_IF_CONFIG_SMALL("Closed Caption (EIA-608 / CEA-708)"),
> > .type = AVMEDIA_TYPE_SUBTITLE,
> > .id = AV_CODEC_ID_EIA_608,
> > ...
> >
> > I was hoping to "add" another codec like AV_CODEC_ID_EIA_RAW_608 and
> > having this decoder be able to decode both types.
> >
> > I was anticipating being able to define some kind of "query" method so
> > it would check if the requested codec id was "either
> > AV_CODEC_ID_EIA_608 or AV_CODEC_ID_EIA_RAW_608" and accept decoding
> > either codec.
> >
> > Is there a way for a codec to decode two id's like this?
> > If not any recommendations on how to best handle this?
>
> Usually, you set up two decoders that both reference the same functions
> (or most of them). In the case of shared function, they would then
> execute a different codepath depending on codec_id as required.
>
> See mpeg12dec.c and how both the mpeg1 and mpeg2 AVCodec entries are
> essentially the same for an example. Or the nvenc encoders.
Thanks that did it, those are good examples. One thing I did notice
is if two decoders use the same ".priv_class" then it causes an
infinite loop trying to find the next decoder to search for
parameters. But one past that, all is well...
Thanks!
-roger-
More information about the ffmpeg-devel
mailing list