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

#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.

Referenced by config_props(), thumbnail_kernel(), and uninit().

#define HIST_SIZE   (3*256)

Definition at line 34 of file vf_thumbnail_cuda.c.

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

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

Definition at line 35 of file vf_thumbnail_cuda.c.

Referenced by thumbnail_kernel().

#define BLOCKX   32

Definition at line 36 of file vf_thumbnail_cuda.c.

Referenced by thumbnail_kernel().

#define BLOCKY   16

Definition at line 37 of file vf_thumbnail_cuda.c.

Referenced by thumbnail_kernel().

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

Definition at line 75 of file vf_thumbnail_cuda.c.

Definition at line 76 of file vf_thumbnail_cuda.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( thumbnail_cuda  )
static av_cold int init ( AVFilterContext ctx)
static

Definition at line 85 of file vf_thumbnail_cuda.c.

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().

static AVFrame* get_best_frame ( AVFilterContext ctx)
static

Definition at line 117 of file vf_thumbnail_cuda.c.

Referenced by request_frame().

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().

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

Definition at line 197 of file vf_thumbnail_cuda.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 247 of file vf_thumbnail_cuda.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 303 of file vf_thumbnail_cuda.c.

static int request_frame ( AVFilterLink link)
static

Definition at line 324 of file vf_thumbnail_cuda.c.

static int format_is_supported ( enum AVPixelFormat  fmt)
static

Definition at line 341 of file vf_thumbnail_cuda.c.

Referenced by config_props().

static int config_props ( AVFilterLink inlink)
static

Definition at line 351 of file vf_thumbnail_cuda.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 412 of file vf_thumbnail_cuda.c.

Variable Documentation

enum AVPixelFormat supported_formats[]
static
Initial value:
= {
}
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
#define AV_PIX_FMT_P016
Definition: pixfmt.h:437
#define AV_PIX_FMT_P010
Definition: pixfmt.h:436
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:400
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
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66

Definition at line 39 of file vf_thumbnail_cuda.c.

Referenced by format_is_supported().

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.

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

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

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 outputs[]
Definition: af_acontrast.c:203
static av_cold void uninit(AVFilterContext *ctx)
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
static int query_formats(AVFilterContext *ctx)
static const AVFilterPad thumbnail_cuda_outputs[]

Definition at line 443 of file vf_thumbnail_cuda.c.