mirror of https://git.ffmpeg.org/ffmpeg.git
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>
This commit is contained in:
parent
7a4639b1eb
commit
d8e92a89ed
|
@ -571,6 +571,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s,
|
||||||
FFAMediaCodec *codec = s->codec;
|
FFAMediaCodec *codec = s->codec;
|
||||||
int status;
|
int status;
|
||||||
int64_t input_dequeue_timeout_us = INPUT_DEQUEUE_TIMEOUT_US;
|
int64_t input_dequeue_timeout_us = INPUT_DEQUEUE_TIMEOUT_US;
|
||||||
|
int64_t pts;
|
||||||
|
|
||||||
if (s->flushing) {
|
if (s->flushing) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Decoder is flushing and cannot accept new buffer "
|
av_log(avctx, AV_LOG_ERROR, "Decoder is flushing and cannot accept new buffer "
|
||||||
|
@ -605,13 +606,13 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s,
|
||||||
return AVERROR_EXTERNAL;
|
return AVERROR_EXTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_draining) {
|
pts = pkt->pts;
|
||||||
int64_t pts = pkt->pts;
|
if (pts != AV_NOPTS_VALUE && avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
|
||||||
uint32_t flags = ff_AMediaCodec_getBufferFlagEndOfStream(codec);
|
pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
|
||||||
|
}
|
||||||
|
|
||||||
if (s->surface) {
|
if (need_draining) {
|
||||||
pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
|
uint32_t flags = ff_AMediaCodec_getBufferFlagEndOfStream(codec);
|
||||||
}
|
|
||||||
|
|
||||||
av_log(avctx, AV_LOG_DEBUG, "Sending End Of Stream signal\n");
|
av_log(avctx, AV_LOG_DEBUG, "Sending End Of Stream signal\n");
|
||||||
|
|
||||||
|
@ -627,16 +628,10 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, MediaCodecDecContext *s,
|
||||||
s->draining = 1;
|
s->draining = 1;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
int64_t pts = pkt->pts;
|
|
||||||
|
|
||||||
size = FFMIN(pkt->size - offset, size);
|
size = FFMIN(pkt->size - offset, size);
|
||||||
memcpy(data, pkt->data + offset, size);
|
memcpy(data, pkt->data + offset, size);
|
||||||
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);
|
status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, size, pts, 0);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Failed to queue input buffer (status = %d)\n", status);
|
av_log(avctx, AV_LOG_ERROR, "Failed to queue input buffer (status = %d)\n", status);
|
||||||
|
|
Loading…
Reference in New Issue