... | ... |
@@ -13,7 +13,7 @@ version <next>: |
13 | 13 |
- PCE support for extended channel layouts in the AAC encoder |
14 | 14 |
- native aptX encoder and decoder |
15 | 15 |
- Raw aptX muxer and demuxer |
16 |
-- NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-1/2/4, VC1 and VP9 hwaccel decoding |
|
16 |
+- NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-1/2/4, VC1, VP8/9 hwaccel decoding |
|
17 | 17 |
- Intel QSV-accelerated overlay filter |
18 | 18 |
- mcompand audio filter |
19 | 19 |
- acontrast audio filter |
... | ... |
@@ -2746,6 +2746,8 @@ vc1_vaapi_hwaccel_deps="vaapi" |
2746 | 2746 |
vc1_vaapi_hwaccel_select="vc1_decoder" |
2747 | 2747 |
vc1_vdpau_hwaccel_deps="vdpau" |
2748 | 2748 |
vc1_vdpau_hwaccel_select="vc1_decoder" |
2749 |
+vp8_nvdec_hwaccel_deps="nvdec" |
|
2750 |
+vp8_nvdec_hwaccel_select="vp8_decoder" |
|
2749 | 2751 |
vp8_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVP8" |
2750 | 2752 |
vp8_vaapi_hwaccel_select="vp8_decoder" |
2751 | 2753 |
vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9" |
... | ... |
@@ -871,6 +871,7 @@ OBJS-$(CONFIG_VC1_NVDEC_HWACCEL) += nvdec_vc1.o |
871 | 871 |
OBJS-$(CONFIG_VC1_QSV_HWACCEL) += qsvdec_other.o |
872 | 872 |
OBJS-$(CONFIG_VC1_VAAPI_HWACCEL) += vaapi_vc1.o |
873 | 873 |
OBJS-$(CONFIG_VC1_VDPAU_HWACCEL) += vdpau_vc1.o |
874 |
+OBJS-$(CONFIG_VP8_NVDEC_HWACCEL) += nvdec_vp8.o |
|
874 | 875 |
OBJS-$(CONFIG_VP8_VAAPI_HWACCEL) += vaapi_vp8.o |
875 | 876 |
OBJS-$(CONFIG_VP9_D3D11VA_HWACCEL) += dxva2_vp9.o |
876 | 877 |
OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o |
... | ... |
@@ -59,6 +59,7 @@ extern const AVHWAccel ff_vc1_dxva2_hwaccel; |
59 | 59 |
extern const AVHWAccel ff_vc1_nvdec_hwaccel; |
60 | 60 |
extern const AVHWAccel ff_vc1_vaapi_hwaccel; |
61 | 61 |
extern const AVHWAccel ff_vc1_vdpau_hwaccel; |
62 |
+extern const AVHWAccel ff_vp8_nvdec_hwaccel; |
|
62 | 63 |
extern const AVHWAccel ff_vp8_vaapi_hwaccel; |
63 | 64 |
extern const AVHWAccel ff_vp9_d3d11va_hwaccel; |
64 | 65 |
extern const AVHWAccel ff_vp9_d3d11va2_hwaccel; |
... | ... |
@@ -58,6 +58,7 @@ static int map_avcodec_id(enum AVCodecID id) |
58 | 58 |
case AV_CODEC_ID_MPEG2VIDEO: return cudaVideoCodec_MPEG2; |
59 | 59 |
case AV_CODEC_ID_MPEG4: return cudaVideoCodec_MPEG4; |
60 | 60 |
case AV_CODEC_ID_VC1: return cudaVideoCodec_VC1; |
61 |
+ case AV_CODEC_ID_VP8: return cudaVideoCodec_VP8; |
|
61 | 62 |
case AV_CODEC_ID_VP9: return cudaVideoCodec_VP9; |
62 | 63 |
case AV_CODEC_ID_WMV3: return cudaVideoCodec_VC1; |
63 | 64 |
} |
64 | 65 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,97 @@ |
0 |
+/* |
|
1 |
+ * VP8 HW decode acceleration through NVDEC |
|
2 |
+ * |
|
3 |
+ * Copyright (c) 2017 Philip Langdale |
|
4 |
+ * |
|
5 |
+ * This file is part of FFmpeg. |
|
6 |
+ * |
|
7 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
8 |
+ * modify it under the terms of the GNU Lesser General Public |
|
9 |
+ * License as published by the Free Software Foundation; either |
|
10 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
11 |
+ * |
|
12 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
13 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 |
+ * Lesser General Public License for more details. |
|
16 |
+ * |
|
17 |
+ * You should have received a copy of the GNU Lesser General Public |
|
18 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
19 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
20 |
+ */ |
|
21 |
+ |
|
22 |
+#include "avcodec.h" |
|
23 |
+#include "nvdec.h" |
|
24 |
+#include "decode.h" |
|
25 |
+#include "internal.h" |
|
26 |
+#include "vp8.h" |
|
27 |
+ |
|
28 |
+static unsigned char safe_get_ref_idx(VP8Frame *frame) |
|
29 |
+{ |
|
30 |
+ return frame ? ff_nvdec_get_ref_idx(frame->tf.f) : 255; |
|
31 |
+} |
|
32 |
+ |
|
33 |
+static int nvdec_vp8_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) |
|
34 |
+{ |
|
35 |
+ VP8Context *h = avctx->priv_data; |
|
36 |
+ |
|
37 |
+ NVDECContext *ctx = avctx->internal->hwaccel_priv_data; |
|
38 |
+ CUVIDPICPARAMS *pp = &ctx->pic_params; |
|
39 |
+ FrameDecodeData *fdd; |
|
40 |
+ NVDECFrame *cf; |
|
41 |
+ AVFrame *cur_frame = h->framep[VP56_FRAME_CURRENT]->tf.f; |
|
42 |
+ |
|
43 |
+ int ret; |
|
44 |
+ |
|
45 |
+ ret = ff_nvdec_start_frame(avctx, cur_frame); |
|
46 |
+ if (ret < 0) |
|
47 |
+ return ret; |
|
48 |
+ |
|
49 |
+ fdd = (FrameDecodeData*)cur_frame->private_ref->data; |
|
50 |
+ cf = (NVDECFrame*)fdd->hwaccel_priv; |
|
51 |
+ |
|
52 |
+ *pp = (CUVIDPICPARAMS) { |
|
53 |
+ .PicWidthInMbs = (cur_frame->width + 15) / 16, |
|
54 |
+ .FrameHeightInMbs = (cur_frame->height + 15) / 16, |
|
55 |
+ .CurrPicIdx = cf->idx, |
|
56 |
+ |
|
57 |
+ .CodecSpecific.vp8 = { |
|
58 |
+ .width = cur_frame->width, |
|
59 |
+ .height = cur_frame->height, |
|
60 |
+ |
|
61 |
+ .first_partition_size = h->header_partition_size, |
|
62 |
+ |
|
63 |
+ .LastRefIdx = safe_get_ref_idx(h->framep[VP56_FRAME_PREVIOUS]), |
|
64 |
+ .GoldenRefIdx = safe_get_ref_idx(h->framep[VP56_FRAME_GOLDEN]), |
|
65 |
+ .AltRefIdx = safe_get_ref_idx(h->framep[VP56_FRAME_GOLDEN2]), |
|
66 |
+ |
|
67 |
+ .frame_type = !h->keyframe, |
|
68 |
+ .version = h->profile, |
|
69 |
+ .show_frame = !h->invisible, |
|
70 |
+ .update_mb_segmentation_data = h->segmentation.enabled ? h->segmentation.update_feature_data : 0, |
|
71 |
+ } |
|
72 |
+ }; |
|
73 |
+ |
|
74 |
+ return 0; |
|
75 |
+} |
|
76 |
+ |
|
77 |
+static int nvdec_vp8_frame_params(AVCodecContext *avctx, |
|
78 |
+ AVBufferRef *hw_frames_ctx) |
|
79 |
+{ |
|
80 |
+ // VP8 uses a fixed size pool of 3 possible reference frames |
|
81 |
+ return ff_nvdec_frame_params(avctx, hw_frames_ctx, 3); |
|
82 |
+} |
|
83 |
+ |
|
84 |
+AVHWAccel ff_vp8_nvdec_hwaccel = { |
|
85 |
+ .name = "vp8_nvdec", |
|
86 |
+ .type = AVMEDIA_TYPE_VIDEO, |
|
87 |
+ .id = AV_CODEC_ID_VP8, |
|
88 |
+ .pix_fmt = AV_PIX_FMT_CUDA, |
|
89 |
+ .start_frame = nvdec_vp8_start_frame, |
|
90 |
+ .end_frame = ff_nvdec_simple_end_frame, |
|
91 |
+ .decode_slice = ff_nvdec_simple_decode_slice, |
|
92 |
+ .frame_params = nvdec_vp8_frame_params, |
|
93 |
+ .init = ff_nvdec_decode_init, |
|
94 |
+ .uninit = ff_nvdec_decode_uninit, |
|
95 |
+ .priv_data_size = sizeof(NVDECContext), |
|
96 |
+}; |
... | ... |
@@ -29,7 +29,7 @@ |
29 | 29 |
|
30 | 30 |
#define LIBAVCODEC_VERSION_MAJOR 58 |
31 | 31 |
#define LIBAVCODEC_VERSION_MINOR 6 |
32 |
-#define LIBAVCODEC_VERSION_MICRO 100 |
|
32 |
+#define LIBAVCODEC_VERSION_MICRO 101 |
|
33 | 33 |
|
34 | 34 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
35 | 35 |
LIBAVCODEC_VERSION_MINOR, \ |
... | ... |
@@ -2602,6 +2602,9 @@ int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, |
2602 | 2602 |
#if CONFIG_VP8_VAAPI_HWACCEL |
2603 | 2603 |
AV_PIX_FMT_VAAPI, |
2604 | 2604 |
#endif |
2605 |
+#if CONFIG_VP8_NVDEC_HWACCEL |
|
2606 |
+ AV_PIX_FMT_CUDA, |
|
2607 |
+#endif |
|
2605 | 2608 |
AV_PIX_FMT_YUV420P, |
2606 | 2609 |
AV_PIX_FMT_NONE, |
2607 | 2610 |
}; |
... | ... |
@@ -2950,6 +2953,9 @@ AVCodec ff_vp8_decoder = { |
2950 | 2950 |
#if CONFIG_VP8_VAAPI_HWACCEL |
2951 | 2951 |
HWACCEL_VAAPI(vp8), |
2952 | 2952 |
#endif |
2953 |
+#if CONFIG_VP8_NVDEC_HWACCEL |
|
2954 |
+ HWACCEL_NVDEC(vp8), |
|
2955 |
+#endif |
|
2953 | 2956 |
NULL |
2954 | 2957 |
}, |
2955 | 2958 |
}; |