diff mbox

[FFmpeg-devel,1/5] oma: move some constants into libavcodec

Message ID 20171222143512.92271-2-misty@brew.sh
State Superseded
Headers show

Commit Message

misty@brew.sh Dec. 22, 2017, 2:35 p.m. UTC
From: Misty De Meo <mistydemeo@gmail.com>

Most of the constants in libavcodec/oma aren't specific to
libavformat; moving them into libavcodec makes them available to
libavcodec as well as keeping them compatible with libavformat.

ff_oma_codec_tags uses a libavformat-specific type, so it has been
left in libavformat.
---
 Changelog             |  1 +
 libavcodec/oma.c      | 40 ++++++++++++++++++++++++++++++++++++++++
 libavcodec/oma.h      | 37 +++++++++++++++++++++++++++++++++++++
 libavcodec/version.h  |  2 +-
 libavformat/oma.c     | 18 ------------------
 libavformat/oma.h     | 13 +------------
 libavformat/omadec.c  |  1 +
 libavformat/omaenc.c  |  1 +
 libavformat/version.h |  2 +-
 9 files changed, 83 insertions(+), 32 deletions(-)
 create mode 100644 libavcodec/oma.c
 create mode 100644 libavcodec/oma.h

Comments

wm4 Dec. 22, 2017, 8:20 p.m. UTC | #1
On Fri, 22 Dec 2017 22:35:08 +0800
misty@brew.sh wrote:

