FFmpeg
Macros | Functions | Variables
vf_signature.c File Reference
#include "libavcodec/put_bits.h"
#include "libavformat/avformat.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/avstring.h"
#include "libavutil/file_open.h"
#include "avfilter.h"
#include "filters.h"
#include "signature.h"
#include "signature_lookup.c"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(SignatureContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 
#define BLOCK_LCM   (int64_t) 476985600
 

Functions

 AVFILTER_DEFINE_CLASS (signature)
 
static int config_input (AVFilterLink *inlink)
 
static int get_block_size (const Block *b)
 
static uint64_t get_block_sum (StreamContext *sc, uint64_t intpic[32][32], const Block *b)
 
static int cmp (const void *x, const void *y)
 
static void set_bit (uint8_t *data, size_t pos)
 sets the bit at position pos to 1 in data More...
 
static int filter_frame (AVFilterLink *inlink, AVFrame *picref)
 
static int xml_export (AVFilterContext *ctx, StreamContext *sc, const char *filename)
 
static int binary_export (AVFilterContext *ctx, StreamContext *sc, const char *filename)
 
static int export (AVFilterContext *ctx, StreamContext *sc, int input)
 
static int request_frame (AVFilterLink *outlink)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 

Variables

static const AVOption signature_options []
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad signature_outputs []
 
const AVFilter ff_vf_signature
 

Detailed Description

MPEG-7 video signature calculation and lookup filter

See also
http://epubs.surrey.ac.uk/531590/1/MPEG-7%20Video%20Signature%20Author%27s%20Copy.pdf

Definition in file vf_signature.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 38 of file vf_signature.c.

◆ FLAGS

Definition at line 39 of file vf_signature.c.

◆ BLOCK_LCM

#define BLOCK_LCM   (int64_t) 476985600

Definition at line 40 of file vf_signature.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( signature  )

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 84 of file vf_signature.c.

Referenced by init().

◆ get_block_size()

static int get_block_size ( const Block b)
static

Definition at line 101 of file vf_signature.c.

Referenced by filter_frame().

◆ get_block_sum()

static uint64_t get_block_sum ( StreamContext sc,
uint64_t  intpic[32][32],
const Block b 
)
static

Definition at line 106 of file vf_signature.c.

Referenced by filter_frame().

◆ cmp()

static int cmp ( const void *  x,
const void *  y 
)
static

Definition at line 129 of file vf_signature.c.

Referenced by filter_frame().

◆ set_bit()

static void set_bit ( uint8_t *  data,
size_t  pos 
)
static

sets the bit at position pos to 1 in data

Definition at line 138 of file vf_signature.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame picref 
)
static

Definition at line 144 of file vf_signature.c.

Referenced by init().

◆ xml_export()

static int xml_export ( AVFilterContext ctx,
StreamContext sc,
const char *  filename 
)
static

Definition at line 375 of file vf_signature.c.

Referenced by export().

◆ binary_export()

static int binary_export ( AVFilterContext ctx,
StreamContext sc,
const char *  filename 
)
static

Definition at line 482 of file vf_signature.c.

Referenced by export().

◆ export()

static int export ( AVFilterContext ctx,
StreamContext sc,
int  input 
)
static

Definition at line 558 of file vf_signature.c.

Referenced by request_frame().

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 577 of file vf_signature.c.

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 633 of file vf_signature.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 686 of file vf_signature.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 721 of file vf_signature.c.

Variable Documentation

◆ signature_options

const AVOption signature_options[]
static
Initial value:
= {
{ "detectmode", "set the detectmode",
OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = MODE_OFF}, 0, NB_LOOKUP_MODE-1, FLAGS, .unit = "mode" },
{ "off", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MODE_OFF}, 0, 0, .flags = FLAGS, .unit = "mode" },
{ "full", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MODE_FULL}, 0, 0, .flags = FLAGS, .unit = "mode" },
{ "fast", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MODE_FAST}, 0, 0, .flags = FLAGS, .unit = "mode" },
{ "nb_inputs", "number of inputs",
OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX, FLAGS },
{ "filename", "filename for output files",
OFFSET(filename), AV_OPT_TYPE_STRING, {.str = ""}, 0, NB_FORMATS-1, FLAGS },
{ "format", "set output format",
OFFSET(format), AV_OPT_TYPE_INT, {.i64 = FORMAT_BINARY}, 0, 1, FLAGS , .unit = "format" },
{ "binary", 0, 0, AV_OPT_TYPE_CONST, {.i64=FORMAT_BINARY}, 0, 0, FLAGS, .unit = "format" },
{ "xml", 0, 0, AV_OPT_TYPE_CONST, {.i64=FORMAT_XML}, 0, 0, FLAGS, .unit = "format" },
{ "th_d", "threshold to detect one word as similar",
OFFSET(thworddist), AV_OPT_TYPE_INT, {.i64 = 9000}, 1, INT_MAX, FLAGS },
{ "th_dc", "threshold to detect all words as similar",
OFFSET(thcomposdist), AV_OPT_TYPE_INT, {.i64 = 60000}, 1, INT_MAX, FLAGS },
{ "th_xh", "threshold to detect frames as similar",
OFFSET(thl1), AV_OPT_TYPE_INT, {.i64 = 116}, 1, INT_MAX, FLAGS },
{ "th_di", "minimum length of matching sequence in frames",
OFFSET(thdi), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, FLAGS },
{ "th_it", "threshold for relation of good to all frames",
OFFSET(thit), AV_OPT_TYPE_DOUBLE, {.dbl = 0.5}, 0.0, 1.0, FLAGS },
{ NULL }
}

Definition at line 42 of file vf_signature.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ signature_outputs

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

Definition at line 737 of file vf_signature.c.

◆ ff_vf_signature

const AVFilter ff_vf_signature
Initial value:
= {
.name = "signature",
.description = NULL_IF_CONFIG_SMALL("Calculate the MPEG-7 video signature"),
.priv_size = sizeof(SignatureContext),
.priv_class = &signature_class,
.init = init,
.inputs = NULL,
}

Definition at line 746 of file vf_signature.c.

FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
OFFSET
#define OFFSET(x)
Definition: vf_signature.c:38
signature_outputs
static const AVFilterPad signature_outputs[]
Definition: vf_signature.c:737
FORMAT_BINARY
@ FORMAT_BINARY
Definition: signature.h:48
mode
Definition: swscale.c:52
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
AVFILTER_FLAG_DYNAMIC_INPUTS
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition: avfilter.h:141
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
MODE_FAST
@ MODE_FAST
Definition: signature.h:43
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition: opt.h:267
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_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
NB_LOOKUP_MODE
@ NB_LOOKUP_MODE
Definition: signature.h:44
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
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_signature.c:721
NULL
#define NULL
Definition: coverity.c:32
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vf_signature.c:577
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
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_signature.c:686
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
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:94
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_signature.c:72
MODE_FULL
@ MODE_FULL
Definition: f_graphmonitor.c:66
SignatureContext
Definition: signature.h:126
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
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_signature.c:633
AV_PIX_FMT_NV21
@ AV_PIX_FMT_NV21
as above, but U and V bytes are swapped
Definition: pixfmt.h:97
MODE_OFF
@ MODE_OFF
Definition: signature.h:41
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:96
NB_FORMATS
@ NB_FORMATS
Definition: signature.h:50
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
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
FLAGS
#define FLAGS
Definition: vf_signature.c:39
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
FORMAT_XML
@ FORMAT_XML
Definition: signature.h:49
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_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:79
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299