Differences between revisions 1 and 2
Revision 1 as of 2014-04-13 18:02:07
Size: 1253
Editor: lu_zero
Comment:
Revision 2 as of 2014-04-19 10:26:40
Size: 2229
Editor: lu_zero
Comment:
Deletions are marked like this. Additions are marked like this.
Line 29: Line 29:
The function is currently equivalent of using the AVOption api directly on the '''avr''' context and then call '''avresample_open'''.
Line 35: Line 37:
int avresample_open_frame(AVAudioResampleContext *avr, AVFrame *out, AVFrame *in, AVDictionary **opts); int avresample_config(AVAudioResampleContext *avr, AVFrame *out, AVFrame *in, AVDictionary **opts);
Line 41: Line 43:
The normal workflow would be quite simplified

{{{#!code c
 AVAudioResampleContext *avr = avresample_alloc();
 AVFrame *out = av_frame_alloc();
 AVFrame *in;

 out->format = format;
 out->channel_layout = layout;
 out->sample_rate = rate;

 while (fill_input(in)) {
    ret = avresample_convert_frame(avr, out, in);

    if (configuration_changed(ret))
         avresample_convert_frame(avr, out, NULL);
         process(out);
         avresample_config(avr, out, in);
         avresample_convert_frame(avr, out, in);
    }
    process(out);
 }

 ret = avresample_convert_frame(avr, out, NULL);

 process(out);
}}}

Albeit not checking for allocation errors to keep the code compact, the code above is all that's needed to adapt to changes to the input format and convert to a fixed output.
Line 42: Line 74:

This page is documenting a work in progress feature do not assume it is available on the mainline branch.

Rationale

AVResample is getting extended and some resamplers and mixers have additional parameters that can be user-tuned. In order to match AVScale an AVFrame-based API will be introduced.

API Design

The API extension includes

  • A new function, with slightly different semantics, to configure/reconfigure the resampling context passing extended options.
  • A set of AVFrame based function to have a simplified setup.

Additional options

The new avresample_open2() will match the similarly-named functions in AVCodec and AVFormat.

int avresample_open2(AVAudioResampleContext *avr, AVDictionary **opts);

The function is currently equivalent of using the AVOption api directly on the avr context and then call avresample_open.

AVFrame based API

The main focus had been to simplify the setup and make AVResample simpler to use.

int avresample_config(AVAudioResampleContext *avr, AVFrame *out, AVFrame *in, AVDictionary **opts);

int avresample_convert_frame(AVAudioResampleContext *avr, AVFrame *out, AVFrame *in);

The normal workflow would be quite simplified

 AVAudioResampleContext *avr = avresample_alloc();
 AVFrame *out = av_frame_alloc();
 AVFrame *in;

 out->format              = format;
 out->channel_layout = layout;
 out->sample_rate     = rate;

 while (fill_input(in)) {
    ret = avresample_convert_frame(avr, out, in);

    if (configuration_changed(ret))
         avresample_convert_frame(avr, out, NULL);
         process(out);
         avresample_config(avr, out, in);
         avresample_convert_frame(avr, out, in);
    }
    process(out);
 }

 ret = avresample_convert_frame(avr, out, NULL);

 process(out);

Albeit not checking for allocation errors to keep the code compact, the code above is all that's needed to adapt to changes to the input format and convert to a fixed output.

Architecture Design


CategoryBlueprint CategoryWIP