FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
cuvid.c File Reference
#include "libavutil/buffer.h"
#include "libavutil/mathematics.h"
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda.h"
#include "libavutil/fifo.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include "compat/cuda/nvcuvid.h"

Go to the source code of this file.

Data Structures

struct  CuvidContext
 
struct  CuvidParsedFrame
 

Macros

#define MAX_FRAME_COUNT   25
 
#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_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_dummy_decoder (AVCodecContext *avctx, CUVIDPARSERPARAMS *cuparseinfo)
 
static av_cold int cuvid_decode_init (AVCodecContext *avctx)
 
static void cuvid_flush (AVCodecContext *avctx)
 

Variables

static const AVOption options []
 

Macro Definition Documentation

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

Definition at line 851 of file cuvid.c.

Definition at line 852 of file cuvid.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, \
}; \
AVHWAccel ff_##x##_cuvid_hwaccel = { \
.name = #x "_cuvid", \
.type = AVMEDIA_TYPE_VIDEO, \
.id = AV_CODEC_ID_##X, \
.pix_fmt = AV_PIX_FMT_CUDA, \
}; \
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, \
};
static void flush(AVCodecContext *avctx)
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static CopyRet receive_frame(AVCodecContext *avctx, void *data, int *got_frame)
Definition: crystalhd.c:785
static void cuvid_flush(AVCodecContext *avctx)
Definition: cuvid.c:795
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:984
static int cuvid_decode_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Definition: cuvid.c:255
static av_cold int cuvid_decode_init(AVCodecContext *avctx)
Definition: cuvid.c:597
static av_cold int cuvid_decode_end(AVCodecContext *avctx)
Definition: cuvid.c:536
av_default_item_name
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:176
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:90
static int cuvid_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: cuvid.c:505
static void send_packet(AVFormatContext *ctx, uint8_t parse_code, int info_hdr_size, const uint8_t *buf, int size, int i, int f, int rtp_m)
Definition: rtpenc_vc2hq.c:36
HW acceleration through CUDA.
Definition: pixfmt.h:249
Describe the class of an AVClass context structure.
Definition: log.h:67
static const AVOption options[]
Definition: cuvid.c:853
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:262
static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame)
Definition: cuvid.c:345
#define AV_CODEC_CAP_AVOID_PROBING
Decoder is not a preferred choice for probing.
Definition: avcodec.h:1048
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
Definition: ffmpeg.c:2035
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60

Definition at line 862 of file cuvid.c.

Function Documentation

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

Definition at line 73 of file cuvid.c.

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

Definition at line 96 of file cuvid.c.

Referenced by cuvid_decode_init().

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

Definition at line 221 of file cuvid.c.

Referenced by cuvid_decode_init().

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

Definition at line 235 of file cuvid.c.

Referenced by cuvid_decode_init().

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

Definition at line 255 of file cuvid.c.

Referenced by cuvid_decode_frame(), and cuvid_output_frame().

static int cuvid_output_frame ( AVCodecContext avctx,
AVFrame frame 
)
static

Definition at line 345 of file cuvid.c.

Referenced by cuvid_decode_frame().

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

Definition at line 505 of file cuvid.c.

static av_cold int cuvid_decode_end ( AVCodecContext avctx)
static

Definition at line 536 of file cuvid.c.

Referenced by cuvid_decode_init().

static int cuvid_test_dummy_decoder ( AVCodecContext avctx,
CUVIDPARSERPARAMS cuparseinfo 
)
static

Definition at line 557 of file cuvid.c.

Referenced by cuvid_decode_init().

static av_cold int cuvid_decode_init ( AVCodecContext avctx)
static

Definition at line 597 of file cuvid.c.

static void cuvid_flush ( AVCodecContext avctx)
static

Definition at line 795 of file cuvid.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 },
{ NULL }
}
#define NULL
Definition: coverity.c:32
Drop one field.
Definition: cuviddec.h:99
Weave both fields (no deinterlacing)
Definition: cuviddec.h:98
Adaptive deinterlacing.
Definition: cuviddec.h:100
#define VD
Definition: cuvid.c:852
#define OFFSET(x)
Definition: cuvid.c:851

Definition at line 853 of file cuvid.c.