[FFmpeg-devel] [PATCH 1/3] lavfi/ebur128: add metadata injection.

Clément Bœsch ubitux at gmail.com
Mon Mar 18 03:21:41 CET 2013


On Sat, Mar 16, 2013 at 05:02:11PM +0100, Nicolas George wrote:
[...]
> > +static int config_audio_input(AVFilterLink *inlink)
> > +{
> > +    AVFilterContext *ctx = inlink->dst;
> > +    EBUR128Context *ebur128 = ctx->priv;
> > +
> > +    /* force 100ms framing in case of metadata injection: the frames must have
> > +     * a granularity of the window overlap to be accurately exploited */
> > +    if (ebur128->metadata)
> > +        inlink->min_samples =
> > +        inlink->max_samples =
> > +        inlink->partial_buf_size = inlink->sample_rate / 10;
> 
> Possibly add a warning if sample_rate % 10 is not 0.
> 

Currently the filter only accepts a sample rate of 48k. It might be
changed later, but I'm not sure about adding a warning that suggests it is
possible.

> > +    return 0;
> > +}
> > +
> >  static int config_audio_output(AVFilterLink *outlink)
> >  {
> >      int i;
> > @@ -396,7 +413,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args)
> >  
> 
> >      if (ebur128->loglevel != AV_LOG_INFO &&
> >          ebur128->loglevel != AV_LOG_VERBOSE) {
> > -        if (ebur128->do_video)
> > +        if (ebur128->do_video || ebur128->metadata)
> >              ebur128->loglevel = AV_LOG_VERBOSE;
> >          else
> >              ebur128->loglevel = AV_LOG_INFO;
> 
> I wonder if the surrounding test is valid, but this is not affected by this
> patch.
> 
> > @@ -661,6 +678,20 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples)
> >                      return ret;
> >              }
> >  
> > +            if (ebur128->metadata) { /* happens only once per filter_frame call */
> > +                char metabuf[128];
> > +#define SET_META(name, var) do {                                            \
> > +    snprintf(metabuf, sizeof(metabuf), "%.3f", var);                        \
> > +    av_dict_set(&insamples->metadata, "lavfi.r128." name, metabuf, 0);      \
> > +} while (0)
> > +                SET_META("M",        loudness_400);
> > +                SET_META("S",        loudness_3000);
> > +                SET_META("I",        ebur128->integrated_loudness);
> > +                SET_META("LRA",      ebur128->loudness_range);
> > +                SET_META("LRA.low",  ebur128->lra_low);
> > +                SET_META("LRA.high", ebur128->lra_high);
> > +            }
> > +
> >              av_log(ctx, ebur128->loglevel, "t: %-10s " LOG_FMT "\n",
> >                     av_ts2timestr(pts, &outlink->time_base),
> >                     loudness_400, loudness_3000,
> > @@ -745,6 +776,7 @@ static av_cold void uninit(AVFilterContext *ctx)
> >      for (i = 0; i < ctx->nb_outputs; i++)
> >          av_freep(&ctx->output_pads[i].name);
> >      av_frame_free(&ebur128->outpicref);
> > +    av_opt_free(ebur128);
> >  }
> >  
> >  static const AVFilterPad ebur128_inputs[] = {
> > @@ -753,6 +785,7 @@ static const AVFilterPad ebur128_inputs[] = {
> >          .type             = AVMEDIA_TYPE_AUDIO,
> >          .get_audio_buffer = ff_null_get_audio_buffer,
> >          .filter_frame     = filter_frame,
> > +        .config_props     = config_audio_input,
> >      },
> >      { NULL }
> >  };
> 
> LGTM.
> 

Applied a version with request_frame so we can skip the sensible first
patch.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130318/f541b50e/attachment.asc>


More information about the ffmpeg-devel mailing list