[FFmpeg-devel] [PATCH 2/6] avcodec/mediacodecdec: warn when input buffers are not configured with proper size
Matthieu Bouron
matthieu.bouron at gmail.com
Fri Sep 6 10:39:53 EEST 2019
On Thu, Sep 05, 2019 at 11:27:31AM -0700, Aman Gupta wrote:
> From: Aman Gupta <aman at tmm1.net>
>
> In rare circumstances, if the codec is not configured with the
> proper parameters the input buffers can be allocated with a size
> that's too small to hold an individual packet. Since MediaCodec
> expects exactly one incoming buffer with a given PTS, it is not
> valid to split data for a given PTS across two input buffers.
>
> See https://developer.android.com/reference/android/media/MediaCodec#data-processing:
>
> > Do not submit multiple input buffers with the same timestamp
>
> Signed-off-by: Aman Gupta <aman at tmm1.net>
> ---
> libavcodec/mediacodecdec.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
> index e353e34bd5..f5771bffb1 100644
> --- a/libavcodec/mediacodecdec.c
> +++ b/libavcodec/mediacodecdec.c
> @@ -440,8 +440,13 @@ static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
> if (ret >= 0) {
> s->buffered_pkt.size -= ret;
> s->buffered_pkt.data += ret;
> - if (s->buffered_pkt.size <= 0)
> + if (s->buffered_pkt.size <= 0) {
> av_packet_unref(&s->buffered_pkt);
> + } else {
> + av_log(avctx, AV_LOG_WARNING,
> + "could not send entire packet in single input buffer (%d < %d)\n",
> + ret, s->buffered_pkt.size+ret);
> + }
> } else if (ret < 0 && ret != AVERROR(EAGAIN)) {
> return ret;
> }
> --
> 2.20.1
>
The patch itself looks good to me. We should probably simplifies the
mediacodec_dec_send() function to not try to split the input pkt into
multiple MediaCodec buffers. I will send a patch to do that.
--
Matthieu B.
More information about the ffmpeg-devel
mailing list