1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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>
This commit is contained in:
Vittorio Giovara 2015-07-07 01:20:43 +01:00
parent 03eb557414
commit 4b6b1082a7
14 changed files with 218 additions and 108 deletions

View File

@ -603,8 +603,6 @@ options follow the Libav ones.
@tab Noise reduction. @tab Noise reduction.
@item me_range @tab merange @item me_range @tab merange
@tab Maximum range of the motion search in pixels. @tab Maximum range of the motion search in pixels.
@item me_method @tab me
@tab Full-pixel motion estimation method.
@item subq @tab subme @item subq @tab subme
@tab Sub-pixel motion estimation method. @tab Sub-pixel motion estimation method.
@item b_strategy @tab b-adapt @item b_strategy @tab b-adapt

View File

@ -548,7 +548,9 @@ typedef struct AVCodecDescriptor {
/** /**
* @ingroup lavc_encoding * @ingroup lavc_encoding
* motion estimation type. * motion estimation type.
* @deprecated use codec private option instead
*/ */
#if FF_API_MOTION_EST
enum Motion_Est_ID { enum Motion_Est_ID {
ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed
ME_FULL, ME_FULL,
@ -560,6 +562,7 @@ enum Motion_Est_ID {
ME_UMH, ///< uneven multi-hexagon search ME_UMH, ///< uneven multi-hexagon search
ME_TESA, ///< transformed exhaustive search algorithm ME_TESA, ///< transformed exhaustive search algorithm
}; };
#endif
/** /**
* @ingroup lavc_decoding * @ingroup lavc_decoding
@ -1281,14 +1284,13 @@ typedef struct AVCodecContext {
*/ */
enum AVPixelFormat pix_fmt; enum AVPixelFormat pix_fmt;
#if FF_API_MOTION_EST
/** /**
* Motion estimation algorithm used for video coding. * This option does nothing
* 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), * @deprecated use codec private options instead
* 8 (umh), 10 (tesa) [7, 8, 10 are x264 specific]
* - encoding: MUST be set by user.
* - decoding: unused
*/ */
int me_method; attribute_deprecated int me_method;
#endif
/** /**
* If non NULL, 'draw_horiz_band' is called by the libavcodec * If non NULL, 'draw_horiz_band' is called by the libavcodec

View File

@ -76,6 +76,7 @@ typedef struct X264Context {
int slice_max_size; int slice_max_size;
char *stats; char *stats;
int nal_hrd; int nal_hrd;
int motion_est;
char *x264_params; char *x264_params;
} X264Context; } X264Context;
@ -394,17 +395,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
x4->params.rc.f_pb_factor = avctx->b_quant_factor; x4->params.rc.f_pb_factor = avctx->b_quant_factor;
x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
if (avctx->me_method == ME_EPZS)
x4->params.analyse.i_me_method = X264_ME_DIA;
else if (avctx->me_method == ME_HEX)
x4->params.analyse.i_me_method = X264_ME_HEX;
else if (avctx->me_method == ME_UMH)
x4->params.analyse.i_me_method = X264_ME_UMH;
else if (avctx->me_method == ME_FULL)
x4->params.analyse.i_me_method = X264_ME_ESA;
else if (avctx->me_method == ME_TESA)
x4->params.analyse.i_me_method = X264_ME_TESA;
if (avctx->gop_size >= 0) if (avctx->gop_size >= 0)
x4->params.i_keyint_max = avctx->gop_size; x4->params.i_keyint_max = avctx->gop_size;
if (avctx->max_b_frames >= 0) if (avctx->max_b_frames >= 0)
@ -493,6 +483,25 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (x4->nal_hrd >= 0) if (x4->nal_hrd >= 0)
x4->params.i_nal_hrd = x4->nal_hrd; x4->params.i_nal_hrd = x4->nal_hrd;
if (x4->motion_est >= 0) {
x4->params.analyse.i_me_method = x4->motion_est;
#if FF_API_MOTION_EST
FF_DISABLE_DEPRECATION_WARNINGS
} else {
if (avctx->me_method == ME_EPZS)
x4->params.analyse.i_me_method = X264_ME_DIA;
else if (avctx->me_method == ME_HEX)
x4->params.analyse.i_me_method = X264_ME_HEX;
else if (avctx->me_method == ME_UMH)
x4->params.analyse.i_me_method = X264_ME_UMH;
else if (avctx->me_method == ME_FULL)
x4->params.analyse.i_me_method = X264_ME_ESA;
else if (avctx->me_method == ME_TESA)
x4->params.analyse.i_me_method = X264_ME_TESA;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
}
if (x4->profile) if (x4->profile)
if (x264_param_apply_profile(&x4->params, x4->profile) < 0) { if (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile); av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile);
@ -675,6 +684,12 @@ static const AVOption options[] = {
{ "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_NONE}, INT_MIN, INT_MAX, VE, "nal-hrd" }, { "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_NONE}, INT_MIN, INT_MAX, VE, "nal-hrd" },
{ "vbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_VBR}, INT_MIN, INT_MAX, VE, "nal-hrd" }, { "vbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_VBR}, INT_MIN, INT_MAX, VE, "nal-hrd" },
{ "cbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_CBR}, INT_MIN, INT_MAX, VE, "nal-hrd" }, { "cbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_CBR}, INT_MIN, INT_MAX, VE, "nal-hrd" },
{ "motion-est", "Set motion estimation method", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA, VE, "motion-est"},
{ "dia", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_DIA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "hex", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_HEX }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "umh", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_UMH }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "x264-params", "Override the x264 configuration using a :-separated list of key=value parameters", OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE }, { "x264-params", "Override the x264 configuration using a :-separated list of key=value parameters", OFFSET(x264_params), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE },
{ NULL }, { NULL },
}; };
@ -694,7 +709,9 @@ static const AVCodecDefault x264_defaults[] = {
{ "trellis", "-1" }, { "trellis", "-1" },
{ "nr", "-1" }, { "nr", "-1" },
{ "me_range", "-1" }, { "me_range", "-1" },
#if FF_API_MOTION_EST
{ "me_method", "-1" }, { "me_method", "-1" },
#endif
{ "subq", "-1" }, { "subq", "-1" },
{ "b_strategy", "-1" }, { "b_strategy", "-1" },
{ "keyint_min", "-1" }, { "keyint_min", "-1" },

View File

@ -53,6 +53,7 @@ typedef struct XavsContext {
int direct_pred; int direct_pred;
int aud; int aud;
int fast_pskip; int fast_pskip;
int motion_est;
int mbtree; int mbtree;
int mixed_refs; int mixed_refs;
@ -271,6 +272,8 @@ static av_cold int XAVS_init(AVCodecContext *avctx)
x4->params.analyse.i_direct_mv_pred = x4->direct_pred; x4->params.analyse.i_direct_mv_pred = x4->direct_pred;
if (x4->fast_pskip >= 0) if (x4->fast_pskip >= 0)
x4->params.analyse.b_fast_pskip = x4->fast_pskip; x4->params.analyse.b_fast_pskip = x4->fast_pskip;
if (x4->motion_est >= 0)
x4->params.analyse.i_me_method = x4->motion_est;
if (x4->mixed_refs >= 0) if (x4->mixed_refs >= 0)
x4->params.analyse.b_mixed_references = x4->mixed_refs; x4->params.analyse.b_mixed_references = x4->mixed_refs;
if (x4->b_bias != INT_MIN) if (x4->b_bias != INT_MIN)
@ -278,6 +281,32 @@ static av_cold int XAVS_init(AVCodecContext *avctx)
if (x4->cplxblur >= 0) if (x4->cplxblur >= 0)
x4->params.rc.f_complexity_blur = x4->cplxblur; x4->params.rc.f_complexity_blur = x4->cplxblur;
#if FF_API_MOTION_EST
FF_DISABLE_DEPRECATION_WARNINGS
if (x4->motion_est < 0) {
switch (avctx->me_method) {
case ME_EPZS:
x4->params.analyse.i_me_method = XAVS_ME_DIA;
break;
case ME_HEX:
x4->params.analyse.i_me_method = XAVS_ME_HEX;
break;
case ME_UMH:
x4->params.analyse.i_me_method = XAVS_ME_UMH;
break;
case ME_FULL:
x4->params.analyse.i_me_method = XAVS_ME_ESA;
break;
case ME_TESA:
x4->params.analyse.i_me_method = XAVS_ME_TESA;
break;
default:
x4->params.analyse.i_me_method = XAVS_ME_HEX;
}
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
x4->params.i_bframe = avctx->max_b_frames; x4->params.i_bframe = avctx->max_b_frames;
/* cabac is not included in AVS JiZhun Profile */ /* cabac is not included in AVS JiZhun Profile */
x4->params.b_cabac = 0; x4->params.b_cabac = 0;
@ -314,26 +343,6 @@ static av_cold int XAVS_init(AVCodecContext *avctx)
x4->params.i_fps_den = avctx->time_base.num; x4->params.i_fps_den = avctx->time_base.num;
x4->params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16; x4->params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16;
switch (avctx->me_method) {
case ME_EPZS:
x4->params.analyse.i_me_method = XAVS_ME_DIA;
break;
case ME_HEX:
x4->params.analyse.i_me_method = XAVS_ME_HEX;
break;
case ME_UMH:
x4->params.analyse.i_me_method = XAVS_ME_UMH;
break;
case ME_FULL:
x4->params.analyse.i_me_method = XAVS_ME_ESA;
break;
case ME_TESA:
x4->params.analyse.i_me_method = XAVS_ME_TESA;
break;
default:
x4->params.analyse.i_me_method = XAVS_ME_HEX;
}
x4->params.analyse.i_me_range = avctx->me_range; x4->params.analyse.i_me_range = avctx->me_range;
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
@ -423,6 +432,13 @@ static const AVOption options[] = {
{ "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 1, VE}, { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 1, VE},
{ "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE }, { "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 1, VE },
{ "fast-pskip", NULL, OFFSET(fast_pskip), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 1, VE}, { "fast-pskip", NULL, OFFSET(fast_pskip), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 1, VE},
{ "motion-est", "Set motion estimation method", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, XAVS_ME_TESA, VE, "motion-est"},
{ "dia", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_DIA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "hex", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_HEX }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "umh", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_UMH }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" },
{ NULL }, { NULL },
}; };

View File

@ -68,6 +68,7 @@ struct xvid_context {
int ssim; /**< SSIM information display mode */ int ssim; /**< SSIM information display mode */
int ssim_acc; /**< SSIM accuracy. 0: accurate. 4: fast. */ int ssim_acc; /**< SSIM accuracy. 0: accurate. 4: fast. */
int gmc; int gmc;
int me_quality; /**< Motion estimation quality. 0: fast 6: best. */
}; };
/** /**
@ -379,26 +380,45 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
/* Decide which ME quality setting to use */ /* Decide which ME quality setting to use */
x->me_flags = 0; x->me_flags = 0;
switch (avctx->me_method) { switch (x->me_quality) {
case ME_FULL: /* Quality 6 */ case 6:
case 5:
x->me_flags |= XVID_ME_EXTSEARCH16 | x->me_flags |= XVID_ME_EXTSEARCH16 |
XVID_ME_EXTSEARCH8; XVID_ME_EXTSEARCH8;
case 4:
case ME_EPZS: /* Quality 4 */ case 3:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 | x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |
XVID_ME_HALFPELREFINE8 | XVID_ME_HALFPELREFINE8 |
XVID_ME_CHROMA_PVOP | XVID_ME_CHROMA_PVOP |
XVID_ME_CHROMA_BVOP; XVID_ME_CHROMA_BVOP;
case 2:
case ME_LOG: /* Quality 2 */ case 1:
case ME_PHODS:
case ME_X1:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 | x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |
XVID_ME_HALFPELREFINE16; XVID_ME_HALFPELREFINE16;
#if FF_API_MOTION_EST
case ME_ZERO: /* Quality 0 */ FF_DISABLE_DEPRECATION_WARNINGS
default:
break; break;
default:
switch (avctx->me_method) {
case ME_FULL: /* Quality 6 */
x->me_flags |= XVID_ME_EXTSEARCH16 |
XVID_ME_EXTSEARCH8;
case ME_EPZS: /* Quality 4 */
x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 |
XVID_ME_HALFPELREFINE8 |
XVID_ME_CHROMA_PVOP |
XVID_ME_CHROMA_BVOP;
case ME_LOG: /* Quality 2 */
case ME_PHODS:
case ME_X1:
x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 |
XVID_ME_HALFPELREFINE16;
case ME_ZERO: /* Quality 0 */
default:
break;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
} }
/* Decide how we should decide blocks */ /* Decide how we should decide blocks */
@ -828,6 +848,7 @@ static const AVOption options[] = {
{ "frame", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "ssim" }, { "frame", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "ssim" },
{ "ssim_acc", "SSIM accuracy", OFFSET(ssim_acc), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, 4, VE }, { "ssim_acc", "SSIM accuracy", OFFSET(ssim_acc), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, 4, VE },
{ "gmc", "use GMC", OFFSET(gmc), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, { "gmc", "use GMC", OFFSET(gmc), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE },
{ "me_quality", "Motion estimation quality", OFFSET(me_quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 6, VE },
{ NULL }, { NULL },
}; };

View File

@ -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"); av_log(s->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n");
return -1; return -1;
} }
if (s->me_method != ME_ZERO &&
s->me_method != ME_EPZS && #if FF_API_MOTION_EST
s->me_method != ME_X1) { FF_DISABLE_DEPRECATION_WARNINGS
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"); if (s->motion_est == FF_ME_EPZS) {
return -1; 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; c->avctx= s->avctx;
@ -863,7 +876,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s,
{ {
MotionEstContext * const c= &s->me; MotionEstContext * const c= &s->me;
uint8_t *pix, *ppix; 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 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 vard; ///< sum of squared differences with the estimated motion vector
int P[10][2]; 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; pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8;
c->mb_var_sum_temp += (varc+128)>>8; c->mb_var_sum_temp += (varc+128)>>8;
switch(s->me_method) { if (s->motion_est != FF_ME_ZERO) {
case ME_ZERO: const int mot_stride = s->b8_stride;
default: const int mot_xy = s->block_index[0];
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[0] = s->current_picture.motion_val[0][mot_xy - 1][0];
P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1]; 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 (P_LEFT[0] > (c->xmax << shift))
P_LEFT[0] = c->xmax << shift;
if(!s->first_slice_line) { if (!s->first_slice_line) {
P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0]; 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_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[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]; 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_TOP[1] > (c->ymax << shift))
if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift); P_TOP[1] = c->ymax << shift;
if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[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[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_MEDIAN[1] = mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]);
if(s->out_format == FMT_H263){ if (s->out_format == FMT_H263) {
c->pred_x = P_MEDIAN[0]; c->pred_x = P_MEDIAN[0];
c->pred_y = P_MEDIAN[1]; c->pred_y = P_MEDIAN[1];
}else { /* mpeg1 at least */ } else { /* mpeg1 at least */
c->pred_x= P_LEFT[0]; c->pred_x = P_LEFT[0];
c->pred_y= P_LEFT[1]; c->pred_y = P_LEFT[1];
}
}else{
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); 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 */ /* 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) int16_t (*mv_table)[2], int ref_index, int f_code)
{ {
MotionEstContext * const c= &s->me; MotionEstContext * const c= &s->me;
int mx, my, dmin; int mx = 0, my = 0, dmin = 0;
int P[10][2]; int P[10][2];
const int shift= 1+s->quarter_sample; const int shift= 1+s->quarter_sample;
const int mot_stride = s->mb_stride; 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); get_limits(s, 16*mb_x, 16*mb_y);
switch(s->me_method) { if (s->motion_est != FF_ME_ZERO) {
case ME_ZERO:
default:
mx = 0;
my = 0;
dmin = 0;
break;
case ME_X1:
case ME_EPZS:
P_LEFT[0] = mv_table[mot_xy - 1][0]; P_LEFT[0] = mv_table[mot_xy - 1][0];
P_LEFT[1] = mv_table[mot_xy - 1][1]; 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); 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); 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 */ /* find best f_code for ME which do unlimited searches */
int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type) 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 score[8];
int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2); int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2);
uint8_t * fcode_tab= s->fcode_tab; uint8_t * fcode_tab= s->fcode_tab;