> From: Misty De Meo <mistydemeo@gmail.com>
> 
> Most of the constants in libavcodec/oma aren't specific to
> libavformat; moving them into libavcodec makes them available to
> libavcodec as well as keeping them compatible with libavformat.
> 
> ff_oma_codec_tags uses a libavformat-specific type, so it has been
> left in libavformat.
> ---
>  Changelog             |  1 +
>  libavcodec/oma.c      | 40 ++++++++++++++++++++++++++++++++++++++++
>  libavcodec/oma.h      | 37 +++++++++++++++++++++++++++++++++++++
>  libavcodec/version.h  |  2 +-
>  libavformat/oma.c     | 18 ------------------
>  libavformat/oma.h     | 13 +------------
>  libavformat/omadec.c  |  1 +
>  libavformat/omaenc.c  |  1 +
>  libavformat/version.h |  2 +-
>  9 files changed, 83 insertions(+), 32 deletions(-)
>  create mode 100644 libavcodec/oma.c
>  create mode 100644 libavcodec/oma.h
> 
> diff --git a/Changelog b/Changelog
> index ee48876128..31e720091c 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -27,6 +27,7 @@ version <next>:
>  - video setrange filter
>  - nsp demuxer
>  - support LibreSSL (via libtls)
> +- Move some OMA constants from libavformat into libavcodec
>  
>  
>  version 3.4:
> diff --git a/libavcodec/oma.c b/libavcodec/oma.c
> new file mode 100644
> index 0000000000..dbc763f291
> --- /dev/null
> +++ b/libavcodec/oma.c
> @@ -0,0 +1,40 @@
> +/*
> + * Sony OpenMG (OMA) common data
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include "internal.h"
> +#include "oma.h"
> +#include "libavcodec/avcodec.h"
> +#include "libavutil/channel_layout.h"
> +
> +const uint16_t ff_oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 };
> +
> +/** map ATRAC-X channel id to internal channel layout */
> +const uint64_t ff_oma_chid_to_native_layout[7] = {
> +    AV_CH_LAYOUT_MONO,
> +    AV_CH_LAYOUT_STEREO,
> +    AV_CH_LAYOUT_SURROUND,
> +    AV_CH_LAYOUT_4POINT0,
> +    AV_CH_LAYOUT_5POINT1_BACK,
> +    AV_CH_LAYOUT_6POINT1_BACK,
> +    AV_CH_LAYOUT_7POINT1
> +};
> +
> +/** map ATRAC-X channel id to total number of channels */
> +const int ff_oma_chid_to_num_channels[7] = {1, 2, 3, 4, 6, 7, 8};
> diff --git a/libavcodec/oma.h b/libavcodec/oma.h
> new file mode 100644
> index 0000000000..7f6731839d
> --- /dev/null
> +++ b/libavcodec/oma.h
> @@ -0,0 +1,37 @@
> +/*
> + * Sony OpenMG (OMA) common data
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVCODEC_OMA_H
> +#define AVCODEC_OMA_H
> +
> +#include <stdint.h>
> +
> +#include "internal.h"
> +
> +#define EA3_HEADER_SIZE 96
> +#define ID3v2_EA3_MAGIC "ea3"
> +#define OMA_ENC_HEADER_SIZE 16
> +
> +extern const uint16_t ff_oma_srate_tab[8];
> +
> +extern const uint64_t ff_oma_chid_to_native_layout[7];
> +extern const int ff_oma_chid_to_num_channels[7];
> +
> +#endif /* AVCODEC_OMA_H */
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index d55de89797..d48857578d 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -29,7 +29,7 @@
>  
>  #define LIBAVCODEC_VERSION_MAJOR  58
>  #define LIBAVCODEC_VERSION_MINOR   8
> -#define LIBAVCODEC_VERSION_MICRO 100
> +#define LIBAVCODEC_VERSION_MICRO 101
>  
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
>                                                 LIBAVCODEC_VERSION_MINOR, \
> diff --git a/libavformat/oma.c b/libavformat/oma.c
> index f7ae3c9948..86347e6062 100644
> --- a/libavformat/oma.c
> +++ b/libavformat/oma.c
> @@ -20,10 +20,6 @@
>  
>  #include "internal.h"
>  #include "oma.h"
> -#include "libavcodec/avcodec.h"
> -#include "libavutil/channel_layout.h"
> -
> -const uint16_t ff_oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 };
>  
>  const AVCodecTag ff_oma_codec_tags[] = {
>      { AV_CODEC_ID_ATRAC3,      OMA_CODECID_ATRAC3    },
> @@ -34,17 +30,3 @@ const AVCodecTag ff_oma_codec_tags[] = {
>      { AV_CODEC_ID_ATRAC3AL,    OMA_CODECID_ATRAC3AL  },
>      { 0 },
>  };
> -
> -/** map ATRAC-X channel id to internal channel layout */
> -const uint64_t ff_oma_chid_to_native_layout[7] = {
> -    AV_CH_LAYOUT_MONO,
> -    AV_CH_LAYOUT_STEREO,
> -    AV_CH_LAYOUT_SURROUND,
> -    AV_CH_LAYOUT_4POINT0,
> -    AV_CH_LAYOUT_5POINT1_BACK,
> -    AV_CH_LAYOUT_6POINT1_BACK,
> -    AV_CH_LAYOUT_7POINT1
> -};
> -
> -/** map ATRAC-X channel id to total number of channels */
> -const int ff_oma_chid_to_num_channels[7] = {1, 2, 3, 4, 6, 7, 8};
> diff --git a/libavformat/oma.h b/libavformat/oma.h
> index 36fd0125e4..4417deeb4d 100644
> --- a/libavformat/oma.h
> +++ b/libavformat/oma.h
> @@ -21,14 +21,8 @@
>  #ifndef AVFORMAT_OMA_H
>  #define AVFORMAT_OMA_H
>  
> -#include <stdint.h>
> -
>  #include "internal.h"
>  
> -#define EA3_HEADER_SIZE 96
> -#define ID3v2_EA3_MAGIC "ea3"
> -#define OMA_ENC_HEADER_SIZE 16
> -
>  enum {
>      OMA_CODECID_ATRAC3  = 0,
>      OMA_CODECID_ATRAC3P = 1,
> @@ -39,11 +33,6 @@ enum {
>      OMA_CODECID_ATRAC3AL  = 34,
>  };
>  
> -extern const uint16_t ff_oma_srate_tab[8];
> -
>  extern const AVCodecTag ff_oma_codec_tags[];
>  
> -extern const uint64_t ff_oma_chid_to_native_layout[7];
> -extern const int ff_oma_chid_to_num_channels[7];
> -
> -#endif /* AVFORMAT_OMA_H */
> +#endif /* AVFORMAT_OMA_H */
> \ No newline at end of file
> diff --git a/libavformat/omadec.c b/libavformat/omadec.c
> index 423d52b3aa..ccefd6c1bc 100644
> --- a/libavformat/omadec.c
> +++ b/libavformat/omadec.c
> @@ -48,6 +48,7 @@
>  #include "libavutil/intreadwrite.h"
>  #include "libavutil/des.h"
>  #include "libavutil/mathematics.h"
> +#include "libavcodec/oma.h"
>  #include "oma.h"
>  #include "pcm.h"
>  #include "id3v2.h"
> diff --git a/libavformat/omaenc.c b/libavformat/omaenc.c
> index 7952808bf8..6e72c3ee85 100644
> --- a/libavformat/omaenc.c
> +++ b/libavformat/omaenc.c
> @@ -24,6 +24,7 @@
>  #include "avio_internal.h"
>  #include "id3v2.h"
>  #include "internal.h"
> +#include "libavcodec/oma.h"
>  #include "oma.h"
>  #include "rawenc.h"
>  
> diff --git a/libavformat/version.h b/libavformat/version.h
> index 5ced041f0a..6453d4559f 100644
> --- a/libavformat/version.h
> +++ b/libavformat/version.h
> @@ -33,7 +33,7 @@
>  // Also please add any ticket numbers that you believe might be affected here
>  #define LIBAVFORMAT_VERSION_MAJOR  58
>  #define LIBAVFORMAT_VERSION_MINOR   3
> -#define LIBAVFORMAT_VERSION_MICRO 100
> +#define LIBAVFORMAT_VERSION_MICRO 101
>  
>  #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
>                                                 LIBAVFORMAT_VERSION_MINOR, \

Currently you can't use ff_ symbols over library boundaries. You need
to use avpriv. In addition, avpriv need funny precautions due to
Windows DLL semantics.

I'm not sure what our preferred way to do such cross-library
dependencies.
misty@brew.sh Dec. 23, 2017, 5:42 a.m. UTC | #2
From: Misty De Meo <mistydemeo@gmail.com>

Thanks for the feedback! I checked in with #ffmpeg-devel on IRC, and
they suggested simply making them static consts in the headers since
they're small enough. Updated patch is included.

Misty De Meo (1):
  oma: move some constants into libavcodec

 Changelog                             |  1 +
 libavformat/oma.c => libavcodec/oma.h | 27 +++++++++++++--------------
 libavcodec/version.h                  |  2 +-
 libavformat/Makefile                  |  4 ++--
 libavformat/oma.h                     | 21 +++++++++------------
 libavformat/omadec.c                  |  1 +
 libavformat/omaenc.c                  |  1 +
 libavformat/version.h                 |  2 +-
 8 files changed, 29 insertions(+), 30 deletions(-)
 rename libavformat/oma.c => libavcodec/oma.h (65%)
diff mbox

Patch

diff --git a/Changelog b/Changelog
index ee48876128..31e720091c 100644
--- a/Changelog
+++ b/Changelog
@@ -27,6 +27,7 @@  version <next>:
 - video setrange filter
 - nsp demuxer
 - support LibreSSL (via libtls)
+- Move some OMA constants from libavformat into libavcodec
 
 
 version 3.4:
diff --git a/libavcodec/oma.c b/libavcodec/oma.c
new file mode 100644
index 0000000000..dbc763f291
--- /dev/null
+++ b/libavcodec/oma.c
@@ -0,0 +1,40 @@ 
+/*
+ * Sony OpenMG (OMA) common data
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "internal.h"
+#include "oma.h"
+#include "libavcodec/avcodec.h"
+#include "libavutil/channel_layout.h"
+
+const uint16_t ff_oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 };
+
+/** map ATRAC-X channel id to internal channel layout */
+const uint64_t ff_oma_chid_to_native_layout[7] = {
+    AV_CH_LAYOUT_MONO,
+    AV_CH_LAYOUT_STEREO,
+    AV_CH_LAYOUT_SURROUND,
+    AV_CH_LAYOUT_4POINT0,
+    AV_CH_LAYOUT_5POINT1_BACK,
+    AV_CH_LAYOUT_6POINT1_BACK,
+    AV_CH_LAYOUT_7POINT1
+};
+
+/** map ATRAC-X channel id to total number of channels */
+const int ff_oma_chid_to_num_channels[7] = {1, 2, 3, 4, 6, 7, 8};
diff --git a/libavcodec/oma.h b/libavcodec/oma.h
new file mode 100644
index 0000000000..7f6731839d
--- /dev/null
+++ b/libavcodec/oma.h
@@ -0,0 +1,37 @@ 
+/*
+ * Sony OpenMG (OMA) common data
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_OMA_H
+#define AVCODEC_OMA_H
+
+#include <stdint.h>
+
+#include "internal.h"
+
+#define EA3_HEADER_SIZE 96
+#define ID3v2_EA3_MAGIC "ea3"
+#define OMA_ENC_HEADER_SIZE 16
+
+extern const uint16_t ff_oma_srate_tab[8];
+
+extern const uint64_t ff_oma_chid_to_native_layout[7];
+extern const int ff_oma_chid_to_num_channels[7];
+
+#endif /* AVCODEC_OMA_H */
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d55de89797..d48857578d 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@ 
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR   8
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavformat/oma.c b/libavformat/oma.c
index f7ae3c9948..86347e6062 100644
--- a/libavformat/oma.c
+++ b/libavformat/oma.c
@@ -20,10 +20,6 @@ 
 
 #include "internal.h"
 #include "oma.h"
-#include "libavcodec/avcodec.h"
-#include "libavutil/channel_layout.h"
-
-const uint16_t ff_oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 };
 
 const AVCodecTag ff_oma_codec_tags[] = {
     { AV_CODEC_ID_ATRAC3,      OMA_CODECID_ATRAC3    },
@@ -34,17 +30,3 @@  const AVCodecTag ff_oma_codec_tags[] = {
     { AV_CODEC_ID_ATRAC3AL,    OMA_CODECID_ATRAC3AL  },
     { 0 },
 };
-
-/** map ATRAC-X channel id to internal channel layout */
-const uint64_t ff_oma_chid_to_native_layout[7] = {
-    AV_CH_LAYOUT_MONO,
-    AV_CH_LAYOUT_STEREO,
-    AV_CH_LAYOUT_SURROUND,
-    AV_CH_LAYOUT_4POINT0,
-    AV_CH_LAYOUT_5POINT1_BACK,
-    AV_CH_LAYOUT_6POINT1_BACK,
-    AV_CH_LAYOUT_7POINT1
-};
-
-/** map ATRAC-X channel id to total number of channels */
-const int ff_oma_chid_to_num_channels[7] = {1, 2, 3, 4, 6, 7, 8};
diff --git a/libavformat/oma.h b/libavformat/oma.h
index 36fd0125e4..4417deeb4d 100644
--- a/libavformat/oma.h
+++ b/libavformat/oma.h
@@ -21,14 +21,8 @@ 
 #ifndef AVFORMAT_OMA_H
 #define AVFORMAT_OMA_H
 
-#include <stdint.h>
-
 #include "internal.h"
 
-#define EA3_HEADER_SIZE 96
-#define ID3v2_EA3_MAGIC "ea3"
-#define OMA_ENC_HEADER_SIZE 16
-
 enum {
     OMA_CODECID_ATRAC3  = 0,
     OMA_CODECID_ATRAC3P = 1,
@@ -39,11 +33,6 @@  enum {
     OMA_CODECID_ATRAC3AL  = 34,
 };
 
-extern const uint16_t ff_oma_srate_tab[8];
-
 extern const AVCodecTag ff_oma_codec_tags[];
 
-extern const uint64_t ff_oma_chid_to_native_layout[7];
-extern const int ff_oma_chid_to_num_channels[7];
-
-#endif /* AVFORMAT_OMA_H */
+#endif /* AVFORMAT_OMA_H */
\ No newline at end of file
diff --git a/libavformat/omadec.c b/libavformat/omadec.c
index 423d52b3aa..ccefd6c1bc 100644
--- a/libavformat/omadec.c
+++ b/libavformat/omadec.c
@@ -48,6 +48,7 @@ 
 #include "libavutil/intreadwrite.h"
 #include "libavutil/des.h"
 #include "libavutil/mathematics.h"
+#include "libavcodec/oma.h"
 #include "oma.h"
 #include "pcm.h"
 #include "id3v2.h"
diff --git a/libavformat/omaenc.c b/libavformat/omaenc.c
index 7952808bf8..6e72c3ee85 100644
--- a/libavformat/omaenc.c
+++ b/libavformat/omaenc.c
@@ -24,6 +24,7 @@ 
 #include "avio_internal.h"
 #include "id3v2.h"
 #include "internal.h"
+#include "libavcodec/oma.h"
 #include "oma.h"
 #include "rawenc.h"
 
diff --git a/libavformat/version.h b/libavformat/version.h
index 5ced041f0a..6453d4559f 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -33,7 +33,7 @@ 
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
 #define LIBAVFORMAT_VERSION_MINOR   3
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \