[FFmpeg-devel] [PATCH] ffplay: add startup volume option
Ganesh Ajjanagadde
gajjanag at mit.edu
Sun Dec 25 23:36:25 EET 2016
25.12.2016, 13:31, "Marton Balint" <cus at passwd.hu>:
> On Sat, 24 Dec 2016, Ganesh Ajjanagadde wrote:
>
>> 24.12.2016, 20:00, "Marton Balint" <cus at passwd.hu>:
>>> On Thu, 22 Dec 2016, gajjanag at yandex.com wrote:
>>>
>>>> From: Ganesh Ajjanagadde <gajjanag at alum.mit.edu>
>>>>
>>>> Fixes Ticket 5389.
>>>>
>>>> Signed-off-by: Ganesh Ajjanagadde <gajjanag at alum.mit.edu>
>>>> ---
>>>> doc/ffplay.texi | 4 ++++
>>>> ffplay.c | 10 +++++++++-
>>>> 2 files changed, 13 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/doc/ffplay.texi b/doc/ffplay.texi
>>>> index 073b457256..378a229d67 100644
>>>> --- a/doc/ffplay.texi
>>>> +++ b/doc/ffplay.texi
>>>> @@ -62,6 +62,10 @@ see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1)
>>>> Seek by bytes.
>>>> @item -nodisp
>>>> Disable graphical display.
>>>> + at item -volume
>>>> +Set the startup volume. 0 means silence, 100 means no volume reduction or
>>>> +amplification. Negative values are treated as 0, values above 100 are treated
>>>> +as 100.
>>>> @item -f @var{fmt}
>>>> Force format.
>>>> @item -window_title @var{title}
>>>> diff --git a/ffplay.c b/ffplay.c
>>>> index 911fd7f947..de603c0a27 100644
>>>> --- a/ffplay.c
>>>> +++ b/ffplay.c
>>>> @@ -322,6 +322,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 startup_volume = 100;
>>>> static int show_status = 1;
>>>> static int av_sync_type = AV_SYNC_AUDIO_MASTER;
>>>> static int64_t start_time = AV_NOPTS_VALUE;
>>>> @@ -3105,7 +3106,13 @@ static VideoState *stream_open(const char *filename, AVInputFormat *iformat)
>>>> init_clock(&is->audclk, &is->audioq.serial);
>>>> init_clock(&is->extclk, &is->extclk.serial);
>>>> is->audio_clock_serial = -1;
>>>> - is->audio_volume = SDL_MIX_MAXVOLUME;
>>>> + if (startup_volume < 0)
>>>> + av_log(NULL, AV_LOG_WARNING, "-volume=%d < 0, setting to 0\n", startup_volume);
>>>> + if (startup_volume > 100)
>>>> + av_log(NULL, AV_LOG_WARNING, "-volume=%d > 100, setting to 100\n", startup_volume);
>>>> + startup_volume = av_clip(startup_volume, 0, 100);
>>>> + startup_volume = av_clip(SDL_MIX_MAXVOLUME * startup_volume / 100.0, 0, SDL_MIX_MAXVOLUME);
>>>
>>> Any reason you use 100.0 here instead of a simple integer (100)?
>>
>> Nothing really, I assumed (incorrectly) that double to int cast does rounding instead of truncation,
>> which happens with integer division.
>> On the other hand, the difference here between rounding and truncation is < 1%.
>> Whatever you prefer, i.e can lrint it to get better rounding, or change to 100 and not bother.
>
> I'd simply use 100 and not bother.
Pushed, thanks.
>
> Thanks,
> Marton
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list