[FFmpeg-devel] How to satisfy two codecs with one decoder?

James Almer jamrial at gmail.com
Sat Apr 18 01:53:38 EEST 2020


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.
> 
> -Roger-
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> 



More information about the ffmpeg-devel mailing list