diff options
author | Matthieu Bouron <matthieu.bouron@stupeflix.com> | 2016-06-20 16:41:21 +0200 |
---|---|---|
committer | Matthieu Bouron <matthieu.bouron@stupeflix.com> | 2016-06-23 14:14:15 +0200 |
commit | b316ebf46dd6b025bf116751cd6e0c6b0149f48c (patch) | |
tree | 0f46e06d5402d56740d482290ca49a23921b5b02 | |
parent | 30e3a27119294f7353c7a1e6d6387dbef792c203 (diff) | |
download | ffmpeg-b316ebf46dd6b025bf116751cd6e0c6b0149f48c.tar.gz |
lavc/mediacodec: rely on buffer flags to detect end of stream
-rw-r--r-- | libavcodec/mediacodecdec.c | 17 | ||||
-rw-r--r-- | libavcodec/mediacodecdec.h | 3 |
2 files changed, 9 insertions, 11 deletions
diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c index 75933fca11..7cef90b4b8 100644 --- a/libavcodec/mediacodecdec.c +++ b/libavcodec/mediacodecdec.c @@ -396,7 +396,7 @@ int ff_mediacodec_dec_decode(AVCodecContext *avctx, MediaCodecDecContext *s, need_flushing = 1; } - if (s->flushing && need_flushing && s->queued_buffer_nb <= 0) { + if (s->flushing && s->eos) { return 0; } @@ -443,10 +443,6 @@ int ff_mediacodec_dec_decode(AVCodecContext *avctx, MediaCodecDecContext *s, av_log(avctx, AV_LOG_ERROR, "Failed to queue input buffer (status = %d)\n", status); return AVERROR_EXTERNAL; } - - s->queued_buffer_nb++; - if (s->queued_buffer_nb > s->queued_buffer_max) - s->queued_buffer_max = s->queued_buffer_nb; } } @@ -474,6 +470,10 @@ int ff_mediacodec_dec_decode(AVCodecContext *avctx, MediaCodecDecContext *s, " flags=%" PRIu32 "\n", index, info.offset, info.size, info.presentationTimeUs, info.flags); + if (info.flags & ff_AMediaCodec_getBufferFlagEndOfStream(codec)) { + s->eos = 1; + } + if (info.size) { data = ff_AMediaCodec_getOutputBuffer(codec, index, &size); if (!data) { @@ -487,7 +487,6 @@ int ff_mediacodec_dec_decode(AVCodecContext *avctx, MediaCodecDecContext *s, } *got_frame = 1; - s->queued_buffer_nb--; s->dequeued_buffer_nb++; } else { status = ff_AMediaCodec_releaseOutputBuffer(codec, index, 0); @@ -528,8 +527,8 @@ int ff_mediacodec_dec_decode(AVCodecContext *avctx, MediaCodecDecContext *s, } else if (ff_AMediaCodec_infoTryAgainLater(codec, index)) { if (s->flushing) { av_log(avctx, AV_LOG_ERROR, "Failed to dequeue output buffer within %" PRIi64 "ms " - "while flushing remaining frames, output will probably lack last %d frames\n", - output_dequeue_timeout_us / 1000, s->queued_buffer_nb); + "while flushing remaining frames, output will probably lack frames\n", + output_dequeue_timeout_us / 1000); } else { av_log(avctx, AV_LOG_DEBUG, "No output buffer available, try again later\n"); } @@ -546,10 +545,10 @@ int ff_mediacodec_dec_flush(AVCodecContext *avctx, MediaCodecDecContext *s) FFAMediaCodec *codec = s->codec; int status; - s->queued_buffer_nb = 0; s->dequeued_buffer_nb = 0; s->flushing = 0; + s->eos = 0; status = ff_AMediaCodec_flush(codec); if (status < 0) { diff --git a/libavcodec/mediacodecdec.h b/libavcodec/mediacodecdec.h index 36fdbf54fe..646b628168 100644 --- a/libavcodec/mediacodecdec.h +++ b/libavcodec/mediacodecdec.h @@ -41,6 +41,7 @@ typedef struct MediaCodecDecContext { int started; int flushing; + int eos; int width; int height; @@ -53,8 +54,6 @@ typedef struct MediaCodecDecContext { int crop_left; int crop_right; - int queued_buffer_nb; - int queued_buffer_max; uint64_t dequeued_buffer_nb; int first_buffer; |