summaryrefslogtreecommitdiff
path: root/libavutil/hwcontext_cuda.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2018-05-14 23:24:43 +0200
committerMarton Balint <cus@passwd.hu>2018-05-15 22:18:58 +0200
commit1b2471039b23f4edd3b37899b3edd1ae40c01315 (patch)
tree4b3eb8e2b4a0b3c084fccf3b82e315bd7ac50bb9 /libavutil/hwcontext_cuda.c
parent2dbe936bf7f9e0fe7e8f05e5c3b78fb1afbff164 (diff)
downloadffmpeg-1b2471039b23f4edd3b37899b3edd1ae40c01315.tar.gz
avutil/hwcontext_cuda: fix YUV420P cuda_get_buffer
Regression since ece068a771ac3f725e854c681ecbef08e792addc. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavutil/hwcontext_cuda.c')
-rw-r--r--libavutil/hwcontext_cuda.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libavutil/hwcontext_cuda.c b/libavutil/hwcontext_cuda.c
index cb5d15c9d9..3b1d53e799 100644
--- a/libavutil/hwcontext_cuda.c
+++ b/libavutil/hwcontext_cuda.c
@@ -159,10 +159,11 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
return res;
// YUV420P is a special case.
- // Nvenc expects the U/V planes in swapped order from how ffmpeg expects them.
+ // Nvenc expects the U/V planes in swapped order from how ffmpeg expects them, also chroma is half-aligned
if (ctx->sw_format == AV_PIX_FMT_YUV420P) {
- FFSWAP(uint8_t*, frame->data[1], frame->data[2]);
- FFSWAP(int, frame->linesize[1], frame->linesize[2]);
+ frame->linesize[1] = frame->linesize[2] = frame->linesize[0] / 2;
+ frame->data[2] = frame->data[1];
+ frame->data[1] = frame->data[2] + frame->linesize[2] * ctx->height / 2;
}
frame->format = AV_PIX_FMT_CUDA;