FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
cuviddec.c File Reference
#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/fifo.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "decode.h"
#include "hwaccel.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  CuvidContext
 
struct  CuvidParsedFrame
 

Macros

#define CHECK_CU(x)   check_cu(avctx, (x), #x)
 
#define OFFSET(x)   offsetof(CuvidContext, x)
 
#define VD   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 
#define DEFINE_CUVID_CODEC(x, X)
 

Functions

static int check_cu (AVCodecContext *avctx, CUresult err, const char *func)
 
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 int cuvid_decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 
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
cuvid_hw_configs []
 

Macro Definition Documentation

#define CHECK_CU (   x)    check_cu(avctx, (x), #x)
#define OFFSET (   x)    offsetof(CuvidContext, x)

Definition at line 1104 of file cuviddec.c.

Definition at line 1105 of file cuviddec.c.

#define DEFINE_CUVID_CODEC (   x,
 
)
Value:
static const AVClass x##_cuvid_class = { \
.class_name = #x "_cuvid", \
.item_name = av_default_item_name, \
.option = options, \
.version = LIBAVUTIL_VERSION_INT, \
}; \
AVCodec ff_##x##_cuvid_decoder = { \
.name = #x "_cuvid", \
.long_name = NULL_IF_CONFIG_SMALL("Nvidia CUVID " #X " decoder"), \
.type = AVMEDIA_TYPE_VIDEO, \
.id = AV_CODEC_ID_##X, \
.priv_data_size = sizeof(CuvidContext), \
.priv_class = &x##_cuvid_class, \
.close = cuvid_decode_end, \
.hw_configs = cuvid_hw_configs, \
.wrapper_name = "cuvid", \
};
static void flush(AVCodecContext *avctx)
static av_cold int cuvid_decode_init(AVCodecContext *avctx)
Definition: cuviddec.c:804
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: avcodec.h:1065
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
static av_cold int cuvid_decode_end(AVCodecContext *avctx)
Definition: cuviddec.c:689
static CopyRet receive_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame)
Definition: crystalhd.c:560
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
#define AV_PIX_FMT_P016
Definition: pixfmt.h:427
#define AV_PIX_FMT_P010
Definition: pixfmt.h:426
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:72
#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: avcodec.h:993
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:89
static void cuvid_flush(AVCodecContext *avctx)
Definition: cuviddec.c:1048
static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame)
Definition: cuviddec.c:478
HW acceleration through CUDA.
Definition: pixfmt.h:235
static int cuvid_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: cuviddec.c:658
static const AVOption options[]
Definition: cuviddec.c:1106
static const AVCodecHWConfigInternal * cuvid_hw_configs[]
Definition: cuviddec.c:1119
Describe the class of an AVClass context structure.
Definition: log.h:67
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: avcodec.h:1050
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64

Definition at line 1132 of file cuviddec.c.

Function Documentation

static int check_cu ( AVCodecContext avctx,
CUresult  err,
const char *  func 
)
static

Definition at line 98 of file cuviddec.c.

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

Definition at line 122 of file cuviddec.c.

Referenced by cuvid_decode_init().

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

Definition at line 338 of file cuviddec.c.

Referenced by cuvid_decode_init().

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

Definition at line 354 of file cuviddec.c.

Referenced by cuvid_decode_init().

static int cuvid_is_buffer_full ( AVCodecContext avctx)
static

Definition at line 377 of file cuviddec.c.

Referenced by cuvid_output_frame().

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

Definition at line 388 of file cuviddec.c.

Referenced by cuvid_decode_frame(), and cuvid_output_frame().

static int cuvid_output_frame ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 478 of file cuviddec.c.

Referenced by cuvid_decode_frame().

static int cuvid_decode_frame ( AVCodecContext avctx,
void data,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 658 of file cuviddec.c.

static av_cold int cuvid_decode_end ( AVCodecContext avctx)
static

Definition at line 689 of file cuviddec.c.

Referenced by cuvid_decode_init().

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

Definition at line 716 of file cuviddec.c.

Referenced by cuvid_decode_init().

static av_cold int cuvid_decode_init ( AVCodecContext avctx)
static

Definition at line 804 of file cuviddec.c.

static void cuvid_flush ( AVCodecContext avctx)
static

Definition at line 1048 of file cuviddec.c.

Variable Documentation

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, "deint" },
{ "weave", "Weave deinterlacing (do nothing)", 0, AV_OPT_TYPE_CONST, { .i64 = cudaVideoDeinterlaceMode_Weave }, 0, 0, VD, "deint" },
{ "bob", "Bob deinterlacing", 0, AV_OPT_TYPE_CONST, { .i64 = cudaVideoDeinterlaceMode_Bob }, 0, 0, VD, "deint" },
{ "adaptive", "Adaptive deinterlacing", 0, AV_OPT_TYPE_CONST, { .i64 = cudaVideoDeinterlaceMode_Adaptive }, 0, 0, VD, "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 = 25 }, 0, INT_MAX, VD },
{ "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 }
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
Definition: cuviddec.c:1104
#define VD
Definition: cuviddec.c:1105

Definition at line 1106 of file cuviddec.c.

const AVCodecHWConfigInternal* cuvid_hw_configs[]
static
Initial value:
= {
.public = {
.pix_fmt = AV_PIX_FMT_CUDA,
.device_type = AV_HWDEVICE_TYPE_CUDA
},
.hwaccel = NULL,
},
}
#define NULL
Definition: coverity.c:32
The codec supports this format by some internal method.
Definition: avcodec.h:3386
The codec supports this format via the hw_device_ctx interface.
Definition: avcodec.h:3370
HW acceleration through CUDA.
Definition: pixfmt.h:235

Definition at line 1119 of file cuviddec.c.