Quoting Diego Biurrun (2017-03-24 16:10:04)
> From: Paul B Mahol <[email protected]>
> 
> Signed-off-by: Paul B Mahol <[email protected]>
> Signed-off-by: Diego Biurrun <[email protected]>
> ---
> 
> decode_type2() is, ummm, interesting ..
> 
>  Changelog               |   1 +
>  doc/general.texi        |   1 +
>  libavcodec/Makefile     |   1 +
>  libavcodec/allcodecs.c  |   1 +
>  libavcodec/avcodec.h    |   1 +
>  libavcodec/codec_desc.c |   7 +
>  libavcodec/fmvc.c       | 634 
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/version.h    |   2 +-
>  libavformat/riff.c      |   1 +
>  9 files changed, 648 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/fmvc.c
> diff --git a/libavcodec/fmvc.c b/libavcodec/fmvc.c
> +static av_cold int decode_init(AVCodecContext *avctx)
> +{
> +    FMVCContext *s = avctx->priv_data;
> +    int i, j, m, block = 0, h = BLOCK_HEIGHT, w = BLOCK_WIDTH;
> +
> +    switch (avctx->bits_per_coded_sample) {
> +    case 16:
> +        avctx->pix_fmt = AV_PIX_FMT_RGB555;
> +        break;
> +    case 24:
> +        avctx->pix_fmt = AV_PIX_FMT_BGR24;
> +        break;
> +    case 32:
> +        avctx->pix_fmt = AV_PIX_FMT_BGRA;
> +        break;
> +    default:
> +        av_log(avctx, AV_LOG_ERROR, "Unsupported bitdepth %i\n",
> +               avctx->bits_per_coded_sample);
> +        return AVERROR_INVALIDDATA;
> +    }
> +
> +    s->stride = (avctx->width * avctx->bits_per_coded_sample + 31) / 32;
> +    s->xb     = s->stride / BLOCK_WIDTH;
> +    m         = s->stride % BLOCK_WIDTH;
> +    if (m) {
> +        if (m < 37) {
> +            w = m + BLOCK_WIDTH;
> +        } else {
> +            w = m;
> +            s->xb++;
> +        }
> +    }
> +
> +    s->yb = avctx->height / BLOCK_HEIGHT;
> +    m     = avctx->height % BLOCK_HEIGHT;
> +    if (m) {
> +        if (m < 49) {
> +            h = m + BLOCK_HEIGHT;
> +        } else {
> +            h = m;
> +            s->yb++;
> +        }
> +    }
> +
> +    s->nb_blocks = s->xb * s->yb;

At this point nothing guarantees that nb_blocks is non-zero (if
avctx->width/height are unset or too small), so that needs to be
checked.


-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to