aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/opts.c
blob: bcefc40a3b7c7b7ffe56ab720c7b07af33c73621 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * LGPL
 */

/*
 * typical parsed command line:
 * msmpeg4:bitrate=720000:qmax=16
 *
 */

#include "avcodec.h"

/*
 * possible extension - use for decoder options
 *                    - for given codec names filter only correct
 *                      options given (could be passed with 'str')
 */

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

    avc_config_t cnf[] =
    {
	// FIXME: sorted by importance!!!
        // expert option should follow more common ones
	{
	    "bitrate", "desired video bitrate",
	    FF_CONF_TYPE_INT, &ctx->bit_rate, 4, 240000000, 800000, NULL, class_h263
	}, {
	    "vhq", "very high quality",
	    FF_CONF_TYPE_FLAG, &ctx->flags, 0, CODEC_FLAG_HQ, 0, NULL, class_h263
	}, {
	    "ratetol", "number of bits the bitstream is allowed to diverge from the reference"
	    "the reference can be CBR (for CBR pass1) or VBR (for pass2)",
	    FF_CONF_TYPE_INT, &ctx->bit_rate_tolerance, 4, 240000000, 8000, NULL, class_h263
	}, {
	    "qmin", "minimum quantizer", FF_CONF_TYPE_INT, &ctx->qmin, 1, 31, 2, NULL, class_h263
	}, {
	    "qmax", "maximum qunatizer", FF_CONF_TYPE_INT, &ctx->qmax, 1, 31, 31, NULL, class_h263
	}, {
	    "rc_eq", "rate control equation",
	    FF_CONF_TYPE_STRING, &ctx->rc_eq, 0, 0, 0, "tex^qComp" /* FILLME options */, class_h263
	}, {
	    "rc_minrate", "rate control minimum bitrate",
	    FF_CONF_TYPE_INT, &ctx->rc_min_rate, 4, 24000000, 0, NULL, class_h263
	}, {
	    "rc_maxrate", "rate control maximum bitrate",
	    FF_CONF_TYPE_INT, &ctx->rc_max_rate, 4, 24000000, 0, NULL, class_h263
	}, {
	    "psnr", "calculate PSNR of compressed frames",
	    FF_CONF_TYPE_FLAG, &ctx->flags, 0, CODEC_FLAG_PSNR, 0, NULL, class_h263
	}, {
	    "rc_override", "ratecontrol override (=startframe,endframe,qscale,quality_factor)",
	    FF_CONF_TYPE_RCOVERIDE, &ctx->rc_override, 0, 0, 0, NULL, class_h263
	},

        { NULL, NULL, 0, NULL, 0, 0, 0, NULL, NULL }
    };

    if (config)
    {
	*config = malloc(sizeof(cnf));
	if (*config)
            memcpy(*config, cnf, sizeof(cnf));
    }
}