FFmpeg
Data Structures | Macros | Functions | Variables
vf_thumbnail.c File Reference
#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  ThumbContext
 

Macros

#define HIST_SIZE   (3*256)
 
#define OFFSET(x)   offsetof(ThumbContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (thumbnail)
 
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 filter_frame (AVFilterLink *inlink, AVFrame *frame)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int request_frame (AVFilterLink *link)
 
static int config_props (AVFilterLink *inlink)
 
static int query_formats (AVFilterContext *ctx)
 

Variables

static const AVOption thumbnail_options []
 
static const AVFilterPad thumbnail_inputs []
 
static const AVFilterPad thumbnail_outputs []
 
const AVFilter ff_vf_thumbnail
 

Detailed Description

Potential thumbnail lookup filter to reduce the risk of an inappropriate selection (such as a black frame) we could get with an absolute seek.

Simplified version of algorithm by Vadim Zaliva lord@.nosp@m.croc.nosp@m.odile.nosp@m..org.

See also
http://notbrainsurgery.livejournal.com/29773.html

Definition in file vf_thumbnail.c.

Macro Definition Documentation

◆ HIST_SIZE

#define HIST_SIZE   (3*256)

Definition at line 35 of file vf_thumbnail.c.

◆ OFFSET

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

Definition at line 53 of file vf_thumbnail.c.

◆ FLAGS

Definition at line 54 of file vf_thumbnail.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( thumbnail  )

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 63 of file vf_thumbnail.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 83 of file vf_thumbnail.c.

Referenced by get_best_frame().

◆ get_best_frame()

static AVFrame* get_best_frame ( AVFilterContext ctx)
static

Definition at line 95 of file vf_thumbnail.c.

Referenced by filter_frame(), and request_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 135 of file vf_thumbnail.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 206 of file vf_thumbnail.c.

◆ request_frame()

static int request_frame ( AVFilterLink link)
static

Definition at line 215 of file vf_thumbnail.c.

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 232 of file vf_thumbnail.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 247 of file vf_thumbnail.c.

Variable Documentation

◆ thumbnail_options

const AVOption thumbnail_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 56 of file vf_thumbnail.c.

◆ thumbnail_inputs

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

Definition at line 271 of file vf_thumbnail.c.

◆ thumbnail_outputs

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

Definition at line 281 of file vf_thumbnail.c.

◆ ff_vf_thumbnail

const AVFilter ff_vf_thumbnail
Initial value:
= {
.name = "thumbnail",
.description = NULL_IF_CONFIG_SMALL("Select the most representative frame in a given sequence of consecutive frames."),
.priv_size = sizeof(ThumbContext),
.init = init,
.priv_class = &thumbnail_class,
}

Definition at line 290 of file vf_thumbnail.c.

ThumbContext
Definition: vf_thumbnail.c:42
OFFSET
#define OFFSET(x)
Definition: vf_thumbnail.c:53
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
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_thumbnail.c:247
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
NULL
#define NULL
Definition: coverity.c:32
FLAGS
#define FLAGS
Definition: vf_thumbnail.c:54
config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_thumbnail.c:232
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:117
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_thumbnail.c:215
thumbnail_outputs
static const AVFilterPad thumbnail_outputs[]
Definition: vf_thumbnail.c:281
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_thumbnail.c:206
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:126
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_thumbnail.c:135
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
thumbnail_inputs
static const AVFilterPad thumbnail_inputs[]
Definition: vf_thumbnail.c:271
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_thumbnail.c:63