]> git.sesse.net Git - ffmpeg/commitdiff
Add av_log_{ask_for_sample|missing_feature} replacements to libavutil
authorDiego Biurrun <diego@biurrun.de>
Tue, 22 Jan 2013 01:41:54 +0000 (02:41 +0100)
committerDiego Biurrun <diego@biurrun.de>
Wed, 13 Mar 2013 19:42:06 +0000 (20:42 +0100)
This allows reporting missing features and requesting samples from
all libraries in a standard way; with a simplified API.

libavcodec/avcodec.h
libavcodec/utils.c
libavcodec/version.h
libavutil/internal.h
libavutil/log.c

index e48b114a45db42d3668e4ec179cc653f18077ec8..f7d6553fa5ead04ffd84e9bf9c81abcff40d6673 100644 (file)
@@ -4026,6 +4026,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_MISSING_SAMPLE
 /**
  * Log a generic warning message about a missing feature. This function is
  * intended to be used internally by Libav (libavcodec, libavformat, etc.)
@@ -4037,7 +4038,9 @@ unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
  * 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.
+ * @deprecated Use avpriv_report_missing_feature() instead.
  */
+attribute_deprecated
 void av_log_missing_feature(void *avc, const char *feature, int want_sample);
 
 /**
@@ -4047,8 +4050,11 @@ void av_log_missing_feature(void *avc, const char *feature, int want_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
+ * @deprecated Use avpriv_request_sample() instead.
  */
+attribute_deprecated
 void av_log_ask_for_sample(void *avc, const char *msg, ...) av_printf_format(2, 3);
+#endif /* FF_API_MISSING_SAMPLE */
 
 /**
  * Register the hardware accelerator hwaccel.
index b4c294e0de0a20f900ed0d3ef12b5f52bbe5b58b..818dc5773e42720095e721e0cf49fd74cd868f51 100644 (file)
@@ -42,6 +42,7 @@
 #include "thread.h"
 #include "internal.h"
 #include "bytestream.h"
+#include "version.h"
 #include <stdlib.h>
 #include <stdarg.h>
 #include <limits.h>
@@ -2032,6 +2033,7 @@ int ff_match_2uint16(const uint16_t(*tab)[2], int size, int a, int b)
     return i;
 }
 
+#if FF_API_MISSING_SAMPLE
 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 "
@@ -2056,6 +2058,7 @@ void av_log_ask_for_sample(void *avc, const char *msg, ...)
 
     va_end(argument_list);
 }
+#endif /* FF_API_MISSING_SAMPLE */
 
 static AVHWAccel *first_hwaccel = NULL;
 
index 561c8804747540bd6273c406d4a349cce76c5b9b..8b4fbce1e5e57a45669efa87f413def658fe2c43 100644 (file)
@@ -58,5 +58,8 @@
 #ifndef FF_API_GET_BUFFER
 #define FF_API_GET_BUFFER        (LIBAVCODEC_VERSION_MAJOR < 56)
 #endif
+#ifndef FF_API_MISSING_SAMPLE
+#define FF_API_MISSING_SAMPLE    (LIBAVCODEC_VERSION_MAJOR < 56)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
index 3cf55f6398d12005e86f80fe14e3731e8ef0c060..5f4b060926919e0f98854c132a4e735707b38803 100644 (file)
 #   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] msg string containing the name of the missing feature
+ */
+void avpriv_report_missing_feature(void *avc,
+                                   const char *msg, ...) av_printf_format(2, 3);
+
+/**
+ * Log a generic warning message about a missing feature.
+ * Additionally request that a sample showcasing the feature be uploaded.
+ *
+ * @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 the name of the missing feature
+ */
+void avpriv_request_sample(void *avc,
+                           const char *msg, ...) av_printf_format(2, 3);
+
 #endif /* AVUTIL_INTERNAL_H */
index 80129769f656a9d1a4ad102bfe1f819755c7f82b..bd46b0c054ca603752ea6e56a57ab1cd4f1eda46 100644 (file)
 #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,40 @@ void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
 {
     av_log_callback = callback;
 }
+
+static void missing_feature_sample(int sample, void *avc, const char *msg, ...)
+{
+    va_list argument_list;
+
+    va_start(argument_list, msg);
+
+    av_vlog(avc, AV_LOG_WARNING, msg, 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 (sample)
+        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_request_sample(void *avc, const char *msg, ...)
+{
+    va_list argument_list;
+
+    va_start(argument_list, msg);
+    missing_feature_sample(1, avc, msg, argument_list);
+    va_end(argument_list);
+}
+
+void avpriv_report_missing_feature(void *avc, const char *msg, ...)
+{
+    va_list argument_list;
+
+    va_start(argument_list, msg);
+    missing_feature_sample(0, avc, msg, argument_list);
+    va_end(argument_list);
+}