diff options
author | Dirk Ausserhaus <dausserhaus@gmail.com> | 2014-06-08 13:44:17 +0200 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2014-06-26 19:17:33 +0200 |
commit | 5ec6d152e26c570c0a16ec72c1f354db95708179 (patch) | |
tree | 15bb4cb43131c00c87c2465e2e6e3d92ae74d730 /libavcodec/indeo4.c | |
parent | 422e14f721c22cf9c19a8e7aae051ba9d559f6b6 (diff) | |
download | ffmpeg-5ec6d152e26c570c0a16ec72c1f354db95708179.tar.gz |
indeo4: B-frames decoding
Signed-off-by: Kostya Shishkov <kostya.shishkov@gmail.com>
Diffstat (limited to 'libavcodec/indeo4.c')
-rw-r--r-- | libavcodec/indeo4.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c index 6893077346..35f266ee13 100644 --- a/libavcodec/indeo4.c +++ b/libavcodec/indeo4.c @@ -194,7 +194,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx) /* check if picture layout was changed and reallocate buffers */ if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) { - if (ff_ivi_init_planes(ctx->planes, &pic_conf)) { + if (ff_ivi_init_planes(ctx->planes, &pic_conf, 1)) { av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n"); ctx->pic_conf.luma_bands = 0; return AVERROR(ENOMEM); @@ -462,6 +462,8 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band, mb->xpos = x; mb->ypos = y; mb->buf_offs = mb_offset; + mb->b_mv_x = + mb->b_mv_y = 0; if (get_bits1(&ctx->gb)) { if (ctx->frame_type == IVI4_FRAMETYPE_INTRA) { @@ -537,6 +539,24 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band, mv_x += IVI_TOSIGNED(mv_delta); mb->mv_x = mv_x; mb->mv_y = mv_y; + if (mb->type == 3) { + mv_delta = get_vlc2(&ctx->gb, + ctx->mb_vlc.tab->table, + IVI_VLC_BITS, 1); + mv_y += IVI_TOSIGNED(mv_delta); + mv_delta = get_vlc2(&ctx->gb, + ctx->mb_vlc.tab->table, + IVI_VLC_BITS, 1); + mv_x += IVI_TOSIGNED(mv_delta); + mb->b_mv_x = -mv_x; + mb->b_mv_y = -mv_y; + } + } + if (mb->type == 2) { + mb->b_mv_x = -mb->mv_x; + mb->b_mv_y = -mb->mv_y; + mb->mv_x = 0; + mb->mv_y = 0; } } } @@ -563,32 +583,30 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band, */ static void switch_buffers(IVI45DecContext *ctx) { + int is_prev_ref = 0, is_ref = 0; + switch (ctx->prev_frame_type) { case IVI4_FRAMETYPE_INTRA: case IVI4_FRAMETYPE_INTRA1: case IVI4_FRAMETYPE_INTER: - ctx->buf_switch ^= 1; - ctx->dst_buf = ctx->buf_switch; - ctx->ref_buf = ctx->buf_switch ^ 1; - break; - case IVI4_FRAMETYPE_INTER_NOREF: + is_prev_ref = 1; break; } switch (ctx->frame_type) { case IVI4_FRAMETYPE_INTRA: case IVI4_FRAMETYPE_INTRA1: - ctx->buf_switch = 0; - /* FALLTHROUGH */ case IVI4_FRAMETYPE_INTER: - ctx->dst_buf = ctx->buf_switch; - ctx->ref_buf = ctx->buf_switch ^ 1; - break; - case IVI4_FRAMETYPE_INTER_NOREF: - case IVI4_FRAMETYPE_NULL_FIRST: - case IVI4_FRAMETYPE_NULL_LAST: + is_ref = 1; break; } + + if (is_prev_ref && is_ref) { + FFSWAP(int, ctx->dst_buf, ctx->ref_buf); + } else if (is_prev_ref) { + FFSWAP(int, ctx->ref_buf, ctx->b_ref_buf); + FFSWAP(int, ctx->dst_buf, ctx->ref_buf); + } } @@ -622,6 +640,9 @@ static av_cold int decode_init(AVCodecContext *avctx) ctx->is_indeo4 = 1; + ctx->dst_buf = 0; + ctx->ref_buf = 1; + ctx->b_ref_buf = 3; /* buffer 2 is used for scalability mode */ ctx->p_frame = av_frame_alloc(); if (!ctx->p_frame) return AVERROR(ENOMEM); |