diff mbox

[FFmpeg-devel] doc/examples/encode_audio: Favor a sample rate close to 44khz instead of the maximum sample rate

Message ID 20170330131219.11817-1-michael@niedermayer.cc
State Accepted
Commit 59b8c2a4e668d129dedfab696cd8c07f5103343c
Headers show

Commit Message

Michael Niedermayer March 30, 2017, 1:12 p.m. UTC
This is an example, people will copy and use this. The maximum supported is quite
unreasonable as a default choice

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 doc/examples/encode_audio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Steven Liu March 30, 2017, 1:37 p.m. UTC | #1
2017-03-30 21:12 GMT+08:00 Michael Niedermayer <michael@niedermayer.cc>:

> This is an example, people will copy and use this. The maximum supported
> is quite
> unreasonable as a default choice
>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  doc/examples/encode_audio.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/doc/examples/encode_audio.c b/doc/examples/encode_audio.c
> index 88d0a6fd46..ba9ef6ddb8 100644
> --- a/doc/examples/encode_audio.c
> +++ b/doc/examples/encode_audio.c
> @@ -62,7 +62,8 @@ static int select_sample_rate(const AVCodec *codec)
>
>      p = codec->supported_samplerates;
>      while (*p) {
> -        best_samplerate = FFMAX(*p, best_samplerate);
> +        if (!best_samplerate || abs(44100 - *p) < abs(44100 -
> best_samplerate))
> +            best_samplerate = *p;
>          p++;
>      }
>      return best_samplerate;
> --
> 2.11.0
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



LGTM
Michael Niedermayer March 30, 2017, 2:17 p.m. UTC | #2
On Thu, Mar 30, 2017 at 09:37:34PM +0800, Steven Liu wrote:
> 2017-03-30 21:12 GMT+08:00 Michael Niedermayer <michael@niedermayer.cc>:
> 
> > This is an example, people will copy and use this. The maximum supported
> > is quite
> > unreasonable as a default choice
> >
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> >  doc/examples/encode_audio.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/doc/examples/encode_audio.c b/doc/examples/encode_audio.c
> > index 88d0a6fd46..ba9ef6ddb8 100644
> > --- a/doc/examples/encode_audio.c
> > +++ b/doc/examples/encode_audio.c
> > @@ -62,7 +62,8 @@ static int select_sample_rate(const AVCodec *codec)
> >
> >      p = codec->supported_samplerates;
> >      while (*p) {
> > -        best_samplerate = FFMAX(*p, best_samplerate);
> > +        if (!best_samplerate || abs(44100 - *p) < abs(44100 -
> > best_samplerate))
> > +            best_samplerate = *p;
> >          p++;
> >      }
> >      return best_samplerate;
> > --
> > 2.11.0
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> 
> 
> LGTM

applied

thx

[...]
diff mbox

Patch

diff --git a/doc/examples/encode_audio.c b/doc/examples/encode_audio.c
index 88d0a6fd46..ba9ef6ddb8 100644
--- a/doc/examples/encode_audio.c
+++ b/doc/examples/encode_audio.c
@@ -62,7 +62,8 @@  static int select_sample_rate(const AVCodec *codec)
 
     p = codec->supported_samplerates;
     while (*p) {
-        best_samplerate = FFMAX(*p, best_samplerate);
+        if (!best_samplerate || abs(44100 - *p) < abs(44100 - best_samplerate))
+            best_samplerate = *p;
         p++;
     }
     return best_samplerate;