diff mbox series

[FFmpeg-devel,06/14] pthread_frame: do not copy a range of AVCodecContext fields at once

Message ID 20200327125747.13460-6-anton@khirnov.net
State Accepted
Headers show
Series [FFmpeg-devel,01/14] mpeg4videodec: do not copy a range of fields at once | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Anton Khirnov March 27, 2020, 12:57 p.m. UTC
This is extremely fragile against reordering and hides what is actually
being copied. Copy all the fields manually instead.
---
 libavcodec/pthread_frame.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer March 28, 2020, 2:58 p.m. UTC | #1
On Fri, Mar 27, 2020 at 01:57:40PM +0100, Anton Khirnov wrote:
> This is extremely fragile against reordering and hides what is actually
> being copied. Copy all the fields manually instead.
> ---
>  libavcodec/pthread_frame.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

LGTM

thx

[...]
diff mbox series

Patch

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 639c5ce574..7ebeef357a 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -322,7 +322,6 @@  FF_ENABLE_DEPRECATION_WARNINGS
  */
 static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
 {
-#define copy_fields(s, e) memcpy(&dst->s, &src->s, (char*)&dst->e - (char*)&dst->s);
     dst->flags          = src->flags;
 
     dst->draw_horiz_band= src->draw_horiz_band;
@@ -336,7 +335,9 @@  static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
     dst->flags2      = src->flags2;
     dst->export_side_data = src->export_side_data;
 
-    copy_fields(skip_loop_filter, subtitle_header);
+    dst->skip_loop_filter = src->skip_loop_filter;
+    dst->skip_idct        = src->skip_idct;
+    dst->skip_frame       = src->skip_frame;
 
     dst->frame_number     = src->frame_number;
     dst->reordered_opaque = src->reordered_opaque;
@@ -354,7 +355,6 @@  static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
     }
     dst->slice_count = src->slice_count;
     return 0;
-#undef copy_fields
 }
 
 /// Releases the buffers that this decoding thread was the last user of.