[FFmpeg-devel] [PATCH] Add debug facilities for avfilter.c

Michael Niedermayer michaelni
Mon Oct 5 22:37:10 CEST 2009


On Mon, Oct 05, 2009 at 09:34:50PM +0200, Stefano Sabatini wrote:
> On date Monday 2009-10-05 00:32:40 +0200, Michael Niedermayer encoded:
> > On Sun, Oct 04, 2009 at 06:40:12PM +0200, Stefano Sabatini wrote:
> > > Hi all,
> > > 
> > > these trace messages can be a real pain-saver when debugging complex
> > > filterchains, while I believe they don't clutter the code so much.
> > > 
> > > The result in the output is something like:
> > > avfilter_request_frame(): link[0x8f8f410 w:564 h:348 src:vflip dst:ffplay_output]: requesting frame
> > > avfilter_request_frame(): link[0x8f8f350 w:564 h:348 src:hflip dst:vflip]: requesting frame
> > > avfilter_request_frame(): link[0x8f8f070 w:564 h:348 src:pad dst:hflip]: requesting frame
> > > avfilter_request_frame(): link[0x8f8ede0 w:464 h:348 src:ffplay_input dst:pad]: requesting frame
> > > avfilter_get_video_buffer(): link[0x8f8ede0 w:464 h:348 src:ffplay_input dst:pad]: getting picref [w:464 h:348]
> > > avfilter_get_video_buffer(): link[0x8f8f070 w:564 h:348 src:pad dst:hflip]: getting picref [w:564 h:348]
> > > avfilter_get_video_buffer(): link[0x8f8f350 w:564 h:348 src:hflip dst:vflip]: getting picref [w:564 h:348]
> > > avfilter_get_video_buffer(): link[0x8f8f410 w:564 h:348 src:vflip dst:ffplay_output]: getting picref [w:564 h:348]
> > > avfilter_get_video_buffer(): link[0x8f8f410 w:564 h:348 src:vflip dst:ffplay_output]: returning picref: picref[data[0x97d16f0, 0x98025f0, 0x980e9b0, (nil)] linesize[576, 288, 288, 0] pts:0 564x348]
> > > avfilter_get_video_buffer(): link[0x8f8f350 w:564 h:348 src:hflip dst:vflip]: returning picref: picref[data[0x98023b0, 0x980e890, 0x981ac50, (nil)] linesize[-576, -288, -288, 0] pts:0 564x348]
> > > avfilter_get_video_buffer(): link[0x8f8f070 w:564 h:348 src:pad dst:hflip]: returning picref: picref[data[0x98023b0, 0x980e890, 0x981ac50, (nil)] linesize[-576, -288, -288, 0] pts:0 564x348]
> > > avfilter_get_video_buffer(): link[0x8f8ede0 w:464 h:348 src:ffplay_input dst:pad]: returning picref: picref[data[0x98023b0, 0x980e890, 0x981ac50, (nil)] linesize[-576, -288, -288, 0] pts:0 564x348]
> > > avfilter_start_frame(): link[0x8f8ede0 w:464 h:348 src:ffplay_input dst:pad]: starting frame picref[data[0x98023b0, 0x980e890, 0x981ac50, (nil)] linesize[-576, -288, -288, 0] pts:800000 564x348]
> > > avfilter_start_frame(): link[0x8f8f070 w:564 h:348 src:pad dst:hflip]: starting frame picref[data[0x98023b0, 0x980e890, 0x981ac50, (nil)] linesize[-576, -288, -288, 0] pts:800000 564x348]
> > > avfilter_get_video_buffer(): link[0x8f8f350 w:564 h:348 src:hflip dst:vflip]: getting picref [w:564 h:348]
> > > avfilter_get_video_buffer(): link[0x8f8f410 w:564 h:348 src:vflip dst:ffplay_output]: getting picref [w:564 h:348]
> > > avfilter_get_video_buffer(): link[0x8f8f410 w:564 h:348 src:vflip dst:ffplay_output]: returning picref: picref[data[0x9864450, 0x9895350, 0x98a1710, (nil)] linesize[576, 288, 288, 0] pts:0 564x348]
> > > avfilter_get_video_buffer(): link[0x8f8f350 w:564 h:348 src:hflip dst:vflip]: returning picref: picref[data[0x9895110, 0x98a15f0, 0x98ad9b0, (nil)] linesize[-576, -288, -288, 0] pts:0 564x348]
> > > avfilter_start_frame(): link[0x8f8f350 w:564 h:348 src:hflip dst:vflip]: starting frame picref[data[0x9895110, 0x98a15f0, 0x98ad9b0, (nil)] linesize[-576, -288, -288, 0] pts:800000 564x348]
> > > avfilter_start_frame(): link[0x8f8f410 w:564 h:348 src:vflip dst:ffplay_output]: starting frame picref[data[0x9864450, 0x9895350, 0x98a1710, (nil)] linesize[576, 288, 288, 0] pts:800000 564x348]
> > > avfilter_draw_slice(): link[0x8f8ede0 w:464 h:348 src:ffplay_input dst:pad]: drawing slice y:0 h:348
> > > avfilter_draw_slice(): link[0x8f8f070 w:564 h:348 src:pad dst:hflip]: drawing slice y:0 h:348
> > > avfilter_draw_slice(): link[0x8f8f350 w:564 h:348 src:hflip dst:vflip]: drawing slice y:0 h:348
> > > avfilter_draw_slice(): link[0x8f8f410 w:564 h:348 src:vflip dst:ffplay_output]: drawing slice y:0 h:348
> > 
> > "avfilter_" unneeded, so is ()
> > w:X h:Y -> s:XxY
> > src:vflip dst:ffplay_output ->  vflip->ffplay_output
> 
> Now is:
> 
> request_frame: link[0x9740db0 s:464x348 crop->ffplay_output]
> request_frame: link[0x9740d10 s:464x348 vflip->crop]
> request_frame: link[0x9733020 s:464x348 ffplay_input->vflip]
> get_video_buffer: link[0x9733020 s:464x348 ffplay_input->vflip] perms:2 w:464 h:348
> get_video_buffer: link[0x9740d10 s:464x348 vflip->crop] perms:2 w:464 h:348
> get_video_buffer: link[0x9740db0 s:464x348 crop->ffplay_output] perms:2 w:464 h:348
> get_video_buffer: link[0x9740db0 s:464x348 crop->ffplay_output] returning picref[0x96f8e90 data[0x9891ca0, 0x98b9360, 0x98c3680, (nil)] linesize[464, 240, 240, 0] pts:0 s:464x348]
> get_video_buffer: link[0x9740d10 s:464x348 vflip->crop] returning picref[0x96f8e90 data[0x9891ca0, 0x98b9360, 0x98c3680, (nil)] linesize[464, 240, 240, 0] pts:0 s:464x348]
> get_video_buffer: link[0x9733020 s:464x348 ffplay_input->vflip] returning picref[0x96f8e90 data[0x98b9190, 0x98c3590, 0x98cd8b0, (nil)] linesize[-464, -240, -240, 0] pts:0 s:464x348]
> start_frame: link[0x9733020 s:464x348 ffplay_input->vflip] picref[0x9726590 data[0x98b9190, 0x98c3590, 0x98cd8b0, (nil)] linesize[-464, -240, -240, 0] pts:6433333 s:464x348]
> start_frame: link[0x9740d10 s:464x348 vflip->crop] picref[0x9732dd0 data[0x9891ca0, 0x98b9360, 0x98c3680, (nil)] linesize[464, 240, 240, 0] pts:6433333 s:464x348]
> start_frame: link[0x9740db0 s:464x348 crop->ffplay_output] picref[0x9733070 data[0x9891ca0, 0x98b9360, 0x98c3680, (nil)] linesize[464, 240, 240, 0] pts:6433333 s:464x348]
> draw_slice: link[0x9733020 s:464x348 ffplay_input->vflip] y:0 h:348
> draw_slice: link[0x9740d10 s:464x348 vflip->crop] y:0 h:348
> draw_slice: link[0x9740db0 s:464x348 crop->ffplay_output] y:0 h:348

