Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -832,11 +832,19 @@ static int detect_scene_change(MIContext *mi_ctx) · 831 unmodified lines | ||
| 832 | 832 | ptrdiff_t linesize2 = mi_ctx->frames[2].avf->linesize[0]; |
| 833 | 833 | |
| 834 | 834 | if (mi_ctx->scd_method == SCD_METHOD_FDIFF) { |
| 835 | − double ret = 0, mafd, diff; | |
| 835 | + double ret = 0, mafd = HUGE_VAL, diff; | |
| 836 | 836 | uint64_t sad; |
| 837 | − mi_ctx->sad(p1, linesize1, p2, linesize2, me_ctx->width, me_ctx->height, &sad); | |
| 838 | − emms_c(); | |
| 839 | − mafd = (double) sad / (me_ctx->height * me_ctx->width * 3); | |
| 837 | + AVDictionaryEntry *e_mafd = NULL; | |
| 838 | + char *tail = NULL; | |
| 839 | + | |
| 840 | + e_mafd = av_dict_get(mi_ctx->frames[2].avf->metadata, "lavfi.scd.mafd", NULL, AV_DICT_MATCH_CASE); | |
| 841 | + if (e_mafd) | |
| 842 | + mafd = strtod(e_mafd->value, &tail); | |
| 843 | + if (*tail || mafd == HUGE_VAL) { | |
| 844 | + mi_ctx->sad(p1, linesize1, p2, linesize2, me_ctx->width, me_ctx->height, &sad); | |
| 845 | + emms_c(); | |
| 846 | + mafd = (double) sad / (me_ctx->height * me_ctx->width * 3); | |
| 847 | + } | |
| 840 | 848 | diff = fabs(mafd - mi_ctx->prev_mafd); |
| 841 | 849 | ret = av_clipf(FFMIN(mafd, diff), 0, 100.0); |
| 842 | 850 | mi_ctx->prev_mafd = mafd; |