This belongs in another filter.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -121,7 +121,6 @@ static const AVOption paletteuse_options[] = { · 120 unmodified lines | |||
| 121 | 121 | ||
| 122 | /* following are the debug options, not part of the official API */ | 122 | /* following are the debug options, not part of the official API */ |
| 123 | { "debug_kdtree", "save Graphviz graph of the kdtree in specified file", OFFSET(dot_filename), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, | 123 | { "debug_kdtree", "save Graphviz graph of the kdtree in specified file", OFFSET(dot_filename), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS }, |
| 124 | { "mean_err", "compute and print mean error", OFFSET(calc_mean_err), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS }, | ||
| 125 | { NULL } | 124 | { NULL } |
| 126 | }; | 125 | }; |
| 127 | 126 | ||
| @@ -606,34 +605,6 @@ static void load_colormap(PaletteUseContext *s) · 478 unmodified lines | |||
| 606 | disp_tree(s->map, s->dot_filename); | 605 | disp_tree(s->map, s->dot_filename); |
| 607 | } | 606 | } |
| 608 | 607 | ||
| 609 | static void debug_mean_error(PaletteUseContext *s, const AVFrame *in1, | ||
| 610 | const AVFrame *in2, int frame_count) | ||
| 611 | { | ||
| 612 | int x, y; | ||
| 613 | const uint32_t *palette = s->palette; | ||
| 614 | uint32_t *src1 = (uint32_t *)in1->data[0]; | ||
| 615 | uint8_t *src2 = in2->data[0]; | ||
| 616 | const int src1_linesize = in1->linesize[0] >> 2; | ||
| 617 | const int src2_linesize = in2->linesize[0]; | ||
| 618 | const float div = in1->width * in1->height * 3; | ||
| 619 | unsigned mean_err = 0; | ||
| 620 | |||
| 621 | for (y = 0; y < in1->height; y++) { | ||
| 622 | for (x = 0; x < in1->width; x++) { | ||
| 623 | const struct color_info c1 = get_color_from_srgb(0xff000000 | src1[x]); | ||
| 624 | const struct color_info c2 = get_color_from_srgb(0xff000000 | palette[src2[x]]); | ||
| 625 | mean_err += diff(&c1, &c2, s->trans_thresh); | ||
| 626 | } | ||
| 627 | src1 += src1_linesize; | ||
| 628 | src2 += src2_linesize; | ||
| 629 | } | ||
| 630 | |||
| 631 | s->total_mean_err += mean_err; | ||
| 632 | |||
| 633 | av_log(NULL, AV_LOG_INFO, "MEP:%.3f TotalMEP:%.3f\n", | ||
| 634 | mean_err / div, s->total_mean_err / (div * frame_count)); | ||
| 635 | } | ||
| 636 | |||
| 637 | static void set_processing_window(enum diff_mode diff_mode, | 608 | static void set_processing_window(enum diff_mode diff_mode, |
| 638 | const AVFrame *prv_src, const AVFrame *cur_src, | 609 | const AVFrame *prv_src, const AVFrame *cur_src, |
| 639 | const AVFrame *prv_dst, AVFrame *cur_dst, | 610 | const AVFrame *prv_dst, AVFrame *cur_dst, |
| @@ -759,8 +730,6 @@ static int apply_palette(AVFilterLink *inlink, AVFrame *in, AVFrame **outf) · 119 unmodified lines | |||
| 759 | return ret; | 730 | return ret; |
| 760 | } | 731 | } |
| 761 | memcpy(out->data[1], s->palette, AVPALETTE_SIZE); | 732 | memcpy(out->data[1], s->palette, AVPALETTE_SIZE); |
| 762 | if (s->calc_mean_err) | ||
| 763 | debug_mean_error(s, in, out, inlink->frame_count_out); | ||
| 764 | *outf = out; | 733 | *outf = out; |
| 765 | return 0; | 734 | return 0; |
| 766 | } | 735 | } |