xxan: properly handle odd heights.

Duplicate the last one or two chroma lines.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
CC:libav-stable@libav.org
pull/9/head
Kostya Shishkov 12 years ago committed by Anton Khirnov
parent 2cd4068071
commit 685e6f2e39
  1. 15
      libavcodec/xxan.c
  2. 42
      tests/ref/fate/xxan-wc4

@ -45,6 +45,11 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
if (avctx->height < 8) {
av_log(avctx, AV_LOG_ERROR, "Invalid frame height: %d.\n", avctx->height);
return AVERROR(EINVAL);
}
s->buffer_size = avctx->width * avctx->height;
s->y_buffer = av_malloc(s->buffer_size);
if (!s->y_buffer)
@ -210,6 +215,10 @@ static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
U += s->pic.linesize[1];
V += s->pic.linesize[2];
}
if (avctx->height & 1) {
memcpy(U, U - s->pic.linesize[1], avctx->width >> 1);
memcpy(V, V - s->pic.linesize[2], avctx->width >> 1);
}
} else {
uint8_t *U2 = U + s->pic.linesize[1];
uint8_t *V2 = V + s->pic.linesize[2];
@ -230,6 +239,12 @@ static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off)
U2 += s->pic.linesize[1] * 2;
V2 += s->pic.linesize[2] * 2;
}
if (avctx->height & 3) {
int lines = ((avctx->height + 1) >> 1) - (avctx->height >> 2) * 2;
memcpy(U, U - lines * s->pic.linesize[1], lines * s->pic.linesize[1]);
memcpy(V, V - lines * s->pic.linesize[2], lines * s->pic.linesize[2]);
}
}
return 0;

@ -1,22 +1,22 @@
#tb 0: 1/15
0, 0, 0, 1, 79360, 0x3b0a7d1b
0, 1, 1, 1, 79360, 0x740842c3
0, 2, 2, 1, 79360, 0x85160167
0, 3, 3, 1, 79360, 0xaf510e92
0, 4, 4, 1, 79360, 0x8e290bec
0, 5, 5, 1, 79360, 0x51e981b0
0, 6, 6, 1, 79360, 0x16e52c60
0, 7, 7, 1, 79360, 0x66e1e60a
0, 8, 8, 1, 79360, 0x40fa58f6
0, 9, 9, 1, 79360, 0x00388edd
0, 10, 10, 1, 79360, 0xc74f95bf
0, 11, 11, 1, 79360, 0xf446a3fd
0, 12, 12, 1, 79360, 0x27b5eb60
0, 13, 13, 1, 79360, 0xea9266a2
0, 14, 14, 1, 79360, 0x7b6a7907
0, 15, 15, 1, 79360, 0x2be7d946
0, 16, 16, 1, 79360, 0x61881ee4
0, 17, 17, 1, 79360, 0x9214bd4f
0, 18, 18, 1, 79360, 0xeb294afe
0, 19, 19, 1, 79360, 0xc861ad55
0, 20, 20, 1, 79360, 0x3d3b6220
0, 0, 0, 1, 79360, 0x8537821b
0, 1, 1, 1, 79360, 0x110c4343
0, 2, 2, 1, 79360, 0xa85105bb
0, 3, 3, 1, 79360, 0x87431836
0, 4, 4, 1, 79360, 0x5c701720
0, 5, 5, 1, 79360, 0x20308ce4
0, 6, 6, 1, 79360, 0xe51d3794
0, 7, 7, 1, 79360, 0x80e6f1e0
0, 8, 8, 1, 79360, 0x5aff64cc
0, 9, 9, 1, 79360, 0x1a3d9ab3
0, 10, 10, 1, 79360, 0xe154a195
0, 11, 11, 1, 79360, 0x608dafdc
0, 12, 12, 1, 79360, 0x93edf73f
0, 13, 13, 1, 79360, 0x56d97281
0, 14, 14, 1, 79360, 0xe7a284e6
0, 15, 15, 1, 79360, 0xd4e5e513
0, 16, 16, 1, 79360, 0x0a952ab1
0, 17, 17, 1, 79360, 0x3b21c91c
0, 18, 18, 1, 79360, 0x943656cb
0, 19, 19, 1, 79360, 0xffbdb94b
0, 20, 20, 1, 79360, 0x74976e16

Loading…
Cancel
Save