[vlc-devel] [PATCH 3/3] nvedc: fixed indentation
Alexandre Janniaux
ajanni at videolabs.io
Fri Mar 13 19:30:10 CET 2020
Hi,
There is a typo in the commit message,
Regards,
--
Alexandre Janniaux
Videolabs
On Fri, Mar 13, 2020 at 05:19:29PM +0100, quentin.chateau at deepskycorp.com wrote:
> From: Quentin Chateau <quentin.chateau at deepskycorp.com>
>
> ---
> modules/hw/nvdec/nvdec.c | 296 ++++++++++++++++++++-------------------
> 1 file changed, 149 insertions(+), 147 deletions(-)
>
> diff --git a/modules/hw/nvdec/nvdec.c b/modules/hw/nvdec/nvdec.c
> index 31dc06d024..e708ee998e 100644
> --- a/modules/hw/nvdec/nvdec.c
> +++ b/modules/hw/nvdec/nvdec.c
> @@ -137,8 +137,9 @@ static cudaVideoSurfaceFormat MapSurfaceFmt(int i_vlc_fourcc)
> case VLC_CODEC_NVDEC_OPAQUE_444:
> return cudaVideoSurfaceFormat_YUV444;
> case VLC_CODEC_NVDEC_OPAQUE_444_16B:
> - return cudaVideoSurfaceFormat_YUV444_16Bit;
> - default: vlc_assert_unreachable();
> + return cudaVideoSurfaceFormat_YUV444_16Bit;
> + default:
> + vlc_assert_unreachable();
> }
> }
>
> @@ -165,17 +166,17 @@ static int CUDAAPI HandleVideoSequence(void *p_opaque, CUVIDEOFORMAT *p_format)
> nvdec_ctx_t *p_sys = p_dec->p_sys;
> int ret;
>
> - for (size_t i=0; i < ARRAY_SIZE(p_sys->outputDevicePtr); i++)
> - {
> - CALL_CUDA_DEC(cuMemFree, p_sys->outputDevicePtr[i]);
> - p_sys->outputDevicePtr[i] = 0;
> - }
> + for (size_t i=0; i < ARRAY_SIZE(p_sys->outputDevicePtr); i++)
> + {
> + CALL_CUDA_DEC(cuMemFree, p_sys->outputDevicePtr[i]);
> + p_sys->outputDevicePtr[i] = 0;
> + }
>
> - if (p_sys->out_pool)
> - {
> - picture_pool_Release(p_sys->out_pool);
> - p_sys->out_pool = NULL;
> - }
> + if (p_sys->out_pool)
> + {
> + picture_pool_Release(p_sys->out_pool);
> + p_sys->out_pool = NULL;
> + }
>
> // update vlc's output format using NVDEC parser's output
> ret = CUtoFMT(&p_dec->fmt_out.video, p_format);
> @@ -214,71 +215,71 @@ static int CUDAAPI HandleVideoSequence(void *p_opaque, CUVIDEOFORMAT *p_format)
> goto error;
>
> // ensure the output surfaces have the same pitch so copies can work properly
> - // get the real decoder pitch
> - CUdeviceptr frameDevicePtr = 0;
> - CUVIDPROCPARAMS params = {
> - .progressive_frame = 1,
> - .top_field_first = 1,
> - };
> - ret = CALL_CUVID( cuvidMapVideoFrame, p_sys->cudecoder, 0, &frameDevicePtr, &p_sys->outputPitch, ¶ms );
> - if (ret != VLC_SUCCESS)
> - goto error;
> - CALL_CUVID(cuvidUnmapVideoFrame, p_sys->cudecoder, frameDevicePtr);
> + // get the real decoder pitch
> + CUdeviceptr frameDevicePtr = 0;
> + CUVIDPROCPARAMS params = {
> + .progressive_frame = 1,
> + .top_field_first = 1,
> + };
> + ret = CALL_CUVID( cuvidMapVideoFrame, p_sys->cudecoder, 0, &frameDevicePtr, &p_sys->outputPitch, ¶ms );
> + if (ret != VLC_SUCCESS)
> + goto error;
> + CALL_CUVID(cuvidUnmapVideoFrame, p_sys->cudecoder, frameDevicePtr);
>
> - unsigned int ByteWidth = p_sys->outputPitch;
> - unsigned int Height = p_dec->fmt_out.video.i_height;
> - 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();
> - }
> + unsigned int ByteWidth = p_sys->outputPitch;
> + unsigned int Height = p_dec->fmt_out.video.i_height;
> + 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++)
> + picture_t *pics[ARRAY_SIZE(p_sys->outputDevicePtr)];
> + for (size_t i=0; i < ARRAY_SIZE(p_sys->outputDevicePtr); i++)
> + {
> + ret = CALL_CUDA_DEC(cuMemAlloc, &p_sys->outputDevicePtr[i], ByteWidth * Height);
> + if (ret != VLC_SUCCESS || p_sys->outputDevicePtr[i] == 0)
> + goto clean_pics;
> + picture_resource_t res = {
> + .p_sys = (void*)(uintptr_t)i,
> + };
> + pics[i] = picture_NewFromResource( &p_dec->fmt_out.video, &res );
> + if (unlikely(pics[i] == NULL))
> {
> - ret = CALL_CUDA_DEC(cuMemAlloc, &p_sys->outputDevicePtr[i], ByteWidth * Height);
> - if (ret != VLC_SUCCESS || p_sys->outputDevicePtr[i] == 0)
> - goto clean_pics;
> - picture_resource_t res = {
> - .p_sys = (void*)(uintptr_t)i,
> - };
> - pics[i] = picture_NewFromResource( &p_dec->fmt_out.video, &res );
> - if (unlikely(pics[i] == NULL))
> - {
> - msg_Dbg(p_dec, "failed to get a picture for the buffer");
> - ret = VLC_ENOMEM;
> - goto clean_pics;
> - }
> - continue;
> + msg_Dbg(p_dec, "failed to get a picture for the buffer");
> + ret = VLC_ENOMEM;
> + goto clean_pics;
> + }
> + continue;
> clean_pics:
> - if (p_sys->outputDevicePtr[i])
> + if (p_sys->outputDevicePtr[i])
> + {
> + CALL_CUDA_DEC(cuMemFree, p_sys->outputDevicePtr[i]);
> + p_sys->outputDevicePtr[i] = 0;
> + }
> + if (i > 0)
> + {
> + while (i--)
> {
> + picture_Release(pics[i]);
> CALL_CUDA_DEC(cuMemFree, p_sys->outputDevicePtr[i]);
> p_sys->outputDevicePtr[i] = 0;
> }
> - if (i > 0)
> - {
> - while (i--)
> - {
> - picture_Release(pics[i]);
> - CALL_CUDA_DEC(cuMemFree, p_sys->outputDevicePtr[i]);
> - p_sys->outputDevicePtr[i] = 0;
> - }
> - }
> - break;
> }
> - if (ret != VLC_SUCCESS)
> - goto error;
> + break;
> + }
> + if (ret != VLC_SUCCESS)
> + goto error;
>
> - p_sys->out_pool = picture_pool_New( ARRAY_SIZE(p_sys->outputDevicePtr), pics );
> + p_sys->out_pool = picture_pool_New( ARRAY_SIZE(p_sys->outputDevicePtr), pics );
> p_sys->decoderHeight = p_format->coded_height;
>
> CALL_CUDA_DEC(cuCtxPopCurrent, NULL);
> @@ -339,94 +340,95 @@ static int CUDAAPI HandlePictureDisplay(void *p_opaque, CUVIDPARSERDISPINFO *p_d
> };
> int result;
>
> - p_pic = picture_pool_Wait(p_sys->out_pool);
> - if (unlikely(p_pic == NULL))
> - return 0;
> + p_pic = picture_pool_Wait(p_sys->out_pool);
> + if (unlikely(p_pic == NULL))
> + return 0;
>
> - result = CALL_CUDA_DEC(cuCtxPushCurrent, p_sys->cuCtx);
> - if (unlikely(result != VLC_SUCCESS))
> - {
> - picture_Release(p_pic);
> - return 0;
> - }
> + result = CALL_CUDA_DEC(cuCtxPushCurrent, p_sys->cuCtx);
> + if (unlikely(result != VLC_SUCCESS))
> + {
> + picture_Release(p_pic);
> + return 0;
> + }
>
> - unsigned int i_pitch;
> + unsigned int i_pitch;
>
> - // Map decoded frame to a device pointer
> - result = CALL_CUVID( cuvidMapVideoFrame, p_sys->cudecoder, p_dispinfo->picture_index,
> - &frameDevicePtr, &i_pitch, ¶ms );
> - if (result != VLC_SUCCESS)
> - goto error;
> + // Map decoded frame to a device pointer
> + result = CALL_CUVID( cuvidMapVideoFrame, p_sys->cudecoder, p_dispinfo->picture_index,
> + &frameDevicePtr, &i_pitch, ¶ms );
> + if (result != VLC_SUCCESS)
> + goto error;
>
> - // put a new context in the output picture
> - pic_context_nvdec_t *picctx = malloc(sizeof(*picctx));
> - if (unlikely(picctx == NULL))
> - goto error;
> - picctx->ctx = (picture_context_t) {
> - NVDecCtxDestroy, NVDecCtxClone,
> - p_sys->vctx_out,
> - };
> - uintptr_t pool_idx = (uintptr_t)p_pic->p_sys;
> - picctx->devicePtr = p_sys->outputDevicePtr[pool_idx];
> - picctx->bufferPitch = p_sys->outputPitch;
> - picctx->bufferHeight = p_sys->decoderHeight;
> -
> - size_t srcY = 0;
> - size_t dstY = 0;
> - 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->devicePtr,
> - .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;
> + // put a new context in the output picture
> + pic_context_nvdec_t *picctx = malloc(sizeof(*picctx));
> + if (unlikely(picctx == NULL))
> + goto error;
> + picctx->ctx = (picture_context_t) {
> + NVDecCtxDestroy, NVDecCtxClone,
> + p_sys->vctx_out,
> + };
> + uintptr_t pool_idx = (uintptr_t)p_pic->p_sys;
> + picctx->devicePtr = p_sys->outputDevicePtr[pool_idx];
> + picctx->bufferPitch = p_sys->outputPitch;
> + picctx->bufferHeight = p_sys->decoderHeight;
> +
> + size_t srcY = 0;
> + size_t dstY = 0;
> + 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->devicePtr,
> + .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->devicePtr,
> - .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;
> + }
> + 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->devicePtr,
> + .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;
> }
> - p_pic->context = &picctx->ctx;
> - vlc_video_context_Hold(picctx->ctx.vctx);
> + }
> +
> + p_pic->context = &picctx->ctx;
> + vlc_video_context_Hold(picctx->ctx.vctx);
>
> // Release surface on GPU
> result = CALL_CUVID(cuvidUnmapVideoFrame, p_sys->cudecoder, frameDevicePtr);
> --
> 2.17.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list