[FFmpeg-devel] [PATCH v2 7/8] lavf: use new decode API
wm4
nfxjfg at googlemail.com
Wed Mar 23 14:02:14 CET 2016
---
libavformat/utils.c | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 67d4d1b..c7b7969 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2814,27 +2814,22 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt,
(!st->codec_info_nb_frames &&
(st->codec->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)))) {
got_picture = 0;
- switch (st->codec->codec_type) {
- case AVMEDIA_TYPE_VIDEO:
- ret = avcodec_decode_video2(st->codec, frame,
- &got_picture, &pkt);
- break;
- case AVMEDIA_TYPE_AUDIO:
- ret = avcodec_decode_audio4(st->codec, frame, &got_picture, &pkt);
- break;
- case AVMEDIA_TYPE_SUBTITLE:
- ret = avcodec_decode_subtitle2(st->codec, &subtitle,
- &got_picture, &pkt);
- ret = pkt.size;
- break;
- default:
- break;
+ if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
+ st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+ ret = avcodec_send_packet(st->codec, &pkt);
+ if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
+ break;
+ if (ret >= 0)
+ pkt.size = 0;
+ ret = avcodec_receive_frame(st->codec, frame);
+ if (ret >= 0)
+ got_picture = 1;
+ if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
+ ret = 0;
}
if (ret >= 0) {
if (got_picture)
st->nb_decoded_frames++;
- pkt.data += ret;
- pkt.size -= ret;
ret = got_picture;
}
}
--
2.8.0.rc3
More information about the ffmpeg-devel
mailing list