fftools/cmdutils: Make allocate_array_elem() return ptr to new element
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
9d73967b40
commit
2e7ef008e3
@ -2216,8 +2216,9 @@ void *grow_array(void *array, int elem_size, int *size, int new_size)
|
|||||||
|
|
||||||
void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
|
void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
|
||||||
{
|
{
|
||||||
void *new_elem, **array = (void**)ptr;
|
void *new_elem, **array;
|
||||||
|
|
||||||
|
memcpy(&array, ptr, sizeof(array));
|
||||||
if (*nb_elems == INT_MAX) {
|
if (*nb_elems == INT_MAX) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Array too big.\n");
|
av_log(NULL, AV_LOG_ERROR, "Array too big.\n");
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
@ -2226,8 +2227,9 @@ void *allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
|
|||||||
if (!new_elem)
|
if (!new_elem)
|
||||||
exit_program(1);
|
exit_program(1);
|
||||||
GROW_ARRAY(array, *nb_elems);
|
GROW_ARRAY(array, *nb_elems);
|
||||||
|
memcpy(ptr, &array, sizeof(array));
|
||||||
array[*nb_elems - 1] = new_elem;
|
array[*nb_elems - 1] = new_elem;
|
||||||
return array;
|
return new_elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
double get_rotation(int32_t *displaymatrix)
|
double get_rotation(int32_t *displaymatrix)
|
||||||
|
@ -638,7 +638,7 @@ void *grow_array(void *array, int elem_size, int *size, int new_size);
|
|||||||
* @param elem_size size of the new element to allocate
|
* @param elem_size size of the new element to allocate
|
||||||
* @param nb_elems pointer to the number of elements of the array array;
|
* @param nb_elems pointer to the number of elements of the array array;
|
||||||
* *nb_elems will be incremented by one by this function.
|
* *nb_elems will be incremented by one by this function.
|
||||||
* @return reallocated array
|
* @return pointer to the newly allocated entry
|
||||||
*/
|
*/
|
||||||
void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
|
void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
|
||||||
|
|
||||||
@ -648,7 +648,7 @@ void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
|
|||||||
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
|
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
|
||||||
|
|
||||||
#define ALLOC_ARRAY_ELEM(array, nb_elems)\
|
#define ALLOC_ARRAY_ELEM(array, nb_elems)\
|
||||||
array = allocate_array_elem(array, sizeof(*array[0]), &nb_elems)
|
allocate_array_elem(&array, sizeof(*array[0]), &nb_elems)
|
||||||
|
|
||||||
#define GET_PIX_FMT_NAME(pix_fmt)\
|
#define GET_PIX_FMT_NAME(pix_fmt)\
|
||||||
const char *name = av_get_pix_fmt_name(pix_fmt);
|
const char *name = av_get_pix_fmt_name(pix_fmt);
|
||||||
|
@ -166,16 +166,14 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
|||||||
exit_program(1);
|
exit_program(1);
|
||||||
fg->index = nb_filtergraphs;
|
fg->index = nb_filtergraphs;
|
||||||
|
|
||||||
ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||||
ofilter = fg->outputs[0];
|
|
||||||
ofilter->ost = ost;
|
ofilter->ost = ost;
|
||||||
ofilter->graph = fg;
|
ofilter->graph = fg;
|
||||||
ofilter->format = -1;
|
ofilter->format = -1;
|
||||||
|
|
||||||
ost->filter = ofilter;
|
ost->filter = ofilter;
|
||||||
|
|
||||||
ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||||
ifilter = fg->inputs[0];
|
|
||||||
ifilter->ist = ist;
|
ifilter->ist = ist;
|
||||||
ifilter->graph = fg;
|
ifilter->graph = fg;
|
||||||
ifilter->format = -1;
|
ifilter->format = -1;
|
||||||
@ -281,8 +279,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
|||||||
ist->decoding_needed |= DECODING_FOR_FILTER;
|
ist->decoding_needed |= DECODING_FOR_FILTER;
|
||||||
ist->st->discard = AVDISCARD_NONE;
|
ist->st->discard = AVDISCARD_NONE;
|
||||||
|
|
||||||
ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||||
ifilter = fg->inputs[fg->nb_inputs - 1];
|
|
||||||
ifilter->ist = ist;
|
ifilter->ist = ist;
|
||||||
ifilter->graph = fg;
|
ifilter->graph = fg;
|
||||||
ifilter->format = -1;
|
ifilter->format = -1;
|
||||||
@ -318,9 +315,7 @@ int init_complex_filtergraph(FilterGraph *fg)
|
|||||||
init_input_filter(fg, cur);
|
init_input_filter(fg, cur);
|
||||||
|
|
||||||
for (cur = outputs; cur;) {
|
for (cur = outputs; cur;) {
|
||||||
OutputFilter *ofilter;
|
OutputFilter *const ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||||
ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
|
||||||
ofilter = fg->outputs[fg->nb_outputs - 1];
|
|
||||||
|
|
||||||
ofilter->graph = fg;
|
ofilter->graph = fg;
|
||||||
ofilter->out_tmp = cur;
|
ofilter->out_tmp = cur;
|
||||||
|
@ -1265,8 +1265,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
|
|||||||
/* dump the file content */
|
/* dump the file content */
|
||||||
av_dump_format(ic, nb_input_files, filename, 0);
|
av_dump_format(ic, nb_input_files, filename, 0);
|
||||||
|
|
||||||
ALLOC_ARRAY_ELEM(input_files, nb_input_files);
|
f = ALLOC_ARRAY_ELEM(input_files, nb_input_files);
|
||||||
f = input_files[nb_input_files - 1];
|
|
||||||
|
|
||||||
f->ctx = ic;
|
f->ctx = ic;
|
||||||
f->ist_index = nb_input_streams - ic->nb_streams;
|
f->ist_index = nb_input_streams - ic->nb_streams;
|
||||||
@ -2260,8 +2259,7 @@ static int open_output_file(OptionsContext *o, const char *filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ALLOC_ARRAY_ELEM(output_files, nb_output_files);
|
of = ALLOC_ARRAY_ELEM(output_files, nb_output_files);
|
||||||
of = output_files[nb_output_files - 1];
|
|
||||||
|
|
||||||
of->ost_index = nb_output_streams;
|
of->ost_index = nb_output_streams;
|
||||||
of->recording_time = o->recording_time;
|
of->recording_time = o->recording_time;
|
||||||
@ -3278,8 +3276,7 @@ static int opt_filter_complex_script(void *optctx, const char *opt, const char *
|
|||||||
if (!graph_desc)
|
if (!graph_desc)
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
|
|
||||||
ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs);
|
fg = ALLOC_ARRAY_ELEM(filtergraphs, nb_filtergraphs);
|
||||||
fg = filtergraphs[nb_filtergraphs - 1];
|
|
||||||
fg->index = nb_filtergraphs - 1;
|
fg->index = nb_filtergraphs - 1;
|
||||||
fg->graph_desc = graph_desc;
|
fg->graph_desc = graph_desc;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user