openjp2/j2k: Report error if all wanted components are not decoded.
- exuberant-ctags
install:
- - ./tools/travis-ci/install.sh
+ - "./tools/travis-ci/install.sh"
script:
- - ./tools/travis-ci/run.sh
- - ./tools/travis-ci/abi-check.sh
+ - "./tools/travis-ci/run.sh"
+ - "./tools/travis-ci/abi-check.sh"
before_deploy:
- export OPJ_RELEASE_PKG_FILE=$(ls build/openjpeg-${TRAVIS_TAG}*)
deploy:
provider: releases
api_key:
- secure: Npi13uOffALCVNwea4p4q8v85Lo/WsRqaeZQcWrAkt8MxRnfvWQtmnuwmHnVB6Cig+T1lVUHrklOaJIApIb6nkGq3CS/9bD8+SCS2NEdAAP/QYWnBi0ubWXVMRyDLypmwRpzLNSZ0xLYGFUl2PjieZYKRcz1dd/J7S+FnXhPtdjXweq0FS63zTcMe7ggjfmzSOWUCEFmMjZPaM0Be+3PweieCO1dxlHuy7ugCkx2S7d+5hNsicIhQmTADjqtJAkHoMhYqu6/yLFxhjO/+f938PATFULdODTvjCsUwdN/ySWi1Oj4uPAntfytZP7H6YrzLh8dS73QCsdkhhDJIgJskHIBSbRyyEVUnOvQgD9VaBVGHtc1KtZQTwc41OUO3BGPHl97s3oX6bqWqo/L53dB3TPHGx+1+2HL/F0zaDZuHhAKMkPwe8LFPMPB/ur65zXMHjnWb2ZTVVdoIvkbQ7nu8ApI60ejxocYBsEyAuC2CPXU2ki4jdEhm0E1hIziWNE9/LTuM17ziQuJ6WpXOSMrfP4o5aVDmLp5ZGBSocrspOksgyI9XogHaO/r+Y6N3exy+giObFfMHkZVUpsKrKmtOJ7TC1Vg5HsYGlWW8RN8dkJV47bUXm9K4sMos9eYMUt/czykPAs+132cogpII3QxXpFZQqZg6SEPVfOiyqQzTUI=
+ secure: dJXdzoFwk9wYWIKztnXKlVIr1QDmeXtk3oK+2MEzy22fBTKPuphU/cYMvhi5B7sWDwm77f43vbAYO6z7IFmuThwhkuVMD/o+lUyCqGffGeiU1pKpxEvB+LbO/C5asdSnor3RfYdOyo3x4cNlhNtfhXIn7FcAg371yEY6VSIP87adoQcuE+taig0cYWcrNWYGHirHlzEz1utnKwCT/nlhV4nSIWxjwYUp3nt8PAw3RbqQkPPNBniW92g6JA25vLRc3HMD18ISCfNLC2fI6a/dTR+vd+bCySA7JvqeDZnv8SxbVIabu5T+A5CHzHbdp2l2kynPwqHOO47pGa+VfisXEwSsOpa+4EZsPLdwOhaFFnvDwKwR3EjI1TkRVd26IcK61Y5zVZQgalnXBowBEZoI4fT/oEPF7VZMjN3sy/do1U6d5kO0UGqCHCJIVwPeELhwq5z7Ld04K7dSFFVenZhhQKCwxI1o8vgkGNJUWD2Ii6ZLrZKYZ0lC65hr2d39e/KoK3Yh5KHF0cVn6ppBTcUjYr/tdHHO43rwoaf3r1CdAQAYpFvfi3900hl9I/GPwky0YJ6W2QDS2vincwaqWDQ0+WNGf4AKSdx5kCgQU45PSfDb/lxAyXkqmBuI3h/C2ellleaWVL9sGtNRWa/w6WseGMGwfCXgN82XRVM2bgP6pYg=
file_glob: true
file: "${OPJ_RELEASE_PKG_FILE}"
skip_cleanup: true
repo: uclouvain/openjpeg
tags: true
condition: "$OPJ_CI_INCLUDE_IF_DEPLOY = 1"
-
# Changelog
+## [v2.3.1](https://github.com/uclouvain/openjpeg/releases/v2.3.1) (2019-04-02)
+[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.3.0...v2.3.1)
+
+**Closed issues:**
+
+- v2.2.0 regression for decoding images where TNsot == 0 [\#1120](https://github.com/uclouvain/openjpeg/issues/1120)
+- Int overflow in jp3d [\#1162](https://github.com/uclouvain/openjpeg/issues/1162)
+- Heap buffer overflow in opj\_j2k\_update\_image\_data\(\) triggered with Ghostscript [\#1157](https://github.com/uclouvain/openjpeg/issues/1157)
+- LINUX install doesn't work when building shared libraries is disabled [\#1155](https://github.com/uclouvain/openjpeg/issues/1155)
+- OPENJPEG null ptr dereference in openjpeg-2.3.0/src/bin/jp2/convert.c:2243 [\#1152](https://github.com/uclouvain/openjpeg/issues/1152)
+- How to drop certain subbands/layers in DWT [\#1147](https://github.com/uclouvain/openjpeg/issues/1147)
+- where is the MQ-Coder ouput stream in t2.c? [\#1146](https://github.com/uclouvain/openjpeg/issues/1146)
+- OpenJPEG 2.3 \(and 2.2?\) multi component image fails to decode with KDU v7.10 [\#1132](https://github.com/uclouvain/openjpeg/issues/1132)
+- Missing checks for header\_info.height and header\_info.width in function pnmtoimage in src/bin/jpwl/convert.c, which can lead to heap buffer overflow [\#1126](https://github.com/uclouvain/openjpeg/issues/1126)
+- Assertion Failure in jp2.c [\#1125](https://github.com/uclouvain/openjpeg/issues/1125)
+- Division-by-zero vulnerabilities in the function pi\_next\_pcrl, pi\_next\_cprl and pi\_next\_rpcl in src/lib/openjp3d/pi.c [\#1123](https://github.com/uclouvain/openjpeg/issues/1123)
+- Precinct switch \(-c\) doesn't right-shift last record to remaining resolution levels [\#1117](https://github.com/uclouvain/openjpeg/issues/1117)
+- Sample: encode J2K a data using streams??? [\#1114](https://github.com/uclouvain/openjpeg/issues/1114)
+- HIGH THROUGHPUT JPEG 2000 \(HTJ2K\) [\#1112](https://github.com/uclouvain/openjpeg/issues/1112)
+- How to build openjpeg for arm linux? [\#1108](https://github.com/uclouvain/openjpeg/issues/1108)
+- crash [\#1106](https://github.com/uclouvain/openjpeg/issues/1106)
+- JP2000 returning OPJ\_CLRSPC\_UNKNOWN color space [\#1103](https://github.com/uclouvain/openjpeg/issues/1103)
+- Compilation successful but install unsuccessful: Calling executables throws libraries missing error [\#1102](https://github.com/uclouvain/openjpeg/issues/1102)
+- fprintf format string requires 1 parameter but only 0 are given [\#1093](https://github.com/uclouvain/openjpeg/issues/1093)
+- fprintf format string requires 1 parameter but only 0 are given [\#1092](https://github.com/uclouvain/openjpeg/issues/1092)
+- sprintf buffer overflow [\#1088](https://github.com/uclouvain/openjpeg/issues/1088)
+- sprintf buffer overflow [\#1085](https://github.com/uclouvain/openjpeg/issues/1085)
+- Infinite loop when reading jp2 [\#1081](https://github.com/uclouvain/openjpeg/issues/1081)
+- missing format string parameter [\#1074](https://github.com/uclouvain/openjpeg/issues/1074)
+- Excessive Iteration in opj\_t1\_encode\_cblks \(src/lib/openjp2/t1.c\) [\#1059](https://github.com/uclouvain/openjpeg/issues/1059)
+- Out-of-bound left shift in opj\_j2k\_setup\_encoder \(src/lib/openjp2/j2k.c\) [\#1057](https://github.com/uclouvain/openjpeg/issues/1057)
+- Encode image on Unsplash [\#1054](https://github.com/uclouvain/openjpeg/issues/1054)
+- Integer overflow in opj\_t1\_encode\_cblks \(src/lib/openjp2/t1.c\) [\#1053](https://github.com/uclouvain/openjpeg/issues/1053)
+- Signed Integer Overflow - 68065512 [\#1048](https://github.com/uclouvain/openjpeg/issues/1048)
+- Similar vulnerable functions related to CVE-2017-14041 [\#1044](https://github.com/uclouvain/openjpeg/issues/1044)
+- \[ERROR\] COD marker already read. No more than one COD marker per tile. [\#1043](https://github.com/uclouvain/openjpeg/issues/1043)
+- failing to install latest version of openjpeg from source [\#1041](https://github.com/uclouvain/openjpeg/issues/1041)
+- Trouble compressing large raw image [\#1032](https://github.com/uclouvain/openjpeg/issues/1032)
+- Download and installed code from 2.3 archive. Installing 2.2? [\#1030](https://github.com/uclouvain/openjpeg/issues/1030)
+- missing fclose [\#1029](https://github.com/uclouvain/openjpeg/issues/1029)
+- NULL Pointer Access in function imagetopnm of convert.c\(jp2\):1289 [\#860](https://github.com/uclouvain/openjpeg/issues/860)
+- NULL Pointer Access in function imagetopnm of convert.c:2226\(jp2\) [\#859](https://github.com/uclouvain/openjpeg/issues/859)
+- Heap Buffer Overflow in function imagetotga of convert.c\(jp2\):942 [\#858](https://github.com/uclouvain/openjpeg/issues/858)
+
+**Merged pull requests:**
+
+- abi-check.sh: fix broken download URL [\#1188](https://github.com/uclouvain/openjpeg/pull/1188) ([rouault](https://github.com/rouault))
+- opj\_t1\_encode\_cblks: fix UBSAN signed integer overflow [\#1187](https://github.com/uclouvain/openjpeg/pull/1187) ([rouault](https://github.com/rouault))
+- convertbmp: detect invalid file dimensions early \(CVE-2018-6616\) [\#1172](https://github.com/uclouvain/openjpeg/pull/1172) ([hlef](https://github.com/hlef))
+- color\_apply\_icc\_profile: avoid potential heap buffer overflow [\#1170](https://github.com/uclouvain/openjpeg/pull/1170) ([rouault](https://github.com/rouault))
+- Fix multiple potential vulnerabilities and bugs [\#1168](https://github.com/uclouvain/openjpeg/pull/1168) ([Young-X](https://github.com/Young-X))
+- Fix several memory and resource leaks [\#1163](https://github.com/uclouvain/openjpeg/pull/1163) ([nforro](https://github.com/nforro))
+- Fix some potential overflow issues [\#1161](https://github.com/uclouvain/openjpeg/pull/1161) ([stweil](https://github.com/stweil))
+- jp3d/jpwl convert: fix write stack buffer overflow [\#1160](https://github.com/uclouvain/openjpeg/pull/1160) ([hlef](https://github.com/hlef))
+- Int overflow fixed [\#1159](https://github.com/uclouvain/openjpeg/pull/1159) ([ichlubna](https://github.com/ichlubna))
+- Update knownfailures- files given current configurations [\#1149](https://github.com/uclouvain/openjpeg/pull/1149) ([rouault](https://github.com/rouault))
+- CVE-2018-5785: fix issues with zero bitmasks [\#1148](https://github.com/uclouvain/openjpeg/pull/1148) ([hlef](https://github.com/hlef))
+- openjp2/jp2: Fix two format strings [\#1143](https://github.com/uclouvain/openjpeg/pull/1143) ([stweil](https://github.com/stweil))
+- Changes in pnmtoimage if image data are missing [\#1141](https://github.com/uclouvain/openjpeg/pull/1141) ([szukw000](https://github.com/szukw000))
+- Relative path to header files is hardcoded in OpenJPEGConfig.cmake.in file [\#1140](https://github.com/uclouvain/openjpeg/pull/1140) ([bukatlib](https://github.com/bukatlib))
+- Cast on uint ceildiv [\#1136](https://github.com/uclouvain/openjpeg/pull/1136) ([reverson](https://github.com/reverson))
+- Add -DBUILD\_PKGCONFIG\_FILES to install instructions [\#1133](https://github.com/uclouvain/openjpeg/pull/1133) ([robe2](https://github.com/robe2))
+- Fix some typos in code comments and documentation [\#1128](https://github.com/uclouvain/openjpeg/pull/1128) ([stweil](https://github.com/stweil))
+- Fix regression in reading files with TNsot == 0 \(refs \#1120\) [\#1121](https://github.com/uclouvain/openjpeg/pull/1121) ([rouault](https://github.com/rouault))
+- Use local type declaration for POSIX standard type only for MS compiler [\#1119](https://github.com/uclouvain/openjpeg/pull/1119) ([stweil](https://github.com/stweil))
+- Fix Mac builds [\#1104](https://github.com/uclouvain/openjpeg/pull/1104) ([rouault](https://github.com/rouault))
+- jp3d: Replace sprintf\(\) by snprintf\(\) in volumetobin\(\) [\#1101](https://github.com/uclouvain/openjpeg/pull/1101) ([kbabioch](https://github.com/kbabioch))
+- opj\_mj2\_extract: Rename output\_location to output\_prefix [\#1096](https://github.com/uclouvain/openjpeg/pull/1096) ([kbabioch](https://github.com/kbabioch))
+- mj2: Add missing variable to format string in fprintf\(\) invocation in meta\_out.c [\#1094](https://github.com/uclouvain/openjpeg/pull/1094) ([kbabioch](https://github.com/kbabioch))
+- Convert files to UTF-8 encoding [\#1090](https://github.com/uclouvain/openjpeg/pull/1090) ([stweil](https://github.com/stweil))
+- fix unchecked integer multiplication overflow [\#1080](https://github.com/uclouvain/openjpeg/pull/1080) ([setharnold](https://github.com/setharnold))
+- Fixed typos [\#1062](https://github.com/uclouvain/openjpeg/pull/1062) ([radarhere](https://github.com/radarhere))
+- Note that seek uses SEEK\_SET behavior. [\#1055](https://github.com/uclouvain/openjpeg/pull/1055) ([ideasman42](https://github.com/ideasman42))
+- Some Doxygen tags are removed [\#1050](https://github.com/uclouvain/openjpeg/pull/1050) ([szukw000](https://github.com/szukw000))
+- Fix resource leak \(CID 179466\) [\#1047](https://github.com/uclouvain/openjpeg/pull/1047) ([stweil](https://github.com/stweil))
+- Changed cmake version test to allow for cmake 2.8.11.x [\#1042](https://github.com/uclouvain/openjpeg/pull/1042) ([radarhere](https://github.com/radarhere))
+- Add missing fclose\(\) statement in error condition. [\#1037](https://github.com/uclouvain/openjpeg/pull/1037) ([gfiumara](https://github.com/gfiumara))
+
## [v2.3.0](https://github.com/uclouvain/openjpeg/releases/v2.3.0) (2017-10-04)
[Full Changelog](https://github.com/uclouvain/openjpeg/compare/v2.2.0...v2.3.0)
# OPENJPEG version number, useful for packaging and doxygen doc:
set(OPENJPEG_VERSION_MAJOR 2)
set(OPENJPEG_VERSION_MINOR 3)
-set(OPENJPEG_VERSION_BUILD 0)
+set(OPENJPEG_VERSION_BUILD 1)
set(OPENJPEG_VERSION
"${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
set(PACKAGE_VERSION
# 2.1.2 | 7
# 2.2.0 | 7
# 2.3.0 | 7
+# 2.3.1 | 7
# above is the recommendation by the OPJ team. If you really need to override this default,
# you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
# cmake -DOPENJPEG_SOVERSION:STRING=42 /path/to/openjpeg
# OpenJPEG NEWS
-More details in the [Changelog](https://github.com/uclouvain/openjpeg/blob/master/CHANGELOG.md)
+More details in the [CHANGELOG](https://github.com/uclouvain/openjpeg/blob/master/CHANGELOG.md)
+
+## OpenJPEG 2.3.1 (April 2019)
+
+No API/ABI break compared to v2.3.0
+
+* Many bug fixes (including security fixes)
## OpenJPEG 2.3.0 (October 2017)
-version: 2.3.0.{build}
+version: 2.3.1.{build}
branches:
except:
- coverity_scan
description: 'OpenJPEG $(appveyor_repo_tag_name) has been released. More info [here](https://github.com/uclouvain/openjpeg/blob/$(appveyor_repo_tag_name)/NEWS) and a detailed view [here](https://github.com/uclouvain/openjpeg/blob/$(appveyor_repo_tag_name)/CHANGES).'
provider: GitHub
auth_token:
- secure: Huk03f1heCD/HMyA+4ZeVmICdmKn9rPxK5p8/KxzgL+FtJDHlqcllcCrtN9bDxRH # your encrypted token from GitHub
+ secure: XUL+IoRRw8U/4tupa/fMpinxurft7WRQHZiWHMLO5iuFbwZ+C3vCjVVVM+5Ebky7 # your encrypted token from GitHub
artifact: /.*\.zip/ # upload all zip packages to release assets
- draft: false
+ draft: true
prerelease: false
on:
appveyor_repo_tag: true # deploy on tag push only
static OPJ_BOOL bmp_read_rle4_data(FILE* IN, OPJ_UINT8* pData,
OPJ_UINT32 stride, OPJ_UINT32 width, OPJ_UINT32 height)
{
- OPJ_UINT32 x, y;
+ OPJ_UINT32 x, y, written;
OPJ_UINT8 *pix;
const OPJ_UINT8 *beyond;
beyond = pData + stride * height;
pix = pData;
- x = y = 0U;
+ x = y = written = 0U;
while (y < height) {
int c = getc(IN);
if (c == EOF) {
- break;
+ return OPJ_FALSE;
}
if (c) { /* encoded mode */
- int j;
- OPJ_UINT8 c1 = (OPJ_UINT8)getc(IN);
+ int j, c1_int;
+ OPJ_UINT8 c1;
+
+ c1_int = getc(IN);
+ if (c1_int == EOF) {
+ return OPJ_FALSE;
+ }
+ c1 = (OPJ_UINT8)c1_int;
for (j = 0; (j < c) && (x < width) &&
((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
*pix = (OPJ_UINT8)((j & 1) ? (c1 & 0x0fU) : ((c1 >> 4) & 0x0fU));
+ written++;
}
} else { /* absolute mode */
c = getc(IN);
if (c == EOF) {
- break;
+ return OPJ_FALSE;
}
if (c == 0x00) { /* EOL */
break;
} else if (c == 0x02) { /* MOVE by dxdy */
c = getc(IN);
+ if (c == EOF) {
+ return OPJ_FALSE;
+ }
x += (OPJ_UINT32)c;
c = getc(IN);
+ if (c == EOF) {
+ return OPJ_FALSE;
+ }
y += (OPJ_UINT32)c;
pix = pData + y * stride + x;
} else { /* 03 .. 255 : absolute mode */
for (j = 0; (j < c) && (x < width) &&
((OPJ_SIZE_T)pix < (OPJ_SIZE_T)beyond); j++, x++, pix++) {
if ((j & 1) == 0) {
- c1 = (OPJ_UINT8)getc(IN);
+ int c1_int;
+ c1_int = getc(IN);
+ if (c1_int == EOF) {
+ return OPJ_FALSE;
+ }
+ c1 = (OPJ_UINT8)c1_int;
}
*pix = (OPJ_UINT8)((j & 1) ? (c1 & 0x0fU) : ((c1 >> 4) & 0x0fU));
+ written++;
}
if (((c & 3) == 1) || ((c & 3) == 2)) { /* skip padding byte */
- getc(IN);
+ c = getc(IN);
+ if (c == EOF) {
+ return OPJ_FALSE;
+ }
}
}
}
} /* while(y < height) */
+ if (written != width * height) {
+ fprintf(stderr, "warning, image's actual size does not match advertized one\n");
+ return OPJ_FALSE;
+ }
return OPJ_TRUE;
}
};
#endif /* INFORMATION_ONLY */
-/* Returns a ushort from a little-endian serialized value */
-static unsigned short get_tga_ushort(const unsigned char *data)
+static unsigned short get_ushort(unsigned short val)
{
- return data[0] | (data[1] << 8);
+
+#ifdef OPJ_BIG_ENDIAN
+ return (((val & 0xff) << 8) + (val >> 8));
+#else
+ return (val);
+#endif
+
}
#define TGA_HEADER_SIZE 18
id_len = (unsigned char)tga[0];
cmap_type = (unsigned char)tga[1];
image_type = (unsigned char)tga[2];
- cmap_index = get_tga_ushort(*(unsigned short*)(&tga[3]));
- cmap_len = get_tga_ushort(*(unsigned short*)(&tga[5]));
+ cmap_index = get_ushort(*(unsigned short*)(&tga[3]));
+ cmap_len = get_ushort(*(unsigned short*)(&tga[5]));
cmap_entry_size = (unsigned char)tga[7];
- x_origin = get_tga_ushort(*(unsigned short*)(&tga[8]));
- y_origin = get_tga_ushort(*(unsigned short*)(&tga[10]));
- image_w = get_tga_ushort(*(unsigned short*)(&tga[12]));
- image_h = get_tga_ushort(*(unsigned short*)(&tga[14]));
+ x_origin = get_ushort(*(unsigned short*)(&tga[8]));
+ y_origin = get_ushort(*(unsigned short*)(&tga[10]));
+ image_w = get_ushort(*(unsigned short*)(&tga[12]));
+ image_h = get_ushort(*(unsigned short*)(&tga[14]));
pixel_depth = (unsigned char)tga[16];
image_desc = (unsigned char)tga[17];
color_space = CLRSPC_SRGB;
}
- /* If the declared file size is > 10 MB, check that the file is big */
- /* enough to avoid excessive memory allocations */
- if (image_height != 0 && image_width > 10000000 / image_height / numcomps) {
- char ch;
- OPJ_UINT64 expected_file_size =
- (OPJ_UINT64)image_width * image_height * numcomps;
- long curpos = ftell(f);
- if (expected_file_size > (OPJ_UINT64)INT_MAX) {
- expected_file_size = (OPJ_UINT64)INT_MAX;
- }
- fseek(f, (long)expected_file_size - 1, SEEK_SET);
- if (fread(&ch, 1, 1, f) != 1) {
- fclose(f);
- return NULL;
- }
- fseek(f, curpos, SEEK_SET);
- }
-
subsampling_dx = parameters->subsampling_dx;
subsampling_dy = parameters->subsampling_dy;
static OPJ_BOOL opj_j2k_write_first_tile_part(opj_j2k_t *p_j2k,
OPJ_BYTE * p_data,
OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_total_data_size,
+ OPJ_UINT32 total_data_size,
opj_stream_private_t *p_stream,
struct opj_event_mgr * p_manager);
static OPJ_BOOL opj_j2k_write_all_tile_parts(opj_j2k_t *p_j2k,
OPJ_BYTE * p_data,
OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_total_data_size,
+ OPJ_UINT32 total_data_size,
opj_stream_private_t *p_stream,
struct opj_event_mgr * p_manager);
*
* @param p_j2k J2K codec.
* @param p_data Output buffer
- * @param p_total_data_size Output buffer size
+ * @param total_data_size Output buffer size
* @param p_data_written Number of bytes written into stream
* @param p_stream the stream to write data to.
* @param p_manager the user event manager.
*/
static OPJ_BOOL opj_j2k_write_sot(opj_j2k_t *p_j2k,
OPJ_BYTE * p_data,
- OPJ_UINT32 p_total_data_size,
+ OPJ_UINT32 total_data_size,
OPJ_UINT32 * p_data_written,
const opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager);
* @param p_tile_coder FIXME DOC
* @param p_data FIXME DOC
* @param p_data_written FIXME DOC
- * @param p_total_data_size FIXME DOC
+ * @param total_data_size FIXME DOC
* @param p_stream the stream to write data to.
* @param p_manager the user event manager.
*/
opj_tcd_t * p_tile_coder,
OPJ_BYTE * p_data,
OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_total_data_size,
+ OPJ_UINT32 total_data_size,
const opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager);
* A nice message is outputted at errors.
*
* @param p_pocs the progression order changes.
+ * @param tileno the tile number of interest
* @param p_nb_pocs the number of progression order changes.
* @param p_nb_resolutions the number of resolutions.
* @param numcomps the number of components
* @return true if the pocs are valid.
*/
static OPJ_BOOL opj_j2k_check_poc_val(const opj_poc_t *p_pocs,
+ OPJ_UINT32 tileno,
OPJ_UINT32 p_nb_pocs,
OPJ_UINT32 p_nb_resolutions,
OPJ_UINT32 numcomps,
}
static OPJ_BOOL opj_j2k_check_poc_val(const opj_poc_t *p_pocs,
+ OPJ_UINT32 tileno,
OPJ_UINT32 p_nb_pocs,
OPJ_UINT32 p_nb_resolutions,
OPJ_UINT32 p_num_comps,
OPJ_UINT32 step_r = p_num_comps * step_c;
OPJ_UINT32 step_l = p_nb_resolutions * step_r;
OPJ_BOOL loss = OPJ_FALSE;
- OPJ_UINT32 layno0 = 0;
+
+ assert(p_nb_pocs > 0);
packet_array = (OPJ_UINT32*) opj_calloc(step_l * p_num_layers,
sizeof(OPJ_UINT32));
return OPJ_FALSE;
}
- if (p_nb_pocs == 0) {
- opj_free(packet_array);
- return OPJ_TRUE;
- }
-
- index = step_r * p_pocs->resno0;
- /* take each resolution for each poc */
- for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno) {
- OPJ_UINT32 res_index = index + p_pocs->compno0 * step_c;
-
- /* take each comp of each resolution for each poc */
- for (compno = p_pocs->compno0 ; compno < p_pocs->compno1 ; ++compno) {
- OPJ_UINT32 comp_index = res_index + layno0 * step_l;
-
- /* and finally take each layer of each res of ... */
- for (layno = layno0; layno < p_pocs->layno1 ; ++layno) {
- /*index = step_r * resno + step_c * compno + step_l * layno;*/
- packet_array[comp_index] = 1;
- comp_index += step_l;
- }
-
- res_index += step_c;
- }
-
- index += step_r;
- }
- ++p_pocs;
-
- /* iterate through all the pocs */
- for (i = 1; i < p_nb_pocs ; ++i) {
- OPJ_UINT32 l_last_layno1 = (p_pocs - 1)->layno1 ;
+ /* iterate through all the pocs that match our tile of interest. */
+ for (i = 0; i < p_nb_pocs; ++i) {
+ const opj_poc_t *poc = &p_pocs[i];
+ if (tileno + 1 == poc->tile) {
+ index = step_r * poc->resno0;
- layno0 = (p_pocs->layno1 > l_last_layno1) ? l_last_layno1 : 0;
- index = step_r * p_pocs->resno0;
+ /* take each resolution for each poc */
+ for (resno = poc->resno0 ;
+ resno < opj_uint_min(poc->resno1, p_nb_resolutions); ++resno) {
+ OPJ_UINT32 res_index = index + poc->compno0 * step_c;
- /* take each resolution for each poc */
- for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno) {
- OPJ_UINT32 res_index = index + p_pocs->compno0 * step_c;
+ /* take each comp of each resolution for each poc */
+ for (compno = poc->compno0 ;
+ compno < opj_uint_min(poc->compno1, p_num_comps); ++compno) {
+ /* The layer index always starts at zero for every progression. */
+ const OPJ_UINT32 layno0 = 0;
+ OPJ_UINT32 comp_index = res_index + layno0 * step_l;
- /* take each comp of each resolution for each poc */
- for (compno = p_pocs->compno0 ; compno < p_pocs->compno1 ; ++compno) {
- OPJ_UINT32 comp_index = res_index + layno0 * step_l;
+ /* and finally take each layer of each res of ... */
+ for (layno = layno0; layno < opj_uint_min(poc->layno1, p_num_layers);
+ ++layno) {
+ packet_array[comp_index] = 1;
+ comp_index += step_l;
+ }
- /* and finally take each layer of each res of ... */
- for (layno = layno0; layno < p_pocs->layno1 ; ++layno) {
- /*index = step_r * resno + step_c * compno + step_l * layno;*/
- packet_array[comp_index] = 1;
- comp_index += step_l;
+ res_index += step_c;
}
- res_index += step_c;
+ index += step_r;
}
-
- index += step_r;
}
-
- ++p_pocs;
}
index = 0;
for (resno = 0; resno < p_nb_resolutions; ++resno) {
for (compno = 0; compno < p_num_comps; ++compno) {
loss |= (packet_array[index] != 1);
- /*index = step_r * resno + step_c * compno + step_l * layno;*/
+#ifdef DEBUG_VERBOSE
+ if (packet_array[index] != 1) {
+ fprintf(stderr,
+ "Missing packet in POC: layno=%d resno=%d compno=%d\n",
+ layno, resno, compno);
+ }
+#endif
index += step_c;
}
}
static OPJ_BOOL opj_j2k_write_sot(opj_j2k_t *p_j2k,
OPJ_BYTE * p_data,
- OPJ_UINT32 p_total_data_size,
+ OPJ_UINT32 total_data_size,
OPJ_UINT32 * p_data_written,
const opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager
OPJ_UNUSED(p_stream);
- if (p_total_data_size < 12) {
+ if (total_data_size < 12) {
opj_event_msg(p_manager, EVT_ERROR,
"Not enough bytes in output buffer to write SOT marker\n");
return OPJ_FALSE;
opj_tcd_t * p_tile_coder,
OPJ_BYTE * p_data,
OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_total_data_size,
+ OPJ_UINT32 total_data_size,
const opj_stream_private_t *p_stream,
opj_event_mgr_t * p_manager
)
OPJ_UNUSED(p_stream);
- if (p_total_data_size < 4) {
+ if (total_data_size < 4) {
opj_event_msg(p_manager, EVT_ERROR,
"Not enough bytes in output buffer to write SOD marker\n");
return OPJ_FALSE;
p_data += 2;
/* make room for the EOF marker */
- l_remaining_data = p_total_data_size - 4;
+ l_remaining_data = total_data_size - 4;
/* update tile coder */
p_tile_coder->tp_num =
"Not enough memory to allocate tile coding parameters\n");
return OPJ_FALSE;
}
- if (parameters->numpocs) {
- /* initialisation of POC */
- opj_j2k_check_poc_val(parameters->POC, parameters->numpocs,
- (OPJ_UINT32)parameters->numresolution, image->numcomps,
- (OPJ_UINT32)parameters->tcp_numlayers, p_manager);
- /* TODO MSD use the return value*/
- }
for (tileno = 0; tileno < cp->tw * cp->th; tileno++) {
opj_tcp_t *tcp = &cp->tcps[tileno];
if (parameters->numpocs) {
/* initialisation of POC */
- tcp->POC = 1;
for (i = 0; i < parameters->numpocs; i++) {
if (tileno + 1 == parameters->POC[i].tile) {
opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile];
}
}
- tcp->numpocs = numpocs_tile - 1 ;
+ if (numpocs_tile) {
+
+ /* TODO MSD use the return value*/
+ opj_j2k_check_poc_val(parameters->POC, tileno, parameters->numpocs,
+ (OPJ_UINT32)parameters->numresolution, image->numcomps,
+ (OPJ_UINT32)parameters->tcp_numlayers, p_manager);
+
+ tcp->POC = 1;
+ tcp->numpocs = numpocs_tile - 1 ;
+ }
} else {
tcp->numpocs = 0;
}
static OPJ_BOOL opj_j2k_write_first_tile_part(opj_j2k_t *p_j2k,
OPJ_BYTE * p_data,
OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_total_data_size,
+ OPJ_UINT32 total_data_size,
opj_stream_private_t *p_stream,
struct opj_event_mgr * p_manager)
{
l_current_nb_bytes_written = 0;
l_begin_data = p_data;
- if (! opj_j2k_write_sot(p_j2k, p_data, p_total_data_size,
+ if (! opj_j2k_write_sot(p_j2k, p_data, total_data_size,
&l_current_nb_bytes_written, p_stream,
p_manager)) {
return OPJ_FALSE;
l_nb_bytes_written += l_current_nb_bytes_written;
p_data += l_current_nb_bytes_written;
- p_total_data_size -= l_current_nb_bytes_written;
+ total_data_size -= l_current_nb_bytes_written;
if (!OPJ_IS_CINEMA(l_cp->rsiz)) {
#if 0
p_manager);
l_nb_bytes_written += l_current_nb_bytes_written;
p_data += l_current_nb_bytes_written;
- p_total_data_size -= l_current_nb_bytes_written;
+ total_data_size -= l_current_nb_bytes_written;
l_current_nb_bytes_written = 0;
opj_j2k_write_qcc_in_memory(p_j2k, compno, p_data, &l_current_nb_bytes_written,
p_manager);
l_nb_bytes_written += l_current_nb_bytes_written;
p_data += l_current_nb_bytes_written;
- p_total_data_size -= l_current_nb_bytes_written;
+ total_data_size -= l_current_nb_bytes_written;
}
#endif
- if (l_cp->tcps[p_j2k->m_current_tile_number].numpocs) {
+ if (l_cp->tcps[p_j2k->m_current_tile_number].POC) {
l_current_nb_bytes_written = 0;
opj_j2k_write_poc_in_memory(p_j2k, p_data, &l_current_nb_bytes_written,
p_manager);
l_nb_bytes_written += l_current_nb_bytes_written;
p_data += l_current_nb_bytes_written;
- p_total_data_size -= l_current_nb_bytes_written;
+ total_data_size -= l_current_nb_bytes_written;
}
}
l_current_nb_bytes_written = 0;
if (! opj_j2k_write_sod(p_j2k, l_tcd, p_data, &l_current_nb_bytes_written,
- p_total_data_size, p_stream, p_manager)) {
+ total_data_size, p_stream, p_manager)) {
return OPJ_FALSE;
}
static OPJ_BOOL opj_j2k_write_all_tile_parts(opj_j2k_t *p_j2k,
OPJ_BYTE * p_data,
OPJ_UINT32 * p_data_written,
- OPJ_UINT32 p_total_data_size,
+ OPJ_UINT32 total_data_size,
opj_stream_private_t *p_stream,
struct opj_event_mgr * p_manager
)
l_begin_data = p_data;
if (! opj_j2k_write_sot(p_j2k, p_data,
- p_total_data_size,
+ total_data_size,
&l_current_nb_bytes_written,
p_stream,
p_manager)) {
l_nb_bytes_written += l_current_nb_bytes_written;
p_data += l_current_nb_bytes_written;
- p_total_data_size -= l_current_nb_bytes_written;
+ total_data_size -= l_current_nb_bytes_written;
l_part_tile_size += l_current_nb_bytes_written;
l_current_nb_bytes_written = 0;
if (! opj_j2k_write_sod(p_j2k, l_tcd, p_data, &l_current_nb_bytes_written,
- p_total_data_size, p_stream, p_manager)) {
+ total_data_size, p_stream, p_manager)) {
return OPJ_FALSE;
}
p_data += l_current_nb_bytes_written;
l_nb_bytes_written += l_current_nb_bytes_written;
- p_total_data_size -= l_current_nb_bytes_written;
+ total_data_size -= l_current_nb_bytes_written;
l_part_tile_size += l_current_nb_bytes_written;
/* Writing Psot in SOT marker */
l_begin_data = p_data;
if (! opj_j2k_write_sot(p_j2k, p_data,
- p_total_data_size,
+ total_data_size,
&l_current_nb_bytes_written, p_stream,
p_manager)) {
return OPJ_FALSE;
l_nb_bytes_written += l_current_nb_bytes_written;
p_data += l_current_nb_bytes_written;
- p_total_data_size -= l_current_nb_bytes_written;
+ total_data_size -= l_current_nb_bytes_written;
l_part_tile_size += l_current_nb_bytes_written;
l_current_nb_bytes_written = 0;
if (! opj_j2k_write_sod(p_j2k, l_tcd, p_data, &l_current_nb_bytes_written,
- p_total_data_size, p_stream, p_manager)) {
+ total_data_size, p_stream, p_manager)) {
return OPJ_FALSE;
}
l_nb_bytes_written += l_current_nb_bytes_written;
p_data += l_current_nb_bytes_written;
- p_total_data_size -= l_current_nb_bytes_written;
+ total_data_size -= l_current_nb_bytes_written;
l_part_tile_size += l_current_nb_bytes_written;
/* Writing Psot in SOT marker */
OPJ_PROG_ORDER prg1, prg;
/** Progression order string*/
OPJ_CHAR progorder[5];
- /** Tile number */
+ /** Tile number (starting at 1) */
OPJ_UINT32 tile;
/** Start and end values for Tile width and height*/
OPJ_INT32 tx0, tx1, ty0, ty1;
t1->data = tiledp;
t1->data_stride = tile_w;
if (tccp->qmfbid == 1) {
+ /* Do multiplication on unsigned type, even if the
+ * underlying type is signed, to avoid potential
+ * int overflow on large value (the output will be
+ * incorrect in such situation, but whatever...)
+ * This assumes complement-to-2 signed integer
+ * representation
+ * Fixes https://github.com/uclouvain/openjpeg/issues/1053
+ */
+ OPJ_UINT32* OPJ_RESTRICT tiledp_u = (OPJ_UINT32*) tiledp;
for (j = 0; j < cblk_h; ++j) {
for (i = 0; i < cblk_w; ++i) {
- tiledp[tileIndex] *= (1 << T1_NMSEDEC_FRACBITS);
+ tiledp_u[tileIndex] <<= T1_NMSEDEC_FRACBITS;
tileIndex++;
}
tileIndex += tileLineAdvance;
OPJ_BOOL packet_empty = OPJ_FALSE;
#endif
+#ifdef DEBUG_VERBOSE
+ if (p_t2_mode == FINAL_PASS) {
+ fprintf(stderr,
+ "encode packet compono=%d, resno=%d, precno=%d, layno=%d\n",
+ compno, resno, precno, layno);
+ }
+#endif
+
/* <SOP 0xff91> */
if (tcp->csty & J2K_CP_CSTY_SOP) {
if (length < 6) {
==========================================================
*/
-static void opj_pi_emit_error(opj_pi_iterator_t * pi, const char* msg)
-{
- (void)pi;
- (void)msg;
-}
-
static opj_bool pi_next_lrcp(opj_pi_iterator_t * pi)
{
opj_pi_comp_t *comp = NULL;
for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
pi->step_c + pi->precno * pi->step_p;
- /* Avoids index out of bounds access with include*/
- if (index >= pi->include_size) {
- opj_pi_emit_error(pi, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
if (!pi->include[index]) {
pi->include[index] = 1;
return OPJ_TRUE;
for (pi->precno = pi->poc.precno0; pi->precno < pi->poc.precno1; pi->precno++) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
pi->step_c + pi->precno * pi->step_p;
- /* Avoids index out of bounds access with include*/
- if (index >= pi->include_size) {
- opj_pi_emit_error(pi, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
if (!pi->include[index]) {
pi->include[index] = 1;
return OPJ_TRUE;
for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
pi->step_c + pi->precno * pi->step_p;
- /* Avoids index out of bounds access with include*/
- if (index >= pi->include_size) {
- opj_pi_emit_error(pi, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
if (!pi->include[index]) {
pi->include[index] = 1;
return OPJ_TRUE;
for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
pi->step_c + pi->precno * pi->step_p;
- /* Avoids index out of bounds access with include*/
- if (index >= pi->include_size) {
- opj_pi_emit_error(pi, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
if (!pi->include[index]) {
pi->include[index] = 1;
return OPJ_TRUE;
for (pi->layno = pi->poc.layno0; pi->layno < pi->poc.layno1; pi->layno++) {
index = pi->layno * pi->step_l + pi->resno * pi->step_r + pi->compno *
pi->step_c + pi->precno * pi->step_p;
- /* Avoids index out of bounds access with include*/
- if (index >= pi->include_size) {
- opj_pi_emit_error(pi, "Invalid access to pi->include");
- return OPJ_FALSE;
- }
if (!pi->include[index]) {
pi->include[index] = 1;
return OPJ_TRUE;
OPJ_UINT32 width = psImage->x1 - psImage->x0;
OPJ_UINT32 height = psImage->y1 - psImage->y0;
+#if 0
// Reject too big images since that will require allocating a lot of
// memory
if (width != 0 && psImage->numcomps != 0 &&
return 0;
}
+#endif
OPJ_UINT32 width_to_read = width;
if (width_to_read > 1024) {
opj_compress -i @INPUT_NR_PATH@/issue982.bmp -o @TEMP_PATH@/issue982.j2k -n 1
+# Test generating only one POC
+opj_compress -i @INPUT_NR_PATH@/byte.tif -o @TEMP_PATH@/byte_one_poc.j2k -n 2 -r 20,1 -POC T1=0,0,2,2,1,CPRL -b 4,4
+opj_compress -i @INPUT_NR_PATH@/byte.tif -o @TEMP_PATH@/byte_one_poc_funky_bounds.j2k -n 2 -r 20,1 -POC T1=0,0,65535,33,255,CPRL -b 4,4
+opj_compress -i @INPUT_NR_PATH@/byte.tif -o @TEMP_PATH@/byte_one_poc_unrelated_tile.j2k -n 1 -POC T1000=0,0,1,1,1,CPRL
+
# DECODER TEST SUITE
opj_decompress -i @INPUT_NR_PATH@/Bretagne2.j2k -o @TEMP_PATH@/Bretagne2.j2k.pgx
opj_decompress -i @INPUT_NR_PATH@/_00042.j2k -o @TEMP_PATH@/_00042.j2k.pgx
*ptilew = pCodeStreamInfo->tdx;
}
if (ptileh) {
- *ptilew = pCodeStreamInfo->tdy;
+ *ptileh = pCodeStreamInfo->tdy;
}
//int numResolutions = pCodeStreamInfo->m_default_tile_info.tccp_info[0].numresolutions;
if (pcblkw) {
fi
OPJ_UPLOAD_ABI_REPORT=0
-#OPJ_PREVIOUS_VERSION="2.2.0"
-OPJ_LATEST_VERSION="2.3.0"
+#OPJ_PREVIOUS_VERSION="2.3.0"
+OPJ_LATEST_VERSION="2.3.1"
if [ "${OPJ_PREVIOUS_VERSION:-}" != "" ]; then
OPJ_LIMIT_ABI_BUILDS="-limit 3"
else
make install &> /dev/null
cd ..
export PATH=${PWD}/tools/wdiff/bin:$PATH
-wget -qO - https://tools.ietf.org/tools/rfcdiff/rfcdiff-1.42.tgz | tar -xz
-mv rfcdiff-1.42 ${PWD}/tools/rfcdiff
-export PATH=${PWD}/tools/rfcdiff:$PATH
+wget https://tools.ietf.org/tools/rfcdiff/rfcdiff
+chmod +x rfcdiff
+mv rfcdiff ${PWD}/tools
+export PATH=${PWD}/tools:$PATH
wget -qO - https://github.com/lvc/installer/archive/0.10.tar.gz | tar -xz
mkdir ${PWD}/tools/abi-tracker
make -C installer-0.10 install prefix=${PWD}/tools/abi-tracker target=abi-tracker