Commit 8d6c358e authored by Philip Langdale's avatar Philip Langdale

libavutil/hwcontext_cuda: Support P010 and P016 formats

CUVID is now capable of returning 10bit and 12bit decoded content
in P010/P016. Let's support transfering those formats.
parent 237421f1
...@@ -35,6 +35,8 @@ static const enum AVPixelFormat supported_formats[] = { ...@@ -35,6 +35,8 @@ static const enum AVPixelFormat supported_formats[] = {
AV_PIX_FMT_NV12, AV_PIX_FMT_NV12,
AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV420P,
AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P,
AV_PIX_FMT_P010,
AV_PIX_FMT_P016,
}; };
static void cuda_buffer_free(void *opaque, uint8_t *data) static void cuda_buffer_free(void *opaque, uint8_t *data)
...@@ -111,6 +113,8 @@ static int cuda_frames_init(AVHWFramesContext *ctx) ...@@ -111,6 +113,8 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
size = aligned_width * ctx->height * 3 / 2; size = aligned_width * ctx->height * 3 / 2;
break; break;
case AV_PIX_FMT_YUV444P: case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_P010:
case AV_PIX_FMT_P016:
size = aligned_width * ctx->height * 3; size = aligned_width * ctx->height * 3;
break; break;
} }
...@@ -125,7 +129,14 @@ static int cuda_frames_init(AVHWFramesContext *ctx) ...@@ -125,7 +129,14 @@ static int cuda_frames_init(AVHWFramesContext *ctx)
static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
{ {
int aligned_width = FFALIGN(ctx->width, CUDA_FRAME_ALIGNMENT); int aligned_width;
int width_in_bytes = ctx->width;
if (ctx->sw_format == AV_PIX_FMT_P010 ||
ctx->sw_format == AV_PIX_FMT_P016) {
width_in_bytes *= 2;
}
aligned_width = FFALIGN(width_in_bytes, CUDA_FRAME_ALIGNMENT);
frame->buf[0] = av_buffer_pool_get(ctx->pool); frame->buf[0] = av_buffer_pool_get(ctx->pool);
if (!frame->buf[0]) if (!frame->buf[0])
...@@ -133,6 +144,8 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame) ...@@ -133,6 +144,8 @@ static int cuda_get_buffer(AVHWFramesContext *ctx, AVFrame *frame)
switch (ctx->sw_format) { switch (ctx->sw_format) {
case AV_PIX_FMT_NV12: case AV_PIX_FMT_NV12:
case AV_PIX_FMT_P010:
case AV_PIX_FMT_P016:
frame->data[0] = frame->buf[0]->data; frame->data[0] = frame->buf[0]->data;
frame->data[1] = frame->data[0] + aligned_width * ctx->height; frame->data[1] = frame->data[0] + aligned_width * ctx->height;
frame->linesize[0] = aligned_width; frame->linesize[0] = aligned_width;
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
#define LIBAVUTIL_VERSION_MAJOR 55 #define LIBAVUTIL_VERSION_MAJOR 55
#define LIBAVUTIL_VERSION_MINOR 41 #define LIBAVUTIL_VERSION_MINOR 41
#define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \ LIBAVUTIL_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment