FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_minterpolate.c File Reference
#include "motion_estimation.h"
#include "libavcodec/mathops.h"
#include "libavutil/common.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "filters.h"
#include "video.h"
#include "scene_sad.h"

Go to the source code of this file.

Data Structures

struct  Cluster
 
struct  Block
 
struct  PixelMVS
 
struct  PixelWeights
 
struct  PixelRefs
 
struct  Frame
 
struct  MIContext
 

Macros

#define ME_MODE_BIDIR   0
 Copyright (c) 2014-2015 Michael Niedermayer micha.nosp@m.elni.nosp@m.@gmx..nosp@m.at Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<@gmail.com> More...
 
#define ME_MODE_BILAT   1
 
#define MC_MODE_OBMC   0
 
#define MC_MODE_AOBMC   1
 
#define SCD_METHOD_NONE   0
 
#define SCD_METHOD_FDIFF   1
 
#define NB_FRAMES   4
 
#define NB_PIXEL_MVS   32
 
#define NB_CLUSTERS   128
 
#define ALPHA_MAX   1024
 
#define CLUSTER_THRESHOLD   4
 
#define PX_WEIGHT_MAX   255
 
#define COST_PRED_SCALE   64
 
#define OFFSET(x)   offsetof(MIContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define CONST(name, help, val, u)   { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, .unit = u }
 
#define ADD_PRED(preds, px, py)
 
#define ADD_PIXELS(b_weight, mv_x, mv_y)
 

Enumerations

enum  MIMode { MI_MODE_DUP = 0, MI_MODE_BLEND = 1, MI_MODE_MCI = 2 }
 

Functions

 AVFILTER_DEFINE_CLASS (minterpolate)
 
static uint64_t get_sbad (AVMotionEstContext *me_ctx, int x, int y, int x_mv, int y_mv)
 
static uint64_t get_sbad_ob (AVMotionEstContext *me_ctx, int x, int y, int x_mv, int y_mv)
 
static uint64_t get_sad_ob (AVMotionEstContext *me_ctx, int x, int y, int x_mv, int y_mv)
 
static int config_input (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static void search_mv (MIContext *mi_ctx, Block *blocks, int mb_x, int mb_y, int dir)
 
static void bilateral_me (MIContext *mi_ctx)
 
static int var_size_bme (MIContext *mi_ctx, Block *block, int x_mb, int y_mb, int n)
 
static int cluster_mvs (MIContext *mi_ctx)
 
static int inject_frame (AVFilterLink *inlink, AVFrame *avf_in)
 
static int detect_scene_change (AVFilterContext *ctx)
 
static void bidirectional_obmc (MIContext *mi_ctx, int alpha)
 
static void set_frame_data (MIContext *mi_ctx, int alpha, AVFrame *avf_out)
 
static void var_size_bmc (MIContext *mi_ctx, Block *block, int x_mb, int y_mb, int n, int alpha)
 
static void bilateral_obmc (MIContext *mi_ctx, Block *block, int mb_x, int mb_y, int alpha)
 
static void interpolate (AVFilterLink *inlink, AVFrame *avf_out)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *avf_in)
 
static av_cold void free_blocks (Block *block, int sb)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const uint8_t obmc_linear32 [1024]
 
static const uint8_t obmc_linear16 [256]
 
static const uint8_t obmc_linear8 [64]
 
static const uint8_t obmc_linear4 [16]
 
static const uint8_t *const obmc_tab_linear [4]
 
static const AVOption minterpolate_options []
 
static enum AVPixelFormat pix_fmts []
 
static const AVFilterPad minterpolate_inputs []
 
static const AVFilterPad minterpolate_outputs []
 
const AVFilter ff_vf_minterpolate
 

Macro Definition Documentation

◆ ME_MODE_BIDIR

#define ME_MODE_BIDIR   0

Copyright (c) 2014-2015 Michael Niedermayer micha.nosp@m.elni.nosp@m.@gmx..nosp@m.at Copyright (c) 2016 Davinder Singh (DSM_) <ds.mudhar<@gmail.com>

This file is part of FFmpeg.

FFmpeg is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

FFmpeg is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with FFmpeg; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Definition at line 33 of file vf_minterpolate.c.

◆ ME_MODE_BILAT

