Skip to content

Commit c6ab32f

Browse files
committed
1 parent 101be77 commit c6ab32f

File tree

10 files changed

+54
-17
lines changed

10 files changed

+54
-17
lines changed

3rdparty/libjpeg-turbo/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter -Wsign-compare -Wshorten-6
44

55
set(VERSION_MAJOR 2)
66
set(VERSION_MINOR 1)
7-
set(VERSION_REVISION 0)
7+
set(VERSION_REVISION 2)
88
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION})
9-
set(LIBJPEG_TURBO_VERSION_NUMBER 2001000)
9+
set(LIBJPEG_TURBO_VERSION_NUMBER 2001002)
1010

1111
string(TIMESTAMP BUILD "opencv-${OPENCV_VERSION}-libjpeg-turbo")
1212
if(CMAKE_BUILD_TYPE STREQUAL "Debug")

3rdparty/libjpeg-turbo/jconfigint.h.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,13 @@
4040
#define HAVE_BITSCANFORWARD
4141
#endif
4242
#endif
43+
44+
#if defined(__has_attribute)
45+
#if __has_attribute(fallthrough)
46+
#define FALLTHROUGH __attribute__((fallthrough));
47+
#else
48+
#define FALLTHROUGH
49+
#endif
50+
#else
51+
#define FALLTHROUGH
52+
#endif

3rdparty/libjpeg-turbo/src/jchuff.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@
4444
* flags (this defines __thumb__).
4545
*/
4646

47-
#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || \
48-
defined(_M_ARM64)
47+
/* NOTE: Both GCC and Clang define __GNUC__ */
48+
#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
49+
defined(_M_ARM) || defined(_M_ARM64)
4950
#if !defined(__thumb__) || defined(__thumb2__)
5051
#define USE_CLZ_INTRINSIC
5152
#endif

3rdparty/libjpeg-turbo/src/jcmaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ prepare_for_pass(j_compress_ptr cinfo)
493493
master->pass_type = output_pass;
494494
master->pass_number++;
495495
#endif
496-
/*FALLTHROUGH*/
496+
FALLTHROUGH /*FALLTHROUGH*/
497497
case output_pass:
498498
/* Do a data-output pass. */
499499
/* We need not repeat per-scan setup if prior optimization pass did it. */

3rdparty/libjpeg-turbo/src/jcphuff.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Copyright (C) 2011, 2015, 2018, 2021, D. R. Commander.
88
* Copyright (C) 2016, 2018, Matthieu Darbois.
99
* Copyright (C) 2020, Arm Limited.
10+
* Copyright (C) 2021, Alex Richardson.
1011
* For conditions of distribution and use, see the accompanying README.ijg
1112
* file.
1213
*
@@ -52,8 +53,9 @@
5253
* flags (this defines __thumb__).
5354
*/
5455

55-
#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || \
56-
defined(_M_ARM64)
56+
/* NOTE: Both GCC and Clang define __GNUC__ */
57+
#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
58+
defined(_M_ARM) || defined(_M_ARM64)
5759
#if !defined(__thumb__) || defined(__thumb2__)
5860
#define USE_CLZ_INTRINSIC
5961
#endif
@@ -679,7 +681,7 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
679681
emit_restart(entropy, entropy->next_restart_num);
680682

681683
#ifdef WITH_SIMD
682-
cvalue = values = (JCOEF *)PAD((size_t)values_unaligned, 16);
684+
cvalue = values = (JCOEF *)PAD((JUINTPTR)values_unaligned, 16);
683685
#else
684686
/* Not using SIMD, so alignment is not needed */
685687
cvalue = values = values_unaligned;
@@ -944,7 +946,7 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
944946
emit_restart(entropy, entropy->next_restart_num);
945947

946948
#ifdef WITH_SIMD
947-
cabsvalue = absvalues = (JCOEF *)PAD((size_t)absvalues_unaligned, 16);
949+
cabsvalue = absvalues = (JCOEF *)PAD((JUINTPTR)absvalues_unaligned, 16);
948950
#else
949951
/* Not using SIMD, so alignment is not needed */
950952
cabsvalue = absvalues = absvalues_unaligned;

3rdparty/libjpeg-turbo/src/jdapimin.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "jinclude.h"
2424
#include "jpeglib.h"
2525
#include "jdmaster.h"
26+
#include "jconfigint.h"
2627

2728

2829
/*
@@ -308,7 +309,7 @@ jpeg_consume_input(j_decompress_ptr cinfo)
308309
/* Initialize application's data source module */
309310
(*cinfo->src->init_source) (cinfo);
310311
cinfo->global_state = DSTATE_INHEADER;
311-
/*FALLTHROUGH*/
312+
FALLTHROUGH /*FALLTHROUGH*/
312313
case DSTATE_INHEADER:
313314
retcode = (*cinfo->inputctl->consume_input) (cinfo);
314315
if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */

3rdparty/libjpeg-turbo/src/jdhuff.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
584584
* behavior is, to the best of our understanding, innocuous, and it is
585585
* unclear how to work around it without potentially affecting
586586
* performance. Thus, we (hopefully temporarily) suppress UBSan integer
587-
* overflow errors for this function.
587+
* overflow errors for this function and decode_mcu_fast().
588588
*/
589589
s += state.last_dc_val[ci];
590590
state.last_dc_val[ci] = s;
@@ -651,6 +651,12 @@ decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
651651
}
652652

