summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-03 21:00:05 +0200
committerwm4 <wm4@nowhere>2013-05-04 01:38:27 +0200
commit012d297bb13a290508c8a40c5d9f62d6535bb415 (patch)
tree172276c4d2f59a6851af483f30088b72fe10eedf /video
parent844249317b350ad2a9f71b4382252027861d9e20 (diff)
downloadmpv-012d297bb13a290508c8a40c5d9f62d6535bb415.tar.bz2
mpv-012d297bb13a290508c8a40c5d9f62d6535bb415.tar.xz
video: add --hwdec-codecs option to whitelist codecs for hw decoding
Diffstat (limited to 'video')
-rw-r--r--video/decode/vd_lavc.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 59eba1166b..c3e9ce5860 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -135,6 +135,18 @@ static struct hwdec *find_hwcodec(enum hwdec_type api, const char *codec)
return NULL;
}
+static bool hwdec_codec_allowed(sh_video_t *sh, struct hwdec *hwdec)
+{
+ bstr s = bstr0(sh->opts->hwdec_codecs);
+ while (s.len) {
+ bstr item;
+ bstr_split_tok(s, ",", &item, &s);
+ if (bstr_equals0(item, "all") || bstr_equals0(item, hwdec->codec))
+ return true;
+ }
+ return false;
+}
+
static enum AVDiscard str2AVDiscard(char *str)
{
if (!str) return AVDISCARD_DEFAULT;
@@ -155,19 +167,20 @@ static int init(sh_video_t *sh, const char *decoder)
ctx->non_dr1_pool = talloc_steal(ctx, mp_image_pool_new(16));
struct hwdec *hwdec = find_hwcodec(sh->opts->hwdec_api, decoder);
- if (hwdec) {
+ struct hwdec *use_hwdec = NULL;
+ if (hwdec && hwdec_codec_allowed(sh, hwdec)) {
AVCodec *lavc_hwcodec = avcodec_find_decoder_by_name(hwdec->hw_codec);
if (lavc_hwcodec) {
ctx->software_fallback_decoder = talloc_strdup(ctx, decoder);
decoder = lavc_hwcodec->name;
+ use_hwdec = hwdec;
} else {
mp_tmsg(MSGT_DECVIDEO, MSGL_WARN, "Decoder '%s' not found in "
"libavcodec, using software decoding.\n", hwdec->hw_codec);
- hwdec = NULL;
}
}
- init_avctx(sh, decoder, hwdec);
+ init_avctx(sh, decoder, use_hwdec);
if (!ctx->avctx) {
if (ctx->software_fallback_decoder) {
mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "Error initializing hardware "