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"

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)
 
static int query_formats (AVFilterContext *ctx)
 

Variables

static enum AVPixelFormat supported_formats []
 
static const AVOption thumbnail_cuda_options []
 
static const AVFilterPad thumbnail_cuda_inputs []
 
static const AVFilterPad thumbnail_cuda_outputs []
 
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 32 of file vf_thumbnail_cuda.c.

◆ HIST_SIZE

#define HIST_SIZE   (3*256)

Definition at line 34 of file vf_thumbnail_cuda.c.

◆ DIV_UP

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

Definition at line 35 of file vf_thumbnail_cuda.c.

◆ BLOCKX

#define BLOCKX   32

Definition at line 36 of file vf_thumbnail_cuda.c.

◆ BLOCKY

#define BLOCKY   16

Definition at line 37 of file vf_thumbnail_cuda.c.

◆ OFFSET

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

Definition at line 75 of file vf_thumbnail_cuda.c.

◆ FLAGS

Definition at line 76 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 85 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 105 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 117 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 157 of file vf_thumbnail_cuda.c.

Referenced by thumbnail().

◆ thumbnail()

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

Definition at line 197 of file vf_thumbnail_cuda.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 247 of file vf_thumbnail_cuda.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 303 of file vf_thumbnail_cuda.c.

◆ request_frame()

static int request_frame ( AVFilterLink link)
static

Definition at line 324 of file vf_thumbnail_cuda.c.

◆ format_is_supported()

static int format_is_supported ( enum AVPixelFormat  fmt)
static

Definition at line 341 of file vf_thumbnail_cuda.c.

Referenced by config_props().

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 351 of file vf_thumbnail_cuda.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 412 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 78 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,
},
{ NULL }
}

Definition at line 424 of file vf_thumbnail_cuda.c.

◆ thumbnail_cuda_outputs

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

Definition at line 434 of file vf_thumbnail_cuda.c.

◆ ff_vf_thumbnail_cuda

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 443 of file vf_thumbnail_cuda.c.

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:365
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_thumbnail_cuda.c:247
thumbnail_cuda_inputs
static const AVFilterPad thumbnail_cuda_inputs[]
Definition: vf_thumbnail_cuda.c:424
config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_thumbnail_cuda.c:351
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_thumbnail_cuda.c:324
FLAGS
#define FLAGS
Definition: vf_thumbnail_cuda.c:76
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:410
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
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
ThumbnailCudaContext
Definition: vf_thumbnail_cuda.c:53
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_thumbnail_cuda.c:85
NULL
#define NULL
Definition: coverity.c:32
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_thumbnail_cuda.c:303
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:188
AV_PIX_FMT_P016
#define AV_PIX_FMT_P016
Definition: pixfmt.h:447
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_thumbnail_cuda.c:412
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:223
thumbnail_cuda_outputs
static const AVFilterPad thumbnail_cuda_outputs[]
Definition: vf_thumbnail_cuda.c:434
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:446
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
OFFSET
#define OFFSET(x)
Definition: vf_thumbnail_cuda.c:75