FFmpeg
Data Structures | Macros | Functions | Variables
vf_thumbnail_cuda.c File Reference
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.h"
#include "libavutil/cuda_check.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "internal.h"
#include "cuda/load_helper.h"

Go to the source code of this file.

Data Structures

struct  thumb_frame
 
struct  ThumbnailCudaContext
 

Macros

#define CHECK_CU(x)   FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
 
#define HIST_SIZE   (3*256)
 
#define DIV_UP(a, b)   ( ((a) + (b) - 1) / (b) )
 
#define BLOCKX   32
 
#define BLOCKY   16
 
#define OFFSET(x)   offsetof(ThumbnailCudaContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (thumbnail_cuda)
 
static av_cold int init (AVFilterContext *ctx)
 
static double frame_sum_square_err (const int *hist, const double *median)
 Compute Sum-square deviation to estimate "closeness". More...
 
static AVFrameget_best_frame (AVFilterContext *ctx)
 
static int thumbnail_kernel (AVFilterContext *ctx, CUfunction func, int channels, int *histogram, uint8_t *src_dptr, int src_width, int src_height, int src_pitch, int pixel_size)
 
static int thumbnail (AVFilterContext *ctx, int *histogram, AVFrame *in)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int request_frame (AVFilterLink *link)
 
static int format_is_supported (enum AVPixelFormat fmt)
 
static int config_props (AVFilterLink *inlink)
 

Variables

static enum AVPixelFormat supported_formats []
 
static const AVOption thumbnail_cuda_options []
 
static const AVFilterPad thumbnail_cuda_inputs []
 
static const AVFilterPad thumbnail_cuda_outputs []
 
const AVFilter ff_vf_thumbnail_cuda
 

Macro Definition Documentation

◆ CHECK_CU

#define CHECK_CU (   x)    FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)

Definition at line 34 of file vf_thumbnail_cuda.c.

◆ HIST_SIZE

#define HIST_SIZE   (3*256)

Definition at line 36 of file vf_thumbnail_cuda.c.

◆ DIV_UP

#define DIV_UP (   a,
  b 
)    ( ((a) + (b) - 1) / (b) )

Definition at line 37 of file vf_thumbnail_cuda.c.

◆ BLOCKX

#define BLOCKX   32

Definition at line 38 of file vf_thumbnail_cuda.c.

◆ BLOCKY

#define BLOCKY   16

Definition at line 39 of file vf_thumbnail_cuda.c.

◆ OFFSET

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

Definition at line 77 of file vf_thumbnail_cuda.c.

◆ FLAGS

Definition at line 78 of file vf_thumbnail_cuda.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( thumbnail_cuda  )

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 87 of file vf_thumbnail_cuda.c.

◆ frame_sum_square_err()

static double frame_sum_square_err ( const int hist,
const double median 
)
static

Compute Sum-square deviation to estimate "closeness".

Parameters
histcolor distribution histogram
medianaverage color distribution histogram
Returns
sum of squared errors

Definition at line 107 of file vf_thumbnail_cuda.c.

Referenced by get_best_frame().

◆ get_best_frame()

static AVFrame* get_best_frame ( AVFilterContext ctx)
static

Definition at line 119 of file vf_thumbnail_cuda.c.

Referenced by request_frame().

◆ thumbnail_kernel()

static int thumbnail_kernel ( AVFilterContext ctx,
CUfunction  func,
int  channels,
int histogram,
uint8_t *  src_dptr,
int  src_width,
int  src_height,
int  src_pitch,
int  pixel_size 
)
static

Definition at line 159 of file vf_thumbnail_cuda.c.

Referenced by thumbnail().

◆ thumbnail()

static int thumbnail ( AVFilterContext ctx,
int histogram,
AVFrame in 
)
static

Definition at line 199 of file vf_thumbnail_cuda.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 249 of file vf_thumbnail_cuda.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 305 of file vf_thumbnail_cuda.c.

◆ request_frame()

static int request_frame ( AVFilterLink link)
static

Definition at line 330 of file vf_thumbnail_cuda.c.

◆ format_is_supported()

static int format_is_supported ( enum AVPixelFormat  fmt)
static

Definition at line 347 of file vf_thumbnail_cuda.c.

Referenced by config_props().

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 357 of file vf_thumbnail_cuda.c.

Variable Documentation

◆ supported_formats

enum AVPixelFormat supported_formats[]
static

◆ thumbnail_cuda_options

const AVOption thumbnail_cuda_options[]
static
Initial value:
= {
{ "n", "set the frames batch size", OFFSET(n_frames), AV_OPT_TYPE_INT, {.i64=100}, 2, INT_MAX, FLAGS },
{ NULL }
}

Definition at line 80 of file vf_thumbnail_cuda.c.

◆ thumbnail_cuda_inputs

const AVFilterPad thumbnail_cuda_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_props,
.filter_frame = filter_frame,
},
}

Definition at line 419 of file vf_thumbnail_cuda.c.

◆ thumbnail_cuda_outputs

const AVFilterPad thumbnail_cuda_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
},
}

Definition at line 428 of file vf_thumbnail_cuda.c.

◆ ff_vf_thumbnail_cuda

const AVFilter ff_vf_thumbnail_cuda
Initial value:
= {
.name = "thumbnail_cuda",
.description = NULL_IF_CONFIG_SMALL("Select the most representative frame in a given sequence of consecutive frames."),
.priv_size = sizeof(ThumbnailCudaContext),
.init = init,
.priv_class = &thumbnail_cuda_class,
.flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
}

Definition at line 436 of file vf_thumbnail_cuda.c.

AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:253
FF_FILTER_FLAG_HWFRAME_AWARE
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition: internal.h:374
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_thumbnail_cuda.c:249
thumbnail_cuda_inputs
static const AVFilterPad thumbnail_cuda_inputs[]
Definition: vf_thumbnail_cuda.c:419
config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_thumbnail_cuda.c:357
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_thumbnail_cuda.c:330
FLAGS
#define FLAGS
Definition: vf_thumbnail_cuda.c:78
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:472
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:194
ThumbnailCudaContext
Definition: vf_thumbnail_cuda.c:55
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_thumbnail_cuda.c:87
NULL
#define NULL
Definition: coverity.c:32
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_thumbnail_cuda.c:305
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:115
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: internal.h:184
AV_PIX_FMT_P016
#define AV_PIX_FMT_P016
Definition: pixfmt.h:510
AV_PIX_FMT_NV12
@ AV_PIX_FMT_NV12
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
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
thumbnail_cuda_outputs
static const AVFilterPad thumbnail_cuda_outputs[]
Definition: vf_thumbnail_cuda.c:428
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:508
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:195
OFFSET
#define OFFSET(x)
Definition: vf_thumbnail_cuda.c:77