[FFmpeg-devel] [PATCH] ffprobe: Support adding av_log output to frames

Michael Niedermayer michael at niedermayer.cc
Wed Jun 8 18:49:10 CEST 2016


On Wed, Jun 08, 2016 at 12:04:44AM -0300, James Almer wrote:
> On 5/31/2016 4:23 PM, Michael Niedermayer wrote:
> > adding demuxer and other logs should be easy
> > This forces single threaded decoding for simplicity
> > It also requires pthreads, this could be avoided either with
> > some lockless tricks or simply by assuming av_log would never be called from
> > another thread.
> > 
> > doc/ffprobe.xsd update missing (TODO & help welcome)
> > 
> > Fixes Ticket5521
> > 
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> >  ffprobe.c |  154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 153 insertions(+), 1 deletion(-)
> > 
> > diff --git a/ffprobe.c b/ffprobe.c
> > index a7e329c..07b61ec 100644
> > --- a/ffprobe.c
> > +++ b/ffprobe.c
> > @@ -49,6 +49,19 @@
> >  #include "libpostproc/postprocess.h"
> >  #include "cmdutils.h"
> >  
> > +#if HAVE_PTHREADS
> > +#  include <pthread.h>
> > +#else
> > +#  ifdef pthread_mutex_lock
> > +#    undef pthread_mutex_lock
> > +#  endif
> > +#  define pthread_mutex_lock(a)
> > +#  ifdef pthread_mutex_unlock
> > +#    undef pthread_mutex_unlock
> > +#  endif
> > +#  define pthread_mutex_unlock(a)
> > +#endif
> 
> Why are you not using the compat wrappers here? These are simple
> mutex locks that don't even use static init, so i don't see why
> they wouldn't work with w32threads or os2threads.

i just used the same as ffmpeg.c does

but locally changed as:
no idea if it works on os2 or w32

diff --git a/ffprobe.c b/ffprobe.c
index 07b61ec..ef6d4db 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -49,9 +49,9 @@
 #include "libpostproc/postprocess.h"
 #include "cmdutils.h"

-#if HAVE_PTHREADS
-#  include <pthread.h>
-#else
+#include "libavutil/thread.h"
+
+#if !HAVE_THREADS
 #  ifdef pthread_mutex_lock
 #    undef pthread_mutex_lock
 #  endif
@@ -274,7 +274,7 @@ static uint64_t *nb_streams_packets;
 static uint64_t *nb_streams_frames;
 static int *selected_streams;

-#if HAVE_PTHREADS
+#if HAVE_THREADS
 pthread_mutex_t log_mutex;
 #endif
 typedef struct LogBuffer {
@@ -302,7 +302,7 @@ static void log_callback(void *ptr, int level, const char *fmt, va_list vl)
     av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix);
     va_end(vl2);

-#if HAVE_PTHREADS
+#if HAVE_THREADS
     pthread_mutex_lock(&log_mutex);

     new_log_buffer = av_realloc_array(log_buffer, log_buffer_size + 1, sizeof(*log_buffer));
@@ -338,7 +338,7 @@ static void ffprobe_cleanup(int ret)
     for (i = 0; i < FF_ARRAY_ELEMS(sections); i++)
         av_dict_free(&(sections[i].entries_to_show));

-#if HAVE_PTHREADS
+#if HAVE_THREADS
     pthread_mutex_destroy(&log_mutex);
 #endif
 }
@@ -3332,7 +3332,7 @@ static const OptionDef real_options[] = {
       "show a particular entry from the format/container info", "entry" },
     { "show_entries", HAS_ARG, {.func_arg = opt_show_entries},
       "show a set of specified entries", "entry_list" },
-#if HAVE_PTHREADS
+#if HAVE_THREADS
     { "show_log", OPT_INT|HAS_ARG, {(void*)&do_show_log}, "show log" },
 #endif
     { "show_packets", 0, {(void*)&opt_show_packets}, "show packets info" },
@@ -3379,7 +3379,7 @@ int main(int argc, char **argv)
     char *w_name = NULL, *w_args = NULL;
     int ret, i;

-#if HAVE_PTHREADS
+#if HAVE_THREADS
     ret = pthread_mutex_init(&log_mutex, NULL);
     if (ret != 0) {
         goto end;

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160608/c6cfda54/attachment.sig>


More information about the ffmpeg-devel mailing list