FFmpeg
Data Structures | Macros | Functions | Variables
cuviddec.c File Reference
#include "config_components.h"
#include "compat/cuda/dynlink_loader.h"
#include "libavutil/buffer.h"
#include "libavutil/mathematics.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/cuda_check.h"
#include "libavutil/fifo.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "bsf.h"
#include "codec_internal.h"
#include "decode.h"
#include "hwconfig.h"
#include "nvdec.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  CuvidContext
 
struct  CuvidParsedFrame
 

Macros

#define cudaVideoSurfaceFormat_YUV444   2
 
#define cudaVideoSurfaceFormat_YUV444_16Bit   3
 
#define CHECK_CU(x)   FF_CUDA_CHECK_DL(avctx, ctx->cudl, x)
 
#define CUVID_MAX_DISPLAY_DELAY   (4)
 
#define CUVID_DEFAULT_NUM_SURFACES   (CUVID_MAX_DISPLAY_DELAY + 1)
 
#define OFFSET(x)   offsetof(CuvidContext, x)
 
#define VD   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 
#define DEFINE_CUVID_CODEC(x, X, bsf_name)
 

Functions

static int CUDAAPI cuvid_handle_video_sequence (void *opaque, CUVIDEOFORMAT *format)
 
static int CUDAAPI cuvid_handle_picture_decode (void *opaque, CUVIDPICPARAMS *picparams)
 
static int CUDAAPI cuvid_handle_picture_display (void *opaque, CUVIDPARSERDISPINFO *dispinfo)
 
static int cuvid_is_buffer_full (AVCodecContext *avctx)
 
static int cuvid_decode_packet (AVCodecContext *avctx, const AVPacket *avpkt)
 
static int cuvid_output_frame (AVCodecContext *avctx, AVFrame *frame)
 
static av_cold int cuvid_decode_end (AVCodecContext *avctx)
 
static int cuvid_test_capabilities (AVCodecContext *avctx, const CUVIDPARSERPARAMS *cuparseinfo, int probed_width, int probed_height, int bit_depth)
 
static av_cold int cuvid_decode_init (AVCodecContext *avctx)
 
static void cuvid_flush (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 
static const AVCodecHWConfigInternal *const cuvid_hw_configs []
 

Macro Definition Documentation

◆ cudaVideoSurfaceFormat_YUV444

#define cudaVideoSurfaceFormat_YUV444   2

Definition at line 45 of file cuviddec.c.

◆ cudaVideoSurfaceFormat_YUV444_16Bit

#define cudaVideoSurfaceFormat_YUV444_16Bit   3

Definition at line 46 of file cuviddec.c.

◆ CHECK_CU

#define CHECK_CU (   x)    FF_CUDA_CHECK_DL(avctx, ctx->cudl, x)

Definition at line 116 of file cuviddec.c.

◆ CUVID_MAX_DISPLAY_DELAY

#define CUVID_MAX_DISPLAY_DELAY   (4)

Definition at line 119 of file cuviddec.c.

◆ CUVID_DEFAULT_NUM_SURFACES

#define CUVID_DEFAULT_NUM_SURFACES   (CUVID_MAX_DISPLAY_DELAY + 1)

Definition at line 122 of file cuviddec.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(CuvidContext, x)

Definition at line 1127 of file cuviddec.c.

◆ VD

Definition at line 1128 of file cuviddec.c.

◆ DEFINE_CUVID_CODEC

#define DEFINE_CUVID_CODEC (   x,
  X,
  bsf_name 
)
Value:
static const AVClass x##_cuvid_class = { \
.class_name = #x "_cuvid", \
.item_name = av_default_item_name, \
.option = options, \
.version = LIBAVUTIL_VERSION_INT, \
}; \
const FFCodec ff_##x##_cuvid_decoder = { \
.p.name = #x "_cuvid", \
CODEC_LONG_NAME("Nvidia CUVID " #X " decoder"), \
.p.type = AVMEDIA_TYPE_VIDEO, \
.p.id = AV_CODEC_ID_##X, \
.priv_data_size = sizeof(CuvidContext), \
.p.priv_class = &x##_cuvid_class, \
.init = cuvid_decode_init, \
.close = cuvid_decode_end, \
.flush = cuvid_flush, \
.bsfs = bsf_name, \
.caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE | \
FF_CODEC_CAP_SETS_FRAME_PROPS, \
.hw_configs = cuvid_hw_configs, \
.p.wrapper_name = "cuvid", \
};

Definition at line 1155 of file cuviddec.c.

Function Documentation

◆ cuvid_handle_video_sequence()

static int CUDAAPI cuvid_handle_video_sequence ( void *  opaque,
CUVIDEOFORMAT *  format 
)
static

Definition at line 124 of file cuviddec.c.

Referenced by cuvid_decode_init().

◆ cuvid_handle_picture_decode()

static int CUDAAPI cuvid_handle_picture_decode ( void *  opaque,
CUVIDPICPARAMS *  picparams 
)
static

Definition at line 371 of file cuviddec.c.

Referenced by cuvid_decode_init().

◆ cuvid_handle_picture_display()

static int CUDAAPI cuvid_handle_picture_display ( void *  opaque,
CUVIDPARSERDISPINFO *  dispinfo 
)
static

Definition at line 388 of file cuviddec.c.

Referenced by cuvid_decode_init().

◆ cuvid_is_buffer_full()

