Merge commit 'aa943bd31fada23db5cb9611215656ab9ebe5b94' into release/2.2
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 11 Aug 2014 16:02:19 +0000 (18:02 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 11 Aug 2014 16:02:36 +0000 (18:02 +0200)
* commit 'aa943bd31fada23db5cb9611215656ab9ebe5b94':
  huffyuvdec: check width size for yuv422p

Conflicts:
libavcodec/huffyuvdec.c

See: 6abb9a901fca27da14d4fffbb01948288b5da3ba
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/huffyuvdec.c

@@@ -346,188 -316,38 +346,191 @@@ static av_cold int decode_init(AVCodecC
              return ret;
      }
  
 -    switch (s->bitstream_bpp) {
 -    case 12:
 -        avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 -        break;
 -    case 16:
 -        if (s->yuy2) {
 -            avctx->pix_fmt = AV_PIX_FMT_YUYV422;
 -        } else {
 -            avctx->pix_fmt = AV_PIX_FMT_YUV422P;
 -        }
 -        break;
 -    case 24:
 -    case 32:
 -        if (s->bgr32) {
 +    if (s->version <= 2) {
 +        switch (s->bitstream_bpp) {
 +        case 12:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 +            s->yuv = 1;
 +            break;
 +        case 16:
 +            if (s->yuy2) {
 +                avctx->pix_fmt = AV_PIX_FMT_YUYV422;
 +            } else {
 +                avctx->pix_fmt = AV_PIX_FMT_YUV422P;
 +            }
 +            s->yuv = 1;
 +            break;
 +        case 24:
 +            if (s->bgr32) {
 +                avctx->pix_fmt = AV_PIX_FMT_0RGB32;
 +            } else {
 +                avctx->pix_fmt = AV_PIX_FMT_BGR24;
 +            }
 +            break;
 +        case 32:
 +            av_assert0(s->bgr32);
              avctx->pix_fmt = AV_PIX_FMT_RGB32;
 -        } else {
 -            avctx->pix_fmt = AV_PIX_FMT_BGR24;
 +            s->alpha = 1;
 +            break;
 +        default:
 +            return AVERROR_INVALIDDATA;
 +        }
 +        av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
 +                                         &s->chroma_h_shift,
 +                                         &s->chroma_v_shift);
 +    } else {
 +        switch ( (s->chroma<<10) | (s->yuv<<9) | (s->alpha<<8) | ((s->bps-1)<<4) | s->chroma_h_shift | (s->chroma_v_shift<<2)) {
 +        case 0x070:
 +            avctx->pix_fmt = AV_PIX_FMT_GRAY8;
 +            break;
 +        case 0x0F0:
 +            avctx->pix_fmt = AV_PIX_FMT_GRAY16;
 +            break;
 +        case 0x170:
 +            avctx->pix_fmt = AV_PIX_FMT_GRAY8A;
 +            break;
 +        case 0x470:
 +            avctx->pix_fmt = AV_PIX_FMT_GBRP;
 +            break;
 +        case 0x480:
 +            avctx->pix_fmt = AV_PIX_FMT_GBRP9;
 +            break;
 +        case 0x490:
 +            avctx->pix_fmt = AV_PIX_FMT_GBRP10;
 +            break;
 +        case 0x4B0:
 +            avctx->pix_fmt = AV_PIX_FMT_GBRP12;
 +            break;
 +        case 0x4D0:
 +            avctx->pix_fmt = AV_PIX_FMT_GBRP14;
 +            break;
 +        case 0x4F0:
 +            avctx->pix_fmt = AV_PIX_FMT_GBRP16;
 +            break;
 +        case 0x570:
 +            avctx->pix_fmt = AV_PIX_FMT_GBRAP;
 +            break;
 +        case 0x670:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV444P;
 +            break;
 +        case 0x680:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV444P9;
 +            break;
 +        case 0x690:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV444P10;
 +            break;
 +        case 0x6B0:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV444P12;
 +            break;
 +        case 0x6D0:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV444P14;
 +            break;
 +        case 0x6F0:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV444P16;
 +            break;
 +        case 0x671:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV422P;
 +            break;
 +        case 0x681:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV422P9;
 +            break;
 +        case 0x691:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV422P10;
 +            break;
 +        case 0x6B1:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV422P12;
 +            break;
 +        case 0x6D1:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV422P14;
 +            break;
 +        case 0x6F1:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV422P16;
 +            break;
 +        case 0x672:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV411P;
 +            break;
 +        case 0x674:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV440P;
 +            break;
 +        case 0x675:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV420P;
 +            break;
 +        case 0x685:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV420P9;
 +            break;
 +        case 0x695:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV420P10;
 +            break;
 +        case 0x6B5:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV420P12;
 +            break;
 +        case 0x6D5:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV420P14;
 +            break;
 +        case 0x6F5:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV420P16;
 +            break;
 +        case 0x67A:
 +            avctx->pix_fmt = AV_PIX_FMT_YUV410P;
 +            break;
 +        case 0x770:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
 +            break;
 +        case 0x780:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA444P9;
 +            break;
 +        case 0x790:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA444P10;
 +            break;
 +        case 0x7F0:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA444P16;
 +            break;
 +        case 0x771:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA422P;
 +            break;
 +        case 0x781:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA422P9;
 +            break;
 +        case 0x791:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA422P10;
 +            break;
 +        case 0x7F1:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA422P16;
 +            break;
 +        case 0x775:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA420P;
 +            break;
 +        case 0x785:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA420P9;
 +            break;
 +        case 0x795:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA420P10;
 +            break;
 +        case 0x7F5:
 +            avctx->pix_fmt = AV_PIX_FMT_YUVA420P16;
 +            break;
 +        default:
 +            return AVERROR_INVALIDDATA;
          }
 -        break;
 -    default:
 -        return AVERROR_INVALIDDATA;
      }
  
-     if (s->predictor == MEDIAN && avctx->pix_fmt == AV_PIX_FMT_YUV422P && avctx->width%4) {
-         av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 4 this colorspace and predictor\n");
 +    ff_huffyuv_common_init(avctx);
 +
 +    if ((avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUV420P) && avctx->width & 1) {
 +        av_log(avctx, AV_LOG_ERROR, "width must be even for this colorspace\n");
 +        return AVERROR_INVALIDDATA;
 +    }
 -        av_log(avctx, AV_LOG_ERROR, "width must be multiple of 4 "
+     if (s->predictor == MEDIAN && avctx->pix_fmt == AV_PIX_FMT_YUV422P &&
+         avctx->width % 4) {
++        av_log(avctx, AV_LOG_ERROR, "width must be a multiple of 4 "
+                "for this combination of colorspace and predictor type.\n");
          return AVERROR_INVALIDDATA;
      }
 -    if ((ret = ff_huffyuv_alloc_temp(s)) < 0)
 +    if ((ret = ff_huffyuv_alloc_temp(s)) < 0) {
 +        ff_huffyuv_common_end(s);
          return ret;
 +    }
  
      return 0;
  }