diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-08 02:59:09 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-08 05:53:35 +0100 |
commit | 18d0a16fc9d189b1d5593f9a42bb2316e9a66ca9 (patch) | |
tree | aad3d9b1a07b9efebd7435bb27dde147cfa67913 /libavcodec/vp8.c | |
parent | 950930b461cef025152de406f816a3b2efffb540 (diff) | |
parent | ef1c785f11c168384e42d147648c8fdf5317739b (diff) | |
download | ffmpeg-18d0a16fc9d189b1d5593f9a42bb2316e9a66ca9.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
swscale: make yuv2yuv1 use named registers.
h264: mark h264_idct_add8_10 with number of XMM registers.
swscale: fix V plane memory location in bilinear/unscaled RGB/YUYV case.
vp8: always update next_framep[] before returning from decode_frame().
avconv: estimate next_dts from framerate if it is set.
avconv: better next_dts usage.
avconv: rename InputStream.pts to last_dts.
avconv: reduce overloading for InputStream.pts.
avconv: rename InputStream.next_pts to next_dts.
avconv: rework -t handling for encoding.
avconv: set encoder timebase for subtitles.
pva-demux test: add -vn
swscale: K&R formatting cosmetics for SPARC code
apedec: allow the user to set the maximum number of output samples per call
apedec: do not unnecessarily zero output samples for mono frames
apedec: allocate a single flat buffer for decoded samples
apedec: use sizeof(field) instead of sizeof(type)
swscale: split C output functions into separate file.
swscale: Split C input functions into separate file.
bytestream: Add bytestream2 writing API.
The avconv changes are due to massive regressions and bugs not merged yet.
Conflicts:
ffmpeg.c
libavcodec/vp8.c
libswscale/swscale.c
libswscale/x86/swscale_template.c
tests/fate/demux.mak
tests/ref/lavf/asf
tests/ref/lavf/avi
tests/ref/lavf/mkv
tests/ref/lavf/mpg
tests/ref/lavf/nut
tests/ref/lavf/ogg
tests/ref/lavf/rm
tests/ref/lavf/ts
tests/ref/seek/lavf_avi
tests/ref/seek/lavf_mkv
tests/ref/seek/lavf_rm
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/vp8.c')
-rw-r--r-- | libavcodec/vp8.c | 78 |
1 files changed, 32 insertions, 46 deletions
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index 370fb0070c..4728393d10 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -1561,18 +1561,6 @@ static void release_queued_segmaps(VP8Context *s, int is_close) s->maps_are_invalid = 0; } -/** - * Sets things up for skipping the current frame. - * In particular, removes it from the reference buffers. - */ -static void skipframe_clear(VP8Context *s) -{ - s->invisible = 1; - s->next_framep[VP56_FRAME_CURRENT] = NULL; - if (s->update_last) - s->next_framep[VP56_FRAME_PREVIOUS] = NULL; -} - static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { @@ -1584,7 +1572,7 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, release_queued_segmaps(s, 0); if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0) - return ret; + goto err; prev_frame = s->framep[VP56_FRAME_CURRENT]; @@ -1594,6 +1582,11 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, skip_thresh = !referenced ? AVDISCARD_NONREF : !s->keyframe ? AVDISCARD_NONKEY : AVDISCARD_ALL; + if (avctx->skip_frame >= skip_thresh) { + s->invisible = 1; + memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4); + goto skip_decode; + } s->deblock_filter = s->filter.level && avctx->skip_loop_filter < skip_thresh; // release no longer referenced frames @@ -1618,6 +1611,27 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, av_log(avctx, AV_LOG_FATAL, "Ran out of free frames!\n"); abort(); } + if (curframe->data[0]) + vp8_release_frame(s, curframe, 1, 0); + + // Given that arithmetic probabilities are updated every frame, it's quite likely + // that the values we have on a random interframe are complete junk if we didn't + // start decode on a keyframe. So just don't display anything rather than junk. + if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] || + !s->framep[VP56_FRAME_GOLDEN] || + !s->framep[VP56_FRAME_GOLDEN2])) { + av_log(avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n"); + ret = AVERROR_INVALIDDATA; + goto err; + } + + curframe->key_frame = s->keyframe; + curframe->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; + curframe->reference = referenced ? 3 : 0; + if ((ret = vp8_alloc_frame(s, curframe))) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed!\n"); + goto err; + } // check if golden and altref are swapped if (s->update_altref != VP56_FRAME_NONE) { @@ -1637,36 +1651,6 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, } s->next_framep[VP56_FRAME_CURRENT] = curframe; - if (avctx->skip_frame >= skip_thresh) { - skipframe_clear(s); - ret = avpkt->size; - goto skip_decode; - } - - // Given that arithmetic probabilities are updated every frame, it's quite likely - // that the values we have on a random interframe are complete junk if we didn't - // start decode on a keyframe. So just don't display anything rather than junk. - if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] || - !s->framep[VP56_FRAME_GOLDEN] || - !s->framep[VP56_FRAME_GOLDEN2])) { - av_log(avctx, AV_LOG_WARNING, "Discarding interframe without a prior keyframe!\n"); - skipframe_clear(s); - ret = AVERROR_INVALIDDATA; - goto skip_decode; - } - - if (curframe->data[0]) - vp8_release_frame(s, curframe, 1, 0); - - curframe->key_frame = s->keyframe; - curframe->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; - curframe->reference = referenced ? 3 : 0; - if ((ret = vp8_alloc_frame(s, curframe))) { - av_log(avctx, AV_LOG_ERROR, "get_buffer() failed!\n"); - skipframe_clear(s); - goto skip_decode; - } - ff_thread_finish_setup(avctx); s->linesize = curframe->linesize[0]; @@ -1778,20 +1762,22 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, } ff_thread_report_progress(curframe, INT_MAX, 0); - ret = avpkt->size; + memcpy(&s->framep[0], &s->next_framep[0], sizeof(s->framep[0]) * 4); + skip_decode: // if future frames don't use the updated probabilities, // reset them to the values we saved if (!s->update_probabilities) s->prob[0] = s->prob[1]; - memcpy(&s->framep[0], &s->next_framep[0], sizeof(s->framep[0]) * 4); - if (!s->invisible) { *(AVFrame*)data = *curframe; *data_size = sizeof(AVFrame); } + return avpkt->size; +err: + memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4); return ret; } |