diff mbox series

[FFmpeg-devel,13/20] avcodec/snow: Move freeing encoder-only buffers to snowenc.c

Message ID AS8P250MB074460DED2F3BFF8C63F56C38F209@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State New
Headers show
Series [FFmpeg-devel,1/8] configure: Remove dependencies of inexistant rtjpeg decoder | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 10, 2022, 3:13 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/snow.c    |  8 --------
 libavcodec/snowenc.c | 12 ++++++++++++
 2 files changed, 12 insertions(+), 8 deletions(-)

Comments

Michael Niedermayer Oct. 10, 2022, 4:19 p.m. UTC | #1
On Mon, Oct 10, 2022 at 05:13:03AM +0200, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  libavcodec/snow.c    |  8 --------
>  libavcodec/snowenc.c | 12 ++++++++++++
>  2 files changed, 12 insertions(+), 8 deletions(-)

should be ok

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index 4a6c781a95..f55b3310ac 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -606,19 +606,11 @@  av_cold void ff_snow_common_end(SnowContext *s)
     av_freep(&s->temp_idwt_buffer);
     av_freep(&s->run_buffer);
 
-    s->m.me.temp= NULL;
-    av_freep(&s->m.me.scratchpad);
-    av_freep(&s->m.me.map);
-    av_freep(&s->m.me.score_map);
-    av_freep(&s->m.sc.obmc_scratchpad);
-
     av_freep(&s->block);
     av_freep(&s->scratchbuf);
     av_freep(&s->emu_edge_buffer);
 
     for(i=0; i<MAX_REF_FRAMES; i++){
-        av_freep(&s->ref_mvs[i]);
-        av_freep(&s->ref_scores[i]);
         if(s->last_picture[i] && s->last_picture[i]->data[0]) {
             av_assert0(s->last_picture[i]->data[0] != s->current_picture->data[0]);
         }
diff --git a/libavcodec/snowenc.c b/libavcodec/snowenc.c
index 0854f78da7..fec061a8c5 100644
--- a/libavcodec/snowenc.c
+++ b/libavcodec/snowenc.c
@@ -1986,6 +1986,18 @@  static av_cold int encode_end(AVCodecContext *avctx)
     ff_snow_common_end(s);
     ff_rate_control_uninit(&s->m);
     av_frame_free(&s->input_picture);
+
+    for (int i = 0; i < MAX_REF_FRAMES; i++) {
+        av_freep(&s->ref_mvs[i]);
+        av_freep(&s->ref_scores[i]);
+    }
+
+    s->m.me.temp = NULL;
+    av_freep(&s->m.me.scratchpad);
+    av_freep(&s->m.me.map);
+    av_freep(&s->m.me.score_map);
+    av_freep(&s->m.sc.obmc_scratchpad);
+
     av_freep(&avctx->stats_out);
 
     return 0;