aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorAman Gupta <aman@tmm1.net>2018-04-24 13:51:15 -0700
committerAman Gupta <aman@tmm1.net>2018-04-25 10:53:54 -0700
commitd8e92a89edd8e73cdc7f125f078c576df10b66f2 (patch)
treea55105633f9380ec8b597701535330717499b985 /libavcodec
parent7a4639b1eba31f88490c85663c75fb1414307680 (diff)
downloadffmpeg-d8e92a89edd8e73cdc7f125f078c576df10b66f2.tar.gz
avcodec/mediacodecdec: refactor pts handling
Also fixes a bug where EOS buffer was sent with incorrect pts when not using surface generation. Signed-off-by: Matthieu Bouron <matthieu.bouron@gmail.com> Signed-off-by: Aman Gupta <aman@tmm1.net>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mediacodecdec_common.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/libavcodec/mediacodecdec_common.c b/libavcodec/mediacodecdec_common.c
index 56b3c4fd1e..c0f0a6b983 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -571,6 +571,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s,
FFAMediaCodec *codec = s->codec;
int status;
int64_t input_dequeue_timeout_us = INPUT_DEQUEUE_TIMEOUT_US;
+ int64_t pts;
if (s->flushing) {
av_log(avctx, AV_LOG_ERROR, "Decoder is flushing and cannot accept new buffer "
@@ -605,14 +606,14 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s,
return AVERROR_EXTERNAL;
}
+ pts = pkt->pts;
+ if (pts != AV_NOPTS_VALUE && avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
+ pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
+ }
+
if (need_draining) {
- int64_t pts = pkt->pts;
uint32_t flags = ff_AMediaCodec_getBufferFlagEndOfStream(codec);
- if (s->surface) {
- pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
- }
-
av_log(avctx, AV_LOG_DEBUG, "Sending End Of Stream signal\n");
status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, 0, pts, flags);
@@ -627,16 +628,10 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s,
s->draining = 1;
break;
} else {
- int64_t pts = pkt->pts;
-
size = FFMIN(pkt->size - offset, size);
memcpy(data, pkt->data + offset, size);
offset += size;
- if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
- pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
- }
-
status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, size, pts, 0);
if (status < 0) {
av_log(avctx, AV_LOG_ERROR, "Failed to queue input buffer (status = %d)\n", status);