Commit 31d8d61f authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'aec50f79'

* commit 'aec50f79':
  rawdec: use AVPALETTE_SIZE instead of magic constants.
  mimic: remove a pointless cast.
  mdec: return meaningful error codes.

Conflicts:
	libavcodec/rawdec.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents f02033b9 aec50f79
...@@ -68,7 +68,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) ...@@ -68,7 +68,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
component = (n <= 3 ? 0 : n - 4 + 1); component = (n <= 3 ? 0 : n - 4 + 1);
diff = decode_dc(&a->gb, component); diff = decode_dc(&a->gb, component);
if (diff >= 0xffff) if (diff >= 0xffff)
return -1; return AVERROR_INVALIDDATA;
a->last_dc[component] += diff; a->last_dc[component] += diff;
block[0] = a->last_dc[component] << 3; block[0] = a->last_dc[component] << 3;
} }
...@@ -108,7 +108,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) ...@@ -108,7 +108,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
} }
if (i > 63) { if (i > 63) {
av_log(a->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y); av_log(a->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", a->mb_x, a->mb_y);
return -1; return AVERROR_INVALIDDATA;
} }
block[j] = level; block[j] = level;
...@@ -121,15 +121,17 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n) ...@@ -121,15 +121,17 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
static inline int decode_mb(MDECContext *a, int16_t block[6][64]) static inline int decode_mb(MDECContext *a, int16_t block[6][64])
{ {
int i; int i, ret;
const int block_index[6] = { 5, 4, 0, 1, 2, 3 }; const int block_index[6] = { 5, 4, 0, 1, 2, 3 };
a->dsp.clear_blocks(block[0]); a->dsp.clear_blocks(block[0]);
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (mdec_decode_block_intra(a, block[block_index[i]], block_index[i]) < 0 || if ((ret = mdec_decode_block_intra(a, block[block_index[i]],
get_bits_left(&a->gb) < 0) block_index[i])) < 0)
return -1; return ret;
if (get_bits_left(&a->gb) < 0)
return AVERROR_INVALIDDATA;
} }
return 0; return 0;
} }
...@@ -163,15 +165,15 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -163,15 +165,15 @@ static int decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size; int buf_size = avpkt->size;
AVFrame *picture = data; AVFrame *picture = data;
AVFrame * const p = &a->picture; AVFrame * const p = &a->picture;
int i; int i, ret;
if (p->data[0]) if (p->data[0])
ff_thread_release_buffer(avctx, p); ff_thread_release_buffer(avctx, p);
p->reference = 0; p->reference = 0;
if (ff_thread_get_buffer(avctx, p) < 0) { if ((ret = ff_thread_get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1; return ret;
} }
p->pict_type = AV_PICTURE_TYPE_I; p->pict_type = AV_PICTURE_TYPE_I;
p->key_frame = 1; p->key_frame = 1;
...@@ -195,8 +197,8 @@ static int decode_frame(AVCodecContext *avctx, ...@@ -195,8 +197,8 @@ static int decode_frame(AVCodecContext *avctx,
for (a->mb_x = 0; a->mb_x < a->mb_width; a->mb_x++) { for (a->mb_x = 0; a->mb_x < a->mb_width; a->mb_x++) {
for (a->mb_y = 0; a->mb_y < a->mb_height; a->mb_y++) { for (a->mb_y = 0; a->mb_y < a->mb_height; a->mb_y++) {
if (decode_mb(a, a->block) < 0) if ((ret = decode_mb(a, a->block)) < 0)
return -1; return ret;
idct_put(a, a->mb_x, a->mb_y); idct_put(a, a->mb_x, a->mb_y);
} }
......
...@@ -297,7 +297,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs, ...@@ -297,7 +297,7 @@ static int decode(MimicContext *ctx, int quality, int num_coeffs,
* Flip the buffer upside-down and put it in the YVU order to match the * Flip the buffer upside-down and put it in the YVU order to match the
* way Mimic encodes frames. * way Mimic encodes frames.
*/ */
static void prepare_avpic(MimicContext *ctx, AVPicture *dst, AVPicture *src) static void prepare_avpic(MimicContext *ctx, AVPicture *dst, AVFrame *src)
{ {
int i; int i;
dst->data[0] = src->data[0] + ( ctx->avctx->height - 1) * src->linesize[0]; dst->data[0] = src->data[0] + ( ctx->avctx->height - 1) * src->linesize[0];
...@@ -374,7 +374,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data, ...@@ -374,7 +374,7 @@ static int mimic_decode_frame(AVCodecContext *avctx, void *data,
ctx->next_cur_index = (ctx->cur_index - 1) & 15; ctx->next_cur_index = (ctx->cur_index - 1) & 15;
prepare_avpic(ctx, &ctx->flipped_ptrs[ctx->cur_index], prepare_avpic(ctx, &ctx->flipped_ptrs[ctx->cur_index],
(AVPicture*) &ctx->buf_ptrs[ctx->cur_index]); &ctx->buf_ptrs[ctx->cur_index]);
ff_thread_finish_setup(avctx); ff_thread_finish_setup(avctx);
......
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