@@ -224,9 +224,6 @@ static avifBool aomCodecGetNextImage(struct avifCodec * codec,
224224 yuvFormat = AVIF_PIXEL_FORMAT_YUV400 ;
225225 }
226226
227- // Throw away the old color planes if there are
228- avifImageFreePlanes (image , AVIF_PLANES_YUV );
229-
230227 image -> width = codec -> internal -> image -> d_w ;
231228 image -> height = codec -> internal -> image -> d_h ;
232229 image -> depth = codec -> internal -> image -> bit_depth ;
@@ -240,6 +237,7 @@ static avifBool aomCodecGetNextImage(struct avifCodec * codec,
240237 image -> matrixCoefficients = (avifMatrixCoefficients )codec -> internal -> image -> mc ;
241238
242239 // Steal the pointers from the decoder's image directly
240+ avifImageFreePlanes (image , AVIF_PLANES_YUV );
243241 int yuvPlaneCount = (yuvFormat == AVIF_PIXEL_FORMAT_YUV400 ) ? 1 : 3 ;
244242 for (int yuvPlane = 0 ; yuvPlane < yuvPlaneCount ; ++ yuvPlane ) {
245243 image -> yuvPlanes [yuvPlane ] = codec -> internal -> image -> planes [yuvPlane ];
@@ -249,13 +247,11 @@ static avifBool aomCodecGetNextImage(struct avifCodec * codec,
249247 } else {
250248 // Alpha plane - set image to correct size, fill alpha
251249
252- // Throw away the old alpha plane if there are
253- avifImageFreePlanes (image , AVIF_PLANES_A );
254-
255250 image -> width = codec -> internal -> image -> d_w ;
256251 image -> height = codec -> internal -> image -> d_h ;
257252 image -> depth = codec -> internal -> image -> bit_depth ;
258253
254+ avifImageFreePlanes (image , AVIF_PLANES_A );
259255 image -> alphaPlane = codec -> internal -> image -> planes [0 ];
260256 image -> alphaRowBytes = codec -> internal -> image -> stride [0 ];
261257 * isLimitedRangeAlpha = (codec -> internal -> image -> range == AOM_CR_STUDIO_RANGE );
0 commit comments