/* magic number division by 3 from schroedinger */
static inline int divide3(int x)
{
- return ((x+1)*21845 + 10922) >> 16;
+ return (int)((x+1U)*21845 + 10922) >> 16;
}
static DiracFrame *remove_frame(DiracFrame *framelist[], int picnum)
static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset)
{
int coeff = dirac_get_se_golomb(gb);
- const int sign = FFSIGN(coeff);
+ const unsigned sign = FFSIGN(coeff);
if (coeff)
coeff = sign*((sign * coeff * qfactor + qoffset) >> 2);
return coeff;
static inline void coeff_unpack_arith_##n(DiracArith *c, int qfactor, int qoffset, \
SubBand *b, type *buf, int x, int y) \
{ \
- int coeff, sign, sign_pred = 0, pred_ctx = CTX_ZPZN_F1; \
+ int sign, sign_pred = 0, pred_ctx = CTX_ZPZN_F1; \
+ unsigned coeff; \
const int mstride = -(b->stride >> (1+b->pshift)); \
if (b->parent) { \
const type *pbuf = (type *)b->parent->ibuf; \
} \
INTRA_DC_PRED(8, int16_t)
-INTRA_DC_PRED(10, int32_t)
+INTRA_DC_PRED(10, uint32_t)
/**
* Dirac Specification ->
skip_bits_long(gb, 8*s->highquality.prefix_bytes);
quant_idx = get_bits(gb, 8);
- if (quant_idx > DIRAC_MAX_QUANT_INDEX) {
+ if (quant_idx > DIRAC_MAX_QUANT_INDEX - 1) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid quantization index - %i\n", quant_idx);
return AVERROR_INVALIDDATA;
}
s->globalmc[ref].perspective[0] = dirac_get_se_golomb(gb);
s->globalmc[ref].perspective[1] = dirac_get_se_golomb(gb);
}
+ if (s->globalmc[ref].perspective_exp + (uint64_t)s->globalmc[ref].zrs_exp > 30) {
+ return AVERROR_INVALIDDATA;
+ }
+
}
}
if (get_bits1(gb)) {
s->weight_log2denom = get_interleaved_ue_golomb(gb);
+ if (s->weight_log2denom < 1 || s->weight_log2denom > 8) {
+ av_log(s->avctx, AV_LOG_ERROR, "weight_log2denom unsupported or invalid\n");
+ s->weight_log2denom = 1;
+ return AVERROR_INVALIDDATA;
+ }
s->weight[0] = dirac_get_se_golomb(gb);
if (s->num_refs == 2)
s->weight[1] = dirac_get_se_golomb(gb);
if (get_bits1(gb)) {
av_log(s->avctx,AV_LOG_DEBUG,"Low Delay: Has Custom Quantization Matrix!\n");
/* custom quantization matrix */
- s->lowdelay.quant[0][0] = get_interleaved_ue_golomb(gb);
for (level = 0; level < s->wavelet_depth; level++) {
- s->lowdelay.quant[level][1] = get_interleaved_ue_golomb(gb);
- s->lowdelay.quant[level][2] = get_interleaved_ue_golomb(gb);
- s->lowdelay.quant[level][3] = get_interleaved_ue_golomb(gb);
+ for (i = !!level; i < 4; i++) {
+ s->lowdelay.quant[level][i] = get_interleaved_ue_golomb(gb);
+ }
}
} else {
if (s->wavelet_depth > 4) {
if (!block->ref) {
pred_block_dc(block, stride, x, y);
for (i = 0; i < 3; i++)
- block->u.dc[i] += dirac_get_arith_int(arith+1+i, CTX_DC_F1, CTX_DC_DATA);
+ block->u.dc[i] += (unsigned)dirac_get_arith_int(arith+1+i, CTX_DC_F1, CTX_DC_DATA);
return;
}
if (out) {
out->reference ^= DELAYED_PIC_REF;
- *got_frame = 1;
if((ret = av_frame_ref(picture, out->avframe)) < 0)
return ret;
+ *got_frame = 1;
}
return 0;
return ret;
}
- ret = ff_set_dimensions(avctx, dsh->width, dsh->height);
+ if (CALC_PADDING((int64_t)dsh->width, MAX_DWT_LEVELS) * CALC_PADDING((int64_t)dsh->height, MAX_DWT_LEVELS) > avctx->max_pixels)
+ ret = AVERROR(ERANGE);
+ if (ret >= 0)
+ ret = ff_set_dimensions(avctx, dsh->width, dsh->height);
if (ret < 0) {
av_freep(&dsh);
return ret;