diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2017-09-01 16:30:52 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2017-09-01 16:30:52 +0200 |
| commit | 1644665a9105e2d761e8b29f43af602560e6bcf9 (patch) | |
| tree | 810b93c47f60df97958b9b98c79a6ff8b1d5bd9f /src/lib/openjp2 | |
| parent | b2cc8f7f81242f967b65e76de043e5e31663d793 (diff) | |
opj_j2k_update_image_data(): avoid zero-ing the buffer if not needed
Diffstat (limited to 'src/lib/openjp2')
| -rw-r--r-- | src/lib/openjp2/j2k.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c index e548fefc..8fb56e37 100644 --- a/src/lib/openjp2/j2k.c +++ b/src/lib/openjp2/j2k.c @@ -8926,6 +8926,7 @@ static OPJ_BOOL opj_j2k_update_image_data(opj_tcd_t * p_tcd, OPJ_INT32 res_x0, res_x1, res_y0, res_y1; OPJ_UINT32 src_data_stride; const OPJ_INT32* p_src_data; + OPJ_BOOL check_if_must_memset = OPJ_FALSE; /* Allocate output component buffer if necessary */ if (!l_img_comp_dest->data) { @@ -8942,8 +8943,8 @@ static OPJ_BOOL opj_j2k_update_image_data(opj_tcd_t * p_tcd, if (! l_img_comp_dest->data) { return OPJ_FALSE; } - /* Do we really need this memset ? */ - memset(l_img_comp_dest->data, 0, l_width * l_height * sizeof(OPJ_INT32)); + + check_if_must_memset = OPJ_TRUE; } /* Copy info from decoded comp image to output image */ @@ -9061,6 +9062,12 @@ static OPJ_BOOL opj_j2k_update_image_data(opj_tcd_t * p_tcd, } /*-----*/ + if (check_if_must_memset && (l_img_comp_dest->w != l_width_dest || + l_img_comp_dest->h != l_height_dest)) { + memset(l_img_comp_dest->data, 0, + (OPJ_SIZE_T)l_img_comp_dest->w * l_img_comp_dest->h * sizeof(OPJ_INT32)); + } + /* Compute the input buffer offset */ l_start_offset_src = (OPJ_SIZE_T)l_offset_x0_src + (OPJ_SIZE_T)l_offset_y0_src * (OPJ_SIZE_T)src_data_stride; |
