static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
- JpeglsContext *const s = avctx->priv_data;
- AVFrame *const p = &s->picture;
+ const AVFrame *const p = pict;
const int near = avctx->prediction_method;
PutBitContext pb, pb2;
GetBitContext gb;
int i, size, ret;
int comps;
- *p = *pict;
- p->pict_type = AV_PICTURE_TYPE_I;
- p->key_frame = 1;
-
if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY16)
comps = 1;
Rc[j] = last[j];
}
last = cur;
- cur += s->picture.linesize[0];
+ cur += p->linesize[0];
}
} else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
int j, width;
Rc[j] = last[j];
}
last = cur;
- cur += s->picture.linesize[0];
+ cur += p->linesize[0];
}
}
return 0;
}
+static av_cold int encode_close(AVCodecContext *avctx)
+{
+ av_frame_free(&avctx->coded_frame);
+ return 0;
+}
+
static av_cold int encode_init_ls(AVCodecContext *ctx)
{
- JpeglsContext *c = (JpeglsContext *)ctx->priv_data;
+ ctx->coded_frame = av_frame_alloc();
+ if (!ctx->coded_frame)
+ return AVERROR(ENOMEM);
- c->avctx = ctx;
- ctx->coded_frame = &c->picture;
+ ctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+ ctx->coded_frame->key_frame = 1;
if (ctx->pix_fmt != AV_PIX_FMT_GRAY8 &&
ctx->pix_fmt != AV_PIX_FMT_GRAY16 &&
.long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_JPEGLS,
- .priv_data_size = sizeof(JpeglsContext),
.init = encode_init_ls,
+ .close = encode_close,
.encode2 = encode_picture_ls,
.pix_fmts = (const enum AVPixelFormat[]) {
AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24,