[FFmpeg-devel] Fwd: [PATCH] Psygnosis YOP demuxer

Stefano Sabatini stefano.sabatini-lala
Sat Mar 27 15:05:34 CET 2010


On date Saturday 2010-03-27 07:39:14 +0530, Mohamed Naufal encoded:
[...]
> +static av_cold int yop_decode_init(AVCodecContext *avctx)
> +{
> +    YopDecContext *s = avctx->priv_data;
> +    s->avctx = avctx;
> +
> +    if (avctx->width & 1 || avctx->height & 1 ||
> +        avcodec_check_dimensions(avctx, avctx->width, avctx->height)) {
> +        av_log(avctx, AV_LOG_ERROR, "YOP has invalid dimensions\n");
> +        return -1;
> +    }
> +
> +    avctx->pix_fmt = PIX_FMT_PAL8;
> +
> +    s->num_pal_colors      = AV_RL8(avctx->extradata);
> +    s->first_color[0]      = AV_RL8(avctx->extradata + 1);
> +    s->first_color[1]      = AV_RL8(avctx->extradata + 2);
> +
> +    if (s->num_pal_colors + s->first_color[0] > 256 ||
> +        s->num_pal_colors + s->first_color[1] > 256) {
> +        av_log(avctx, AV_LOG_ERROR,
> +               "YOP: palette parameters invalid, header probably corrupt\n");
> +        return -1;

Now that we have saner error codes let's start to use them.

This could be AVERROR_INVALIDDATA.

[...]
> +static int yop_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
> +                            AVPacket *avpkt)
> +{
> +    YopDecContext *s = avctx->priv_data;
> +    int tag, firstcolor, is_odd_frame, i;
> +    uint32_t *palette;
> +    uint8_t const *dstbuf;
> +
> +    if (s->frame.data[0])
> +        avctx->release_buffer(avctx, &s->frame);
> +
> +    if (avctx->get_buffer(avctx, &s->frame) < 0) {
> +        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
> +        return -1;
> +    }

if ((ret = avctx->get_buffer(avctx, &s->frame) < 0) {
   ...
   return ret;
}

Regards.
-- 
FFmpeg = Faithful & Forgiving Multipurpose Pure Eretic Geisha



More information about the ffmpeg-devel mailing list