| 128 | } |
| 129 | |
| 130 | static int alloc_scratch_buffers(H264SliceContext *sl, int linesize) |
| 131 | { |
| 132 | const H264Context *h = sl->h264; |
| 133 | int alloc_size = FFALIGN(FFABS(linesize) + 32, 32); |
| 134 | |
| 135 | av_fast_malloc(&sl->bipred_scratchpad, &sl->bipred_scratchpad_allocated, 16 * 6 * alloc_size); |
| 136 | // edge emu needs blocksize + filter length - 1 |
| 137 | // (= 21x21 for H.264) |
| 138 | av_fast_malloc(&sl->edge_emu_buffer, &sl->edge_emu_buffer_allocated, alloc_size * 2 * 21); |
| 139 | |
| 140 | av_fast_mallocz(&sl->top_borders[0], &sl->top_borders_allocated[0], |
| 141 | h->mb_width * 16 * 3 * sizeof(uint8_t) * 2); |
| 142 | av_fast_mallocz(&sl->top_borders[1], &sl->top_borders_allocated[1], |
| 143 | h->mb_width * 16 * 3 * sizeof(uint8_t) * 2); |
| 144 | |
| 145 | if (!sl->bipred_scratchpad || !sl->edge_emu_buffer || |
| 146 | !sl->top_borders[0] || !sl->top_borders[1]) { |
| 147 | av_freep(&sl->bipred_scratchpad); |
| 148 | av_freep(&sl->edge_emu_buffer); |
| 149 | av_freep(&sl->top_borders[0]); |
| 150 | av_freep(&sl->top_borders[1]); |
| 151 | |
| 152 | sl->bipred_scratchpad_allocated = 0; |
| 153 | sl->edge_emu_buffer_allocated = 0; |
| 154 | sl->top_borders_allocated[0] = 0; |
| 155 | sl->top_borders_allocated[1] = 0; |
| 156 | return AVERROR(ENOMEM); |
| 157 | } |
| 158 | |
| 159 | return 0; |
| 160 | } |
| 161 | |
| 162 | static int init_table_pools(H264Context *h) |
| 163 | { |
no test coverage detected