Browse Source

Merge pull request #2048 from VodBox/webm-hwaccel

deps/media-playback: Use hardware decoding with non-alpha WebM files
Jim 6 years ago
parent
commit
f2ad6ab076
1 changed files with 11 additions and 4 deletions
  1. 11 4
      deps/media-playback/media-playback/decode.c

+ 11 - 4
deps/media-playback/media-playback/decode.c

@@ -142,10 +142,17 @@ bool mp_decode_init(mp_media_t *m, enum AVMediaType type, bool hw)
 	id = stream->codec->codec_id;
 #endif
 
-	if (id == AV_CODEC_ID_VP8)
-		d->codec = avcodec_find_decoder_by_name("libvpx");
-	else if (id == AV_CODEC_ID_VP9)
-		d->codec = avcodec_find_decoder_by_name("libvpx-vp9");
+	if (id == AV_CODEC_ID_VP8 || id == AV_CODEC_ID_VP9) {
+		AVDictionaryEntry *tag = NULL;
+		tag = av_dict_get(stream->metadata, "alpha_mode", tag,
+				  AV_DICT_IGNORE_SUFFIX);
+
+		if (tag && strcmp(tag->value, "1") == 0) {
+			char *codec = (id == AV_CODEC_ID_VP8) ? "libvpx"
+							      : "libvpx-vp9";
+			d->codec = avcodec_find_decoder_by_name(codec);
+		}
+	}
 
 	if (!d->codec)
 		d->codec = avcodec_find_decoder(id);