in libavcore, and deprecate the corresponding libavcodec/audioconvert.h functions:
avcodec_get_sample_fmt_name()
avcodec_get_sample_fmt()
avcodec_sample_fmt_string()
Originally committed as revision 25653 to svn://svn.ffmpeg.org/ffmpeg/trunk
| ... | ... |
@@ -13,6 +13,16 @@ libavutil: 2009-03-08 |
| 13 | 13 |
|
| 14 | 14 |
API changes, most recent first: |
| 15 | 15 |
|
| 16 |
+2010-11-02 - r25653 - lavcore 0.11.0 - samplefmt.h |
|
| 17 |
+ Add sample format functions in libavcore/samplefmt.h: |
|
| 18 |
+ av_get_sample_fmt_name(), |
|
| 19 |
+ av_get_sample_fmt(), |
|
| 20 |
+ av_get_sample_fmt_string(), |
|
| 21 |
+ and deprecate the corresponding libavcodec/audioconvert.h functions: |
|
| 22 |
+ avcodec_get_sample_fmt_name(), |
|
| 23 |
+ avcodec_get_sample_fmt(), |
|
| 24 |
+ avcodec_sample_fmt_string(). |
|
| 25 |
+ |
|
| 16 | 26 |
2010-11-02 - r25652 - lavcore 0.10.0 - samplefmt.h |
| 17 | 27 |
Define enum AVSampleFormat in libavcore/samplefmt.h, deprecate enum |
| 18 | 28 |
SampleFormat. |
| ... | ... |
@@ -27,50 +27,26 @@ |
| 27 | 27 |
|
| 28 | 28 |
#include "libavutil/avstring.h" |
| 29 | 29 |
#include "libavutil/libm.h" |
| 30 |
+#include "libavcore/samplefmt.h" |
|
| 30 | 31 |
#include "avcodec.h" |
| 31 | 32 |
#include "audioconvert.h" |
| 32 | 33 |
|
| 33 |
-typedef struct SampleFmtInfo {
|
|
| 34 |
- const char *name; |
|
| 35 |
- int bits; |
|
| 36 |
-} SampleFmtInfo; |
|
| 37 |
- |
|
| 38 |
-/** this table gives more information about formats */ |
|
| 39 |
-static const SampleFmtInfo sample_fmt_info[SAMPLE_FMT_NB] = {
|
|
| 40 |
- [SAMPLE_FMT_U8] = { .name = "u8", .bits = 8 },
|
|
| 41 |
- [SAMPLE_FMT_S16] = { .name = "s16", .bits = 16 },
|
|
| 42 |
- [SAMPLE_FMT_S32] = { .name = "s32", .bits = 32 },
|
|
| 43 |
- [SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32 },
|
|
| 44 |
- [SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64 },
|
|
| 45 |
-}; |
|
| 46 |
- |
|
| 34 |
+#if FF_API_OLD_SAMPLE_FMT |
|
| 47 | 35 |
const char *avcodec_get_sample_fmt_name(int sample_fmt) |
| 48 | 36 |
{
|
| 49 |
- if (sample_fmt < 0 || sample_fmt >= SAMPLE_FMT_NB) |
|
| 50 |
- return NULL; |
|
| 51 |
- return sample_fmt_info[sample_fmt].name; |
|
| 37 |
+ return av_get_sample_fmt_name(sample_fmt); |
|
| 52 | 38 |
} |
| 53 | 39 |
|
| 54 | 40 |
enum SampleFormat avcodec_get_sample_fmt(const char* name) |
| 55 | 41 |
{
|
| 56 |
- int i; |
|
| 57 |
- |
|
| 58 |
- for (i=0; i < SAMPLE_FMT_NB; i++) |
|
| 59 |
- if (!strcmp(sample_fmt_info[i].name, name)) |
|
| 60 |
- return i; |
|
| 61 |
- return SAMPLE_FMT_NONE; |
|
| 42 |
+ return av_get_sample_fmt(name); |
|
| 62 | 43 |
} |
| 63 | 44 |
|
| 64 | 45 |
void avcodec_sample_fmt_string (char *buf, int buf_size, int sample_fmt) |
| 65 | 46 |
{
|
| 66 |
- /* print header */ |
|
| 67 |
- if (sample_fmt < 0) |
|
| 68 |
- snprintf (buf, buf_size, "name " " depth"); |
|
| 69 |
- else if (sample_fmt < SAMPLE_FMT_NB) {
|
|
| 70 |
- SampleFmtInfo info= sample_fmt_info[sample_fmt]; |
|
| 71 |
- snprintf (buf, buf_size, "%-6s" " %2d ", info.name, info.bits); |
|
| 72 |
- } |
|
| 47 |
+ av_get_sample_fmt_string(buf, buf_size, sample_fmt); |
|
| 73 | 48 |
} |
| 49 |
+#endif |
|
| 74 | 50 |
|
| 75 | 51 |
static const char* const channel_names[]={
|
| 76 | 52 |
"FL", "FR", "FC", "LFE", "BL", "BR", "FLC", "FRC", |
| ... | ... |
@@ -32,28 +32,25 @@ |
| 32 | 32 |
#include "libavutil/cpu.h" |
| 33 | 33 |
#include "avcodec.h" |
| 34 | 34 |
|
| 35 |
- |
|
| 35 |
+#if FF_API_OLD_SAMPLE_FMT |
|
| 36 | 36 |
/** |
| 37 |
- * Generate string corresponding to the sample format with |
|
| 38 |
- * number sample_fmt, or a header if sample_fmt is negative. |
|
| 39 |
- * |
|
| 40 |
- * @param[in] buf the buffer where to write the string |
|
| 41 |
- * @param[in] buf_size the size of buf |
|
| 42 |
- * @param[in] sample_fmt the number of the sample format to print the corresponding info string, or |
|
| 43 |
- * a negative value to print the corresponding header. |
|
| 44 |
- * Meaningful values for obtaining a sample format info vary from 0 to SAMPLE_FMT_NB -1. |
|
| 37 |
+ * @deprecated Use av_get_sample_fmt_string() instead. |
|
| 45 | 38 |
*/ |
| 39 |
+attribute_deprecated |
|
| 46 | 40 |
void avcodec_sample_fmt_string(char *buf, int buf_size, int sample_fmt); |
| 47 | 41 |
|
| 48 | 42 |
/** |
| 49 |
- * @return NULL on error |
|
| 43 |
+ * @deprecated Use av_get_sample_fmt_name() instead. |
|
| 50 | 44 |
*/ |
| 45 |
+attribute_deprecated |
|
| 51 | 46 |
const char *avcodec_get_sample_fmt_name(int sample_fmt); |
| 52 | 47 |
|
| 53 | 48 |
/** |
| 54 |
- * @return SAMPLE_FMT_NONE on error |
|
| 49 |
+ * @deprecated Use av_get_sample_fmt() instead. |
|
| 55 | 50 |
*/ |
| 51 |
+attribute_deprecated |
|
| 56 | 52 |
enum SampleFormat avcodec_get_sample_fmt(const char* name); |
| 53 |
+#endif |
|
| 57 | 54 |
|
| 58 | 55 |
/** |
| 59 | 56 |
* @return NULL on error |
| ... | ... |
@@ -33,7 +33,7 @@ |
| 33 | 33 |
|
| 34 | 34 |
#define LIBAVCODEC_VERSION_MAJOR 52 |
| 35 | 35 |
#define LIBAVCODEC_VERSION_MINOR 94 |
| 36 |
-#define LIBAVCODEC_VERSION_MICRO 1 |
|
| 36 |
+#define LIBAVCODEC_VERSION_MICRO 2 |
|
| 37 | 37 |
|
| 38 | 38 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 39 | 39 |
LIBAVCODEC_VERSION_MINOR, \ |
| ... | ... |
@@ -27,7 +27,7 @@ |
| 27 | 27 |
#include "libavutil/avutil.h" |
| 28 | 28 |
|
| 29 | 29 |
#define LIBAVCORE_VERSION_MAJOR 0 |
| 30 |
-#define LIBAVCORE_VERSION_MINOR 10 |
|
| 30 |
+#define LIBAVCORE_VERSION_MINOR 11 |
|
| 31 | 31 |
#define LIBAVCORE_VERSION_MICRO 0 |
| 32 | 32 |
|
| 33 | 33 |
#define LIBAVCORE_VERSION_INT AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \ |
| 34 | 34 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,64 @@ |
| 0 |
+/* |
|
| 1 |
+ * This file is part of FFmpeg. |
|
| 2 |
+ * |
|
| 3 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
| 4 |
+ * modify it under the terms of the GNU Lesser General Public |
|
| 5 |
+ * License as published by the Free Software Foundation; either |
|
| 6 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
| 7 |
+ * |
|
| 8 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
| 9 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 10 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
| 11 |
+ * Lesser General Public License for more details. |
|
| 12 |
+ * |
|
| 13 |
+ * You should have received a copy of the GNU Lesser General Public |
|
| 14 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
| 15 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
| 16 |
+ */ |
|
| 17 |
+ |
|
| 18 |
+#include "avcore.h" |
|
| 19 |
+#include "samplefmt.h" |
|
| 20 |
+ |
|
| 21 |
+typedef struct SampleFmtInfo {
|
|
| 22 |
+ const char *name; |
|
| 23 |
+ int bits; |
|
| 24 |
+} SampleFmtInfo; |
|
| 25 |
+ |
|
| 26 |
+/** this table gives more information about formats */ |
|
| 27 |
+static const SampleFmtInfo sample_fmt_info[AV_SAMPLE_FMT_NB] = {
|
|
| 28 |
+ [AV_SAMPLE_FMT_U8] = { .name = "u8", .bits = 8 },
|
|
| 29 |
+ [AV_SAMPLE_FMT_S16] = { .name = "s16", .bits = 16 },
|
|
| 30 |
+ [AV_SAMPLE_FMT_S32] = { .name = "s32", .bits = 32 },
|
|
| 31 |
+ [AV_SAMPLE_FMT_FLT] = { .name = "flt", .bits = 32 },
|
|
| 32 |
+ [AV_SAMPLE_FMT_DBL] = { .name = "dbl", .bits = 64 },
|
|
| 33 |
+}; |
|
| 34 |
+ |
|
| 35 |
+const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt) |
|
| 36 |
+{
|
|
| 37 |
+ if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) |
|
| 38 |
+ return NULL; |
|
| 39 |
+ return sample_fmt_info[sample_fmt].name; |
|
| 40 |
+} |
|
| 41 |
+ |
|
| 42 |
+enum AVSampleFormat av_get_sample_fmt(const char *name) |
|
| 43 |
+{
|
|
| 44 |
+ int i; |
|
| 45 |
+ |
|
| 46 |
+ for (i = 0; i < AV_SAMPLE_FMT_NB; i++) |
|
| 47 |
+ if (!strcmp(sample_fmt_info[i].name, name)) |
|
| 48 |
+ return i; |
|
| 49 |
+ return AV_SAMPLE_FMT_NONE; |
|
| 50 |
+} |
|
| 51 |
+ |
|
| 52 |
+char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt) |
|
| 53 |
+{
|
|
| 54 |
+ /* print header */ |
|
| 55 |
+ if (sample_fmt < 0) |
|
| 56 |
+ snprintf(buf, buf_size, "name " " depth"); |
|
| 57 |
+ else if (sample_fmt < AV_SAMPLE_FMT_NB) {
|
|
| 58 |
+ SampleFmtInfo info = sample_fmt_info[sample_fmt]; |
|
| 59 |
+ snprintf (buf, buf_size, "%-6s" " %2d ", info.name, info.bits); |
|
| 60 |
+ } |
|
| 61 |
+ |
|
| 62 |
+ return buf; |
|
| 63 |
+} |
| ... | ... |
@@ -32,4 +32,30 @@ enum AVSampleFormat {
|
| 32 | 32 |
AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcore |
| 33 | 33 |
}; |
| 34 | 34 |
|
| 35 |
+/** |
|
| 36 |
+ * Return the name of sample_fmt, or NULL if sample_fmt is not |
|
| 37 |
+ * recognized. |
|
| 38 |
+ */ |
|
| 39 |
+const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt); |
|
| 40 |
+ |
|
| 41 |
+/** |
|
| 42 |
+ * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE |
|
| 43 |
+ * on error. |
|
| 44 |
+ */ |
|
| 45 |
+enum AVSampleFormat av_get_sample_fmt(const char *name); |
|
| 46 |
+ |
|
| 47 |
+/** |
|
| 48 |
+ * Generate a string corresponding to the sample format with |
|
| 49 |
+ * sample_fmt, or a header if sample_fmt is negative. |
|
| 50 |
+ * |
|
| 51 |
+ * @param buf the buffer where to write the string |
|
| 52 |
+ * @param buf_size the size of buf |
|
| 53 |
+ * @param sample_fmt the number of the sample format to print the |
|
| 54 |
+ * corresponding info string, or a negative value to print the |
|
| 55 |
+ * corresponding header. |
|
| 56 |
+ * @return the pointer to the filled buffer or NULL if sample_fmt is |
|
| 57 |
+ * unknown or in case of other errors |
|
| 58 |
+ */ |
|
| 59 |
+char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); |
|
| 60 |
+ |
|
| 35 | 61 |
#endif /* AVCORE_SAMPLEFMT_H */ |