[FFmpeg-devel] [PATCH 2/3] avcodec: Implement mpeg1 nvdec hwaccel
Philip Langdale
philipl at overt.org
Sun Nov 19 21:52:27 EET 2017
Once I remembered that there's a separate decoder type for mpeg1,
even though params struct is shared with mpeg2, everything worked.
Signed-off-by: Philip Langdale <philipl at overt.org>
---
Changelog | 2 +-
configure | 2 ++
libavcodec/Makefile | 1 +
libavcodec/allcodecs.c | 1 +
libavcodec/mpeg12dec.c | 3 +++
libavcodec/nvdec.c | 1 +
libavcodec/nvdec_mpeg12.c | 18 +++++++++++++++++-
libavcodec/version.h | 2 +-
8 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/Changelog b/Changelog
index e1f8a648b0..5a9d183aed 100644
--- a/Changelog
+++ b/Changelog
@@ -13,7 +13,7 @@ version <next>:
- PCE support for extended channel layouts in the AAC encoder
- native aptX encoder and decoder
- Raw aptX muxer and demuxer
-- NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-2, VC1 and VP9 hwaccel decoding
+- NVIDIA NVDEC-accelerated H.264, HEVC, MPEG-1/2, VC1 and VP9 hwaccel decoding
- Intel QSV-accelerated overlay filter
- mcompand audio filter
- acontrast audio filter
diff --git a/configure b/configure
index 48761934be..35713805fa 100755
--- a/configure
+++ b/configure
@@ -2700,6 +2700,8 @@ mjpeg_cuvid_hwaccel_select="mjpeg_cuvid_decoder"
mpeg_xvmc_hwaccel_deps="xvmc"
mpeg_xvmc_hwaccel_select="mpeg2video_decoder"
mpeg1_cuvid_hwaccel_select="mpeg1_cuvid_decoder"
+mpeg1_nvdec_hwaccel_deps="nvdec"
+mpeg1_nvdec_hwaccel_select="mpeg1video_decoder"
mpeg1_vdpau_hwaccel_deps="vdpau"
mpeg1_vdpau_hwaccel_select="mpeg1video_decoder"
mpeg1_videotoolbox_hwaccel_deps="videotoolbox"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 494c76da76..0573454c7b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -849,6 +849,7 @@ OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
OBJS-$(CONFIG_HEVC_QSV_HWACCEL) += qsvdec_h2645.o
OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
+OBJS-$(CONFIG_MPEG1_NVDEC_HWACCEL) += nvdec_mpeg12.o
OBJS-$(CONFIG_MPEG1_VDPAU_HWACCEL) += vdpau_mpeg12.o
OBJS-$(CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL) += mpegvideo_xvmc.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index e0adb71951..e9df7049de 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -87,6 +87,7 @@ static void register_all(void)
REGISTER_HWACCEL(HEVC_VIDEOTOOLBOX, hevc_videotoolbox);
REGISTER_HWACCEL(MJPEG_CUVID, mjpeg_cuvid);
REGISTER_HWACCEL(MPEG1_CUVID, mpeg1_cuvid);
+ REGISTER_HWACCEL(MPEG1_NVDEC, mpeg1_nvdec);
REGISTER_HWACCEL(MPEG1_XVMC, mpeg1_xvmc);
REGISTER_HWACCEL(MPEG1_VDPAU, mpeg1_vdpau);
REGISTER_HWACCEL(MPEG1_VIDEOTOOLBOX, mpeg1_videotoolbox);
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 2b213eebcd..5a51d09bb0 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1130,6 +1130,9 @@ static void quant_matrix_rebuild(uint16_t *matrix, const uint8_t *old_perm,
}
static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
+#if CONFIG_MPEG1_NVDEC_HWACCEL
+ AV_PIX_FMT_CUDA,
+#endif
#if CONFIG_MPEG1_XVMC_HWACCEL
AV_PIX_FMT_XVMC,
#endif
diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c
index 97ff605f0f..d5cf1058cb 100644
--- a/libavcodec/nvdec.c
+++ b/libavcodec/nvdec.c
@@ -54,6 +54,7 @@ static int map_avcodec_id(enum AVCodecID id)
switch (id) {
case AV_CODEC_ID_H264: return cudaVideoCodec_H264;
case AV_CODEC_ID_HEVC: return cudaVideoCodec_HEVC;
+ case AV_CODEC_ID_MPEG1VIDEO: return cudaVideoCodec_MPEG1;
case AV_CODEC_ID_MPEG2VIDEO: return cudaVideoCodec_MPEG2;
case AV_CODEC_ID_VC1: return cudaVideoCodec_VC1;
case AV_CODEC_ID_VP9: return cudaVideoCodec_VP9;
diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c
index db9cebeddd..e29d085a79 100644
--- a/libavcodec/nvdec_mpeg12.c
+++ b/libavcodec/nvdec_mpeg12.c
@@ -1,5 +1,5 @@
/*
- * MPEG-2 HW decode acceleration through NVDEC
+ * MPEG-1/2 HW decode acceleration through NVDEC
*
* Copyright (c) 2017 Philip Langdale
*
@@ -105,3 +105,19 @@ AVHWAccel ff_mpeg2_nvdec_hwaccel = {
.priv_data_size = sizeof(NVDECContext),
};
#endif
+
+#if CONFIG_MPEG1_NVDEC_HWACCEL
+AVHWAccel ff_mpeg1_nvdec_hwaccel = {
+ .name = "mpeg1_nvdec",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .id = AV_CODEC_ID_MPEG1VIDEO,
+ .pix_fmt = AV_PIX_FMT_CUDA,
+ .start_frame = nvdec_mpeg12_start_frame,
+ .end_frame = ff_nvdec_simple_end_frame,
+ .decode_slice = ff_nvdec_simple_decode_slice,
+ .frame_params = nvdec_mpeg12_frame_params,
+ .init = ff_nvdec_decode_init,
+ .uninit = ff_nvdec_decode_uninit,
+ .priv_data_size = sizeof(NVDECContext),
+};
+#endif
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 5b25a9a8ac..ff54670ea9 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 3
-#define LIBAVCODEC_VERSION_MICRO 103
+#define LIBAVCODEC_VERSION_MICRO 104
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
--
2.14.1
More information about the ffmpeg-devel
mailing list