[FFmpeg-cvslog] avcodec/magicyuvenc: Hoist check out of loop
Andreas Rheinhardt
git at videolan.org
Sun Apr 20 23:31:33 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Apr 17 13:34:53 2025 +0200| [bad3f308d39d16db5d1629bc7a65d89ce4a0e3dd] | committer: Andreas Rheinhardt
avcodec/magicyuvenc: Hoist check out of loop
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bad3f308d39d16db5d1629bc7a65d89ce4a0e3dd
---
libavcodec/magicyuvenc.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavcodec/magicyuvenc.c b/libavcodec/magicyuvenc.c
index 94e8d31122..02b570d618 100644
--- a/libavcodec/magicyuvenc.c
+++ b/libavcodec/magicyuvenc.c
@@ -625,12 +625,14 @@ static av_cold int magy_encode_close(AVCodecContext *avctx)
{
MagicYUVContext *s = avctx->priv_data;
- for (int i = 0; i < s->planes * s->nb_slices && s->slices; i++) {
- Slice *sl = &s->slices[i];
+ if (s->slices) {
+ for (int i = 0; i < s->planes * s->nb_slices; i++) {
+ Slice *sl = &s->slices[i];
- av_freep(&sl->slice);
+ av_freep(&sl->slice);
+ }
+ av_freep(&s->slices);
}
- av_freep(&s->slices);
av_freep(&s->decorrelate_buf);
return 0;
More information about the ffmpeg-cvslog
mailing list