summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-02-06 15:26:24 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-02-06 15:26:32 +0100
commit68c0144d028bb65ea93651503b154a056246b03d (patch)
treec50a3f457c91490ea489cb652e1c3fd886b0280b /libavcodec
parenta845ac78c9428d6fd0f9f4f61a34ac816e3dedfa (diff)
parent685e6f2e3939f124b41c7801cc541dad8252af3d (diff)
Merge commit '685e6f2e3939f124b41c7801cc541dad8252af3d'
* commit '685e6f2e3939f124b41c7801cc541dad8252af3d': xxan: properly handle odd heights. Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/xxan.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c
index 3476dcca31..9168327caf 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)
@@ -212,6 +217,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];
@@ -236,6 +245,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;