diff options
author | Martin Herkt <lachs0r@srsfckn.biz> | 2016-12-25 13:28:05 +0100 |
---|---|---|
committer | Martin Herkt <lachs0r@srsfckn.biz> | 2016-12-25 13:28:05 +0100 |
commit | b3d670a3e1ee9c60be33b6e5fafdf3b6449b5762 (patch) | |
tree | 341f80d55bf200c6bb195f77ce50a2fd1f030345 /common | |
parent | 1d4273cfb52043c8165b85e9d7ac7bc14cb59cba (diff) | |
parent | 1c761bd6f59c369e45037e80f781429da65734c3 (diff) | |
download | mpv-b3d670a3e1ee9c60be33b6e5fafdf3b6449b5762.tar.bz2 mpv-b3d670a3e1ee9c60be33b6e5fafdf3b6449b5762.tar.xz |
Merge branch 'master' into release/current
Diffstat (limited to 'common')
-rw-r--r-- | common/av_common.c | 5 | ||||
-rw-r--r-- | common/av_common.h | 9 | ||||
-rw-r--r-- | common/av_log.c | 2 | ||||
-rw-r--r-- | common/codecs.c | 46 | ||||
-rw-r--r-- | common/codecs.h | 10 | ||||
-rw-r--r-- | common/encode_lavc.c | 18 |
6 files changed, 23 insertions, 67 deletions
diff --git a/common/av_common.c b/common/av_common.c index 27a331927a..f2f43498e3 100644 --- a/common/av_common.c +++ b/common/av_common.c @@ -77,13 +77,8 @@ void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st) // other demuxers must be handled manually. void mp_set_lav_codec_headers(AVCodecContext *avctx, struct mp_codec_params *c) { -#if HAVE_AVCODEC_HAS_CODECPAR if (c->lav_codecpar) avcodec_parameters_to_context(avctx, c->lav_codecpar); -#else - if (c->lav_headers) - mp_copy_lav_codec_headers(avctx, c->lav_headers); -#endif } // Pick a "good" timebase, which will be used to convert double timestamps diff --git a/common/av_common.h b/common/av_common.h index b5ca034def..4b13dcdd0c 100644 --- a/common/av_common.h +++ b/common/av_common.h @@ -46,13 +46,4 @@ void mp_set_avdict(struct AVDictionary **dict, char **kv); void mp_avdict_print_unset(struct mp_log *log, int msgl, struct AVDictionary *d); int mp_set_avopts(struct mp_log *log, void *avobj, char **kv); -#if (LIBAVCODEC_VERSION_MICRO >= 100 && \ - LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 61, 100)) || \ - (LIBAVCODEC_VERSION_MICRO < 100 && \ - LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 24, 0)) -#define MP_AVFRAME_DEC_PTS(frame) ((frame)->pts) -#else -#define MP_AVFRAME_DEC_PTS(frame) ((frame)->pkt_pts) -#endif - #endif diff --git a/common/av_log.c b/common/av_log.c index 64ce26d853..e2a4c3316e 100644 --- a/common/av_log.c +++ b/common/av_log.c @@ -218,9 +218,7 @@ bool print_libav_versions(struct mp_log *log, int v) mp_msg(log, v, "\n"); } -#if HAVE_AV_VERSION_INFO mp_msg(log, v, "%s version: %s\n", LIB_PREFIX, av_version_info()); -#endif return !mismatch; } diff --git a/common/codecs.c b/common/codecs.c index c0d99eb959..5e744da5de 100644 --- a/common/codecs.c +++ b/common/codecs.c @@ -45,9 +45,10 @@ static struct mp_decoder_entry *find_decoder(struct mp_decoder_list *list, { for (int n = 0; n < list->num_entries; n++) { struct mp_decoder_entry *cur = &list->entries[n]; - if (bstr_equals0(decoder, cur->decoder) && - bstr_equals0(family, cur->family)) - return cur; + if (bstr_equals0(decoder, cur->decoder)) { + if (bstr_equals0(family, "*") || bstr_equals0(family, cur->family)) + return cur; + } } return NULL; } @@ -70,13 +71,14 @@ static void add_new(struct mp_decoder_list *to, struct mp_decoder_entry *entry, // The selection string corresponds to --vd/--ad directly, and has the // following syntax: // selection = [<entry> ("," <entry>)*] -// entry = <family> ":" <decoder> // prefer decoder +// entry = [<family> ":"] <decoder> // prefer decoder // entry = <family> ":*" // prefer all decoders -// entry = "+" <family> ":" <decoder> // force a decoder -// entry = "-" <family> ":" <decoder> // exclude a decoder +// entry = "+" [<family> ":"] <decoder> // force a decoder +// entry = "-" [<family> ":"] <decoder> // exclude a decoder // entry = "-" // don't add fallback decoders // Forcing a decoder means it's added even if the codec mismatches. -struct mp_decoder_list *mp_select_decoders(struct mp_decoder_list *all, +struct mp_decoder_list *mp_select_decoders(struct mp_log *log, + struct mp_decoder_list *all, const char *codec, const char *selection) { @@ -90,16 +92,22 @@ struct mp_decoder_list *mp_select_decoders(struct mp_decoder_list *all, bstr entry; bstr_split_tok(sel, ",", &entry, &sel); if (bstr_equals0(entry, "-")) { + mp_warn(log, "Excluding codecs is deprecated.\n"); stop = true; break; } bool force = bstr_eatstart0(&entry, "+"); bool exclude = !force && bstr_eatstart0(&entry, "-"); + if (exclude || force) + mp_warn(log, "Forcing or excluding codecs is deprecated.\n"); struct mp_decoder_list *dest = exclude ? remove : list; bstr family, decoder; - if (!bstr_split_tok(entry, ":", &family, &decoder)) { - family = entry; - decoder = bstr0("*"); + if (bstr_split_tok(entry, ":", &family, &decoder)) { + mp_warn(log, "Codec family selection is deprecated. " + "Pass the codec name directly.\n"); + } else { + family = bstr0("*"); + decoder = entry; } if (bstr_equals0(decoder, "*")) { for (int n = 0; n < all->num_entries; n++) { @@ -130,22 +138,6 @@ struct mp_decoder_list *mp_select_decoders(struct mp_decoder_list *all, return list; } -// selection is a ","-separated list of decoders, all in the given family. -struct mp_decoder_list *mp_select_decoder_list(struct mp_decoder_list *all, - const char *codec, - const char *family, - const char *selection) -{ - struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list); - bstr sel = bstr0(selection); - while (sel.len) { - bstr decoder; - bstr_split_tok(sel, ",", &decoder, &sel); - add_new(list, find_decoder(all, bstr0(family), decoder), codec); - } - return list; -} - void mp_append_decoders(struct mp_decoder_list *list, struct mp_decoder_list *a) { for (int n = 0; n < a->num_entries; n++) @@ -158,7 +150,7 @@ void mp_print_decoders(struct mp_log *log, int msgl, const char *header, mp_msg(log, msgl, "%s\n", header); for (int n = 0; n < list->num_entries; n++) { struct mp_decoder_entry *entry = &list->entries[n]; - mp_msg(log, msgl, " %s:%s", entry->family, entry->decoder); + mp_msg(log, msgl, " %s", entry->decoder); if (strcmp(entry->decoder, entry->codec) != 0) mp_msg(log, msgl, " (%s)", entry->codec); mp_msg(log, msgl, " - %s\n", entry->desc); diff --git a/common/codecs.h b/common/codecs.h index 17316c85e9..bed5c46905 100644 --- a/common/codecs.h +++ b/common/codecs.h @@ -18,6 +18,8 @@ #ifndef MP_CODECS_H #define MP_CODECS_H +struct mp_log; + struct mp_decoder_entry { const char *family; // decoder module (e.g. ad_lavc => "lavc") const char *codec; // name of the codec (e.g. "mp3") @@ -33,15 +35,11 @@ struct mp_decoder_list { void mp_add_decoder(struct mp_decoder_list *list, const char *family, const char *codec, const char *decoder, const char *desc); -struct mp_decoder_list *mp_select_decoders(struct mp_decoder_list *all, +struct mp_decoder_list *mp_select_decoders(struct mp_log *log, + struct mp_decoder_list *all, const char *codec, const char *selection); -struct mp_decoder_list *mp_select_decoder_list(struct mp_decoder_list *all, - const char *codec, - const char *family, - const char *selection); - void mp_append_decoders(struct mp_decoder_list *list, struct mp_decoder_list *a); struct mp_log; diff --git a/common/encode_lavc.c b/common/encode_lavc.c index d0523857ee..7e116e3b0c 100644 --- a/common/encode_lavc.c +++ b/common/encode_lavc.c @@ -595,12 +595,7 @@ int encode_lavc_alloc_stream(struct encode_lavc_context *ctx, } return -1; } -#if HAVE_AVCODEC_HAS_CODECPAR ctx->vcc = avcodec_alloc_context3(ctx->vc); -#else - avcodec_get_context_defaults3(ctx->vst->codec, ctx->vc); - ctx->vcc = ctx->vst->codec; -#endif // Using codec->time_base is deprecated, but needed for older lavf. ctx->vst->time_base = ctx->timebase; @@ -635,12 +630,7 @@ int encode_lavc_alloc_stream(struct encode_lavc_context *ctx, } return -1; } -#if HAVE_AVCODEC_HAS_CODECPAR ctx->acc = avcodec_alloc_context3(ctx->ac); -#else - avcodec_get_context_defaults3(ctx->ast->codec, ctx->ac); - ctx->acc = ctx->ast->codec; -#endif // Using codec->time_base is deprecated, but needed for older lavf. ctx->ast->time_base = ctx->timebase; @@ -708,10 +698,8 @@ int encode_lavc_open_codec(struct encode_lavc_context *ctx, } ret = avcodec_open2(codec, ctx->vc, &ctx->voptions); -#if HAVE_AVCODEC_HAS_CODECPAR if (ret >= 0) ret = avcodec_parameters_from_context(ctx->vst->codecpar, codec); -#endif // complain about all remaining options, then free the dict for (de = NULL; (de = av_dict_get(ctx->voptions, "", de, @@ -747,10 +735,8 @@ int encode_lavc_open_codec(struct encode_lavc_context *ctx, } ret = avcodec_open2(codec, ctx->ac, &ctx->aoptions); -#if HAVE_AVCODEC_HAS_CODECPAR if (ret >= 0) ret = avcodec_parameters_from_context(ctx->ast->codecpar, codec); -#endif // complain about all remaining options, then free the dict for (de = NULL; (de = av_dict_get(ctx->aoptions, "", de, @@ -826,11 +812,7 @@ int encode_lavc_write_frame(struct encode_lavc_context *ctx, AVStream *stream, (int)packet->size); -#if HAVE_AVCODEC_HAS_CODECPAR switch (stream->codecpar->codec_type) { -#else - switch (stream->codec->codec_type) { -#endif case AVMEDIA_TYPE_VIDEO: ctx->vbytes += packet->size; ++ctx->frames; |