summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-19 18:35:11 +0100
committerwm4 <wm4@nowhere>2016-02-19 18:50:14 +0100
commit6640b22a8c0384972c2782efe4092968e09161c1 (patch)
tree263dacac3f82395177c439c6306806fba2054afd /video
parentb3804e71af34fa76e17d9bf6d6575383a3a4aa21 (diff)
downloadmpv-6640b22a8c0384972c2782efe4092968e09161c1.tar.bz2
mpv-6640b22a8c0384972c2782efe4092968e09161c1.tar.xz
video: allow the decoder to consume packets partially
This is in preparation for a hypothetical API change in libavcodec, which would allow the decoder to return multiple video frames before accepting a new input packet. In theory, the body of the if() added to vd_lavc.c could be replaced with this code: packet->buffer += ret; packet->len -= ret; but currently this is not needed, as libavformat already outputs one frame per packet. Also, using libavcodec this way could lead to a "deadlock" if the decoder refuses to consume e.g. garbage padding, so enabling this now would introduce bugs. (Adding this now for easier testing, and for symmetry with the audio code.)
Diffstat (limited to 'video')
-rw-r--r--video/decode/dec_video.c6
-rw-r--r--video/decode/vd_lavc.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index 42c7e873ad..80b5379d2d 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -412,8 +412,10 @@ void video_work(struct dec_video *d_video)
framedrop_type = 2;
}
d_video->current_mpi = decode_packet(d_video, d_video->packet, framedrop_type);
- talloc_free(d_video->packet); // always fully consumed
- d_video->packet = NULL;
+ if (d_video->packet && d_video->packet->len == 0) {
+ talloc_free(d_video->packet);
+ d_video->packet = NULL;
+ }
d_video->current_state = DATA_OK;
if (!d_video->current_mpi) {
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 19c05a9c2f..ed4b347392 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -702,6 +702,11 @@ static void decode(struct dec_video *vd, struct demux_packet *packet,
return;
}
+ if (packet) {
+ // always fully consumed
+ packet->len = 0;
+ }
+
// Skipped frame, or delayed output due to multithreaded decoding.
if (!got_picture) {
if (!packet)