From patchwork Mon Oct 2 17:24:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Roche X-Patchwork-Id: 5383 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.61.8 with SMTP id n8csp1752577jan; Mon, 2 Oct 2017 10:25:26 -0700 (PDT) X-Received: by 10.223.197.13 with SMTP id q13mr16382598wrf.80.1506965126532; Mon, 02 Oct 2017 10:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506965126; cv=none; d=google.com; s=arc-20160816; b=CdRsLE8E7UFFR/6rrrw42jnQz7VNAv3yr4e+rPPNDo/A8bAxgLlLyA8M9guGIyainj xFUfSrV7dV8gS6KT2emVGKozp0KCXoGZJxYqZplaGfAmkCaISULuKqDceh2uZR0eTE1q 85QzpqMdH3Z6WS76O88qDA367HyPUUhKR0wxOgIA6kOtEC6FWGunN9XAG3+EsCo4Mkn9 Nhw3d6tUnE9NLl0wm/xzKteJFmF+aYLKgFHXJaR/piq3H/xBV19Ekv+qlqusHmYJADhc 6031B8XVBaizAevqAAOEw0MTeW4Xis87DYOiVV+Oc+PaIubQCN9jY9Lpj9Exn6o46mCS AQvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=owwMDz14Y22pGml803/I4ARAUgWo87eWC9gBAPnzbrc=; b=SpdETiLGnMnTzuE4ENVoSDvwRwx1axynMnTALkpIsiiclUIDzL+itj5x7ujv2EpO5u a7XZLAnBRQA3Q9i4vbNqeUO2Tigg7PwRHkSrzxCXgOsJymr1dMn7Jh6r+8ATw8yfmHVJ U7SupAtd8PBEWl6TnzAoEB6GEMfKKtAOv7Zxuvaq+amcVETk4ootIgZFcvhc/obkjApA kBbgVKBr+bvbAkiF3ayn6JyZiGbemGTD82a6BJg7vovJxhKghAvSgk1SPhTJgoYqb/+D GuIN1r7eAfcNCZ5rqiTlKPIz1bnzfCP21Ls86ukuPGllkaB7q6af7PdFuh2fb3g8QplD q/Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@giphy.com header.s=google header.b=m1Wnobgx; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id w18si9245498wra.410.2017.10.02.10.25.26; Mon, 02 Oct 2017 10:25:26 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@giphy.com header.s=google header.b=m1Wnobgx; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2270E689F00; Mon, 2 Oct 2017 20:24:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f181.google.com (mail-qk0-f181.google.com [209.85.220.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D0FAF689CE6 for ; Mon, 2 Oct 2017 20:24:48 +0300 (EEST) Received: by mail-qk0-f181.google.com with SMTP id w63so5928910qkd.10 for ; Mon, 02 Oct 2017 10:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=giphy.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=R+WyUmli7+NeLJ84dOs1jUyPxSunsB/lWypTRxoXMhw=; b=m1Wnobgx+kxuN/loRk+LNJc1wY6I9DbhDDARsqOj4/NNeF31gITfg4jFb29tbKvsib jDFYaF3EQVkihDW5Z6cs07bF8Cvywr7EFm1QS+o9Zi6x0n+Ft7SdA68LsvGytly0S6YO zwARmK8UxSe2IYVTCL7VPC3BZD89Du49PvK2M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=R+WyUmli7+NeLJ84dOs1jUyPxSunsB/lWypTRxoXMhw=; b=F24Ft+Tp/HLsUX7IVf+P+2JyEAeeK/GkpEoayPz9kx5oeXqG9kqU9yJmU8iIzeQLUx ytdCAh274MOHjfVlUCcyVi9uG1NnTGM2j+sCP5NjCL+kotXW1YpzSx/1q0Za+96iU4ua 6+t6o2LH5WGhdfjpe0wVgs4Qd77480S2GniqXTUtQbwYmTPm4HJTWSlBX+g0adXrcGj7 TZ1brjfQVQkd/5Fr49hhxIJs7iEjnIbZCxeMvZZxnsXNd1Qx6atij+x00makiL9M1O8t t3Xusy+g9YCagILb3GCDCvuqQj41YZWa279psSkwrYuH9oQ7vrSXpEW2H4oSlIPEy/S6 RWCg== X-Gm-Message-State: AMCzsaUPX1zf2edFvIjqclBTtinjo1eF26Cd5xxxvLycxTZSWrDRziai iBaL861yHeGPAvUHbtZT/hv8FrWRNKU= X-Google-Smtp-Source: AOwi7QAx3TXZ2I8MvClWngjE5GRhbXy1xQQSRqjEUQmrATwMx5b7VbgbL6MN+U+GbF/FSvne+24Ltg== X-Received: by 10.55.120.129 with SMTP id t123mr16288183qkc.13.1506965102134; Mon, 02 Oct 2017 10:25:02 -0700 (PDT) Received: from localhost.localdomain ([208.184.100.82]) by smtp.gmail.com with ESMTPSA id p25sm7339001qte.28.2017.10.02.10.25.01 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 02 Oct 2017 10:25:01 -0700 (PDT) From: Bjorn Roche To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Oct 2017 13:24:35 -0400 Message-Id: <20171002172439.65628-4-bjorn@giphy.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171002172439.65628-1-bjorn@giphy.com> References: <20171002172439.65628-1-bjorn@giphy.com> Subject: [FFmpeg-devel] [PATCH 3/7] Removing some debugging X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Bjorn Roche MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Bjorn Roche --- libavfilter/vf_paletteuse.c | 65 ++++++++------------------------------------- 1 file changed, 11 insertions(+), 54 deletions(-) diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c index abee1b3735..21870c22f5 100644 --- a/libavfilter/vf_paletteuse.c +++ b/libavfilter/vf_paletteuse.c @@ -172,14 +172,11 @@ static av_always_inline int diff(const uint8_t *c1, const uint8_t *c2) const int dg = c1[2] - c2[2]; const int db = c1[3] - c2[3]; - printf( "alpha 1, 2: %d, %d\n", c1[0], c2[0] ); - return ( c1[0] == 0 && c2[0] == 0 ) ? 0 : ( (c1[0] == c2[0]) ? (dr*dr + dg*dg + db*db) : (max_diff) ) ; } static av_always_inline uint8_t colormap_nearest_bruteforce(const uint32_t *palette, const uint8_t *rgb) { - printf( "colormap_nearest_bruteforce\n" ); int i, pal_id = -1, min_dist = INT_MAX; for (i = 0; i < AVPALETTE_COUNT; i++) { @@ -214,7 +211,6 @@ static void colormap_nearest_node(const struct color_node *map, const uint8_t *target, struct nearest_color *nearest) { - printf( "colormap_nearest_node\n" ); const struct color_node *kd = map + node_pos; const int s = kd->split; int dx, nearer_kd_id, further_kd_id; @@ -255,7 +251,6 @@ struct stack_node { static av_always_inline uint8_t colormap_nearest_iterative(const struct color_node *root, const uint8_t *target) { - printf( "colormap_nearest_iterative\n" ); int pos = 0, best_node_id = -1, best_dist = INT_MAX, cur_color_id = 0; struct stack_node nodes[16]; struct stack_node *node = &nodes[0]; @@ -266,14 +261,11 @@ static av_always_inline uint8_t colormap_nearest_iterative(const struct color_no const uint8_t *current = kd->val; const int current_to_target = diff(target, current); - printf( "%d-%d-%d-%d, %d, %d-%d-%d-%d\n", target[0], target[1], target[2], target[3], current_to_target, current[0], current[1], current[2], current[3] ); - /* Compare current color node to the target and update our best node if * it's actually better. */ if (current_to_target < best_dist) { best_node_id = cur_color_id; if (!current_to_target) { - printf( "exact\n"); goto end; // exact match, we can return immediately } best_dist = current_to_target; @@ -282,7 +274,6 @@ static av_always_inline uint8_t colormap_nearest_iterative(const struct color_no /* Check if it's not a leaf */ if (kd->left_id != -1 || kd->right_id != -1) { const int split = kd->split; - printf( "split %d\n", split ); const int dx = target[split-1] - current[split-1]; int nearer_kd_id, further_kd_id; @@ -317,10 +308,8 @@ static av_always_inline uint8_t colormap_nearest_iterative(const struct color_no /* Unstack as much as we can, typically as long as the least probable * branch aren't actually probable. */ do { - if (--pos < 0) { - printf( "pos < 0\n"); + if (--pos < 0) goto end; - } node--; } while (node->dx2 >= best_dist); @@ -351,7 +340,6 @@ static av_always_inline int color_get(struct cache_node *cache, uint32_t argb, const uint32_t *palette, const enum color_search_method search_method) { - printf("color_get\n"); int i; const uint8_t argb_elts[] = {a, r, g, b}; const uint8_t rhash = r & ((1<= 0 ) { - printf( "trans %d %d %d %d\n", a, r, g, b ); return transparency_index; } - printf( "opaque %d %d %d %d\n", a, r, g, b ); for (i = 0; i < node->nb_entries; i++) { e = &node->entries[i]; @@ -397,7 +381,6 @@ static av_always_inline int get_dst_color_err(struct cache_node *cache, const uint8_t r = argb >> 16 & 0xff; const uint8_t g = argb >> 8 & 0xff; const uint8_t b = argb & 0xff; - printf( "get_dst_color_err %d %d %d %d %d\n", argb, a, r, g, b ); const int dstx = color_get(cache, argb, a, r, g, b, transparency_index, map, palette, search_method); const uint32_t dstc = palette[dstx]; *er = r - (dstc >> 16 & 0xff); @@ -412,7 +395,6 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram const enum color_search_method search_method) { int x, y; - printf( "set_frame\n" ); const struct color_node *map = s->map; struct cache_node *cache = s->cache; const uint32_t *palette = s->palette; @@ -430,7 +412,6 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram int er, eg, eb; if (dither == DITHERING_BAYER) { - printf( "bayer\n" ); const int d = s->ordered_dither[(y & 7)<<3 | (x & 7)]; const uint8_t a8 = src[x] >> 24 & 0xff; const uint8_t r8 = src[x] >> 16 & 0xff; @@ -439,7 +420,6 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram const uint8_t r = av_clip_uint8(r8 + d); const uint8_t g = av_clip_uint8(g8 + d); const uint8_t b = av_clip_uint8(b8 + d); - //const uint32_t argb = a8 << 24 | r<<16 | g<<8 | b; const int color = color_get(cache, src[x], a8, r, g, b, transparency_index, map, palette, search_method); if (color < 0) @@ -447,7 +427,6 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram dst[x] = color; } else if (dither == DITHERING_HECKBERT) { - printf( "heckbert\n" ); const int right = x < w - 1, down = y < h - 1; const int color = get_dst_color_err(cache, src[x], map, palette, transparency_index, &er, &eg, &eb, search_method); @@ -460,7 +439,6 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram if (right && down) src[src_linesize + x + 1] = dither_color(src[src_linesize + x + 1], er, eg, eb, 2, 3); } else if (dither == DITHERING_FLOYD_STEINBERG) { - printf( "fs\n" ); const int right = x < w - 1, down = y < h - 1, left = x > x_start; const int color = get_dst_color_err(cache, src[x], map, palette, transparency_index, &er, &eg, &eb, search_method); @@ -474,7 +452,6 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram if (right && down) src[src_linesize + x + 1] = dither_color(src[src_linesize + x + 1], er, eg, eb, 1, 4); } else if (dither == DITHERING_SIERRA2) { - printf( "s2\n" ); const int right = x < w - 1, down = y < h - 1, left = x > x_start; const int right2 = x < w - 2, left2 = x > x_start + 1; const int color = get_dst_color_err(cache, src[x], map, palette, transparency_index, &er, &eg, &eb, search_method); @@ -495,7 +472,6 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram } } else if (dither == DITHERING_SIERRA2_4A) { - printf( "s24a\n" ); const int right = x < w - 1, down = y < h - 1, left = x > x_start; const int color = get_dst_color_err(cache, src[x], map, palette, transparency_index, &er, &eg, &eb, search_method); @@ -508,24 +484,12 @@ static av_always_inline int set_frame(PaletteUseContext *s, AVFrame *out, AVFram if ( down) src[src_linesize + x ] = dither_color(src[src_linesize + x ], er, eg, eb, 1, 2); } else { - printf( "none\n" ); const uint8_t a = src[x] >> 24 & 0xff; const uint8_t r = src[x] >> 16 & 0xff; const uint8_t g = src[x] >> 8 & 0xff; const uint8_t b = src[x] & 0xff; const int color = color_get(cache, src[x], a, r, g, b, transparency_index, map, palette, search_method); - printf( "%3d,%3d,%3d,%3d -> %3d -> %3d,%3d,%3d,%3d\n", - src[x] >> 24 & 0xff, - src[x] >> 16 & 0xff, - src[x] >> 8 & 0xff, - src[x] >> 0 & 0xff, - color, - s->palette[color] >> 24 & 0xff, - s->palette[color] >> 16 & 0xff, - s->palette[color] >> 8 & 0xff, - s->palette[color] >> 0 & 0xff ); - if (color < 0) return color; dst[x] = color; @@ -777,23 +741,16 @@ static void load_colormap(PaletteUseContext *s, int nb_colors) continue; } last_color = c; - // if ((c & 0xff000000) == 0x00000000) { // ignore totally transparent - // color_used[i] = 1; // ignore transparent color(s) - // continue; - // } } box.min[0] = box.min[1] = box.min[2] = 0x00; box.max[0] = box.max[1] = box.max[2] = 0xff; - //printf( "-0- %d\n", nb_colors ); - colormap_insert(s->map, color_used, &nb_used, s->palette, nb_colors, &box); - for (i = 0; i < nb_used; i++) { - //printf( "-p-: %d\n", s->palette[i] ); - printf( "map: %3d %3d %3d %3d -> %3d\n", s->map[i].val[0], s->map[i].val[1], s->map[i].val[2], s->map[i].val[3], s->map[i].palette_id ); - } + // for (i = 0; i < nb_used; i++) { + // printf( "map: %3d %3d %3d %3d -> %3d\n", s->map[i].val[0], s->map[i].val[1], s->map[i].val[2], s->map[i].val[3], s->map[i].palette_id ); + // } if (s->dot_filename) disp_tree(s->map, s->dot_filename); @@ -1026,7 +983,7 @@ static void load_palette(PaletteUseContext *s, const AVFrame *palette_frame) ++pal_index; } else { has_transparency = 1; - printf( "ti set %d\n", pal_index ); + //printf( "ti set %d\n", pal_index ); } } p += p_linesize; @@ -1036,16 +993,16 @@ static void load_palette(PaletteUseContext *s, const AVFrame *palette_frame) if( has_transparency ) { s->transparency_index = pal_index; - printf( "ti set\n" ); + //printf( "ti set\n" ); } - printf( "%d\n", s->transparency_index ); + //printf( "%d\n", s->transparency_index ); - for (int j=0; jheight * palette_frame->width; ++j ) { - printf( "palette: %3i: %3d, %3d, %3d, %3d\n", j, ( s->palette[j] >> 24 ) & 0xff, ( s->palette[j] >> 16 ) & 0xff, ( s->palette[j] >> 8 ) & 0xff, ( s->palette[j] >> 0 ) & 0xff ); - } + // for (int j=0; jheight * palette_frame->width; ++j ) { + // printf( "palette: %3i: %3d, %3d, %3d, %3d\n", j, ( s->palette[j] >> 24 ) & 0xff, ( s->palette[j] >> 16 ) & 0xff, ( s->palette[j] >> 8 ) & 0xff, ( s->palette[j] >> 0 ) & 0xff ); + // } - printf( "::palette loaded with transparency index :: %d\n", s->transparency_index ); + // printf( "::palette loaded with transparency index :: %d\n", s->transparency_index ); if (!s->new) s->palette_loaded = 1;