- avctx->pix_fmt = PIX_FMT_PAL8;
- dsputil_init(&s->dsp, avctx);
+
+ if (!avctx->width || !avctx->height ||
+ (avctx->width & 7) || (avctx->height & 7)) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid video dimensions: %dx%d\n",
+ avctx->width, avctx->height);
+ return AVERROR(EINVAL);
+ }
+
+ s->frame = av_frame_alloc();
+ if (!s->frame)
+ return AVERROR(ENOMEM);
+
+ avctx->pix_fmt = AV_PIX_FMT_PAL8;
+ ff_blockdsp_init(&s->bdsp);