X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=ffplay.c;h=cf138dc51513eaba4f8392ba3e2288e4ddb64c14;hb=3796fb2692f87d0000fc0aa4572ac025a6469c2b;hp=7ea172f8dac9c796a96c5ddbf21dcdfce0acd8fd;hpb=b9292a9698375510c5668cde4ce80dea79d8ec02;p=ffmpeg diff --git a/ffplay.c b/ffplay.c index 7ea172f8dac..cf138dc5151 100644 --- a/ffplay.c +++ b/ffplay.c @@ -73,8 +73,8 @@ const int program_birth_year = 2003; /* Calculate actual buffer size keeping in mind not cause too frequent audio callbacks */ #define SDL_AUDIO_MAX_CALLBACKS_PER_SEC 30 -/* Step size for volume control */ -#define SDL_VOLUME_STEP (SDL_MIX_MAXVOLUME / 50) +/* Step size for volume control in dB */ +#define SDL_VOLUME_STEP (0.75) /* no AV sync correction is done if below the minimum AV sync threshold */ #define AV_SYNC_THRESHOLD_MIN 0.04 @@ -321,6 +321,7 @@ static int subtitle_disable; static const char* wanted_stream_spec[AVMEDIA_TYPE_NB] = {0}; static int seek_by_bytes = -1; static int display_disable; +static int borderless; static int startup_volume = 100; static int show_status = 1; static int av_sync_type = AV_SYNC_AUDIO_MASTER; @@ -1260,11 +1261,15 @@ static int video_open(VideoState *is) } if (!window) { - int flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; + int flags = SDL_WINDOW_SHOWN; if (!window_title) window_title = input_filename; if (is_full_screen) flags |= SDL_WINDOW_FULLSCREEN_DESKTOP; + if (borderless) + flags |= SDL_WINDOW_BORDERLESS; + else + flags |= SDL_WINDOW_RESIZABLE; window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, w, h, flags); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); if (window) { @@ -1445,9 +1450,11 @@ static void toggle_mute(VideoState *is) is->muted = !is->muted; } -static void update_volume(VideoState *is, int sign, int step) +static void update_volume(VideoState *is, int sign, double step) { - is->audio_volume = av_clip(is->audio_volume + sign * step, 0, SDL_MIX_MAXVOLUME); + double volume_level = is->audio_volume ? (20 * log(is->audio_volume / (double)SDL_MIX_MAXVOLUME) / log(10)) : -1000.0; + int new_volume = lrint(SDL_MIX_MAXVOLUME * pow(10.0, (volume_level + sign * step) / 20.0)); + is->audio_volume = av_clip(is->audio_volume == new_volume ? (is->audio_volume + sign) : new_volume, 0, SDL_MIX_MAXVOLUME); } static void step_to_next_frame(VideoState *is) @@ -3513,6 +3520,7 @@ static const OptionDef options[] = { { "t", HAS_ARG, { .func_arg = opt_duration }, "play \"duration\" seconds of audio/video", "duration" }, { "bytes", OPT_INT | HAS_ARG, { &seek_by_bytes }, "seek by bytes 0=off 1=on -1=auto", "val" }, { "nodisp", OPT_BOOL, { &display_disable }, "disable graphical display" }, + { "noborder", OPT_BOOL, { &borderless }, "borderless window" }, { "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" },