[FFmpeg-devel] [PATCH 1/2] avfilter/transform: Stop exporting internal functions

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Thu Feb 25 02:31:55 EET 2021


James Almer:
> On 2/24/2021 11:22 AM, Andreas Rheinhardt wrote:
>> avfilter_transform, avfilter_(add|sub|mult)_matrix are not part of the
>> public API (transform.h is not a public header), yet they are currently
>> exported because of their name. This commit changes this:
>> avfilter_transform is renamed to ff_affine_transform; the other
>> functions are just removed as they have never been used at all.
> 
> The symbols are exported and have been in four releases so far for this
> soname. If we plan on making a 4.4 release before the bump, it may be a
> good idea if we keep the symbols around for the sake of not affecting
> the ABI, so I'm inclined towards just wrapping them in a
> LIBAVFILTER_VERSION_MAJOR < 8 check like we do when we remove avpriv ones.
> 

And why? There was never a legitimate outside user of these functions.
And removing avfilter_all_channel_layouts in
d5e5c6862bbc834d5a036a3fa053a7569d84f928 (which also didn't have a
legitimate outside user) didn't seem to break anything either.
Btw: 88d80cb97528d52dac3178cf5393d6095eca6200 broke ABI for x64, because
older versions of libavformat exchange a PutBitContext with libavcodec
via avpriv_align_put_bits and avpriv_copy_bits. So we can't really make
a 4.4 release.

- Andreas

>>
>> Found-by: Anton Khirnov <anton at khirnov.net>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
>> ---
>>   libavfilter/transform.c  | 23 +----------------------
>>   libavfilter/transform.h  | 29 +----------------------------
>>   libavfilter/vf_deshake.c |  5 +++--
>>   3 files changed, 5 insertions(+), 52 deletions(-)
>>
>> diff --git a/libavfilter/transform.c b/libavfilter/transform.c
>> index f4f9e0a47d..1f91436f73 100644
>> --- a/libavfilter/transform.c
>> +++ b/libavfilter/transform.c
>> @@ -122,28 +122,7 @@ void ff_get_matrix(
>>       matrix[8] = 1;
>>   }
>>   -void avfilter_add_matrix(const float *m1, const float *m2, float
>> *result)
>> -{
>> -    int i;
>> -    for (i = 0; i < 9; i++)
>> -        result[i] = m1[i] + m2[i];
>> -}
>> -
>> -void avfilter_sub_matrix(const float *m1, const float *m2, float
>> *result)
>> -{
>> -    int i;
>> -    for (i = 0; i < 9; i++)
>> -        result[i] = m1[i] - m2[i];
>> -}
>> -
>> -void avfilter_mul_matrix(const float *m1, float scalar, float *result)
>> -{
>> -    int i;
>> -    for (i = 0; i < 9; i++)
>> -        result[i] = m1[i] * scalar;
>> -}
>> -
>> -int avfilter_transform(const uint8_t *src, uint8_t *dst,
>> +int ff_affine_transform(const uint8_t *src, uint8_t *dst,
>>                           int src_stride, int dst_stride,
>>                           int width, int height, const float *matrix,
>>                           enum InterpolateMethod interpolate,
>> diff --git a/libavfilter/transform.h b/libavfilter/transform.h
>> index 9b0c19ceca..0344f9c228 100644
>> --- a/libavfilter/transform.h
>> +++ b/libavfilter/transform.h
>> @@ -83,33 +83,6 @@ void ff_get_matrix(
>>       float *matrix
>>   );
>>   -/**
>> - * Add two matrices together. result = m1 + m2.
>> - *
>> - * @param m1     9-item transformation matrix
>> - * @param m2     9-item transformation matrix
>> - * @param result 9-item transformation matrix
>> - */
>> -void avfilter_add_matrix(const float *m1, const float *m2, float
>> *result);
>> -
>> -/**
>> - * Subtract one matrix from another. result = m1 - m2.
>> - *
>> - * @param m1     9-item transformation matrix
>> - * @param m2     9-item transformation matrix
>> - * @param result 9-item transformation matrix
>> - */
>> -void avfilter_sub_matrix(const float *m1, const float *m2, float
>> *result);
>> -
>> -/**
>> - * Multiply a matrix by a scalar value. result = m1 * scalar.
>> - *
>> - * @param m1     9-item transformation matrix
>> - * @param scalar a number
>> - * @param result 9-item transformation matrix
>> - */
>> -void avfilter_mul_matrix(const float *m1, float scalar, float *result);
>> -
>>   /**
>>    * Do an affine transformation with the given interpolation method.
>> This
>>    * multiplies each vector [x,y,1] by the matrix and then
>> interpolates to
>> @@ -126,7 +99,7 @@ void avfilter_mul_matrix(const float *m1, float
>> scalar, float *result);
>>    * @param fill        edge fill method
>>    * @return negative on error
>>    */
>> -int avfilter_transform(const uint8_t *src, uint8_t *dst,
>> +int ff_affine_transform(const uint8_t *src, uint8_t *dst,
>>                           int src_stride, int dst_stride,
>>                           int width, int height, const float *matrix,
>>                           enum InterpolateMethod interpolate,
>> diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
>> index 28a541b94a..8771399351 100644
>> --- a/libavfilter/vf_deshake.c
>> +++ b/libavfilter/vf_deshake.c
>> @@ -330,8 +330,9 @@ static int deshake_transform_c(AVFilterContext *ctx,
>>         for (i = 0; i < 3; i++) {
>>           // Transform the luma and chroma planes
>> -        ret = avfilter_transform(in->data[i], out->data[i],
>> in->linesize[i], out->linesize[i],
>> -                                 plane_w[i], plane_h[i], matrixs[i],
>> interpolate, fill);
>> +        ret = ff_affine_transform(in->data[i], out->data[i],
>> in->linesize[i],
>> +                                  out->linesize[i], plane_w[i],
>> plane_h[i],
>> +                                  matrixs[i], interpolate, fill);
>>           if (ret < 0)
>>               return ret;
>>       }
>>
> 



More information about the ffmpeg-devel mailing list