IMAGE: Compilation fixes for Indeo4 decoder

This commit is contained in:
Paul Gilbert 2016-09-10 10:43:23 -04:00
parent a6ffef9e26
commit 9c7b9e1667
6 changed files with 15 additions and 14 deletions

View File

@ -21,6 +21,7 @@
*/
#include "image/codecs/indeo/get_bits.h"
#include "image/codecs/indeo/mem.h"
#include "common/algorithm.h"
#include "common/endian.h"
#include "common/textconsole.h"
@ -158,7 +159,7 @@ static uint zeroExtend(uint val, uint bits) {
}
GetBits::GetBits(const byte *buffer, size_t totalBits) {
assert(buffer && totalBits < (INT_MAX - 7));
assert(buffer && totalBits < (MAX_INTEGER - 7));
_buffer = buffer;
_sizeInBits = totalBits;

View File

@ -1304,7 +1304,7 @@ int IndeoDecoderBase::ivi_decode_coded_blocks(GetBits *gb, IVIBandDesc *band,
col_flags[pos & col_mask] |= !!val;
}
if (scan_pos < 0 || scan_pos >= num_coeffs && sym != rvmap->eob_sym)
if (scan_pos < 0 || (scan_pos >= num_coeffs && sym != rvmap->eob_sym))
return -1; // corrupt block data
// undoing DC coeff prediction for intra-blocks
@ -1348,7 +1348,7 @@ int IndeoDecoderBase::ivi_dc_transform(IVIBandDesc *band, int *prev_dc,
/*------------------------------------------------------------------------*/
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) {
if (((w + 128) * (uint64)(h + 128)) < (INT_MAX / 8))
if (((w + 128) * (uint64)(h + 128)) < (MAX_INTEGER / 8))
return 0;
error("Picture size %ux%u is invalid", w, h);

View File

@ -113,7 +113,7 @@ struct IVIHuffDesc {
void ivi_huff_desc_copy(const IVIHuffDesc *src);
};
class IVI45DecContext;
struct IVI45DecContext;
/**
* macroblock/block huffman table descriptor
@ -341,7 +341,7 @@ struct AVFrame {
};
struct IVI45DecContext {
friend class IVIHuffTab;
friend struct IVIHuffTab;
private:
VLC_TYPE table_data[8192 * 16][2];
VLC ivi_mb_vlc_tabs[8]; ///< static macroblock Huffman tables

View File

@ -85,13 +85,13 @@ void *av_mallocz(size_t size) {
}
void *av_malloc_array(size_t nmemb, size_t size) {
if (!size || nmemb >= INT_MAX / size)
if (!size || nmemb >= MAX_INTEGER / size)
return nullptr;
return malloc(nmemb * size);
}
void *av_mallocz_array(size_t nmemb, size_t size) {
if (!size || nmemb >= INT_MAX / size)
if (!size || nmemb >= MAX_INTEGER / size)
return NULL;
return av_mallocz(nmemb * size);

View File

@ -38,6 +38,7 @@ namespace Indeo {
#define FFALIGN(x, a) (((x) + (a)-1) & ~((a)-1))
#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
#define FFSIGN(a) ((a) > 0 ? 1 : -1)
#define MAX_INTEGER 0x7ffffff
/**
* Allocate a memory block with alignment suitable for all memory accesses

View File

@ -317,7 +317,7 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
if (!_ctx.gb->getBits1() || _ctx.frame_type == IVI4_FRAMETYPE_INTRA) {
transform_id = _ctx.gb->getBits(5);
if (transform_id >= FF_ARRAY_ELEMS(_transforms) ||
if ((uint)transform_id >= FF_ARRAY_ELEMS(_transforms) ||
!_transforms[transform_id].inv_trans) {
warning("Transform %d", transform_id);
return -3;
@ -372,7 +372,7 @@ int Indeo4Decoder::decode_band_hdr(IVIBandDesc *band) {
warning("Custom quant matrix encountered!");
return -1;
}
if (quant_mat >= FF_ARRAY_ELEMS(_quant_index_to_tab)) {
if ((uint)quant_mat >= FF_ARRAY_ELEMS(_quant_index_to_tab)) {
warning("Quantization matrix %d", quant_mat);
return -1;
}
@ -523,8 +523,7 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
mb->q_delta = 0;
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
}
else if (mb->cbp || (!band->plane && !band->band_num &&
} else if (mb->cbp || (!band->plane && !band->band_num &&
_ctx.in_q)) {
mb->q_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,
IVI_VLC_BITS, 1);
@ -535,16 +534,16 @@ int Indeo4Decoder::decode_mb_info(IVIBandDesc *band, IVITile *tile) {
mb->mv_x = mb->mv_y = 0; // there is no motion vector in intra-macroblocks
} else {
if (band->inherit_mv) {
if (ref_mb)
if (ref_mb) {
// motion vector inheritance
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
}
else {
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
}
}
} else {
// decode motion vector deltas
mv_delta = _ctx.gb->getVLC2(_ctx.mb_vlc.tab->_table,