summaryrefslogtreecommitdiffstats
path: root/video/decode/dec_video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-01-10 16:19:57 +0100
committerwm4 <wm4@nowhere>2017-01-10 16:20:02 +0100
commited937b6eca269c653fcaa39db14c2623dd3d2862 (patch)
tree461d31459f6ee3e14e95ce1b71e78e86d275444b /video/decode/dec_video.c
parent4e25feda0d5e084761a9935de7c1e592e86de94f (diff)
downloadmpv-ed937b6eca269c653fcaa39db14c2623dd3d2862.tar.bz2
mpv-ed937b6eca269c653fcaa39db14c2623dd3d2862.tar.xz
video: restructure decode loop
Basically change everything. Why does the code get larger? No idea.
Diffstat (limited to 'video/decode/dec_video.c')
-rw-r--r--video/decode/dec_video.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index 95ca49250b..79b706d1fd 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -251,15 +251,8 @@ static void fix_image_params(struct dec_video *d_video,
d_video->fixed_format = p;
}
-static struct mp_image *decode_packet(struct dec_video *d_video,
- struct demux_packet *packet,
- int drop_frame)
+static bool send_packet(struct dec_video *d_video, struct demux_packet *packet)
{
- struct MPOpts *opts = d_video->opts;
-
- if (!d_video->vd_driver)
- return NULL;
-
double pkt_pts = packet ? packet->pts : MP_NOPTS_VALUE;
double pkt_dts = packet ? packet->dts : MP_NOPTS_VALUE;
@@ -272,15 +265,26 @@ static struct mp_image *decode_packet(struct dec_video *d_video,
MP_STATS(d_video, "start decode video");
- struct mp_image *mpi = d_video->vd_driver->decode(d_video, packet, drop_frame);
+ bool res = d_video->vd_driver->send_packet(d_video, packet);
+
+ MP_STATS(d_video, "end decode video");
+
+ return res;
+}
+
+static struct mp_image *receive_frame(struct dec_video *d_video)
+{
+ struct MPOpts *opts = d_video->opts;
+
+ MP_STATS(d_video, "start decode video");
+
+ struct mp_image *mpi = d_video->vd_driver->receive_frame(d_video);
MP_STATS(d_video, "end decode video");
// Error, discarded frame, dropped frame, or initial codec delay.
- if (!mpi || drop_frame) {
- talloc_free(mpi);
+ if (!mpi)
return NULL;
- }
if (opts->field_dominance == 0) {
mpi->fields |= MP_IMGFIELD_TOP_FIRST | MP_IMGFIELD_INTERLACED;
@@ -378,7 +382,7 @@ void video_set_start(struct dec_video *d_video, double start_pts)
void video_work(struct dec_video *d_video)
{
- if (d_video->current_mpi)
+ if (d_video->current_mpi || !d_video->vd_driver)
return;
if (!d_video->packet && !d_video->new_segment &&
@@ -414,12 +418,16 @@ void video_work(struct dec_video *d_video)
{
framedrop_type = 2;
}
- d_video->current_mpi = decode_packet(d_video, d_video->packet, framedrop_type);
- if (d_video->packet && d_video->packet->len == 0) {
+
+ d_video->vd_driver->control(d_video, VDCTRL_SET_FRAMEDROP, &framedrop_type);
+
+ if (send_packet(d_video, d_video->packet)) {
talloc_free(d_video->packet);
d_video->packet = NULL;
}
+ d_video->current_mpi = receive_frame(d_video);
+
d_video->current_state = DATA_OK;
if (!d_video->current_mpi) {
d_video->current_state = DATA_EOF;