View File

@ -31,6 +31,10 @@ struct MpegEncContext;
#define MAX_MV 2048 #define MAX_MV 2048
#define FF_ME_ZERO 0
#define FF_ME_EPZS 1
#define FF_ME_XONE 2
/** /**
* Motion estimation context. * Motion estimation context.
*/ */

View File

@ -256,7 +256,10 @@ typedef struct MpegEncContext {
int16_t (*b_field_mv_table[2][2][2])[2];///< MV table (4MV per MB) interlaced b-frame encoding int16_t (*b_field_mv_table[2][2][2])[2];///< MV table (4MV per MB) interlaced b-frame encoding
uint8_t (*p_field_select_table[2]); uint8_t (*p_field_select_table[2]);
uint8_t (*b_field_select_table[2][2]); uint8_t (*b_field_select_table[2][2]);
#if FF_API_MOTION_EST
int me_method; ///< ME algorithm int me_method; ///< ME algorithm
#endif
int motion_est; ///< ME algorithm
int mv_dir; int mv_dir;
#define MV_DIR_FORWARD 1 #define MV_DIR_FORWARD 1
#define MV_DIR_BACKWARD 2 #define MV_DIR_BACKWARD 2
@ -576,6 +579,10 @@ typedef struct MpegEncContext {
{"ibias", "intra quant bias", FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"ibias", "intra quant bias", FF_MPV_OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"pbias", "inter quant bias", FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \ {"pbias", "inter quant bias", FF_MPV_OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.i64 = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"rc_strategy", "ratecontrol method", FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \ {"rc_strategy", "ratecontrol method", FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \
{"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, FF_MPV_OPT_FLAGS, "motion_est" }, \
{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \
extern const AVOption ff_mpv_generic_options[]; extern const AVOption ff_mpv_generic_options[];

View File

@ -324,7 +324,11 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
s->intra_only = 0; s->intra_only = 0;
} }
#if FF_API_MOTION_EST
FF_DISABLE_DEPRECATION_WARNINGS
s->me_method = avctx->me_method; s->me_method = avctx->me_method;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
/* Fixed QSCALE */ /* Fixed QSCALE */
s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE); s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE);

View File

@ -84,6 +84,7 @@ static const AVOption avcodec_options[] = {
{"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"}, {"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"},
{"ignorecrop", "ignore cropping information from sps", 1, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"}, {"ignorecrop", "ignore cropping information from sps", 1, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"},
{"local_header", "place global headers at every keyframe instead of in extradata", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"}, {"local_header", "place global headers at every keyframe instead of in extradata", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"},
#if FF_API_MOTION_EST
{"me_method", "set motion estimation method", OFFSET(me_method), AV_OPT_TYPE_INT, {.i64 = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method"}, {"me_method", "set motion estimation method", OFFSET(me_method), AV_OPT_TYPE_INT, {.i64 = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method"},
{"zero", "zero motion estimation (fastest)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_ZERO }, INT_MIN, INT_MAX, V|E, "me_method" }, {"zero", "zero motion estimation (fastest)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_ZERO }, INT_MIN, INT_MAX, V|E, "me_method" },
{"full", "full motion estimation (slowest)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" }, {"full", "full motion estimation (slowest)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" },
@ -96,6 +97,7 @@ static const AVOption avcodec_options[] = {
{"x1", "X1 motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_X1 }, INT_MIN, INT_MAX, V|E, "me_method" }, {"x1", "X1 motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_X1 }, INT_MIN, INT_MAX, V|E, "me_method" },
{"hex", "hex motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_HEX }, INT_MIN, INT_MAX, V|E, "me_method" }, {"hex", "hex motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_HEX }, INT_MIN, INT_MAX, V|E, "me_method" },
{"umh", "umh motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" }, {"umh", "umh motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" },
#endif
{"extradata_size", NULL, OFFSET(extradata_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, {"extradata_size", NULL, OFFSET(extradata_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX},
{"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX}, {"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX},
{"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E}, {"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},

View File

@ -272,7 +272,20 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane,
s->m.b8_stride = 2 * s->m.mb_width + 1; s->m.b8_stride = 2 * s->m.mb_width + 1;
s->m.f_code = 1; s->m.f_code = 1;
s->m.pict_type = s->pict_type; s->m.pict_type = s->pict_type;
#if FF_API_MOTION_EST
FF_DISABLE_DEPRECATION_WARNINGS
s->m.me_method = s->avctx->me_method; s->m.me_method = s->avctx->me_method;
if (s->motion_est == FF_ME_EPZS) {
if (s->avctx->me_method == ME_ZERO)
s->motion_est = FF_ME_ZERO;
else if (s->avctx->me_method == ME_EPZS)
s->motion_est = FF_ME_EPZS;
else if (s->avctx->me_method == ME_X1)
s->motion_est = FF_ME_XONE;
}
FF_ENABLE_DEPRECATION_WARNINGS
#endif
s->m.motion_est = s->motion_est;
s->m.me.scene_change_score = 0; s->m.me.scene_change_score = 0;
// s->m.out_format = FMT_H263; // s->m.out_format = FMT_H263;
// s->m.unrestricted_mv = 1; // s->m.unrestricted_mv = 1;
@ -654,12 +667,31 @@ FF_ENABLE_DEPRECATION_WARNINGS
return 0; return 0;
} }
#define OFFSET(x) offsetof(struct SVQ1EncContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
static const AVOption options[] = {
{ "motion-est", "Motion estimation algorithm", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = FF_ME_EPZS }, FF_ME_ZERO, FF_ME_XONE, VE, "motion-est"},
{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion-est" },
{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion-est" },
{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion-est" },
{ NULL },
};
static const AVClass svq1enc_class = {
.class_name = "svq1enc",
.item_name = av_default_item_name,
.option = options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_svq1_encoder = { AVCodec ff_svq1_encoder = {
.name = "svq1", .name = "svq1",
.long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"),
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_SVQ1, .id = AV_CODEC_ID_SVQ1,
.priv_data_size = sizeof(SVQ1EncContext), .priv_data_size = sizeof(SVQ1EncContext),
.priv_class = &svq1enc_class,
.init = svq1_encode_init, .init = svq1_encode_init,
.encode2 = svq1_encode_frame, .encode2 = svq1_encode_frame,
.close = svq1_encode_end, .close = svq1_encode_end,

View File

@ -72,6 +72,8 @@ typedef struct SVQ1EncContext {
uint8_t *scratchbuf; uint8_t *scratchbuf;
int motion_est;
int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2, int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
int size); int size);
} SVQ1EncContext; } SVQ1EncContext;

View File

@ -30,7 +30,7 @@
#define LIBAVCODEC_VERSION_MAJOR 56 #define LIBAVCODEC_VERSION_MAJOR 56
#define LIBAVCODEC_VERSION_MINOR 34 #define LIBAVCODEC_VERSION_MINOR 34
#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_MICRO 1
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \
@ -174,5 +174,8 @@
#ifndef FF_API_CODED_FRAME #ifndef FF_API_CODED_FRAME
#define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59) #define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59)
#endif #endif
#ifndef FF_API_MOTION_EST
#define FF_API_MOTION_EST (LIBAVCODEC_VERSION_MAJOR < 59)
#endif
#endif /* AVCODEC_VERSION_H */ #endif /* AVCODEC_VERSION_H */

View File

@ -216,12 +216,20 @@ void ff_wmv2_encode_mb(MpegEncContext *s, int16_t block[6][64],
ff_msmpeg4_encode_block(s, block[i], i); ff_msmpeg4_encode_block(s, block[i], i);
} }
static const AVClass wmv2_class = {
.class_name = "wmv2 encoder",
.item_name = av_default_item_name,
.option = ff_mpv_generic_options,
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_wmv2_encoder = { AVCodec ff_wmv2_encoder = {
.name = "wmv2", .name = "wmv2",
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"), .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"),
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_WMV2, .id = AV_CODEC_ID_WMV2,
.priv_data_size = sizeof(Wmv2Context), .priv_data_size = sizeof(Wmv2Context),
.priv_class = &wmv2_class,
.init = wmv2_encode_init, .init = wmv2_encode_init,
.encode2 = ff_mpv_encode_picture, .encode2 = ff_mpv_encode_picture,
.close = ff_mpv_encode_end, .close = ff_mpv_encode_end,