@@ -196,12 +196,6 @@ static av_cold int magy_encode_init(AVCodecContext *avctx)
196
196
s -> format = 0x6b ;
197
197
break ;
198
198
}
199
- if (s -> correlate ) {
200
- s -> decorrelate_buf [0 ] = av_calloc (2U * avctx -> height , FFALIGN (avctx -> width , av_cpu_max_align ()));
201
- if (!s -> decorrelate_buf [0 ])
202
- return AVERROR (ENOMEM );
203
- s -> decorrelate_buf [1 ] = s -> decorrelate_buf [0 ] + avctx -> height * FFALIGN (avctx -> width , av_cpu_max_align ());
204
- }
205
199
206
200
ff_llvidencdsp_init (& s -> llvidencdsp );
207
201
@@ -216,6 +210,13 @@ static av_cold int magy_encode_init(AVCodecContext *avctx)
216
210
if (!s -> slices )
217
211
return AVERROR (ENOMEM );
218
212
213
+ if (s -> correlate ) {
214
+ s -> decorrelate_buf [0 ] = av_calloc (2U * (s -> nb_slices * s -> slice_height ), FFALIGN (avctx -> width , av_cpu_max_align ()));
215
+ if (!s -> decorrelate_buf [0 ])
216
+ return AVERROR (ENOMEM );
217
+ s -> decorrelate_buf [1 ] = s -> decorrelate_buf [0 ] + (s -> nb_slices * s -> slice_height ) * FFALIGN (avctx -> width , av_cpu_max_align ());
218
+ }
219
+
219
220
s -> bitslice_size = avctx -> width * (s -> slice_height + 2 ) + AV_INPUT_BUFFER_PADDING_SIZE ;
220
221
for (int n = 0 ; n < s -> nb_slices ; n ++ ) {
221
222
for (int i = 0 ; i < s -> planes ; i ++ ) {
@@ -375,7 +376,7 @@ static int count_plane_slice(AVCodecContext *avctx, int n, int plane)
375
376
const uint8_t * dst = sl -> slice ;
376
377
PTable * counts = sl -> counts ;
377
378
378
- memset (counts , 0 , sizeof (* counts ) * 256 );
379
+ memset (counts , 0 , sizeof (sl -> counts ));
379
380
380
381
count_usage (dst , AV_CEIL_RSHIFT (avctx -> width , s -> hshift [plane ]),
381
382
AV_CEIL_RSHIFT (s -> slice_height , s -> vshift [plane ]), counts );
0 commit comments