This option is extremely codec specific and only a few codecs employ it. Move it to codec private options instead: mpegenc family only support 3 values, xavs and x264 use 5, while xvid has a different metric (0-6).
Signed-off-by: Vittorio Giovara <[email protected]> --- Moved the option to codec private as requested. Vittorio doc/encoders.texi | 2 - libavcodec/avcodec.h | 14 ++++--- libavcodec/libx264.c | 23 ++++++------ libavcodec/libxavs.c | 30 +++++---------- libavcodec/libxvid.c | 21 +++++------ libavcodec/motion_est.c | 94 +++++++++++++++++++--------------------------- libavcodec/motion_est.h | 4 ++ libavcodec/mpegvideo.h | 6 ++- libavcodec/mpegvideo_enc.c | 2 - libavcodec/options_table.h | 2 + libavcodec/svq1enc.c | 21 ++++++++++- libavcodec/svq1enc.h | 2 + libavcodec/version.h | 5 ++- 13 files changed, 115 insertions(+), 111 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 94d8340..779a469 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -603,8 +603,6 @@ options follow the Libav ones. @tab Noise reduction. @item me_range @tab merange @tab Maximum range of the motion search in pixels. -@item me_method @tab me -@tab Full-pixel motion estimation method. @item subq @tab subme @tab Sub-pixel motion estimation method. @item b_strategy @tab b-adapt diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index e8be196..3da9f9a 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -548,7 +548,9 @@ typedef struct AVCodecDescriptor { /** * @ingroup lavc_encoding * motion estimation type. + * @deprecated use codec private option instead */ +#if FF_API_MOTION_EST enum Motion_Est_ID { ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed ME_FULL, @@ -560,6 +562,7 @@ enum Motion_Est_ID { ME_UMH, ///< uneven multi-hexagon search ME_TESA, ///< transformed exhaustive search algorithm }; +#endif /** * @ingroup lavc_decoding @@ -1274,14 +1277,13 @@ typedef struct AVCodecContext { */ enum AVPixelFormat pix_fmt; +#if FF_API_MOTION_EST /** - * Motion estimation algorithm used for video coding. - * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), - * 8 (umh), 10 (tesa) [7, 8, 10 are x264 specific] - * - encoding: MUST be set by user. - * - decoding: unused + * This option does nothing + * @deprecated use codec private options instead */ - int me_method; + attribute_deprecated int me_method; +#endif /** * If non NULL, 'draw_horiz_band' is called by the libavcodec diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 7c502fd..c18038e 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -76,6 +76,7 @@ typedef struct X264Context { int slice_max_size; char *stats; int nal_hrd; + int motion_est; char *x264_params; } X264Context; @@ -374,17 +375,6 @@ static av_cold int X264_init(AVCodecContext *avctx) x4->params.rc.f_pb_factor = avctx->b_quant_factor; 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) x4->params.i_keyint_max = avctx->gop_size; if (avctx->max_b_frames >= 0) @@ -473,6 +463,9 @@ static av_cold int X264_init(AVCodecContext *avctx) if (x4->nal_hrd >= 0) x4->params.i_nal_hrd = x4->nal_hrd; + if (x4->motion_est >= 0) + x4->params.analyse.i_me_method = x4->motion_est; + if (x4->profile) if (x264_param_apply_profile(&x4->params, x4->profile) < 0) { av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile); @@ -659,6 +652,12 @@ static const AVOption options[] = { { "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" }, { "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 }, { NULL }, }; @@ -685,7 +684,9 @@ static const AVCodecDefault x264_defaults[] = { { "trellis", "-1" }, { "nr", "-1" }, { "me_range", "-1" }, +#if FF_API_MOTION_EST { "me_method", "-1" }, +#endif { "subq", "-1" }, { "b_strategy", "-1" }, { "keyint_min", "-1" }, diff --git a/libavcodec/libxavs.c b/libavcodec/libxavs.c index 7a74e36..4889a86 100644 --- a/libavcodec/libxavs.c +++ b/libavcodec/libxavs.c @@ -53,6 +53,7 @@ typedef struct XavsContext { int direct_pred; int aud; int fast_pskip; + int motion_est; int mbtree; int mixed_refs; @@ -251,6 +252,8 @@ static av_cold int XAVS_init(AVCodecContext *avctx) x4->params.analyse.i_direct_mv_pred = x4->direct_pred; if (x4->fast_pskip >= 0) 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) x4->params.analyse.b_mixed_references = x4->mixed_refs; if (x4->b_bias != INT_MIN) @@ -294,26 +297,6 @@ static av_cold int XAVS_init(AVCodecContext *avctx) x4->params.i_fps_den = avctx->time_base.num; 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_subpel_refine = avctx->me_subpel_quality; @@ -407,6 +390,13 @@ static const AVOption options[] = { { "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 }, { "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 }, }; diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index 97ff95b..7a231f9 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -68,6 +68,7 @@ struct xvid_context { int ssim; /**< SSIM information display mode */ int ssim_acc; /**< SSIM accuracy. 0: accurate. 4: fast. */ int gmc; + int me_quality; /**< Motion estimation quality. 0: fast 6: best. */ }; /** @@ -379,26 +380,21 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) /* Decide which ME quality setting to use */ x->me_flags = 0; - switch (avctx->me_method) { - case ME_FULL: /* Quality 6 */ + switch (x->me_quality) { + case 6: + case 5: x->me_flags |= XVID_ME_EXTSEARCH16 | XVID_ME_EXTSEARCH8; - - case ME_EPZS: /* Quality 4 */ + case 4: + case 3: 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: + case 2: + case 1: x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 | XVID_ME_HALFPELREFINE16; - - case ME_ZERO: /* Quality 0 */ - default: - break; } /* Decide how we should decide blocks */ @@ -814,6 +810,7 @@ static const AVOption options[] = { { "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 }, { "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 }, }; diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index d0c0439..8b15400 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -309,12 +309,6 @@ 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; - } c->avctx= s->avctx; @@ -895,52 +889,48 @@ 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: + if (s->motion_est == FF_ME_ZERO) { 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); + } else { + 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; + dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16); } /* At this point (mx,my) are full-pell and the relative displacement */ @@ -1115,15 +1105,11 @@ 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: + if (s->motion_est == FF_ME_ZERO) { mx = 0; my = 0; dmin = 0; - break; - case ME_X1: - case ME_EPZS: + } else { P_LEFT[0] = mv_table[mot_xy - 1][0]; P_LEFT[1] = mv_table[mot_xy - 1][1]; @@ -1152,8 +1138,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 +1576,9 @@ 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) { + return 1; + } else { 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; @@ -1638,8 +1624,6 @@ int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type) } return best_fcode; - }else{ - return 1; } } diff --git a/libavcodec/motion_est.h b/libavcodec/motion_est.h index 4ffe70e..a5c662f 100644 --- a/libavcodec/motion_est.h +++ b/libavcodec/motion_est.h @@ -31,6 +31,10 @@ struct MpegEncContext; #define MAX_MV 2048 +#define FF_ME_ZERO 0 +#define FF_ME_EPZS 1 +#define FF_ME_XONE 2 + /** * Motion estimation context. */ diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index a023123..66b76af 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -255,7 +255,7 @@ typedef struct MpegEncContext { 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 (*b_field_select_table[2][2]); - int me_method; ///< ME algorithm + int motion_est; ///< ME algorithm int mv_dir; #define MV_DIR_FORWARD 1 #define MV_DIR_BACKWARD 2 @@ -575,6 +575,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 }, \ {"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 }, \ +{"motion_est", "motion estimation algorithm", FF_MPV_OFFSET(motion_est), AV_OPT_TYPE_INT, {.i64 = FF_ME_ZERO }, 0, 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[]; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index f88e009..d6ff758 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -324,8 +324,6 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) s->intra_only = 0; } - s->me_method = avctx->me_method; - /* Fixed QSCALE */ s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE); diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 4fc59ff..c5b2f76 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -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"}, {"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"}, +#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"}, {"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" }, @@ -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" }, {"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" }, +#endif {"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}, {"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E}, diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c index 08d85b8..7acc24c 100644 --- a/libavcodec/svq1enc.c +++ b/libavcodec/svq1enc.c @@ -273,7 +273,7 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, s->m.b8_stride = 2 * s->m.mb_width + 1; s->m.f_code = 1; s->m.pict_type = f->pict_type; - s->m.me_method = s->avctx->me_method; + s->m.motion_est = s->motion_est; s->m.me.scene_change_score = 0; // s->m.out_format = FMT_H263; // s->m.unrestricted_mv = 1; @@ -644,12 +644,31 @@ static int svq1_encode_frame(AVCodecContext *avctx, AVPacket *pkt, 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_ZERO }, 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 = { .name = "svq1", .long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_SVQ1, .priv_data_size = sizeof(SVQ1EncContext), + .priv_class = &svq1enc_class, .init = svq1_encode_init, .encode2 = svq1_encode_frame, .close = svq1_encode_end, diff --git a/libavcodec/svq1enc.h b/libavcodec/svq1enc.h index 516e875..f820d95 100644 --- a/libavcodec/svq1enc.h +++ b/libavcodec/svq1enc.h @@ -68,6 +68,8 @@ typedef struct SVQ1EncContext { uint8_t *scratchbuf; + int motion_est; + int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2, int size); } SVQ1EncContext; diff --git a/libavcodec/version.h b/libavcodec/version.h index 0ea5ada..a0a2098 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -30,7 +30,7 @@ #define LIBAVCODEC_VERSION_MAJOR 56 #define LIBAVCODEC_VERSION_MINOR 31 -#define LIBAVCODEC_VERSION_MICRO 2 +#define LIBAVCODEC_VERSION_MICRO 3 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ @@ -171,5 +171,8 @@ #ifndef FF_API_RC_STRATEGY #define FF_API_RC_STRATEGY (LIBAVCODEC_VERSION_MAJOR < 59) #endif +#ifndef FF_API_MOTION_EST +#define FF_API_MOTION_EST (LIBAVCODEC_VERSION_MAJOR < 59) +#endif #endif /* AVCODEC_VERSION_H */ -- 1.9.5 (Apple Git-50.3) _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
