Commit 2faf1016 authored by skal's avatar skal Committed by Ronald S. Bultje

fix -Wsign-compare warnings

"comparison between signed and unsigned integer expressions"
parent 2d3e3ef0
......@@ -82,8 +82,8 @@ unsigned dav1d_get_uniform(GetBits *const c, const unsigned n) {
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);
}
......
......@@ -193,7 +193,7 @@ int dav1d_decode(Dav1dContext *const c,
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 @@ void dav1d_close(Dav1dContext **const c_out) {
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);
......
......@@ -273,28 +273,28 @@ int msac_decode_subexp(MsacContext *const c, const int ref,
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) {
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 @@ void update_cdf(uint16_t *cdf, unsigned val, unsigned nsymbs) {
};
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) {
......
......@@ -200,7 +200,7 @@ static int parse_seq_hdr(Dav1dContext *const c, GetBits *const gb) {
#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 @@ static int parse_frame_hdr(Dav1dContext *const c, GetBits *const gb,
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 dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
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 @@ int dav1d_parse_obus(Dav1dContext *const c, Dav1dData *const in) {
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;
......
......@@ -161,7 +161,7 @@ void dav1d_thread_picture_wait(const Dav1dThreadPicture *const p,
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)
......
......@@ -109,7 +109,7 @@ static int decode_coefs(Dav1dTileContext *const t,
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];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment