- s->last_frame = &s->frames[0];
- s->current_frame = &s->frames[1];
- avctx->pix_fmt = PIX_FMT_YUV444P;
+
+ s->last_frame = av_frame_alloc();
+ s->current_frame = av_frame_alloc();
+ if (!s->current_frame || !s->last_frame) {
+ av_frame_free(&s->current_frame);
+ av_frame_free(&s->last_frame);
+ return AVERROR(ENOMEM);
+ }
+
+ avctx->pix_fmt = AV_PIX_FMT_YUV444P;