Bläddra i källkod

deps/media-playback: Start decoding regardless of keyframe

Currently, when media-playback is used with a network address, video has
to wait for the first keyframe before it starts decoding.  This is
probably not wise because the first packet of video may contain
additional header information, and because audio is forced to wait and
buffer while waiting for a keyframe, potentially causing a lot of audio
to get backed up unnecessarily which could inadvertently cause sync or
audio playback issues.

So, instead of waiting for a keyframe before decoding starts, decode
right away, and make it wait for a keyframe before calling the video
callback instead.
jp9000 8 år sedan
förälder
incheckning
0302a4e7f7

+ 0 - 12
deps/media-playback/media-playback/decode.c

@@ -279,18 +279,6 @@ bool mp_decode_next(struct mp_decode *d)
 			}
 		}
 
-		if (!d->audio && d->m->is_network && !d->got_first_keyframe) {
-			if (d->pkt.flags & AV_PKT_FLAG_KEY) {
-				d->got_first_keyframe = true;
-			} else {
-				av_packet_unref(&d->orig_pkt);
-				av_init_packet(&d->orig_pkt);
-				av_init_packet(&d->pkt);
-				d->packet_pending = false;
-				return true;
-			}
-		}
-
 		ret = decode_packet(d, &got_frame);
 
 		if (!got_frame && ret == 0) {

+ 7 - 0
deps/media-playback/media-playback/media.c

@@ -357,6 +357,13 @@ static void mp_media_next_video(mp_media_t *m, bool preload)
 	frame->height = f->height;
 	frame->flip = flip;
 
+	if (m->is_network && !d->got_first_keyframe) {
+		if (!f->key_frame)
+			return;
+
+		d->got_first_keyframe = true;
+	}
+
 	if (preload)
 		m->v_preload_cb(m->opaque, frame);
 	else