Revision 40c5fa26

View differences:

libavcodec/Makefile
15 15
      motion_est.o imgconvert.o imgresample.o \
16 16
      mpeg12.o mpegaudiodec.o pcm.o simple_idct.o \
17 17
      ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \
18
      fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \
18
      fft.o mdct.o mace.o huffyuv.o cyuv.o raw.o h264.o golomb.o \
19 19
      vp3.o asv1.o 4xm.o cabac.o ffv1.o ra144.o ra288.o vcr1.o cljr.o \
20 20
      roqvideo.o dpcm.o interplayvideo.o xan.o rpza.o cinepak.o msrle.o \
21 21
      msvideo1.o vqavideo.o idcinvideo.o adx.o rational.o faandct.o 8bps.o \
libavcodec/apiexample.c
409 409
    printf("\n");
410 410
}
411 411

  
412
// simple example how the options could be used
413
int options_example(int argc, char* argv[])
414
{
415
    AVCodec* codec = avcodec_find_encoder_by_name((argc > 1) ? argv[2] : "mpeg4");
416
    const AVOption* c;
417
    AVCodecContext* avctx;
418
#define DEF_SIZE 5000
419
    char* def = av_malloc(DEF_SIZE);
420
    const char* col = "";
421
    int i = 0;
422

  
423
    if (!codec)
424
	return -1;
425
    c = codec->options;
426
    avctx = avcodec_alloc_context();
427
    *def = 0;
428

  
429
    if (c) {
430
	const AVOption *stack[FF_OPT_MAX_DEPTH];
431
	int depth = 0;
432
	for (;;) {
433
	    if (!c->name) {
434
		if (c->help) {
435
		    stack[depth++] = c;
436
		    c = (const AVOption*)c->help;
437
		} else {
438
		    if (depth == 0)
439
			break; // finished
440
		    c = stack[--depth];
441
                    c++;
442
		}
443
	    } else {
444
		int t = c->type & FF_OPT_TYPE_MASK;
445
		printf("Config   %s  %s\n",
446
		       t == FF_OPT_TYPE_BOOL ? "bool   " :
447
		       t == FF_OPT_TYPE_DOUBLE ? "double  " :
448
		       t == FF_OPT_TYPE_INT ? "integer" :
449
		       t == FF_OPT_TYPE_STRING ? "string " :
450
		       "unknown??", c->name);
451
		switch (t) {
452
		case FF_OPT_TYPE_BOOL:
453
		    i += snprintf(def + i, DEF_SIZE-i, "%s%s=%s",
454
				 col, c->name,
455
				 c->defval != 0. ? "on" : "off");
456
		    break;
457
		case FF_OPT_TYPE_DOUBLE:
458
		    i += snprintf(def + i, DEF_SIZE-i, "%s%s=%f",
459
				 col, c->name, c->defval);
460
		    break;
461
		case FF_OPT_TYPE_INT:
462
		    i += snprintf(def + i, DEF_SIZE-i, "%s%s=%d",
463
				 col, c->name, (int) c->defval);
464
		    break;
465
		case FF_OPT_TYPE_STRING:
466
		    if (c->defstr) {
467
			char* d = av_strdup(c->defstr);
468
			char* f = strchr(d, ',');
469
			if (f)
470
                            *f = 0;
471
			i += snprintf(def + i, DEF_SIZE-i, "%s%s=%s",
472
				     col, c->name, d);
473
                        av_free(d);
474
		    }
475
		    break;
476
		}
477
		col = ":";
478
		c++;
479
	    }
480
	}
481
    }
482
    printf("Default Options: %s\n", def);
483
    av_free(def);
484
    return 0;
485
}
486

  
487

  
488 412
int main(int argc, char **argv)
489 413
{
490 414
    const char *filename;
......
496 420
       you wish to have smaller code */
497 421
    avcodec_register_all();
498 422

  
499
#ifdef OPT_TEST
500
    options_example(argc, argv);
501
#else
502 423
    if (argc <= 1) {
503 424
        audio_encode_example("/tmp/test.mp2");
504 425
        audio_decode_example("/tmp/test.sw", "/tmp/test.mp2");
......
511 432

  
512 433
    //    audio_decode_example("/tmp/test.sw", filename);
513 434
    video_decode_example("/tmp/test%d.pgm", filename);
514
#endif
515 435

  
516 436
    return 0;
517 437
}
libavcodec/avcodec.h
17 17

  
18 18
#define FFMPEG_VERSION_INT     0x000409
19 19
#define FFMPEG_VERSION         "0.4.9-pre1"
20
#define LIBAVCODEC_BUILD       4746
20
#define LIBAVCODEC_BUILD       4747
21 21

  
22 22
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
23 23
#define LIBAVCODEC_VERSION     FFMPEG_VERSION
......
1818 1818
} AVOption;
1819 1819

  
1820 1820
/**
1821
 * Parse option(s) and sets fields in passed structure
1822
 * @param strct	structure where the parsed results will be written
1823
 * @param list  list with AVOptions
1824
 * @param opts	string with options for parsing
1825
 */
