[FFmpeg-cvslog] avutil/hwcontext_cuda: fix YUV420P cuda_get_buffer
Marton Balint
git at videolan.org
Wed May 16 00:06:27 EEST 2018
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Mon May 14 23:24:43 2018 +0200| [1b2471039b23f4edd3b37899b3edd1ae40c01315] | committer: Marton Balint
avutil/hwcontext_cuda: fix YUV420P cuda_get_buffer
Regression since ece068a771ac3f725e854c681ecbef08e792addc.
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1b2471039b23f4edd3b37899b3edd1ae40c01315
---
libavutil/hwcontext_cuda.c | 7 ++++---
1 file 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;
More information about the ffmpeg-cvslog
mailing list