summaryrefslogtreecommitdiffstats
path: root/sub/sd_lavc.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-27 02:07:01 +0100
committerwm4 <wm4@nowhere>2015-12-27 02:13:06 +0100
commitd85753b79e4ce0fa7a5ddac5b2ed0cf65f7aecd8 (patch)
tree4c4844981e89c7ad056d0e52335b2d963e37d44b /sub/sd_lavc.c
parent50c379e2d8a2cee0fcdbadbcbf5d0a0617fdafec (diff)
downloadmpv-d85753b79e4ce0fa7a5ddac5b2ed0cf65f7aecd8.tar.bz2
mpv-d85753b79e4ce0fa7a5ddac5b2ed0cf65f7aecd8.tar.xz
sub: refactor initialization
Just simplify by removing parts not needed anymore. This includes merging dec_sub allocation and initialization (since things making initialization complicated were removed), or format support queries (it simply tries to create a decoder, and if that fails, tries the next one).
Diffstat (limited to 'sub/sd_lavc.c')
-rw-r--r--sub/sd_lavc.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/sub/sd_lavc.c b/sub/sd_lavc.c
index 86aaf4fda9..d9b9f507e7 100644
--- a/sub/sd_lavc.c
+++ b/sub/sd_lavc.c
@@ -64,21 +64,6 @@ struct sd_lavc_priv {
int num_seekpoints;
};
-static bool supports_format(const char *format)
-{
- enum AVCodecID cid = mp_codec_to_av_codec_id(format);
- // Supported codecs must be known to decode to paletted bitmaps
- switch (cid) {
- case AV_CODEC_ID_DVB_SUBTITLE:
- case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
- case AV_CODEC_ID_XSUB:
- case AV_CODEC_ID_DVD_SUBTITLE:
- return true;
- default:
- return false;
- }
-}
-
static void get_resolution(struct sd *sd, int wh[2])
{
struct sd_lavc_priv *priv = sd->priv;
@@ -110,8 +95,20 @@ static void get_resolution(struct sd *sd, int wh[2])
static int init(struct sd *sd)
{
- struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_priv);
enum AVCodecID cid = mp_codec_to_av_codec_id(sd->sh->codec);
+
+ // Supported codecs must be known to decode to paletted bitmaps
+ switch (cid) {
+ case AV_CODEC_ID_DVB_SUBTITLE:
+ case AV_CODEC_ID_HDMV_PGS_SUBTITLE:
+ case AV_CODEC_ID_XSUB:
+ case AV_CODEC_ID_DVD_SUBTITLE:
+ break;
+ default:
+ return -1;
+ }
+
+ struct sd_lavc_priv *priv = talloc_zero(NULL, struct sd_lavc_priv);
AVCodecContext *ctx = NULL;
AVCodec *sub_codec = avcodec_find_decoder(cid);
if (!sub_codec)
@@ -467,7 +464,6 @@ static int control(struct sd *sd, enum sd_ctrl cmd, void *arg)
const struct sd_functions sd_lavc = {
.name = "lavc",
- .supports_format = supports_format,
.init = init,
.decode = decode,
.get_bitmaps = get_bitmaps,