Of all the buffers that are made writable, three are always allocated and the other four are allocated iff any one of them is allocated; so one can replace the seven checks for existence with one.
Signed-off-by: Andreas Rheinhardt <andreas.rheinha...@outlook.com> --- libavcodec/mpegpicture.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index f32f8d061b..dc79662143 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -49,21 +49,22 @@ static void av_noinline free_picture_tables(Picture *pic) static int make_tables_writable(Picture *pic) { - int ret, i; #define MAKE_WRITABLE(table) \ do {\ - if (pic->table &&\ - (ret = av_buffer_make_writable(&pic->table)) < 0)\ - return ret;\ + int ret = av_buffer_make_writable(&pic->table); \ + if (ret < 0) \ + return ret; \ } while (0) MAKE_WRITABLE(mbskip_table_buf); MAKE_WRITABLE(qscale_table_buf); MAKE_WRITABLE(mb_type_buf); - for (i = 0; i < 2; i++) { - MAKE_WRITABLE(motion_val_buf[i]); - MAKE_WRITABLE(ref_index_buf[i]); + if (pic->motion_val_buf[0]) { + for (int i = 0; i < 2; i++) { + MAKE_WRITABLE(motion_val_buf[i]); + MAKE_WRITABLE(ref_index_buf[i]); + } } return 0; -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".