| OLD | NEW |
| (Empty) | |
| 1 diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c |
| 2 index 17c097e..ce14e63 100644 |
| 3 --- a/libavcodec/vp3.c |
| 4 +++ b/libavcodec/vp3.c |
| 5 @@ -45,6 +45,7 @@ |
| 6 #define FRAGMENT_PIXELS 8 |
| 7 |
| 8 static av_cold int vp3_decode_end(AVCodecContext *avctx); |
| 9 +static void vp3_decode_flush(AVCodecContext *avctx); |
| 10 |
| 11 //FIXME split things out into their own arrays |
| 12 typedef struct Vp3Fragment { |
| 13 @@ -942,6 +943,10 @@ static int unpack_vlcs(Vp3DecodeContext *s, GetBitContext *
gb, |
| 14 for (i = coeff_index+1; i <= coeff_index+zero_run; i++) |
| 15 s->num_coded_frags[plane][i]--; |
| 16 coeff_i++; |
| 17 + } else { |
| 18 + av_log(s->avctx, AV_LOG_ERROR, |
| 19 + "Invalid token %d\n", token); |
| 20 + return -1; |
| 21 } |
| 22 } |
| 23 |
| 24 @@ -991,6 +996,8 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitCont
ext *gb) |
| 25 /* unpack the Y plane DC coefficients */ |
| 26 residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0, |
| 27 0, residual_eob_run); |
| 28 + if (residual_eob_run < 0) |
| 29 + return residual_eob_run; |
| 30 |
| 31 /* reverse prediction of the Y-plane DC coefficients */ |
| 32 reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]); |
| 33 @@ -998,8 +1005,12 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBitCo
ntext *gb) |
| 34 /* unpack the C plane DC coefficients */ |
| 35 residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, |
| 36 1, residual_eob_run); |
| 37 + if (residual_eob_run < 0) |
| 38 + return residual_eob_run; |
| 39 residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, |
| 40 2, residual_eob_run); |
| 41 + if (residual_eob_run < 0) |
| 42 + return residual_eob_run; |
| 43 |
| 44 /* reverse prediction of the C-plane DC coefficients */ |
| 45 if (!(s->avctx->flags & CODEC_FLAG_GRAY)) |
| 46 @@ -1036,11 +1047,17 @@ static int unpack_dct_coeffs(Vp3DecodeContext *s, GetBit
Context *gb) |
| 47 for (i = 1; i <= 63; i++) { |
| 48 residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i, |
| 49 0, residual_eob_run); |
| 50 + if (residual_eob_run < 0) |
| 51 + return residual_eob_run; |
| 52 |
| 53 residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, |
| 54 1, residual_eob_run); |
| 55 + if (residual_eob_run < 0) |
| 56 + return residual_eob_run; |
| 57 residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, |
| 58 2, residual_eob_run); |
| 59 + if (residual_eob_run < 0) |
| 60 + return residual_eob_run; |
| 61 } |
| 62 |
| 63 return 0; |
| 64 @@ -1990,9 +2007,6 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx) |
| 65 Vp3DecodeContext *s = avctx->priv_data; |
| 66 int i; |
| 67 |
| 68 - if (avctx->is_copy && !s->current_frame.data[0]) |
| 69 - return 0; |
| 70 - |
| 71 av_free(s->superblock_coding); |
| 72 av_free(s->all_fragments); |
| 73 av_free(s->coded_fragment_list[0]); |
| 74 @@ -2019,12 +2033,7 @@ static av_cold int vp3_decode_end(AVCodecContext *avctx) |
| 75 free_vlc(&s->motion_vector_vlc); |
| 76 |
| 77 /* release all frames */ |
| 78 - if (s->golden_frame.data[0]) |
| 79 - ff_thread_release_buffer(avctx, &s->golden_frame); |
| 80 - if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY) |
| 81 - ff_thread_release_buffer(avctx, &s->last_frame); |
| 82 - /* no need to release the current_frame since it will always be pointing |
| 83 - * to the same frame as either the golden or last frame */ |
| 84 + vp3_decode_flush(avctx); |
| 85 |
| 86 return 0; |
| 87 } |
| 88 @@ -2344,6 +2353,23 @@ static void vp3_decode_flush(AVCodecContext *avctx) |
| 89 ff_thread_release_buffer(avctx, &s->current_frame); |
| 90 } |
| 91 |
| 92 +static int vp3_init_thread_copy(AVCodecContext *avctx) |
| 93 +{ |
| 94 + Vp3DecodeContext *s = avctx->priv_data; |
| 95 + |
| 96 + s->superblock_coding = NULL; |
| 97 + s->all_fragments = NULL; |
| 98 + s->coded_fragment_list[0] = NULL; |
| 99 + s->dct_tokens_base = NULL; |
| 100 + s->superblock_fragments = NULL; |
| 101 + s->macroblock_coding = NULL; |
| 102 + s->motion_val[0] = NULL; |
| 103 + s->motion_val[1] = NULL; |
| 104 + s->edge_emu_buffer = NULL; |
| 105 + |
| 106 + return 0; |
| 107 +} |
| 108 + |
| 109 AVCodec ff_theora_decoder = { |
| 110 .name = "theora", |
| 111 .type = AVMEDIA_TYPE_VIDEO, |
| 112 @@ -2355,6 +2381,7 @@ AVCodec ff_theora_decoder = { |
| 113 .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRA
ME_THREADS, |
| 114 .flush = vp3_decode_flush, |
| 115 .long_name = NULL_IF_CONFIG_SMALL("Theora"), |
| 116 + .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), |
| 117 .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) |
| 118 }; |
| 119 #endif |
| 120 @@ -2370,5 +2397,6 @@ AVCodec ff_vp3_decoder = { |
| 121 .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRA
ME_THREADS, |
| 122 .flush = vp3_decode_flush, |
| 123 .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"), |
| 124 + .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), |
| 125 .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) |
| 126 }; |
| 127 -- |
| 128 1.7.2.1 |
| 129 |
| OLD | NEW |