OLD | NEW |
1 /** | 1 /** |
2 * VP8 compatible video decoder | 2 * VP8 compatible video decoder |
3 * | 3 * |
4 * Copyright (C) 2010 David Conrad | 4 * Copyright (C) 2010 David Conrad |
5 * Copyright (C) 2010 Ronald S. Bultje | 5 * Copyright (C) 2010 Ronald S. Bultje |
6 * Copyright (C) 2010 Jason Garrett-Glaser | 6 * Copyright (C) 2010 Jason Garrett-Glaser |
7 * | 7 * |
8 * This file is part of FFmpeg. | 8 * This file is part of FFmpeg. |
9 * | 9 * |
10 * FFmpeg is free software; you can redistribute it and/or | 10 * FFmpeg is free software; you can redistribute it and/or |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 av_freep(&s->top_border); | 43 av_freep(&s->top_border); |
44 | 44 |
45 s->macroblocks = NULL; | 45 s->macroblocks = NULL; |
46 } | 46 } |
47 | 47 |
48 static int vp8_alloc_frame(VP8Context *s, AVFrame *f) | 48 static int vp8_alloc_frame(VP8Context *s, AVFrame *f) |
49 { | 49 { |
50 int ret; | 50 int ret; |
51 if ((ret = ff_thread_get_buffer(s->avctx, f)) < 0) | 51 if ((ret = ff_thread_get_buffer(s->avctx, f)) < 0) |
52 return ret; | 52 return ret; |
53 if (s->num_maps_to_be_freed) { | 53 if (s->num_maps_to_be_freed && !s->maps_are_invalid) { |
54 assert(!s->maps_are_invalid); | |
55 f->ref_index[0] = s->segmentation_maps[--s->num_maps_to_be_freed]; | 54 f->ref_index[0] = s->segmentation_maps[--s->num_maps_to_be_freed]; |
56 } else if (!(f->ref_index[0] = av_mallocz(s->mb_width * s->mb_height))) { | 55 } else if (!(f->ref_index[0] = av_mallocz(s->mb_width * s->mb_height))) { |
57 ff_thread_release_buffer(s->avctx, f); | 56 ff_thread_release_buffer(s->avctx, f); |
58 return AVERROR(ENOMEM); | 57 return AVERROR(ENOMEM); |
59 } | 58 } |
60 return 0; | 59 return 0; |
61 } | 60 } |
62 | 61 |
63 static void vp8_release_frame(VP8Context *s, AVFrame *f, int prefer_delayed_free
, int can_direct_free) | 62 static void vp8_release_frame(VP8Context *s, AVFrame *f, int prefer_delayed_free
, int can_direct_free) |
64 { | 63 { |
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 av_freep(&s->segmentation_maps[--s->num_maps_to_be_freed]); | 1557 av_freep(&s->segmentation_maps[--s->num_maps_to_be_freed]); |
1559 s->maps_are_invalid = 0; | 1558 s->maps_are_invalid = 0; |
1560 } | 1559 } |
1561 | 1560 |
1562 static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, | 1561 static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
1563 AVPacket *avpkt) | 1562 AVPacket *avpkt) |
1564 { | 1563 { |
1565 VP8Context *s = avctx->priv_data; | 1564 VP8Context *s = avctx->priv_data; |
1566 int ret, mb_x, mb_y, i, y, referenced; | 1565 int ret, mb_x, mb_y, i, y, referenced; |
1567 enum AVDiscard skip_thresh; | 1566 enum AVDiscard skip_thresh; |
1568 AVFrame *av_uninit(curframe), *prev_frame = s->framep[VP56_FRAME_CURRENT]; | 1567 AVFrame *av_uninit(curframe), *prev_frame; |
1569 | 1568 |
1570 release_queued_segmaps(s, 0); | 1569 release_queued_segmaps(s, 0); |
1571 | 1570 |
1572 if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0) | 1571 if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0) |
1573 return ret; | 1572 return ret; |
1574 | 1573 |
| 1574 prev_frame = s->framep[VP56_FRAME_CURRENT]; |
| 1575 |
1575 referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT | 1576 referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT |
1576 || s->update_altref == VP56_FRAME_CURRENT; | 1577 || s->update_altref == VP56_FRAME_CURRENT; |
1577 | 1578 |
1578 skip_thresh = !referenced ? AVDISCARD_NONREF : | 1579 skip_thresh = !referenced ? AVDISCARD_NONREF : |
1579 !s->keyframe ? AVDISCARD_NONKEY : AVDISCARD_ALL; | 1580 !s->keyframe ? AVDISCARD_NONKEY : AVDISCARD_ALL; |
1580 | 1581 |
1581 if (avctx->skip_frame >= skip_thresh) { | 1582 if (avctx->skip_frame >= skip_thresh) { |
1582 s->invisible = 1; | 1583 s->invisible = 1; |
1583 goto skip_decode; | 1584 goto skip_decode; |
1584 } | 1585 } |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1836 vp8_decode_init, | 1837 vp8_decode_init, |
1837 NULL, | 1838 NULL, |
1838 vp8_decode_free, | 1839 vp8_decode_free, |
1839 vp8_decode_frame, | 1840 vp8_decode_frame, |
1840 CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, | 1841 CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS, |
1841 .flush = vp8_decode_flush, | 1842 .flush = vp8_decode_flush, |
1842 .long_name = NULL_IF_CONFIG_SMALL("On2 VP8"), | 1843 .long_name = NULL_IF_CONFIG_SMALL("On2 VP8"), |
1843 .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp8_decode_init_thread_copy
), | 1844 .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp8_decode_init_thread_copy
), |
1844 .update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_co
ntext), | 1845 .update_thread_context = ONLY_IF_THREADS_ENABLED(vp8_decode_update_thread_co
ntext), |
1845 }; | 1846 }; |
OLD | NEW |