aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-03 13:38:48 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2021-12-05 13:27:37 +0100
commit9d73967b40231b27504cb86ea177887be03bb328 (patch)
tree0ced59b0620e7dee1c7cab2d28404b2a8b80f37e
parent3ca1e31e63085ab84bc2d031c9ba06ea161188d3 (diff)
downloadffmpeg-9d73967b40231b27504cb86ea177887be03bb328.tar.gz
fftools/ffmpeg_(filter|opt): Use dedicated pointer for array elem access
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--fftools/ffmpeg_filter.c56
-rw-r--r--fftools/ffmpeg_opt.c14
2 files changed, 41 insertions, 29 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 28704203b9..7263ea5f03 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -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);
-
- fg->inputs[fg->nb_inputs - 1]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
- if (!fg->inputs[fg->nb_inputs - 1]->frame_queue)
+ 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);
+
+ 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:
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 848b817e9c..bd1d451ff7 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -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;