avcodec/textdec: Deduplicate AVClasses

The child_class_next API relied on different AVCodecs to use
different AVClasses; yet this API has been replaced by
child_class_iterate.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2021-06-07 16:13:33 +02:00
parent d46de6d4bc
commit f067795c74
1 changed files with 11 additions and 26 deletions

View File

@ -71,17 +71,14 @@ static void text_flush(AVCodecContext *avctx)
text->readorder = 0; text->readorder = 0;
} }
#define DECLARE_CLASS(decname) static const AVClass decname ## _decoder_class = { \ static const AVClass textsub_decoder_class = {
.class_name = #decname " decoder", \ .class_name = "text/vplayer/stl/pjs/subviewer1 decoder",
.item_name = av_default_item_name, \ .item_name = av_default_item_name,
.option = decname ## _options, \ .option = options,
.version = LIBAVUTIL_VERSION_INT, \ .version = LIBAVUTIL_VERSION_INT,
} };
#if CONFIG_TEXT_DECODER #if CONFIG_TEXT_DECODER
#define text_options options
DECLARE_CLASS(text);
const AVCodec ff_text_decoder = { const AVCodec ff_text_decoder = {
.name = "text", .name = "text",
.long_name = NULL_IF_CONFIG_SMALL("Raw text subtitle"), .long_name = NULL_IF_CONFIG_SMALL("Raw text subtitle"),
@ -90,7 +87,7 @@ const AVCodec ff_text_decoder = {
.id = AV_CODEC_ID_TEXT, .id = AV_CODEC_ID_TEXT,
.decode = text_decode_frame, .decode = text_decode_frame,
.init = ff_ass_subtitle_header_default, .init = ff_ass_subtitle_header_default,
.priv_class = &text_decoder_class, .priv_class = &textsub_decoder_class,
.flush = text_flush, .flush = text_flush,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}; };
@ -106,9 +103,6 @@ static int linebreak_init(AVCodecContext *avctx)
} }
#if CONFIG_VPLAYER_DECODER #if CONFIG_VPLAYER_DECODER
#define vplayer_options options
DECLARE_CLASS(vplayer);
const AVCodec ff_vplayer_decoder = { const AVCodec ff_vplayer_decoder = {
.name = "vplayer", .name = "vplayer",
.long_name = NULL_IF_CONFIG_SMALL("VPlayer subtitle"), .long_name = NULL_IF_CONFIG_SMALL("VPlayer subtitle"),
@ -117,16 +111,13 @@ const AVCodec ff_vplayer_decoder = {
.id = AV_CODEC_ID_VPLAYER, .id = AV_CODEC_ID_VPLAYER,
.decode = text_decode_frame, .decode = text_decode_frame,
.init = linebreak_init, .init = linebreak_init,
.priv_class = &vplayer_decoder_class, .priv_class = &textsub_decoder_class,
.flush = text_flush, .flush = text_flush,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}; };
#endif #endif
#if CONFIG_STL_DECODER #if CONFIG_STL_DECODER
#define stl_options options
DECLARE_CLASS(stl);
const AVCodec ff_stl_decoder = { const AVCodec ff_stl_decoder = {
.name = "stl", .name = "stl",
.long_name = NULL_IF_CONFIG_SMALL("Spruce subtitle format"), .long_name = NULL_IF_CONFIG_SMALL("Spruce subtitle format"),
@ -135,16 +126,13 @@ const AVCodec ff_stl_decoder = {
.id = AV_CODEC_ID_STL, .id = AV_CODEC_ID_STL,
.decode = text_decode_frame, .decode = text_decode_frame,
.init = linebreak_init, .init = linebreak_init,
.priv_class = &stl_decoder_class, .priv_class = &textsub_decoder_class,
.flush = text_flush, .flush = text_flush,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}; };
#endif #endif
#if CONFIG_PJS_DECODER #if CONFIG_PJS_DECODER
#define pjs_options options
DECLARE_CLASS(pjs);
const AVCodec ff_pjs_decoder = { const AVCodec ff_pjs_decoder = {
.name = "pjs", .name = "pjs",
.long_name = NULL_IF_CONFIG_SMALL("PJS subtitle"), .long_name = NULL_IF_CONFIG_SMALL("PJS subtitle"),
@ -153,16 +141,13 @@ const AVCodec ff_pjs_decoder = {
.id = AV_CODEC_ID_PJS, .id = AV_CODEC_ID_PJS,
.decode = text_decode_frame, .decode = text_decode_frame,
.init = linebreak_init, .init = linebreak_init,
.priv_class = &pjs_decoder_class, .priv_class = &textsub_decoder_class,
.flush = text_flush, .flush = text_flush,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}; };
#endif #endif
#if CONFIG_SUBVIEWER1_DECODER #if CONFIG_SUBVIEWER1_DECODER
#define subviewer1_options options
DECLARE_CLASS(subviewer1);
const AVCodec ff_subviewer1_decoder = { const AVCodec ff_subviewer1_decoder = {
.name = "subviewer1", .name = "subviewer1",
.long_name = NULL_IF_CONFIG_SMALL("SubViewer1 subtitle"), .long_name = NULL_IF_CONFIG_SMALL("SubViewer1 subtitle"),
@ -171,7 +156,7 @@ const AVCodec ff_subviewer1_decoder = {
.id = AV_CODEC_ID_SUBVIEWER1, .id = AV_CODEC_ID_SUBVIEWER1,
.decode = text_decode_frame, .decode = text_decode_frame,
.init = linebreak_init, .init = linebreak_init,
.priv_class = &subviewer1_decoder_class, .priv_class = &textsub_decoder_class,
.flush = text_flush, .flush = text_flush,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
}; };