X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=avplay.c;h=2db892849b94b1ae15d75bc8aeb1b1de0f4579d2;hb=4aa80808bcc2a30fcd7ce5b38594319df3a85b36;hp=ba59a8c0fc636f34bac1152eaa85c1f913f49f2b;hpb=26a44143efb513a602542fb59aee87b1fc62af51;p=ffmpeg diff --git a/avplay.c b/avplay.c index ba59a8c0fc6..2db892849b9 100644 --- a/avplay.c +++ b/avplay.c @@ -23,6 +23,8 @@ #include #include #include +#include + #include "libavutil/avstring.h" #include "libavutil/colorspace.h" #include "libavutil/mathematics.h" @@ -242,7 +244,6 @@ static int show_status = 1; static int av_sync_type = AV_SYNC_AUDIO_MASTER; static int64_t start_time = AV_NOPTS_VALUE; static int64_t duration = AV_NOPTS_VALUE; -static int debug_mv = 0; static int step = 0; static int workaround_bugs = 1; static int fast = 0; @@ -847,7 +848,8 @@ static void video_audio_display(VideoState *s) } av_rdft_calc(s->rdft, data[ch]); } - // least efficient way to do this, we should of course directly access it but its more than fast enough + /* Least efficient way to do this, we should of course + * directly access it but it is more than fast enough. */ for (y = 0; y < s->height; y++) { double w = 1 / sqrt(nb_freq); int a = sqrt(w * sqrt(data[0][2 * y + 0] * data[0][2 * y + 0] + data[0][2 * y + 1] * data[0][2 * y + 1])); @@ -1321,6 +1323,8 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts, int64_t vp = &is->pictq[is->pictq_windex]; + vp->sar = src_frame->sample_aspect_ratio; + /* alloc or resize hardware picture buffer */ if (!vp->bmp || vp->reallocate || #if CONFIG_AVFILTER @@ -1842,10 +1846,9 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) int resample_changed, audio_resample; if (!is->frame) { - if (!(is->frame = avcodec_alloc_frame())) + if (!(is->frame = av_frame_alloc())) return AVERROR(ENOMEM); - } else - avcodec_get_frame_defaults(is->frame); + } if (flush_complete) break; @@ -2035,7 +2038,6 @@ static int stream_component_open(VideoState *is, int stream_index) opts = filter_codec_opts(codec_opts, avctx->codec_id, ic, ic->streams[stream_index], NULL); codec = avcodec_find_decoder(avctx->codec_id); - avctx->debug_mv = debug_mv; avctx->workaround_bugs = workaround_bugs; avctx->idct_algo = idct; avctx->skip_frame = skip_frame; @@ -2151,7 +2153,7 @@ static void stream_component_close(VideoState *is, int stream_index) avresample_free(&is->avr); av_freep(&is->audio_buf1); is->audio_buf = NULL; - avcodec_free_frame(&is->frame); + av_frame_free(&is->frame); if (is->rdft) { av_rdft_end(is->rdft); @@ -2601,6 +2603,33 @@ static void toggle_audio_display(void) } } +static void seek_chapter(VideoState *is, int incr) +{ + int64_t pos = get_master_clock(is) * AV_TIME_BASE; + int i; + + if (!is->ic->nb_chapters) + return; + + /* find the current chapter */ + for (i = 0; i < is->ic->nb_chapters; i++) { + AVChapter *ch = is->ic->chapters[i]; + if (av_compare_ts(pos, AV_TIME_BASE_Q, ch->start, ch->time_base) < 0) { + i--; + break; + } + } + + i += incr; + i = FFMAX(i, 0); + if (i >= is->ic->nb_chapters) + return; + + av_log(NULL, AV_LOG_VERBOSE, "Seeking to chapter %d.\n", i); + stream_seek(is, av_rescale_q(is->ic->chapters[i]->start, is->ic->chapters[i]->time_base, + AV_TIME_BASE_Q), 0, 0); +} + /* handle an event sent by the GUI */ static void event_loop(void) { @@ -2646,6 +2675,12 @@ static void event_loop(void) case SDLK_w: toggle_audio_display(); break; + case SDLK_PAGEUP: + seek_chapter(cur_stream, 1); + break; + case SDLK_PAGEDOWN: + seek_chapter(cur_stream, -1); + break; case SDLK_LEFT: incr = -10.0; goto do_seek; @@ -2811,12 +2846,6 @@ static int opt_duration(void *optctx, const char *opt, const char *arg) return 0; } -static int opt_vismv(void *optctx, const char *opt, const char *arg) -{ - debug_mv = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); - return 0; -} - static const OptionDef options[] = { #include "cmdutils_common_opts.h" { "x", HAS_ARG, { .func_arg = opt_width }, "force displayed width", "width" }, @@ -2836,7 +2865,6 @@ static const OptionDef options[] = { { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" }, { "stats", OPT_BOOL | OPT_EXPERT, { &show_status }, "show status", "" }, { "bug", OPT_INT | HAS_ARG | OPT_EXPERT, { &workaround_bugs }, "workaround bugs", "" }, - { "vismv", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vismv }, "visualize motion vectors", "" }, { "fast", OPT_BOOL | OPT_EXPERT, { &fast }, "non spec compliant optimizations", "" }, { "genpts", OPT_BOOL | OPT_EXPERT, { &genpts }, "generate pts", "" }, { "drp", OPT_INT | HAS_ARG | OPT_EXPERT, { &decoder_reorder_pts }, "let decoder reorder pts 0=off 1=on -1=auto", ""},