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/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "filters.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 35 of file vf_thumbnail_cuda.c.

◆ HIST_SIZE

#define HIST_SIZE   (3*256)

Definition at line 37 of file vf_thumbnail_cuda.c.

◆ DIV_UP

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

Definition at line 38 of file vf_thumbnail_cuda.c.

◆ BLOCKX

#define BLOCKX   32

Definition at line 39 of file vf_thumbnail_cuda.c.

◆ BLOCKY

#define BLOCKY   16

Definition at line 40 of file vf_thumbnail_cuda.c.

◆ OFFSET

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

Definition at line 78 of file vf_thumbnail_cuda.c.

◆ FLAGS

Definition at line 79 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 88 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 108 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 120 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 160 of file vf_thumbnail_cuda.c.

Referenced by thumbnail().

◆ thumbnail()

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

Definition at line 200 of file vf_thumbnail_cuda.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 250 of file vf_thumbnail_cuda.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 306 of file vf_thumbnail_cuda.c.

◆ request_frame()

static int request_frame ( AVFilterLink link)
static

Definition at line 331 of file vf_thumbnail_cuda.c.

◆ format_is_supported()

static int format_is_supported ( enum AVPixelFormat  fmt)
static

Definition at line 348 of file vf_thumbnail_cuda.c.

Referenced by config_props().

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 358 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 81 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 422 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 431 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 439 of file vf_thumbnail_cuda.c.

AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:260
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_thumbnail_cuda.c:250
thumbnail_cuda_inputs
static const AVFilterPad thumbnail_cuda_inputs[]
Definition: vf_thumbnail_cuda.c:422
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_thumbnail_cuda.c:358
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_thumbnail_cuda.c:331
FLAGS
#define FLAGS
Definition: vf_thumbnail_cuda.c:79
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:515
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:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
ThumbnailCudaContext
Definition: vf_thumbnail_cuda.c:56
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_thumbnail_cuda.c:88
NULL
#define NULL
Definition: coverity.c:32
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: filters.h:206
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_thumbnail_cuda.c:306
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:94
AV_PIX_FMT_P016
#define AV_PIX_FMT_P016
Definition: pixfmt.h:554
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:96
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
thumbnail_cuda_outputs
static const AVFilterPad thumbnail_cuda_outputs[]
Definition: vf_thumbnail_cuda.c:431
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:78
AV_PIX_FMT_P010
#define AV_PIX_FMT_P010
Definition: pixfmt.h:552
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:252
OFFSET
#define OFFSET(x)
Definition: vf_thumbnail_cuda.c:78