diff options
Diffstat (limited to 'libavcodec/vp6.c')
-rw-r--r-- | libavcodec/vp6.c | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c index 2e25a55f3f..6e385ce1de 100644 --- a/libavcodec/vp6.c +++ b/libavcodec/vp6.c @@ -1,20 +1,20 @@ /* * Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org> * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -42,8 +42,7 @@ static void vp6_parse_coeff(VP56Context *s); static void vp6_parse_coeff_huffman(VP56Context *s); -static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, - int *golden_frame) +static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size) { VP56RangeCoder *c = &s->c; int parse_filter_info = 0; @@ -99,6 +98,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, if (sub_version < 8) vrt_shift = 5; s->sub_version = sub_version; + s->golden_frame = 0; } else { if (!s->sub_version || !s->avctx->coded_width || !s->avctx->coded_height) return AVERROR_INVALIDDATA; @@ -110,7 +110,7 @@ static int vp6_parse_header(VP56Context *s, const uint8_t *buf, int buf_size, } ff_vp56_init_range_decoder(c, buf+1, buf_size-1); - *golden_frame = vp56_rac_get(c); + s->golden_frame = vp56_rac_get(c); if (s->filter_header) { s->deblock_filtering = vp56_rac_get(c); if (s->deblock_filtering) @@ -368,7 +368,7 @@ static unsigned vp6_get_nb_null(VP56Context *s) static void vp6_parse_coeff_huffman(VP56Context *s) { VP56Model *model = s->modelp; - uint8_t *permute = s->scantable.permutated; + uint8_t *permute = s->idct_scantable; VLC *vlc_coeff; int coeff, sign, coeff_idx; int b, cg, idx; @@ -428,7 +428,7 @@ static void vp6_parse_coeff(VP56Context *s) { VP56RangeCoder *c = s->ccp; VP56Model *model = s->modelp; - uint8_t *permute = s->scantable.permutated; + uint8_t *permute = s->idct_scantable; uint8_t *model1, *model2, *model3; int coeff, sign, coeff_idx; int b, i, cg, idx, ctx; @@ -589,6 +589,8 @@ static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src, } } +static av_cold void vp6_decode_init_context(VP56Context *s); + static av_cold int vp6_decode_init(AVCodecContext *avctx) { VP56Context *s = avctx->priv_data; @@ -598,6 +600,21 @@ static av_cold int vp6_decode_init(AVCodecContext *avctx) avctx->codec->id == AV_CODEC_ID_VP6A)) < 0) return ret; + vp6_decode_init_context(s); + + if (s->has_alpha) { + s->alpha_context = av_mallocz(sizeof(VP56Context)); + ff_vp56_init_context(avctx, s->alpha_context, + s->flip == -1, s->has_alpha); + vp6_decode_init_context(s->alpha_context); + } + + return 0; +} + +static av_cold void vp6_decode_init_context(VP56Context *s) +{ + s->deblock_filtering = 0; s->vp56_coord_div = vp6_coord_div; s->parse_vector_adjustment = vp6_parse_vector_adjustment; s->filter = vp6_filter; @@ -605,16 +622,29 @@ static av_cold int vp6_decode_init(AVCodecContext *avctx) s->parse_vector_models = vp6_parse_vector_models; s->parse_coeff_models = vp6_parse_coeff_models; s->parse_header = vp6_parse_header; - - return 0; } +static av_cold void vp6_decode_free_context(VP56Context *s); + static av_cold int vp6_decode_free(AVCodecContext *avctx) { VP56Context *s = avctx->priv_data; - int pt, ct, cg; ff_vp56_free(avctx); + vp6_decode_free_context(s); + + if (s->alpha_context) { + ff_vp56_free_context(s->alpha_context); + vp6_decode_free_context(s->alpha_context); + av_free(s->alpha_context); + } + + return 0; +} + +static av_cold void vp6_decode_free_context(VP56Context *s) +{ + int pt, ct, cg; for (pt=0; pt<2; pt++) { ff_free_vlc(&s->dccv_vlc[pt]); @@ -623,7 +653,6 @@ static av_cold int vp6_decode_free(AVCodecContext *avctx) for (cg=0; cg<6; cg++) ff_free_vlc(&s->ract_vlc[pt][ct][cg]); } - return 0; } AVCodec ff_vp6_decoder = { @@ -660,6 +689,6 @@ AVCodec ff_vp6a_decoder = { .init = vp6_decode_init, .close = vp6_decode_free, .decode = ff_vp56_decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, .long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"), }; |