[FFmpeg-devel] [PATCH] Move sample format definitions from libavcodec to libavcore.

Stefano Sabatini stefano.sabatini-lala
Mon Oct 25 08:38:20 CEST 2010


---
 libavcodec/avcodec.h  |   27 +++++++++++++++------------
 libavcore/Makefile    |    1 +
 libavcore/samplefmt.h |   35 +++++++++++++++++++++++++++++++++++
 3 files changed, 51 insertions(+), 12 deletions(-)
 create mode 100644 libavcore/samplefmt.h

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 705259e..447493e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -27,6 +27,7 @@
  */
 
 #include <errno.h>
+#include "libavcore/samplefmt.h"
 #include "libavutil/avutil.h"
 #include "libavutil/cpu.h"
 
@@ -75,6 +76,9 @@
 #ifndef FF_API_INOFFICIAL
 #define FF_API_INOFFICIAL       (LIBAVCODEC_VERSION_MAJOR < 53)
 #endif
+#ifndef FF_API_OLD_SAMPLE_FMT
+#define FF_API_OLD_SAMPLE_FMT   (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
 
 #define AV_NOPTS_VALUE          INT64_C(0x8000000000000000)
 #define AV_TIME_BASE            1000000
@@ -409,18 +413,17 @@ enum CodecID {
 #define CODEC_TYPE_NB         AVMEDIA_TYPE_NB
 #endif
 
-/**
- * all in native-endian format
- */
-enum SampleFormat {
-    SAMPLE_FMT_NONE = -1,
-    SAMPLE_FMT_U8,              ///< unsigned 8 bits
-    SAMPLE_FMT_S16,             ///< signed 16 bits
-    SAMPLE_FMT_S32,             ///< signed 32 bits
-    SAMPLE_FMT_FLT,             ///< float
-    SAMPLE_FMT_DBL,             ///< double
-    SAMPLE_FMT_NB               ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec
-};
+
+#if FF_API_OLD_SAMPLE_FMT
+#define SAMPLE_FMT_NONE AV_SAMPLE_FMT_NONE
+#define SAMPLE_FMT_U8   AV_SAMPLE_FMT_U8
+#define SAMPLE_FMT_S16  AV_SAMPLE_FMT_S16
+#define SAMPLE_FMT_S32  AV_SAMPLE_FMT_S32
+#define SAMPLE_FMT_FLT  AV_SAMPLE_FMT_FLT
+#define SAMPLE_FMT_DBL  AV_SAMPLE_FMT_DBL
+#define SAMPLE_FMT_NB   AV_SAMPLE_FMT_NB
+#endif
+
 
 /* Audio channel masks */
 #define CH_FRONT_LEFT             0x00000001
diff --git a/libavcore/Makefile b/libavcore/Makefile
index 5e16c34..97d973f 100644
--- a/libavcore/Makefile
+++ b/libavcore/Makefile
@@ -6,6 +6,7 @@ FFLIBS = avutil
 HEADERS = avcore.h                                                      \
           imgutils.h                                                    \
           parseutils.h                                                  \
+          samplefmt.h                                                   \
 
 OBJS = imgutils.o                                                       \
        parseutils.o                                                     \
diff --git a/libavcore/samplefmt.h b/libavcore/samplefmt.h
new file mode 100644
index 0000000..0051c8d
--- /dev/null
+++ b/libavcore/samplefmt.h
@@ -0,0 +1,35 @@
+/*
+ * 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 AVCORE_SAMPLEFMT_H
+#define AVCORE_SAMPLEFMT_H
+
+/**
+ * all in native-endian format
+ */
+enum AVSampleFormat {
+    AV_SAMPLE_FMT_NONE = -1,
+    AV_SAMPLE_FMT_U8,          ///< unsigned 8 bits
+    AV_SAMPLE_FMT_S16,         ///< signed 16 bits
+    AV_SAMPLE_FMT_S32,         ///< signed 32 bits
+    AV_SAMPLE_FMT_FLT,         ///< float
+    AV_SAMPLE_FMT_DBL,         ///< double
+    AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec
+};
+
+#endif /* AVCORE_SAMPLEFMT_H */
-- 
1.7.1




More information about the ffmpeg-devel mailing list