+ return ret;
+ }
+ ff_blockdsp_init(&ctx->bdsp, avctx);
+ ff_bswapdsp_init(&ctx->bbdsp);
+ ff_hpeldsp_init(&ctx->hdsp, avctx->flags);
+ ff_idctdsp_init(&ctx->idsp, avctx);
+ ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable, col_zag);
+
+ for (i = 0; i < FF_ARRAY_ELEMS(ctx->frames); i++) {
+ ctx->frames[i].f = av_frame_alloc();
+ if (!ctx->frames[i].f) {
+ mimic_decode_end(avctx);
+ return AVERROR(ENOMEM);
+ }
+ }
+
+ return 0;
+}
+
+static int mimic_decode_update_thread_context(AVCodecContext *avctx, const AVCodecContext *avctx_from)
+{
+ MimicContext *dst = avctx->priv_data, *src = avctx_from->priv_data;
+ int i, ret;
+
+ if (avctx == avctx_from)
+ return 0;
+
+ dst->cur_index = src->next_cur_index;
+ dst->prev_index = src->next_prev_index;
+
+ for (i = 0; i < FF_ARRAY_ELEMS(dst->frames); i++) {
+ ff_thread_release_buffer(avctx, &dst->frames[i]);
+ if (src->frames[i].f->data[0]) {
+ ret = ff_thread_ref_frame(&dst->frames[i], &src->frames[i]);
+ if (ret < 0)
+ return ret;
+ }