#define ME_MODE_BILAT   1

Definition at line 34 of file vf_minterpolate.c.

◆ MC_MODE_OBMC

#define MC_MODE_OBMC   0

Definition at line 36 of file vf_minterpolate.c.

◆ MC_MODE_AOBMC

#define MC_MODE_AOBMC   1

Definition at line 37 of file vf_minterpolate.c.

◆ SCD_METHOD_NONE

#define SCD_METHOD_NONE   0

Definition at line 39 of file vf_minterpolate.c.

◆ SCD_METHOD_FDIFF

#define SCD_METHOD_FDIFF   1

Definition at line 40 of file vf_minterpolate.c.

◆ NB_FRAMES

#define NB_FRAMES   4

Definition at line 42 of file vf_minterpolate.c.

◆ NB_PIXEL_MVS

#define NB_PIXEL_MVS   32

Definition at line 43 of file vf_minterpolate.c.

◆ NB_CLUSTERS

#define NB_CLUSTERS   128

Definition at line 44 of file vf_minterpolate.c.

◆ ALPHA_MAX

#define ALPHA_MAX   1024

Definition at line 46 of file vf_minterpolate.c.

◆ CLUSTER_THRESHOLD

#define CLUSTER_THRESHOLD   4

Definition at line 47 of file vf_minterpolate.c.

◆ PX_WEIGHT_MAX

#define PX_WEIGHT_MAX   255

Definition at line 48 of file vf_minterpolate.c.

◆ COST_PRED_SCALE

#define COST_PRED_SCALE   64

Definition at line 49 of file vf_minterpolate.c.

◆ OFFSET

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

Definition at line 199 of file vf_minterpolate.c.

◆ FLAGS

Definition at line 200 of file vf_minterpolate.c.

◆ CONST

#define CONST (   name,
  help,
  val,
  u 
)    { name, help, 0, AV_OPT_TYPE_CONST, {.i64=val}, 0, 0, FLAGS, .unit = u }

Definition at line 201 of file vf_minterpolate.c.

◆ ADD_PRED

#define ADD_PRED (   preds,
  px,
  py 
)
Value:
do {\
preds.mvs[preds.nb][0] = px;\
preds.mvs[preds.nb][1] = py;\
preds.nb++;\
} while(0)

Definition at line 409 of file vf_minterpolate.c.

◆ ADD_PIXELS

#define ADD_PIXELS (   b_weight,
  mv_x,
  mv_y 
)
Value:
do {\
if (!b_weight || pixel_refs->nb + 1 >= NB_PIXEL_MVS)\
continue;\
pixel_refs->refs[pixel_refs->nb] = 1;\
pixel_weights->weights[pixel_refs->nb] = b_weight * (ALPHA_MAX - alpha);\
pixel_mvs->mvs[pixel_refs->nb][0] = av_clip((mv_x * alpha) / ALPHA_MAX, x_min, x_max);\
pixel_mvs->mvs[pixel_refs->nb][1] = av_clip((mv_y * alpha) / ALPHA_MAX, y_min, y_max);\
pixel_refs->nb++;\
pixel_refs->refs[pixel_refs->nb] = 2;\
pixel_weights->weights[pixel_refs->nb] = b_weight * alpha;\
pixel_mvs->mvs[pixel_refs->nb][0] = av_clip(-mv_x * (ALPHA_MAX - alpha) / ALPHA_MAX, x_min, x_max);\
pixel_mvs->mvs[pixel_refs->nb][1] = av_clip(-mv_y * (ALPHA_MAX - alpha) / ALPHA_MAX, y_min, y_max);\
pixel_refs->nb++;\
} while(0)

Definition at line 841 of file vf_minterpolate.c.

Enumeration Type Documentation

◆ MIMode

enum MIMode
Enumerator
MI_MODE_DUP 
MI_MODE_BLEND 
MI_MODE_MCI 

Definition at line 127 of file vf_minterpolate.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( minterpolate  )

◆ get_sbad()

static uint64_t get_sbad ( AVMotionEstContext me_ctx,
int  x,
int  y,
int  x_mv,
int  y_mv 
)
static

Definition at line 249 of file vf_minterpolate.c.

Referenced by bilateral_obmc(), and inject_frame().

