[FFmpeg-devel] [PATCH 3/3] Add av_get_bits_per_sample_fmt() to libavcore/samplefmt.h and deprecate av_get_bits_per_sample_format().
Stefano Sabatini
stefano.sabatini-lala
Sat Oct 30 06:11:06 CEST 2010
---
doc/APIchanges | 4 ++++
libavcodec/avcodec.h | 8 ++++----
libavcodec/utils.c | 16 +++-------------
libavcore/samplefmt.c | 6 ++++++
libavcore/samplefmt.h | 9 +++++++++
5 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/doc/APIchanges b/doc/APIchanges
index 0b3f688..4f52fd0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil: 2009-03-08
API changes, most recent first:
+2010-XX-XX - rXXXXX - lavcore 0.X.0 - av_get_bits_per_sample_fmt()
+ Add av_get_bits_per_sample_fmt() to libavcore/samplefmt.h and
+ deprecate av_get_bits_per_sample_format().
+
2010-XX-XX - rXXXXX - lavcore 0.X.0 - samplefmt.h
Add sample format functions:
av_get_sample_fmt_name(),
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7b9f50b..62d2441 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3738,13 +3738,13 @@ char av_get_pict_type_char(int pict_type);
*/
int av_get_bits_per_sample(enum CodecID codec_id);
+#if FF_API_OLD_SAMPLE_FMT
/**
- * Return sample format bits per sample.
- *
- * @param[in] sample_fmt the sample format
- * @return Number of bits per sample or zero if unknown for the given sample format.
+ * @deprecated Use av_get_bits_per_sample_fmt() instead.
*/
+attribute_deprecated
int av_get_bits_per_sample_format(enum SampleFormat sample_fmt);
+#endif
/* frame parsing */
typedef struct AVCodecParserContext {
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index ffd34ee..351698c 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1064,21 +1064,11 @@ int av_get_bits_per_sample(enum CodecID codec_id){
}
}
+#if #if FF_API_OLD_SAMPLE_FMT
int av_get_bits_per_sample_format(enum SampleFormat sample_fmt) {
- switch (sample_fmt) {
- case SAMPLE_FMT_U8:
- return 8;
- case SAMPLE_FMT_S16:
- return 16;
- case SAMPLE_FMT_S32:
- case SAMPLE_FMT_FLT:
- return 32;
- case SAMPLE_FMT_DBL:
- return 64;
- default:
- return 0;
- }
+ return av_get_bits_per_sample_fmt(sample_fmt);
}
+#endif
#if !HAVE_THREADS
int avcodec_thread_init(AVCodecContext *s, int thread_count){
diff --git a/libavcore/samplefmt.c b/libavcore/samplefmt.c
index 49ab829..532acd9 100644
--- a/libavcore/samplefmt.c
+++ b/libavcore/samplefmt.c
@@ -62,3 +62,9 @@ char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sam
return buf;
}
+
+int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt)
+{
+ return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ?
+ 0 : sample_fmt_info[sample_fmt].bits;
+}
diff --git a/libavcore/samplefmt.h b/libavcore/samplefmt.h
index 3db3cd7..bdc1855 100644
--- a/libavcore/samplefmt.h
+++ b/libavcore/samplefmt.h
@@ -60,4 +60,13 @@ enum AVSampleFormat av_get_sample_fmt(const char *name);
*/
char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
+/**
+ * Return sample format bits per sample.
+ *
+ * @param sample_fmt the sample format
+ * @return number of bits per sample or zero if unknown for the given
+ * sample format
+ */
+int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
+
#endif /* AVCORE_SAMPLEFMT_H */
--
1.7.1
More information about the ffmpeg-devel
mailing list