summaryrefslogtreecommitdiff
path: root/libavcodec/motion_est.c
diff options
context:
space:
mode:
authorVittorio Giovara <vittorio.giovara@gmail.com>2015-07-07 01:20:43 +0100
committerVittorio Giovara <vittorio.giovara@gmail.com>2015-07-27 15:24:56 +0100
commit4b6b1082a73907c7c3de2646c6398bc61320f2c6 (patch)
tree3a85c5b997a1a9fdadd923c921af433dc67f1ef4 /libavcodec/motion_est.c
parent03eb55741427c6608f63972c105e565ca0ba4f15 (diff)
lavc: Deprecate avctx.me_method
This option is extremely codec specific and only a few codecs employ it. Move it to codec private options instead: mpegenc family supports only 3 values, xavs and x264 use 5, and xvid has a different metric entirely. Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
Diffstat (limited to 'libavcodec/motion_est.c')
-rw-r--r--libavcodec/motion_est.c114
1 files changed, 54 insertions, 60 deletions
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index d0c0439319..83d7b39e91 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -309,12 +309,25 @@ int ff_init_me(MpegEncContext *s){
av_log(s->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n");
return -1;
}
- if (s->me_method != ME_ZERO &&
- s->me_method != ME_EPZS &&
- s->me_method != ME_X1) {
- av_log(s->avctx, AV_LOG_ERROR, "me_method is only allowed to be set to zero and epzs; for hex,umh,full and others see dia_size\n");
- return -1;
+
+#if FF_API_MOTION_EST
+FF_DISABLE_DEPRECATION_WARNINGS
+ if (s->motion_est == FF_ME_EPZS) {
+ if (s->me_method == ME_ZERO)
+ s->motion_est = FF_ME_ZERO;
+ else if (s->me_method == ME_EPZS)
+ s->motion_est = FF_ME_EPZS;
+ else if (s->me_method == ME_X1)
+ s->motion_est = FF_ME_XONE;
+ else {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "me_method is only allowed to be set to zero and epzs; "
+ "for hex,umh,full and others see dia_size\n");
+ return -1;
+ }
}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
c->avctx= s->avctx;
@@ -863,7 +876,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
{
MotionEstContext * const c= &s->me;
uint8_t *pix, *ppix;
- int sum, mx, my, dmin;
+ int sum, mx = 0, my = 0, dmin = 0;
int varc; ///< the variance of the block (sum of squared (p[y][x]-average))
int vard; ///< sum of squared differences with the estimated motion vector
int P[10][2];
@@ -895,52 +908,43 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8;
c->mb_var_sum_temp += (varc+128)>>8;
- switch(s->me_method) {
- case ME_ZERO:
- default:
- mx = 0;
- my = 0;
- dmin = 0;
- break;
- case ME_X1:
- case ME_EPZS:
- {
- const int mot_stride = s->b8_stride;
- const int mot_xy = s->block_index[0];
-
- P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0];
- P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1];
-
- if(P_LEFT[0] > (c->xmax<<shift)) P_LEFT[0] = (c->xmax<<shift);
-
- if(!s->first_slice_line) {
- P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0];
- P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1];
- P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0];
- P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1];
- if(P_TOP[1] > (c->ymax<<shift)) P_TOP[1] = (c->ymax<<shift);
- if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift);
- if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift);
+ if (s->motion_est != FF_ME_ZERO) {
+ const int mot_stride = s->b8_stride;
+ const int mot_xy = s->block_index[0];
- P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
- P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
+ P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0];
+ P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1];
- if(s->out_format == FMT_H263){
- c->pred_x = P_MEDIAN[0];
- c->pred_y = P_MEDIAN[1];
- }else { /* mpeg1 at least */
- c->pred_x= P_LEFT[0];
- c->pred_y= P_LEFT[1];
- }
- }else{
- c->pred_x= P_LEFT[0];
- c->pred_y= P_LEFT[1];
- }
+ if (P_LEFT[0] > (c->xmax << shift))
+ P_LEFT[0] = c->xmax << shift;
+ if (!s->first_slice_line) {
+ P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0];
+ P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1];
+ P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0];
+ P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1];
+ if (P_TOP[1] > (c->ymax << shift))
+ P_TOP[1] = c->ymax << shift;
+ if (P_TOPRIGHT[0] < (c->xmin << shift))
+ P_TOPRIGHT[0] = c->xmin << shift;
+ if (P_TOPRIGHT[1] > (c->ymax << shift))
+ P_TOPRIGHT[1] = c->ymax << shift;
+
+ P_MEDIAN[0] = mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]);
+ P_MEDIAN[1] = mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
+
+ if (s->out_format == FMT_H263) {
+ c->pred_x = P_MEDIAN[0];
+ c->pred_y = P_MEDIAN[1];
+ } else { /* mpeg1 at least */
+ c->pred_x = P_LEFT[0];
+ c->pred_y = P_LEFT[1];
+ }
+ } else {
+ c->pred_x = P_LEFT[0];
+ c->pred_y = P_LEFT[1];
}
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16);
-
- break;
}
/* At this point (mx,my) are full-pell and the relative displacement */
@@ -1100,7 +1104,7 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y,
int16_t (*mv_table)[2], int ref_index, int f_code)
{
MotionEstContext * const c= &s->me;
- int mx, my, dmin;
+ int mx = 0, my = 0, dmin = 0;
int P[10][2];
const int shift= 1+s->quarter_sample;
const int mot_stride = s->mb_stride;
@@ -1115,15 +1119,7 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y,
get_limits(s, 16*mb_x, 16*mb_y);
- switch(s->me_method) {
- case ME_ZERO:
- default:
- mx = 0;
- my = 0;
- dmin = 0;
- break;
- case ME_X1:
- case ME_EPZS:
+ if (s->motion_est != FF_ME_ZERO) {
P_LEFT[0] = mv_table[mot_xy - 1][0];
P_LEFT[1] = mv_table[mot_xy - 1][1];
@@ -1152,8 +1148,6 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y,
}
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, ref_index, s->p_mv_table, mv_scale, 0, 16);
-
- break;
}
dmin= c->sub_motion_search(s, &mx, &my, dmin, 0, ref_index, 0, 16);
@@ -1592,7 +1586,7 @@ void ff_estimate_b_frame_motion(MpegEncContext * s,
/* find best f_code for ME which do unlimited searches */
int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type)
{
- if(s->me_method>=ME_EPZS){
+ if (s->motion_est != FF_ME_ZERO) {
int score[8];
int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2);
uint8_t * fcode_tab= s->fcode_tab;