[FFmpeg-devel] [PATCH] Implement av_set_options_string()
Stefano Sabatini
stefano.sabatini-lala
Thu May 7 09:22:01 CEST 2009
On date Thursday 2009-05-07 02:02:58 +0200, Michael Niedermayer encoded:
> On Wed, May 06, 2009 at 09:52:46PM +0200, Stefano Sabatini wrote:
> > On date Wednesday 2009-05-06 05:15:40 +0200, Michael Niedermayer encoded:
> > > On Wed, May 06, 2009 at 12:33:28AM +0200, Stefano Sabatini wrote:
> [...]
> > > [...]
> > > > Index: libavfilter-soc/ffmpeg/libavfilter/parseutils.h
> > > > ===================================================================
> > > > --- libavfilter-soc.orig/ffmpeg/libavfilter/parseutils.h 2009-05-06 00:28:08.000000000 +0200
> > > > +++ libavfilter-soc/ffmpeg/libavfilter/parseutils.h 2009-05-06 00:29:32.000000000 +0200
> > > > @@ -63,4 +63,21 @@
> > > > options \
> > > > }
> > > >
> > > > +/**
> > > > + * Parses the key/value pairs list in opts. For each key/value pair
> > > > + * found, stores the value in the field in ctx that is named like the
> > > > + * key. ctx must be an AVClass context, storing is done using
> > > > + * AVOptions.
> > > > + *
> > > > + * @param key_val_sep a 0-terminated list of the characters used to
> > > > + * separate key from value
> > >
> > > > + * @param pairs_sep a 0-terminated list of the characters used to
> > > > + * separate key/value pairs
> > >
> > > seperate 2 ...
> >
> > Added some more test cases, result is now:
> >
> > Testing av_set_options_string()
> > [test @ 0xbfa56988]Setting options string ''
> >
> > [test @ 0xbfa56988]Setting options string ':'
> > [test @ 0xbfa56988]Missing key or no key/value separator found after key ':'
> > [test @ 0xbfa56988]Error setting options string: ':'
> >
> > [test @ 0xbfa56988]Setting options string '='
> > [test @ 0xbfa56988]Missing key or no key/value separator found after key ''
> > [test @ 0xbfa56988]Error setting options string: '='
> >
> > [test @ 0xbfa56988]Setting options string 'foo = :'
> > [test @ 0xbfa56988]Setting value '' for key 'foo'
> > [test @ 0xbfa56988]Unknown option key 'foo'
> > [test @ 0xbfa56988]Error setting options string: 'foo = :'
> >
> > [test @ 0xbfa56988]Setting options string ': = foo'
> > [test @ 0xbfa56988]Setting value 'foo' for key ':'
> > [test @ 0xbfa56988]Unknown option key ':'
> > [test @ 0xbfa56988]Error setting options string: ': = foo'
> >
> > [test @ 0xbfa56988]Setting options string '= foo'
> > [test @ 0xbfa56988]Missing key or no key/value separator found after key ''
> > [test @ 0xbfa56988]Error setting options string: '= foo'
> >
> > [test @ 0xbfa56988]Setting options string 'foo='
> > [test @ 0xbfa56988]Setting value '' for key 'foo'
> > [test @ 0xbfa56988]Unknown option key 'foo'
> > [test @ 0xbfa56988]Error setting options string: 'foo='
> >
> > [test @ 0xbfa56988]Setting options string 'foo'
> > [test @ 0xbfa56988]Missing key or no key/value separator found after key 'foo'
> > [test @ 0xbfa56988]Error setting options string: 'foo'
> >
> > [test @ 0xbfa56988]Setting options string 'foo=val'
> > [test @ 0xbfa56988]Setting value 'val' for key 'foo'
> > [test @ 0xbfa56988]Unknown option key 'foo'
> > [test @ 0xbfa56988]Error setting options string: 'foo=val'
> >
> > [test @ 0xbfa56988]Setting options string 'foo==val'
> > [test @ 0xbfa56988]Setting value '=val' for key 'foo'
> > [test @ 0xbfa56988]Unknown option key 'foo'
> > [test @ 0xbfa56988]Error setting options string: 'foo==val'
> >
> > [test @ 0xbfa56988]Setting options string 'toggle=:'
> > [test @ 0xbfa56988]Setting value '' for key 'toggle'
> > Unable to parse option value "": undefined constant or missing (
> > [test @ 0xbfa56988]Invalid value '' for key 'toggle'
> > [test @ 0xbfa56988]Error setting options string: 'toggle=:'
> >
> > [test @ 0xbfa56988]Setting options string 'string=:'
> > [test @ 0xbfa56988]Setting value '' for key 'string'
> >
> > [test @ 0xbfa56988]Setting options string 'toggle=1 : foo'
> > [test @ 0xbfa56988]Setting value '1' for key 'toggle'
> > [test @ 0xbfa56988]Missing key or no key/value separator found after key 'foo'
> > [test @ 0xbfa56988]Error setting options string: 'toggle=1 : foo'
> >
> > [test @ 0xbfa56988]Setting options string 'toggle=100'
> > [test @ 0xbfa56988]Setting value '100' for key 'toggle'
> > Value 100.000000 for parameter 'toggle' out of range
> > [test @ 0xbfa56988]Invalid value '100' for key 'toggle'
> > [test @ 0xbfa56988]Error setting options string: 'toggle=100'
> >
> > [test @ 0xbfa56988]Setting options string 'toggle==1'
> > [test @ 0xbfa56988]Setting value '=1' for key 'toggle'
> > Unable to parse option value "=1": undefined constant or missing (
> > [test @ 0xbfa56988]Invalid value '=1' for key 'toggle'
> > [test @ 0xbfa56988]Error setting options string: 'toggle==1'
> >
> > [test @ 0xbfa56988]Setting options string 'flags=+mu-lame : num=42: toggle=0'
> > [test @ 0xbfa56988]Setting value '+mu-lame' for key 'flags'
> > [test @ 0xbfa56988]Setting value '42' for key 'num'
> > [test @ 0xbfa56988]Setting value '0' for key 'toggle'
> >
> > [test @ 0xbfa56988]Setting options string 'num=42 : string=blahblah'
> > [test @ 0xbfa56988]Setting value '42' for key 'num'
> > [test @ 0xbfa56988]Setting value 'blahblah' for key 'string'
> >
> > [test @ 0xbfa56988]Setting options string 'rational=0 : rational=1/2 : rational=1/-1'
> > [test @ 0xbfa56988]Setting value '0' for key 'rational'
> > [test @ 0xbfa56988]Setting value '1/2' for key 'rational'
> > [test @ 0xbfa56988]Setting value '1/-1' for key 'rational'
> > Unable to parse option value "1/-1": undefined constant or missing (
> > [test @ 0xbfa56988]Invalid value '1/-1' for key 'rational'
> > [test @ 0xbfa56988]Error setting options string: 'rational=0 : rational=1/2 : rational=1/-1'
> >
> > [test @ 0xbfa56988]Setting options string 'rational=-1/0'
> > [test @ 0xbfa56988]Setting value '-1/0' for key 'rational'
> > Value -inf for parameter 'rational' out of range
> > [test @ 0xbfa56988]Invalid value '-1/0' for key 'rational'
> > [test @ 0xbfa56988]Error setting options string: 'rational=-1/0'
> >
> > Regards.
> > --
> > FFmpeg = Fundamentalist Faithless Multimedia Power Elaborated Gadget
>
> > parseutils.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > parseutils.h | 19 ++++++++
> > 2 files changed, 158 insertions(+)
> > ac27e17f4f13f6d420cc89211e05104162e4f1b3 parseutils-implement-set-options.patch
> > Index: libavfilter-soc/ffmpeg/libavfilter/parseutils.c
> > ===================================================================
> > --- libavfilter-soc.orig/ffmpeg/libavfilter/parseutils.c 2009-05-06 20:58:43.000000000 +0200
> > +++ libavfilter-soc/ffmpeg/libavfilter/parseutils.c 2009-05-06 21:49:38.000000000 +0200
> > @@ -248,10 +248,110 @@
> > return 0;
> > }
> >
> > +/**
> > + * Stores the value in the field in ctx that is named like key.
> > + * ctx must be an AVClass context, storing is done using AVOptions.
> > + *
>
> > + * @param buf the buffer to parse, buf will be updated to point to the
> > + * character just after the string to parse
>
> the string to parse, will be updated to point at/after? the pair seperator.
Changed:
* @param buf the string to parse, buf will be updated to point at the
* separator just after the parsed key/value pair
Suggestions are welcome.
> > + * @param key_val_sep a 0-terminated list of the characters used to
> > + * separate key from value
> > + * @param pairs_sep a 0-terminated list of the characters used to
> > + * separate two pairs from each other
> > + * @return 0 if no key/value pair has been found, 1 if a key/value
> > + * pair has been successfully parsed and set, a negative value
> > + * otherwise
> > + */
> > +static int parse_key_value_pair(void *ctx, const char **buf,
> > + const char *key_val_sep, const char *pairs_sep)
> > +{
>
> > + char *key = av_get_token(buf, key_val_sep);
> > + char *val;
>
> const?
Well, they're freed after their used and I wanted to avoid pesky
warnings.
Regards.
--
FFmpeg = Foolish and Friendly Mean Power Exuberant Guru
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parseutils-implement-set-options.patch
Type: text/x-diff
Size: 6515 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090507/a144e376/attachment.patch>
More information about the ffmpeg-devel
mailing list