653653

654+
#if defined(__has_feature)
655+
#if __has_feature(undefined_behavior_sanitizer)
656+
__attribute__((no_sanitize("signed-integer-overflow"),
657+
no_sanitize("unsigned-integer-overflow")))
658+
#endif
659+
#endif
654660
LOCAL(boolean)
655661
decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
656662
{
@@ -681,6 +687,9 @@ decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
681687

682688
if (entropy->dc_needed[blkn]) {
683689
int ci = cinfo->MCU_membership[blkn];
690+
/* Refer to the comment in decode_mcu_slow() regarding the supression of
691+
* a UBSan integer overflow error in this line of code.
692+
*/
684693
s += state.last_dc_val[ci];
685694
state.last_dc_val[ci] = s;
686695
if (block)

3rdparty/libjpeg-turbo/src/jdmainct.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "jinclude.h"
2020
#include "jdmainct.h"
21+
#include "jconfigint.h"
2122

2223

2324
/*
@@ -360,7 +361,7 @@ process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
360361
main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
361362
if (*out_row_ctr >= out_rows_avail)
362363
return; /* Postprocessor exactly filled output buf */
363-
/*FALLTHROUGH*/
364+
FALLTHROUGH /*FALLTHROUGH*/
364365
case CTX_PREPARE_FOR_IMCU:
365366
/* Prepare to process first M-1 row groups of this iMCU row */
366367
main_ptr->rowgroup_ctr = 0;
@@ -371,7 +372,7 @@ process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
371372
if (main_ptr->iMCU_row_ctr == cinfo->total_iMCU_rows)
372373
set_bottom_pointers(cinfo);
373374
main_ptr->context_state = CTX_PROCESS_IMCU;
374-
/*FALLTHROUGH*/
375+
FALLTHROUGH /*FALLTHROUGH*/
375376
case CTX_PROCESS_IMCU:
376377
/* Call postprocessor using previously set pointers */
377378
(*cinfo->post->post_process_data) (cinfo,

3rdparty/libjpeg-turbo/src/jmemmgr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This file was part of the Independent JPEG Group's software:
55
* Copyright (C) 1991-1997, Thomas G. Lane.
66
* libjpeg-turbo Modifications:
7-
* Copyright (C) 2016, D. R. Commander.
7+
* Copyright (C) 2016, 2021, D. R. Commander.
88
* For conditions of distribution and use, see the accompanying README.ijg
99
* file.
1010
*
@@ -1032,7 +1032,7 @@ free_pool(j_common_ptr cinfo, int pool_id)
10321032
large_pool_ptr next_lhdr_ptr = lhdr_ptr->next;
10331033
space_freed = lhdr_ptr->bytes_used +
10341034
lhdr_ptr->bytes_left +
1035-
sizeof(large_pool_hdr);
1035+
sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
10361036
jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
10371037
mem->total_space_allocated -= space_freed;
10381038
lhdr_ptr = next_lhdr_ptr;
@@ -1045,7 +1045,7 @@ free_pool(j_common_ptr cinfo, int pool_id)
10451045
while (shdr_ptr != NULL) {
10461046
small_pool_ptr next_shdr_ptr = shdr_ptr->next;
10471047
space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
1048-
sizeof(small_pool_hdr);
1048+
sizeof(small_pool_hdr) + ALIGN_SIZE - 1;
10491049
jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
10501050
mem->total_space_allocated -= space_freed;
10511051
shdr_ptr = next_shdr_ptr;

3rdparty/libjpeg-turbo/src/jpegint.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
* Copyright (C) 1991-1997, Thomas G. Lane.
66
* Modified 1997-2009 by Guido Vollbeding.
77
* libjpeg-turbo Modifications:
8-
* Copyright (C) 2015-2016, 2019, D. R. Commander.
8+
* Copyright (C) 2015-2016, 2019, 2021, D. R. Commander.
99
* Copyright (C) 2015, Google, Inc.
10+
* Copyright (C) 2021, Alex Richardson.
1011
* For conditions of distribution and use, see the accompanying README.ijg
1112
* file.
1213
*
@@ -47,6 +48,18 @@ typedef enum { /* Operating modes for buffer controllers */
4748
/* JLONG must hold at least signed 32-bit values. */
4849
typedef long JLONG;
4950

51+
/* JUINTPTR must hold pointer values. */
52+
#ifdef __UINTPTR_TYPE__
53+
/*
54+
* __UINTPTR_TYPE__ is GNU-specific and available in GCC 4.6+ and Clang 3.0+.
55+
* Fortunately, that is sufficient to support the few architectures for which
56+
* sizeof(void *) != sizeof(size_t). The only other options would require C99
57+
* or Clang-specific builtins.
58+
*/
59+
typedef __UINTPTR_TYPE__ JUINTPTR;
60+
#else
61+
typedef size_t JUINTPTR;
62+
#endif
5063

5164
/*
5265
* Left shift macro that handles a negative operand without causing any

0 commit comments

Comments
 (0)