shithub: dav1d

Download patch

ref: 2faf1016f0d6b8a0d39c3796738a38095972e231
parent: 2d3e3ef02956b555c3184a993570d477da51ebd5
author: skal <pascal.massimino@gmail.com>
date: Tue Oct 2 14:06:07 EDT 2018

fix -Wsign-compare warnings

"comparison between signed and unsigned integer expressions"

--- a/src/getbits.c
+++ b/src/getbits.c
@@ -82,8 +82,8 @@
     assert(n > 0);
     const int l = ulog2(n) + 1;
     assert(l > 0);
-    const int m = (1 << l) - n;
-    const int v = dav1d_get_bits(c, l - 1);
+    const unsigned m = (1U << l) - n;
+    const unsigned v = dav1d_get_bits(c, l - 1);
     return v < m ? v : (v << 1) - m + dav1d_get_bits(c, 1);
 }
 
--- a/src/lib.c
+++ b/src/lib.c
@@ -193,7 +193,7 @@
         if ((res = dav1d_parse_obus(c, in)) < 0)
             return res;
 
-        assert(res <= in->sz);
+        assert(res <= (int)in->sz);
         in->sz -= res;
         in->data += res;
         if (!in->sz) dav1d_data_unref(in);
@@ -252,7 +252,7 @@
                 t->tile_thread.die = 1;
             }
             pthread_cond_broadcast(&f->tile_thread.cond);
-            while (f->tile_thread.available != (1 << f->n_tc) - 1)
+            while (f->tile_thread.available != (1U << f->n_tc) - 1)
                 pthread_cond_wait(&f->tile_thread.icond,
                                   &f->tile_thread.lock);
             pthread_mutex_unlock(&f->tile_thread.lock);
--- a/src/msac.c
+++ b/src/msac.c
@@ -273,14 +273,14 @@
     int i = 0;
     int a = 0;
     int b = k;
-    while ((2 << b) < n) {
+    while ((2U << b) < n) {
         if (!msac_decode_bool(c, 128 << 7)) break;
         b = k + i++;
         a = (1 << b);
     }
     const unsigned v = msac_decode_bools(c, b) + a;
-    return ref * 2 <= n ? inv_recenter(ref, v) :
-                          n - 1 - inv_recenter(n - 1 - ref, v);
+    return ref * 2U <= n ? inv_recenter(ref, v) :
+                           n - 1 - inv_recenter(n - 1 - ref, v);
 }
 
 int msac_decode_uniform(MsacContext *const c, const unsigned n) {
@@ -287,14 +287,14 @@
     assert(n > 0);
     const int l = ulog2(n) + 1;
     assert(l > 1);
-    const int m = (1 << l) - n;
-    const int v = msac_decode_bools(c, l - 1);
+    const unsigned m = (1U << l) - n;
+    const unsigned v = msac_decode_bools(c, l - 1);
     return v < m ? v : (v << 1) - m + msac_decode_bool(c, 128 << 7);
 }
 
 void update_cdf(uint16_t *cdf, unsigned val, unsigned nsymbs) {
     int rate;
-    int i, tmp;
+    unsigned i, tmp;
 
     static const int nsymbs2speed[17] = {
         0, 0, 1, 1, 2, 2, 2, 2, 2,
@@ -302,7 +302,7 @@
     };
     assert(nsymbs < 17);
     rate = 3 + (cdf[nsymbs] > 15) + (cdf[nsymbs] > 31) + nsymbs2speed[nsymbs];
-    tmp = 32768;
+    tmp = 32768U;
 
     // Single loop (faster)
     for (i = 0; i < nsymbs - 1; ++i) {
--- a/src/obu.c
+++ b/src/obu.c
@@ -200,7 +200,7 @@
 #endif
 
     const int hbd = dav1d_get_bits(gb, 1);
-    hdr->bpc = hdr->profile == 2 && hbd ? 10 + 2 * dav1d_get_bits(gb, 1): 8 + 2 * hbd;
+    hdr->bpc = hdr->profile == 2 && hbd ? 10U + 2 * dav1d_get_bits(gb, 1) : 8U + 2 * hbd;
     hdr->hbd = hdr->bpc > 8;
     const int monochrome = hdr->profile != 1 ? dav1d_get_bits(gb, 1) : 0;
     hdr->color_description_present = dav1d_get_bits(gb, 1);
@@ -516,8 +516,9 @@
     if (hdr->quant.qm) {
         hdr->quant.qm_y = dav1d_get_bits(gb, 4);
         hdr->quant.qm_u = dav1d_get_bits(gb, 4);
-        hdr->quant.qm_v = seqhdr->separate_uv_delta_q ? dav1d_get_bits(gb, 4) :
-                                                        hdr->quant.qm_u;
+        hdr->quant.qm_v =
+            seqhdr->separate_uv_delta_q ? (int)dav1d_get_bits(gb, 4) :
+                                          hdr->quant.qm_u;
     }
 #if DEBUG_FRAME_HDR
     printf("HDR: post-qm: off=%ld\n",
@@ -1005,7 +1006,7 @@
 
     int off = dav1d_flush_get_bits(&gb) - in->data;
     const int init_off = off;
-    if (len > in->sz - off) goto error;
+    if (len > (int)in->sz - off) goto error;
 
     switch (type) {
     case OBU_SEQ_HDR:
@@ -1063,7 +1064,7 @@
     const int n_tiles = 1 << (c->frame_hdr.tiling.log2_cols +
                               c->frame_hdr.tiling.log2_rows);
     if (c->have_seq_hdr && c->have_frame_hdr &&
-        c->tile_mask == (1 << n_tiles) - 1)
+        c->tile_mask == (1U << n_tiles) - 1)
     {
         if (!c->n_tile_data)
             return -EINVAL;
--- a/src/picture.c
+++ b/src/picture.c
@@ -161,7 +161,7 @@
     const int ss_ver = p->p.p.layout == DAV1D_PIXEL_LAYOUT_I420;
     y_unclipped *= 1 << (plane_type & ss_ver); // we rely here on PLANE_TYPE_UV being 1
     y_unclipped += (plane_type != PLANE_TYPE_BLOCK) * 8; // delay imposed by loopfilter
-    const int y = iclip(y_unclipped, 1, p->p.p.h);
+    const unsigned y = iclip(y_unclipped, 1, p->p.p.h);
     atomic_uint *const progress = &p->progress[plane_type != PLANE_TYPE_BLOCK];
 
     if (atomic_load_explicit(progress, memory_order_acquire) >= y)
--- a/src/recon.c
+++ b/src/recon.c
@@ -109,7 +109,7 @@
             idx = msac_decode_symbol_adapt(&ts->msac, txtp_cdf, set_cnt);
             if (dbg)
             printf("Post-txtp[%d->%d][%d->%d][%d][%d->%d]: r=%d\n",
-                   set, set_idx, tx, t_dim->min, b->intra ? y_mode_nofilt : -1,
+                   set, set_idx, tx, t_dim->min, b->intra ? (int)y_mode_nofilt : -1,
                    idx, dav1d_tx_types_per_set[set][idx], ts->msac.rng);
         }
         *txtp = dav1d_tx_types_per_set[set][idx];