FFmpeg
Macros | Functions
me_cmp.c File Reference
#include <stddef.h>
#include "libavutil/attributes.h"
#include "libavutil/internal.h"
#include "libavutil/mem_internal.h"
#include "avcodec.h"
#include "copy_block.h"
#include "simple_idct.h"
#include "me_cmp.h"
#include "mpegvideoenc.h"
#include "config.h"
#include "config_components.h"

Go to the source code of this file.

Macros

#define avg2(a, b)   (((a) + (b) + 1) >> 1)
 
#define avg4(a, b, c, d)   (((a) + (b) + (c) + (d) + 2) >> 2)
 
#define V(x)   (pix1[x] - pix2[x])
 
#define V(x)   (pix1[x] - pix2[x])
 
#define ENTRY(CMP_FLAG, ARRAY, MPVENC_ONLY)
 
#define BUTTERFLY2(o1, o2, i1, i2)
 
#define BUTTERFLY1(x, y)
 
#define BUTTERFLYA(x, y)   (FFABS((x) + (y)) + FFABS((x) - (y)))
 
#define VSAD_INTRA(size)
 
#define VSAD(size)
 
#define SQ(a)   ((a) * (a))
 
#define VSSE_INTRA(size)
 
#define VSSE(size)
 
#define WRAPPER8_16_SQ(name8, name16)
 
#define SET_CMP_FUNC(name)
 

Functions

static int sse4_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int sse8_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int sse16_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int sum_abs_dctelem_c (const int16_t *block)
 
static int pix_abs16_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int pix_median_abs16_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int pix_abs16_x2_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int pix_abs16_y2_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int pix_abs16_xy2_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int pix_abs8_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int pix_median_abs8_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int pix_abs8_x2_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int pix_abs8_y2_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int pix_abs8_xy2_c (MPVEncContext *unused, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t stride, int h)
 
static int nsse16_c (MPVEncContext *const c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h)
 
static int nsse8_c (MPVEncContext *const c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h)
 
static int zero_cmp (MPVEncContext *s, const uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h)
 
av_cold int ff_set_cmp (const MECmpContext *c, me_cmp_func *cmp, int type, int mpvenc)
 Fill the function pointer array cmp[6] with me_cmp_funcs from c based upon type. More...
 
static int hadamard8_diff8x8_c (MPVEncContext *unused, const uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h)
 
static int hadamard8_intra8x8_c (MPVEncContext *unused, const uint8_t *src, const uint8_t *dummy, ptrdiff_t stride, int h)
 
static int dct_sad8x8_c (MPVEncContext *const s, const uint8_t *src1, const uint8_t *src2, ptrdiff_t stride, int h)
 
static int dct_max8x8_c (MPVEncContext *const s, const uint8_t *src1, const uint8_t *src2, ptrdiff_t stride, int h)
 
static int quant_psnr8x8_c (MPVEncContext *const s, const uint8_t *src1, const uint8_t *src2, ptrdiff_t stride, int h)
 
static int rd8x8_c (MPVEncContext *const s, const uint8_t *src1, const uint8_t *src2, ptrdiff_t stride, int h)
 
static int bit8x8_c (MPVEncContext *const s, const uint8_t *src1, const uint8_t *src2, ptrdiff_t stride, int h)
 
av_cold void ff_me_cmp_init (MECmpContext *c, AVCodecContext *avctx)
 

Macro Definition Documentation

◆ avg2

#define avg2 (   a,
  b 
)    (((a) + (b) + 1) >> 1)

Definition at line 113 of file me_cmp.c.

◆ avg4

#define avg4 (   a,
  b,
  c,
 
)    (((a) + (b) + (c) + (d) + 2) >> 2)

Definition at line 114 of file me_cmp.c.

◆ V [1/2]

#define V (   x)    (pix1[x] - pix2[x])

◆ V [2/2]

#define V (   x)    (pix1[x] - pix2[x])

◆ ENTRY

#define ENTRY (   CMP_FLAG,
  ARRAY,
  MPVENC_ONLY 
)
Value:
[FF_CMP_ ## CMP_FLAG] = { \
.offset = offsetof(MECmpContext, ARRAY), \
.mpv_only = MPVENC_ONLY, \
.available = 1, \
}

◆ BUTTERFLY2

#define BUTTERFLY2 (   o1,
  o2,
  i1,
  i2 
)
Value:
o1 = (i1) + (i2); \
o2 = (i1) - (i2);

Definition at line 498 of file me_cmp.c.

◆ BUTTERFLY1

#define BUTTERFLY1 (   x,
 
)
Value:
{ \
int a, b; \
a = x; \
b = y; \
x = a + b; \
y = a - b; \
}

Definition at line 502 of file me_cmp.c.

◆ BUTTERFLYA

#define BUTTERFLYA (   x,
 
)    (FFABS((x) + (y)) + FFABS((x) - (y)))

Definition at line 511 of file me_cmp.c.

◆ VSAD_INTRA

#define VSAD_INTRA (   size)
Value:
static int vsad_intra ## size ## _c(MPVEncContext *unused, \
const uint8_t *s, const uint8_t *dummy, \
ptrdiff_t stride, int h) \
{ \
int score = 0, x, y; \
for (y = 1; y < h; y++) { \
for (x = 0; x < size; x += 4) { \
score += FFABS(s[x] - s[x + stride]) + \
FFABS(s[x + 1] - s[x + stride + 1]) + \
FFABS(s[x + 2] - s[x + 2 + stride]) + \
FFABS(s[x + 3] - s[x + 3 + stride]); \
} \
s += stride; \
} \
\
return score; \
}

Definition at line 850 of file me_cmp.c.

◆ VSAD

#define VSAD (   size)
Value:
static int vsad ## size ## _c(MPVEncContext *unused, \
const uint8_t *s1, const uint8_t *s2, \
ptrdiff_t stride, int h) \
{ \
int score = 0, x, y; \
for (y = 1; y < h; y++) { \
for (x = 0; x < size; x++) \
score += FFABS(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]); \
s1 += stride; \
s2 += stride; \
} \
\
return score; \
}

Definition at line 872 of file me_cmp.c.

◆ SQ

#define SQ (   a)    ((a) * (a))

Definition at line 891 of file me_cmp.c.

◆ VSSE_INTRA

#define VSSE_INTRA (   size)
Value:
static int vsse_intra ## size ## _c(MPVEncContext *unused, \
const uint8_t *s, const uint8_t *dummy, \
ptrdiff_t stride, int h) \
{ \
int score = 0, x, y; \
for (y = 1; y < h; y++) { \
for (x = 0; x < size; x += 4) { \
score += SQ(s[x] - s[x + stride]) + \
SQ(s[x + 1] - s[x + stride + 1]) + \
SQ(s[x + 2] - s[x + stride + 2]) + \
SQ(s[x + 3] - s[x + stride + 3]); \
} \
s += stride; \
} \
\
return score; \
}

Definition at line 892 of file me_cmp.c.

◆ VSSE

#define VSSE (   size)
Value:
static int vsse ## size ## _c(MPVEncContext *unused, const uint8_t *s1, \
const uint8_t *s2, ptrdiff_t stride, int h) \
{ \
int score = 0, x, y; \
for (y = 1; y < h; y++) { \
for (x = 0; x < size; x++) \
score += SQ(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]); \
s1 += stride; \
s2 += stride; \
} \
\
return score; \
}

Definition at line 914 of file me_cmp.c.

◆ WRAPPER8_16_SQ

#define WRAPPER8_16_SQ (   name8,
  name16 
)
Value:
static int name16(MPVEncContext *const s, const uint8_t *dst, \
const uint8_t *src, ptrdiff_t stride, int h) \
{ \
int score = 0; \
\
score += name8(s, dst, src, stride, 8); \
score += name8(s, dst + 8, src + 8, stride, 8); \
if (h == 16) { \
dst += 8 * stride; \
src += 8 * stride; \
score += name8(s, dst, src, stride, 8); \
score += name8(s, dst + 8, src + 8, stride, 8); \
} \
return score; \
}

Definition at line 932 of file me_cmp.c.

◆ SET_CMP_FUNC

#define SET_CMP_FUNC (   name)
Value:
c->name[0] = name ## 16_c; \
c->name[1] = name ## 8x8_c;

Function Documentation

◆ sse4_c()

static int sse4_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 36 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ sse8_c()

static int sse8_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 53 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ sse16_c()

static int sse16_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 74 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ sum_abs_dctelem_c()

static int sum_abs_dctelem_c ( const int16_t *  block)
static

Definition at line 104 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_abs16_c()

static int pix_abs16_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
inlinestatic

Definition at line 116 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_median_abs16_c()

static int pix_median_abs16_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
inlinestatic

Definition at line 144 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_abs16_x2_c()

static int pix_abs16_x2_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 183 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_abs16_y2_c()

static int pix_abs16_y2_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 211 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_abs16_xy2_c()

static int pix_abs16_xy2_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 241 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_abs8_c()

static int pix_abs8_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
inlinestatic

Definition at line 271 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_median_abs8_c()

static int pix_median_abs8_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
inlinestatic

Definition at line 291 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_abs8_x2_c()

static int pix_abs8_x2_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 322 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_abs8_y2_c()

static int pix_abs8_y2_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 342 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ pix_abs8_xy2_c()

static int pix_abs8_xy2_c ( MPVEncContext unused,
const uint8_t *  pix1,
const uint8_t *  pix2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 364 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ nsse16_c()

static int nsse16_c ( MPVEncContext *const  c,
const uint8_t *  s1,
const uint8_t *  s2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 386 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ nsse8_c()

static int nsse8_c ( MPVEncContext *const  c,
const uint8_t *  s1,
const uint8_t *  s2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 411 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ zero_cmp()

static int zero_cmp ( MPVEncContext s,
const uint8_t *  a,
const uint8_t *  b,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 436 of file me_cmp.c.

Referenced by ff_set_cmp().

◆ ff_set_cmp()

av_cold int ff_set_cmp ( const MECmpContext c,
me_cmp_func cmp,
int  type,
int  mpvenc 
)

Fill the function pointer array cmp[6] with me_cmp_funcs from c based upon type.

If mpvenc is not set, an error is returned if the type of comparison functions requires an initialized MPVEncContext.

Definition at line 442 of file me_cmp.c.

Referenced by dvvideo_encode_init(), ff_me_init(), and me_cmp_init().

◆ hadamard8_diff8x8_c()

static int hadamard8_diff8x8_c ( MPVEncContext unused,
const uint8_t *  dst,
const uint8_t *  src,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 513 of file me_cmp.c.

◆ hadamard8_intra8x8_c()

static int hadamard8_intra8x8_c ( MPVEncContext unused,
const uint8_t *  src,
const uint8_t *  dummy,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 563 of file me_cmp.c.

Referenced by ff_me_cmp_init().

◆ dct_sad8x8_c()

static int dct_sad8x8_c ( MPVEncContext *const  s,
const uint8_t *  src1,
const uint8_t *  src2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 613 of file me_cmp.c.

◆ dct_max8x8_c()

static int dct_max8x8_c ( MPVEncContext *const  s,
const uint8_t *  src1,
const uint8_t *  src2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 677 of file me_cmp.c.

◆ quant_psnr8x8_c()

static int quant_psnr8x8_c ( MPVEncContext *const  s,
const uint8_t *  src1,
const uint8_t *  src2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 692 of file me_cmp.c.

◆ rd8x8_c()

static int rd8x8_c ( MPVEncContext *const  s,
const uint8_t *  src1,
const uint8_t *  src2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 716 of file me_cmp.c.

◆ bit8x8_c()

static int bit8x8_c ( MPVEncContext *const  s,
const uint8_t *  src1,
const uint8_t *  src2,
ptrdiff_t  stride,
int  h 
)
static

Definition at line 791 of file me_cmp.c.

◆ ff_me_cmp_init()

av_cold void ff_me_cmp_init ( MECmpContext c,
AVCodecContext avctx 
)
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
MPVEncContext
Definition: mpegvideoenc.h:45
b
#define b
Definition: input.c:42
dummy
int dummy
Definition: motion.c:66
s
#define s(width, name)
Definition: cbs_vp9.c:198
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:74
MECmpContext
Definition: me_cmp.h:50
SQ
#define SQ(a)
Definition: me_cmp.c:891
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:424
size
int size
Definition: twinvq_data.h:10344
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
stride
#define stride
Definition: h264pred_template.c:536
h
h
Definition: vp9dsp_template.c:2070
src
#define src
Definition: vp8dsp.c:248