AVOption removial patch from (James A. Morrison >ja2morri csclub.uwaterloo ca>)

with minor changes from me

Originally committed as revision 4019 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Michael Niedermayer 20 years ago
parent 6867a90b41
commit 40c5fa2689
  1. 2
      libavcodec/Makefile
  2. 80
      libavcodec/apiexample.c
  3. 13
      libavcodec/avcodec.h
  4. 8
      libavcodec/common.h
  5. 12
      libavcodec/h263dec.c
  6. 16
      libavcodec/huffyuv.c
  7. 1
      libavcodec/lcl.c
  8. 79
      libavcodec/mpegvideo.c
  9. 208
      libavcodec/opts.c

@ -15,7 +15,7 @@ OBJS= bitstream.o utils.o mem.o allcodecs.o \
motion_est.o imgconvert.o imgresample.o \
mpeg12.o mpegaudiodec.o pcm.o simple_idct.o \
ratecontrol.o adpcm.o eval.o dv.o error_resilience.o \
fft.o mdct.o mace.o huffyuv.o cyuv.o opts.o raw.o h264.o golomb.o \
fft.o mdct.o mace.o huffyuv.o cyuv.o raw.o h264.o golomb.o \
vp3.o asv1.o 4xm.o cabac.o ffv1.o ra144.o ra288.o vcr1.o cljr.o \
roqvideo.o dpcm.o interplayvideo.o xan.o rpza.o cinepak.o msrle.o \
msvideo1.o vqavideo.o idcinvideo.o adx.o rational.o faandct.o 8bps.o \

