aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/indeo4.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-06-27 01:31:42 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-06-27 02:05:22 +0200
commit357168bcf63429e9472fb9fff1e1301f9514dca6 (patch)
tree04b94fe1d99e435cbe63d1b2ef06a728121f21e5 /libavcodec/indeo4.c
parent826726b83fab660e45166bca476c4e91713c62aa (diff)
parent5ec6d152e26c570c0a16ec72c1f354db95708179 (diff)
downloadffmpeg-357168bcf63429e9472fb9fff1e1301f9514dca6.tar.gz
Merge commit '5ec6d152e26c570c0a16ec72c1f354db95708179'
* commit '5ec6d152e26c570c0a16ec72c1f354db95708179': indeo4: B-frames decoding Conflicts: libavcodec/ivi_common.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/indeo4.c')
-rw-r--r--libavcodec/indeo4.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c
index 7adfcbc9ca..ed4272bbe6 100644
--- a/libavcodec/indeo4.c
+++ b/libavcodec/indeo4.c
@@ -195,7 +195,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);
@@ -494,6 +494,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) {
@@ -571,6 +573,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;
}
}
}
@@ -606,32 +626,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);
+ }
}
@@ -665,6 +683,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);