diff options
author | wm4 <nfxjfg@googlemail.com> | 2017-10-03 15:04:45 +0200 |
---|---|---|
committer | Timo Rothenpieler <timo@rothenpieler.org> | 2017-11-10 22:48:34 +0100 |
commit | ae5046e492cd87233111e994ca4ae3d74a233b51 (patch) | |
tree | 7858bdb33d3fe30a13821553d51874376c263726 /libavcodec/decode.c | |
parent | 5593049466bcd1d3f1ddbfe580be4f36123d7c3d (diff) | |
download | ffmpeg-ae5046e492cd87233111e994ca4ae3d74a233b51.tar.gz |
avcodec: allow multiple hwaccels for the same codec/pixfmt
Currently, AVHWAccels are looked up using a (codec_id, pixfmt) tuple.
This means it's impossible to have 2 decoders for the same codec and
using the same opaque hardware pixel format.
This breaks merging Libav's CUVID hwaccel. FFmpeg has its own CUVID
support, but it's a full stream decoder, using NVIDIA's codec parser.
The Libav one is a true hwaccel, which is based on the builtin software
decoders.
Fix this by introducing another field to disambiguate AVHWAccels, and
use it for our CUVID decoders. FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS makes
this mechanism backwards compatible and optional.
Diffstat (limited to 'libavcodec/decode.c')
-rw-r--r-- | libavcodec/decode.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 44b874d4f8..9fdc7bb565 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1090,15 +1090,19 @@ enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const en return fmt[0]; } -static AVHWAccel *find_hwaccel(enum AVCodecID codec_id, +static AVHWAccel *find_hwaccel(AVCodecContext *avctx, enum AVPixelFormat pix_fmt) { AVHWAccel *hwaccel = NULL; + const AVClass *av_class = + (avctx->codec->caps_internal & FF_CODEC_CAP_HWACCEL_REQUIRE_CLASS) + ? avctx->codec->priv_class : NULL; - while ((hwaccel = av_hwaccel_next(hwaccel))) - if (hwaccel->id == codec_id + while ((hwaccel = av_hwaccel_next(hwaccel))) { + if (hwaccel->decoder_class == av_class && hwaccel->id == avctx->codec_id && hwaccel->pix_fmt == pix_fmt) return hwaccel; + } return NULL; } @@ -1106,7 +1110,7 @@ static int setup_hwaccel(AVCodecContext *avctx, const enum AVPixelFormat fmt, const char *name) { - AVHWAccel *hwa = find_hwaccel(avctx->codec_id, fmt); + AVHWAccel *hwa = find_hwaccel(avctx, fmt); int ret = 0; if (!hwa) { |