#include "avcodec.h"
#include "h263.h"
+#include "internal.h"
#include "intrax8.h"
#include "mathops.h"
#include "mpegutils.h"
int code;
if (s->avctx->extradata_size < 4)
- return -1;
+ return AVERROR_INVALIDDATA;
init_get_bits(&gb, s->avctx->extradata, 32);
code = get_bits(&gb, 3);
if (code == 0)
- return -1;
+ return AVERROR_INVALIDDATA;
s->slice_height = s->mb_height / code;
}
s->chroma_qscale = s->qscale = get_bits(&s->gb, 5);
if (s->qscale <= 0)
- return -1;
+ return AVERROR_INVALIDDATA;
return 0;
}
s->picture_number++; // FIXME ?
if (w->j_type) {
- ff_intrax8_decode_picture(&w->x8, 2 * s->qscale, (s->qscale - 1) | 1);
+ ff_intrax8_decode_picture(&w->x8, &s->current_picture,
+ &s->gb, &s->mb_x, &s->mb_y,
+ 2 * s->qscale, (s->qscale - 1) | 1,
+ s->loop_filter, s->low_delay);
+
+ ff_er_add_slice(&w->s.er, 0, 0,
+ (w->s.mb_x >> 1) - 1, (w->s.mb_y >> 1) - 1,
+ ER_MB_END);
return 1;
}
ret = ff_msmpeg4_decode_motion(s, mx_ptr, my_ptr);
if (ret < 0)
- return -1;
+ return ret;
if ((((*mx_ptr) | (*my_ptr)) & 1) && s->mspel)
w->hshift = get_bits1(&s->gb);
{
MpegEncContext *const s = &w->s;
static const int sub_cbp_table[3] = { 2, 3, 1 };
- int sub_cbp;
+ int sub_cbp, ret;
if (!cbp) {
s->block_last_index[n] = -1;
sub_cbp = sub_cbp_table[decode012(&s->gb)];
if (sub_cbp & 1)
- if (ff_msmpeg4_decode_block(s, block, n, 1, scantable) < 0)
- return -1;
+ if ((ret = ff_msmpeg4_decode_block(s, block, n, 1, scantable)) < 0)
+ return ret;
if (sub_cbp & 2)
- if (ff_msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable) < 0)
- return -1;
+ if ((ret = ff_msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable)) < 0)
+ return ret;
s->block_last_index[n] = 63;
int ff_wmv2_decode_mb(MpegEncContext *s, int16_t block[6][64])
{
Wmv2Context *const w = (Wmv2Context *) s;
- int cbp, code, i;
+ int cbp, code, i, ret;
uint8_t *coded_val;
if (w->j_type)
code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[w->cbp_table_index].table,
MB_NON_INTRA_VLC_BITS, 3);
if (code < 0)
- return -1;
+ return AVERROR_INVALIDDATA;
s->mb_intra = (~code & 0x40) >> 6;
cbp = code & 0x3f;
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"II-cbp illegal at %d %d\n", s->mb_x, s->mb_y);
- return -1;
+ return AVERROR_INVALIDDATA;
}
/* predict coded block pattern */
cbp = 0;
w->per_block_abt = 0;
}
- if (wmv2_decode_motion(w, &mx, &my) < 0)
- return -1;
+ if ((ret = wmv2_decode_motion(w, &mx, &my)) < 0)
+ return ret;
s->mv_dir = MV_DIR_FORWARD;
s->mv_type = MV_TYPE_16X16;
s->mv[0][0][1] = my;
for (i = 0; i < 6; i++) {
- if (wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1) < 0) {
+ if ((ret = wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1)) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"\nerror while decoding inter block: %d x %d (%d)\n",
s->mb_x, s->mb_y, i);
- return -1;
+ return ret;
}
}
} else {
if (s->pict_type == AV_PICTURE_TYPE_P)
- av_dlog(s->avctx, "%d%d ", s->inter_intra_pred, cbp);
- av_dlog(s->avctx, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
+ ff_dlog(s->avctx, "%d%d ", s->inter_intra_pred, cbp);
+ ff_dlog(s->avctx, "I at %d %d %d %06X\n", s->mb_x, s->mb_y,
((cbp & 3) ? 1 : 0) + ((cbp & 0x3C) ? 2 : 0),
show_bits(&s->gb, 24));
s->ac_pred = get_bits1(&s->gb);
if (s->inter_intra_pred) {
s->h263_aic_dir = get_vlc2(&s->gb, ff_inter_intra_vlc.table,
INTER_INTRA_VLC_BITS, 1);
- av_dlog(s->avctx, "%d%d %d %d/",
+ ff_dlog(s->avctx, "%d%d %d %d/",
s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y);
}
if (s->per_mb_rl_table && cbp) {
s->bdsp.clear_blocks(s->block[0]);
for (i = 0; i < 6; i++) {
- if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) {
+ if ((ret = ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL)) < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"\nerror while decoding intra block: %d x %d (%d)\n",
s->mb_x, s->mb_y, i);
- return -1;
+ return ret;
}
}
}
static av_cold int wmv2_decode_init(AVCodecContext *avctx)
{
Wmv2Context *const w = avctx->priv_data;
+ int ret;
- if (ff_msmpeg4_decode_init(avctx) < 0)
- return -1;
+ if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
+ return ret;
ff_wmv2_common_init(w);
- ff_intrax8_common_init(&w->x8, &w->s);
-
- return 0;
+ return ff_intrax8_common_init(avctx, &w->x8, &w->s.idsp,
+ w->s.block, w->s.block_last_index,
+ w->s.mb_width, w->s.mb_height);
}
static av_cold int wmv2_decode_end(AVCodecContext *avctx)
.init = wmv2_decode_init,
.close = wmv2_decode_end,
.decode = ff_h263_decode_frame,
- .capabilities = CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
+ .capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE },
};