#include "libavfilter/avfilter.h"
#include "libavfilter/avfiltergraph.h"
-#include "libavutil/audioconvert.h"
#include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixfmt.h"
#include "libavutil/samplefmt.h"
-/**
- * Define a function for building a string containing a list of
- * allowed formats,
- */
+/* Define a function for building a string containing a list of
+ * allowed formats. */
#define DEF_CHOOSE_FORMAT(type, var, supported_list, none, get_name, separator)\
static char *choose_ ## var ## s(OutputStream *ost) \
{ \
int len; \
\
if (avio_open_dyn_buf(&s) < 0) \
- exit_program(1); \
+ exit(1); \
\
for (p = ost->enc->supported_list; *p != none; p++) { \
get_name(*p); \
return NULL; \
}
-DEF_CHOOSE_FORMAT(enum PixelFormat, pix_fmt, pix_fmts, PIX_FMT_NONE,
+DEF_CHOOSE_FORMAT(enum AVPixelFormat, pix_fmt, pix_fmts, AV_PIX_FMT_NONE,
GET_PIX_FMT_NAME, ":")
DEF_CHOOSE_FORMAT(enum AVSampleFormat, sample_fmt, sample_fmts,
FilterGraph *fg = av_mallocz(sizeof(*fg));
if (!fg)
- exit_program(1);
+ exit(1);
fg->index = nb_filtergraphs;
- fg->outputs = grow_array(fg->outputs, sizeof(*fg->outputs), &fg->nb_outputs,
- fg->nb_outputs + 1);
+ GROW_ARRAY(fg->outputs, fg->nb_outputs);
if (!(fg->outputs[0] = av_mallocz(sizeof(*fg->outputs[0]))))
- exit_program(1);
+ exit(1);
fg->outputs[0]->ost = ost;
fg->outputs[0]->graph = fg;
ost->filter = fg->outputs[0];
- fg->inputs = grow_array(fg->inputs, sizeof(*fg->inputs), &fg->nb_inputs,
- fg->nb_inputs + 1);
+ GROW_ARRAY(fg->inputs, fg->nb_inputs);
if (!(fg->inputs[0] = av_mallocz(sizeof(*fg->inputs[0]))))
- exit_program(1);
+ exit(1);
fg->inputs[0]->ist = ist;
fg->inputs[0]->graph = fg;
- ist->filters = grow_array(ist->filters, sizeof(*ist->filters),
- &ist->nb_filters, ist->nb_filters + 1);
+ GROW_ARRAY(ist->filters, ist->nb_filters);
ist->filters[ist->nb_filters - 1] = fg->inputs[0];
- filtergraphs = grow_array(filtergraphs, sizeof(*filtergraphs),
- &nb_filtergraphs, nb_filtergraphs + 1);
+ GROW_ARRAY(filtergraphs, nb_filtergraphs);
filtergraphs[nb_filtergraphs - 1] = fg;
return fg;
if (type != AVMEDIA_TYPE_VIDEO && type != AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_FATAL, "Only video and audio filters supported "
"currently.\n");
- exit_program(1);
+ exit(1);
}
if (in->name) {
if (file_idx < 0 || file_idx >= nb_input_files) {
av_log(NULL, AV_LOG_FATAL, "Invalid file index %d in filtegraph description %s.\n",
file_idx, fg->graph_desc);
- exit_program(1);
+ exit(1);
}
s = input_files[file_idx]->ctx;
if (!st) {
av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
"matches no streams.\n", p, fg->graph_desc);
- exit_program(1);
+ exit(1);
}
ist = input_streams[input_files[file_idx]->ist_index + st->index];
} else {
av_log(NULL, AV_LOG_FATAL, "Cannot find a matching stream for "
"unlabeled input pad %d on filter %s", in->pad_idx,
in->filter_ctx->name);
- exit_program(1);
+ exit(1);
}
}
av_assert0(ist);
ist->decoding_needed = 1;
ist->st->discard = AVDISCARD_NONE;
- fg->inputs = grow_array(fg->inputs, sizeof(*fg->inputs),
- &fg->nb_inputs, fg->nb_inputs + 1);
+ GROW_ARRAY(fg->inputs, fg->nb_inputs);
if (!(fg->inputs[fg->nb_inputs - 1] = av_mallocz(sizeof(*fg->inputs[0]))))
- exit_program(1);
+ exit(1);
fg->inputs[fg->nb_inputs - 1]->ist = ist;
fg->inputs[fg->nb_inputs - 1]->graph = fg;
- ist->filters = grow_array(ist->filters, sizeof(*ist->filters),
- &ist->nb_filters, ist->nb_filters + 1);
+ GROW_ARRAY(ist->filters, ist->nb_filters);
ist->filters[ist->nb_filters - 1] = fg->inputs[fg->nb_inputs - 1];
}
snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&ofilter->filter,
avfilter_get_by_name("buffersink"),
- name, NULL, pix_fmts, fg->graph);
+ name, NULL, NULL, fg->graph);
if (ret < 0)
return ret;
AVIOContext *pb; \
\
if (avio_open_dyn_buf(&pb) < 0) \
- exit_program(1); \
+ exit(1); \
\
avio_printf(pb, "%s", ctx->filter->name); \
if (nb_pads > 1) \
if (audio_sync_method > 0) {
AVFilterContext *async;
- char args[256];
int len = 0;
av_log(NULL, AV_LOG_WARNING, "-async has been deprecated. Used the "
first_filter = async;
pad_idx = 0;
}
+ if (audio_volume != 256) {
+ AVFilterContext *volume;
+
+ av_log(NULL, AV_LOG_WARNING, "-vol has been deprecated. Use the volume "
+ "audio filter instead.\n");
+
+ snprintf(args, sizeof(args), "volume=%f", audio_volume / 256.0);
+
+ snprintf(name, sizeof(name), "graph %d volume for input stream %d:%d",
+ fg->index, ist->file_index, ist->st->index);
+ ret = avfilter_graph_create_filter(&volume,
+ avfilter_get_by_name("volume"),
+ name, args, NULL, fg->graph);
+ if (ret < 0)
+ return ret;
+
+ ret = avfilter_link(volume, 0, first_filter, pad_idx);
+ if (ret < 0)
+ return ret;
+
+ first_filter = volume;
+ pad_idx = 0;
+ }
if ((ret = avfilter_link(ifilter->filter, 0, first_filter, pad_idx)) < 0)
return ret;
} else {
/* wait until output mappings are processed */
for (cur = outputs; cur;) {
- fg->outputs = grow_array(fg->outputs, sizeof(*fg->outputs),
- &fg->nb_outputs, fg->nb_outputs + 1);
+ GROW_ARRAY(fg->outputs, fg->nb_outputs);
if (!(fg->outputs[fg->nb_outputs - 1] = av_mallocz(sizeof(*fg->outputs[0]))))
- exit_program(1);
+ exit(1);
fg->outputs[fg->nb_outputs - 1]->graph = fg;
fg->outputs[fg->nb_outputs - 1]->out_tmp = cur;
cur = cur->next;