diff mbox series

[FFmpeg-devel,9/9] avcodec/ffv1: Move ffv1_template.c inclusion to dec/enc templates

Message ID GV1P250MB0737BFBF0D0D054EECE89C428F269@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit a5e59fec071b1b94d8e2792e3f982ed4040b8708
Headers show
Series [FFmpeg-devel,1/9] avcodec/(ffv1|h264|png|snow)dec: Remove comment out DRAW_HORIZ_BAND cap | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 16, 2022, 8:46 p.m. UTC
Both the FFV1 decoder and encoder use a template of their own
to generate code multiple times. They also use a common template,
used by both decoder and encoder templates which is currently
instantiated in ffv1.h (and therefore also in ffv1.c, which
doesn't need it at all).

All these templates have the prerequisite that two macros
are defined, namely RENAME() and TYPE. The codec-specific
templates call the functions generated via the common template
via the RENAME() macro and therefore the macros used for
the common template must coincide with the macros used for
the codec-specific templates. But then it is better to not
instantiate the common template in ffv1.h, but in the codec
specific templates.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/ffv1.h             | 12 ------------
 libavcodec/ffv1dec_template.c |  2 ++
 libavcodec/ffv1enc_template.c |  2 ++
 3 files changed, 4 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 3532815501..005f308784 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -182,16 +182,4 @@  static inline void update_vlc_state(VlcState *const state, const int v)
     state->count = count;
 }
 
-#define TYPE int16_t
-#define RENAME(name) name
-#include "ffv1_template.c"
-#undef TYPE
-#undef RENAME
-
-#define TYPE int32_t
-#define RENAME(name) name ## 32
-#include "ffv1_template.c"
-#undef TYPE
-#undef RENAME
-
 #endif /* AVCODEC_FFV1_H */
diff --git a/libavcodec/ffv1dec_template.c b/libavcodec/ffv1dec_template.c
index 9b1d65e825..590ccac022 100644
--- a/libavcodec/ffv1dec_template.c
+++ b/libavcodec/ffv1dec_template.c
@@ -20,6 +20,8 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "ffv1_template.c"
+
 static av_always_inline int RENAME(decode_line)(FFV1Context *s, int w,
                                                  TYPE *sample[2],
                                                  int plane_index, int bits)
diff --git a/libavcodec/ffv1enc_template.c b/libavcodec/ffv1enc_template.c
index 8a4a387923..8953dbe07c 100644
--- a/libavcodec/ffv1enc_template.c
+++ b/libavcodec/ffv1enc_template.c
@@ -20,6 +20,8 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "ffv1_template.c"
+
 static av_always_inline int RENAME(encode_line)(FFV1Context *s, int w,
                                                 TYPE *sample[3],
                                                 int plane_index, int bits)