aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpegpicture.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-08-08 10:42:32 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-08-10 18:49:35 +0200
commit3d5a74cc3899df9d1f0b215b03bfddd1c8226f04 (patch)
tree22e7ec1a3e2f89e2089c4ca9779eb67ea6ff231b /libavcodec/mpegpicture.c
parent68a90ac3e6bc192d78b30faa9f771c14775c93e8 (diff)
downloadffmpeg-3d5a74cc3899df9d1f0b215b03bfddd1c8226f04.tar.gz
avcodec/mpegpicture: Remove always-true checks
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.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/mpegpicture.c')
-rw-r--r--libavcodec/mpegpicture.c15
1 files 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;