[FFmpeg-cvslog] avcodec/mpeg4audio: add avpriv_mpeg4audio_get_config2()

James Almer git at videolan.org
Fri Sep 27 16:39:47 EEST 2019


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sat Sep 21 19:57:11 2019 -0300| [f96a8b015f2fa62b18a613ebdb3c26da50951652] | committer: James Almer

avcodec/mpeg4audio: add avpriv_mpeg4audio_get_config2()

Identical to avpriv_mpeg4audio_get_config() except taking a size argument in
bytes, and featuring a new logging context paremeter.

Schedule avpriv_mpeg4audio_get_config() for removal as soon as major is bumped
as well.

Signed-off-by: James Almer <jamrial at gmail.com>

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

 libavcodec/aacdec_template.c |  2 +-
 libavcodec/mpeg4audio.c      | 22 ++++++++++++++++++++--
 libavcodec/mpeg4audio.h      | 17 ++++++++++++++++-
 3 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 6e086e00df..8726c8b828 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -975,7 +975,7 @@ static int decode_audio_specific_config_gb(AACContext *ac,
     int i, ret;
     GetBitContext gbc = *gb;
 
-    if ((i = ff_mpeg4audio_get_config_gb(m4ac, &gbc, sync_extension)) < 0)
+    if ((i = ff_mpeg4audio_get_config_gb(m4ac, &gbc, sync_extension, avctx)) < 0)
         return AVERROR_INVALIDDATA;
 
     if (m4ac->sampling_index > 12) {
diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
index 219714752f..6962a42537 100644
--- a/libavcodec/mpeg4audio.c
+++ b/libavcodec/mpeg4audio.c
@@ -84,7 +84,7 @@ static inline int get_sample_rate(GetBitContext *gb, int *index)
 }
 
 int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
-                                int sync_extension)
+                                int sync_extension, void *logctx)
 {
     int specific_config_bitindex, ret;
     int start_bit_index = get_bits_count(gb);
@@ -152,6 +152,7 @@ int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
     return specific_config_bitindex - start_bit_index;
 }
 
+#if LIBAVCODEC_VERSION_MAJOR < 59
 int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
                                  int bit_size, int sync_extension)
 {
@@ -165,5 +166,22 @@ int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
     if (ret < 0)
         return ret;
 
-    return ff_mpeg4audio_get_config_gb(c, &gb, sync_extension);
+    return ff_mpeg4audio_get_config_gb(c, &gb, sync_extension, NULL);
+}
+#endif
+
+int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf,
+                                  int size, int sync_extension, void *logctx)
+{
+    GetBitContext gb;
+    int ret;
+
+    if (size <= 0)
+        return AVERROR_INVALIDDATA;
+
+    ret = init_get_bits8(&gb, buf, size);
+    if (ret < 0)
+        return ret;
+
+    return ff_mpeg4audio_get_config_gb(c, &gb, sync_extension, logctx);
 }
diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
index b9cea8af17..00aa680c13 100644
--- a/libavcodec/mpeg4audio.h
+++ b/libavcodec/mpeg4audio.h
@@ -53,11 +53,13 @@ extern const uint8_t ff_mpeg4audio_channels[8];
  * @param[in] c        MPEG4AudioConfig structure to fill.
  * @param[in] gb       Extradata from container.
  * @param[in] sync_extension look for a sync extension after config if true.
+ * @param[in] logctx opaque struct starting with an AVClass element, used for logging.
  * @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata.
  */
 int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
-                                int sync_extension);
+                                int sync_extension, void *logctx);
 
+#if LIBAVCODEC_VERSION_MAJOR < 59
 /**
  * Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
  * @param[in] c        MPEG4AudioConfig structure to fill.
@@ -68,6 +70,19 @@ int ff_mpeg4audio_get_config_gb(MPEG4AudioConfig *c, GetBitContext *gb,
  */
 int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf,
                                  int bit_size, int sync_extension);
+#endif
+
+/**
+ * Parse MPEG-4 systems extradata from a raw buffer to retrieve audio configuration.
+ * @param[in] c        MPEG4AudioConfig structure to fill.
+ * @param[in] buf      Extradata from container.
+ * @param[in] size     Extradata size in bytes.
+ * @param[in] sync_extension look for a sync extension after config if true.
+ * @param[in] logctx opaque struct starting with an AVClass element, used for logging.
+ * @return negative AVERROR code on error, AudioSpecificConfig bit index in extradata on success.
+ */
+int avpriv_mpeg4audio_get_config2(MPEG4AudioConfig *c, const uint8_t *buf,
+                                  int size, int sync_extension, void *logctx);
 
 enum AudioObjectType {
     AOT_NULL,



More information about the ffmpeg-cvslog mailing list