@ -409,82 +409,6 @@ void video_decode_example(const char *outfilename, const char *filename)
printf("\n");
}
// simple example how the options could be used
int options_example(int argc, char* argv[])
{
AVCodec* codec = avcodec_find_encoder_by_name((argc > 1) ? argv[2] : "mpeg4");
const AVOption* c;
AVCodecContext* avctx;
#define DEF_SIZE 5000
char* def = av_malloc(DEF_SIZE);
const char* col = "";
int i = 0;
if (!codec)
return -1;
c = codec->options;
avctx = avcodec_alloc_context();
*def = 0;
if (c) {
const AVOption *stack[FF_OPT_MAX_DEPTH];
int depth = 0;
for (;;) {
if (!c->name) {
if (c->help) {
stack[depth++] = c;
c = (const AVOption*)c->help;
} else {
if (depth == 0)
break; // finished
c = stack[--depth];
c++;
}
} else {
int t = c->type & FF_OPT_TYPE_MASK;
printf("Config %s %s\n",
t == FF_OPT_TYPE_BOOL ? "bool " :
t == FF_OPT_TYPE_DOUBLE ? "double " :
t == FF_OPT_TYPE_INT ? "integer" :
t == FF_OPT_TYPE_STRING ? "string " :
"unknown??", c->name);
switch (t) {
case FF_OPT_TYPE_BOOL:
i += snprintf(def + i, DEF_SIZE-i, "%s%s=%s",
col, c->name,
c->defval != 0. ? "on" : "off");
break;
case FF_OPT_TYPE_DOUBLE:
i += snprintf(def + i, DEF_SIZE-i, "%s%s=%f",
col, c->name, c->defval);
break;
case FF_OPT_TYPE_INT:
i += snprintf(def + i, DEF_SIZE-i, "%s%s=%d",
col, c->name, (int) c->defval);
break;
case FF_OPT_TYPE_STRING:
if (c->defstr) {
char* d = av_strdup(c->defstr);
char* f = strchr(d, ',');
if (f)
*f = 0;
i += snprintf(def + i, DEF_SIZE-i, "%s%s=%s",
col, c->name, d);
av_free(d);
}
break;
}
col = ":";
c++;
}
}
}
printf("Default Options: %s\n", def);
av_free(def);
return 0;
}
int main(int argc, char **argv)
{
const char *filename;
@ -496,9 +420,6 @@ int main(int argc, char **argv)
you wish to have smaller code */
avcodec_register_all();
#ifdef OPT_TEST
options_example(argc, argv);
#else
if (argc <= 1) {
audio_encode_example("/tmp/test.mp2");
audio_decode_example("/tmp/test.sw", "/tmp/test.mp2");
@ -511,7 +432,6 @@ int main(int argc, char **argv)
// audio_decode_example("/tmp/test.sw", filename);
video_decode_example("/tmp/test%d.pgm", filename);
#endif
return 0;
}

@ -17,7 +17,7 @@ extern "C" {
#define FFMPEG_VERSION_INT 0x000409
#define FFMPEG_VERSION "0.4.9-pre1"
#define LIBAVCODEC_BUILD 4746
#define LIBAVCODEC_BUILD 4747
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION
@ -1817,15 +1817,6 @@ typedef struct AVOption {
#define FF_OPT_MAX_DEPTH 10
} AVOption;
/**
* Parse option(s) and sets fields in passed structure
* @param strct structure where the parsed results will be written
* @param list list with AVOptions
* @param opts string with options for parsing
*/
int avoption_parse(void* strct, const AVOption* list, const char* opts);
/**
* AVCodec.
*/
@ -1840,7 +1831,7 @@ typedef struct AVCodec {
int (*decode)(AVCodecContext *, void *outdata, int *outdata_size,
uint8_t *buf, int buf_size);
int capabilities;
const AVOption *options;
void *dummy; // FIXME remove next time we break binary compatibility
struct AVCodec *next;
void (*flush)(AVCodecContext *);
const AVRational *supported_framerates; ///array of supported framerates, or NULL if any, array is terminated by {0,0}

@ -54,14 +54,6 @@
#define AVOPTION_SUB(ptr) { .name = NULL, .help = (const char*)ptr }
#define AVOPTION_END() AVOPTION_SUB(NULL)
struct AVOption;
#ifdef HAVE_MMX
extern const struct AVOption avoptions_common[3 + 5];
#else
extern const struct AVOption avoptions_common[3];
#endif
extern const struct AVOption avoptions_workaround_bug[11];
#endif /* HAVE_AV_CONFIG_H */
/* Suppress restrict if it was not defined in config.h. */

@ -783,12 +783,6 @@ printf("%Ld\n", rdtsc()-time);
return get_consumed_bytes(s, buf_size);
}
static const AVOption mpeg4_decoptions[] =
{
AVOPTION_SUB(avoptions_workaround_bug),
AVOPTION_END()
};
AVCodec mpeg4_decoder = {
"mpeg4",
CODEC_TYPE_VIDEO,
@ -799,7 +793,6 @@ AVCodec mpeg4_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
.options = mpeg4_decoptions,
.flush= ff_mpeg_flush,
};
@ -826,7 +819,6 @@ AVCodec msmpeg4v1_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
mpeg4_decoptions,
};
AVCodec msmpeg4v2_decoder = {
@ -839,7 +831,6 @@ AVCodec msmpeg4v2_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
mpeg4_decoptions,
};
AVCodec msmpeg4v3_decoder = {
@ -852,7 +843,6 @@ AVCodec msmpeg4v3_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
.options = mpeg4_decoptions,
};
AVCodec wmv1_decoder = {
@ -865,7 +855,6 @@ AVCodec wmv1_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
mpeg4_decoptions,
};
AVCodec h263i_decoder = {
@ -878,7 +867,6 @@ AVCodec h263i_decoder = {
ff_h263_decode_end,
ff_h263_decode_frame,
CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
mpeg4_decoptions,
};
AVCodec flv_decoder = {

@ -1219,20 +1219,6 @@ static int encode_end(AVCodecContext *avctx)
return 0;
}
static const AVOption huffyuv_options[] =
{
AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0),
AVOPTION_END()
};
static const AVOption ffvhuff_options[] =
{
AVOPTION_CODEC_INT("prediction_method", "prediction_method", prediction_method, 0, 2, 0),
AVOPTION_CODEC_INT("context_model", "context_model", context_model, 0, 2, 0),
AVOPTION_END()
};
AVCodec huffyuv_decoder = {
"huffyuv",
CODEC_TYPE_VIDEO,
@ -1269,7 +1255,6 @@ AVCodec huffyuv_encoder = {
encode_init,
encode_frame,
encode_end,
.options = huffyuv_options,
};
AVCodec ffvhuff_encoder = {
@ -1280,7 +1265,6 @@ AVCodec ffvhuff_encoder = {
encode_init,
encode_frame,
encode_end,
.options = ffvhuff_options,
};
#endif //CONFIG_ENCODERS

@ -917,7 +917,6 @@ AVCodec zlib_encoder = {
encode_init,
encode_frame,
encode_end,
// .options = lcl_options,
};
#endif //CONFIG_ENCODERS

@ -6399,80 +6399,6 @@ static void dct_unquantize_h263_inter_c(MpegEncContext *s,
}
}
static const AVOption mpeg4_options[] =
{
AVOPTION_CODEC_INT("bitrate", "desired video bitrate", bit_rate, 4, 240000000, 800000),
AVOPTION_CODEC_INT("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)",
bit_rate_tolerance, 4, 240000000, 8000),
AVOPTION_CODEC_INT("qmin", "minimum quantizer", qmin, 1, 31, 2),
AVOPTION_CODEC_INT("qmax", "maximum quantizer", qmax, 1, 31, 31),
AVOPTION_CODEC_STRING("rc_eq", "rate control equation",
rc_eq, "tex^qComp,option1,options2", 0),
AVOPTION_CODEC_INT("rc_minrate", "rate control minimum bitrate",
rc_min_rate, 4, 24000000, 0),
AVOPTION_CODEC_INT("rc_maxrate", "rate control maximum bitrate",
rc_max_rate, 4, 24000000, 0),
AVOPTION_CODEC_DOUBLE("rc_buf_aggresivity", "rate control buffer aggresivity",
rc_buffer_aggressivity, 4, 24000000, 0),
AVOPTION_CODEC_DOUBLE("rc_initial_cplx", "initial complexity for pass1 ratecontrol",
rc_initial_cplx, 0., 9999999., 0),
AVOPTION_CODEC_DOUBLE("i_quant_factor", "qscale factor between p and i frames",
i_quant_factor, 0., 0., 0),
AVOPTION_CODEC_DOUBLE("i_quant_offset", "qscale offset between p and i frames",
i_quant_factor, -999999., 999999., 0),
AVOPTION_CODEC_INT("dct_algo", "dct alghorithm",
dct_algo, 0, 5, 0), // fixme - "Auto,FastInt,Int,MMX,MLib,Altivec"
AVOPTION_CODEC_DOUBLE("lumi_masking", "luminance masking",
lumi_masking, 0., 999999., 0),
AVOPTION_CODEC_DOUBLE("temporal_cplx_masking", "temporary complexity masking",
temporal_cplx_masking, 0., 999999., 0),
AVOPTION_CODEC_DOUBLE("spatial_cplx_masking", "spatial complexity masking",
spatial_cplx_masking, 0., 999999., 0),
AVOPTION_CODEC_DOUBLE("p_masking", "p block masking",
p_masking, 0., 999999., 0),
AVOPTION_CODEC_DOUBLE("dark_masking", "darkness masking",
dark_masking, 0., 999999., 0),
AVOPTION_CODEC_INT("idct_algo", "idct alghorithm",
idct_algo, 0, 8, 0), // fixme - "Auto,Int,Simple,SimpleMMX,LibMPEG2MMX,PS2,MLib,ARM,Altivec"
AVOPTION_CODEC_INT("mb_qmin", "minimum MB quantizer",
mb_qmin, 0, 8, 0),
AVOPTION_CODEC_INT("mb_qmax", "maximum MB quantizer",
mb_qmin, 0, 8, 0),
AVOPTION_CODEC_INT("me_cmp", "ME compare function",
me_cmp, 0, 24000000, 0),
AVOPTION_CODEC_INT("me_sub_cmp", "subpixel ME compare function",
me_sub_cmp, 0, 24000000, 0),
AVOPTION_CODEC_INT("dia_size", "ME diamond size & shape",
dia_size, 0, 24000000, 0),
AVOPTION_CODEC_INT("last_predictor_count", "amount of previous MV predictors",
last_predictor_count, 0, 24000000, 0),
AVOPTION_CODEC_INT("pre_me", "pre pass for ME",
pre_me, 0, 24000000, 0),
AVOPTION_CODEC_INT("me_pre_cmp", "ME pre pass compare function",
me_pre_cmp, 0, 24000000, 0),
AVOPTION_CODEC_INT("me_range", "maximum ME search range",
me_range, 0, 24000000, 0),
AVOPTION_CODEC_INT("pre_dia_size", "ME pre pass diamod size & shape",
pre_dia_size, 0, 24000000, 0),
AVOPTION_CODEC_INT("me_subpel_quality", "subpel ME quality",
me_subpel_quality, 0, 24000000, 0),
AVOPTION_CODEC_INT("me_range", "maximum ME search range",
me_range, 0, 24000000, 0),
AVOPTION_CODEC_FLAG("psnr", "calculate PSNR of compressed frames",
flags, CODEC_FLAG_PSNR, 0),
AVOPTION_CODEC_RCOVERRIDE("rc_override", "ratecontrol override (=startframe,endframe,qscale,quality_factor)",
rc_override),
AVOPTION_SUB(avoptions_common),
AVOPTION_END()
};
#ifdef CONFIG_ENCODERS
AVCodec h263_encoder = {
"h263",
@ -6538,7 +6464,6 @@ AVCodec mpeg4_encoder = {
MPV_encode_picture,
MPV_encode_end,
.pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
.options = mpeg4_options,
.capabilities= CODEC_CAP_DELAY,
};
@ -6551,7 +6476,6 @@ AVCodec msmpeg4v1_encoder = {
MPV_encode_picture,
MPV_encode_end,
.pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
.options = mpeg4_options,
};
AVCodec msmpeg4v2_encoder = {
@ -6563,7 +6487,6 @@ AVCodec msmpeg4v2_encoder = {
MPV_encode_picture,
MPV_encode_end,
.pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
.options = mpeg4_options,
};
AVCodec msmpeg4v3_encoder = {
@ -6575,7 +6498,6 @@ AVCodec msmpeg4v3_encoder = {
MPV_encode_picture,
MPV_encode_end,
.pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
.options = mpeg4_options,
};
AVCodec wmv1_encoder = {
@ -6587,7 +6509,6 @@ AVCodec wmv1_encoder = {
MPV_encode_picture,
MPV_encode_end,
.pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1},
.options = mpeg4_options,
};
AVCodec mjpeg_encoder = {

@ -1,208 +0,0 @@
/*
* LGPL
*/
/**
* @file opts.c
* options parser.
* typical parsed command line:
* msmpeg4:bitrate=720000:qmax=16
*
*/
#include "avcodec.h"
const AVOption avoptions_common[] = {
AVOPTION_CODEC_FLAG("bit_exact", "use only bit-exact stuff", flags, CODEC_FLAG_BITEXACT, 0),
AVOPTION_CODEC_FLAG("mm_force", "force mm flags", dsp_mask, FF_MM_FORCE, 0),
#ifdef HAVE_MMX
AVOPTION_CODEC_FLAG("mm_mmx", "mask MMX feature", dsp_mask, FF_MM_MMX, 0),
AVOPTION_CODEC_FLAG("mm_3dnow", "mask 3DNow feature", dsp_mask, FF_MM_3DNOW, 0),
AVOPTION_CODEC_FLAG("mm_mmxext", "mask MMXEXT (MMX2) feature", dsp_mask, FF_MM_MMXEXT, 0),
AVOPTION_CODEC_FLAG("mm_sse", "mask SSE feature", dsp_mask, FF_MM_SSE, 0),
AVOPTION_CODEC_FLAG("mm_sse2", "mask SSE2 feature", dsp_mask, FF_MM_SSE2, 0),
#endif
AVOPTION_END()
};
const AVOption avoptions_workaround_bug[] = {
AVOPTION_CODEC_FLAG("bug_autodetect", "workaround bug autodetection", workaround_bugs, FF_BUG_AUTODETECT, 1),
AVOPTION_CODEC_FLAG("bug_old_msmpeg4", "workaround old msmpeg4 bug", workaround_bugs, FF_BUG_OLD_MSMPEG4, 0),
AVOPTION_CODEC_FLAG("bug_xvid_ilace", "workaround XviD interlace bug", workaround_bugs, FF_BUG_XVID_ILACE, 0),
AVOPTION_CODEC_FLAG("bug_ump4", "workaround ump4 bug", workaround_bugs, FF_BUG_UMP4, 0),
AVOPTION_CODEC_FLAG("bug_no_padding", "workaround padding bug", workaround_bugs, FF_BUG_NO_PADDING, 0),
AVOPTION_CODEC_FLAG("bug_ac_vlc", "workaround ac VLC bug", workaround_bugs, FF_BUG_AC_VLC, 0),
AVOPTION_CODEC_FLAG("bug_qpel_chroma", "workaround qpel chroma bug", workaround_bugs, FF_BUG_QPEL_CHROMA, 0),
AVOPTION_CODEC_FLAG("bug_std_qpel", "workaround std qpel bug", workaround_bugs, FF_BUG_STD_QPEL, 0),
AVOPTION_CODEC_FLAG("bug_qpel_chroma2", "workaround qpel chroma2 bug", workaround_bugs, FF_BUG_QPEL_CHROMA2, 0),
AVOPTION_CODEC_FLAG("bug_direct_blocksize", "workaround direct blocksize bug", workaround_bugs, FF_BUG_DIRECT_BLOCKSIZE, 0),
AVOPTION_END()
};
/* avoid compatibility problems by redefining it */
static int av_strcasecmp(const char *s1, const char *s2)
{
signed char val;
for(;;) {
val = toupper(*s1) - toupper(*s2);
if (val != 0)
break;
if (*s1 != '\0')
break;
s1++;
s2++;
}
return val;
}
static int parse_bool(const AVOption *c, char *s, int *var)
{
int b = 1; /* by default -on- when present */
if (s) {
if (!av_strcasecmp(s, "off") || !av_strcasecmp(s, "false")
|| !strcmp(s, "0"))
b = 0;
else if (!av_strcasecmp(s, "on") || !av_strcasecmp(s, "true")
|| !strcmp(s, "1"))
b = 1;
else
return -1;
}
if (c->type == FF_OPT_TYPE_FLAG) {
if (b)
*var |= (int)c->min;
else
*var &= ~(int)c->min;
} else
*var = b;
return 0;
}
static int parse_double(const AVOption *c, char *s, double *var)
{
double d;
if (!s)
return -1;
d = atof(s);
if (c->min != c->max) {
if (d < c->min || d > c->max) {
av_log(NULL, AV_LOG_ERROR, "Option: %s double value: %f out of range <%f, %f>\n",
c->name, d, c->min, c->max);
return -1;
}
}
*var = d;
return 0;
}
static int parse_int(const AVOption* c, char* s, int* var)
{
int i;
if (!s)
return -1;
i = atoi(s);
if (c->min != c->max) {
if (i < (int)c->min || i > (int)c->max) {
av_log(NULL, AV_LOG_ERROR, "Option: %s integer value: %d out of range <%d, %d>\n",
c->name, i, (int)c->min, (int)c->max);
return -1;
}
}
*var = i;
return 0;
}
static int parse_string(const AVOption *c, char *s, void* strct, char **var)
{
if (!s)
return -1;
if (c->type == FF_OPT_TYPE_RCOVERRIDE) {
int sf, ef, qs;
float qf;
if (sscanf(s, "%d,%d,%d,%f", &sf, &ef, &qs, &qf) == 4 && sf < ef) {
AVCodecContext *avctx = (AVCodecContext *) strct;
RcOverride *o;
avctx->rc_override = av_realloc(avctx->rc_override,
sizeof(RcOverride) * (avctx->rc_override_count + 1));
o = avctx->rc_override + avctx->rc_override_count++;
o->start_frame = sf;
o->end_frame = ef;
o->qscale = qs;
o->quality_factor = qf;
//printf("parsed Rc: %d,%d,%d,%f (%d)\n", sf,ef,qs,qf, avctx->rc_override_count);
} else {
av_log(NULL, AV_LOG_ERROR, "incorrect/unparsable Rc: \"%s\"\n", s);
}
} else
*var = av_strdup(s);
return 0;
}
int avoption_parse(void* strct, const AVOption* list, const char *opts)
{
int r = 0;
char* dopts = av_strdup(opts);
if (dopts) {
char *str = dopts;
while (str && *str && r == 0) {
const AVOption *stack[FF_OPT_MAX_DEPTH];
const AVOption *c = list;
int depth = 0;
char* e = strchr(str, ':');
char* p;
if (e)
*e++ = 0;
p = strchr(str, '=');
if (p)
*p++ = 0;
// going through option structures
for (;;) {
if (!c->name) {
if (c->help) {
stack[depth++] = c;
c = (const AVOption*) c->help;
assert(depth > FF_OPT_MAX_DEPTH);
} else {
if (depth == 0)
break; // finished
c = stack[--depth];
c++;
}
} else {
if (!strcmp(c->name, str)) {
void* ptr = (char*)strct + c->offset;
switch (c->type & FF_OPT_TYPE_MASK) {
case FF_OPT_TYPE_BOOL:
r = parse_bool(c, p, (int*)ptr);
break;
case FF_OPT_TYPE_DOUBLE:
r = parse_double(c, p, (double*)ptr);
break;
case FF_OPT_TYPE_INT:
r = parse_int(c, p, (int*)ptr);
break;
case FF_OPT_TYPE_STRING:
r = parse_string(c, p, strct, (char**)ptr);
break;
default:
assert(0 == 1);
}
}
c++;
}
}
str = e;
}
av_free(dopts);
}
return r;
}
Loading…
Cancel
Save