[FFmpeg-cvslog] flac: make avpriv_flac_parse_block_header() inline

Anton Khirnov git at videolan.org
Wed May 28 12:38:15 CEST 2014


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon May 26 09:43:50 2014 +0200| [5fdaf312c5541b77b6364db8b49d6abb416a25c0] | committer: Anton Khirnov

flac: make avpriv_flac_parse_block_header() inline

This avoids all the ABI troubles associated with avpriv_.
Since this function is very small and does not depend on any tables,
making it inline should have no adverse effects.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5fdaf312c5541b77b6364db8b49d6abb416a25c0
---

 libavcodec/flac.c     |   10 +++-------
 libavcodec/flac.h     |   29 ++++++++++++++++++++++-------
 libavcodec/flacdec.c  |    4 ++--
 libavformat/flacdec.c |    2 +-
 4 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/libavcodec/flac.c b/libavcodec/flac.c
index e6a8ab8..cd1a6ab 100644
--- a/libavcodec/flac.c
+++ b/libavcodec/flac.c
@@ -237,14 +237,10 @@ void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *
     skip_bits_long(&gb, 64); /* md5 sum */
 }
 
+#if LIBAVCODEC_VERSION_MAJOR < 56
 void avpriv_flac_parse_block_header(const uint8_t *block_header,
                                 int *last, int *type, int *size)
 {
-    int tmp = bytestream_get_byte(&block_header);
-    if (last)
-        *last = tmp & 0x80;
-    if (type)
-        *type = tmp & 0x7F;
-    if (size)
-        *size = bytestream_get_be24(&block_header);
+    flac_parse_block_header(block_header, last, type, size);
 }
+#endif
diff --git a/libavcodec/flac.h b/libavcodec/flac.h
index 63f41c2..fbd34a1 100644
--- a/libavcodec/flac.h
+++ b/libavcodec/flac.h
@@ -28,6 +28,7 @@
 #define AVCODEC_FLAC_H
 
 #include "avcodec.h"
+#include "bytestream.h"
 #include "get_bits.h"
 
 #define FLAC_STREAMINFO_SIZE   34
@@ -109,15 +110,10 @@ int avpriv_flac_is_extradata_valid(AVCodecContext *avctx,
                                    enum FLACExtradataFormat *format,
                                    uint8_t **streaminfo_start);
 
-/**
- * Parse the metadata block parameters from the header.
- * @param[in]  block_header header data, at least 4 bytes
- * @param[out] last indicator for last metadata block
- * @param[out] type metadata block type
- * @param[out] size metadata block size
- */
+#if LIBAVCODEC_VERSION_MAJOR < 56
 void avpriv_flac_parse_block_header(const uint8_t *block_header,
                                     int *last, int *type, int *size);
+#endif
 
 /**
  * Calculate an estimate for the maximum frame size based on verbatim mode.
@@ -140,4 +136,23 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
 
 void ff_flac_set_channel_layout(AVCodecContext *avctx);
 
+/**
+ * Parse the metadata block parameters from the header.
+ * @param[in]  block_header header data, at least 4 bytes
+ * @param[out] last indicator for last metadata block
+ * @param[out] type metadata block type
+ * @param[out] size metadata block size
+ */
+static av_always_inline void flac_parse_block_header(const uint8_t *block_header,
+                                                      int *last, int *type, int *size)
+{
+    int tmp = bytestream_get_byte(&block_header);
+    if (last)
+        *last = tmp & 0x80;
+    if (type)
+        *type = tmp & 0x7F;
+    if (size)
+        *size = bytestream_get_be24(&block_header);
+}
+
 #endif /* AVCODEC_FLAC_H */
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 0305d50..9ca55cc 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -156,7 +156,7 @@ static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size)
         /* need more data */
         return 0;
     }
-    avpriv_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size);
+    flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size);
     if (metadata_type != FLAC_METADATA_TYPE_STREAMINFO ||
         metadata_size != FLAC_STREAMINFO_SIZE) {
         return AVERROR_INVALIDDATA;
@@ -187,7 +187,7 @@ static int get_metadata_size(const uint8_t *buf, int buf_size)
     do {
         if (buf_end - buf < 4)
             return 0;
-        avpriv_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);
+        flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);
         buf += 4;
         if (buf_end - buf < metadata_size) {
             /* need more data in order to read the complete header */
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index d02d8b5..ee40a20 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -51,7 +51,7 @@ static int flac_read_header(AVFormatContext *s)
     /* process metadata blocks */
     while (!s->pb->eof_reached && !metadata_last) {
         avio_read(s->pb, header, 4);
-        avpriv_flac_parse_block_header(header, &metadata_last, &metadata_type,
+        flac_parse_block_header(header, &metadata_last, &metadata_type,
                                    &metadata_size);
         switch (metadata_type) {
         /* allocate and read metadata block for supported types */



More information about the ffmpeg-cvslog mailing list