On 05/12/2014 04:39 AM, Luca Barbato wrote:
On 11/05/14 19:18, Justin Ruggles wrote:
On 05/10/2014 12:16 PM, Luca Barbato wrote:
+int avresample_convert_frame(AVAudioResampleContext *avr,
+ AVFrame *out, AVFrame *in)
+{
+ int ret, setup = 0;
+
+ if (!avresample_is_open(avr)) {
+ if ((ret = avresample_config(avr, out, in, NULL)) < 0)
+ return ret;
+ setup = 1;
+ } else {
+ // return as is or reconfigure for input changes?
+ if ((ret = avresample_config_changed(avr, out, in)))
+ return ret;
What do you think about having an option to automatically reconfigure
without returning? It would simplify the user code if they know they
will always want default settings for any potential new configuration.
It was one of the two options I asked feedback for at the start, it
would be probably nice to have since, while switching input format isn't
problematic, switching output resampling is gory.
I'm tempted to add an avoption to select the behaviour and then
implement both (help on the latter welcome).
Yeah the latter would be pretty ugly. Basically having to re-convert the
flushed samples to either the input or the new output format. But all
the alternatives I can think of are equally ugly...
This would segfault if out is NULL.
Right, I forgot about that codepath =)
Also, we should only override out->nb_samples if it is not already set
by the user.
Not sure which default behaviour would work best since we'd set its
value in a loop.
In my case I'd like to write the largest number of samples the frame
would fit every time, not the amount that was available last time.
But if we let the user provide the buffer (not calling get_buffer()
unconditionally) we should not assume how many samples they want to have
put in that buffer based on the linesize, which can have padding. The
only other solutions that come to mind that would allow the user to
specify their own buffer with padding are a separate param to indicate
the number of samples requested (with special-case for as much as
possible) or to follow the decoding model and allow get_buffer()
override. Besides that it just seems simpler to honor nb_samples, and if
you want the behavior you have in your patch, set nb_samples to 0 before
calling avresample_convert_frame() if you're reusing an old AVFrame.
-Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel