FFmpeg
Loading...
Searching...
No Matches
motion_est.h
Go to the documentation of this file.
1/*
2 * Motion estimation
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef AVCODEC_MOTION_EST_H
22#define AVCODEC_MOTION_EST_H
23
24#include <stdint.h>
25
26#include "avcodec.h"
27#include "hpeldsp.h"
28#include "me_cmp.h"
29#include "qpeldsp.h"
30
31typedef struct MPVEncContext MPVEncContext;
33
34#if ARCH_IA64 // Limit static arrays to avoid gcc failing "short data segment overflowed"
35#define MAX_MV 1024
36#else
37#define MAX_MV 4096
38#endif
39#define MAX_DMV (2*MAX_MV)
40#define ME_MAP_SIZE 64
41
42#define FF_ME_ZERO 0
43#define FF_ME_EPZS 1
44#define FF_ME_XONE 2
45
46/**
47 * Motion estimation context.
48 */
49typedef struct MotionEstContext {
51 int motion_est; ///< ME algorithm
52 int skip; ///< set if ME is skipped for the current MB
53 int co_located_mv[4][2]; ///< mv from last P-frame for direct mode ME
54 int direct_basis_mv[4][2];
55 uint8_t *scratchpad; /**< data area for the ME algo, so that
56 * the ME does not need to malloc/free. */
57 uint8_t *temp;
60 int penalty_factor; /**< an estimate of the bits required to
61 * code a given mv value, e.g. (1,0) takes
62 * more bits than (0,0). We have to
63 * estimate whether any reduction in
64 * residual is worth the extra bits. */
67 int flags;
70 int pre_pass; ///< = 1 for the pre pass
72 int unrestricted_mv; ///< mv can point outside of the coded picture
73 int xmin;
74 int xmax;
75 int ymin;
76 int ymax;
77 int pred_x;
78 int pred_y;
79 const uint8_t *src[4][4];
80 const uint8_t *ref[4][4];
81 int stride;
83 /* temp variables for picture complexity calculation */
87
92
95
100 const uint8_t (*mv_penalty)[MAX_DMV * 2 + 1]; ///< bit amount needed to encode a MV
101 const uint8_t *current_mv_penalty;
103 int *mx_ptr, int *my_ptr, int dmin,
104 int src_index, int ref_index,
105 int size, int h);
106
107 uint32_t map[ME_MAP_SIZE]; ///< map to avoid duplicate evaluations
108 uint32_t score_map[ME_MAP_SIZE];///< map to store the scores
110
111/**
112 * Performs one-time initialization of the MotionEstContext.
113 */
115 const struct MECmpContext *mecc, int mpvenc);
116
118
119void ff_estimate_p_frame_motion(MPVEncContext *s, int mb_x, int mb_y);
120void ff_estimate_b_frame_motion(MPVEncContext *s, int mb_x, int mb_y);
121
123 int mb_x, int mb_y);
124
125int ff_epzs_motion_search(MPVEncContext *s, int *mx_ptr, int *my_ptr,
126 int P[10][2], int src_index, int ref_index,
127 const int16_t (*last_mv)[2], int ref_mv_scale,
128 int size, int h);
129
130int ff_get_mb_score(MPVEncContext *s, int mx, int my, int src_index,
131 int ref_index, int size, int h, int add_rate);
132
134 const int16_t (*mv_table)[2], int type);
135
137void ff_fix_long_mvs(MPVEncContext *s, uint8_t *field_select_table,
138 int field_select, int16_t (*mv_table)[2], int f_code,
139 int type, int truncate);
140
141#endif /* AVCODEC_MOTION_EST_H */
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
Definition dsp.h:57
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
Definition dsp.h:57
Libavcodec external API header.
#define s(width, name)
Definition cbs_vp9.c:198
long long int64_t
Definition coverity.c:34
Half-pel DSP functions.
void(* op_pixels_func)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
Average and put pixel Widths can be 16, 8, 4 or 2.
Definition hpeldsp.h:39
cl_device_type type
int(* me_cmp_func)(MPVEncContext *c, const uint8_t *blk1, const uint8_t *blk2, ptrdiff_t stride, int h)
Definition me_cmp.h:45
int ff_epzs_motion_search(MPVEncContext *s, int *mx_ptr, int *my_ptr, int P[10][2], int src_index, int ref_index, const int16_t(*last_mv)[2], int ref_mv_scale, int size, int h)
void ff_estimate_p_frame_motion(MPVEncContext *s, int mb_x, int mb_y)
Definition motion_est.c:888
void ff_fix_long_mvs(MPVEncContext *s, uint8_t *field_select_table, int field_select, int16_t(*mv_table)[2], int f_code, int type, int truncate)
#define ME_MAP_SIZE
Definition motion_est.h:40
int ff_me_init(MotionEstContext *c, struct AVCodecContext *avctx, const struct MECmpContext *mecc, int mpvenc)
Performs one-time initialization of the MotionEstContext.
void ff_me_init_pic(MPVEncContext *s)
Definition motion_est.c:371
void ff_fix_long_p_mvs(MPVEncContext *s, int type)
int ff_pre_estimate_p_frame_motion(MPVEncContext *s, int mb_x, int mb_y)
int ff_get_mb_score(MPVEncContext *s, int mx, int my, int src_index, int ref_index, int size, int h, int add_rate)
void ff_estimate_b_frame_motion(MPVEncContext *s, int mb_x, int mb_y)
int ff_get_best_fcode(MPVMainEncContext *m, const int16_t(*mv_table)[2], int type)
#define MAX_DMV
Definition motion_est.h:39
#define P
quarterpel DSP functions
void(* qpel_mc_func)(uint8_t *dst, const uint8_t *src, ptrdiff_t stride)
Definition qpeldsp.h:65
main external API structure.
Definition avcodec.h:443
Motion estimation context.
Definition motion_est.h:49
const uint8_t * src[4][4]
Definition motion_est.h:79
uint8_t * scratchpad
data area for the ME algo, so that the ME does not need to malloc/free.
Definition motion_est.h:55
const uint8_t(* mv_penalty)[MAX_DMV *2+1]
bit amount needed to encode a MV
Definition motion_est.h:100
AVCodecContext * avctx
Definition motion_est.h:50
const uint8_t * current_mv_penalty
Definition motion_est.h:101
uint32_t score_map[ME_MAP_SIZE]
map to store the scores
Definition motion_est.h:108
int skip
set if ME is skipped for the current MB
Definition motion_est.h:52
qpel_mc_func(* qpel_put)[16]
Definition motion_est.h:98
int pre_pass
= 1 for the pre pass
Definition motion_est.h:70
int64_t mb_var_sum_temp
Definition motion_est.h:85
me_cmp_func mb_cmp[6]
Definition motion_est.h:91
int unrestricted_mv
mv can point outside of the coded picture
Definition motion_est.h:72
uint8_t * temp
Definition motion_est.h:57
int motion_est
ME algorithm.
Definition motion_est.h:51
unsigned map_generation
Definition motion_est.h:58
int penalty_factor
an estimate of the bits required to code a given mv value, e.g.
Definition motion_est.h:60
int direct_basis_mv[4][2]
Definition motion_est.h:54
int64_t mc_mb_var_sum_temp
Definition motion_est.h:84
me_cmp_func me_pre_cmp[6]
Definition motion_est.h:88
op_pixels_func(* hpel_avg)[4]
Definition motion_est.h:97
int(* sub_motion_search)(MPVEncContext *s, int *mx_ptr, int *my_ptr, int dmin, int src_index, int ref_index, int size, int h)
Definition motion_est.h:102
me_cmp_func pix_abs[2][4]
Definition motion_est.h:93
me_cmp_func sse
Definition motion_est.h:94
me_cmp_func me_sub_cmp[6]
Definition motion_est.h:90
op_pixels_func(* hpel_put)[4]
Definition motion_est.h:96
int co_located_mv[4][2]
mv from last P-frame for direct mode ME
Definition motion_est.h:53
const uint8_t * ref[4][4]
Definition motion_est.h:80
uint32_t map[ME_MAP_SIZE]
map to avoid duplicate evaluations
Definition motion_est.h:107
qpel_mc_func(* qpel_avg)[16]
Definition motion_est.h:99
me_cmp_func me_cmp[6]
Definition motion_est.h:89
int size
static double c[64]