aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-04-24 13:16:27 +0200
committerMartin Storsjö <martin@martin.st>2013-05-28 13:55:46 +0300
commit93b1281264b87961f53c3e9c134cc2727ecd91ed (patch)
tree166eb567b498ce5f3d59077ac5ab7bf9298e54b3 /libavcodec
parent851bc1d6be0c7485609e0208d188f3edbc4ade13 (diff)
downloadffmpeg-93b1281264b87961f53c3e9c134cc2727ecd91ed.tar.gz
vc1dec: Shuffle field MVs after decoding, not before
This simplifies the code since copying MVs to the reference is not needed anymore (and maybe something about fixing artifacts). Also remove the unused mv_f_last. Fixes a small number of artifacts in black_screen_VC-1.mkv and several more artifacts in other videos. Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/vc1.h1
-rw-r--r--libavcodec/vc1dec.c21
2 files changed, 4 insertions, 18 deletions
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 88980d49a6..9d7743a9fd 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -354,7 +354,6 @@ typedef struct VC1Context{
int8_t zzi_8x8[64];
uint8_t *blk_mv_type_base, *blk_mv_type; ///< 0: frame MV, 1: field MV (interlaced frame)
uint8_t *mv_f_base, *mv_f[2]; ///< 0: MV obtained from same field, 1: opposite field
- uint8_t *mv_f_last_base, *mv_f_last[2];
uint8_t *mv_f_next_base, *mv_f_next[2];
int field_mode; ///< 1 for interlaced field pictures
int fptype;
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index a1c9890ead..12e6a99e5d 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -5419,9 +5419,6 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
v->mv_f_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
v->mv_f[0] = v->mv_f_base + s->b8_stride + 1;
v->mv_f[1] = v->mv_f[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
- v->mv_f_last_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
- v->mv_f_last[0] = v->mv_f_last_base + s->b8_stride + 1;
- v->mv_f_last[1] = v->mv_f_last[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
v->mv_f_next_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1;
v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2);
@@ -5619,7 +5616,6 @@ av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
av_freep(&v->mb_type_base);
av_freep(&v->blk_mv_type_base);
av_freep(&v->mv_f_base);
- av_freep(&v->mv_f_last_base);
av_freep(&v->mv_f_next_base);
av_freep(&v->block);
av_freep(&v->cbp_base);
@@ -5889,20 +5885,11 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
v->bits = buf_size * 8;
v->end_mb_x = s->mb_width;
if (v->field_mode) {
- uint8_t *tmp[2];
s->current_picture.f.linesize[0] <<= 1;
s->current_picture.f.linesize[1] <<= 1;
s->current_picture.f.linesize[2] <<= 1;
s->linesize <<= 1;
s->uvlinesize <<= 1;
- tmp[0] = v->mv_f_last[0];
- tmp[1] = v->mv_f_last[1];
- v->mv_f_last[0] = v->mv_f_next[0];
- v->mv_f_last[1] = v->mv_f_next[1];
- v->mv_f_next[0] = v->mv_f[0];
- v->mv_f_next[1] = v->mv_f[1];
- v->mv_f[0] = tmp[0];
- v->mv_f[1] = tmp[1];
}
mb_height = s->mb_height >> v->field_mode;
for (i = 0; i <= n_slices; i++) {
@@ -5947,15 +5934,15 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data,
}
if (v->field_mode) {
v->second_field = 0;
- if (s->pict_type == AV_PICTURE_TYPE_B) {
- memcpy(v->mv_f_base, v->mv_f_next_base,
- 2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2));
- }
s->current_picture.f.linesize[0] >>= 1;
s->current_picture.f.linesize[1] >>= 1;
s->current_picture.f.linesize[2] >>= 1;
s->linesize >>= 1;
s->uvlinesize >>= 1;
+ if (v->s.pict_type != AV_PICTURE_TYPE_BI && v->s.pict_type != AV_PICTURE_TYPE_B) {
+ FFSWAP(uint8_t *, v->mv_f_next[0], v->mv_f[0]);
+ FFSWAP(uint8_t *, v->mv_f_next[1], v->mv_f[1]);
+ }
}
av_dlog(s->avctx, "Consumed %i/%i bits\n",
get_bits_count(&s->gb), s->gb.size_in_bits);