summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2016-03-22 19:09:57 +0100
committerwm4 <nfxjfg@googlemail.com>2016-04-21 14:23:36 +0200
commit656b07b5a9698c5f5a244f334a2a9852cfbbd01c (patch)
treec3924d0bc2c6c8d75a180c7deec5388cb9238d6c /libavformat/utils.c
parent7fc329e2dd6226dfecaa4a1d7adf353bf2773726 (diff)
lavf: use new decode API
From Libav commit 8bc4accc37ab047d2fd85d672c577b39dfc918e1, with additional code for decoding subtitles (not present in Libav). Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 566c7b811d..72396af97f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2891,27 +2891,27 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, AVPacket *avpkt,
(!st->codec_info_nb_frames &&
(avctx->codec->capabilities & AV_CODEC_CAP_CHANNEL_CONF)))) {
got_picture = 0;
- switch (avctx->codec_type) {
- case AVMEDIA_TYPE_VIDEO:
- ret = avcodec_decode_video2(avctx, frame,
- &got_picture, &pkt);
- break;
- case AVMEDIA_TYPE_AUDIO:
- ret = avcodec_decode_audio4(avctx, frame, &got_picture, &pkt);
- break;
- case AVMEDIA_TYPE_SUBTITLE:
+ if (avctx->codec_type == AVMEDIA_TYPE_VIDEO ||
+ avctx->codec_type == AVMEDIA_TYPE_AUDIO) {
+ ret = avcodec_send_packet(avctx, &pkt);
+ if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
+ break;
+ if (ret >= 0)
+ pkt.size = 0;
+ ret = avcodec_receive_frame(avctx, frame);
+ if (ret >= 0)
+ got_picture = 1;
+ if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
+ ret = 0;
+ } else if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
ret = avcodec_decode_subtitle2(avctx, &subtitle,
&got_picture, &pkt);
- ret = pkt.size;
- break;
- default:
- break;
+ if (ret >= 0)
+ pkt.size = 0;
}
if (ret >= 0) {
if (got_picture)
st->nb_decoded_frames++;
- pkt.data += ret;
- pkt.size -= ret;
ret = got_picture;
}
}