Showing the changes to libavfilter/avfilter.c (1 of 34 files). Show all
Unified · Split
| @@ -101,18 +101,16 @@ void ff_command_queue_pop(AVFilterContext *filter) · 100 unmodified lines | |||
| 101 | av_free(c); | 101 | av_free(c); |
| 102 | } | 102 | } |
| 103 | 103 | ||
| 104 | int ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, | 104 | int ff_append_pad(unsigned *count, |
| 105 | AVFilterPad **pads, AVFilterLink ***links, | 105 | AVFilterPad **pads, AVFilterLink ***links, |
| 106 | AVFilterPad *newpad) | 106 | AVFilterPad *newpad) |
| 107 | { | 107 | { |
| 108 | AVFilterLink **newlinks; | 108 | AVFilterLink **newlinks; |
| 109 | AVFilterPad *newpads; | 109 | AVFilterPad *newpads; |
| 110 | unsigned i; | 110 | unsigned idx = *count; |
| 111 | |||
| 112 | idx = FFMIN(idx, *count); | ||
| 113 | 111 | ||
| 114 | newpads = av_realloc_array(*pads, *count + 1, sizeof(AVFilterPad)); | 112 | newpads = av_realloc_array(*pads, idx + 1, sizeof(*newpads)); |
| 115 | newlinks = av_realloc_array(*links, *count + 1, sizeof(AVFilterLink*)); | 113 | newlinks = av_realloc_array(*links, idx + 1, sizeof(*newlinks)); |
| 116 | if (newpads) | 114 | if (newpads) |
| 117 | *pads = newpads; | 115 | *pads = newpads; |
| 118 | if (newlinks) | 116 | if (newlinks) |
| @@ -120,15 +118,10 @@ int ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, · 1 unmodified line | |||
| 120 | if (!newpads || !newlinks) | 118 | if (!newpads || !newlinks) |
| 121 | return AVERROR(ENOMEM); | 119 | return AVERROR(ENOMEM); |
| 122 | 120 | ||
| 123 | memmove(*pads + idx + 1, *pads + idx, sizeof(AVFilterPad) * (*count - idx)); | ||
| 124 | memmove(*links + idx + 1, *links + idx, sizeof(AVFilterLink*) * (*count - idx)); | ||
| 125 | memcpy(*pads + idx, newpad, sizeof(AVFilterPad)); | 121 | memcpy(*pads + idx, newpad, sizeof(AVFilterPad)); |
| 126 | (*links)[idx] = NULL; | 122 | (*links)[idx] = NULL; |
| 127 | 123 | ||
| 128 | (*count)++; | 124 | (*count)++; |
| 129 | for (i = idx + 1; i < *count; i++) | ||
| 130 | if ((*links)[i]) | ||
| 131 | (*(unsigned *)((uint8_t *) (*links)[i] + padidx_off))++; | ||
| 132 | 125 | ||
| 133 | return 0; | 126 | return 0; |
| 134 | } | 127 | } |