Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -71,13 +71,20 @@ static double get_scene_score(AVFilterContext *ctx, AVFrame *crnt, AVFrame *next · 70 unmodified lines | ||
| 71 | 71 | |
| 72 | 72 | if (crnt->height == next->height && |
| 73 | 73 | crnt->width == next->width) { |
| 74 | + AVDictionaryEntry *e_mafd = NULL; | |
| 74 | 75 | uint64_t sad; |
| 75 | − double mafd, diff; | |
| 76 | + double mafd = HUGE_VAL, diff; | |
| 77 | + char *tail = NULL; | |
| 76 | 78 | |
| 77 | 79 | ff_dlog(ctx, "get_scene_score() process\n"); |
| 78 | − s->sad(crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->width, crnt->height, &sad); | |
| 79 | − emms_c(); | |
| 80 | − mafd = (double)sad * 100.0 / (crnt->width * crnt->height) / (1 << s->bitdepth); | |
| 80 | + e_mafd = av_dict_get(next->metadata, "lavfi.scd.mafd", NULL, AV_DICT_MATCH_CASE); | |
| 81 | + if (e_mafd) | |
| 82 | + mafd = strtod(e_mafd->value, &tail); | |
| 83 | + if (*tail || mafd == HUGE_VAL) { | |
| 84 | + s->sad(crnt->data[0], crnt->linesize[0], next->data[0], next->linesize[0], crnt->width, crnt->height, &sad); | |
| 85 | + emms_c(); | |
| 86 | + mafd = (double)sad * 100.0 / (crnt->width * crnt->height) / (1 << s->bitdepth); | |
| 87 | + } | |
| 81 | 88 | diff = fabs(mafd - s->prev_mafd); |
| 82 | 89 | ret = av_clipf(FFMIN(mafd, diff), 0, 100.0); |
| 83 | 90 | s->prev_mafd = mafd; |