1826
int avoption_parse(void* strct, const AVOption* list, const char* opts);
1827

  
1828

  
1829
/**
1830 1821
 * AVCodec.
1831 1822
 */
1832 1823
typedef struct AVCodec {
......
1840 1831
    int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
1841 1832
                  uint8_t *buf, int buf_size);
1842 1833
    int capabilities;
1843
    const AVOption *options;
1834
    void *dummy; // FIXME remove next time we break binary compatibility
1844 1835
    struct AVCodec *next;
1845 1836
    void (*flush)(AVCodecContext *);
1846 1837
    const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}
libavcodec/common.h
54 54
#define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr }
55 55
#define AVOPTION_END() AVOPTION_SUB(NULL)
56 56

  
57
struct AVOption;
58
#ifdef HAVE_MMX
59
extern const struct AVOption avoptions_common[3 + 5];
60
#else
61
extern const struct AVOption avoptions_common[3];
62
#endif
63
extern const struct AVOption avoptions_workaround_bug[11];
64

  
65 57
#endif /* HAVE_AV_CONFIG_H */
66 58

  
67 59
/* Suppress restrict if it was not defined in config.h.  */
libavcodec/h263dec.c
783 783
    return get_consumed_bytes(s, buf_size);
784 784
}
785 785

  
786
static const AVOption mpeg4_decoptions[] =
787
{
788
    AVOPTION_SUB(avoptions_workaround_bug),
789
    AVOPTION_END()
790
};
791

  
792 786
AVCodec mpeg4_decoder = {
793 787
    "mpeg4",
794 788
    CODEC_TYPE_VIDEO,
......
799 793
    ff_h263_decode_end,
800 794
    ff_h263_decode_frame,
801 795
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
802
    .options = mpeg4_decoptions,
803 796
    .flush= ff_mpeg_flush,
804 797
};
805 798

  
......
826 819
    ff_h263_decode_end,
827 820
    ff_h263_decode_frame,
828 821
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
829
    mpeg4_decoptions,
830 822
};
831 823

  
832 824
AVCodec msmpeg4v2_decoder = {
......
839 831
    ff_h263_decode_end,
840 832
    ff_h263_decode_frame,
841 833
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
842
    mpeg4_decoptions,
843 834
};
844 835

  
845 836
AVCodec msmpeg4v3_decoder = {
......
852 843
    ff_h263_decode_end,
853 844
    ff_h263_decode_frame,
854 845
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
855
    .options = mpeg4_decoptions,
856 846
};
857 847

  
858 848
AVCodec wmv1_decoder = {
......
865 855
    ff_h263_decode_end,
866 856
    ff_h263_decode_frame,
867 857
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
868
    mpeg4_decoptions,
869 858
};
870 859

  
871 860
AVCodec h263i_decoder = {
......
878 867
    ff_h263_decode_end,
879 868
    ff_h263_decode_frame,
880 869
    CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
881
    mpeg4_decoptions,
882 870
};
883 871

  
884 872
AVCodec flv_decoder = {
libavcodec/huffyuv.c
1219 1219
    return 0;
1220 1220
}
1221 1221

  
1222
static const AVOption huffyuv_options[] =
1223
{
1224
    AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0),
1225
    AVOPTION_END()
1226
};
1227

  
1228
static const AVOption ffvhuff_options[] =
1229
{
1230
    AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0),
1231
    AVOPTION_CODEC_INT("context_model", "context_model", context_model, 0, 2, 0),
1232
    AVOPTION_END()
