On 09/05/14 09:59, wm4 wrote:
> On Mon,  5 May 2014 16:11:33 +0200
> Luca Barbato <[email protected]> wrote:
> 
>> ---
>>  libavresample/avresample.h |  72 +++++++++++++++++++++++++
>>  libavresample/utils.c      | 128 
>> +++++++++++++++++++++++++++++++++++++++++++++
>>  libavutil/error.h          |   2 +
>>  3 files changed, 202 insertions(+)
>>
>> diff --git a/libavresample/avresample.h b/libavresample/avresample.h
>> index 0d42e88..37b92d3 100644
>> --- a/libavresample/avresample.h
>> +++ b/libavresample/avresample.h
>> @@ -95,6 +95,7 @@
>>  #include "libavutil/avutil.h"
>>  #include "libavutil/channel_layout.h"
>>  #include "libavutil/dict.h"
>> +#include "libavutil/frame.h"
>>  #include "libavutil/log.h"
>>  #include "libavutil/mathematics.h"
>>  
>> @@ -165,6 +166,10 @@ AVAudioResampleContext *avresample_alloc_context(void);
>>  
>>  /**
>>   * Initialize AVAudioResampleContext.
>> + * @note The context must be configured using the AVOption api.
>> + *
>> + * @see av_opt_set_int()
>> + * @see av_opt_set_dict()
>>   *
>>   * @param avr  audio resample context
>>   * @return     0 on success, negative AVERROR code on failure
>> @@ -424,6 +429,73 @@ int avresample_available(AVAudioResampleContext *avr);
>>   */
>>  int avresample_read(AVAudioResampleContext *avr, uint8_t **output, int 
>> nb_samples);
>>  
>> +
>> +
>> +/**
>> + * Convert the samples in the input AVFrame and write them to the output 
>> AVFrame.
>> + *
>> + * Input and output AVFrames must have channel_layout, sample_rate and 
>> format set.
> 
> What about other things. Will side-data be used? Both
> AV_FRAME_DATA_MATRIXENCODING and AV_FRAME_DATA_DOWNMIX_INFO
> seem relevant.
> 
> (I know the patch currently doesn't implement them. But should they in
> the future? If so, should that be reflected in the documentation? There
> needs to be forward-compatibility too.)

I'd mention them when they are supported, having that information
missing won't make the conversion fail.

> You should also mention avresample_max_output_samples().

Good catch! Thank you.

> Annoying corner cases: what if the format is planar and only some
> pointers are allocated? I guess this should be considered invalid.

Not sure that is the right place to check it, but yes, it would be invalid.

> IMO this absolutely should provide a example how to convert a stream of
> input AVFrame (in any format). The code fragment should fully handle
> format changes. It's best to provide this right in the docs, instead of
> requiring every API user to reinvent it badly.

I do agree, I'd put the snippet in the code and have a working example
in the docs/examples.

>> + * @param avr             audio resample context
>> + * @param output          output AVFrame
>> + * @param input           input AVFrame
>> + * @return                0 on success, AVERROR on failure or nonmatching
>> + *                        configuration.
>> + */
>> +int avresample_convert_frame(AVAudioResampleContext *avr,
>> +                             AVFrame *output, AVFrame *input);
>> +
>> +/**
>> + * Configure or reconfigure the AVAudioResampleContext using the information
>> + * provided by the AVFrames and an optional AVDictionary containing 
>> additional
>> + * resampler options.
>> + *
>> + * The original resampling context is reset even on failure.
>> + * The function calls internally avresample_open().
>> + *
>> + * @see avresample_open();
>> + *
>> + * @param avr             audio resample context
>> + * @param output          output AVFrame
>> + * @param input           input AVFrame
> 
> Forgets opts.
> 
> Should opts be allowed to be NULL?

Might be a good idea.

> IMO there absolutely should be a public function that should check
> whether two AVFrames have the same configuration, and/or a function
> which checks whether an AVFrame is the same as the current configured
> in/out format of the context (like the private config_changed).

The function can be exposed anytime, Justin wanted me to prepare a
commit with the least API increment so I kept it hidden.

lu


_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to