diff options
author | wm4 <wm4@nowhere> | 2013-11-26 01:07:14 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-26 01:07:32 +0100 |
commit | fe73b14eb1e8ccfc49dc73e1dbeb6510ed1e9452 (patch) | |
tree | 34544c5f99417bdc37b25abeca98947acc65c93e | |
parent | 49f076d86dc8b9b451861c9a2a3c1726420a0914 (diff) | |
download | mpv-fe73b14eb1e8ccfc49dc73e1dbeb6510ed1e9452.tar.bz2 mpv-fe73b14eb1e8ccfc49dc73e1dbeb6510ed1e9452.tar.xz |
player: move code for skipping 0-sized video packets to demuxer
These packets have to be explicitly dropped, because usually libavcodec
uses 0-sized packets to flush delayed frames, meaning just passing
through these packets would have bad consequences.
Normally, libavformat doesn't output 0-sized packets anyway. But I don't
want to take any chances, so don't delete it, and just move it out of
the way to demux.c.
-rw-r--r-- | demux/demux.c | 8 | ||||
-rw-r--r-- | mpvcore/player/video.c | 11 |
2 files changed, 9 insertions, 10 deletions
diff --git a/demux/demux.c b/demux/demux.c index 467b016699..bfa999ab15 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -318,6 +318,14 @@ int demuxer_add_packet(demuxer_t *demuxer, struct sh_stream *stream, return 0; } + if (stream->type == STREAM_VIDEO && !dp->len) { + /* Video packets with size 0 are assumed to not correspond to frames, + * but to indicate the absence of a frame in formats like AVI + * that must have packets at fixed timestamp intervals. */ + talloc_free(dp); + return 1; + } + dp->stream = stream->index; dp->next = NULL; diff --git a/mpvcore/player/video.c b/mpvcore/player/video.c index a3fef6d53c..65fc81d92c 100644 --- a/mpvcore/player/video.c +++ b/mpvcore/player/video.c @@ -295,16 +295,7 @@ double update_video(struct MPContext *mpctx, double endpts) while (1) { if (load_next_vo_frame(mpctx, false)) break; - struct demux_packet *pkt = NULL; - while (1) { - pkt = demux_read_packet(d_video->header); - if (!pkt || pkt->len) - break; - /* Packets with size 0 are assumed to not correspond to frames, - * but to indicate the absence of a frame in formats like AVI - * that must have packets at fixed timecode intervals. */ - talloc_free(pkt); - } + struct demux_packet *pkt = demux_read_packet(d_video->header); if (pkt && pkt->pts != MP_NOPTS_VALUE) pkt->pts += mpctx->video_offset; if (pkt && pkt->pts >= mpctx->hrseek_pts - .005) |