[FFmpeg-devel] [PATCH] ffprobe: rework/fix ini writer

Stefano Sabatini stefasab at gmail.com
Thu Sep 27 10:33:23 CEST 2012


On date Thursday 2012-09-27 09:14:38 +0200, Clément Bœsch encoded:
> On Thu, Sep 27, 2012 at 12:40:24AM +0200, Stefano Sabatini wrote:
> > Do not build from scratch the section header for each section, but build
> > it using the previous level buffer, thus improving efficiency.
> > 
> > Also fix some few corner cases related to numbering which are exposed by
> > the pending disposition patch.
> > ---
> >  ffprobe.c |   48 ++++++++++++++++++++++++++++++++++--------------
> >  1 files changed, 34 insertions(+), 14 deletions(-)
> > 
> > diff --git a/ffprobe.c b/ffprobe.c
> > index 8550c22..9d804b0 100644
> > --- a/ffprobe.c
> > +++ b/ffprobe.c
> > @@ -956,6 +956,7 @@ static const Writer flat_writer = {
> >  typedef struct {
> >      const AVClass *class;
> >      int hierarchical;
> > +    AVBPrint section_header[SECTION_MAX_NB_LEVELS];
> >  } INIContext;
> >  
> >  #undef OFFSET
> > @@ -969,6 +970,25 @@ static const AVOption ini_options[] = {
> >  
> >  DEFINE_WRITER_CLASS(ini);
> >  
> > +static int ini_init(WriterContext *wctx)
> > +{
> > +    INIContext *ini = wctx->priv;
> > +    int i;
> > +
> > +    for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
> > +        av_bprint_init(&ini->section_header[i], 1, AV_BPRINT_SIZE_UNLIMITED);
> > +    return 0;
> > +}
> > +
> > +static void ini_uninit(WriterContext *wctx)
> > +{
> > +    INIContext *ini = wctx->priv;
> > +    int i;
> > +
> > +    for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
> > +        av_bprint_finalize(&ini->section_header[i], NULL);
> > +}
> > +
> 
> Aren't these AVBPrint buffers kind of handy for most of the writers? If
> so, it might makes sense to put them in the WriterContext.

Yes, but they have every time a different use, and I don't have a good
idea for a generic name, so I'd leave it to a following refactoring.
-- 
FFmpeg = Formidable and Free Mastering Peaceful Exxagerate Goblin


More information about the ffmpeg-devel mailing list