FFmpeg  4.0
Data Structures | Macros | Functions | Variables
vf_thumbnail_cuda.c File Reference
#include <cuda.h>
#include "libavutil/hwcontext.h"
#include "libavutil/hwcontext_cuda_internal.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 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 (ThumbnailCudaContext *s, CUfunction func, CUtexref tex, 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

◆ HIST_SIZE

#define HIST_SIZE   (3*256)

Definition at line 33 of file vf_thumbnail_cuda.c.

Referenced by config_props(), frame_sum_square_err(), and get_best_frame().

◆ DIV_UP

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

Definition at line 34 of file vf_thumbnail_cuda.c.

Referenced by thumbnail_kernel().

◆ BLOCKX

#define BLOCKX   32

Definition at line 35 of file vf_thumbnail_cuda.c.

Referenced by thumbnail_kernel().

◆ BLOCKY

#define BLOCKY   16

Definition at line 36 of file vf_thumbnail_cuda.c.

Referenced by thumbnail_kernel().

◆ 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 ( ThumbnailCudaContext s,
CUfunction  func,
CUtexref  tex,
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 180 of file vf_thumbnail_cuda.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 230 of file vf_thumbnail_cuda.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 289 of file vf_thumbnail_cuda.c.

◆ request_frame()

static int request_frame ( AVFilterLink link)
static

Definition at line 309 of file vf_thumbnail_cuda.c.

◆ format_is_supported()

static int format_is_supported ( enum AVPixelFormat  fmt)
static

Definition at line 326 of file vf_thumbnail_cuda.c.

Referenced by config_props().

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 336 of file vf_thumbnail_cuda.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 403 of file vf_thumbnail_cuda.c.

Variable Documentation

◆ supported_formats

enum AVPixelFormat supported_formats[]
static
Initial value:
= {
}
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:67
#define AV_PIX_FMT_P016
Definition: pixfmt.h:414
#define AV_PIX_FMT_P010
Definition: pixfmt.h:413
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:381
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
Definition: pixfmt.h:85
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:62

Definition at line 38 of file vf_thumbnail_cuda.c.

Referenced by format_is_supported().

◆ 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 }
}
#define NULL
Definition: coverity.c:32
#define OFFSET(x)
#define FLAGS

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 }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
static int config_props(AVFilterLink *inlink)

Definition at line 415 of file vf_thumbnail_cuda.c.

◆ thumbnail_cuda_outputs

const AVFilterPad thumbnail_cuda_outputs[]
static
Initial value:
= {
{
.name = "default",
.request_frame = request_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int request_frame(AVFilterLink *link)

Definition at line 425 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,
}
#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:385
static const AVFilterPad thumbnail_cuda_inputs[]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
static av_cold int init(AVFilterContext *ctx)
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
static av_cold void uninit(AVFilterContext *ctx)
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad thumbnail_cuda_outputs[]

Definition at line 434 of file vf_thumbnail_cuda.c.