[FFmpeg-devel] [PATCH] swresample/swresample: check for invalid sample rates

Paul B Mahol onemda at gmail.com
Sat May 25 20:55:50 EEST 2019


On 5/25/19, Michael Niedermayer <michael at niedermayer.cc> wrote:
> On Fri, May 24, 2019 at 06:05:42PM +0200, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>>  libswresample/swresample.c | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/libswresample/swresample.c b/libswresample/swresample.c
>> index 6d28e6a798..1ac5ef9a30 100644
>> --- a/libswresample/swresample.c
>> +++ b/libswresample/swresample.c
>> @@ -164,6 +164,14 @@ av_cold int swr_init(struct SwrContext *s){
>>          return AVERROR(EINVAL);
>>      }
>>
>> +    if(s-> in_sample_rate <= 0){
>> +        av_log(s, AV_LOG_ERROR, "Requested input sample rate %d is
>> invalid\n", s->in_sample_rate);
>> +        return AVERROR(EINVAL);
>> +    }
>> +    if(s->out_sample_rate <= 0){
>> +        av_log(s, AV_LOG_ERROR, "Requested output sample rate %d is
>> invalid\n", s->out_sample_rate);
>> +        return AVERROR(EINVAL);
>> +    }
>
> probably ok
>
> Only hypothetical issue i could see is convering sample types or channel
> layout with unspecified sample rate, that is both 0.
> dont know if that works currently but it at least semantically would make
> sense

It does not work, it reach floating-point exception and crashes.
(outlink sample rate set to 0 and input sample rate set to 48000)

>
> Thanks
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> I know you won't believe me, but the highest form of Human Excellence is
> to question oneself and others. -- Socrates
>


More information about the ffmpeg-devel mailing list