On Sun, May 01, 2011 at 12:01:35PM +0200, Stefano Sabatini wrote:
On date Sunday 2011-05-01 10:31:12 +1000, Peter Ross wrote:
On Sun, May 01, 2011 at 02:04:58AM +0200, Stefano Sabatini wrote: [...]
String default value setting doesn't work, that's because av_set_string3() doesn't accept NULL values for val, so for example:
av_set_string3(obj, name, NULL, 1, NULL);
will always return AVERROR(EINVAL).
Here there is a problem since you can't represent a NULL value string with a string safely, you could set "" but that's not the very same thing.
But you could define a valid string that FFmpeg treats always as NULL.
e.g.
avcodec/string.h extern const char * av_null_string;
avutil/string.c const char *av_null_string = "(null)";
av_set_string(..)
if (str == av_null_string)
behave this way
That's possible, an alternative could be to make av_set_string() accept the NULL vale for string options.
already done locally
But this is only part of the problem, when you set options for the first time you have random values in the context, so you need a function for initing the context, that is av_opt_set_defaults2() is not anymore sufficient, you need at least to pass a flag to it for telling that it has to init the context (and ignore the already present string fubar values).
contexts should be allocated with av_mallocz() or if they are on the stack they should be memset(0). [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The misfortune of the wise is better than the prosperity of the fool. -- Epicurus