fftools/ffmpeg_(filter|opt): Use dedicated pointer for array elem access
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
3ca1e31e63
commit
9d73967b40
@ -159,29 +159,33 @@ DEF_CHOOSE_FORMAT(channel_layouts, uint64_t, channel_layout, channel_layouts, 0,
|
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
{
|
||||
FilterGraph *fg = av_mallocz(sizeof(*fg));
|
||||
OutputFilter *ofilter;
|
||||
InputFilter *ifilter;
|
||||
|
||||
if (!fg)
|
||||
exit_program(1);
|
||||
fg->index = nb_filtergraphs;
|
||||
|
||||
ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||
fg->outputs[0]->ost = ost;
|
||||
fg->outputs[0]->graph = fg;
|
||||
fg->outputs[0]->format = -1;
|
||||
ofilter = fg->outputs[0];
|
||||
ofilter->ost = ost;
|
||||
ofilter->graph = fg;
|
||||
ofilter->format = -1;
|
||||
|
||||
ost->filter = fg->outputs[0];
|
||||
ost->filter = ofilter;
|
||||
|
||||
ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||
fg->inputs[0]->ist = ist;
|
||||
fg->inputs[0]->graph = fg;
|
||||
fg->inputs[0]->format = -1;
|
||||
ifilter = fg->inputs[0];
|
||||
ifilter->ist = ist;
|
||||
ifilter->graph = fg;
|
||||
ifilter->format = -1;
|
||||
|
||||
fg->inputs[0]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[0]->frame_queue)
|
||||
ifilter->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!ifilter->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[0];
|
||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||
|
||||
GROW_ARRAY(filtergraphs, nb_filtergraphs);
|
||||
filtergraphs[nb_filtergraphs - 1] = fg;
|
||||
@ -210,6 +214,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
{
|
||||
InputStream *ist = NULL;
|
||||
enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx);
|
||||
InputFilter *ifilter;
|
||||
int i;
|
||||
|
||||
// TODO: support other filter types
|
||||
@ -277,18 +282,19 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
ist->st->discard = AVDISCARD_NONE;
|
||||
|
||||
ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||
fg->inputs[fg->nb_inputs - 1]->ist = ist;
|
||||
fg->inputs[fg->nb_inputs - 1]->graph = fg;
|
||||
fg->inputs[fg->nb_inputs - 1]->format = -1;
|
||||
fg->inputs[fg->nb_inputs - 1]->type = ist->st->codecpar->codec_type;
|
||||
fg->inputs[fg->nb_inputs - 1]->name = describe_filter_link(fg, in, 1);
|
||||
ifilter = fg->inputs[fg->nb_inputs - 1];
|
||||
ifilter->ist = ist;
|
||||
ifilter->graph = fg;
|
||||
ifilter->format = -1;
|
||||
ifilter->type = ist->st->codecpar->codec_type;
|
||||
ifilter->name = describe_filter_link(fg, in, 1);
|
||||
|
||||
fg->inputs[fg->nb_inputs - 1]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[fg->nb_inputs - 1]->frame_queue)
|
||||
ifilter->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!ifilter->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[fg->nb_inputs - 1];
|
||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||
}
|
||||
|
||||
int init_complex_filtergraph(FilterGraph *fg)
|
||||
@ -312,15 +318,17 @@ int init_complex_filtergraph(FilterGraph *fg)
|
||||
init_input_filter(fg, cur);
|
||||
|
||||
for (cur = outputs; cur;) {
|
||||
OutputFilter *ofilter;
|
||||
ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||
ofilter = fg->outputs[fg->nb_outputs - 1];
|
||||
|
||||
fg->outputs[fg->nb_outputs - 1]->graph = fg;
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp = cur;
|
||||
fg->outputs[fg->nb_outputs - 1]->type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
|
||||
ofilter->graph = fg;
|
||||
ofilter->out_tmp = cur;
|
||||
ofilter->type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
|
||||
cur->pad_idx);
|
||||
fg->outputs[fg->nb_outputs - 1]->name = describe_filter_link(fg, cur, 0);
|
||||
ofilter->name = describe_filter_link(fg, cur, 0);
|
||||
cur = cur->next;
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL;
|
||||
ofilter->out_tmp->next = NULL;
|
||||
}
|
||||
|
||||
fail:
|
||||
|
@ -3258,10 +3258,12 @@ static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
|
||||
|
||||
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
|
||||
{
|
||||
FilterGraph *fg;
|
||||
ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs);
|
||||
filtergraphs[nb_filtergraphs - 1]->index = nb_filtergraphs - 1;
|
||||
filtergraphs[nb_filtergraphs - 1]->graph_desc = av_strdup(arg);
|
||||
if (!filtergraphs[nb_filtergraphs - 1]->graph_desc)
|
||||
fg = filtergraphs[nb_filtergraphs - 1];
|
||||
fg->index = nb_filtergraphs - 1;
|
||||
fg->graph_desc = av_strdup(arg);
|
||||
if (!fg->graph_desc)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
input_stream_potentially_available = 1;
|
||||
@ -3271,13 +3273,15 @@ static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
|
||||
|
||||
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
|
||||
{
|
||||
FilterGraph *fg;
|
||||
uint8_t *graph_desc = read_file(arg);
|
||||
if (!graph_desc)
|
||||
return AVERROR(EINVAL);
|
||||
|
||||
ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs);
|
||||
filtergraphs[nb_filtergraphs - 1]->index = nb_filtergraphs - 1;
|
||||
filtergraphs[nb_filtergraphs - 1]->graph_desc = graph_desc;
|
||||
fg = filtergraphs[nb_filtergraphs - 1];
|
||||
fg->index = nb_filtergraphs - 1;
|
||||
fg->graph_desc = graph_desc;
|
||||
|
||||
input_stream_potentially_available = 1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user