[FFmpeg-devel] [PATCH] graph2dot tool

Stefano Sabatini stefano.sabatini-lala
Sat Dec 27 00:39:27 CET 2008


On date Friday 2008-12-26 23:20:12 +0100, Benoit Fouet encoded:
> Hi,
> 
> Stefano Sabatini wrote :
> > Hi all,
> >
> > this neat tool should help to debug/understand avfilter graphs, if you
> > find it useful we could include this in the tools dir.
> >
> > Usage example:
> > $ echo "scale=100:100, crop=100:20:30:30, vflip, hflip" | graph2dot
> > digraph G {
> > "Parsed filter 0 (scale)" -> "Parsed filter 1 (crop)";
> > "Parsed filter 1 (crop)" -> "Parsed filter 2 (vflip)";
> > "Parsed filter 2 (vflip)" -> "Parsed filter 3 (hflip)";
> > }
> >
> > To directly display the graph:
> > $ echo "scale=100:100, crop=100:20:30:30, vflip, hflip" | graph2dot | dot -Tpng -o graph.png; and display graph.png
> >
> > Regards.
> >   
> > ------------------------------------------------------------------------
> >
> > const char *program_name = NULL;
> >
> >   
> 
> static

Fixed.
 
> > static void usage()
> > {
> >     printf("Convert a libavfilter graph to a dot file\n");
> >     printf("Usage: %s [ outfile ]\n", program_name);
> > }
> >
> > typedef struct Line {
> >     char data[128];
> >     struct Line *next;
> > } Line;
> >
> > int main(int argc, char **argv)
> > {
> >     const char *outfilename = NULL;
> >     FILE *outfile = NULL;
> >
> >     program_name = argv[0];
> >
> >     if (argc < 2 || !strcmp(argv[1], "-"))
> >         outfilename = "/dev/stdout";
> >   
> 
> else
>     outfilename = argv[1]
> ?

Yes it was missing.
 
> >     outfile = fopen(outfilename, "w");
> >     if (!outfile) {
> >         fprintf(stderr, "Impossible to open output file '%s': %s\n", argv[0], strerror(errno));
> >   
> 
> s/argv[0]/outfilename/

Fixed.
 
> >         return 1;
> >     }
> >
> >     /* read from stdin and put it in a buffer */
> >     unsigned int count = 0;
> >     Line *line, *last_line, *first_line;
> >   
> 
> this should be with the other declarations...

I created a context for them.

> >     last_line = first_line = malloc(sizeof(Line));
> >
> >     while (fgets(last_line->data, sizeof(last_line->data), stdin)) {
> >         count += strlen(last_line->data);
> >         Line *new_line = malloc(sizeof(Line));
> >   
> 
> those two lines should be swapped

[...]

I should have been fixed all the C99 mixed declaration around, and
done some simplification.

I also implemented a getopt() based CLI parsing mechanism, extended
the interface and fixed other random errors.

Thanks for the review, regards.
-- 
FFmpeg = Friendly and Freak Mega Problematic Enhancing Gadget
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graph2dot.c
Type: text/x-csrc
Size: 4552 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081227/63b7d0ec/attachment.c>



More information about the ffmpeg-devel mailing list