diff options
Diffstat (limited to 'contrib/ffmpeg/libavcodec/imc.c')
-rw-r--r-- | contrib/ffmpeg/libavcodec/imc.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/contrib/ffmpeg/libavcodec/imc.c b/contrib/ffmpeg/libavcodec/imc.c index 6140130b1..237ff6816 100644 --- a/contrib/ffmpeg/libavcodec/imc.c +++ b/contrib/ffmpeg/libavcodec/imc.c @@ -19,7 +19,6 @@ * You should have received a copy of the GNU Lesser General Public * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * */ /** @@ -42,6 +41,7 @@ #include "imcdata.h" +#define IMC_BLOCK_SIZE 64 #define IMC_FRAME_ID 0x21 #define BANDS 32 #define COEFFS 256 @@ -455,7 +455,7 @@ static void imc_get_skip_coeff(IMCContext* q) { q->skipFlagBits[i] = band_tab[i+1] - band_tab[i]; for(j = band_tab[i]; j < band_tab[i+1]; j++) { - if ((q->skipFlags[j] = get_bits(&q->gb,1))) + if ((q->skipFlags[j] = get_bits1(&q->gb))) q->skipFlagCount[i]++; } } else { @@ -486,7 +486,7 @@ static void imc_get_skip_coeff(IMCContext* q) { if (j < band_tab[i+1]) { q->skipFlagBits[i]++; - if ((q->skipFlags[j] = get_bits(&q->gb,1))) + if ((q->skipFlags[j] = get_bits1(&q->gb))) q->skipFlagCount[i]++; } } @@ -626,7 +626,7 @@ static int imc_get_coeffs (IMCContext* q) { static int imc_decode_frame(AVCodecContext * avctx, void *data, int *data_size, - uint8_t * buf, int buf_size) + const uint8_t * buf, int buf_size) { IMCContext *q = avctx->priv_data; @@ -636,13 +636,16 @@ static int imc_decode_frame(AVCodecContext * avctx, int flag; int bits, summer; int counter, bitscount; - uint16_t *buf16 = (uint16_t *) buf; + uint16_t buf16[IMC_BLOCK_SIZE / 2]; - /* FIXME: input should not be modified */ - for(i = 0; i < FFMIN(buf_size, avctx->block_align) / 2; i++) - buf16[i] = bswap_16(buf16[i]); + if (buf_size < IMC_BLOCK_SIZE) { + av_log(avctx, AV_LOG_ERROR, "imc frame too small!\n"); + return -1; + } + for(i = 0; i < IMC_BLOCK_SIZE / 2; i++) + buf16[i] = bswap_16(((const uint16_t*)buf)[i]); - init_get_bits(&q->gb, buf, 512); + init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); /* Check the frame header */ imc_hdr = get_bits(&q->gb, 9); @@ -789,7 +792,7 @@ static int imc_decode_frame(AVCodecContext * avctx, *data_size = COEFFS * sizeof(int16_t); - return avctx->block_align; + return IMC_BLOCK_SIZE; } |