diff mbox series

[FFmpeg-devel,3/7] avcodec/mpegpicture: Reset fields explicitly instead of memsetting them

Message ID HE1PR0101MB221920430370DE8431365E0C8F689@HE1PR0101MB2219.eurprd01.prod.exchangelabs.com
State Accepted
Commit e50684318390b5cffc68da131f7630f11814b808
Headers show
Series [FFmpeg-devel,1/7] avcodec/h263dec: Remove redundant code to set cur_pic_ptr | 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 Aug. 15, 2022, 11:52 a.m. UTC
Improves the grepability of the code.
(Furthermore, I hope that no compiler will really call memset
for 28 bytes.)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/mpegpicture.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c
index c57f149752..884af1731b 100644
--- a/libavcodec/mpegpicture.c
+++ b/libavcodec/mpegpicture.c
@@ -297,8 +297,6 @@  fail:
  */
 void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
 {
-    int off = offsetof(Picture, hwaccel_priv_buf) + sizeof(pic->hwaccel_priv_buf);
-
     pic->tf.f = pic->f;
     /* WM Image / Screen codecs allocate internal buffers with different
      * dimensions / colorspaces; ignore user-defined callbacks for these. */
@@ -314,7 +312,12 @@  void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic)
     if (pic->needs_realloc)
         free_picture_tables(pic);
 
-    memset((uint8_t*)pic + off, 0, sizeof(*pic) - off);
+    pic->hwaccel_picture_private = NULL;
+    pic->field_picture = 0;
+    pic->b_frame_score = 0;
+    pic->needs_realloc = 0;
+    pic->reference     = 0;
+    pic->shared        = 0;
 }
 
 int ff_update_picture_tables(Picture *dst, const Picture *src)