1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avutil/hwcontext_cuda: fix YUV420P cuda_get_buffer

Regression since ece068a771.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint 2018-05-14 23:24:43 +02:00
parent 2dbe936bf7
commit 1b2471039b

View File

@ -159,10 +159,11 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
return res; return res;
// YUV420P is a special case. // 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) { if (ctx->sw_format == AV_PIX_FMT_YUV420P) {
FFSWAP(uint8_t*, frame->data[1], frame->data[2]); frame->linesize[1] = frame->linesize[2] = frame->linesize[0] / 2;
FFSWAP(int, frame->linesize[1], frame->linesize[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; frame->format = AV_PIX_FMT_CUDA;