following would be better:

> request_frame   : 9740db0 s:464x348 crop        ->ffplay_output]
> request_frame   : 9740d10 s:464x348 vflip       ->crop]
> request_frame   : 9733020 s:464x348 ffplay_input->vflip]
> get_video_buffer: 9733020 s:464x348 ffplay_input->vflip        ] perms:2 w:464 h:348
> get_video_buffer: 9740d10 s:464x348 vflip       ->crop         ] perms:2 w:464 h:348
> get_video_buffer: 9740db0 s:464x348 crop        ->ffplay_output] perms:2 w:464 h:348
> get_video_buffer: 9740db0 s:464x348 crop        ->ffplay_output] returning picref[0x96f8e90 data[0x9891ca0, 0x98b9360, 0x98c3680, (nil)] linesize[464, 240, 240, 0] pts:0 s:464x348]
> get_video_buffer: 9740d10 s:464x348 vflip       ->crop         ] returning picref[0x96f8e90 data[0x9891ca0, 0x98b9360, 0x98c3680, (nil)] linesize[464, 240, 240, 0] pts:0 s:464x348]
> get_video_buffer: 9733020 s:464x348 ffplay_input->vflip        ] returning picref[0x96f8e90 data[0x98b9190, 0x98c3590, 0x98cd8b0, (nil)] linesize[-464, -240, -240, 0] pts:0 s:464x348]
> start_frame     : 9733020 s:464x348 ffplay_input->vflip        ] picref[0x9726590 data[0x98b9190, 0x98c3590, 0x98cd8b0, (nil)] linesize[-464, -240, -240, 0] pts:6433333 s:464x348]
> start_frame     : 9740d10 s:464x348 vflip       ->crop         ] picref[0x9732dd0 data[0x9891ca0, 0x98b9360, 0x98c3680, (nil)] linesize[464, 240, 240, 0] pts:6433333 s:464x348]
> start_frame     : 9740db0 s:464x348 crop        ->ffplay_output] picref[0x9733070 data[0x9891ca0, 0x98b9360, 0x98c3680, (nil)] linesize[464, 240, 240, 0] pts:6433333 s:464x348]
> draw_slice      : 9733020 s:464x348 ffplay_input->vflip        ] y:0 h:348
> draw_slice      : 9740d10 s:464x348 vflip       ->crop         ] y:0 h:348
> draw_slice      : 9740db0 s:464x348 crop        ->ffplay_output] y:0 h:348



