From d872e1130092ba18f54131511d7ea64666878459 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 27 May 2012 14:43:53 +0200 Subject: [PATCH 1/4] ffplay: remove VideoPicture duration field We are not using it. Signed-off-by: Marton Balint --- ffplay.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ffplay.c b/ffplay.c index 779c87967a..708dab8d63 100644 --- a/ffplay.c +++ b/ffplay.c @@ -99,7 +99,6 @@ typedef struct PacketQueue { typedef struct VideoPicture { double pts; ///< presentation time stamp for this picture - double duration; ///< expected duration of the frame int64_t pos; ///< byte position in file int skip; SDL_Overlay *bmp; @@ -1194,13 +1193,8 @@ retry: if (is->pictq_size > 1) { VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE]; - duration = nextvp->pts - vp->pts; // More accurate this way, 1/time_base is often not reflecting FPS - } else { - duration = vp->duration; - } - - if((framedrop>0 || (framedrop && is->audio_st)) && time > is->frame_timer + duration){ - if(is->pictq_size > 1){ + duration = nextvp->pts - vp->pts; + if((framedrop>0 || (framedrop && is->audio_st)) && time > is->frame_timer + duration){ is->frame_drops_late++; pictq_next_picture(is); goto retry; @@ -1387,8 +1381,6 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_ vp = &is->pictq[is->pictq_windex]; - vp->duration = frame_delay; - /* alloc or resize hardware picture buffer */ if (!vp->bmp || vp->reallocate || vp->width != src_frame->width || From a6f51de3bf5110dad301bab625f67fc2172f286d Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Mon, 28 May 2012 21:42:52 +0200 Subject: [PATCH 2/4] ffplay: add pause audio feature in the middle of a packet Fixes ticket 215. Signed-off-by: Marton Balint --- ffplay.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ffplay.c b/ffplay.c index 708dab8d63..44ae931601 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2077,6 +2077,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) } else avcodec_get_frame_defaults(is->frame); + if (is->paused) + return -1; + if (flush_complete) break; new_packet = 0; From 15751e3fdd66f595f25692d180d6f154af2da11c Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Tue, 27 Mar 2012 22:28:28 +0200 Subject: [PATCH 3/4] ffplay: only request 4 or 6 channels from SDL, if SDL version is at least 1.2.8 Signed-off-by: Marton Balint --- ffplay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffplay.c b/ffplay.c index 44ae931601..2fae0e5996 100644 --- a/ffplay.c +++ b/ffplay.c @@ -2299,7 +2299,7 @@ static int stream_component_open(VideoState *is, int stream_index) wanted_channel_layout &= ~AV_CH_LAYOUT_STEREO_DOWNMIX; wanted_nb_channels = av_get_channel_layout_nb_channels(wanted_channel_layout); /* SDL only supports 1, 2, 4 or 6 channels at the moment, so we have to make sure not to request anything else. */ - while (wanted_nb_channels > 0 && (wanted_nb_channels == 3 || wanted_nb_channels == 5 || wanted_nb_channels > 6)) { + while (wanted_nb_channels > 0 && (wanted_nb_channels == 3 || wanted_nb_channels == 5 || wanted_nb_channels > (SDL_VERSION_ATLEAST(1, 2, 8) ? 6 : 2))) { wanted_nb_channels--; wanted_channel_layout = av_get_default_channel_layout(wanted_nb_channels); } From f1a75aa033db9e8beceb0b44d797decfc41fd469 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Tue, 29 May 2012 00:20:11 +0200 Subject: [PATCH 4/4] ffplay: remove VideoPicture pix_fmt and use frame pixel format instead VideoPicture pixel format is set at allocation time, therefore it is not reflecting the proper value. Fixes files with changing pixel format in the avfilter disabled case. Signed-off-by: Marton Balint --- ffplay.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ffplay.c b/ffplay.c index 2fae0e5996..260391fb7f 100644 --- a/ffplay.c +++ b/ffplay.c @@ -106,7 +106,6 @@ typedef struct VideoPicture { AVRational sample_aspect_ratio; int allocated; int reallocate; - enum PixelFormat pix_fmt; #if CONFIG_AVFILTER AVFilterBufferRef *picref; @@ -1320,7 +1319,6 @@ static void alloc_picture(AllocEventProps *event_props) vp->width = frame->width; vp->height = frame->height; - vp->pix_fmt = frame->format; video_open(event_props->is, 0); @@ -1441,12 +1439,12 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts1, int64_ #if CONFIG_AVFILTER // FIXME use direct rendering av_picture_copy(&pict, (AVPicture *)src_frame, - vp->pix_fmt, vp->width, vp->height); + src_frame->format, vp->width, vp->height); vp->sample_aspect_ratio = vp->picref->video->sample_aspect_ratio; #else sws_flags = av_get_int(sws_opts, "sws_flags", NULL); is->img_convert_ctx = sws_getCachedContext(is->img_convert_ctx, - vp->width, vp->height, vp->pix_fmt, vp->width, vp->height, + vp->width, vp->height, src_frame->format, vp->width, vp->height, PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL); if (is->img_convert_ctx == NULL) { fprintf(stderr, "Cannot initialize the conversion context\n");