#include <sys/resource.h>
#endif
+static int init_report(const char *env);
+
struct SwsContext *sws_opts;
- AVDictionary *format_opts, *codec_opts;
+SwrContext *swr_opts;
+ AVDictionary *format_opts, *codec_opts, *resample_opts;
-static const int this_year = 2013;
+const int this_year = 2013;
+
+static FILE *report_file;
void init_opts(void)
{
sws_freeContext(sws_opts);
sws_opts = NULL;
#endif
+
+ if(CONFIG_SWRESAMPLE)
+ swr_free(&swr_opts);
+
av_dict_free(&format_opts);
av_dict_free(&codec_opts);
+ av_dict_free(&resample_opts);
}
void log_callback_help(void *ptr, int level, const char *fmt, va_list vl)
char opt_stripped[128];
const char *p;
const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
- const AVClass *rc = avresample_get_class();
-#if CONFIG_SWSCALE
- const AVClass *sc = sws_get_class();
-#endif
++ const av_unused AVClass *rc_class;
+ const AVClass *sc, *swr_class;
+
+ if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))
+ av_log_set_level(AV_LOG_DEBUG);
if (!(p = strchr(opt, ':')))
p = opt + strlen(opt);
av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
return ret;
}
+ consumed = 1;
+ }
+#endif
+#if CONFIG_SWRESAMPLE
+ swr_class = swr_get_class();
+ if (!consumed && av_opt_find(&swr_class, opt, NULL, 0,
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) {
+ int ret = av_opt_set(swr_opts, opt, arg, 0);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
+ return ret;
+ }
+ consumed = 1;
+ }
+#endif
++#if CONFIG_AVRESAMPLE
++ rc_class = avresample_get_class();
++ if (av_opt_find(&rc_class, opt, NULL, 0,
++ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) {
++ av_dict_set(&resample_opts, opt, arg, FLAGS);
++ consumed = 1;
+ }
+ #endif
- if (o)
+ if (consumed)
return 0;
return AVERROR_OPTION_NOT_FOUND;
}
#if CONFIG_SWSCALE
g->sws_opts = sws_opts;
#endif
+ g->swr_opts = swr_opts;
g->codec_opts = codec_opts;
g->format_opts = format_opts;
+ g->resample_opts = resample_opts;
codec_opts = NULL;
format_opts = NULL;
extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
extern AVFormatContext *avformat_opts;
extern struct SwsContext *sws_opts;
- extern AVDictionary *format_opts, *codec_opts;
+extern struct SwrContext *swr_opts;
+ extern AVDictionary *format_opts, *codec_opts, *resample_opts;
/**
* Initialize the cmdutils option system, in particular
AVDictionary *codec_opts;
AVDictionary *format_opts;
+ AVDictionary *resample_opts;
struct SwsContext *sws_opts;
+ struct SwrContext *swr_opts;
} OptionGroup;
/**
char *avfilter;
int64_t sws_flags;
+ int64_t swr_filter_type;
+ int64_t swr_dither_method;
+ double swr_dither_scale;
AVDictionary *opts;
+ AVDictionary *resample_opts;
int finished; /* no more packets should be written for this stream */
+ int unavailable; /* true if the steram is unavailable (possibly temporarily) */
int stream_copy;
const char *attachment_filename;
int copy_initial_nonkeyframes;
#include "libavfilter/avfilter.h"
#include "libavfilter/avfiltergraph.h"
+#include "libavfilter/buffersink.h"
+ #include "libavresample/avresample.h"
+
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
+#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
if (simple) {
OutputStream *ost = fg->outputs[0]->ost;
- char args[255];
+ char args[512];
+ AVDictionaryEntry *e = NULL;
- const AVClass *rc = avresample_get_class();
+
snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags);
fg->graph->scale_sws_opts = av_strdup(args);
+ args[0] = 0;
+ if (ost->swr_filter_type != SWR_FILTER_TYPE_KAISER)
+ av_strlcatf(args, sizeof(args), "filter_type=%d:", (int)ost->swr_filter_type);
+ if (ost->swr_dither_method)
+ av_strlcatf(args, sizeof(args), "dither_method=%d:", (int)ost->swr_dither_method);
+ if (ost->swr_dither_scale != 1.0)
+ av_strlcatf(args, sizeof(args), "dither_scale=%f:", ost->swr_dither_scale);
+ if (strlen(args))
+ args[strlen(args)-1] = 0;
+ av_opt_set(fg->graph, "aresample_swr_opts", args, 0);
++
+ args[0] = '\0';
+ while ((e = av_dict_get(fg->outputs[0]->ost->resample_opts, "", e,
+ AV_DICT_IGNORE_SUFFIX))) {
+ av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
+ }
+ if (strlen(args))
+ args[strlen(args) - 1] = '\0';
+ fg->graph->resample_lavr_opts = av_strdup(args);
}
if ((ret = avfilter_graph_parse2(fg->graph, graph_desc, &inputs, &outputs)) < 0)
st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
av_opt_get_int(o->g->sws_opts, "sws_flags", 0, &ost->sws_flags);
+ av_opt_get_int (o->g->swr_opts, "filter_type" , 0, &ost->swr_filter_type);
+ av_opt_get_int (o->g->swr_opts, "dither_method", 0, &ost->swr_dither_method);
+ av_opt_get_double(o->g->swr_opts, "dither_scale" , 0, &ost->swr_dither_scale);
+ if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24)
+ ost->swr_dither_scale = ost->swr_dither_scale*256;
- ost->pix_fmts[0] = ost->pix_fmts[1] = AV_PIX_FMT_NONE;
+ av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0);
+
+ ost->source_index = source_index;
+ if (source_index >= 0) {
+ ost->sync_ist = input_streams[source_index];
+ input_streams[source_index]->discard = 0;
+ input_streams[source_index]->st->discard = AVDISCARD_NONE;
+ }
return ost;
}