+int ff_rv34_decode_init_thread_copy(AVCodecContext *avctx)
+{
+ RV34DecContext *r = avctx->priv_data;
+
+ r->s.avctx = avctx;
+
+ if (avctx->internal->is_copy) {
+ r->cbp_chroma = av_malloc(r->s.mb_stride * r->s.mb_height *
+ sizeof(*r->cbp_chroma));
+ r->cbp_luma = av_malloc(r->s.mb_stride * r->s.mb_height *
+ sizeof(*r->cbp_luma));
+ r->deblock_coefs = av_malloc(r->s.mb_stride * r->s.mb_height *
+ sizeof(*r->deblock_coefs));
+ r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 *
+ sizeof(*r->intra_types_hist));
+ r->mb_type = av_malloc(r->s.mb_stride * r->s.mb_height *
+ sizeof(*r->mb_type));
+
+ if (!(r->cbp_chroma && r->cbp_luma && r->deblock_coefs &&
+ r->intra_types_hist && r->mb_type)) {
+ av_freep(&r->cbp_chroma);
+ av_freep(&r->cbp_luma);
+ av_freep(&r->deblock_coefs);
+ av_freep(&r->intra_types_hist);
+ av_freep(&r->mb_type);
+ r->intra_types = NULL;
+ return AVERROR(ENOMEM);
+ }
+
+ r->intra_types = r->intra_types_hist + r->intra_types_stride * 4;
+ r->tmp_b_block_base = NULL;
+
+ memset(r->mb_type, 0, r->s.mb_stride * r->s.mb_height *
+ sizeof(*r->mb_type));
+
+ MPV_common_init(&r->s);
+ }
+ return 0;
+}
+
+int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
+{
+ RV34DecContext *r = dst->priv_data, *r1 = src->priv_data;
+ MpegEncContext * const s = &r->s, * const s1 = &r1->s;
+ int err;
+
+ if (dst == src || !s1->context_initialized)
+ return 0;
+
+ if ((err = ff_mpeg_update_thread_context(dst, src)))
+ return err;
+
+ r->cur_pts = r1->cur_pts;
+ r->last_pts = r1->last_pts;
+ r->next_pts = r1->next_pts;
+
+ memset(&r->si, 0, sizeof(r->si));
+
+ /* necessary since it is it the condition checked for in decode_slice
+ * to call MPV_frame_start. cmp. comment at the end of decode_frame */
+ s->current_picture_ptr = NULL;
+
+ return 0;
+}
+