1233
};
1234

  
1235

  
1236 1222
AVCodec huffyuv_decoder = {
1237 1223
    "huffyuv",
1238 1224
    CODEC_TYPE_VIDEO,
......
1269 1255
    encode_init,
1270 1256
    encode_frame,
1271 1257
    encode_end,
1272
    .options = huffyuv_options,
1273 1258
};
1274 1259

  
1275 1260
AVCodec ffvhuff_encoder = {
......
1280 1265
    encode_init,
1281 1266
    encode_frame,
1282 1267
    encode_end,
1283
    .options = ffvhuff_options,
1284 1268
};
1285 1269

  
1286 1270
#endif //CONFIG_ENCODERS
libavcodec/lcl.c
917 917
    encode_init,
918 918
    encode_frame,
919 919
    encode_end,
920
//    .options = lcl_options,
921 920
};
922 921

  
923 922
#endif //CONFIG_ENCODERS
libavcodec/mpegvideo.c
6399 6399
    }
6400 6400
}
6401 6401

  
6402
static const AVOption mpeg4_options[] =
6403
{
6404
    AVOPTION_CODEC_INT("bitrate", "desired video bitrate", bit_rate, 4, 240000000, 800000),
6405
    AVOPTION_CODEC_INT("ratetol", "number of bits the bitstream is allowed to diverge from the reference"
6406
		       "the reference can be CBR (for CBR pass1) or VBR (for pass2)",
6407
		       bit_rate_tolerance, 4, 240000000, 8000),
6408
    AVOPTION_CODEC_INT("qmin", "minimum quantizer", qmin, 1, 31, 2),
6409
    AVOPTION_CODEC_INT("qmax", "maximum quantizer", qmax, 1, 31, 31),
6410
    AVOPTION_CODEC_STRING("rc_eq", "rate control equation",
6411
			  rc_eq, "tex^qComp,option1,options2", 0),
6412
    AVOPTION_CODEC_INT("rc_minrate", "rate control minimum bitrate",
6413
		       rc_min_rate, 4, 24000000, 0),
6414
    AVOPTION_CODEC_INT("rc_maxrate", "rate control maximum bitrate",
6415
		       rc_max_rate, 4, 24000000, 0),
6416
    AVOPTION_CODEC_DOUBLE("rc_buf_aggresivity", "rate control buffer aggresivity",
6417
			  rc_buffer_aggressivity, 4, 24000000, 0),
6418
    AVOPTION_CODEC_DOUBLE("rc_initial_cplx", "initial complexity for pass1 ratecontrol",
6419
			  rc_initial_cplx, 0., 9999999., 0),
6420
    AVOPTION_CODEC_DOUBLE("i_quant_factor", "qscale factor between p and i frames",
6421
			  i_quant_factor, 0., 0., 0),
6422
    AVOPTION_CODEC_DOUBLE("i_quant_offset", "qscale offset between p and i frames",
6423
			  i_quant_factor, -999999., 999999., 0),
6424
    AVOPTION_CODEC_INT("dct_algo", "dct alghorithm",
6425
		       dct_algo, 0, 5, 0), // fixme - "Auto,FastInt,Int,MMX,MLib,Altivec"
6426
    AVOPTION_CODEC_DOUBLE("lumi_masking", "luminance masking",
6427
			  lumi_masking, 0., 999999., 0),
6428
    AVOPTION_CODEC_DOUBLE("temporal_cplx_masking", "temporary complexity masking",
6429
			  temporal_cplx_masking, 0., 999999., 0),
6430
    AVOPTION_CODEC_DOUBLE("spatial_cplx_masking", "spatial complexity masking",
6431
			  spatial_cplx_masking, 0., 999999., 0),
6432
    AVOPTION_CODEC_DOUBLE("p_masking", "p block masking",
6433
			  p_masking, 0., 999999., 0),
6434
    AVOPTION_CODEC_DOUBLE("dark_masking", "darkness masking",
6435
			  dark_masking, 0., 999999., 0),
6436
    AVOPTION_CODEC_INT("idct_algo", "idct alghorithm",
6437
		       idct_algo, 0, 8, 0), // fixme - "Auto,Int,Simple,SimpleMMX,LibMPEG2MMX,PS2,MLib,ARM,Altivec"
6438

  
6439
    AVOPTION_CODEC_INT("mb_qmin", "minimum MB quantizer",
6440
		       mb_qmin, 0, 8, 0),
6441
    AVOPTION_CODEC_INT("mb_qmax", "maximum MB quantizer",
6442
		       mb_qmin, 0, 8, 0),
6443

  
6444
    AVOPTION_CODEC_INT("me_cmp", "ME compare function",
6445
		       me_cmp, 0, 24000000, 0),
6446
    AVOPTION_CODEC_INT("me_sub_cmp", "subpixel ME compare function",
6447
		       me_sub_cmp, 0, 24000000, 0),
6448

  
6449

  
6450
    AVOPTION_CODEC_INT("dia_size", "ME diamond size & shape",
6451
		       dia_size, 0, 24000000, 0),
6452
    AVOPTION_CODEC_INT("last_predictor_count", "amount of previous MV predictors",
6453
		       last_predictor_count, 0, 24000000, 0),
6454

  
6455
    AVOPTION_CODEC_INT("pre_me", "pre pass for ME",
6456
		       pre_me, 0, 24000000, 0),
6457
    AVOPTION_CODEC_INT("me_pre_cmp", "ME pre pass compare function",
6458
		       me_pre_cmp, 0, 24000000, 0),
6459

  
6460
    AVOPTION_CODEC_INT("me_range", "maximum ME search range",
6461
		       me_range, 0, 24000000, 0),
6462
    AVOPTION_CODEC_INT("pre_dia_size", "ME pre pass diamod size & shape",
6463
		       pre_dia_size, 0, 24000000, 0),
6464
    AVOPTION_CODEC_INT("me_subpel_quality", "subpel ME quality",
6465
		       me_subpel_quality, 0, 24000000, 0),
6466
    AVOPTION_CODEC_INT("me_range", "maximum ME search range",
6467
		       me_range, 0, 24000000, 0),
6468
    AVOPTION_CODEC_FLAG("psnr", "calculate PSNR of compressed frames",
6469
		        flags, CODEC_FLAG_PSNR, 0),
6470
    AVOPTION_CODEC_RCOVERRIDE("rc_override", "ratecontrol override (=startframe,endframe,qscale,quality_factor)",
6471
			      rc_override),
6472
    AVOPTION_SUB(avoptions_common),
6473
    AVOPTION_END()
6474
};
6475

  
6476 6402
#ifdef CONFIG_ENCODERS
6477 6403
AVCodec h263_encoder = {
6478 6404
    "h263",
......
6538 6464
    MPV_encode_picture,
6539 6465
    MPV_encode_end,
6540 6466
    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
6541
    .options = mpeg4_options,
6542 6467
    .capabilities= CODEC_CAP_DELAY,
6543 6468
};
6544 6469

  
......
6551 6476
    MPV_encode_picture,
