From 060c42bc3dff937df04f6d6166c43ab23e077ad6 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 13 Oct 2013 22:15:39 +0200 Subject: [PATCH 1/4] ffplay: update and extend documentation for channel and stream switching Signed-off-by: Marton Balint --- doc/ffplay.texi | 7 +++++-- ffplay.c | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/ffplay.texi b/doc/ffplay.texi index c465af7c86..54b6f19a48 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -174,13 +174,16 @@ Toggle full screen. Pause. @item a -Cycle audio channel. +Cycle audio channel in the curret program. @item v Cycle video channel. @item t -Cycle subtitle channel. +Cycle subtitle channel in the current program. + +@item c +Cycle program. @item w Show audio waves. diff --git a/ffplay.c b/ffplay.c index 8c0c415b4f..2930234a99 100644 --- a/ffplay.c +++ b/ffplay.c @@ -3500,9 +3500,9 @@ void show_help_default(const char *opt, const char *arg) "q, ESC quit\n" "f toggle full screen\n" "p, SPC pause\n" - "a cycle audio channel\n" + "a cycle audio channel in the current program\n" "v cycle video channel\n" - "t cycle subtitle channel\n" + "t cycle subtitle channel in the current program\n" "c cycle program\n" "w show audio waves\n" "s activate frame-step mode\n" From 2d059d8de1b4904c3a56ac99dc0badb870a50941 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sat, 19 Oct 2013 01:18:41 +0200 Subject: [PATCH 2/4] ffplay: factor out picture freeing code Signed-off-by: Marton Balint --- ffplay.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ffplay.c b/ffplay.c index 2930234a99..0be7414356 100644 --- a/ffplay.c +++ b/ffplay.c @@ -785,6 +785,14 @@ static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, } } +static void free_picture(VideoPicture *vp) +{ + if (vp->bmp) { + SDL_FreeYUVOverlay(vp->bmp); + vp->bmp = NULL; + } +} + static void free_subpicture(SubPicture *sp) { avsubtitle_free(&sp->sub); @@ -1013,7 +1021,6 @@ static void video_audio_display(VideoState *s) static void stream_close(VideoState *is) { - VideoPicture *vp; int i; /* XXX: use a special url_shutdown call to abort parse cleanly */ is->abort_request = 1; @@ -1023,13 +1030,8 @@ static void stream_close(VideoState *is) packet_queue_destroy(&is->subtitleq); /* free all pictures */ - for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) { - vp = &is->pictq[i]; - if (vp->bmp) { - SDL_FreeYUVOverlay(vp->bmp); - vp->bmp = NULL; - } - } + for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) + free_picture(&is->pictq[i]); for (i = 0; i < SUBPICTURE_QUEUE_SIZE; i++) free_subpicture(&is->subpq[i]); SDL_DestroyMutex(is->pictq_mutex); @@ -1505,8 +1507,7 @@ static void alloc_picture(VideoState *is) vp = &is->pictq[is->pictq_windex]; - if (vp->bmp) - SDL_FreeYUVOverlay(vp->bmp); + free_picture(vp); video_open(is, 0, vp); From 04de0e04c5d0e9298dc020dbdd02b72f6b6d61b7 Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sat, 19 Oct 2013 17:25:57 +0200 Subject: [PATCH 3/4] ffplay: use av_frame_get_pkt_pos instead directly accessing pkt pos Signed-off-by: Marton Balint --- ffplay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ffplay.c b/ffplay.c index 0be7414356..54764c6bba 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1715,7 +1715,7 @@ static int get_video_frame(VideoState *is, AVFrame *frame, AVPacket *pkt, int *s !isnan(ptsdiff) && ptsdiff > 0 && ptsdiff < AV_NOSYNC_THRESHOLD && clockdiff + ptsdiff - is->frame_last_filter_delay < 0 && is->videoq.nb_packets) { - is->frame_last_dropped_pos = pkt->pos; + is->frame_last_dropped_pos = av_frame_get_pkt_pos(frame); is->frame_last_dropped_pts = dpts; is->frame_last_dropped_serial = *serial; is->frame_drops_early++; @@ -1983,7 +1983,7 @@ static int video_thread(void *arg) } #else pts = (frame->pts == AV_NOPTS_VALUE) ? NAN : frame->pts * av_q2d(is->video_st->time_base); - ret = queue_picture(is, frame, pts, pkt.pos, serial); + ret = queue_picture(is, frame, pts, av_frame_get_pkt_pos(frame), serial); av_frame_unref(frame); #endif From 44758b4d17f6bcdfca74d329ad2fcff3e930bdbd Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 20 Oct 2013 13:10:36 +0200 Subject: [PATCH 4/4] ffplay: add support for libswresample options Signed-off-by: Marton Balint --- ffplay.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ffplay.c b/ffplay.c index 54764c6bba..5d3d18946e 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1833,6 +1833,8 @@ static int configure_audio_filters(VideoState *is, const char *afilters, int for int64_t channel_layouts[2] = { 0, -1 }; int channels[2] = { 0, -1 }; AVFilterContext *filt_asrc = NULL, *filt_asink = NULL; + char aresample_swr_opts[512] = ""; + AVDictionaryEntry *e = NULL; char asrc_args[256]; int ret; @@ -1840,6 +1842,12 @@ static int configure_audio_filters(VideoState *is, const char *afilters, int for if (!(is->agraph = avfilter_graph_alloc())) return AVERROR(ENOMEM); + while ((e = av_dict_get(swr_opts, "", e, AV_DICT_IGNORE_SUFFIX))) + av_strlcatf(aresample_swr_opts, sizeof(aresample_swr_opts), "%s=%s:", e->key, e->value); + if (strlen(aresample_swr_opts)) + aresample_swr_opts[strlen(aresample_swr_opts)-1] = '\0'; + av_opt_set(is->agraph, "aresample_swr_opts", aresample_swr_opts, 0); + ret = snprintf(asrc_args, sizeof(asrc_args), "sample_rate=%d:sample_fmt=%s:channels=%d:time_base=%d/%d", is->audio_filter_src.freq, av_get_sample_fmt_name(is->audio_filter_src.fmt),