> 
> > and the stuf above would be more readable if you could do something about
> > variable size fields so that things are vertically aligned
> 
> I tried different times to align, that usually resulted in a bigger
> mess than before and it tends to waste space, we could still
> grep|print|format|cut if necessary.
> 
> > > By default they are completely disabled, to enable them is sufficient to
> > > de-comment the DEBUG symbol definition.
> > > 
> > > Regards.
> > > -- 
> > > FFmpeg = Funny and Fast Merciful Picky Enhancing Gospel
> > 
> > >  avfilter.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 47 insertions(+)
> > > 16de016cde39d4efe4f8e30d00314ca8d7afa5da  debug-system.patch
> > > Index: ffmpeg-vfilters/ffmpeg/libavfilter/avfilter.c
> > > ===================================================================
> > > --- ffmpeg-vfilters.orig/ffmpeg/libavfilter/avfilter.c	2009-10-04 17:47:08.000000000 +0200
> > > +++ ffmpeg-vfilters/ffmpeg/libavfilter/avfilter.c	2009-10-04 18:30:15.000000000 +0200
> > > @@ -22,6 +22,8 @@
> > >  #include "libavcodec/imgconvert.h"
> > >  #include "avfilter.h"
> > >  
> > > +/* #define DEBUG */
> > > +
> > >  unsigned avfilter_version(void) {
> > >      return LIBAVFILTER_VERSION_INT;
> > >  }
> > > @@ -160,10 +162,29 @@
> > >      return 0;
> > >  }
> > >  
> > > +#define DPRINT_PICREF(dst, dst_size, picref) snprintf(dst, dst_size,    \
> > > +                                                      "picref[data[%p, %p, %p, %p] linesize[%d, %d, %d, %d] pts:%"PRId64" %dx%d]", \
> > > +                                                      picref->data[0], picref->data[1], picref->data[2], picref->data[3], \
> > > +                                                      picref->linesize[0], picref->linesize[1], picref->linesize[2], picref->linesize[3], \
> > > +                                                      picref->pts, picref->w, picref->h)
> > > +
> > > +#define DPRINT_LINK(dst_, dst_size_, link_) snprintf(dst_, dst_size_,   \
> > > +                                                     "link[%p w:%d h:%d src:%s dst:%s]", link_, link_->w, link_->h, \
> > > +                                                     link_->src ? link_->src->filter->name : "", \
> > > +                                                     link_->dst ? link_->dst->filter->name : "")
> > > +
> > 
> > these could be functions
> 
> Implemented as functions.
> 
> > >  AVFilterPicRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
> > >  {
> > >      AVFilterPicRef *ret = NULL;
> > >  
> > > +#ifdef DEBUG
> > > +    char picref_buf[256], link_buf[256];
> > > +
> > > +    DPRINT_LINK(link_buf, sizeof(link_buf), link);
> > > +    av_log(NULL, AV_LOG_DEBUG, "%s(): %s: getting picref [w:%d h:%d]\n",
> > > +           __func__, link_buf, w, h);
> > > +#endif
> > 
> > the buffers and snprintf() are useless, a single av_log call is enough
> 
> How? I'd like to keep the dprint_STUFF functions, so it's easy to
> add/customize other traces in other places if necessary.

you have a single function that prints it all and you call that single
function from various places
that function is #defined to ; if DEBUG is not set
you pass NULL if you dont have some link or picref
the fuction just calls av_log() or dprintf()

this is simpler than your code

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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091005/90e7de97/attachment.pgp>



More information about the ffmpeg-devel mailing list