aboutsummaryrefslogtreecommitdiff
path: root/libavcodec/huffyuv.c
diff options
context:
space:
mode:
authorPaul B Mahol2012-03-23 01:16:19 +0000
committerMichael Niedermayer2012-03-23 03:09:07 +0100
commit3a085c6a37ad381a58eb30486beda44386058327 (patch)
tree4f493f12e072185eadc6eb8ef6bc63c3be8a75e6 /libavcodec/huffyuv.c
parentba02069a8e22985a9a775dac9ece6dc54a7e8b44 (diff)
huffyuv: do not decode/encode yuv colorspace with odd width
Signed-off-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/huffyuv.c')
-rw-r--r--libavcodec/huffyuv.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 7082ed8276..c1b9715c20 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -551,6 +551,11 @@ s->bgr32=1;
return AVERROR_INVALIDDATA;
}
+ if ((avctx->pix_fmt == PIX_FMT_YUV422P || avctx->pix_fmt == PIX_FMT_YUV420P) && avctx->width & 1) {
+ av_log(avctx, AV_LOG_ERROR, "width must be even for this colorspace\n");
+ return AVERROR_INVALIDDATA;
+ }
+
alloc_temp(s);
// av_log(NULL, AV_LOG_DEBUG, "pred:%d bpp:%d hbpp:%d il:%d\n", s->predictor, s->bitstream_bpp, avctx->bits_per_coded_sample, s->interlaced);
@@ -620,10 +625,12 @@ static av_cold int encode_init(AVCodecContext *avctx)
switch(avctx->pix_fmt){
case PIX_FMT_YUV420P:
- s->bitstream_bpp= 12;
- break;
case PIX_FMT_YUV422P:
- s->bitstream_bpp= 16;
+ if (s->width & 1) {
+ av_log(avctx, AV_LOG_ERROR, "width must be even for this colorspace\n");
+ return AVERROR(EINVAL);
+ }
+ s->bitstream_bpp = avctx->pix_fmt == PIX_FMT_YUV420P ? 12 : 16;
break;
case PIX_FMT_RGB32:
s->bitstream_bpp= 32;