[vlc-commits] nvdec: decode HEVC 4:4:4 8/10/12/16 bits
Steve Lhomme
git at videolan.org
Fri Dec 13 17:28:13 CET 2019
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Dec 13 13:59:18 2019 +0100| [33f6fd9ecffe11cd31885bf4f20b0b8b32af26ad] | committer: Steve Lhomme
nvdec: decode HEVC 4:4:4 8/10/12/16 bits
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=33f6fd9ecffe11cd31885bf4f20b0b8b32af26ad
---
include/vlc_fourcc.h | 2 +
modules/hw/nvdec/chroma.c | 11 ++++-
modules/hw/nvdec/nvdec.c | 113 +++++++++++++++++++++++++++++++------------
modules/hw/nvdec/nvdec_fmt.h | 4 +-
src/misc/fourcc.c | 5 ++
src/misc/fourcc_list.h | 6 +++
6 files changed, 107 insertions(+), 34 deletions(-)
diff --git a/include/vlc_fourcc.h b/include/vlc_fourcc.h
index 68c037d8da..023b8b8b66 100644
--- a/include/vlc_fourcc.h
+++ b/include/vlc_fourcc.h
@@ -413,6 +413,8 @@
#define VLC_CODEC_NVDEC_OPAQUE VLC_FOURCC('N','V','D','8') /* 4:2:0 8 bpc */
#define VLC_CODEC_NVDEC_OPAQUE_10B VLC_FOURCC('N','V','D','0') /* 4:2:0 10 bpc */
#define VLC_CODEC_NVDEC_OPAQUE_16B VLC_FOURCC('N','V','D','6') /* 4:2:0 16 bpc */
+#define VLC_CODEC_NVDEC_OPAQUE_444 VLC_FOURCC('N','V','4','8') /* 4:4:4 8 bpc */
+#define VLC_CODEC_NVDEC_OPAQUE_444_16B VLC_FOURCC('N','V','4','6') /* 4:4:4 16 bpc */
/* CVPixelBuffer opaque buffer type */
#define VLC_CODEC_CVPX_NV12 VLC_FOURCC('C','V','P','N')
diff --git a/modules/hw/nvdec/chroma.c b/modules/hw/nvdec/chroma.c
index ad52e4361d..c96bcb9106 100644
--- a/modules/hw/nvdec/chroma.c
+++ b/modules/hw/nvdec/chroma.c
@@ -71,6 +71,11 @@ static picture_t * FilterCUDAToCPU( filter_t *p_filter, picture_t *src )
size_t srcY = 0;
for (int i_plane = 0; i_plane < dst->i_planes; i_plane++) {
plane_t plane = dst->p[i_plane];
+ if (dst->format.i_chroma == VLC_CODEC_YUVA && i_plane == 3)
+ {
+ memset(plane.p_pixels, 0xFF, plane.i_pitch * plane.i_visible_lines);
+ continue;
+ }
CUDA_MEMCPY2D cu_cpy = {
.srcMemoryType = CU_MEMORYTYPE_DEVICE,
.srcDevice = srcpic->devidePtr,
@@ -112,7 +117,11 @@ static int OpenCUDAToCPU( vlc_object_t *p_this )
( p_filter->fmt_in.video.i_chroma == VLC_CODEC_NVDEC_OPAQUE_10B &&
p_filter->fmt_out.video.i_chroma == VLC_CODEC_P010 ) ||
( p_filter->fmt_in.video.i_chroma == VLC_CODEC_NVDEC_OPAQUE_16B &&
- p_filter->fmt_out.video.i_chroma == VLC_CODEC_P016 )
+ p_filter->fmt_out.video.i_chroma == VLC_CODEC_P016 ) ||
+ ( p_filter->fmt_in.video.i_chroma == VLC_CODEC_NVDEC_OPAQUE_444 &&
+ (p_filter->fmt_out.video.i_chroma == VLC_CODEC_I444 || p_filter->fmt_out.video.i_chroma == VLC_CODEC_YUVA) ) ||
+ ( p_filter->fmt_in.video.i_chroma == VLC_CODEC_NVDEC_OPAQUE_444_16B &&
+ p_filter->fmt_out.video.i_chroma == VLC_CODEC_I444_16L )
) )
return VLC_EGENERIC;
diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
index 5c8275387d..19b45e2529 100644
--- a/modules/hw/nvdec/nvdec.c
+++ b/modules/hw/nvdec/nvdec.c
@@ -117,10 +117,10 @@ static vlc_fourcc_t MapSurfaceChroma(cudaVideoChromaFormat chroma, unsigned bitD
if (bitDepth <= 10)
return VLC_CODEC_P010;
return VLC_CODEC_P016;
- // case cudaVideoChromaFormat_444:
- // if (bitDepth <= 8)
- // return VLC_CODEC_I444;
- // return VLC_CODEC_I444_16L;
+ case cudaVideoChromaFormat_444:
+ if (bitDepth <= 8)
+ return VLC_CODEC_I444;
+ return VLC_CODEC_I444_16L;
default:
return 0;
}
@@ -137,10 +137,12 @@ static cudaVideoSurfaceFormat MapSurfaceFmt(int i_vlc_fourcc)
case VLC_CODEC_NVDEC_OPAQUE:
case VLC_CODEC_NV12:
return cudaVideoSurfaceFormat_NV12;
- // case VLC_CODEC_I444:
- // return cudaVideoSurfaceFormat_YUV444;
- // case VLC_CODEC_I444_16L:
- // return cudaVideoSurfaceFormat_YUV444_16Bit;
+ case VLC_CODEC_NVDEC_OPAQUE_444:
+ case VLC_CODEC_I444:
+ return cudaVideoSurfaceFormat_YUV444;
+ case VLC_CODEC_NVDEC_OPAQUE_444_16B:
+ case VLC_CODEC_I444_16L:
+ return cudaVideoSurfaceFormat_YUV444_16Bit;
default: vlc_assert_unreachable();
}
}
@@ -244,7 +246,19 @@ static int CUDAAPI HandleVideoSequence(void *p_opaque, CUVIDEOFORMAT *p_format)
unsigned int ByteWidth = p_sys->outputPitch;
unsigned int Height = p_dec->fmt_out.video.i_height;
- Height += Height / 2;
+ switch (dparams.OutputFormat)
+ {
+ case cudaVideoSurfaceFormat_YUV444:
+ case cudaVideoSurfaceFormat_YUV444_16Bit:
+ Height += 2 * Height; // 3 planes
+ break;
+ case cudaVideoSurfaceFormat_NV12:
+ case cudaVideoSurfaceFormat_P016:
+ Height += Height / 2; // U and V at quarter resolution
+ break;
+ default:
+ vlc_assert_unreachable();
+ }
picture_t *pics[ARRAY_SIZE(p_sys->outputDevicePtr)];
for (size_t i=0; i < ARRAY_SIZE(p_sys->outputDevicePtr); i++)
@@ -382,29 +396,57 @@ static int CUDAAPI HandlePictureDisplay(void *p_opaque, CUVIDPARSERDISPINFO *p_d
size_t srcY = 0;
size_t dstY = 0;
- for (int i_plane = 0; i_plane < 2; i_plane++) {
- CUDA_MEMCPY2D cu_cpy = {
- .srcMemoryType = CU_MEMORYTYPE_DEVICE,
- .srcDevice = frameDevicePtr,
- .srcY = srcY,
- .srcPitch = i_pitch,
- .dstMemoryType = CU_MEMORYTYPE_DEVICE,
- .dstDevice = picctx->devidePtr,
- .dstPitch = picctx->bufferPitch,
- .dstY = dstY,
- .WidthInBytes = i_pitch,
- .Height = __MIN(picctx->bufferHeight, p_dec->fmt_out.video.i_y_offset + p_dec->fmt_out.video.i_visible_height),
- };
- if (i_plane == 1)
- cu_cpy.Height >>= 1;
- result = CALL_CUDA_DEC(cuMemcpy2DAsync, &cu_cpy, 0);
- if (unlikely(result != VLC_SUCCESS))
- {
- free(picctx);
- goto error;
+ if (p_pic->format.i_chroma == VLC_CODEC_NVDEC_OPAQUE_444 || p_pic->format.i_chroma == VLC_CODEC_NVDEC_OPAQUE_444_16B)
+ {
+ for (int i_plane = 0; i_plane < 3; i_plane++) {
+ CUDA_MEMCPY2D cu_cpy = {
+ .srcMemoryType = CU_MEMORYTYPE_DEVICE,
+ .srcDevice = frameDevicePtr,
+ .srcY = srcY,
+ .srcPitch = i_pitch,
+ .dstMemoryType = CU_MEMORYTYPE_DEVICE,
+ .dstDevice = picctx->devidePtr,
+ .dstPitch = picctx->bufferPitch,
+ .dstY = dstY,
+ .WidthInBytes = i_pitch,
+ .Height = __MIN(picctx->bufferHeight, p_dec->fmt_out.video.i_y_offset + p_dec->fmt_out.video.i_visible_height),
+ };
+ result = CALL_CUDA_DEC(cuMemcpy2DAsync, &cu_cpy, 0);
+ if (unlikely(result != VLC_SUCCESS))
+ {
+ free(picctx);
+ goto error;
+ }
+ srcY += picctx->bufferHeight;
+ dstY += p_sys->decoderHeight;
+ }
+ }
+ else
+ {
+ for (int i_plane = 0; i_plane < 2; i_plane++) {
+ CUDA_MEMCPY2D cu_cpy = {
+ .srcMemoryType = CU_MEMORYTYPE_DEVICE,
+ .srcDevice = frameDevicePtr,
+ .srcY = srcY,
+ .srcPitch = i_pitch,
+ .dstMemoryType = CU_MEMORYTYPE_DEVICE,
+ .dstDevice = picctx->devidePtr,
+ .dstPitch = picctx->bufferPitch,
+ .dstY = dstY,
+ .WidthInBytes = i_pitch,
+ .Height = __MIN(picctx->bufferHeight, p_dec->fmt_out.video.i_y_offset + p_dec->fmt_out.video.i_visible_height),
+ };
+ if (i_plane == 1)
+ cu_cpy.Height >>= 1;
+ result = CALL_CUDA_DEC(cuMemcpy2DAsync, &cu_cpy, 0);
+ if (unlikely(result != VLC_SUCCESS))
+ {
+ free(picctx);
+ goto error;
+ }
+ srcY += picctx->bufferHeight;
+ dstY += p_sys->decoderHeight;
}
- srcY += picctx->bufferHeight;
- dstY += p_sys->decoderHeight;
}
p_pic->context = &picctx->ctx;
vlc_video_context_Hold(picctx->ctx.vctx);
@@ -890,11 +932,18 @@ static int OpenDecoder(vlc_object_t *p_this)
{
if (i_depth_luma >= 16)
output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE_16B;
- else if (i_depth_luma >= 10)
+ else if (i_depth_luma > 8)
output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE_10B;
else
output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE;
}
+ else if (cudaChroma == cudaVideoChromaFormat_444)
+ {
+ if (i_depth_luma > 8)
+ output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE_444_16B;
+ else
+ output_chromas[chroma_idx++] = VLC_CODEC_NVDEC_OPAQUE_444;
+ }
output_chromas[chroma_idx++] = MapSurfaceChroma(cudaChroma, i_depth_luma);
output_chromas[chroma_idx++] = 0;
diff --git a/modules/hw/nvdec/nvdec_fmt.h b/modules/hw/nvdec/nvdec_fmt.h
index f1e471c779..fda98a11bc 100644
--- a/modules/hw/nvdec/nvdec_fmt.h
+++ b/modules/hw/nvdec/nvdec_fmt.h
@@ -55,7 +55,9 @@ static inline bool is_nvdec_opaque(vlc_fourcc_t fourcc)
{
return fourcc == VLC_CODEC_NVDEC_OPAQUE ||
fourcc == VLC_CODEC_NVDEC_OPAQUE_10B ||
- fourcc == VLC_CODEC_NVDEC_OPAQUE_16B;
+ fourcc == VLC_CODEC_NVDEC_OPAQUE_16B ||
+ fourcc == VLC_CODEC_NVDEC_OPAQUE_444 ||
+ fourcc == VLC_CODEC_NVDEC_OPAQUE_444_16B;
}
/* for VLC_CODEC_NVDEC_OPAQUE / VLC_CODEC_NVDEC_OPAQUE_16B */
diff --git a/src/misc/fourcc.c b/src/misc/fourcc.c
index c1822f174e..880d6b4685 100644
--- a/src/misc/fourcc.c
+++ b/src/misc/fourcc.c
@@ -563,6 +563,8 @@ static const vlc_fourcc_t p_list_YUV[] = {
VLC_CODEC_NVDEC_OPAQUE,
VLC_CODEC_NVDEC_OPAQUE_10B,
VLC_CODEC_NVDEC_OPAQUE_16B,
+ VLC_CODEC_NVDEC_OPAQUE_444,
+ VLC_CODEC_NVDEC_OPAQUE_444_16B,
0,
};
@@ -821,6 +823,9 @@ static const struct
VLC_CODEC_NVDEC_OPAQUE_10B, VLC_CODEC_NVDEC_OPAQUE },
FAKE_FMT() },
+ { { VLC_CODEC_NVDEC_OPAQUE_444, VLC_CODEC_NVDEC_OPAQUE_444_16B },
+ FAKE_FMT() },
+
{ { VLC_CODEC_CVPX_NV12, VLC_CODEC_CVPX_UYVY,
VLC_CODEC_CVPX_I420, VLC_CODEC_CVPX_BGRA },
FAKE_FMT() },
diff --git a/src/misc/fourcc_list.h b/src/misc/fourcc_list.h
index e121b3b9a8..662ae5b24e 100644
--- a/src/misc/fourcc_list.h
+++ b/src/misc/fourcc_list.h
@@ -1235,6 +1235,12 @@ static const staticentry_t p_list_video[] = {
B(VLC_CODEC_NVDEC_OPAQUE_16B, "4:2:0 16bits NVDEC opaque"),
A("NVD6"),
+ B(VLC_CODEC_NVDEC_OPAQUE_444, "4:4:4 NVDEC opaque"),
+ A("NV48"),
+
+ B(VLC_CODEC_NVDEC_OPAQUE_444_16B, "4:4:4 16bits NVDEC opaque"),
+ A("NV46"),
+
B(VLC_CODEC_AGM, "AmuseGraphics Movie"),
A("AGM0"),
A("AGM1"),
More information about the vlc-commits
mailing list