huffman: K&R formatting cosmetics

Message ID 1477563691-21155-1-git-send-email-diego@biurrun.de
State New
Headers show

Commit Message

Diego Biurrun Oct. 27, 2016, 10:21 a.m.
---
 libavcodec/huffman.c | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

Comments

Anton Khirnov Oct. 27, 2016, 10:59 a.m. | #1
Quoting Diego Biurrun (2016-10-27 12:21:31)
> ---
>  libavcodec/huffman.c | 41 +++++++++++++++++++++--------------------
>  1 file changed, 21 insertions(+), 20 deletions(-)
> 
> diff --git a/libavcodec/huffman.c b/libavcodec/huffman.c
> index 3b15aa2..e7764f9 100644
> --- a/libavcodec/huffman.c
> +++ b/libavcodec/huffman.c
> @@ -26,7 +26,7 @@

As a standalone patch? I am against this, it's pure noise.

And more generally, I think any pure reformatting patches that are not
either:
 - a part of a larger set that does non-cosmetic changes on the affected
   code
 - touching a file that blatantly violates the coding standards all over
   the place (not the case here, and we have very few, if any, of those
   left)
should be rejected.

Patch

diff --git a/libavcodec/huffman.c b/libavcodec/huffman.c
index 3b15aa2..e7764f9 100644
--- a/libavcodec/huffman.c
+++ b/libavcodec/huffman.c
@@ -26,7 +26,7 @@ 
 
 #include <stdint.h>
 
-#include"libavutil/common.h"
+#include "libavutil/common.h"
 
 #include "avcodec.h"
 #include "huffman.h"
@@ -44,7 +44,7 @@  static void heap_sift(HeapElem *h, int root, int size)
 {
     while (root * 2 + 1 < size) {
         int child = root * 2 + 1;
-        if (child < size - 1 && h[child].val > h[child+1].val)
+        if (child < size - 1 && h[child].val > h[child + 1].val)
             child++;
         if (h[root].val > h[child].val) {
             FFSWAP(HeapElem, h[root], h[child]);
@@ -57,15 +57,15 @@  static void heap_sift(HeapElem *h, int root, int size)
 void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats)
 {
     HeapElem h[256];
-    int up[2*256];
-    int len[2*256];
+    int up[2 * 256];
+    int len[2 * 256];
     int offset, i, next;
     int size = 256;
 
-    for (offset = 1; ; offset <<= 1) {
-        for (i=0; i < size; i++) {
+    for (offset = 1;; offset <<= 1) {
+        for (i = 0; i < size; i++) {
             h[i].name = i;
-            h[i].val = (stats[i] << 8) + offset;
+            h[i].val  = (stats[i] << 8) + offset;
         }
         for (i = size / 2 - 1; i >= 0; i--)
             heap_sift(h, i, size);
@@ -74,11 +74,11 @@  void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats)
             // merge the two smallest entries, and put it back in the heap
             uint64_t min1v = h[0].val;
             up[h[0].name] = next;
-            h[0].val = INT64_MAX;
+            h[0].val      = INT64_MAX;
             heap_sift(h, 0, size);
             up[h[0].name] = next;
-            h[0].name = next;
-            h[0].val += min1v;
+            h[0].name     = next;
+            h[0].val     += min1v;
             heap_sift(h, 0, size);
         }
 
@@ -87,9 +87,11 @@  void ff_huff_gen_len_table(uint8_t *dst, const uint64_t *stats)
             len[i] = len[up[i]] + 1;
         for (i = 0; i < size; i++) {
             dst[i] = len[up[i]] + 1;
-            if (dst[i] >= 32) break;
+            if (dst[i] >= 32)
+                break;
         }
-        if (i==size) break;
+        if (i == size)
+            break;
     }
 }
 
@@ -129,7 +131,6 @@  static int build_huff_tree(VLC *vlc, Node *nodes, int head, int flags, int nb_bi
     return ff_init_vlc_sparse(vlc, nb_bits, pos, lens, 2, 2, bits, 4, 4, xlat, 1, 1, 0);
 }
 
-
 /**
  * nodes size must be 2*nb_codes
  * first nb_codes nodes.count must be set
@@ -143,8 +144,8 @@  int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, int nb_bit
 
     for (i = 0; i < nb_codes; i++) {
         nodes[i].sym = i;
-        nodes[i].n0 = -2;
-        sum += nodes[i].count;
+        nodes[i].n0  = -2;
+        sum         += nodes[i].count;
     }
 
     if (sum >> 31) {
@@ -154,18 +155,18 @@  int ff_huff_build_tree(AVCodecContext *avctx, VLC *vlc, int nb_codes, int nb_bit
         return -1;
     }
     qsort(nodes, nb_codes, sizeof(Node), cmp);
-    cur_node = nb_codes;
-    nodes[nb_codes*2-1].count = 0;
+    cur_node                      = nb_codes;
+    nodes[nb_codes * 2 - 1].count = 0;
     for (i = 0; i < nb_codes * 2 - 1; i += 2) {
-        nodes[cur_node].sym = HNODE;
+        nodes[cur_node].sym   = HNODE;
         nodes[cur_node].count = nodes[i].count + nodes[i + 1].count;
-        nodes[cur_node].n0 = i;
+        nodes[cur_node].n0    = i;
         for (j = cur_node; j > 0; j--) {
             if (nodes[j].count > nodes[j - 1].count ||
                 (nodes[j].count == nodes[j - 1].count &&
                  (!(flags & FF_HUFFMAN_FLAG_HNODE_FIRST) ||
                   nodes[j].n0 == j - 1 || nodes[j].n0 == j - 2 ||
-                  (nodes[j].sym!=HNODE && nodes[j-1].sym!=HNODE))))
+                  (nodes[j].sym != HNODE && nodes[j - 1].sym != HNODE))))
                 break;
             FFSWAP(Node, nodes[j], nodes[j - 1]);
         }