summaryrefslogtreecommitdiff
path: root/libavcodec/xxan.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2013-01-29 19:53:04 +0100
committerAnton Khirnov <anton@khirnov.net>2013-02-06 10:21:52 +0100
commit685e6f2e3939f124b41c7801cc541dad8252af3d (patch)
tree9d66df7e60c3303c8fccfabda5c12ffd17d56718 /libavcodec/xxan.c
parent2cd4068071b9a8908823a3107f97e938211045ce (diff)
downloadffmpeg-685e6f2e3939f124b41c7801cc541dad8252af3d.tar.gz
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
Diffstat (limited to 'libavcodec/xxan.c')
-rw-r--r--libavcodec/xxan.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c
index c28ba2f964..31f475512a 100644
--- a/libavcodec/xxan.c
+++ b/libavcodec/xxan.c
@@ -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;