X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=fftools%2Fffplay.c;h=d673b8049a681854464b826d70bdf05afe22c584;hb=1779f0b12e112dfd993be1206a0891a47f9bf804;hp=8f050e16e64b6f15e09619f37ddad1fbf88f2bbc;hpb=34a0a9746b2f441db7c45983838a88aa87a33834;p=ffmpeg diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 8f050e16e64..d673b8049a6 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -40,6 +40,7 @@ #include "libavutil/samplefmt.h" #include "libavutil/avassert.h" #include "libavutil/time.h" +#include "libavutil/bprint.h" #include "libavformat/avformat.h" #include "libavdevice/avdevice.h" #include "libswscale/swscale.h" @@ -324,8 +325,9 @@ static int seek_by_bytes = -1; static float seek_interval = 10; static int display_disable; static int borderless; +static int alwaysontop; static int startup_volume = 100; -static int show_status = 1; +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; @@ -643,7 +645,10 @@ static int decoder_decode_frame(Decoder *d, AVFrame *frame, AVSubtitle *sub) { if (packet_queue_get(d->queue, &pkt, 1, &d->pkt_serial) < 0) return -1; } - } while (d->queue->serial != d->pkt_serial); + if (d->queue->serial == d->pkt_serial) + break; + av_packet_unref(&pkt); + } while (1); if (pkt.data == flush_pkt.data) { avcodec_flush_buffers(d->avctx); @@ -1688,6 +1693,7 @@ display: } is->force_refresh = 0; if (show_status) { + AVBPrint buf; static int64_t last_time; int64_t cur_time; int aqsize, vqsize, sqsize; @@ -1711,18 +1717,28 @@ display: av_diff = get_master_clock(is) - get_clock(&is->vidclk); else if (is->audio_st) av_diff = get_master_clock(is) - get_clock(&is->audclk); - av_log(NULL, AV_LOG_INFO, - "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r", - get_master_clock(is), - (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? "M-A" : " ")), - av_diff, - is->frame_drops_early + is->frame_drops_late, - aqsize / 1024, - vqsize / 1024, - sqsize, - is->video_st ? is->viddec.avctx->pts_correction_num_faulty_dts : 0, - is->video_st ? is->viddec.avctx->pts_correction_num_faulty_pts : 0); - fflush(stdout); + + av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC); + av_bprintf(&buf, + "%7.2f %s:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r", + get_master_clock(is), + (is->audio_st && is->video_st) ? "A-V" : (is->video_st ? "M-V" : (is->audio_st ? "M-A" : " ")), + av_diff, + is->frame_drops_early + is->frame_drops_late, + aqsize / 1024, + vqsize / 1024, + sqsize, + is->video_st ? is->viddec.avctx->pts_correction_num_faulty_dts : 0, + is->video_st ? is->viddec.avctx->pts_correction_num_faulty_pts : 0); + + if (show_status == 1 && AV_LOG_INFO > av_log_get_level()) + fprintf(stderr, "%s", buf.str); + else + av_log(NULL, AV_LOG_INFO, "%s", buf.str); + + fflush(stderr); + av_bprint_finalize(&buf, NULL); + last_time = cur_time; } } @@ -2759,9 +2775,6 @@ static int read_thread(void *arg) } memset(st_index, -1, sizeof(st_index)); - is->last_video_stream = is->video_stream = -1; - is->last_audio_stream = is->audio_stream = -1; - is->last_subtitle_stream = is->subtitle_stream = -1; is->eof = 0; ic = avformat_alloc_context(); @@ -2973,7 +2986,7 @@ static int read_thread(void *arg) } if (is->queue_attachments_req) { if (is->video_st && is->video_st->disposition & AV_DISPOSITION_ATTACHED_PIC) { - AVPacket copy = { 0 }; + AVPacket copy; if ((ret = av_packet_ref(©, &is->video_st->attached_pic)) < 0) goto fail; packet_queue_put(&is->videoq, ©); @@ -3067,6 +3080,9 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat) is = av_mallocz(sizeof(VideoState)); if (!is) return NULL; + is->last_video_stream = is->video_stream = -1; + is->last_audio_stream = is->audio_stream = -1; + is->last_subtitle_stream = is->subtitle_stream = -1; is->filename = av_strdup(filename); if (!is->filename) goto fail; @@ -3435,7 +3451,7 @@ static void event_loop(VideoState *cur_stream) break; case SDL_WINDOWEVENT: switch (event.window.event) { - case SDL_WINDOWEVENT_RESIZED: + case SDL_WINDOWEVENT_SIZE_CHANGED: screen_width = cur_stream->width = event.window.data1; screen_height = cur_stream->height = event.window.data2; if (cur_stream->vis_texture) { @@ -3581,6 +3597,7 @@ static const OptionDef options[] = { { "seek_interval", OPT_FLOAT | HAS_ARG, { &seek_interval }, "set seek interval for left/right keys, in seconds", "seconds" }, { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" }, { "noborder", OPT_BOOL, { &borderless }, "borderless window" }, + { "alwaysontop", OPT_BOOL, { &alwaysontop }, "window always on top" }, { "volume", OPT_INT | HAS_ARG, { &startup_volume}, "set startup volume 0=min 100=max", "volume" }, { "f", HAS_ARG, { .func_arg = opt_format }, "force format", "fmt" }, { "pix_fmt", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_frame_pix_fmt }, "set pixel format", "format" }, @@ -3722,6 +3739,12 @@ int main(int argc, char **argv) if (!display_disable) { int flags = SDL_WINDOW_HIDDEN; + if (alwaysontop) +#if SDL_VERSION_ATLEAST(2,0,5) + flags |= SDL_WINDOW_ALWAYS_ON_TOP; +#else + av_log(NULL, AV_LOG_WARNING, "Your SDL version doesn't support SDL_WINDOW_ALWAYS_ON_TOP. Feature will be inactive.\n"); +#endif if (borderless) flags |= SDL_WINDOW_BORDERLESS; else