}
if(a->is_mjpeg) {
- AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
+ const AVCodec *codec = avcodec_find_decoder(AV_CODEC_ID_MJPEG);
AVDictionary *thread_opt = NULL;
if (!codec) {
av_log(avctx, AV_LOG_ERROR, "MJPEG codec not found\n");
}
a->mjpeg_avctx = avcodec_alloc_context3(codec);
+ if (!a->mjpeg_avctx)
+ return AVERROR(ENOMEM);
av_dict_set(&thread_opt, "threads", "1", 0); // Is this needed ?
a->mjpeg_avctx->refcounted_frames = 1;
{
AVRnContext *a = avctx->priv_data;
- avcodec_close(a->mjpeg_avctx);
- av_freep(&a->mjpeg_avctx);
+ avcodec_free_context(&a->mjpeg_avctx);
return 0;
}
.close = end,
.decode = decode_frame,
.max_lowres = 3,
- .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
};