On 08/09/2014 10:36 AM, wm4 wrote:
On Sat, 09 Aug 2014 10:26:16 -0400
Justin Ruggles <[email protected]> wrote:

On 08/02/2014 10:56 AM, Luca Barbato wrote:
---
+int avresample_config(AVAudioResampleContext *avr, AVFrame *out, AVFrame *in,
+                      AVDictionary **opts)
+{
+    int ret;
+
+    if (avresample_is_open(avr)) {
+        avresample_close(avr);
+    }
+
+    if (in) {
+        avr->in_channel_layout  = in->channel_layout;
+        avr->in_sample_rate     = in->sample_rate;
+        avr->in_sample_fmt      = in->format;
+    }
+
+    if (out) {
+        avr->out_channel_layout = out->channel_layout;
+        avr->out_sample_rate    = out->sample_rate;
+        avr->out_sample_fmt     = out->format;
+    }
+
+    if (opts) {
+        if ((ret = av_opt_set_dict(avr, opts)) < 0)
+            return ret;
+    }
Since input/output params can also be set through AVOption, it may be
beneficial to check for consistency.

I'm a bit worried about this part of API design in general: what if
features are added to AVFrame that overlap with what can be configured
with AVOption? On one hand, it'd be nice if configuration is as
automatic as possible, and settings are derived from AVFrame parameters.
On the other hand you'd have to detect whether an AVOption was set (or
set to a conflicting value), which all leads to chaos.

It doesn't necessarily lead to chaos. We could, for example, document clearly that the AVOptions take precedence over AVFrame values. In some cases we can print warnings for conflicts (channel_layout/sample_rate/sample_fmt), and in some other future cases it might be better not to.

-Justin

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

Reply via email to