[FFmpeg-devel] [PATCH 20/29] avformat/voc: Deduplicate codec tags list

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Thu Feb 18 05:42:05 EET 2021


Also saves a relocation.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
 libavformat/voc.c    | 8 ++++++--
 libavformat/voc.h    | 1 +
 libavformat/vocdec.c | 2 +-
 libavformat/vocenc.c | 2 +-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/libavformat/voc.c b/libavformat/voc.c
index 2a972344d3..89639a98c4 100644
--- a/libavformat/voc.c
+++ b/libavformat/voc.c
@@ -19,11 +19,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include "voc.h"
 #include "internal.h"
 
-const unsigned char ff_voc_magic[21] = "Creative Voice File\x1A";
-
 const AVCodecTag ff_voc_codec_tags[] = {
     {AV_CODEC_ID_PCM_U8,        0x00},
     {AV_CODEC_ID_ADPCM_SBPRO_4, 0x01},
@@ -35,3 +34,8 @@ const AVCodecTag ff_voc_codec_tags[] = {
     {AV_CODEC_ID_ADPCM_CT,    0x0200},
     {AV_CODEC_ID_NONE,             0},
 };
+
+#if CONFIG_VOC_DEMUXER || CONFIG_VOC_MUXER
+const unsigned char ff_voc_magic[21] = "Creative Voice File\x1A";
+const AVCodecTag *const ff_voc_codec_tags_list[] = { ff_voc_codec_tags, NULL };
+#endif
diff --git a/libavformat/voc.h b/libavformat/voc.h
index 1f9a8be000..1fc6bb4227 100644
--- a/libavformat/voc.h
+++ b/libavformat/voc.h
@@ -45,6 +45,7 @@ typedef enum voc_type {
 
 extern const unsigned char ff_voc_magic[21];
 extern const AVCodecTag ff_voc_codec_tags[];
+extern const AVCodecTag *const ff_voc_codec_tags_list[];
 
 int ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt,
                       AVStream *st, int max_size);
diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c
index d388fce92e..6cdc720ee7 100644
--- a/libavformat/vocdec.c
+++ b/libavformat/vocdec.c
@@ -106,5 +106,5 @@ AVInputFormat ff_voc_demuxer = {
     .read_header    = voc_read_header,
     .read_packet    = voc_read_packet,
     .read_seek      = voc_read_seek,
-    .codec_tag      = (const AVCodecTag* const []){ ff_voc_codec_tags, 0 },
+    .codec_tag      = ff_voc_codec_tags_list,
 };
diff --git a/libavformat/vocenc.c b/libavformat/vocenc.c
index 321b113032..bdc63843c4 100644
--- a/libavformat/vocenc.c
+++ b/libavformat/vocenc.c
@@ -106,6 +106,6 @@ AVOutputFormat ff_voc_muxer = {
     .write_header      = voc_write_header,
     .write_packet      = voc_write_packet,
     .write_trailer     = voc_write_trailer,
-    .codec_tag         = (const AVCodecTag* const []){ ff_voc_codec_tags, 0 },
+    .codec_tag         = ff_voc_codec_tags_list,
     .flags             = AVFMT_NOTIMESTAMPS,
 };
-- 
2.27.0



More information about the ffmpeg-devel mailing list