6552 6477
    MPV_encode_end,
6553 6478
    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
6554
    .options = mpeg4_options,
6555 6479
};
6556 6480

  
6557 6481
AVCodec msmpeg4v2_encoder = {
......
6563 6487
    MPV_encode_picture,
6564 6488
    MPV_encode_end,
6565 6489
    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
6566
    .options = mpeg4_options,
6567 6490
};
6568 6491

  
6569 6492
AVCodec msmpeg4v3_encoder = {
......
6575 6498
    MPV_encode_picture,
6576 6499
    MPV_encode_end,
6577 6500
    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
6578
    .options = mpeg4_options,
6579 6501
};
6580 6502

  
6581 6503
AVCodec wmv1_encoder = {
......
6587 6509
    MPV_encode_picture,
6588 6510
    MPV_encode_end,
6589 6511
    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
6590
    .options = mpeg4_options,
6591 6512
};
6592 6513

  
6593 6514
AVCodec mjpeg_encoder = {
libavcodec/opts.c
1
/*
2
 * LGPL
3
 */
4

  
5
/**
6
 * @file opts.c
7
 * options parser.
8
 * typical parsed command line:
9
 * msmpeg4:bitrate=720000:qmax=16
10
 *
11
 */
12

  
13
#include "avcodec.h"
14

  
15
const AVOption avoptions_common[] = {
16
    AVOPTION_CODEC_FLAG("bit_exact", "use only bit-exact stuff", flags, CODEC_FLAG_BITEXACT, 0),
17
    AVOPTION_CODEC_FLAG("mm_force", "force mm flags", dsp_mask, FF_MM_FORCE, 0),
18
#ifdef HAVE_MMX
19
    AVOPTION_CODEC_FLAG("mm_mmx", "mask MMX feature", dsp_mask, FF_MM_MMX, 0),
20
    AVOPTION_CODEC_FLAG("mm_3dnow", "mask 3DNow feature", dsp_mask, FF_MM_3DNOW, 0),
21
    AVOPTION_CODEC_FLAG("mm_mmxext", "mask MMXEXT (MMX2) feature", dsp_mask, FF_MM_MMXEXT, 0),
22
    AVOPTION_CODEC_FLAG("mm_sse", "mask SSE feature", dsp_mask, FF_MM_SSE, 0),
23
    AVOPTION_CODEC_FLAG("mm_sse2", "mask SSE2 feature", dsp_mask, FF_MM_SSE2, 0),
24
#endif
25
    AVOPTION_END()
26
};
27

  
28
const AVOption avoptions_workaround_bug[] = {
29
    AVOPTION_CODEC_FLAG("bug_autodetect", "workaround bug autodetection", workaround_bugs, FF_BUG_AUTODETECT, 1),
30
    AVOPTION_CODEC_FLAG("bug_old_msmpeg4", "workaround old msmpeg4 bug", workaround_bugs, FF_BUG_OLD_MSMPEG4, 0),
31
    AVOPTION_CODEC_FLAG("bug_xvid_ilace", "workaround XviD interlace bug", workaround_bugs, FF_BUG_XVID_ILACE, 0),
32
    AVOPTION_CODEC_FLAG("bug_ump4", "workaround ump4 bug", workaround_bugs, FF_BUG_UMP4, 0),
33
    AVOPTION_CODEC_FLAG("bug_no_padding", "workaround padding bug", workaround_bugs, FF_BUG_NO_PADDING, 0),
34
    AVOPTION_CODEC_FLAG("bug_ac_vlc", "workaround ac VLC bug", workaround_bugs, FF_BUG_AC_VLC, 0),
35
    AVOPTION_CODEC_FLAG("bug_qpel_chroma", "workaround qpel chroma bug", workaround_bugs, FF_BUG_QPEL_CHROMA, 0),
36
    AVOPTION_CODEC_FLAG("bug_std_qpel", "workaround std qpel bug", workaround_bugs, FF_BUG_STD_QPEL, 0),
37
    AVOPTION_CODEC_FLAG("bug_qpel_chroma2", "workaround qpel chroma2 bug", workaround_bugs, FF_BUG_QPEL_CHROMA2, 0),
38
    AVOPTION_CODEC_FLAG("bug_direct_blocksize", "workaround direct blocksize bug", workaround_bugs, FF_BUG_DIRECT_BLOCKSIZE, 0),
39
    AVOPTION_END()
40
};
41

  
42
/* avoid compatibility problems by redefining it */
43
static int av_strcasecmp(const char *s1, const char *s2)
44
{
45
    signed char val;
46
    
47
    for(;;) {
48
        val = toupper(*s1) - toupper(*s2);
49
        if (val != 0)
50
            break;
51
        if (*s1 != '\0')
52
            break;
53
        s1++;
54
        s2++;
55
    }
56
    return val;
57
}
58

  
59

  
60
static int parse_bool(const AVOption *c, char *s, int *var)
61
{
62
    int b = 1; /* by default -on- when present */
63
    if (s) {
64
	if (!av_strcasecmp(s, "off") || !av_strcasecmp(s, "false")
65
	    || !strcmp(s, "0"))
66
	    b = 0;
67
	else if (!av_strcasecmp(s, "on") || !av_strcasecmp(s, "true")
68
		 || !strcmp(s, "1"))
69
	    b = 1;
70
	else
71
	    return -1;
72
    }
73

  
74
    if (c->type == FF_OPT_TYPE_FLAG) {
75
	if (b)
76
	    *var |= (int)c->min;
77
	else
78
            *var &= ~(int)c->min;
79
    } else
80
	*var = b;
81
    return 0;
82
}
83

  
84
static int parse_double(const AVOption *c, char *s, double *var)
85
{
86
    double d;
87
    if (!s)
88
        return -1;
89
    d = atof(s);
90
    if (c->min != c->max) {
91
	if (d < c->min || d > c->max) {
92
	    av_log(NULL, AV_LOG_ERROR, "Option: %s double value: %f out of range <%f, %f>\n",
93
		    c->name, d, c->min, c->max);
94
	    return -1;
95
	}
96
    }
97
    *var = d;
98
    return 0;
99
}
100

  
101
static int parse_int(const AVOption* c, char* s, int* var)
102
{
103
    int i;
104
    if (!s)
105
        return -1;
106
    i = atoi(s);
107
    if (c->min != c->max) {
108
	if (i < (int)c->min || i > (int)c->max) {
109
	    av_log(NULL, AV_LOG_ERROR, "Option: %s integer value: %d out of range <%d, %d>\n",
110
		    c->name, i, (int)c->min, (int)c->max);
111
	    return -1;
112
	}
113
    }
114
    *var = i;
115
    return 0;
116
}
117

  
118
static int parse_string(const AVOption *c, char *s, void* strct, char **var)
119
{
120
    if (!s)
121
	return -1;
122

  
123
    if (c->type == FF_OPT_TYPE_RCOVERRIDE) {
124
	int sf, ef, qs;
125
	float qf;
126
	if (sscanf(s, "%d,%d,%d,%f", &sf, &ef, &qs, &qf) == 4 && sf < ef) {
127
	    AVCodecContext *avctx = (AVCodecContext *) strct;
128
	    RcOverride *o;
129
	    avctx->rc_override = av_realloc(avctx->rc_override,
130
					    sizeof(RcOverride) * (avctx->rc_override_count + 1));
131
	    o = avctx->rc_override + avctx->rc_override_count++;
132
	    o->start_frame = sf;
133
	    o->end_frame = ef;
134
	    o->qscale = qs;
135
	    o->quality_factor = qf;
136

  
137
	    //printf("parsed Rc:  %d,%d,%d,%f  (%d)\n", sf,ef,qs,qf, avctx->rc_override_count);
138
	} else {
139
	    av_log(NULL, AV_LOG_ERROR, "incorrect/unparsable Rc: \"%s\"\n", s);
140
	}
141
    } else
142
	*var = av_strdup(s);
143
    return 0;
144
}
145

  
146
int avoption_parse(void* strct, const AVOption* list, const char *opts)
147
{
148
    int r = 0;
149
    char* dopts = av_strdup(opts);
150
    if (dopts) {
151
        char *str = dopts;
152

  
153
	while (str && *str && r == 0) {
154
	    const AVOption *stack[FF_OPT_MAX_DEPTH];
155
	    const AVOption *c = list;
156
	    int depth = 0;
157
	    char* e = strchr(str, ':');
158
	    char* p;
159
	    if (e)
160
		*e++ = 0;
161

  
162
	    p = strchr(str, '=');
163
	    if (p)
164
		*p++ = 0;
165

  
166
            // going through option structures
167
	    for (;;) {
168
		if (!c->name) {
169
		    if (c->help) {
170
			stack[depth++] = c;
171
			c = (const AVOption*) c->help;
172
			assert(depth > FF_OPT_MAX_DEPTH);
173
		    } else {
174
			if (depth == 0)
175
			    break; // finished
176
			c = stack[--depth];
177
                        c++;
178
		    }
179
		} else {
180
		    if (!strcmp(c->name, str)) {
181
			void* ptr = (char*)strct + c->offset;
182

  
183
			switch (c->type & FF_OPT_TYPE_MASK) {
184
			case FF_OPT_TYPE_BOOL:
185
			    r = parse_bool(c, p, (int*)ptr);
186
			    break;
187
			case FF_OPT_TYPE_DOUBLE:
188
			    r = parse_double(c, p, (double*)ptr);
189
			    break;
190
			case FF_OPT_TYPE_INT:
191
			    r = parse_int(c, p, (int*)ptr);
192
			    break;
193
			case FF_OPT_TYPE_STRING:
194
			    r = parse_string(c, p, strct, (char**)ptr);
195
			    break;
196
			default:
197
			    assert(0 == 1);
198
			}
199
		    }
200
		    c++;
201
		}
202
	    }
203
	    str = e;
204
	}
205
	av_free(dopts);
206
    }
207
    return r;
208
}

Also available in: Unified diff