static int cuvid_is_buffer_full ( AVCodecContext avctx)
static

Definition at line 414 of file cuviddec.c.

Referenced by cuvid_decode_packet(), and cuvid_output_frame().

◆ cuvid_decode_packet()

static int cuvid_decode_packet ( AVCodecContext avctx,
const AVPacket avpkt 
)
static

Definition at line 425 of file cuviddec.c.

Referenced by cuvid_output_frame().

◆ cuvid_output_frame()

static int cuvid_output_frame ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 490 of file cuviddec.c.

◆ cuvid_decode_end()

static av_cold int cuvid_decode_end ( AVCodecContext avctx)
static

Definition at line 694 of file cuviddec.c.

Referenced by cuvid_decode_init().

◆ cuvid_test_capabilities()

static int cuvid_test_capabilities ( AVCodecContext avctx,
const CUVIDPARSERPARAMS *  cuparseinfo,
int  probed_width,
int  probed_height,
int  bit_depth 
)
static

Definition at line 728 of file cuviddec.c.

Referenced by cuvid_decode_init().

◆ cuvid_decode_init()

static av_cold int cuvid_decode_init ( AVCodecContext avctx)
static

Definition at line 822 of file cuviddec.c.

◆ cuvid_flush()

static void cuvid_flush ( AVCodecContext avctx)
static

Definition at line 1077 of file cuviddec.c.

Variable Documentation

◆ options

const AVOption options[]
static
Initial value:
= {
{ "deint", "Set deinterlacing mode", OFFSET(deint_mode), AV_OPT_TYPE_INT, { .i64 = cudaVideoDeinterlaceMode_Weave }, cudaVideoDeinterlaceMode_Weave, cudaVideoDeinterlaceMode_Adaptive, VD, .unit = "deint" },
{ "weave", "Weave deinterlacing (do nothing)", 0, AV_OPT_TYPE_CONST, { .i64 = cudaVideoDeinterlaceMode_Weave }, 0, 0, VD, .unit = "deint" },
{ "bob", "Bob deinterlacing", 0, AV_OPT_TYPE_CONST, { .i64 = cudaVideoDeinterlaceMode_Bob }, 0, 0, VD, .unit = "deint" },
{ "adaptive", "Adaptive deinterlacing", 0, AV_OPT_TYPE_CONST, { .i64 = cudaVideoDeinterlaceMode_Adaptive }, 0, 0, VD, .unit = "deint" },
{ "gpu", "GPU to be used for decoding", OFFSET(cu_gpu), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD },
{ "surfaces", "Maximum surfaces to be used for decoding", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, VD | AV_OPT_FLAG_DEPRECATED },
{ "drop_second_field", "Drop second field when deinterlacing", OFFSET(drop_second_field), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
{ "crop", "Crop (top)x(bottom)x(left)x(right)", OFFSET(crop_expr), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD },
{ "resize", "Resize (width)x(height)", OFFSET(resize_expr), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD },
{ NULL }
}

Definition at line 1129 of file cuviddec.c.

◆ cuvid_hw_configs

const AVCodecHWConfigInternal* const cuvid_hw_configs[]
static
Initial value:
= {
.public = {
.pix_fmt = AV_PIX_FMT_CUDA,
.device_type = AV_HWDEVICE_TYPE_CUDA
},
.hwaccel = NULL,
},
}

Definition at line 1142 of file cuviddec.c.

AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:260
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:145
AV_CODEC_HW_CONFIG_METHOD_INTERNAL
@ AV_CODEC_HW_CONFIG_METHOD_INTERNAL
The codec supports this format by some internal method.
Definition: codec.h:322
cuvid_output_frame
static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame)
Definition: cuviddec.c:490
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:34
FFCodec
Definition: codec_internal.h:127
options
static const AVOption options[]
Definition: cuviddec.c:1129
AV_HWDEVICE_TYPE_CUDA
@ AV_HWDEVICE_TYPE_CUDA
Definition: hwcontext.h:30
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
@ AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX
The codec supports this format via the hw_device_ctx interface.
Definition: codec.h:302
CuvidContext
Definition: cuviddec.c:53
cuvid_hw_configs
static const AVCodecHWConfigInternal *const cuvid_hw_configs[]
Definition: cuviddec.c:1142
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
NULL
#define NULL
Definition: coverity.c:32
VD
#define VD
Definition: cuviddec.c:1128
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
X
@ X
Definition: vf_addroi.c:27
cuvid_decode_init
static av_cold int cuvid_decode_init(AVCodecContext *avctx)
Definition: cuviddec.c:822
cuvid_decode_end
static av_cold int cuvid_decode_end(AVCodecContext *avctx)
Definition: cuviddec.c:694
AVCodecHWConfigInternal
Definition: hwconfig.h:25
AV_OPT_FLAG_DEPRECATED
#define AV_OPT_FLAG_DEPRECATED
Set if option is deprecated, users should refer to AVOption.help text for more information.
Definition: opt.h:303
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
FF_CODEC_RECEIVE_FRAME_CB
#define FF_CODEC_RECEIVE_FRAME_CB(func)
Definition: codec_internal.h:293
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
OFFSET
#define OFFSET(x)
Definition: cuviddec.c:1127
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
cuvid_flush
static void cuvid_flush(AVCodecContext *avctx)
Definition: cuviddec.c:1077
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
AV_CODEC_CAP_AVOID_PROBING
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: codec.h:138
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244