Revision 628d601b

View differences:

libavcodec/avcodec.h
1109 1109

  
1110 1110
void avcodec_flush_buffers(AVCodecContext *avctx);
1111 1111

  
1112
typedef struct {
1113
    /** options' name with default value*/
1114
    const char* name;
1115
    /** English text help */
1116
    const char* help;
1117
    /** type of variable */
1118
    int type;
1119
#define FF_CONF_TYPE_BOOL 1     // boolean - true,1,on  (or simply presence)
1120
#define FF_CONF_TYPE_DOUBLE 2   // double
1121
#define FF_CONF_TYPE_INT 3      // integer
1122
#define FF_CONF_TYPE_STRING 4   // string (finished with \0)
1123
#define FF_CONF_TYPE_MASK 0x1f	// mask for types - upper bits are various flags
1124
#define FF_CONF_TYPE_EXPERT 0x20 // flag for expert option
1125
#define FF_CONF_TYPE_FLAG (FF_CONF_TYPE_BOOL | 0x40)
1126
#define FF_CONF_TYPE_RCOVERIDE (FF_CONF_TYPE_STRING | 0x80)
1127
    /** where the parsed value should be stored */
1128
    void* val;
1129
    /** min value  (min == max   ->  no limits) */
1130
    double min;
1131
    /** maximum value for double/int */
1132
    double max;
1133
    /** default boo [0,1]l/double/int value */
1134
    double defval;
1135
    /**
1136
     * default string value (with optional semicolon delimited extra option-list
1137
     * i.e.   option1;option2;option3
1138
     * defval might select other then first argument as default
1139
     */
1140
    const char* defstr;
1141
    /** char* list of supported codecs (i.e. ",msmpeg4,h263," NULL - everything */
1142
    const char* supported;
1143
} avc_config_t;
1144

  
1145
void avcodec_getopt(AVCodecContext* avctx, char* str, avc_config_t** config);
1146

  
1112 1147
/**
1113 1148
 * Interface for 0.5.0 version
1114 1149
 *
......
1193 1228
#define av_freep(p) __av_freep((void **)(p))
1194 1229
/* for static data only */
1195 1230
/* call av_free_static to release all staticaly allocated tables */
1196
void av_free_static();
1231
void av_free_static(void);
1197 1232
void *__av_mallocz_static(void** location, unsigned int size);
1198 1233
#define av_mallocz_static(p, s) __av_mallocz_static((void **)(p), s)
1199 1234

  
libavcodec/opts.c
1
/*
2
 * LGPL
3
 */
4

  
5
/*
6
 * typical parsed command line:
7
 * msmpeg4:bitrate=720000:qmax=16
8
 *
9
 */
10

  
11
#include "avcodec.h"
12

  
13
/*
14
 * possible extension - use for decoder options
15
 *                    - for given codec names filter only correct
16
 *                      options given (could be passed with 'str')
17
 */
18

  
19
/**
20
 * \param avctx  where to store parsed results
21
 * \param str    string with options for parsing
22
 * \param config allocated avc_config_t for external parsing
23
 *               i.e. external program might learn about all available
24
 *               options for given codec
25
 **/
26
void avcodec_getopt(AVCodecContext* avctx, char* str, avc_config_t** config)
27
{
28
    AVCodecContext avctx_tmp;
29
    AVCodecContext* ctx = (avctx) ? avctx : &avctx_tmp;
30
    static const char* class_h263 = ",msmpeg4,";
31
    //"huffyuv,wmv1,msmpeg4v2,msmpeg4,mpeg4,mpeg1,mpeg1video,mjpeg,rv10,h263,h263p"
32

  
33
    avc_config_t cnf[] =
34
    {
35
	// FIXME: sorted by importance!!!
36
        // expert option should follow more common ones
37
	{
38
	    "bitrate", "desired video bitrate",
39
	    FF_CONF_TYPE_INT, &ctx->bit_rate, 4, 240000000, 800000, NULL, class_h263
40
	}, {
41
	    "vhq", "very high quality",
42
	    FF_CONF_TYPE_FLAG, &ctx->flags, 0, CODEC_FLAG_HQ, 0, NULL, class_h263
43
	}, {
44
	    "ratetol", "number of bits the bitstream is allowed to diverge from the reference"
45
	    "the reference can be CBR (for CBR pass1) or VBR (for pass2)",
46
	    FF_CONF_TYPE_INT, &ctx->bit_rate_tolerance, 4, 240000000, 8000, NULL, class_h263
47
	}, {
48
	    "qmin", "minimum quantizer", FF_CONF_TYPE_INT, &ctx->qmin, 1, 31, 2, NULL, class_h263
49
	}, {
50
	    "qmax", "maximum qunatizer", FF_CONF_TYPE_INT, &ctx->qmax, 1, 31, 31, NULL, class_h263
51
	}, {
52
	    "rc_eq", "rate control equation",
53
	    FF_CONF_TYPE_STRING, &ctx->rc_eq, 0, 0, 0, "tex^qComp" /* FILLME options */, class_h263
54
	}, {
55
	    "rc_minrate", "rate control minimum bitrate",
56
	    FF_CONF_TYPE_INT, &ctx->rc_min_rate, 4, 24000000, 0, NULL, class_h263
57
	}, {
58
	    "rc_maxrate", "rate control maximum bitrate",
59
	    FF_CONF_TYPE_INT, &ctx->rc_max_rate, 4, 24000000, 0, NULL, class_h263
60
	}, {
61
	    "psnr", "calculate PSNR of compressed frames",
62
	    FF_CONF_TYPE_FLAG, &ctx->flags, 0, CODEC_FLAG_PSNR, 0, NULL, class_h263
63
	}, {
64
	    "rc_override", "ratecontrol override (=startframe,endframe,qscale,quality_factor)",
65
	    FF_CONF_TYPE_RCOVERIDE, &ctx->rc_override, 0, 0, 0, NULL, class_h263
66
	},
67

  
68
        { NULL, NULL, 0, NULL, 0, 0, 0, NULL, NULL }
69
    };
70

  
71
    if (config)
72
    {
73
	*config = malloc(sizeof(cnf));
74
	if (*config)
75
            memcpy(*config, cnf, sizeof(cnf));
76
    }
77
}

Also available in: Unified diff