This is more correct, as these two functions are meant to be internal and
it will allow reusing them from other libraries, e.g. libswresample.
---
 libavcodec/avcodec.h |    2 ++
 libavcodec/utils.c   |   20 +++-----------------
 libavcodec/version.h |    3 +++
 libavutil/internal.h |   25 +++++++++++++++++++++++++
 libavutil/log.c      |   34 ++++++++++++++++++++++++++++++++++
 5 files changed, 67 insertions(+), 17 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7a24775..ad8744e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4559,6 +4559,7 @@ void av_fast_padded_malloc(void *ptr, unsigned int *size, 
size_t min_size);
  */
 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
 
+#if FF_API_AV_LOG
 /**
  * Log a generic warning message about a missing feature. This function is
  * intended to be used internally by Libav (libavcodec, libavformat, etc.)
@@ -4582,6 +4583,7 @@ void av_log_missing_feature(void *avc, const char 
*feature, int want_sample);
  * @param[in] msg string containing an optional message, or NULL if no message
  */
 void av_log_ask_for_sample(void *avc, const char *msg, ...) 
av_printf_format(2, 3);
+#endif /* FF_API_AV_LOG */
 
 /**
  * Register the hardware accelerator hwaccel.
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4148264..a78738f 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -30,6 +30,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
+#include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/imgutils.h"
@@ -2010,27 +2011,12 @@ int ff_match_2uint16(const uint16_t(*tab)[2], int size, 
int a, int b)
 
 void av_log_missing_feature(void *avc, const char *feature, int want_sample)
 {
-    av_log(avc, AV_LOG_WARNING, "%s is not implemented. Update your Libav "
-            "version to the newest one from Git. If the problem still "
-            "occurs, it means that your file has a feature which has not "
-            "been implemented.\n", feature);
-    if(want_sample)
-        av_log_ask_for_sample(avc, NULL);
+    avpriv_log_missing_feature(avc, want_sample, feature);
 }
 
 void av_log_ask_for_sample(void *avc, const char *msg, ...)
 {
-    va_list argument_list;
-
-    va_start(argument_list, msg);
-
-    if (msg)
-        av_vlog(avc, AV_LOG_WARNING, msg, argument_list);
-    av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample "
-            "of this file to ftp://upload.libav.org/incoming/ "
-            "and contact the libav-devel mailing list.\n");
-
-    va_end(argument_list);
+    avpriv_log_ask_for_sample(avc, msg);
 }
 
 static AVHWAccel *first_hwaccel = NULL;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 7a024d3..9b92a4c 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -97,5 +97,8 @@
 #ifndef FF_API_IDCT
 #define FF_API_IDCT              (LIBAVCODEC_VERSION_MAJOR < 55)
 #endif
+#ifndef FF_API_AV_LOG
+#define FF_API_AV_LOG            (LIBAVCODEC_VERSION_MAJOR < 55)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
diff --git a/libavutil/internal.h b/libavutil/internal.h
index 3cf55f6..bd789cd 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -162,4 +162,29 @@
 #   define ONLY_IF_THREADS_ENABLED(x) NULL
 #endif
 
+/**
+ * Log a generic warning message about a missing feature.
+ *
+ * @param[in] avc         a pointer to an arbitrary struct of which the first
+ *                        field is a pointer to an AVClass struct
+ * @param[in] want_sample Flag value to indicate if samples exhibiting this
+ *                        feature should be requested.
+ * @param[in] feature     string containing the name of the missing feature
+ *
+ * If want_sample is non-zero, additional verbage will be added to the log
+ * message which tells the user how to report samples to the development
+ * mailing list.
+ */
+void avpriv_log_missing_feature(void *avc, int want_sample,
+                                const char *feature, ...) av_printf_format(3, 
4);
+
+/**
+ * Log a generic warning message asking for a sample.
+ *
+ * @param[in] avc a pointer to an arbitrary struct of which the first field is
+ *                a pointer to an AVClass struct
+ * @param[in] msg string containing an optional message, or NULL if no message
+ */
+void avpriv_log_ask_for_sample(void *avc, const char *msg, ...) 
av_printf_format(2, 3);
+
 #endif /* AVUTIL_INTERNAL_H */
diff --git a/libavutil/log.c b/libavutil/log.c
index 8012976..55480e6 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -32,10 +32,12 @@
 #if HAVE_IO_H
 #include <io.h>
 #endif
+#include <stdarg.h>
 #include <stdlib.h>
 #include "avstring.h"
 #include "avutil.h"
 #include "common.h"
+#include "internal.h"
 #include "log.h"
 
 static int av_log_level = AV_LOG_INFO;
@@ -179,3 +181,35 @@ void av_log_set_callback(void (*callback)(void*, int, 
const char*, va_list))
 {
     av_log_callback = callback;
 }
+
+void avpriv_log_ask_for_sample(void *avc, const char *msg, ...)
+{
+    va_list argument_list;
+
+    va_start(argument_list, msg);
+
+    if (msg)
+        av_vlog(avc, AV_LOG_WARNING, msg, argument_list);
+    av_log(avc, AV_LOG_WARNING, "If you want to help, upload a sample "
+           "of this file to ftp://upload.libav.org/incoming/ "
+           "and contact the libav-devel mailing list.\n");
+
+    va_end(argument_list);
+}
+
+void avpriv_log_missing_feature(void *avc, int want_sample,
+                                const char *feature, ...)
+{
+    va_list argument_list;
+    va_start(argument_list, feature);
+
+    av_vlog(avc, AV_LOG_WARNING, feature, argument_list);
+    av_log(avc, AV_LOG_WARNING, " is not implemented. Update your Libav "
+           "version to the newest one from Git. If the problem still "
+           "occurs, it means that your file has a feature which has not "
+           "been implemented.\n");
+    if (want_sample)
+        avpriv_log_ask_for_sample(avc, NULL);
+
+    va_end(argument_list);
+}
-- 
1.7.9.5

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to