- if (buf_size < avctx->width * avctx->height * 4) {
- av_log(avctx, AV_LOG_ERROR, "Out buffer is too small.\n");
- return AVERROR(ENOMEM);
+ if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * 4)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
+ return ret;