diff mbox series

[FFmpeg-devel,05/41] avcodec/videodsp: Make ff_emulated_edge_mc_16 static

Message ID DB6PR0101MB2214D12B692F3EB9B76144D38FA79@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Superseded
Headers show
Series Stop including superseded functions for x64 | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt June 9, 2022, 11:54 p.m. UTC
Only ff_emulated_edge_mc_8() is used outside of lavc/videodsp.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/videodsp.c          | 4 ++++
 libavcodec/videodsp.h          | 1 -
 libavcodec/videodsp_template.c | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

Comments

Ronald S. Bultje June 10, 2022, 3:50 p.m. UTC | #1
Hi,

On Thu, Jun 9, 2022 at 7:56 PM Andreas Rheinhardt <
andreas.rheinhardt@outlook.com> wrote:

> Only ff_emulated_edge_mc_8() is used outside of lavc/videodsp.c.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/videodsp.c          | 4 ++++
>  libavcodec/videodsp.h          | 1 -
>  libavcodec/videodsp_template.c | 1 +
>  3 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/videodsp.c b/libavcodec/videodsp.c
> index 2198d46c15..02af046b81 100644
> --- a/libavcodec/videodsp.c
> +++ b/libavcodec/videodsp.c
> @@ -25,11 +25,15 @@
>  #include "videodsp.h"
>
>  #define BIT_DEPTH 8
> +#define STATIC
>  #include "videodsp_template.c"
> +#undef STATIC
>  #undef BIT_DEPTH
>
>  #define BIT_DEPTH 16
> +#define STATIC static
>  #include "videodsp_template.c"
> +#undef STATIC
>  #undef BIT_DEPTH
>
>  static void just_return(uint8_t *buf, ptrdiff_t stride, int h)
>
[..]

> diff --git a/libavcodec/videodsp_template.c
> b/libavcodec/videodsp_template.c
> index 55123a5844..8bc3290248 100644
> --- a/libavcodec/videodsp_template.c
> +++ b/libavcodec/videodsp_template.c
> @@ -20,6 +20,7 @@
>   */
>
>  #include "bit_depth_template.c"
> +STATIC
>  void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
>                                 ptrdiff_t buf_linesize,
>                                 ptrdiff_t src_linesize,
> --
> 2.34.1
>

This splits the "staticness" over two places (i.e. to understand what
STATIC means and/or why it exists, you have to look at two places), and
also doesn't explain why we need "variable staticness" (i.e. one being
static, but not the other one).

Maybe you could use the following:

#if BIT_DEPTH != 8 // we make a call to the 8-bit version in
$fill_me_in_here$
static
#endif
void FUNC(ff_..

That way the meaning of STATIC is not obfuscated (I know, STATIC should be
obvious, but it's still an indirection) and the reasoning is included also.

Ronald
Andreas Rheinhardt June 10, 2022, 4:07 p.m. UTC | #2
Ronald S. Bultje:
> Hi,
> 
> On Thu, Jun 9, 2022 at 7:56 PM Andreas Rheinhardt <
> andreas.rheinhardt@outlook.com> wrote:
> 
>> Only ff_emulated_edge_mc_8() is used outside of lavc/videodsp.c.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  libavcodec/videodsp.c          | 4 ++++
>>  libavcodec/videodsp.h          | 1 -
>>  libavcodec/videodsp_template.c | 1 +
>>  3 files changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/videodsp.c b/libavcodec/videodsp.c
>> index 2198d46c15..02af046b81 100644
>> --- a/libavcodec/videodsp.c
>> +++ b/libavcodec/videodsp.c
>> @@ -25,11 +25,15 @@
>>  #include "videodsp.h"
>>
>>  #define BIT_DEPTH 8
>> +#define STATIC
>>  #include "videodsp_template.c"
>> +#undef STATIC
>>  #undef BIT_DEPTH
>>
>>  #define BIT_DEPTH 16
>> +#define STATIC static
>>  #include "videodsp_template.c"
>> +#undef STATIC
>>  #undef BIT_DEPTH
>>
>>  static void just_return(uint8_t *buf, ptrdiff_t stride, int h)
>>
> [..]
> 
>> diff --git a/libavcodec/videodsp_template.c
>> b/libavcodec/videodsp_template.c
>> index 55123a5844..8bc3290248 100644
>> --- a/libavcodec/videodsp_template.c
>> +++ b/libavcodec/videodsp_template.c
>> @@ -20,6 +20,7 @@
>>   */
>>
>>  #include "bit_depth_template.c"
>> +STATIC
>>  void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
>>                                 ptrdiff_t buf_linesize,
>>                                 ptrdiff_t src_linesize,
>> --
>> 2.34.1
>>
> 
> This splits the "staticness" over two places (i.e. to understand what
> STATIC means and/or why it exists, you have to look at two places), and
> also doesn't explain why we need "variable staticness" (i.e. one being
> static, but not the other one).
> 
> Maybe you could use the following:
> 
> #if BIT_DEPTH != 8 // we make a call to the 8-bit version in
> $fill_me_in_here$
> static
> #endif
> void FUNC(ff_..
> 
> That way the meaning of STATIC is not obfuscated (I know, STATIC should be
> obvious, but it's still an indirection) and the reasoning is included also.
> 
> Ronald
> 

I'll change it if you prefer it that way.

- Andreas
diff mbox series

Patch

diff --git a/libavcodec/videodsp.c b/libavcodec/videodsp.c
index 2198d46c15..02af046b81 100644
--- a/libavcodec/videodsp.c
+++ b/libavcodec/videodsp.c
@@ -25,11 +25,15 @@ 
 #include "videodsp.h"
 
 #define BIT_DEPTH 8
+#define STATIC
 #include "videodsp_template.c"
+#undef STATIC
 #undef BIT_DEPTH
 
 #define BIT_DEPTH 16
+#define STATIC static
 #include "videodsp_template.c"
+#undef STATIC
 #undef BIT_DEPTH
 
 static void just_return(uint8_t *buf, ptrdiff_t stride, int h)
diff --git a/libavcodec/videodsp.h b/libavcodec/videodsp.h
index ac971dc57f..b5219d236c 100644
--- a/libavcodec/videodsp.h
+++ b/libavcodec/videodsp.h
@@ -36,7 +36,6 @@  void ff_emulated_edge_mc_ ## depth(uint8_t *dst, const uint8_t *src, \
                                    int src_x, int src_y, int w, int h);
 
 EMULATED_EDGE(8)
-EMULATED_EDGE(16)
 
 typedef struct VideoDSPContext {
     /**
diff --git a/libavcodec/videodsp_template.c b/libavcodec/videodsp_template.c
index 55123a5844..8bc3290248 100644
--- a/libavcodec/videodsp_template.c
+++ b/libavcodec/videodsp_template.c
@@ -20,6 +20,7 @@ 
  */
 
 #include "bit_depth_template.c"
+STATIC
 void FUNC(ff_emulated_edge_mc)(uint8_t *buf, const uint8_t *src,
                                ptrdiff_t buf_linesize,
                                ptrdiff_t src_linesize,