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 do_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
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)
 

Variables

static const AVOption thumbnail_options []
 
static enum AVPixelFormat pix_fmts []
 
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 57 of file vf_thumbnail.c.

◆ FLAGS

Definition at line 58 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 71 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 91 of file vf_thumbnail.c.

Referenced by get_best_frame().

◆ get_best_frame()

static AVFrame* get_best_frame ( AVFilterContext ctx)
static

Definition at line 103 of file vf_thumbnail.c.

Referenced by filter_frame(), and request_frame().

◆ do_slice()

static int do_slice ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 144 of file vf_thumbnail.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame frame 
)
static

Definition at line 216 of file vf_thumbnail.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 245 of file vf_thumbnail.c.

◆ request_frame()

static int request_frame ( AVFilterLink link)
static

Definition at line 255 of file vf_thumbnail.c.

◆ config_props()

static int config_props ( AVFilterLink inlink)
static

Definition at line 272 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 },
{ "log", "force stats logging level", OFFSET(loglevel), AV_OPT_TYPE_INT, {.i64 = AV_LOG_INFO}, INT_MIN, INT_MAX, FLAGS, .unit = "level" },
{ "quiet", "logging disabled", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_QUIET}, 0, 0, FLAGS, .unit = "level" },
{ "info", "information logging level", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_INFO}, 0, 0, FLAGS, .unit = "level" },
{ "verbose", "verbose logging level", 0, AV_OPT_TYPE_CONST, {.i64 = AV_LOG_VERBOSE}, 0, 0, FLAGS, .unit = "level" },
{ NULL }
}

Definition at line 60 of file vf_thumbnail.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ thumbnail_inputs

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

Definition at line 309 of file vf_thumbnail.c.

◆ thumbnail_outputs

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

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

ThumbContext
Definition: vf_thumbnail.c:42
AV_LOG_QUIET
#define AV_LOG_QUIET
Print no output.
Definition: log.h:162
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:162
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
AV_PIX_FMT_BGR24
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:76
AV_PIX_FMT_BGRA
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:106
OFFSET
#define OFFSET(x)
Definition: vf_thumbnail.c:57
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_thumbnail.c:292
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:283
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:86
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:108
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_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:87
AV_PIX_FMT_RGBA
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
NULL
#define NULL
Definition: coverity.c:32
FLAGS
#define FLAGS
Definition: vf_thumbnail.c:58
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:85
config_props
static int config_props(AVFilterLink *inlink)
Definition: vf_thumbnail.c:272
AV_PIX_FMT_BGR0
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
AV_PIX_FMT_ABGR
@ AV_PIX_FMT_ABGR
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
AV_PIX_FMT_RGB24
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:75
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:106
request_frame
static int request_frame(AVFilterLink *link)
Definition: vf_thumbnail.c:255
thumbnail_outputs
static const AVFilterPad thumbnail_outputs[]
Definition: vf_thumbnail.c:318
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_thumbnail.c:245
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:174
AV_PIX_FMT_RGB0
@ AV_PIX_FMT_RGB0
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
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:147
AV_PIX_FMT_ARGB
@ AV_PIX_FMT_ARGB
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_thumbnail.c:216
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:107
AV_PIX_FMT_0BGR
@ AV_PIX_FMT_0BGR
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
thumbnail_inputs
static const AVFilterPad thumbnail_inputs[]
Definition: vf_thumbnail.c:309
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_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:77
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:80
AV_PIX_FMT_0RGB
@ AV_PIX_FMT_0RGB
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_thumbnail.c:71
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:173