| 138 | } |
| 139 | |
| 140 | av_cold int ff_ffv1_init_slice_contexts(FFV1Context *f) |
| 141 | { |
| 142 | int max_slice_count = f->num_h_slices * f->num_v_slices; |
| 143 | |
| 144 | av_assert0(max_slice_count > 0); |
| 145 | |
| 146 | f->slices = av_calloc(max_slice_count, sizeof(*f->slices)); |
| 147 | if (!f->slices) |
| 148 | return AVERROR(ENOMEM); |
| 149 | |
| 150 | f->max_slice_count = max_slice_count; |
| 151 | |
| 152 | for (int i = 0; i < max_slice_count; i++) { |
| 153 | FFV1SliceContext *sc = &f->slices[i]; |
| 154 | int sx = i % f->num_h_slices; |
| 155 | int sy = i / f->num_h_slices; |
| 156 | int sxs = ff_slice_coord(f, f->avctx->width , sx , f->num_h_slices, f->chroma_h_shift); |
| 157 | int sxe = ff_slice_coord(f, f->avctx->width , sx + 1, f->num_h_slices, f->chroma_h_shift); |
| 158 | int sys = ff_slice_coord(f, f->avctx->height, sy , f->num_v_slices, f->chroma_v_shift); |
| 159 | int sye = ff_slice_coord(f, f->avctx->height, sy + 1, f->num_v_slices, f->chroma_v_shift); |
| 160 | |
| 161 | sc->slice_width = sxe - sxs; |
| 162 | sc->slice_height = sye - sys; |
| 163 | sc->slice_x = sxs; |
| 164 | sc->slice_y = sys; |
| 165 | sc->sx = sx; |
| 166 | sc->sy = sy; |
| 167 | |
| 168 | sc->sample_buffer = av_malloc_array((f->width + 6), 3 * MAX_PLANES * |
| 169 | sizeof(*sc->sample_buffer)); |
| 170 | sc->sample_buffer32 = av_malloc_array((f->width + 6), 3 * MAX_PLANES * |
| 171 | sizeof(*sc->sample_buffer32)); |
| 172 | if (!sc->sample_buffer || !sc->sample_buffer32) |
| 173 | return AVERROR(ENOMEM); |
| 174 | |
| 175 | sc->plane = ff_ffv1_planes_alloc(); |
| 176 | if (!sc->plane) |
| 177 | return AVERROR(ENOMEM); |
| 178 | } |
| 179 | |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | int ff_ffv1_allocate_initial_states(FFV1Context *f) |
| 184 | { |
no test coverage detected