-#if defined(CONFIG_HUFFYUV_ENCODER) || defined(CONFIG_FFVHUFF_ENCODER)
-static int store_table(HYuvContext *s, uint8_t *len, uint8_t *buf){
+static av_cold int decode_init_thread_copy(AVCodecContext *avctx)
+{
+ HYuvContext *s = avctx->priv_data;
+ int i;
+
+ avctx->coded_frame= &s->picture;
+ alloc_temp(s);
+
+ for (i = 0; i < 6; i++)
+ s->vlc[i].table = NULL;
+
+ if(s->version==2){
+ if(read_huffman_tables(s, ((uint8_t*)avctx->extradata)+4, avctx->extradata_size) < 0)
+ return -1;
+ }else{
+ if(read_old_huffman_tables(s) < 0)
+ return -1;
+ }
+
+ return 0;
+}
+#endif /* CONFIG_HUFFYUV_DECODER || CONFIG_FFVHUFF_DECODER */
+
+#if CONFIG_HUFFYUV_ENCODER || CONFIG_FFVHUFF_ENCODER
+static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf){