Skip to content

Commit

Permalink
avutil/hwcontext_cuda: add support for nvenc rgb formats
Browse files Browse the repository at this point in the history
  • Loading branch information
BtbN committed May 9, 2018
1 parent 93d1756 commit 41a1898
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions libavutil/hwcontext_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ static const enum AVPixelFormat supported_formats[] = {
AV_PIX_FMT_P010,
AV_PIX_FMT_P016,
AV_PIX_FMT_YUV444P16,
AV_PIX_FMT_0RGB32,
AV_PIX_FMT_0BGR32,
};

static int cuda_frames_get_constraints(AVHWDeviceContext *ctx,
Expand Down Expand Up @@ -146,6 +148,10 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
case AV_PIX_FMT_YUV444P16:
size = aligned_width * ctx->height * 6;
break;
case AV_PIX_FMT_0RGB32:
case AV_PIX_FMT_0BGR32:
size = aligned_width * ctx->height * 4;
break;
default:
av_log(ctx, AV_LOG_ERROR, "BUG: Pixel format missing from size calculation.");
return AVERROR_BUG;
Expand Down Expand Up @@ -201,6 +207,11 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
frame->linesize[1] = aligned_width;
frame->linesize[2] = aligned_width;
break;
case AV_PIX_FMT_0BGR32:
case AV_PIX_FMT_0RGB32:
frame->data[0] = frame->buf[0]->data;
frame->linesize[0] = aligned_width * 4;
break;
default:
av_frame_unref(frame);
return AVERROR_BUG;
Expand Down
2 changes: 1 addition & 1 deletion libavutil/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

#define LIBAVUTIL_VERSION_MAJOR 56
#define LIBAVUTIL_VERSION_MINOR 18
#define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_MICRO 102

#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
Expand Down

1 comment on commit 41a1898

@ancientstraits
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was this easy?

Please sign in to comment.