[FFmpeg-devel] [PATCH] swresample fixes

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Wed Jan 4 19:37:58 EET 2023


Paul B Mahol:
> On Wed, Jan 4, 2023 at 6:26 PM Andreas Rheinhardt <
> andreas.rheinhardt at outlook.com> wrote:
> 
>> Paul B Mahol:
>>> diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c
>>> index 7923377c8c..2744388f75 100644
>>> --- a/libavfilter/af_aresample.c
>>> +++ b/libavfilter/af_aresample.c
>>> @@ -209,8 +209,14 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>>      } else {
>>>          outsamplesref->pts  = AV_NOPTS_VALUE;
>>>      }
>>> +again:
>>>      ret = swr_convert_frame(aresample->swr, outsamplesref,
>>>                              (void *)insamplesref);
>>> +    if (ret & (AVERROR_INPUT_CHANGED | AVERROR_OUTPUT_CHANGED)) {
>>
>> This is wrong: There are lots of errors besides AVERROR_INPUT_CHANGED,
>> AVERROR_OUTPUT_CHANGED and AVERROR_INPUT_CHANGED |
>> AVERROR_OUTPUT_CHANGED for which this condition is true. See also ticket
>> #9343.
>>
> 
> So what you propose?
> 

The only check way I see to do this is to check for ret ==
AVERROR_INPUT_CHANGED || ret == AVERROR_OUTPUT_CHANGED || ret ==
(AVERROR_INPUT_CHANGED | AVERROR_OUTPUT_CHANGED) (the latter value is
equal to AVERROR_INPUT_CHANGED). This should be done in the ret < 0
codepath.

("lots of errors" is btw an understatement: All errors are < 0 and
therefore have the sign bit set.)

> 
>>
>>> +        swr_close(aresample->swr);
>>> +        goto again;
>>> +    }
>>> +
>>>      if (ret < 0) {
>>>          av_frame_free(&outsamplesref);
>>>          av_frame_free(&insamplesref);
>>
>>



More information about the ffmpeg-devel mailing list