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>
... | ... |
@@ -603,8 +603,6 @@ options follow the Libav ones. |
603 | 603 |
@tab Noise reduction. |
604 | 604 |
@item me_range @tab merange |
605 | 605 |
@tab Maximum range of the motion search in pixels. |
606 |
-@item me_method @tab me |
|
607 |
-@tab Full-pixel motion estimation method. |
|
608 | 606 |
@item subq @tab subme |
609 | 607 |
@tab Sub-pixel motion estimation method. |
610 | 608 |
@item b_strategy @tab b-adapt |
... | ... |
@@ -548,7 +548,9 @@ typedef struct AVCodecDescriptor { |
548 | 548 |
/** |
549 | 549 |
* @ingroup lavc_encoding |
550 | 550 |
* motion estimation type. |
551 |
+ * @deprecated use codec private option instead |
|
551 | 552 |
*/ |
553 |
+#if FF_API_MOTION_EST |
|
552 | 554 |
enum Motion_Est_ID { |
553 | 555 |
ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed |
554 | 556 |
ME_FULL, |
... | ... |
@@ -560,6 +562,7 @@ enum Motion_Est_ID { |
560 | 560 |
ME_UMH, ///< uneven multi-hexagon search |
561 | 561 |
ME_TESA, ///< transformed exhaustive search algorithm |
562 | 562 |
}; |
563 |
+#endif |
|
563 | 564 |
|
564 | 565 |
/** |
565 | 566 |
* @ingroup lavc_decoding |
... | ... |
@@ -1281,14 +1284,13 @@ typedef struct AVCodecContext { |
1281 | 1281 |
*/ |
1282 | 1282 |
enum AVPixelFormat pix_fmt; |
1283 | 1283 |
|
1284 |
+#if FF_API_MOTION_EST |
|
1284 | 1285 |
/** |
1285 |
- * Motion estimation algorithm used for video coding. |
|
1286 |
- * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), |
|
1287 |
- * 8 (umh), 10 (tesa) [7, 8, 10 are x264 specific] |
|
1288 |
- * - encoding: MUST be set by user. |
|
1289 |
- * - decoding: unused |
|
1286 |
+ * This option does nothing |
|
1287 |
+ * @deprecated use codec private options instead |
|
1290 | 1288 |
*/ |
1291 |
- int me_method; |
|
1289 |
+ attribute_deprecated int me_method; |
|
1290 |
+#endif |
|
1292 | 1291 |
|
1293 | 1292 |
/** |
1294 | 1293 |
* If non NULL, 'draw_horiz_band' is called by the libavcodec |
... | ... |
@@ -76,6 +76,7 @@ typedef struct X264Context { |
76 | 76 |
int slice_max_size; |
77 | 77 |
char *stats; |
78 | 78 |
int nal_hrd; |
79 |
+ int motion_est; |
|
79 | 80 |
char *x264_params; |
80 | 81 |
} X264Context; |
81 | 82 |
|
... | ... |
@@ -394,17 +395,6 @@ static av_cold int X264_init(AVCodecContext *avctx) |
394 | 394 |
x4->params.rc.f_pb_factor = avctx->b_quant_factor; |
395 | 395 |
x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset; |
396 | 396 |
|
397 |
- if (avctx->me_method == ME_EPZS) |
|
398 |
- x4->params.analyse.i_me_method = X264_ME_DIA; |
|
399 |
- else if (avctx->me_method == ME_HEX) |
|
400 |
- x4->params.analyse.i_me_method = X264_ME_HEX; |
|
401 |
- else if (avctx->me_method == ME_UMH) |
|
402 |
- x4->params.analyse.i_me_method = X264_ME_UMH; |
|
403 |
- else if (avctx->me_method == ME_FULL) |
|
404 |
- x4->params.analyse.i_me_method = X264_ME_ESA; |
|
405 |
- else if (avctx->me_method == ME_TESA) |
|
406 |
- x4->params.analyse.i_me_method = X264_ME_TESA; |
|
407 |
- |
|
408 | 397 |
if (avctx->gop_size >= 0) |
409 | 398 |
x4->params.i_keyint_max = avctx->gop_size; |
410 | 399 |
if (avctx->max_b_frames >= 0) |
... | ... |
@@ -493,6 +483,25 @@ static av_cold int X264_init(AVCodecContext *avctx) |
493 | 493 |
if (x4->nal_hrd >= 0) |
494 | 494 |
x4->params.i_nal_hrd = x4->nal_hrd; |
495 | 495 |
|
496 |
+ if (x4->motion_est >= 0) { |
|
497 |
+ x4->params.analyse.i_me_method = x4->motion_est; |
|
498 |
+#if FF_API_MOTION_EST |
|
499 |
+FF_DISABLE_DEPRECATION_WARNINGS |
|
500 |
+ } else { |
|
501 |
+ if (avctx->me_method == ME_EPZS) |
|
502 |
+ x4->params.analyse.i_me_method = X264_ME_DIA; |
|
503 |
+ else if (avctx->me_method == ME_HEX) |
|
504 |
+ x4->params.analyse.i_me_method = X264_ME_HEX; |
|
505 |
+ else if (avctx->me_method == ME_UMH) |
|
506 |
+ x4->params.analyse.i_me_method = X264_ME_UMH; |
|
507 |
+ else if (avctx->me_method == ME_FULL) |
|
508 |
+ x4->params.analyse.i_me_method = X264_ME_ESA; |
|
509 |
+ else if (avctx->me_method == ME_TESA) |
|
510 |
+ x4->params.analyse.i_me_method = X264_ME_TESA; |
|
511 |
+FF_ENABLE_DEPRECATION_WARNINGS |
|
512 |
+#endif |
|
513 |
+ } |
|
514 |
+ |
|
496 | 515 |
if (x4->profile) |
497 | 516 |
if (x264_param_apply_profile(&x4->params, x4->profile) < 0) { |
498 | 517 |
av_log(avctx, AV_LOG_ERROR, "Error setting profile %s.\n", x4->profile); |
... | ... |
@@ -675,6 +684,12 @@ static const AVOption options[] = { |
675 | 675 |
{ "none", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_NONE}, INT_MIN, INT_MAX, VE, "nal-hrd" }, |
676 | 676 |
{ "vbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_VBR}, INT_MIN, INT_MAX, VE, "nal-hrd" }, |
677 | 677 |
{ "cbr", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = X264_NAL_HRD_CBR}, INT_MIN, INT_MAX, VE, "nal-hrd" }, |
678 |
+ { "motion-est", "Set motion estimation method", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, X264_ME_TESA, VE, "motion-est"}, |
|
679 |
+ { "dia", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_DIA }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
680 |
+ { "hex", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_HEX }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
681 |
+ { "umh", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_UMH }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
682 |
+ { "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
683 |
+ { "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = X264_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
678 | 684 |
{ "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 }, |
679 | 685 |
{ NULL }, |
680 | 686 |
}; |
... | ... |
@@ -694,7 +709,9 @@ static const AVCodecDefault x264_defaults[] = { |
694 | 694 |
{ "trellis", "-1" }, |
695 | 695 |
{ "nr", "-1" }, |
696 | 696 |
{ "me_range", "-1" }, |
697 |
+#if FF_API_MOTION_EST |
|
697 | 698 |
{ "me_method", "-1" }, |
699 |
+#endif |
|
698 | 700 |
{ "subq", "-1" }, |
699 | 701 |
{ "b_strategy", "-1" }, |
700 | 702 |
{ "keyint_min", "-1" }, |
... | ... |
@@ -53,6 +53,7 @@ typedef struct XavsContext { |
53 | 53 |
int direct_pred; |
54 | 54 |
int aud; |
55 | 55 |
int fast_pskip; |
56 |
+ int motion_est; |
|
56 | 57 |
int mbtree; |
57 | 58 |
int mixed_refs; |
58 | 59 |
|
... | ... |
@@ -271,6 +272,8 @@ static av_cold int XAVS_init(AVCodecContext *avctx) |
271 | 271 |
x4->params.analyse.i_direct_mv_pred = x4->direct_pred; |
272 | 272 |
if (x4->fast_pskip >= 0) |
273 | 273 |
x4->params.analyse.b_fast_pskip = x4->fast_pskip; |
274 |
+ if (x4->motion_est >= 0) |
|
275 |
+ x4->params.analyse.i_me_method = x4->motion_est; |
|
274 | 276 |
if (x4->mixed_refs >= 0) |
275 | 277 |
x4->params.analyse.b_mixed_references = x4->mixed_refs; |
276 | 278 |
if (x4->b_bias != INT_MIN) |
... | ... |
@@ -278,6 +281,32 @@ static av_cold int XAVS_init(AVCodecContext *avctx) |
278 | 278 |
if (x4->cplxblur >= 0) |
279 | 279 |
x4->params.rc.f_complexity_blur = x4->cplxblur; |
280 | 280 |
|
281 |
+#if FF_API_MOTION_EST |
|
282 |
+FF_DISABLE_DEPRECATION_WARNINGS |
|
283 |
+ if (x4->motion_est < 0) { |
|
284 |
+ switch (avctx->me_method) { |
|
285 |
+ case ME_EPZS: |
|
286 |
+ x4->params.analyse.i_me_method = XAVS_ME_DIA; |
|
287 |
+ break; |
|
288 |
+ case ME_HEX: |
|
289 |
+ x4->params.analyse.i_me_method = XAVS_ME_HEX; |
|
290 |
+ break; |
|
291 |
+ case ME_UMH: |
|
292 |
+ x4->params.analyse.i_me_method = XAVS_ME_UMH; |
|
293 |
+ break; |
|
294 |
+ case ME_FULL: |
|
295 |
+ x4->params.analyse.i_me_method = XAVS_ME_ESA; |
|
296 |
+ break; |
|
297 |
+ case ME_TESA: |
|
298 |
+ x4->params.analyse.i_me_method = XAVS_ME_TESA; |
|
299 |
+ break; |
|
300 |
+ default: |
|
301 |
+ x4->params.analyse.i_me_method = XAVS_ME_HEX; |
|
302 |
+ } |
|
303 |
+ } |
|
304 |
+FF_ENABLE_DEPRECATION_WARNINGS |
|
305 |
+#endif |
|
306 |
+ |
|
281 | 307 |
x4->params.i_bframe = avctx->max_b_frames; |
282 | 308 |
/* cabac is not included in AVS JiZhun Profile */ |
283 | 309 |
x4->params.b_cabac = 0; |
... | ... |
@@ -314,26 +343,6 @@ static av_cold int XAVS_init(AVCodecContext *avctx) |
314 | 314 |
x4->params.i_fps_den = avctx->time_base.num; |
315 | 315 |
x4->params.analyse.inter = XAVS_ANALYSE_I8x8 |XAVS_ANALYSE_PSUB16x16| XAVS_ANALYSE_BSUB16x16; |
316 | 316 |
|
317 |
- switch (avctx->me_method) { |
|
318 |
- case ME_EPZS: |
|
319 |
- x4->params.analyse.i_me_method = XAVS_ME_DIA; |
|
320 |
- break; |
|
321 |
- case ME_HEX: |
|
322 |
- x4->params.analyse.i_me_method = XAVS_ME_HEX; |
|
323 |
- break; |
|
324 |
- case ME_UMH: |
|
325 |
- x4->params.analyse.i_me_method = XAVS_ME_UMH; |
|
326 |
- break; |
|
327 |
- case ME_FULL: |
|
328 |
- x4->params.analyse.i_me_method = XAVS_ME_ESA; |
|
329 |
- break; |
|
330 |
- case ME_TESA: |
|
331 |
- x4->params.analyse.i_me_method = XAVS_ME_TESA; |
|
332 |
- break; |
|
333 |
- default: |
|
334 |
- x4->params.analyse.i_me_method = XAVS_ME_HEX; |
|
335 |
- } |
|
336 |
- |
|
337 | 317 |
x4->params.analyse.i_me_range = avctx->me_range; |
338 | 318 |
x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality; |
339 | 319 |
|
... | ... |
@@ -423,6 +432,13 @@ static const AVOption options[] = { |
423 | 423 |
{ "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 1, VE}, |
424 | 424 |
{ "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 }, |
425 | 425 |
{ "fast-pskip", NULL, OFFSET(fast_pskip), AV_OPT_TYPE_INT, {.i64 = -1 }, -1, 1, VE}, |
426 |
+ { "motion-est", "Set motion estimation method", OFFSET(motion_est), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, XAVS_ME_TESA, VE, "motion-est"}, |
|
427 |
+ { "dia", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_DIA }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
428 |
+ { "hex", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_HEX }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
429 |
+ { "umh", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_UMH }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
430 |
+ { "esa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_ESA }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
431 |
+ { "tesa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = XAVS_ME_TESA }, INT_MIN, INT_MAX, VE, "motion-est" }, |
|
432 |
+ |
|
426 | 433 |
{ NULL }, |
427 | 434 |
}; |
428 | 435 |
|
... | ... |
@@ -68,6 +68,7 @@ struct xvid_context { |
68 | 68 |
int ssim; /**< SSIM information display mode */ |
69 | 69 |
int ssim_acc; /**< SSIM accuracy. 0: accurate. 4: fast. */ |
70 | 70 |
int gmc; |
71 |
+ int me_quality; /**< Motion estimation quality. 0: fast 6: best. */ |
|
71 | 72 |
}; |
72 | 73 |
|
73 | 74 |
/** |
... | ... |
@@ -379,26 +380,45 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx) |
379 | 379 |
|
380 | 380 |
/* Decide which ME quality setting to use */ |
381 | 381 |
x->me_flags = 0; |
382 |
- switch (avctx->me_method) { |
|
383 |
- case ME_FULL: /* Quality 6 */ |
|
382 |
+ switch (x->me_quality) { |
|
383 |
+ case 6: |
|
384 |
+ case 5: |
|
384 | 385 |
x->me_flags |= XVID_ME_EXTSEARCH16 | |
385 | 386 |
XVID_ME_EXTSEARCH8; |
386 |
- |
|
387 |
- case ME_EPZS: /* Quality 4 */ |
|
387 |
+ case 4: |
|
388 |
+ case 3: |
|
388 | 389 |
x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 | |
389 | 390 |
XVID_ME_HALFPELREFINE8 | |
390 | 391 |
XVID_ME_CHROMA_PVOP | |
391 | 392 |
XVID_ME_CHROMA_BVOP; |
392 |
- |
|
393 |
- case ME_LOG: /* Quality 2 */ |
|
394 |
- case ME_PHODS: |
|
395 |
- case ME_X1: |
|
393 |
+ case 2: |
|
394 |
+ case 1: |
|
396 | 395 |
x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 | |
397 | 396 |
XVID_ME_HALFPELREFINE16; |
398 |
- |
|
399 |
- case ME_ZERO: /* Quality 0 */ |
|
400 |
- default: |
|
397 |
+#if FF_API_MOTION_EST |
|
398 |
+FF_DISABLE_DEPRECATION_WARNINGS |
|
401 | 399 |
break; |
400 |
+ default: |
|
401 |
+ switch (avctx->me_method) { |
|
402 |
+ case ME_FULL: /* Quality 6 */ |
|
403 |
+ x->me_flags |= XVID_ME_EXTSEARCH16 | |
|
404 |
+ XVID_ME_EXTSEARCH8; |
|
405 |
+ case ME_EPZS: /* Quality 4 */ |
|
406 |
+ x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 | |
|
407 |
+ XVID_ME_HALFPELREFINE8 | |
|
408 |
+ XVID_ME_CHROMA_PVOP | |
|
409 |
+ XVID_ME_CHROMA_BVOP; |
|
410 |
+ case ME_LOG: /* Quality 2 */ |
|
411 |
+ case ME_PHODS: |
|
412 |
+ case ME_X1: |
|
413 |
+ x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 | |
|
414 |
+ XVID_ME_HALFPELREFINE16; |
|
415 |
+ case ME_ZERO: /* Quality 0 */ |
|
416 |
+ default: |
|
417 |
+ break; |
|
418 |
+ } |
|
419 |
+FF_ENABLE_DEPRECATION_WARNINGS |
|
420 |
+#endif |
|
402 | 421 |
} |
403 | 422 |
|
404 | 423 |
/* Decide how we should decide blocks */ |
... | ... |
@@ -828,6 +848,7 @@ static const AVOption options[] = { |
828 | 828 |
{ "frame", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 2 }, INT_MIN, INT_MAX, VE, "ssim" }, |
829 | 829 |
{ "ssim_acc", "SSIM accuracy", OFFSET(ssim_acc), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, 4, VE }, |
830 | 830 |
{ "gmc", "use GMC", OFFSET(gmc), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, |
831 |
+ { "me_quality", "Motion estimation quality", OFFSET(me_quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 6, VE }, |
|
831 | 832 |
{ NULL }, |
832 | 833 |
}; |
833 | 834 |
|
... | ... |
@@ -309,12 +309,25 @@ int ff_init_me(MpegEncContext *s){ |
309 | 309 |
av_log(s->avctx, AV_LOG_ERROR, "ME_MAP size is too small for SAB diamond\n"); |
310 | 310 |
return -1; |
311 | 311 |
} |
312 |
- if (s->me_method != ME_ZERO && |
|
313 |
- s->me_method != ME_EPZS && |
|
314 |
- s->me_method != ME_X1) { |
|
315 |
- 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"); |
|
316 |
- return -1; |
|
312 |
+ |
|
313 |
+#if FF_API_MOTION_EST |
|
314 |
+FF_DISABLE_DEPRECATION_WARNINGS |
|
315 |
+ if (s->motion_est == FF_ME_EPZS) { |
|
316 |
+ if (s->me_method == ME_ZERO) |
|
317 |
+ s->motion_est = FF_ME_ZERO; |
|
318 |
+ else if (s->me_method == ME_EPZS) |
|
319 |
+ s->motion_est = FF_ME_EPZS; |
|
320 |
+ else if (s->me_method == ME_X1) |
|
321 |
+ s->motion_est = FF_ME_XONE; |
|
322 |
+ else { |
|
323 |
+ av_log(s->avctx, AV_LOG_ERROR, |
|
324 |
+ "me_method is only allowed to be set to zero and epzs; " |
|
325 |
+ "for hex,umh,full and others see dia_size\n"); |
|
326 |
+ return -1; |
|
327 |
+ } |
|
317 | 328 |
} |
329 |
+FF_ENABLE_DEPRECATION_WARNINGS |
|
330 |
+#endif |
|
318 | 331 |
|
319 | 332 |
c->avctx= s->avctx; |
320 | 333 |
|
... | ... |
@@ -863,7 +876,7 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, |
863 | 863 |
{ |
864 | 864 |
MotionEstContext * const c= &s->me; |
865 | 865 |
uint8_t *pix, *ppix; |
866 |
- int sum, mx, my, dmin; |
|
866 |
+ int sum, mx = 0, my = 0, dmin = 0; |
|
867 | 867 |
int varc; ///< the variance of the block (sum of squared (p[y][x]-average)) |
868 | 868 |
int vard; ///< sum of squared differences with the estimated motion vector |
869 | 869 |
int P[10][2]; |
... | ... |
@@ -895,52 +908,43 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, |
895 | 895 |
pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8; |
896 | 896 |
c->mb_var_sum_temp += (varc+128)>>8; |
897 | 897 |
|
898 |
- switch(s->me_method) { |
|
899 |
- case ME_ZERO: |
|
900 |
- default: |
|
901 |
- mx = 0; |
|
902 |
- my = 0; |
|
903 |
- dmin = 0; |
|
904 |
- break; |
|
905 |
- case ME_X1: |
|
906 |
- case ME_EPZS: |
|
907 |
- { |
|
908 |
- const int mot_stride = s->b8_stride; |
|
909 |
- const int mot_xy = s->block_index[0]; |
|
910 |
- |
|
911 |
- P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0]; |
|
912 |
- P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1]; |
|
913 |
- |
|
914 |
- if(P_LEFT[0] > (c->xmax<<shift)) P_LEFT[0] = (c->xmax<<shift); |
|
915 |
- |
|
916 |
- if(!s->first_slice_line) { |
|
917 |
- P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0]; |
|
918 |
- P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1]; |
|
919 |
- P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0]; |
|
920 |
- P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1]; |
|
921 |
- if(P_TOP[1] > (c->ymax<<shift)) P_TOP[1] = (c->ymax<<shift); |
|
922 |
- if(P_TOPRIGHT[0] < (c->xmin<<shift)) P_TOPRIGHT[0]= (c->xmin<<shift); |
|
923 |
- if(P_TOPRIGHT[1] > (c->ymax<<shift)) P_TOPRIGHT[1]= (c->ymax<<shift); |
|
898 |
+ if (s->motion_est != FF_ME_ZERO) { |
|
899 |
+ const int mot_stride = s->b8_stride; |
|
900 |
+ const int mot_xy = s->block_index[0]; |
|
924 | 901 |
|
925 |
- P_MEDIAN[0]= mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); |
|
926 |
- P_MEDIAN[1]= mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); |
|
902 |
+ P_LEFT[0] = s->current_picture.motion_val[0][mot_xy - 1][0]; |
|
903 |
+ P_LEFT[1] = s->current_picture.motion_val[0][mot_xy - 1][1]; |
|
927 | 904 |
|
928 |
- if(s->out_format == FMT_H263){ |
|
929 |
- c->pred_x = P_MEDIAN[0]; |
|
930 |
- c->pred_y = P_MEDIAN[1]; |
|
931 |
- }else { /* mpeg1 at least */ |
|
932 |
- c->pred_x= P_LEFT[0]; |
|
933 |
- c->pred_y= P_LEFT[1]; |
|
934 |
- } |
|
935 |
- }else{ |
|
936 |
- c->pred_x= P_LEFT[0]; |
|
937 |
- c->pred_y= P_LEFT[1]; |
|
938 |
- } |
|
905 |
+ if (P_LEFT[0] > (c->xmax << shift)) |
|
906 |
+ P_LEFT[0] = c->xmax << shift; |
|
939 | 907 |
|
908 |
+ if (!s->first_slice_line) { |
|
909 |
+ P_TOP[0] = s->current_picture.motion_val[0][mot_xy - mot_stride ][0]; |
|
910 |
+ P_TOP[1] = s->current_picture.motion_val[0][mot_xy - mot_stride ][1]; |
|
911 |
+ P_TOPRIGHT[0] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][0]; |
|
912 |
+ P_TOPRIGHT[1] = s->current_picture.motion_val[0][mot_xy - mot_stride + 2][1]; |
|
913 |
+ if (P_TOP[1] > (c->ymax << shift)) |
|
914 |
+ P_TOP[1] = c->ymax << shift; |
|
915 |
+ if (P_TOPRIGHT[0] < (c->xmin << shift)) |
|
916 |
+ P_TOPRIGHT[0] = c->xmin << shift; |
|
917 |
+ if (P_TOPRIGHT[1] > (c->ymax << shift)) |
|
918 |
+ P_TOPRIGHT[1] = c->ymax << shift; |
|
919 |
+ |
|
920 |
+ P_MEDIAN[0] = mid_pred(P_LEFT[0], P_TOP[0], P_TOPRIGHT[0]); |
|
921 |
+ P_MEDIAN[1] = mid_pred(P_LEFT[1], P_TOP[1], P_TOPRIGHT[1]); |
|
922 |
+ |
|
923 |
+ if (s->out_format == FMT_H263) { |
|
924 |
+ c->pred_x = P_MEDIAN[0]; |
|
925 |
+ c->pred_y = P_MEDIAN[1]; |
|
926 |
+ } else { /* mpeg1 at least */ |
|
927 |
+ c->pred_x = P_LEFT[0]; |
|
928 |
+ c->pred_y = P_LEFT[1]; |
|
929 |
+ } |
|
930 |
+ } else { |
|
931 |
+ c->pred_x = P_LEFT[0]; |
|
932 |
+ c->pred_y = P_LEFT[1]; |
|
940 | 933 |
} |
941 | 934 |
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, 0, s->p_mv_table, (1<<16)>>shift, 0, 16); |
942 |
- |
|
943 |
- break; |
|
944 | 935 |
} |
945 | 936 |
|
946 | 937 |
/* 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, |
1100 | 1100 |
int16_t (*mv_table)[2], int ref_index, int f_code) |
1101 | 1101 |
{ |
1102 | 1102 |
MotionEstContext * const c= &s->me; |
1103 |
- int mx, my, dmin; |
|
1103 |
+ int mx = 0, my = 0, dmin = 0; |
|
1104 | 1104 |
int P[10][2]; |
1105 | 1105 |
const int shift= 1+s->quarter_sample; |
1106 | 1106 |
const int mot_stride = s->mb_stride; |
... | ... |
@@ -1115,15 +1119,7 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y, |
1115 | 1115 |
|
1116 | 1116 |
get_limits(s, 16*mb_x, 16*mb_y); |
1117 | 1117 |
|
1118 |
- switch(s->me_method) { |
|
1119 |
- case ME_ZERO: |
|
1120 |
- default: |
|
1121 |
- mx = 0; |
|
1122 |
- my = 0; |
|
1123 |
- dmin = 0; |
|
1124 |
- break; |
|
1125 |
- case ME_X1: |
|
1126 |
- case ME_EPZS: |
|
1118 |
+ if (s->motion_est != FF_ME_ZERO) { |
|
1127 | 1119 |
P_LEFT[0] = mv_table[mot_xy - 1][0]; |
1128 | 1120 |
P_LEFT[1] = mv_table[mot_xy - 1][1]; |
1129 | 1121 |
|
... | ... |
@@ -1152,8 +1148,6 @@ static int estimate_motion_b(MpegEncContext *s, int mb_x, int mb_y, |
1152 | 1152 |
} |
1153 | 1153 |
|
1154 | 1154 |
dmin = ff_epzs_motion_search(s, &mx, &my, P, 0, ref_index, s->p_mv_table, mv_scale, 0, 16); |
1155 |
- |
|
1156 |
- break; |
|
1157 | 1155 |
} |
1158 | 1156 |
|
1159 | 1157 |
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, |
1592 | 1592 |
/* find best f_code for ME which do unlimited searches */ |
1593 | 1593 |
int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type) |
1594 | 1594 |
{ |
1595 |
- if(s->me_method>=ME_EPZS){ |
|
1595 |
+ if (s->motion_est != FF_ME_ZERO) { |
|
1596 | 1596 |
int score[8]; |
1597 | 1597 |
int i, y, range= s->avctx->me_range ? s->avctx->me_range : (INT_MAX/2); |
1598 | 1598 |
uint8_t * fcode_tab= s->fcode_tab; |
... | ... |
@@ -256,7 +256,10 @@ typedef struct MpegEncContext { |
256 | 256 |
int16_t (*b_field_mv_table[2][2][2])[2];///< MV table (4MV per MB) interlaced b-frame encoding |
257 | 257 |
uint8_t (*p_field_select_table[2]); |
258 | 258 |
uint8_t (*b_field_select_table[2][2]); |
259 |
+#if FF_API_MOTION_EST |
|
259 | 260 |
int me_method; ///< ME algorithm |
261 |
+#endif |
|
262 |
+ int motion_est; ///< ME algorithm |
|
260 | 263 |
int mv_dir; |
261 | 264 |
#define MV_DIR_FORWARD 1 |
262 | 265 |
#define MV_DIR_BACKWARD 2 |
... | ... |
@@ -576,6 +579,10 @@ typedef struct MpegEncContext { |
576 | 576 |
{"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 }, \ |
577 | 577 |
{"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 }, \ |
578 | 578 |
{"rc_strategy", "ratecontrol method", FF_MPV_OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, FF_MPV_OPT_FLAGS }, \ |
579 |
+{"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" }, \ |
|
580 |
+{ "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ |
|
581 |
+{ "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ |
|
582 |
+{ "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion_est" }, \ |
|
579 | 583 |
|
580 | 584 |
extern const AVOption ff_mpv_generic_options[]; |
581 | 585 |
|
... | ... |
@@ -324,7 +324,11 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) |
324 | 324 |
s->intra_only = 0; |
325 | 325 |
} |
326 | 326 |
|
327 |
+#if FF_API_MOTION_EST |
|
328 |
+FF_DISABLE_DEPRECATION_WARNINGS |
|
327 | 329 |
s->me_method = avctx->me_method; |
330 |
+FF_ENABLE_DEPRECATION_WARNINGS |
|
331 |
+#endif |
|
328 | 332 |
|
329 | 333 |
/* Fixed QSCALE */ |
330 | 334 |
s->fixed_qscale = !!(avctx->flags & CODEC_FLAG_QSCALE); |
... | ... |
@@ -84,6 +84,7 @@ static const AVOption avcodec_options[] = { |
84 | 84 |
{"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"}, |
85 | 85 |
{"ignorecrop", "ignore cropping information from sps", 1, AV_OPT_TYPE_CONST, {.i64 = CODEC_FLAG2_IGNORE_CROP }, INT_MIN, INT_MAX, V|D, "flags2"}, |
86 | 86 |
{"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"}, |
87 |
+#if FF_API_MOTION_EST |
|
87 | 88 |
{"me_method", "set motion estimation method", OFFSET(me_method), AV_OPT_TYPE_INT, {.i64 = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method"}, |
88 | 89 |
{"zero", "zero motion estimation (fastest)", 0, AV_OPT_TYPE_CONST, {.i64 = ME_ZERO }, INT_MIN, INT_MAX, V|E, "me_method" }, |
89 | 90 |
{"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[] = { |
96 | 96 |
{"x1", "X1 motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_X1 }, INT_MIN, INT_MAX, V|E, "me_method" }, |
97 | 97 |
{"hex", "hex motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_HEX }, INT_MIN, INT_MAX, V|E, "me_method" }, |
98 | 98 |
{"umh", "umh motion estimation", 0, AV_OPT_TYPE_CONST, {.i64 = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" }, |
99 |
+#endif |
|
99 | 100 |
{"extradata_size", NULL, OFFSET(extradata_size), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, |
100 | 101 |
{"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX}, |
101 | 102 |
{"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E}, |
... | ... |
@@ -272,7 +272,20 @@ static int svq1_encode_plane(SVQ1EncContext *s, int plane, |
272 | 272 |
s->m.b8_stride = 2 * s->m.mb_width + 1; |
273 | 273 |
s->m.f_code = 1; |
274 | 274 |
s->m.pict_type = s->pict_type; |
275 |
+#if FF_API_MOTION_EST |
|
276 |
+FF_DISABLE_DEPRECATION_WARNINGS |
|
275 | 277 |
s->m.me_method = s->avctx->me_method; |
278 |
+ if (s->motion_est == FF_ME_EPZS) { |
|
279 |
+ if (s->avctx->me_method == ME_ZERO) |
|
280 |
+ s->motion_est = FF_ME_ZERO; |
|
281 |
+ else if (s->avctx->me_method == ME_EPZS) |
|
282 |
+ s->motion_est = FF_ME_EPZS; |
|
283 |
+ else if (s->avctx->me_method == ME_X1) |
|
284 |
+ s->motion_est = FF_ME_XONE; |
|
285 |
+ } |
|
286 |
+FF_ENABLE_DEPRECATION_WARNINGS |
|
287 |
+#endif |
|
288 |
+ s->m.motion_est = s->motion_est; |
|
276 | 289 |
s->m.me.scene_change_score = 0; |
277 | 290 |
// s->m.out_format = FMT_H263; |
278 | 291 |
// s->m.unrestricted_mv = 1; |
... | ... |
@@ -654,12 +667,31 @@ FF_ENABLE_DEPRECATION_WARNINGS |
654 | 654 |
return 0; |
655 | 655 |
} |
656 | 656 |
|
657 |
+#define OFFSET(x) offsetof(struct SVQ1EncContext, x) |
|
658 |
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
|
659 |
+static const AVOption options[] = { |
|
660 |
+ { "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"}, |
|
661 |
+ { "zero", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_ZERO }, 0, 0, FF_MPV_OPT_FLAGS, "motion-est" }, |
|
662 |
+ { "epzs", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_EPZS }, 0, 0, FF_MPV_OPT_FLAGS, "motion-est" }, |
|
663 |
+ { "xone", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_ME_XONE }, 0, 0, FF_MPV_OPT_FLAGS, "motion-est" }, |
|
664 |
+ |
|
665 |
+ { NULL }, |
|
666 |
+}; |
|
667 |
+ |
|
668 |
+static const AVClass svq1enc_class = { |
|
669 |
+ .class_name = "svq1enc", |
|
670 |
+ .item_name = av_default_item_name, |
|
671 |
+ .option = options, |
|
672 |
+ .version = LIBAVUTIL_VERSION_INT, |
|
673 |
+}; |
|
674 |
+ |
|
657 | 675 |
AVCodec ff_svq1_encoder = { |
658 | 676 |
.name = "svq1", |
659 | 677 |
.long_name = NULL_IF_CONFIG_SMALL("Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1"), |
660 | 678 |
.type = AVMEDIA_TYPE_VIDEO, |
661 | 679 |
.id = AV_CODEC_ID_SVQ1, |
662 | 680 |
.priv_data_size = sizeof(SVQ1EncContext), |
681 |
+ .priv_class = &svq1enc_class, |
|
663 | 682 |
.init = svq1_encode_init, |
664 | 683 |
.encode2 = svq1_encode_frame, |
665 | 684 |
.close = svq1_encode_end, |
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
|
31 | 31 |
#define LIBAVCODEC_VERSION_MAJOR 56 |
32 | 32 |
#define LIBAVCODEC_VERSION_MINOR 34 |
33 |
-#define LIBAVCODEC_VERSION_MICRO 0 |
|
33 |
+#define LIBAVCODEC_VERSION_MICRO 1 |
|
34 | 34 |
|
35 | 35 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
36 | 36 |
LIBAVCODEC_VERSION_MINOR, \ |
... | ... |
@@ -174,5 +174,8 @@ |
174 | 174 |
#ifndef FF_API_CODED_FRAME |
175 | 175 |
#define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59) |
176 | 176 |
#endif |
177 |
+#ifndef FF_API_MOTION_EST |
|
178 |
+#define FF_API_MOTION_EST (LIBAVCODEC_VERSION_MAJOR < 59) |
|
179 |
+#endif |
|
177 | 180 |
|
178 | 181 |
#endif /* AVCODEC_VERSION_H */ |
... | ... |
@@ -216,12 +216,20 @@ void ff_wmv2_encode_mb(MpegEncContext *s, int16_t block[6][64], |
216 | 216 |
ff_msmpeg4_encode_block(s, block[i], i); |
217 | 217 |
} |
218 | 218 |
|
219 |
+static const AVClass wmv2_class = { |
|
220 |
+ .class_name = "wmv2 encoder", |
|
221 |
+ .item_name = av_default_item_name, |
|
222 |
+ .option = ff_mpv_generic_options, |
|
223 |
+ .version = LIBAVUTIL_VERSION_INT, |
|
224 |
+}; |
|
225 |
+ |
|
219 | 226 |
AVCodec ff_wmv2_encoder = { |
220 | 227 |
.name = "wmv2", |
221 | 228 |
.long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 8"), |
222 | 229 |
.type = AVMEDIA_TYPE_VIDEO, |
223 | 230 |
.id = AV_CODEC_ID_WMV2, |
224 | 231 |
.priv_data_size = sizeof(Wmv2Context), |
232 |
+ .priv_class = &wmv2_class, |
|
225 | 233 |
.init = wmv2_encode_init, |
226 | 234 |
.encode2 = ff_mpv_encode_picture, |
227 | 235 |
.close = ff_mpv_encode_end, |