X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=libavcodec%2Fvp3.c;h=6fe1ca46a3a3b46f89336b5d2afd0ca4ff782119;hb=b1cc6b9496ee6373f7ef46b825b886ffecc09d92;hp=2ae54255c684794259f731db6cfe569710dd96b5;hpb=31c4fe177d750858dff04de6ebfec97dbf7bd04c;p=ffmpeg diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c index 2ae54255c68..6fe1ca46a3a 100644 --- a/libavcodec/vp3.c +++ b/libavcodec/vp3.c @@ -347,9 +347,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx) av_frame_free(&s->last_frame.f); av_frame_free(&s->golden_frame.f); - if (avctx->internal->is_copy) - return 0; - for (i = 0; i < 16; i++) { ff_free_vlc(&s->dc_vlc[i]); ff_free_vlc(&s->ac_vlc_1[i]); @@ -2330,8 +2327,6 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx) if (ret < 0) return ret; - avctx->internal->allocate_progress = 1; - if (avctx->codec_tag == MKTAG('V', 'P', '4', '0')) s->version = 3; else if (avctx->codec_tag == MKTAG('V', 'P', '3', '0')) @@ -2422,32 +2417,32 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx) /* init VLC tables */ if (s->version < 2) { - for (i = 0; i < 16; i++) { - /* DC histograms */ - init_vlc(&s->dc_vlc[i], 11, 32, - &dc_bias[i][0][1], 4, 2, - &dc_bias[i][0][0], 4, 2, 0); + for (i = 0; i < 16; i++) { + /* DC histograms */ + init_vlc(&s->dc_vlc[i], 11, 32, + &dc_bias[i][0][1], 4, 2, + &dc_bias[i][0][0], 4, 2, 0); - /* group 1 AC histograms */ - init_vlc(&s->ac_vlc_1[i], 11, 32, - &ac_bias_0[i][0][1], 4, 2, - &ac_bias_0[i][0][0], 4, 2, 0); + /* group 1 AC histograms */ + init_vlc(&s->ac_vlc_1[i], 11, 32, + &ac_bias_0[i][0][1], 4, 2, + &ac_bias_0[i][0][0], 4, 2, 0); - /* group 2 AC histograms */ - init_vlc(&s->ac_vlc_2[i], 11, 32, - &ac_bias_1[i][0][1], 4, 2, - &ac_bias_1[i][0][0], 4, 2, 0); + /* group 2 AC histograms */ + init_vlc(&s->ac_vlc_2[i], 11, 32, + &ac_bias_1[i][0][1], 4, 2, + &ac_bias_1[i][0][0], 4, 2, 0); - /* group 3 AC histograms */ - init_vlc(&s->ac_vlc_3[i], 11, 32, - &ac_bias_2[i][0][1], 4, 2, - &ac_bias_2[i][0][0], 4, 2, 0); + /* group 3 AC histograms */ + init_vlc(&s->ac_vlc_3[i], 11, 32, + &ac_bias_2[i][0][1], 4, 2, + &ac_bias_2[i][0][0], 4, 2, 0); - /* group 4 AC histograms */ - init_vlc(&s->ac_vlc_4[i], 11, 32, - &ac_bias_3[i][0][1], 4, 2, - &ac_bias_3[i][0][0], 4, 2, 0); - } + /* group 4 AC histograms */ + init_vlc(&s->ac_vlc_4[i], 11, 32, + &ac_bias_3[i][0][1], 4, 2, + &ac_bias_3[i][0][0], 4, 2, 0); + } #if CONFIG_VP4_DECODER } else { /* version >= 2 */ for (i = 0; i < 16; i++) { @@ -2603,23 +2598,6 @@ static int vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext * } if (s != s1) { - if (!s->current_frame.f) - return AVERROR(ENOMEM); - // init tables if the first frame hasn't been decoded - if (!s->current_frame.f->data[0]) { - int y_fragment_count, c_fragment_count; - s->avctx = dst; - err = allocate_tables(dst); - if (err) - return err; - y_fragment_count = s->fragment_width[0] * s->fragment_height[0]; - c_fragment_count = s->fragment_width[1] * s->fragment_height[1]; - memcpy(s->motion_val[0], s1->motion_val[0], - y_fragment_count * sizeof(*s->motion_val[0])); - memcpy(s->motion_val[1], s1->motion_val[1], - c_fragment_count * sizeof(*s->motion_val[1])); - } - // copy previous frame data if ((err = ref_frames(s, s1)) < 0) return err; @@ -2808,10 +2786,10 @@ static int vp3_decode_frame(AVCodecContext *avctx, ff_thread_finish_setup(avctx); if (s->version < 2) { - if ((ret = unpack_superblocks(s, &gb)) < 0) { - av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n"); - goto error; - } + if ((ret = unpack_superblocks(s, &gb)) < 0) { + av_log(s->avctx, AV_LOG_ERROR, "error in unpack_superblocks\n"); + goto error; + } #if CONFIG_VP4_DECODER } else { if ((ret = vp4_unpack_macroblocks(s, &gb)) < 0) { @@ -2834,10 +2812,10 @@ static int vp3_decode_frame(AVCodecContext *avctx, } if (s->version < 2) { - if ((ret = unpack_dct_coeffs(s, &gb)) < 0) { - av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n"); - goto error; - } + if ((ret = unpack_dct_coeffs(s, &gb)) < 0) { + av_log(s->avctx, AV_LOG_ERROR, "error in unpack_dct_coeffs\n"); + goto error; + } #if CONFIG_VP4_DECODER } else { if ((ret = vp4_unpack_dct_coeffs(s, &gb)) < 0) { @@ -2861,10 +2839,10 @@ static int vp3_decode_frame(AVCodecContext *avctx, // filter the last row if (s->version < 2) - for (i = 0; i < 3; i++) { - int row = (s->height >> (3 + (i && s->chroma_y_shift))) - 1; - apply_loop_filter(s, i, row, row + 1); - } + for (i = 0; i < 3; i++) { + int row = (s->height >> (3 + (i && s->chroma_y_shift))) - 1; + apply_loop_filter(s, i, row, row + 1); + } vp3_draw_horiz_band(s, s->height); /* output frame, offset as needed */ @@ -2929,28 +2907,6 @@ static int read_huffman_tree(AVCodecContext *avctx, GetBitContext *gb) return 0; } -#if HAVE_THREADS -static int vp3_init_thread_copy(AVCodecContext *avctx) -{ - Vp3DecodeContext *s = avctx->priv_data; - - s->superblock_coding = NULL; - s->all_fragments = NULL; - s->coded_fragment_list[0] = NULL; - s-> kf_coded_fragment_list= NULL; - s->nkf_coded_fragment_list= NULL; - s->dct_tokens_base = NULL; - s->superblock_fragments = NULL; - s->macroblock_coding = NULL; - s->motion_val[0] = NULL; - s->motion_val[1] = NULL; - s->edge_emu_buffer = NULL; - s->dc_pred_row = NULL; - - return init_frames(s); -} -#endif - #if CONFIG_THEORA_DECODER static const enum AVPixelFormat theora_pix_fmts[4] = { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P @@ -3264,9 +3220,8 @@ AVCodec ff_theora_decoder = { .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, - .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context), - .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING, + .caps_internal = FF_CODEC_CAP_EXPORTS_CROPPING | FF_CODEC_CAP_ALLOCATE_PROGRESS, }; #endif @@ -3282,8 +3237,8 @@ AVCodec ff_vp3_decoder = { .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, - .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context), + .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS, }; #if CONFIG_VP4_DECODER @@ -3299,7 +3254,7 @@ AVCodec ff_vp4_decoder = { .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, - .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context), + .caps_internal = FF_CODEC_CAP_ALLOCATE_PROGRESS, }; #endif