◆ get_sbad_ob()

static uint64_t get_sbad_ob ( AVMotionEstContext me_ctx,
int  x,
int  y,
int  x_mv,
int  y_mv 
)
static

Definition at line 274 of file vf_minterpolate.c.

Referenced by config_input().

◆ get_sad_ob()

static uint64_t get_sad_ob ( AVMotionEstContext me_ctx,
int  x,
int  y,
int  x_mv,
int  y_mv 
)
static

Definition at line 300 of file vf_minterpolate.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 326 of file vf_minterpolate.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 398 of file vf_minterpolate.c.

◆ search_mv()

static void search_mv ( MIContext mi_ctx,
Block blocks,
int  mb_x,
int  mb_y,
int  dir 
)
static

Definition at line 416 of file vf_minterpolate.c.

Referenced by bilateral_me(), and inject_frame().

◆ bilateral_me()

static void bilateral_me ( MIContext mi_ctx)
static

Definition at line 558 of file vf_minterpolate.c.

Referenced by inject_frame().

◆ var_size_bme()

static int var_size_bme ( MIContext mi_ctx,
Block block,
int  x_mb,
int  y_mb,
int  n 
)
static

Definition at line 579 of file vf_minterpolate.c.

Referenced by cluster_mvs().

◆ cluster_mvs()

static int cluster_mvs ( MIContext mi_ctx)
static

Definition at line 641 of file vf_minterpolate.c.

Referenced by inject_frame().

◆ inject_frame()

static int inject_frame ( AVFilterLink inlink,
AVFrame avf_in 
)
static

Definition at line 731 of file vf_minterpolate.c.

Referenced by filter_frame().

◆ detect_scene_change()

static int detect_scene_change ( AVFilterContext ctx)
static

Definition at line 817 of file vf_minterpolate.c.

Referenced by filter_frame().

◆ bidirectional_obmc()

static void bidirectional_obmc ( MIContext mi_ctx,
int  alpha 
)
static

Definition at line 857 of file vf_minterpolate.c.

Referenced by interpolate().

◆ set_frame_data()

static void set_frame_data ( MIContext mi_ctx,
int  alpha,
AVFrame avf_out 
)
static

Definition at line 907 of file vf_minterpolate.c.

Referenced by interpolate().

◆ var_size_bmc()

static void var_size_bmc ( MIContext mi_ctx,
Block block,
int  x_mb,
int  y_mb,
int  n,
int  alpha 
)
static

Definition at line 965 of file vf_minterpolate.c.

Referenced by interpolate().

◆ bilateral_obmc()

static void bilateral_obmc ( MIContext mi_ctx,
Block block,
int  mb_x,
int  mb_y,
int  alpha 
)
static

Definition at line 1004 of file vf_minterpolate.c.

Referenced by interpolate().

◆ interpolate()

static void interpolate ( AVFilterLink inlink,
AVFrame avf_out 
)
static

Definition at line 1068 of file vf_minterpolate.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame avf_in 
)
static

Definition at line 1156 of file vf_minterpolate.c.

◆ free_blocks()

static av_cold void free_blocks ( Block block,
int  sb 
)
static

Definition at line 1207 of file vf_minterpolate.c.

Referenced by uninit().

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1215 of file vf_minterpolate.c.

Variable Documentation

◆ obmc_linear32

const uint8_t obmc_linear32[1024]
static

Definition at line 51 of file vf_minterpolate.c.

◆ obmc_linear16

const uint8_t obmc_linear16[256]
static
Initial value:
= {
0, 4, 4, 8, 8, 12, 12, 16, 16, 12, 12, 8, 8, 4, 4, 0,
4, 8, 16, 20, 28, 32, 40, 44, 44, 40, 32, 28, 20, 16, 8, 4,
4, 16, 24, 36, 44, 56, 64, 76, 76, 64, 56, 44, 36, 24, 16, 4,
8, 20, 36, 48, 64, 76, 92,104,104, 92, 76, 64, 48, 36, 20, 8,
8, 28, 44, 64, 80,100,116,136,136,116,100, 80, 64, 44, 28, 8,
12, 32, 56, 76,100,120,144,164,164,144,120,100, 76, 56, 32, 12,
12, 40, 64, 92,116,144,168,196,196,168,144,116, 92, 64, 40, 12,
16, 44, 76,104,136,164,196,224,224,196,164,136,104, 76, 44, 16,
16, 44, 76,104,136,164,196,224,224,196,164,136,104, 76, 44, 16,
12, 40, 64, 92,116,144,168,196,196,168,144,116, 92, 64, 40, 12,
12, 32, 56, 76,100,120,144,164,164,144,120,100, 76, 56, 32, 12,
8, 28, 44, 64, 80,100,116,136,136,116,100, 80, 64, 44, 28, 8,
8, 20, 36, 48, 64, 76, 92,104,104, 92, 76, 64, 48, 36, 20, 8,
4, 16, 24, 36, 44, 56, 64, 76, 76, 64, 56, 44, 36, 24, 16, 4,
4, 8, 16, 20, 28, 32, 40, 44, 44, 40, 32, 28, 20, 16, 8, 4,
0, 4, 4, 8, 8, 12, 12, 16, 16, 12, 12, 8, 8, 4, 4, 0,
}

Definition at line 86 of file vf_minterpolate.c.

◆ obmc_linear8

const uint8_t obmc_linear8[64]
static
Initial value:
= {
4, 12, 20, 28, 28, 20, 12, 4,
12, 36, 60, 84, 84, 60, 36, 12,
20, 60,100,140,140,100, 60, 20,
28, 84,140,196,196,140, 84, 28,
28, 84,140,196,196,140, 84, 28,
20, 60,100,140,140,100, 60, 20,
12, 36, 60, 84, 84, 60, 36, 12,
4, 12, 20, 28, 28, 20, 12, 4,
}

Definition at line 105 of file vf_minterpolate.c.

◆ obmc_linear4

const uint8_t obmc_linear4[16]
static
Initial value:
= {
16, 48, 48, 16,
48,144,144, 48,
48,144,144, 48,
16, 48, 48, 16,
}

Definition at line 116 of file vf_minterpolate.c.

◆ obmc_tab_linear

const uint8_t* const obmc_tab_linear[4]
static
Initial value:

Definition at line 123 of file vf_minterpolate.c.

Referenced by bidirectional_obmc(), and bilateral_obmc().

◆ minterpolate_options

const AVOption minterpolate_options[]
static

Definition at line 203 of file vf_minterpolate.c.

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ minterpolate_inputs

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

Definition at line 1238 of file vf_minterpolate.c.

◆ minterpolate_outputs

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

Definition at line 1247 of file vf_minterpolate.c.

◆ ff_vf_minterpolate

const AVFilter ff_vf_minterpolate
Initial value:
= {
.name = "minterpolate",
.description = NULL_IF_CONFIG_SMALL("Frame rate conversion using Motion Interpolation."),
.priv_size = sizeof(MIContext),
.priv_class = &minterpolate_class,
}

Definition at line 1255 of file vf_minterpolate.c.

av_clip
#define av_clip
Definition: common.h:100
obmc_linear32
static const uint8_t obmc_linear32[1024]
Definition: vf_minterpolate.c:51
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *avf_in)
Definition: vf_minterpolate.c:1156
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
minterpolate_outputs
static const AVFilterPad minterpolate_outputs[]
Definition: vf_minterpolate.c:1247
obmc_linear4
static const uint8_t obmc_linear4[16]
Definition: vf_minterpolate.c:116
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
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
minterpolate_inputs
static const AVFilterPad minterpolate_inputs[]
Definition: vf_minterpolate.c:1238
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_minterpolate.c:326
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_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
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_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
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
obmc_linear8
static const uint8_t obmc_linear8[64]
Definition: vf_minterpolate.c:105
NB_PIXEL_MVS
#define NB_PIXEL_MVS
Definition: vf_minterpolate.c:43
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
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_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
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_minterpolate.c:237
obmc_linear16
static const uint8_t obmc_linear16[256]
Definition: vf_minterpolate.c:86
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
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
ALPHA_MAX
#define ALPHA_MAX
Definition: vf_minterpolate.c:46
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
alpha
static const int16_t alpha[]
Definition: ilbcdata.h:55
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
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_minterpolate.c:398
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
MIContext
Definition: vf_minterpolate.c:164
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_minterpolate.c:1215