av_freep(&avformat_opts->key);
av_freep(&avformat_opts);
#if CONFIG_SWSCALE
- av_freep(&sws_opts);
+ sws_freeContext(sws_opts);
+ sws_opts = NULL;
#endif
for (i = 0; i < opt_name_count; i++) {
av_freep(&opt_names[i]);
}
av_freep(&opt_names);
av_freep(&opt_values);
+ opt_name_count = 0;
}
void log_callback_help(void* ptr, int level, const char* fmt, va_list vl)
*po->u.int64_arg = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX);
} else if (po->flags & OPT_FLOAT) {
*po->u.float_arg = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY);
- } else if (po->flags & OPT_FUNC2) {
- if (po->u.func2_arg(opt, arg) < 0) {
- fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt);
- exit(1);
- }
} else if (po->flags & OPT_DUMMY) {
/* Do nothing for this option */
} else {
- po->u.func_arg(arg);
+ if (po->u.func_arg(opt, arg) < 0) {
+ fprintf(stderr, "%s: failed to set value '%s' for option '%s'\n", argv[0], arg, opt);
+ exit(1);
+ }
}
if(po->flags & OPT_EXIT)
exit(0);
AVInputFormat *iformat = NULL;
while ((p = av_codec_next(p))) {
- AVClass *c = p->priv_class;
+ const AVClass *c = p->priv_class;
if (c && av_find_opt(&c, opt, NULL, 0, 0))
break;
}
return 0;
}
+static void *alloc_priv_context(int size, const AVClass *class)
+{
+ void *p = av_mallocz(size);
+ if (p) {
+ *(const AVClass **)p = class;
+ av_opt_set_defaults(p);
+ }
+ return p;
+}
+
void set_context_opts(void *ctx, void *opts_ctx, int flags, AVCodec *codec)
{
int i;
void *priv_ctx=NULL;
if(!strcmp("AVCodecContext", (*(AVClass**)ctx)->class_name)){
AVCodecContext *avctx= ctx;
- if(codec && codec->priv_class && avctx->priv_data){
+ if(codec && codec->priv_class){
+ if(!avctx->priv_data && codec->priv_data_size)
+ avctx->priv_data= alloc_priv_context(codec->priv_data_size, codec->priv_class);
priv_ctx= avctx->priv_data;
}
} else if (!strcmp("AVFormatContext", (*(AVClass**)ctx)->class_name)) {
const char *str;
if (priv_ctx) {
if (av_find_opt(priv_ctx, opt_names[i], NULL, flags, flags)) {
- if (av_set_string3(priv_ctx, opt_names[i], opt_values[i], 0, NULL) < 0) {
+ if (av_set_string3(priv_ctx, opt_names[i], opt_values[i], 1, NULL) < 0) {
fprintf(stderr, "Invalid value '%s' for option '%s'\n",
opt_names[i], opt_values[i]);
exit(1);
av_strlcpy(filename, preset_name, filename_size);
f = fopen(filename, "r");
} else {
+#ifdef _WIN32
+ char datadir[MAX_PATH], *ls;
+ base[2] = NULL;
+
+ if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1))
+ {
+ for (ls = datadir; ls < datadir + strlen(datadir); ls++)
+ if (*ls == '\\') *ls = '/';
+
+ if (ls = strrchr(datadir, '/'))
+ {
+ *ls = 0;
+ strncat(datadir, "/ffpresets", sizeof(datadir) - 1 - strlen(datadir));
+ base[2] = datadir;
+ }
+ }
+#endif
for (i = 0; i < 3 && !f; i++) {
if (!base[i])
continue;
{
int ret;
AVFilterBufferRef *picref;
+ *picref_ptr = NULL;
if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
return ret;
memcpy(frame->data, picref->data, sizeof(frame->data));
memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
+ frame->pkt_pos = picref->pos;
frame->interlaced_frame = picref->video->interlaced;
frame->top_field_first = picref->video->top_field_first;
frame->key_frame = picref->video->key_frame;
frame->pict_type = picref->video->pict_type;
+ frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
return 1;
}