Skip to content

Commit

Permalink
Merge commit '4b6b1082a73907c7c3de2646c6398bc61320f2c6'
Browse files Browse the repository at this point in the history
* commit '4b6b1082a73907c7c3de2646c6398bc61320f2c6':
  lavc: Deprecate avctx.me_method

Conflicts:
	doc/encoders.texi
	libavcodec/avcodec.h
	libavcodec/libx264.c
	libavcodec/motion_est.c
	libavcodec/options_table.h
	libavcodec/version.h

Merged-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Jul 27, 2015
2 parents 59b0094 + 4b6b108 commit 0b6f092
Show file tree
Hide file tree
Showing 13 changed files with 214 additions and 107 deletions.
14 changes: 8 additions & 6 deletions libavcodec/avcodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,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,
Expand All @@ -658,6 +660,7 @@ enum Motion_Est_ID {
ME_TESA, ///< transformed exhaustive search algorithm
ME_ITER=50, ///< iterative search
};
#endif

/**
* @ingroup lavc_decoding
Expand Down Expand Up @@ -1485,14 +1488,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), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow 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
Expand Down
39 changes: 28 additions & 11 deletions libavcodec/libx264.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ typedef struct X264Context {
char *stats;
int nal_hrd;
int avcintra_class;
int motion_est;
char *x264_params;
} X264Context;

Expand Down Expand Up @@ -470,17 +471,6 @@ static av_cold int X264_init(AVCodecContext *avctx)
if (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)
x4->params.i_keyint_max = avctx->gop_size;
if (avctx->max_b_frames >= 0)
Expand Down Expand Up @@ -633,6 +623,25 @@ 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 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 (x264_param_apply_profile(&x4->params, x4->profile) < 0) {
int i;
Expand Down Expand Up @@ -854,6 +863,12 @@ static const AVOption options[] = {
{ "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" },
{ "avcintra-class","AVC-Intra class 50/100/200", OFFSET(avcintra_class),AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 200 , VE},
{ "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 },
};
Expand All @@ -876,7 +891,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" },
Expand Down
56 changes: 36 additions & 20 deletions libavcodec/libxavs.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ typedef struct XavsContext {
int direct_pred;
int aud;
int fast_pskip;
int motion_est;
int mbtree;
int mixed_refs;

Expand Down Expand Up @@ -269,13 +270,41 @@ 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)
x4->params.i_bframe_bias = x4->b_bias;
if (x4->cplxblur >= 0)
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;
/* cabac is not included in AVS JiZhun Profile */
x4->params.b_cabac = 0;
Expand Down Expand Up @@ -312,26 +341,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;

Expand Down Expand Up @@ -422,6 +431,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 },
};

Expand Down
43 changes: 32 additions & 11 deletions libavcodec/libxvid.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,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. */
};

/**
Expand Down Expand Up @@ -392,26 +393,45 @@ 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:
#if FF_API_MOTION_EST
FF_DISABLE_DEPRECATION_WARNINGS
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 */
Expand Down Expand Up @@ -863,6 +883,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 },
};

Expand Down
Loading

0 comments on commit 0b6f092

Please sign in to comment.