- // Support "Resolution 1:1" for Avid AVI Codec
- a->is_mjpeg = avctx->extradata_size < 31 || memcmp(&avctx->extradata[28], "1:1", 3);
-
- if(!a->is_mjpeg && avctx->lowres) {
- av_log(avctx, AV_LOG_ERROR, "lowres is not possible with rawvideo\n");
- return AVERROR(EINVAL);
- }
-
- if(a->is_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");
- return AVERROR_DECODER_NOT_FOUND;
- }
-
- 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;
- a->mjpeg_avctx->flags = avctx->flags;
- a->mjpeg_avctx->idct_algo = avctx->idct_algo;
- a->mjpeg_avctx->lowres = avctx->lowres;
- a->mjpeg_avctx->width = avctx->width;
- a->mjpeg_avctx->height = avctx->height;
-
- if ((ret = avcodec_open2(a->mjpeg_avctx, codec, &thread_opt)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "MJPEG codec failed to open\n");
- }
- av_dict_free(&thread_opt);
-
- return ret;
- }
-