OLD | NEW |
1 /* | 1 /* |
2 * The copyright in this software is being made available under the 2-clauses | 2 * The copyright in this software is being made available under the 2-clauses |
3 * BSD License, included below. This software may be subject to other third | 3 * BSD License, included below. This software may be subject to other third |
4 * party and contributor rights, including patent rights, and no such rights | 4 * party and contributor rights, including patent rights, and no such rights |
5 * are granted under this license. | 5 * are granted under this license. |
6 * | 6 * |
7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium | 7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium |
8 * Copyright (c) 2002-2014, Professor Benoit Macq | 8 * Copyright (c) 2002-2014, Professor Benoit Macq |
9 * Copyright (c) 2001-2003, David Janssens | 9 * Copyright (c) 2001-2003, David Janssens |
10 * Copyright (c) 2002-2003, Yannick Verschueren | 10 * Copyright (c) 2002-2003, Yannick Verschueren |
(...skipping 24 matching lines...) Expand all Loading... |
35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 35 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 36 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 37 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 38 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 39 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
40 * POSSIBILITY OF SUCH DAMAGE. | 40 * POSSIBILITY OF SUCH DAMAGE. |
41 */ | 41 */ |
42 | 42 |
43 #include "opj_includes.h" | 43 #include "opj_includes.h" |
44 | 44 |
45 #define CINEMA_24_CS 1302083 /*Codestream length for 24fps*/ | |
46 #define CINEMA_48_CS 651041 /*Codestream length for 48fps*/ | |
47 #define COMP_24_CS 1041666 /*Maximum size per color component for 2
K & 4K @ 24fps*/ | |
48 #define COMP_48_CS 520833 /*Maximum size per color component for 2
K @ 48fps*/ | |
49 | |
50 /** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */ | 45 /** @defgroup J2K J2K - JPEG-2000 codestream reader/writer */ |
51 /*@{*/ | 46 /*@{*/ |
52 | 47 |
53 /** @name Local static functions */ | 48 /** @name Local static functions */ |
54 /*@{*/ | 49 /*@{*/ |
55 | 50 |
56 /** | 51 /** |
57 * Sets up the procedures to do on reading header. Developpers wanting to extend
the library can add their own reading procedures. | 52 * Sets up the procedures to do on reading header. Developpers wanting to extend
the library can add their own reading procedures. |
58 */ | 53 */ |
59 static void opj_j2k_setup_header_reading (opj_j2k_t *p_j2k); | 54 static void opj_j2k_setup_header_reading (opj_j2k_t *p_j2k); |
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 static opj_codestream_index_t* opj_j2k_create_cstr_index(void); | 1160 static opj_codestream_index_t* opj_j2k_create_cstr_index(void); |
1166 | 1161 |
1167 static OPJ_FLOAT32 opj_j2k_get_tp_stride (opj_tcp_t * p_tcp); | 1162 static OPJ_FLOAT32 opj_j2k_get_tp_stride (opj_tcp_t * p_tcp); |
1168 | 1163 |
1169 static OPJ_FLOAT32 opj_j2k_get_default_stride (opj_tcp_t * p_tcp); | 1164 static OPJ_FLOAT32 opj_j2k_get_default_stride (opj_tcp_t * p_tcp); |
1170 | 1165 |
1171 static int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres); | 1166 static int opj_j2k_initialise_4K_poc(opj_poc_t *POC, int numres); |
1172 | 1167 |
1173 static void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_ima
ge_t *image, opj_event_mgr_t *p_manager); | 1168 static void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_ima
ge_t *image, opj_event_mgr_t *p_manager); |
1174 | 1169 |
1175 static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_CINEMA_MODE
cinema_mode, opj_event_mgr_t *p_manager); | 1170 static OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz,
opj_event_mgr_t *p_manager); |
1176 | 1171 |
1177 /*@}*/ | 1172 /*@}*/ |
1178 | 1173 |
1179 /*@}*/ | 1174 /*@}*/ |
1180 | 1175 |
1181 /* ----------------------------------------------------------------------- */ | 1176 /* ----------------------------------------------------------------------- */ |
1182 typedef struct j2k_prog_order{ | 1177 typedef struct j2k_prog_order{ |
1183 OPJ_PROG_ORDER enum_prog; | 1178 OPJ_PROG_ORDER enum_prog; |
1184 char str_prog[5]; | 1179 char str_prog[5]; |
1185 }j2k_prog_order_t; | 1180 }j2k_prog_order_t; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 OPJ_UINT32 step_r = p_num_comps * step_c; | 1492 OPJ_UINT32 step_r = p_num_comps * step_c; |
1498 OPJ_UINT32 step_l = p_nb_resolutions * step_r; | 1493 OPJ_UINT32 step_l = p_nb_resolutions * step_r; |
1499 OPJ_BOOL loss = OPJ_FALSE; | 1494 OPJ_BOOL loss = OPJ_FALSE; |
1500 OPJ_UINT32 layno0 = 0; | 1495 OPJ_UINT32 layno0 = 0; |
1501 | 1496 |
1502 packet_array = (OPJ_UINT32*) opj_calloc(step_l * p_num_layers, sizeof(OP
J_UINT32)); | 1497 packet_array = (OPJ_UINT32*) opj_calloc(step_l * p_num_layers, sizeof(OP
J_UINT32)); |
1503 if (packet_array == 00) { | 1498 if (packet_array == 00) { |
1504 opj_event_msg(p_manager , EVT_ERROR, "Not enough memory for chec
king the poc values.\n"); | 1499 opj_event_msg(p_manager , EVT_ERROR, "Not enough memory for chec
king the poc values.\n"); |
1505 return OPJ_FALSE; | 1500 return OPJ_FALSE; |
1506 } | 1501 } |
1507 memset(packet_array,0,step_l * p_num_layers* sizeof(OPJ_UINT32)); | |
1508 | 1502 |
1509 if (p_nb_pocs == 0) { | 1503 if (p_nb_pocs == 0) { |
1510 opj_free(packet_array); | 1504 opj_free(packet_array); |
1511 return OPJ_TRUE; | 1505 return OPJ_TRUE; |
1512 } | 1506 } |
1513 | 1507 |
1514 index = step_r * p_pocs->resno0; | 1508 index = step_r * p_pocs->resno0; |
1515 /* take each resolution for each poc */ | 1509 /* take each resolution for each poc */ |
1516 for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno) | 1510 for (resno = p_pocs->resno0 ; resno < p_pocs->resno1 ; ++resno) |
1517 { | 1511 { |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1938 l_remaining_size = p_header_size - 36; | 1932 l_remaining_size = p_header_size - 36; |
1939 l_nb_comp = l_remaining_size / 3; | 1933 l_nb_comp = l_remaining_size / 3; |
1940 l_nb_comp_remain = l_remaining_size % 3; | 1934 l_nb_comp_remain = l_remaining_size % 3; |
1941 if (l_nb_comp_remain != 0){ | 1935 if (l_nb_comp_remain != 0){ |
1942 opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker size\
n"); | 1936 opj_event_msg(p_manager, EVT_ERROR, "Error with SIZ marker size\
n"); |
1943 return OPJ_FALSE; | 1937 return OPJ_FALSE; |
1944 } | 1938 } |
1945 | 1939 |
1946 opj_read_bytes(p_header_data,&l_tmp ,2);
/* Rsiz (capabilities) */ | 1940 opj_read_bytes(p_header_data,&l_tmp ,2);
/* Rsiz (capabilities) */ |
1947 p_header_data+=2; | 1941 p_header_data+=2; |
1948 l_cp->rsiz = (OPJ_RSIZ_CAPABILITIES) l_tmp; | 1942 l_cp->rsiz = (OPJ_UINT16) l_tmp; |
1949 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x1, 4); /* Xsiz
*/ | 1943 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x1, 4); /* Xsiz
*/ |
1950 p_header_data+=4; | 1944 p_header_data+=4; |
1951 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y1, 4); /* Ysiz
*/ | 1945 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y1, 4); /* Ysiz
*/ |
1952 p_header_data+=4; | 1946 p_header_data+=4; |
1953 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x0, 4); /* X0siz
*/ | 1947 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->x0, 4); /* X0siz
*/ |
1954 p_header_data+=4; | 1948 p_header_data+=4; |
1955 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y0, 4); /* Y0siz
*/ | 1949 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_image->y0, 4); /* Y0siz
*/ |
1956 p_header_data+=4; | 1950 p_header_data+=4; |
1957 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tdx, 4);
/* XTsiz */ | 1951 opj_read_bytes(p_header_data, (OPJ_UINT32*) &l_cp->tdx, 4);
/* XTsiz */ |
1958 p_header_data+=4; | 1952 p_header_data+=4; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 #endif /* USE_JPWL */ | 2030 #endif /* USE_JPWL */ |
2037 | 2031 |
2038 /* Allocate the resulting image components */ | 2032 /* Allocate the resulting image components */ |
2039 l_image->comps = (opj_image_comp_t*) opj_calloc(l_image->numcomps, sizeo
f(opj_image_comp_t)); | 2033 l_image->comps = (opj_image_comp_t*) opj_calloc(l_image->numcomps, sizeo
f(opj_image_comp_t)); |
2040 if (l_image->comps == 00){ | 2034 if (l_image->comps == 00){ |
2041 l_image->numcomps = 0; | 2035 l_image->numcomps = 0; |
2042 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); | 2036 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); |
2043 return OPJ_FALSE; | 2037 return OPJ_FALSE; |
2044 } | 2038 } |
2045 | 2039 |
2046 memset(l_image->comps,0,l_image->numcomps * sizeof(opj_image_comp_t)); | |
2047 l_img_comp = l_image->comps; | 2040 l_img_comp = l_image->comps; |
2048 | 2041 |
2049 /* Read the component information */ | 2042 /* Read the component information */ |
2050 for (i = 0; i < l_image->numcomps; ++i){ | 2043 for (i = 0; i < l_image->numcomps; ++i){ |
2051 OPJ_UINT32 tmp; | 2044 OPJ_UINT32 tmp; |
2052 opj_read_bytes(p_header_data,&tmp,1); /* Ssiz_i */ | 2045 opj_read_bytes(p_header_data,&tmp,1); /* Ssiz_i */ |
2053 ++p_header_data; | 2046 ++p_header_data; |
2054 l_img_comp->prec = (tmp & 0x7f) + 1; | 2047 l_img_comp->prec = (tmp & 0x7f) + 1; |
2055 l_img_comp->sgnd = tmp >> 7; | 2048 l_img_comp->sgnd = tmp >> 7; |
2056 opj_read_bytes(p_header_data,&tmp,1); /* XRsiz_i */ | 2049 opj_read_bytes(p_header_data,&tmp,1); /* XRsiz_i */ |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2165 } | 2158 } |
2166 } | 2159 } |
2167 #endif /* USE_JPWL */ | 2160 #endif /* USE_JPWL */ |
2168 | 2161 |
2169 /* memory allocations */ | 2162 /* memory allocations */ |
2170 l_cp->tcps = (opj_tcp_t*) opj_calloc(l_nb_tiles, sizeof(opj_tcp_t)); | 2163 l_cp->tcps = (opj_tcp_t*) opj_calloc(l_nb_tiles, sizeof(opj_tcp_t)); |
2171 if (l_cp->tcps == 00) { | 2164 if (l_cp->tcps == 00) { |
2172 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); | 2165 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); |
2173 return OPJ_FALSE; | 2166 return OPJ_FALSE; |
2174 } | 2167 } |
2175 memset(l_cp->tcps,0,l_nb_tiles*sizeof(opj_tcp_t)); | |
2176 | 2168 |
2177 #ifdef USE_JPWL | 2169 #ifdef USE_JPWL |
2178 if (l_cp->correct) { | 2170 if (l_cp->correct) { |
2179 if (!l_cp->tcps) { | 2171 if (!l_cp->tcps) { |
2180 opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT
_ERROR, | 2172 opj_event_msg(p_manager, JPWL_ASSUME ? EVT_WARNING : EVT
_ERROR, |
2181 "JPWL: could not alloc tcps field of cp\n"); | 2173 "JPWL: could not alloc tcps field of cp\n"); |
2182 if (!JPWL_ASSUME || JPWL_ASSUME) { | 2174 if (!JPWL_ASSUME || JPWL_ASSUME) { |
2183 opj_event_msg(p_manager, EVT_ERROR, "JPWL: givin
g up\n"); | 2175 opj_event_msg(p_manager, EVT_ERROR, "JPWL: givin
g up\n"); |
2184 return OPJ_FALSE; | 2176 return OPJ_FALSE; |
2185 } | 2177 } |
2186 } | 2178 } |
2187 } | 2179 } |
2188 #endif /* USE_JPWL */ | 2180 #endif /* USE_JPWL */ |
2189 | 2181 |
2190 p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps = | 2182 p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps = |
2191 (opj_tccp_t*) opj_calloc(l_image->numcomps, sizeof(opj_t
ccp_t)); | 2183 (opj_tccp_t*) opj_calloc(l_image->numcomps, sizeof(opj_t
ccp_t)); |
2192 if(p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps == 00) { | 2184 if(p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps == 00) { |
2193 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); | 2185 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); |
2194 return OPJ_FALSE; | 2186 return OPJ_FALSE; |
2195 } | 2187 } |
2196 memset(p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps ,0,l_image
->numcomps*sizeof(opj_tccp_t)); | |
2197 | 2188 |
2198 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records = | 2189 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records = |
2199 (opj_mct_data_t*)opj_malloc(OPJ_J2K_MCT_DEFAULT_NB_RECOR
DS * sizeof(opj_mct_data_t)); | 2190 (opj_mct_data_t*)opj_calloc(OPJ_J2K_MCT_DEFAULT_NB_RECOR
DS ,sizeof(opj_mct_data_t)); |
2200 | 2191 |
2201 if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records) { | 2192 if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records) { |
2202 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); | 2193 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); |
2203 return OPJ_FALSE; | 2194 return OPJ_FALSE; |
2204 } | 2195 } |
2205 memset(p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records,0,
OPJ_J2K_MCT_DEFAULT_NB_RECORDS * sizeof(opj_mct_data_t)); | |
2206 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mct_records =
OPJ_J2K_MCT_DEFAULT_NB_RECORDS; | 2196 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mct_records =
OPJ_J2K_MCT_DEFAULT_NB_RECORDS; |
2207 | 2197 |
2208 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records = | 2198 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records = |
2209 (opj_simple_mcc_decorrelation_data_t*) | 2199 (opj_simple_mcc_decorrelation_data_t*) |
2210 opj_malloc(OPJ_J2K_MCC_DEFAULT_NB_RECORDS * sizeof(opj_s
imple_mcc_decorrelation_data_t)); | 2200 opj_calloc(OPJ_J2K_MCC_DEFAULT_NB_RECORDS, sizeof(opj_si
mple_mcc_decorrelation_data_t)); |
2211 | 2201 |
2212 if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records) { | 2202 if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records) { |
2213 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); | 2203 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to take i
n charge SIZ marker\n"); |
2214 return OPJ_FALSE; | 2204 return OPJ_FALSE; |
2215 } | 2205 } |
2216 memset(p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records,0,
OPJ_J2K_MCC_DEFAULT_NB_RECORDS * sizeof(opj_simple_mcc_decorrelation_data_t)); | |
2217 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mcc_records =
OPJ_J2K_MCC_DEFAULT_NB_RECORDS; | 2206 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mcc_records =
OPJ_J2K_MCC_DEFAULT_NB_RECORDS; |
2218 | 2207 |
2219 /* set up default dc level shift */ | 2208 /* set up default dc level shift */ |
2220 for (i=0;i<l_image->numcomps;++i) { | 2209 for (i=0;i<l_image->numcomps;++i) { |
2221 if (! l_image->comps[i].sgnd) { | 2210 if (! l_image->comps[i].sgnd) { |
2222 p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i
].m_dc_level_shift = 1 << (l_image->comps[i].prec - 1); | 2211 p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i
].m_dc_level_shift = 1 << (l_image->comps[i].prec - 1); |
2223 } | 2212 } |
2224 } | 2213 } |
2225 | 2214 |
2226 l_current_tile_param = l_cp->tcps; | 2215 l_current_tile_param = l_cp->tcps; |
2227 for (i = 0; i < l_nb_tiles; ++i) { | 2216 for (i = 0; i < l_nb_tiles; ++i) { |
2228 l_current_tile_param->tccps = (opj_tccp_t*) opj_malloc(l_image->
numcomps * sizeof(opj_tccp_t)); | 2217 l_current_tile_param->tccps = (opj_tccp_t*) opj_calloc(l_image->
numcomps, sizeof(opj_tccp_t)); |
2229 if (l_current_tile_param->tccps == 00) { | 2218 if (l_current_tile_param->tccps == 00) { |
2230 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory t
o take in charge SIZ marker\n"); | 2219 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory t
o take in charge SIZ marker\n"); |
2231 return OPJ_FALSE; | 2220 return OPJ_FALSE; |
2232 } | 2221 } |
2233 memset(l_current_tile_param->tccps,0,l_image->numcomps * sizeof(
opj_tccp_t)); | |
2234 | 2222 |
2235 ++l_current_tile_param; | 2223 ++l_current_tile_param; |
2236 } | 2224 } |
2237 | 2225 |
2238 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MH; /* FIXME J2K_
DEC_STATE_MH; */ | 2226 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MH; /* FIXME J2K_
DEC_STATE_MH; */ |
2239 opj_image_comp_header_update(l_image,l_cp); | 2227 opj_image_comp_header_update(l_image,l_cp); |
2240 | 2228 |
2241 return OPJ_TRUE; | 2229 return OPJ_TRUE; |
2242 } | 2230 } |
2243 | 2231 |
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3095 | 3083 |
3096 OPJ_UINT32 opj_j2k_get_specific_header_sizes(opj_j2k_t *p_j2k) | 3084 OPJ_UINT32 opj_j2k_get_specific_header_sizes(opj_j2k_t *p_j2k) |
3097 { | 3085 { |
3098 OPJ_UINT32 l_nb_bytes = 0; | 3086 OPJ_UINT32 l_nb_bytes = 0; |
3099 OPJ_UINT32 l_nb_comps; | 3087 OPJ_UINT32 l_nb_comps; |
3100 OPJ_UINT32 l_coc_bytes,l_qcc_bytes; | 3088 OPJ_UINT32 l_coc_bytes,l_qcc_bytes; |
3101 | 3089 |
3102 l_nb_comps = p_j2k->m_private_image->numcomps - 1; | 3090 l_nb_comps = p_j2k->m_private_image->numcomps - 1; |
3103 l_nb_bytes += opj_j2k_get_max_toc_size(p_j2k); | 3091 l_nb_bytes += opj_j2k_get_max_toc_size(p_j2k); |
3104 | 3092 |
3105 if (p_j2k->m_cp.m_specific_param.m_enc.m_cinema == 0) { | 3093 if (!(OPJ_IS_CINEMA(p_j2k->m_cp.rsiz))) { |
3106 l_coc_bytes = opj_j2k_get_max_coc_size(p_j2k); | 3094 l_coc_bytes = opj_j2k_get_max_coc_size(p_j2k); |
3107 l_nb_bytes += l_nb_comps * l_coc_bytes; | 3095 l_nb_bytes += l_nb_comps * l_coc_bytes; |
3108 | 3096 |
3109 l_qcc_bytes = opj_j2k_get_max_qcc_size(p_j2k); | 3097 l_qcc_bytes = opj_j2k_get_max_qcc_size(p_j2k); |
3110 l_nb_bytes += l_nb_comps * l_qcc_bytes; | 3098 l_nb_bytes += l_nb_comps * l_qcc_bytes; |
3111 } | 3099 } |
3112 | 3100 |
3113 l_nb_bytes += opj_j2k_get_max_poc_size(p_j2k); | 3101 l_nb_bytes += opj_j2k_get_max_poc_size(p_j2k); |
3114 | 3102 |
3115 /*** DEVELOPER CORNER, Add room for your headers ***/ | 3103 /*** DEVELOPER CORNER, Add room for your headers ***/ |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3574 l_cp->ppm_data = NULL; | 3562 l_cp->ppm_data = NULL; |
3575 l_cp->ppm_buffer = NULL; | 3563 l_cp->ppm_buffer = NULL; |
3576 l_cp->ppm = 0; /* do not use PPM */ | 3564 l_cp->ppm = 0; /* do not use PPM */ |
3577 return OPJ_FALSE; | 3565 return OPJ_FALSE; |
3578 } | 3566 } |
3579 | 3567 |
3580 /* First PPM marker: Initialization */ | 3568 /* First PPM marker: Initialization */ |
3581 l_cp->ppm_len = l_N_ppm; | 3569 l_cp->ppm_len = l_N_ppm; |
3582 l_cp->ppm_data_read = 0; | 3570 l_cp->ppm_data_read = 0; |
3583 | 3571 |
3584 l_cp->ppm_data = (OPJ_BYTE *) opj_malloc(l_cp->ppm_len); | 3572 l_cp->ppm_data = (OPJ_BYTE *) opj_calloc(1,l_cp->ppm_len); |
3585 l_cp->ppm_buffer = l_cp->ppm_data; | 3573 l_cp->ppm_buffer = l_cp->ppm_data; |
3586 if (l_cp->ppm_data == 00) { | 3574 if (l_cp->ppm_data == 00) { |
3587 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory t
o read ppm marker\n"); | 3575 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory t
o read ppm marker\n"); |
3588 return OPJ_FALSE; | 3576 return OPJ_FALSE; |
3589 } | 3577 } |
3590 memset(l_cp->ppm_data,0,l_cp->ppm_len); | |
3591 | 3578 |
3592 l_cp->ppm_data_current = l_cp->ppm_data; | 3579 l_cp->ppm_data_current = l_cp->ppm_data; |
3593 | 3580 |
3594 /*l_cp->ppm_data = l_cp->ppm_buffer;*/ | 3581 /*l_cp->ppm_data = l_cp->ppm_buffer;*/ |
3595 } | 3582 } |
3596 else { | 3583 else { |
3597 if (p_header_size < 4) { | 3584 if (p_header_size < 4) { |
3598 opj_event_msg(p_manager, EVT_WARNING, "Empty PPM marker\
n"); | 3585 opj_event_msg(p_manager, EVT_WARNING, "Empty PPM marker\
n"); |
3599 return OPJ_TRUE; | 3586 return OPJ_TRUE; |
3600 } | 3587 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3647 while (l_remaining_data >= l_N_ppm) { | 3634 while (l_remaining_data >= l_N_ppm) { |
3648 /* read a complete Ippm series*/ | 3635 /* read a complete Ippm series*/ |
3649 memcpy(l_cp->ppm_data_current, p_header_data, l_N_ppm); | 3636 memcpy(l_cp->ppm_data_current, p_header_data, l_N_ppm); |
3650 p_header_size -= l_N_ppm; | 3637 p_header_size -= l_N_ppm; |
3651 p_header_data += l_N_ppm; | 3638 p_header_data += l_N_ppm; |
3652 | 3639 |
3653 l_cp->ppm_data_read += l_N_ppm; /* Increase the number of data r
ead*/ | 3640 l_cp->ppm_data_read += l_N_ppm; /* Increase the number of data r
ead*/ |
3654 | 3641 |
3655 if (p_header_size) | 3642 if (p_header_size) |
3656 { | 3643 { |
3657 if (p_header_size < 4) return OP
J_FALSE; | |
3658 opj_read_bytes(p_header_data,&l_N_ppm,4);
/* N_ppm^i */ | 3644 opj_read_bytes(p_header_data,&l_N_ppm,4);
/* N_ppm^i */ |
3659 p_header_data+=4; | 3645 p_header_data+=4; |
3660 p_header_size-=4; | 3646 p_header_size-=4; |
3661 } | 3647 } |
3662 else { | 3648 else { |
3663 l_remaining_data = p_header_size; | 3649 l_remaining_data = p_header_size; |
3664 break; | 3650 break; |
3665 } | 3651 } |
3666 | 3652 |
3667 l_remaining_data = p_header_size; | 3653 l_remaining_data = p_header_size; |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4067 opj_read_bytes(p_header_data,&l_num_parts ,1); /* TNsot
*/ | 4053 opj_read_bytes(p_header_data,&l_num_parts ,1); /* TNsot
*/ |
4068 ++p_header_data; | 4054 ++p_header_data; |
4069 | 4055 |
4070 if (l_num_parts != 0) { /* Number of tile-part header is provide
d by this tile-part header */ | 4056 if (l_num_parts != 0) { /* Number of tile-part header is provide
d by this tile-part header */ |
4071 /* Useful to manage the case of textGBR.jp2 file because
two values of TNSot are allowed: the correct numbers of | 4057 /* Useful to manage the case of textGBR.jp2 file because
two values of TNSot are allowed: the correct numbers of |
4072 * tile-parts for that tile and zero (A.4.2 of 15444-1 :
2002). */ | 4058 * tile-parts for that tile and zero (A.4.2 of 15444-1 :
2002). */ |
4073 if (l_tcp->m_nb_tile_parts) { | 4059 if (l_tcp->m_nb_tile_parts) { |
4074 if (l_current_part >= l_tcp->m_nb_tile_parts){ | 4060 if (l_current_part >= l_tcp->m_nb_tile_parts){ |
4075 opj_event_msg(p_manager, EVT_ERROR, "In
SOT marker, TPSot (%d) is not valid regards to the current " | 4061 opj_event_msg(p_manager, EVT_ERROR, "In
SOT marker, TPSot (%d) is not valid regards to the current " |
4076 "number of tile-part (%d
), giving up\n", l_current_part, l_tcp->m_nb_tile_parts ); | 4062 "number of tile-part (%d
), giving up\n", l_current_part, l_tcp->m_nb_tile_parts ); |
4077 // p_j2k->m_specific_param.m_decoder.m_la
st_tile_part = 1; | 4063 p_j2k->m_specific_param.m_decoder.m_last
_tile_part = 1; |
4078 // return OPJ_FALSE; | 4064 return OPJ_FALSE; |
4079 » » » » » » » » » » | |
4080 » » » » » » » » » »
l_num_parts++; | |
4081 } | 4065 } |
4082 } | 4066 } |
4083 if( l_current_part >= l_num_parts ) { | 4067 if( l_current_part >= l_num_parts ) { |
4084 /* testcase 451.pdf.SIGSEGV.ce9.3723 */ | 4068 /* testcase 451.pdf.SIGSEGV.ce9.3723 */ |
4085 opj_event_msg(p_manager, EVT_ERROR, "In SOT marker, TP
Sot (%d) is not valid regards to the current " | 4069 opj_event_msg(p_manager, EVT_ERROR, "In SOT marker, TP
Sot (%d) is not valid regards to the current " |
4086 "number of tile-part (header) (%d), giving up\n", l_
current_part, l_num_parts ); | 4070 "number of tile-part (header) (%d), giving up\n", l_
current_part, l_num_parts ); |
4087 p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1
; | 4071 p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1
; |
4088 return OPJ_FALSE; | 4072 return OPJ_FALSE; |
4089 } | 4073 } |
4090 l_tcp->m_nb_tile_parts = l_num_parts; | 4074 l_tcp->m_nb_tile_parts = l_num_parts; |
4091 } | 4075 } |
4092 | 4076 |
4093 /* If know the number of tile part header we will check if we di
dn't read the last*/ | 4077 /* If know the number of tile part header we will check if we di
dn't read the last*/ |
4094 if (l_tcp->m_nb_tile_parts) { | 4078 if (l_tcp->m_nb_tile_parts) { |
4095 if (l_tcp->m_nb_tile_parts == (l_current_part+1)) { | 4079 if (l_tcp->m_nb_tile_parts == (l_current_part+1)) { |
4096 p_j2k->m_specific_param.m_decoder.m_can_decode =
0; /* Process the last tile-part header*/ | 4080 p_j2k->m_specific_param.m_decoder.m_can_decode =
1; /* Process the last tile-part header*/ |
4097 } | 4081 } |
4098 } | 4082 } |
4099 | 4083 |
4100 if (!p_j2k->m_specific_param.m_decoder.m_last_tile_part){ | 4084 if (!p_j2k->m_specific_param.m_decoder.m_last_tile_part){ |
4101 /* Keep the size of data to skip after this marker */ | 4085 /* Keep the size of data to skip after this marker */ |
4102 p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_l
en - 12; /* SOT_marker_size = 12 */ | 4086 p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_l
en - 12; /* SOT_marker_size = 12 */ |
4103 } | 4087 } |
4104 else { | 4088 else { |
4105 /* FIXME: need to be computed from the number of bytes r
emaining in the codestream */ | 4089 /* FIXME: need to be computed from the number of bytes r
emaining in the codestream */ |
4106 p_j2k->m_specific_param.m_decoder.m_sot_length = 0; | 4090 p_j2k->m_specific_param.m_decoder.m_sot_length = 0; |
(...skipping 22 matching lines...) Expand all Loading... |
4129 p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_numb
er].tileno = p_j2k->m_current_tile_number; | 4113 p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_numb
er].tileno = p_j2k->m_current_tile_number; |
4130 p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_numb
er].current_tpsno = l_current_part; | 4114 p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_numb
er].current_tpsno = l_current_part; |
4131 | 4115 |
4132 if (l_num_parts != 0){ | 4116 if (l_num_parts != 0){ |
4133 p_j2k->cstr_index->tile_index[p_j2k->m_current_t
ile_number].nb_tps = l_num_parts; | 4117 p_j2k->cstr_index->tile_index[p_j2k->m_current_t
ile_number].nb_tps = l_num_parts; |
4134 p_j2k->cstr_index->tile_index[p_j2k->m_current_t
ile_number].current_nb_tps = l_num_parts; | 4118 p_j2k->cstr_index->tile_index[p_j2k->m_current_t
ile_number].current_nb_tps = l_num_parts; |
4135 | 4119 |
4136 if (!p_j2k->cstr_index->tile_index[p_j2k->m_curr
ent_tile_number].tp_index) { | 4120 if (!p_j2k->cstr_index->tile_index[p_j2k->m_curr
ent_tile_number].tp_index) { |
4137 p_j2k->cstr_index->tile_index[p_j2k->m_c
urrent_tile_number].tp_index = | 4121 p_j2k->cstr_index->tile_index[p_j2k->m_c
urrent_tile_number].tp_index = |
4138 (opj_tp_index_t*)opj_calloc(l_nu
m_parts, sizeof(opj_tp_index_t)); | 4122 (opj_tp_index_t*)opj_calloc(l_nu
m_parts, sizeof(opj_tp_index_t)); |
| 4123 if (!p_j2k->cstr_index->tile_index[p_j2k
->m_current_tile_number].tp_index) { |
| 4124 opj_event_msg(p_manager, EVT_ERR
OR, "Not enough memory to read SOT marker. Tile index allocation failed\n"); |
| 4125 return OPJ_FALSE; |
| 4126
} |
4139 } | 4127 } |
4140 else { | 4128 else { |
4141 opj_tp_index_t *new_tp_index = (opj_tp_i
ndex_t *) opj_realloc( | 4129 opj_tp_index_t *new_tp_index = (opj_tp_i
ndex_t *) opj_realloc( |
4142 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].tp_index, l_num_parts* sizeof(opj_tp_index_t
)); | 4130 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].tp_index, l_num_parts* sizeof(opj_tp_index_t
)); |
4143 if (! new_tp_index) { | 4131 if (! new_tp_index) { |
4144 opj_free(p_j2k->cstr_index->tile
_index[p_j2k->m_current_tile_number].tp_index); | 4132 opj_free(p_j2k->cstr_index->tile
_index[p_j2k->m_current_tile_number].tp_index); |
4145 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = NULL; | 4133 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = NULL; |
4146 opj_event_msg(p_manager, EVT_ERR
OR, "Not enough memory to read PPT marker\n"); | 4134 opj_event_msg(p_manager, EVT_ERR
OR, "Not enough memory to read SOT marker. Tile index allocation failed\n"); |
4147 return OPJ_FALSE; | 4135 return OPJ_FALSE; |
4148 } | 4136 } |
4149 p_j2k->cstr_index->tile_index[p_j2k->m_c
urrent_tile_number].tp_index = new_tp_index; | 4137 p_j2k->cstr_index->tile_index[p_j2k->m_c
urrent_tile_number].tp_index = new_tp_index; |
4150 } | 4138 } |
4151 } | 4139 } |
4152 else{ | 4140 else{ |
4153 /*if (!p_j2k->cstr_index->tile_index[p_j2k->m_cu
rrent_tile_number].tp_index)*/ { | 4141 /*if (!p_j2k->cstr_index->tile_index[p_j2k->m_cu
rrent_tile_number].tp_index)*/ { |
4154 | 4142 |
4155 if (!p_j2k->cstr_index->tile_index[p_j2k
->m_current_tile_number].tp_index) { | 4143 if (!p_j2k->cstr_index->tile_index[p_j2k
->m_current_tile_number].tp_index) { |
4156 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].current_nb_tps = 10; | 4144 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].current_nb_tps = 10; |
4157 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = | 4145 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = |
4158 (opj_tp_index_t*)opj_cal
loc( p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps, | 4146 (opj_tp_index_t*)opj_cal
loc( p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps, |
4159 sizeof(o
pj_tp_index_t)); | 4147 sizeof(o
pj_tp_index_t)); |
| 4148
if (!p_j2k->cstr_index->tile_index[p_j2k->m_curr
ent_tile_number].tp_index) { |
| 4149 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].current_nb_tps = 0; |
| 4150 opj_event_msg(p_manager,
EVT_ERROR, "Not enough memory to read SOT marker. Tile index allocation failed\
n"); |
| 4151 return OPJ_FALSE; |
| 4152
} |
4160 } | 4153 } |
4161 | 4154 |
4162 if ( l_current_part >= p_j2k->cstr_index
->tile_index[p_j2k->m_current_tile_number].current_nb_tps ){ | 4155 if ( l_current_part >= p_j2k->cstr_index
->tile_index[p_j2k->m_current_tile_number].current_nb_tps ){ |
4163 opj_tp_index_t *new_tp_index; | 4156 opj_tp_index_t *new_tp_index; |
4164 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].current_nb_tps = l_current_part + 1; | 4157 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].current_nb_tps = l_current_part + 1; |
4165 new_tp_index = (opj_tp_index_t *
) opj_realloc( | 4158 new_tp_index = (opj_tp_index_t *
) opj_realloc( |
4166 p_j2k->cstr_inde
x->tile_index[p_j2k->m_current_tile_number].tp_index, | 4159 p_j2k->cstr_inde
x->tile_index[p_j2k->m_current_tile_number].tp_index, |
4167 p_j2k->cstr_inde
x->tile_index[p_j2k->m_current_tile_number].current_nb_tps * sizeof(opj_tp_index
_t)); | 4160 p_j2k->cstr_inde
x->tile_index[p_j2k->m_current_tile_number].current_nb_tps * sizeof(opj_tp_index
_t)); |
4168 if (! new_tp_index) { | 4161 if (! new_tp_index) { |
4169 opj_free(p_j2k->cstr_ind
ex->tile_index[p_j2k->m_current_tile_number].tp_index); | 4162 opj_free(p_j2k->cstr_ind
ex->tile_index[p_j2k->m_current_tile_number].tp_index); |
4170 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].tp_index = NULL; | 4163 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].tp_index = NULL; |
4171 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].current_nb_tps = 0; | 4164 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].current_nb_tps = 0; |
4172 opj_event_msg(p_manager,
EVT_ERROR, "Not enough memory to read PPT marker\n"); | 4165 opj_event_msg(p_manager,
EVT_ERROR, "Not enough memory to read SOT marker. Tile index allocation failed\
n"); |
4173 return OPJ_FALSE; | 4166 return OPJ_FALSE; |
4174 } | 4167 } |
4175 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = new_tp_index; | 4168 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = new_tp_index; |
4176 } | 4169 } |
4177 } | 4170 } |
4178 | 4171 |
4179 } | 4172 } |
4180 | 4173 |
4181 } | 4174 } |
4182 | 4175 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4324 | 4317 |
4325 /* Patch to support new PHR data */ | 4318 /* Patch to support new PHR data */ |
4326 if (p_j2k->m_specific_param.m_decoder.m_sot_length) { | 4319 if (p_j2k->m_specific_param.m_decoder.m_sot_length) { |
4327 if (! *l_current_data) { | 4320 if (! *l_current_data) { |
4328 /* LH: oddly enough, in this path, l_tile_len!=0. | 4321 /* LH: oddly enough, in this path, l_tile_len!=0. |
4329 * TODO: If this was consistant, we could simplify the code to o
nly use realloc(), as realloc(0,...) default to malloc(0,...). | 4322 * TODO: If this was consistant, we could simplify the code to o
nly use realloc(), as realloc(0,...) default to malloc(0,...). |
4330 */ | 4323 */ |
4331 *l_current_data = (OPJ_BYTE*) opj_malloc(p_j2k->m_specific_param
.m_decoder.m_sot_length); | 4324 *l_current_data = (OPJ_BYTE*) opj_malloc(p_j2k->m_specific_param
.m_decoder.m_sot_length); |
4332 } | 4325 } |
4333 else { | 4326 else { |
4334 » » » » OPJ_BYTE *l_new_current_data = NULL; | 4327 OPJ_BYTE *l_new_current_data = (OPJ_BYTE *) opj_realloc(*l_curre
nt_data, *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_length); |
4335 » » » » //BUGID: 0056005 and 0056022. | |
4336 » » » » //test file: 366683_fuzz-asan_heap-oob_6bae99_31
55_5245.pdf and fuzz-12.pdf. | |
4337 » » » » if ((OPJ_UINT32)-1 - p_j2k->m_specific_param.m_d
ecoder.m_sot_length >= *l_tile_len) | |
4338 » » » » » l_new_current_data = (OPJ_BYTE *) opj_re
alloc(*l_current_data, *l_tile_len + p_j2k->m_specific_param.m_decoder.m_sot_len
gth); | |
4339 if (! l_new_current_data) { | 4328 if (! l_new_current_data) { |
4340 opj_free(*l_current_data); | 4329 opj_free(*l_current_data); |
4341 /*nothing more is done as l_current_data will be set to
null, and just | 4330 /*nothing more is done as l_current_data will be set to
null, and just |
4342 afterward we enter in the error path | 4331 afterward we enter in the error path |
4343 and the actual tile_len is updated (committed) at the
end of the | 4332 and the actual tile_len is updated (committed) at the
end of the |
4344 function. */ | 4333 function. */ |
4345 } | 4334 } |
4346 *l_current_data = l_new_current_data; | 4335 *l_current_data = l_new_current_data; |
4347 } | 4336 } |
4348 | 4337 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4722 | 4711 |
4723 l_tile_size += opj_j2k_get_specific_header_sizes(p_j2k); | 4712 l_tile_size += opj_j2k_get_specific_header_sizes(p_j2k); |
4724 | 4713 |
4725 p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = l_tile_size; | 4714 p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = l_tile_size; |
4726 p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = | 4715 p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = |
4727 (OPJ_BYTE *) opj_malloc(p_j2k->m_specific_param.m_encode
r.m_encoded_tile_size); | 4716 (OPJ_BYTE *) opj_malloc(p_j2k->m_specific_param.m_encode
r.m_encoded_tile_size); |
4728 if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data == 00) { | 4717 if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data == 00) { |
4729 return OPJ_FALSE; | 4718 return OPJ_FALSE; |
4730 } | 4719 } |
4731 | 4720 |
4732 if (l_cp->m_specific_param.m_enc.m_cinema) { | 4721 if (OPJ_IS_CINEMA(l_cp->rsiz)) { |
4733 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = | 4722 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = |
4734 (OPJ_BYTE *) opj_malloc(5*p_j2k->m_specific_para
m.m_encoder.m_total_tile_parts); | 4723 (OPJ_BYTE *) opj_malloc(5*p_j2k->m_specific_para
m.m_encoder.m_total_tile_parts); |
4735 if (! p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer
) { | 4724 if (! p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer
) { |
4736 return OPJ_FALSE; | 4725 return OPJ_FALSE; |
4737 } | 4726 } |
4738 | 4727 |
4739 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = | 4728 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = |
4740 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offs
ets_buffer; | 4729 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offs
ets_buffer; |
4741 } | 4730 } |
4742 | 4731 |
(...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5858 #endif /* USE_JPWL */ | 5847 #endif /* USE_JPWL */ |
5859 } | 5848 } |
5860 } | 5849 } |
5861 | 5850 |
5862 /* ----------------------------------------------------------------------- */ | 5851 /* ----------------------------------------------------------------------- */ |
5863 /* J2K encoder interface *
/ | 5852 /* J2K encoder interface *
/ |
5864 /* ----------------------------------------------------------------------- */ | 5853 /* ----------------------------------------------------------------------- */ |
5865 | 5854 |
5866 opj_j2k_t* opj_j2k_create_compress(void) | 5855 opj_j2k_t* opj_j2k_create_compress(void) |
5867 { | 5856 { |
5868 opj_j2k_t *l_j2k = (opj_j2k_t*) opj_malloc(sizeof(opj_j2k_t)); | 5857 opj_j2k_t *l_j2k = (opj_j2k_t*) opj_calloc(1,sizeof(opj_j2k_t)); |
5869 if (!l_j2k) { | 5858 if (!l_j2k) { |
5870 return NULL; | 5859 return NULL; |
5871 } | 5860 } |
5872 | 5861 |
5873 memset(l_j2k,0,sizeof(opj_j2k_t)); | |
5874 | 5862 |
5875 l_j2k->m_is_decoder = 0; | 5863 l_j2k->m_is_decoder = 0; |
5876 l_j2k->m_cp.m_is_decoder = 0; | 5864 l_j2k->m_cp.m_is_decoder = 0; |
5877 | 5865 |
5878 l_j2k->m_specific_param.m_encoder.m_header_tile_data = (OPJ_BYTE *) opj_
malloc(OPJ_J2K_DEFAULT_HEADER_SIZE); | 5866 l_j2k->m_specific_param.m_encoder.m_header_tile_data = (OPJ_BYTE *) opj_
malloc(OPJ_J2K_DEFAULT_HEADER_SIZE); |
5879 if (! l_j2k->m_specific_param.m_encoder.m_header_tile_data) { | 5867 if (! l_j2k->m_specific_param.m_encoder.m_header_tile_data) { |
5880 opj_j2k_destroy(l_j2k); | 5868 opj_j2k_destroy(l_j2k); |
5881 return NULL; | 5869 return NULL; |
5882 } | 5870 } |
5883 | 5871 |
(...skipping 30 matching lines...) Expand all Loading... |
5914 POC[1].layno1 = 1; | 5902 POC[1].layno1 = 1; |
5915 POC[1].resno1 = (OPJ_UINT32)numres; | 5903 POC[1].resno1 = (OPJ_UINT32)numres; |
5916 POC[1].compno1 = 3; | 5904 POC[1].compno1 = 3; |
5917 POC[1].prg1 = OPJ_CPRL; | 5905 POC[1].prg1 = OPJ_CPRL; |
5918 return 2; | 5906 return 2; |
5919 } | 5907 } |
5920 | 5908 |
5921 void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *i
mage, opj_event_mgr_t *p_manager) | 5909 void opj_j2k_set_cinema_parameters(opj_cparameters_t *parameters, opj_image_t *i
mage, opj_event_mgr_t *p_manager) |
5922 { | 5910 { |
5923 /* Configure cinema parameters */ | 5911 /* Configure cinema parameters */ |
5924 OPJ_FLOAT32 max_rate = 0; | |
5925 OPJ_FLOAT32 temp_rate = 0; | |
5926 int i; | 5912 int i; |
5927 | 5913 |
5928 /* profile (Rsiz) */ | |
5929 switch (parameters->cp_cinema){ | |
5930 case OPJ_CINEMA2K_24: | |
5931 case OPJ_CINEMA2K_48: | |
5932 parameters->cp_rsiz = OPJ_CINEMA2K; | |
5933 break; | |
5934 case OPJ_CINEMA4K_24: | |
5935 parameters->cp_rsiz = OPJ_CINEMA4K; | |
5936 break; | |
5937 case OPJ_OFF: | |
5938 assert(0); | |
5939 break; | |
5940 } | |
5941 | |
5942 /* No tiling */ | 5914 /* No tiling */ |
5943 parameters->tile_size_on = OPJ_FALSE; | 5915 parameters->tile_size_on = OPJ_FALSE; |
5944 parameters->cp_tdx=1; | 5916 parameters->cp_tdx=1; |
5945 parameters->cp_tdy=1; | 5917 parameters->cp_tdy=1; |
5946 | 5918 |
5947 /* One tile part for each component */ | 5919 /* One tile part for each component */ |
5948 parameters->tp_flag = 'C'; | 5920 parameters->tp_flag = 'C'; |
5949 parameters->tp_on = 1; | 5921 parameters->tp_on = 1; |
5950 | 5922 |
5951 /* Tile and Image shall be at (0,0) */ | 5923 /* Tile and Image shall be at (0,0) */ |
(...skipping 17 matching lines...) Expand all Loading... |
5969 parameters->subsampling_dy = 1; | 5941 parameters->subsampling_dy = 1; |
5970 | 5942 |
5971 /* 9-7 transform */ | 5943 /* 9-7 transform */ |
5972 parameters->irreversible = 1; | 5944 parameters->irreversible = 1; |
5973 | 5945 |
5974 /* Number of layers */ | 5946 /* Number of layers */ |
5975 if (parameters->tcp_numlayers > 1){ | 5947 if (parameters->tcp_numlayers > 1){ |
5976 opj_event_msg(p_manager, EVT_WARNING, | 5948 opj_event_msg(p_manager, EVT_WARNING, |
5977 "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n" | 5949 "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n" |
5978 "1 single quality layer" | 5950 "1 single quality layer" |
5979 "-> Number of layers forced to 1 (rather than %d)\n", | 5951 "-> Number of layers forced to 1 (rather than %d)\n" |
5980 parameters->tcp_numlayers); | 5952 "-> Rate of the last layer (%3.1f) will be used", |
| 5953 parameters->tcp_numlayers, parameters->tcp_rates[parameters->tcp
_numlayers-1]); |
| 5954 parameters->tcp_rates[0] = parameters->tcp_rates[parameters->tcp_numlaye
rs-1]; |
5981 parameters->tcp_numlayers = 1; | 5955 parameters->tcp_numlayers = 1; |
5982 } | 5956 } |
5983 | 5957 |
5984 /* Resolution levels */ | 5958 /* Resolution levels */ |
5985 switch (parameters->cp_cinema){ | 5959 switch (parameters->rsiz){ |
5986 case OPJ_CINEMA2K_24: | 5960 case OPJ_PROFILE_CINEMA_2K: |
5987 case OPJ_CINEMA2K_48: | |
5988 if(parameters->numresolution > 6){ | 5961 if(parameters->numresolution > 6){ |
5989 opj_event_msg(p_manager, EVT_WARNING, | 5962 opj_event_msg(p_manager, EVT_WARNING, |
5990 "JPEG 2000 Profile-3 (2k dc profile) requires:\n" | 5963 "JPEG 2000 Profile-3 (2k dc profile) requires:\n" |
5991 "Number of decomposition levels <= 5\n" | 5964 "Number of decomposition levels <= 5\n" |
5992 "-> Number of decomposition levels forced to 5 (rather than
%d)\n", | 5965 "-> Number of decomposition levels forced to 5 (rather than
%d)\n", |
5993 parameters->numresolution+1); | 5966 parameters->numresolution+1); |
5994 parameters->numresolution = 6; | 5967 parameters->numresolution = 6; |
5995 } | 5968 } |
5996 break; | 5969 break; |
5997 case OPJ_CINEMA4K_24: | 5970 case OPJ_PROFILE_CINEMA_4K: |
5998 if(parameters->numresolution < 2){ | 5971 if(parameters->numresolution < 2){ |
5999 opj_event_msg(p_manager, EVT_WARNING, | 5972 opj_event_msg(p_manager, EVT_WARNING, |
6000 "JPEG 2000 Profile-4 (4k dc profile) requires:\n" | 5973 "JPEG 2000 Profile-4 (4k dc profile) requires:\n" |
6001 "Number of decomposition levels >= 1 && <= 6\n" | 5974 "Number of decomposition levels >= 1 && <= 6\n" |
6002 "-> Number of decomposition levels forced to 1 (rather than
%d)\n", | 5975 "-> Number of decomposition levels forced to 1 (rather than
%d)\n", |
6003 parameters->numresolution+1); | 5976 parameters->numresolution+1); |
6004 parameters->numresolution = 1; | 5977 parameters->numresolution = 1; |
6005 }else if(parameters->numresolution > 7){ | 5978 }else if(parameters->numresolution > 7){ |
6006 opj_event_msg(p_manager, EVT_WARNING, | 5979 opj_event_msg(p_manager, EVT_WARNING, |
6007 "JPEG 2000 Profile-4 (4k dc profile) requires:\n" | 5980 "JPEG 2000 Profile-4 (4k dc profile) requires:\n" |
(...skipping 12 matching lines...) Expand all Loading... |
6020 parameters->res_spec = parameters->numresolution-1; | 5993 parameters->res_spec = parameters->numresolution-1; |
6021 for (i = 0; i<parameters->res_spec; i++) { | 5994 for (i = 0; i<parameters->res_spec; i++) { |
6022 parameters->prcw_init[i] = 256; | 5995 parameters->prcw_init[i] = 256; |
6023 parameters->prch_init[i] = 256; | 5996 parameters->prch_init[i] = 256; |
6024 } | 5997 } |
6025 | 5998 |
6026 /* The progression order shall be CPRL */ | 5999 /* The progression order shall be CPRL */ |
6027 parameters->prog_order = OPJ_CPRL; | 6000 parameters->prog_order = OPJ_CPRL; |
6028 | 6001 |
6029 /* Progression order changes for 4K, disallowed for 2K */ | 6002 /* Progression order changes for 4K, disallowed for 2K */ |
6030 if (parameters->cp_cinema == OPJ_CINEMA4K_24) { | 6003 if (parameters->rsiz == OPJ_PROFILE_CINEMA_4K) { |
6031 parameters->numpocs = (OPJ_UINT32)opj_j2k_initialise_4K_poc(parameters->
POC,parameters->numresolution); | 6004 parameters->numpocs = (OPJ_UINT32)opj_j2k_initialise_4K_poc(parameters->
POC,parameters->numresolution); |
6032 } else { | 6005 } else { |
6033 parameters->numpocs = 0; | 6006 parameters->numpocs = 0; |
6034 } | 6007 } |
6035 | 6008 |
6036 /* Limited bit-rate */ | 6009 /* Limited bit-rate */ |
6037 parameters->cp_disto_alloc = 1; | 6010 parameters->cp_disto_alloc = 1; |
6038 switch (parameters->cp_cinema){ | 6011 if (parameters->max_cs_size <= 0) { |
6039 case OPJ_CINEMA2K_24: | 6012 /* No rate has been introduced, 24 fps is assumed */ |
6040 case OPJ_CINEMA4K_24: | 6013 parameters->max_cs_size = OPJ_CINEMA_24_CS; |
6041 max_rate = (OPJ_FLOAT32) (image->numcomps * image->comps[0].w * image->c
omps[0].h * image->comps[0].prec)/ | 6014 opj_event_msg(p_manager, EVT_WARNING, |
6042 (OPJ_FLOAT32)(CINEMA_24_CS * 8 * image->comps[0].dx * image->com
ps[0].dy); | 6015 "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n" |
6043 if (parameters->tcp_rates[0] == 0){ | 6016 "Maximum 1302083 compressed bytes @ 24fps\n" |
6044 parameters->tcp_rates[0] = max_rate; | 6017 "As no rate has been given, this limit will be used.\n"); |
6045 }else{ | 6018 } else if (parameters->max_cs_size > OPJ_CINEMA_24_CS) { |
6046 temp_rate =(OPJ_FLOAT32)(image->numcomps * image->comps[0].w * image
->comps[0].h * image->comps[0].prec)/ | 6019 opj_event_msg(p_manager, EVT_WARNING, |
6047 (parameters->tcp_rates[0] * 8 * (OPJ_FLOAT32)image->comps[0]
.dx * (OPJ_FLOAT32)image->comps[0].dy); | 6020 "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n" |
6048 if (temp_rate > CINEMA_24_CS ){ | 6021 "Maximum 1302083 compressed bytes @ 24fps\n" |
6049 opj_event_msg(p_manager, EVT_WARNING, | 6022 "-> Specified rate exceeds this limit. Rate will be forced
to 1302083 bytes.\n"); |
6050 "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\
n" | 6023 parameters->max_cs_size = OPJ_CINEMA_24_CS; |
6051 "Maximum 1302083 compressed bytes @ 24fps\n" | |
6052 "-> Specified rate (%3.1f) exceeds this limit. Rate will
be forced to %3.1f.\n", | |
6053 parameters->tcp_rates[0], max_rate); | |
6054 parameters->tcp_rates[0]= max_rate; | |
6055 }else{ | |
6056 opj_event_msg(p_manager, EVT_WARNING, | |
6057 "JPEG 2000 Profile-3 and 4 (2k/4k dc profile):\n" | |
6058 "INFO : Specified rate (%3.1f) is below the 2k/4k limit
@ 24fps.\n", | |
6059 parameters->tcp_rates[0]); | |
6060 } | |
6061 } | |
6062 parameters->max_comp_size = COMP_24_CS; | |
6063 break; | |
6064 case OPJ_CINEMA2K_48: | |
6065 max_rate = ((float) (image->numcomps * image->comps[0].w * image->comps[
0].h * image->comps[0].prec))/ | |
6066 (float)(CINEMA_48_CS * 8 * image->comps[0].dx * image->comps[0].
dy); | |
6067 if (parameters->tcp_rates[0] == 0){ | |
6068 parameters->tcp_rates[0] = max_rate; | |
6069 }else{ | |
6070 temp_rate =((float) (image->numcomps * image->comps[0].w * image->co
mps[0].h * image->comps[0].prec))/ | |
6071 (parameters->tcp_rates[0] * 8 * (float)image->comps[0].dx *
(float)image->comps[0].dy); | |
6072 if (temp_rate > CINEMA_48_CS ){ | |
6073 opj_event_msg(p_manager, EVT_WARNING, | |
6074 "JPEG 2000 Profile-3 (2k dc profile) requires:\n" | |
6075 "Maximum 651041 compressed bytes @ 48fps\n" | |
6076 "-> Specified rate (%3.1f) exceeds this limit. Rate will
be forced to %3.1f.\n", | |
6077 parameters->tcp_rates[0], max_rate); | |
6078 parameters->tcp_rates[0]= max_rate; | |
6079 }else{ | |
6080 opj_event_msg(p_manager, EVT_WARNING, | |
6081 "JPEG 2000 Profile-3 (2k dc profile):\n" | |
6082 "INFO : Specified rate (%3.1f) is below the 2k limit @ 4
8 fps.\n", | |
6083 parameters->tcp_rates[0]); | |
6084 } | |
6085 } | |
6086 parameters->max_comp_size = COMP_48_CS; | |
6087 break; | |
6088 default: | |
6089 break; | |
6090 } | 6024 } |
| 6025 |
| 6026 if (parameters->max_comp_size <= 0) { |
| 6027 /* No rate has been introduced, 24 fps is assumed */ |
| 6028 parameters->max_comp_size = OPJ_CINEMA_24_COMP; |
| 6029 opj_event_msg(p_manager, EVT_WARNING, |
| 6030 "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n" |
| 6031 "Maximum 1041666 compressed bytes @ 24fps\n" |
| 6032 "As no rate has been given, this limit will be used.\n"); |
| 6033 } else if (parameters->max_comp_size > OPJ_CINEMA_24_COMP) { |
| 6034 opj_event_msg(p_manager, EVT_WARNING, |
| 6035 "JPEG 2000 Profile-3 and 4 (2k/4k dc profile) requires:\n" |
| 6036 "Maximum 1041666 compressed bytes @ 24fps\n" |
| 6037 "-> Specified rate exceeds this limit. Rate will be forced
to 1041666 bytes.\n"); |
| 6038 parameters->max_comp_size = OPJ_CINEMA_24_COMP; |
| 6039 } |
| 6040 |
| 6041 parameters->tcp_rates[0] = (OPJ_FLOAT32) (image->numcomps * image->comps[0].
w * image->comps[0].h * image->comps[0].prec)/ |
| 6042 (OPJ_FLOAT32)(((OPJ_UINT32)parameters->max_cs_size) * 8 * image->com
ps[0].dx * image->comps[0].dy); |
| 6043 |
6091 } | 6044 } |
6092 | 6045 |
6093 OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_CINEMA_MODE cinema_
mode, opj_event_mgr_t *p_manager) | 6046 OPJ_BOOL opj_j2k_is_cinema_compliant(opj_image_t *image, OPJ_UINT16 rsiz, opj_ev
ent_mgr_t *p_manager) |
6094 { | 6047 { |
6095 OPJ_UINT32 i; | 6048 OPJ_UINT32 i; |
6096 | 6049 |
6097 /* Number of components */ | 6050 /* Number of components */ |
6098 if (image->numcomps != 3){ | 6051 if (image->numcomps != 3){ |
6099 opj_event_msg(p_manager, EVT_WARNING, | 6052 opj_event_msg(p_manager, EVT_WARNING, |
6100 "JPEG 2000 Profile-3 (2k dc profile) requires:\n" | 6053 "JPEG 2000 Profile-3 (2k dc profile) requires:\n" |
6101 "3 components" | 6054 "3 components" |
6102 "-> Number of components of input image (%d) is not compliant\n" | 6055 "-> Number of components of input image (%d) is not compliant\n" |
6103 "-> Non-profile-3 codestream will be generated\n", | 6056 "-> Non-profile-3 codestream will be generated\n", |
(...skipping 11 matching lines...) Expand all Loading... |
6115 "JPEG 2000 Profile-3 (2k dc profile) requires:\n" | 6068 "JPEG 2000 Profile-3 (2k dc profile) requires:\n" |
6116 "Precision of each component shall be 12 bits unsigned" | 6069 "Precision of each component shall be 12 bits unsigned" |
6117 "-> At least component %d of input image (%d bits, %s) is no
t compliant\n" | 6070 "-> At least component %d of input image (%d bits, %s) is no
t compliant\n" |
6118 "-> Non-profile-3 codestream will be generated\n", | 6071 "-> Non-profile-3 codestream will be generated\n", |
6119 i,image->comps[i].bpp, tmp_str); | 6072 i,image->comps[i].bpp, tmp_str); |
6120 return OPJ_FALSE; | 6073 return OPJ_FALSE; |
6121 } | 6074 } |
6122 } | 6075 } |
6123 | 6076 |
6124 /* Image size */ | 6077 /* Image size */ |
6125 switch (cinema_mode){ | 6078 switch (rsiz){ |
6126 case OPJ_CINEMA2K_24: | 6079 case OPJ_PROFILE_CINEMA_2K: |
6127 case OPJ_CINEMA2K_48: | |
6128 if (((image->comps[0].w > 2048) | (image->comps[0].h > 1080))){ | 6080 if (((image->comps[0].w > 2048) | (image->comps[0].h > 1080))){ |
6129 opj_event_msg(p_manager, EVT_WARNING, | 6081 opj_event_msg(p_manager, EVT_WARNING, |
6130 "JPEG 2000 Profile-3 (2k dc profile) requires:\n" | 6082 "JPEG 2000 Profile-3 (2k dc profile) requires:\n" |
6131 "width <= 2048 and height <= 1080\n" | 6083 "width <= 2048 and height <= 1080\n" |
6132 "-> Input image size %d x %d is not compliant\n" | 6084 "-> Input image size %d x %d is not compliant\n" |
6133 "-> Non-profile-3 codestream will be generated\n", | 6085 "-> Non-profile-3 codestream will be generated\n", |
6134 image->comps[0].w,image->comps[0].h); | 6086 image->comps[0].w,image->comps[0].h); |
6135 return OPJ_FALSE; | 6087 return OPJ_FALSE; |
6136 } | 6088 } |
6137 break; | 6089 break; |
6138 case OPJ_CINEMA4K_24: | 6090 case OPJ_PROFILE_CINEMA_4K: |
6139 if (((image->comps[0].w > 4096) | (image->comps[0].h > 2160))){ | 6091 if (((image->comps[0].w > 4096) | (image->comps[0].h > 2160))){ |
6140 opj_event_msg(p_manager, EVT_WARNING, | 6092 opj_event_msg(p_manager, EVT_WARNING, |
6141 "JPEG 2000 Profile-4 (4k dc profile) requires:\n" | 6093 "JPEG 2000 Profile-4 (4k dc profile) requires:\n" |
6142 "width <= 4096 and height <= 2160\n" | 6094 "width <= 4096 and height <= 2160\n" |
6143 "-> Image size %d x %d is not compliant\n" | 6095 "-> Image size %d x %d is not compliant\n" |
6144 "-> Non-profile-4 codestream will be generated\n", | 6096 "-> Non-profile-4 codestream will be generated\n", |
6145 image->comps[0].w,image->comps[0].h); | 6097 image->comps[0].w,image->comps[0].h); |
6146 return OPJ_FALSE; | 6098 return OPJ_FALSE; |
6147 } | 6099 } |
6148 break; | 6100 break; |
6149 default : | 6101 default : |
6150 break; | 6102 break; |
6151 } | 6103 } |
6152 | 6104 |
6153 return OPJ_TRUE; | 6105 return OPJ_TRUE; |
6154 } | 6106 } |
6155 | 6107 |
6156 void opj_j2k_setup_encoder( opj_j2k_t *p_j2k, | 6108 OPJ_BOOL opj_j2k_setup_encoder( opj_j2k_t *p_j2k, |
6157 opj_cparameters_t *parameter
s, | 6109 opj_cparameters_t *parameter
s, |
6158 opj_image_t *image, | 6110 opj_image_t *image, |
6159 opj_event_mgr_t * p_manager) | 6111 opj_event_mgr_t * p_manager) |
6160 { | 6112 { |
6161 OPJ_UINT32 i, j, tileno, numpocs_tile; | 6113 OPJ_UINT32 i, j, tileno, numpocs_tile; |
6162 opj_cp_t *cp = 00; | 6114 opj_cp_t *cp = 00; |
6163 | 6115 |
6164 if(!p_j2k || !parameters || ! image) { | 6116 if(!p_j2k || !parameters || ! image) { |
6165 return; | 6117 return OPJ_FALSE; |
6166 } | 6118 } |
6167 | 6119 |
6168 /* keep a link to cp so that we can destroy it later in j2k_destroy_comp
ress */ | 6120 /* keep a link to cp so that we can destroy it later in j2k_destroy_comp
ress */ |
6169 cp = &(p_j2k->m_cp); | 6121 cp = &(p_j2k->m_cp); |
6170 | 6122 |
6171 /* set default values for cp */ | 6123 /* set default values for cp */ |
6172 cp->tw = 1; | 6124 cp->tw = 1; |
6173 cp->th = 1; | 6125 cp->th = 1; |
6174 | 6126 |
| 6127 /* FIXME ADE: to be removed once deprecated cp_cinema and cp_rsiz have b
een removed */ |
| 6128 if (parameters->rsiz == OPJ_PROFILE_NONE) { /* consider deprecated field
s only if RSIZ has not been set */ |
| 6129 OPJ_BOOL deprecated_used = OPJ_FALSE; |
| 6130 switch (parameters->cp_cinema){ |
| 6131 case OPJ_CINEMA2K_24: |
| 6132 parameters->rsiz = OPJ_PROFILE_CINEMA_2K; |
| 6133 parameters->max_cs_size = OPJ_CINEMA_24_CS; |
| 6134 parameters->max_comp_size = OPJ_CINEMA_24_COMP; |
| 6135 deprecated_used = OPJ_TRUE; |
| 6136 break; |
| 6137 case OPJ_CINEMA2K_48: |
| 6138 parameters->rsiz = OPJ_PROFILE_CINEMA_2K; |
| 6139 parameters->max_cs_size = OPJ_CINEMA_48_CS; |
| 6140 parameters->max_comp_size = OPJ_CINEMA_48_COMP; |
| 6141 deprecated_used = OPJ_TRUE; |
| 6142 break; |
| 6143 case OPJ_CINEMA4K_24: |
| 6144 parameters->rsiz = OPJ_PROFILE_CINEMA_4K; |
| 6145 parameters->max_cs_size = OPJ_CINEMA_24_CS; |
| 6146 parameters->max_comp_size = OPJ_CINEMA_24_COMP; |
| 6147 deprecated_used = OPJ_TRUE; |
| 6148 break; |
| 6149 case OPJ_OFF: |
| 6150 default: |
| 6151 break; |
| 6152 } |
| 6153 switch (parameters->cp_rsiz){ |
| 6154 case OPJ_CINEMA2K: |
| 6155 parameters->rsiz = OPJ_PROFILE_CINEMA_2K; |
| 6156 deprecated_used = OPJ_TRUE; |
| 6157 break; |
| 6158 case OPJ_CINEMA4K: |
| 6159 parameters->rsiz = OPJ_PROFILE_CINEMA_4K; |
| 6160 deprecated_used = OPJ_TRUE; |
| 6161 break; |
| 6162 case OPJ_MCT: |
| 6163 parameters->rsiz = OPJ_PROFILE_PART2 | OPJ_EXTENSION_MCT; |
| 6164 deprecated_used = OPJ_TRUE; |
| 6165 case OPJ_STD_RSIZ: |
| 6166 default: |
| 6167 break; |
| 6168 } |
| 6169 if (deprecated_used) { |
| 6170 opj_event_msg(p_manager, EVT_WARNING, |
| 6171 "Deprecated fields cp_cinema or cp_rsiz are used\n" |
| 6172 "Please consider using only the rsiz field\n" |
| 6173 "See openjpeg.h documentation for more details\n"); |
| 6174 } |
| 6175 } |
| 6176 |
| 6177 /* see if max_codestream_size does limit input rate */ |
| 6178 if (parameters->max_cs_size <= 0) { |
| 6179 if (parameters->tcp_rates[parameters->tcp_numlayers-1] > 0) { |
| 6180 OPJ_FLOAT32 temp_size; |
| 6181 temp_size =(OPJ_FLOAT32)(image->numcomps * image->comps[0].w * i
mage->comps[0].h * image->comps[0].prec)/ |
| 6182 (parameters->tcp_rates[parameters->tcp_numlayers-1] * 8
* (OPJ_FLOAT32)image->comps[0].dx * (OPJ_FLOAT32)image->comps[0].dy); |
| 6183 parameters->max_cs_size = (int) floor(temp_size); |
| 6184 } else { |
| 6185 parameters->max_cs_size = 0; |
| 6186 } |
| 6187 } else { |
| 6188 OPJ_FLOAT32 temp_rate; |
| 6189 OPJ_BOOL cap = OPJ_FALSE; |
| 6190 temp_rate = (OPJ_FLOAT32) (image->numcomps * image->comps[0].w * ima
ge->comps[0].h * image->comps[0].prec)/ |
| 6191 (OPJ_FLOAT32)(((OPJ_UINT32)parameters->max_cs_size) * 8 * im
age->comps[0].dx * image->comps[0].dy); |
| 6192 for (i = 0; i < (OPJ_UINT32) parameters->tcp_numlayers; i++) { |
| 6193 if (parameters->tcp_rates[i] < temp_rate) { |
| 6194 parameters->tcp_rates[i] = temp_rate; |
| 6195 cap = OPJ_TRUE; |
| 6196 } |
| 6197 } |
| 6198 if (cap) { |
| 6199 opj_event_msg(p_manager, EVT_WARNING, |
| 6200 "The desired maximum codestream size has limited\n" |
| 6201 "at least one of the desired quality layers\n"); |
| 6202 } |
| 6203 } |
| 6204 |
| 6205 /* Manage profiles and applications and set RSIZ */ |
6175 /* set cinema parameters if required */ | 6206 /* set cinema parameters if required */ |
6176 if (parameters->cp_cinema){ | 6207 if (OPJ_IS_CINEMA(parameters->rsiz)){ |
6177 opj_j2k_set_cinema_parameters(parameters,image,p_manager); | 6208 if ((parameters->rsiz == OPJ_PROFILE_CINEMA_S2K) |
6178 if (!opj_j2k_is_cinema_compliant(image,parameters->cp_cinema,p_manag
er)) { | 6209 || (parameters->rsiz == OPJ_PROFILE_CINEMA_S4K)){ |
6179 parameters->cp_rsiz = OPJ_STD_RSIZ; | 6210 opj_event_msg(p_manager, EVT_WARNING, |
| 6211 "JPEG 2000 Scalable Digital Cinema profiles not yet supp
orted\n"); |
| 6212 parameters->rsiz = OPJ_PROFILE_NONE; |
| 6213 } else { |
| 6214 opj_j2k_set_cinema_parameters(parameters,image,p_manager); |
| 6215 if (!opj_j2k_is_cinema_compliant(image,parameters->rsiz,p_manage
r)) { |
| 6216 parameters->rsiz = OPJ_PROFILE_NONE; |
| 6217 } |
| 6218 } |
| 6219 } else if (OPJ_IS_STORAGE(parameters->rsiz)) { |
| 6220 opj_event_msg(p_manager, EVT_WARNING, |
| 6221 "JPEG 2000 Long Term Storage profile not yet supported\n"); |
| 6222 parameters->rsiz = OPJ_PROFILE_NONE; |
| 6223 } else if (OPJ_IS_BROADCAST(parameters->rsiz)) { |
| 6224 opj_event_msg(p_manager, EVT_WARNING, |
| 6225 "JPEG 2000 Broadcast profiles not yet supported\n"); |
| 6226 parameters->rsiz = OPJ_PROFILE_NONE; |
| 6227 } else if (OPJ_IS_IMF(parameters->rsiz)) { |
| 6228 opj_event_msg(p_manager, EVT_WARNING, |
| 6229 "JPEG 2000 IMF profiles not yet supported\n"); |
| 6230 parameters->rsiz = OPJ_PROFILE_NONE; |
| 6231 } else if (OPJ_IS_PART2(parameters->rsiz)) { |
| 6232 if (parameters->rsiz == ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_NONE))
) { |
| 6233 opj_event_msg(p_manager, EVT_WARNING, |
| 6234 "JPEG 2000 Part-2 profile defined\n" |
| 6235 "but no Part-2 extension enabled.\n" |
| 6236 "Profile set to NONE.\n"); |
| 6237 parameters->rsiz = OPJ_PROFILE_NONE; |
| 6238 } else if (parameters->rsiz != ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION
_MCT))) { |
| 6239 opj_event_msg(p_manager, EVT_WARNING, |
| 6240 "Unsupported Part-2 extension enabled\n" |
| 6241 "Profile set to NONE.\n"); |
| 6242 parameters->rsiz = OPJ_PROFILE_NONE; |
6180 } | 6243 } |
6181 } | 6244 } |
6182 | 6245 |
6183 /* | 6246 /* |
6184 copy user encoding parameters | 6247 copy user encoding parameters |
6185 */ | 6248 */ |
6186 cp->m_specific_param.m_enc.m_cinema = parameters->cp_cinema; | |
6187 cp->m_specific_param.m_enc.m_max_comp_size = (OPJ_UINT32)parameters->max
_comp_size; | 6249 cp->m_specific_param.m_enc.m_max_comp_size = (OPJ_UINT32)parameters->max
_comp_size; |
6188 cp->rsiz = parameters->cp_rsiz; | 6250 cp->rsiz = parameters->rsiz; |
6189 cp->m_specific_param.m_enc.m_disto_alloc = (OPJ_UINT32)parameters->cp_di
sto_alloc & 1u; | 6251 cp->m_specific_param.m_enc.m_disto_alloc = (OPJ_UINT32)parameters->cp_di
sto_alloc & 1u; |
6190 cp->m_specific_param.m_enc.m_fixed_alloc = (OPJ_UINT32)parameters->cp_fi
xed_alloc & 1u; | 6252 cp->m_specific_param.m_enc.m_fixed_alloc = (OPJ_UINT32)parameters->cp_fi
xed_alloc & 1u; |
6191 cp->m_specific_param.m_enc.m_fixed_quality = (OPJ_UINT32)parameters->cp_
fixed_quality & 1u; | 6253 cp->m_specific_param.m_enc.m_fixed_quality = (OPJ_UINT32)parameters->cp_
fixed_quality & 1u; |
6192 | 6254 |
6193 /* mod fixed_quality */ | 6255 /* mod fixed_quality */ |
6194 if (parameters->cp_fixed_alloc && parameters->cp_matrice) { | 6256 if (parameters->cp_fixed_alloc && parameters->cp_matrice) { |
6195 size_t array_size = (size_t)parameters->tcp_numlayers * (size_t)
parameters->numresolution * 3 * sizeof(OPJ_INT32); | 6257 size_t array_size = (size_t)parameters->tcp_numlayers * (size_t)
parameters->numresolution * 3 * sizeof(OPJ_INT32); |
6196 cp->m_specific_param.m_enc.m_matrice = (OPJ_INT32 *) opj_malloc(
array_size); | 6258 cp->m_specific_param.m_enc.m_matrice = (OPJ_INT32 *) opj_malloc(
array_size); |
| 6259 if (!cp->m_speci
fic_param.m_enc.m_matrice) { |
| 6260 opj_even
t_msg(p_manager, EVT_ERROR, "Not enough memory to allocate copy of user encoding
parameters matrix \n"); |
| 6261 return O
PJ_FALSE; |
| 6262 } |
6197 memcpy(cp->m_specific_param.m_enc.m_matrice, parameters->cp_matr
ice, array_size); | 6263 memcpy(cp->m_specific_param.m_enc.m_matrice, parameters->cp_matr
ice, array_size); |
6198 } | 6264 } |
6199 | 6265 |
6200 /* tiles */ | 6266 /* tiles */ |
6201 cp->tdx = (OPJ_UINT32)parameters->cp_tdx; | 6267 cp->tdx = (OPJ_UINT32)parameters->cp_tdx; |
6202 cp->tdy = (OPJ_UINT32)parameters->cp_tdy; | 6268 cp->tdy = (OPJ_UINT32)parameters->cp_tdy; |
6203 | 6269 |
6204 /* tile offset */ | 6270 /* tile offset */ |
6205 cp->tx0 = (OPJ_UINT32)parameters->cp_tx0; | 6271 cp->tx0 = (OPJ_UINT32)parameters->cp_tx0; |
6206 cp->ty0 = (OPJ_UINT32)parameters->cp_ty0; | 6272 cp->ty0 = (OPJ_UINT32)parameters->cp_ty0; |
6207 | 6273 |
6208 /* comment string */ | 6274 /* comment string */ |
6209 if(parameters->cp_comment) { | 6275 if(parameters->cp_comment) { |
6210 cp->comment = (char*)opj_malloc(strlen(parameters->cp_comment) +
1); | 6276 cp->comment = (char*)opj_malloc(strlen(parameters->cp_comment) +
1U); |
6211 if(cp->comment) { | 6277 » » » » » » » » if(!cp->comment)
{ |
6212 strcpy(cp->comment, parameters->cp_comment); | 6278 » » » » » » » » opj_even
t_msg(p_manager, EVT_ERROR, "Not enough memory to allocate copy of comment strin
g\n"); |
6213 } | 6279 » » » » » » » » return O
PJ_FALSE; |
6214 } | 6280 » » » » » » » » } |
| 6281 strcpy(cp->comment, parameters->cp_comment); |
| 6282 } else { |
| 6283 /* Create default comment for codestream */ |
| 6284 const char comment[] = "Created by OpenJPEG version "; |
| 6285 const size_t clen = strlen(comment); |
| 6286 const char *version = opj_version(); |
| 6287 |
| 6288 /* UniPG>> */ |
| 6289 #ifdef USE_JPWL |
| 6290 cp->comment = (char*)opj_malloc(clen+strlen(version)+11); |
| 6291 » » » » » » » » if(!cp->comment)
{ |
| 6292 » » » » » » » » opj_even
t_msg(p_manager, EVT_ERROR, "Not enough memory to allocate comment string\n"); |
| 6293 » » » » » » » » return O
PJ_FALSE; |
| 6294 » » » » » » » » } |
| 6295 sprintf(cp->comment,"%s%s with JPWL", comment, version); |
| 6296 #else |
| 6297 cp->comment = (char*)opj_malloc(clen+strlen(version)+1); |
| 6298 » » » » » » » » if(!cp->comment)
{ |
| 6299 » » » » » » » » opj_even
t_msg(p_manager, EVT_ERROR, "Not enough memory to allocate comment string\n"); |
| 6300 » » » » » » » » return O
PJ_FALSE; |
| 6301 » » » » » » » » } |
| 6302 sprintf(cp->comment,"%s%s", comment, version); |
| 6303 #endif |
| 6304 /* <<UniPG */ |
| 6305 » » » » } |
6215 | 6306 |
6216 /* | 6307 /* |
6217 calculate other encoding parameters | 6308 calculate other encoding parameters |
6218 */ | 6309 */ |
6219 | 6310 |
6220 if (parameters->tile_size_on) { | 6311 if (parameters->tile_size_on) { |
6221 cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->x1 - cp-
>tx0), (OPJ_INT32)cp->tdx); | 6312 cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->x1 - cp-
>tx0), (OPJ_INT32)cp->tdx); |
6222 cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp-
>ty0), (OPJ_INT32)cp->tdy); | 6313 cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp-
>ty0), (OPJ_INT32)cp->tdy); |
6223 } else { | 6314 } else { |
6224 cp->tdx = image->x1 - cp->tx0; | 6315 cp->tdx = image->x1 - cp->tx0; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6282 cp->red_on = OPJ_FALSE; | 6373 cp->red_on = OPJ_FALSE; |
6283 | 6374 |
6284 } else { | 6375 } else { |
6285 cp->epc_on = OPJ_FALSE; | 6376 cp->epc_on = OPJ_FALSE; |
6286 } | 6377 } |
6287 #endif /* USE_JPWL */ | 6378 #endif /* USE_JPWL */ |
6288 | 6379 |
6289 /* initialize the mutiple tiles */ | 6380 /* initialize the mutiple tiles */ |
6290 /* ---------------------------- */ | 6381 /* ---------------------------- */ |
6291 cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t)); | 6382 cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t)); |
| 6383 if (!cp->tcps) { |
| 6384 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to alloca
te tile coding parameters\n"); |
| 6385 return OPJ_FALSE; |
| 6386 } |
6292 if (parameters->numpocs) { | 6387 if (parameters->numpocs) { |
6293 /* initialisation of POC */ | 6388 /* initialisation of POC */ |
6294 opj_j2k_check_poc_val(parameters->POC,parameters->numpocs, (OPJ_
UINT32)parameters->numresolution, image->numcomps, (OPJ_UINT32)parameters->tcp_n
umlayers, p_manager); | 6389 opj_j2k_check_poc_val(parameters->POC,parameters->numpocs, (OPJ_
UINT32)parameters->numresolution, image->numcomps, (OPJ_UINT32)parameters->tcp_n
umlayers, p_manager); |
6295 /* TODO MSD use the return value*/ | 6390 /* TODO MSD use the return value*/ |
6296 } | 6391 } |
6297 | 6392 |
6298 for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { | 6393 for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { |
6299 opj_tcp_t *tcp = &cp->tcps[tileno]; | 6394 opj_tcp_t *tcp = &cp->tcps[tileno]; |
6300 tcp->numlayers = (OPJ_UINT32)parameters->tcp_numlayers; | 6395 tcp->numlayers = (OPJ_UINT32)parameters->tcp_numlayers; |
6301 | 6396 |
6302 for (j = 0; j < tcp->numlayers; j++) { | 6397 for (j = 0; j < tcp->numlayers; j++) { |
6303 if(cp->m_specific_param.m_enc.m_cinema){ | 6398 if(OPJ_IS_CINEMA(cp->rsiz)){ |
6304 if (cp->m_specific_param.m_enc.m_fixed_quality)
{ | 6399 if (cp->m_specific_param.m_enc.m_fixed_quality)
{ |
6305 tcp->distoratio[j] = parameters->tcp_dis
toratio[j]; | 6400 tcp->distoratio[j] = parameters->tcp_dis
toratio[j]; |
6306 } | 6401 } |
6307 tcp->rates[j] = parameters->tcp_rates[j]; | 6402 tcp->rates[j] = parameters->tcp_rates[j]; |
6308 }else{ | 6403 }else{ |
6309 if (cp->m_specific_param.m_enc.m_fixed_quality)
{ /* add fixed_quality */ | 6404 if (cp->m_specific_param.m_enc.m_fixed_quality)
{ /* add fixed_quality */ |
6310 tcp->distoratio[j] = parameters->tcp_dis
toratio[j]; | 6405 tcp->distoratio[j] = parameters->tcp_dis
toratio[j]; |
6311 } else { | 6406 } else { |
6312 tcp->rates[j] = parameters->tcp_rates[j]
; | 6407 tcp->rates[j] = parameters->tcp_rates[j]
; |
6313 } | 6408 } |
(...skipping 25 matching lines...) Expand all Loading... |
6339 numpocs_tile++; | 6434 numpocs_tile++; |
6340 } | 6435 } |
6341 } | 6436 } |
6342 | 6437 |
6343 tcp->numpocs = numpocs_tile -1 ; | 6438 tcp->numpocs = numpocs_tile -1 ; |
6344 }else{ | 6439 }else{ |
6345 tcp->numpocs = 0; | 6440 tcp->numpocs = 0; |
6346 } | 6441 } |
6347 | 6442 |
6348 tcp->tccps = (opj_tccp_t*) opj_calloc(image->numcomps, sizeof(op
j_tccp_t)); | 6443 tcp->tccps = (opj_tccp_t*) opj_calloc(image->numcomps, sizeof(op
j_tccp_t)); |
6349 | 6444 if (!tcp->tccps) { |
| 6445 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory t
o allocate tile component coding parameters\n"); |
| 6446 return OPJ_FALSE; |
| 6447 } |
6350 if (parameters->mct_data) { | 6448 if (parameters->mct_data) { |
6351 | 6449 |
6352 OPJ_UINT32 lMctSize = image->numcomps * image->numcomps * (O
PJ_UINT32)sizeof(OPJ_FLOAT32); | 6450 OPJ_UINT32 lMctSize = image->numcomps * image->numcomps * (O
PJ_UINT32)sizeof(OPJ_FLOAT32); |
6353 OPJ_FLOAT32 * lTmpBuf = (OPJ_FLOAT32*)opj_malloc(lMctSize); | 6451 OPJ_FLOAT32 * lTmpBuf = (OPJ_FLOAT32*)opj_malloc(lMctSize); |
6354 OPJ_INT32 * l_dc_shift = (OPJ_INT32 *) ((OPJ_BYTE *) paramet
ers->mct_data + lMctSize); | 6452 OPJ_INT32 * l_dc_shift = (OPJ_INT32 *) ((OPJ_BYTE *) paramet
ers->mct_data + lMctSize); |
6355 | 6453 |
| 6454
if (!lTmpBuf) { |
| 6455 opj_event_msg(p_manager, EVT_ERROR, "Not enough memo
ry to allocate temp buffer\n"); |
| 6456 return OPJ_FALSE; |
| 6457 } |
| 6458 |
6356 tcp->mct = 2; | 6459 tcp->mct = 2; |
6357 tcp->m_mct_coding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize
); | 6460 tcp->m_mct_coding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize
); |
| 6461
if (! tcp->m_mct_coding_matrix) { |
| 6462 opj_free(lTmpBuf); |
| 6463
lTmpBuf = NULL; |
| 6464 opj_event_msg(p_manager, EVT_ERROR, "Not enough memo
ry to allocate encoder MCT coding matrix \n"); |
| 6465 return OPJ_FALSE; |
| 6466 } |
6358 memcpy(tcp->m_mct_coding_matrix,parameters->mct_data,lMctSiz
e); | 6467 memcpy(tcp->m_mct_coding_matrix,parameters->mct_data,lMctSiz
e); |
6359 memcpy(lTmpBuf,parameters->mct_data,lMctSize); | 6468 memcpy(lTmpBuf,parameters->mct_data,lMctSize); |
6360 | 6469 |
6361 tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSi
ze); | 6470 tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSi
ze); |
6362 assert(opj_matrix_inversion_f(lTmpBuf,(tcp->m_mct_decoding_m
atrix),image->numcomps)); | 6471 » » » » » » » » » »
if (! tcp->m_mct_decoding_matrix) { |
| 6472 » » » » » » » » » »
» » » » opj_free(lTmpBuf); |
| 6473 » » » » » » » » » »
» » » » lTmpBuf = NULL; |
| 6474 opj_event_msg(p_manager, EVT_ERROR, "Not enough memo
ry to allocate encoder MCT decoding matrix \n"); |
| 6475 return OPJ_FALSE; |
| 6476 } |
| 6477 if(opj_matrix_inversion_f(lTmpBuf,(tcp->m_mct_decoding_matri
x),image->numcomps) == OPJ_FALSE) { |
| 6478 opj_free(lTmpBuf); |
| 6479 » » » » » » » » » »
» » » » lTmpBuf = NULL; |
| 6480 opj_event_msg(p_manager, EVT_ERROR, "Failed to inver
se encoder MCT decoding matrix \n"); |
| 6481 return OPJ_FALSE; |
| 6482 » » » » » » » » » »
} |
6363 | 6483 |
6364 tcp->mct_norms = (OPJ_FLOAT64*) | 6484 tcp->mct_norms = (OPJ_FLOAT64*) |
6365 opj_malloc(image->numcomps * sizeof(OPJ_FLOA
T64)); | 6485 opj_malloc(image->numcomps * sizeof(OPJ_FLOA
T64)); |
6366 | 6486 » » » » » » » » » »
if (! tcp->mct_norms) { |
| 6487 opj_free(lTmpBuf); |
| 6488 » » » » » » » » » »
» » » » lTmpBuf = NULL; |
| 6489 opj_event_msg(p_manager, EVT_ERROR, "Not enough memo
ry to allocate encoder MCT norms \n"); |
| 6490 return OPJ_FALSE; |
| 6491 } |
6367 opj_calculate_norms(tcp->mct_norms,image->numcomps,tcp->m_mc
t_decoding_matrix); | 6492 opj_calculate_norms(tcp->mct_norms,image->numcomps,tcp->m_mc
t_decoding_matrix); |
6368 opj_free(lTmpBuf); | 6493 opj_free(lTmpBuf); |
6369 | 6494 |
6370 for (i = 0; i < image->numcomps; i++) { | 6495 for (i = 0; i < image->numcomps; i++) { |
6371 opj_tccp_t *tccp = &tcp->tccps[i]; | 6496 opj_tccp_t *tccp = &tcp->tccps[i]; |
6372 tccp->m_dc_level_shift = l_dc_shift[i]; | 6497 tccp->m_dc_level_shift = l_dc_shift[i]; |
6373 } | 6498 } |
6374 | 6499 |
6375 opj_j2k_setup_mct_encoding(tcp,image);
| 6500 if (opj_j2k_setup_mct_encoding(tcp,image) == OPJ_FALSE) { |
| 6501 /* free will be handled by opj_j2k_destroy */ |
| 6502 » » » » » » » » » »
» » opj_event_msg(p_manager, EVT_ERROR, "Failed to setup j2k mct enc
oding\n"); |
| 6503 return OPJ_FALSE; |
| 6504 } |
6376 } | 6505 } |
6377 else { | 6506 else { |
| 6507 if(tcp->mct==1 && image->numcomps == 3) { // RGB->YCC MCT is
enabled |
| 6508 if ((image->comps[0].dx != image->comps[1].dx) || |
| 6509 (image->comps[0].dx != image->comps[2].dx) || |
| 6510 (image->comps[0].dy != image->comps[1].dy) || |
| 6511 (image->comps[0].dy != image->comps[2].dy)) { |
| 6512 opj_event_msg(p_manager, EVT_WARNING, "Cannot perfor
m MCT on components with different sizes. Disabling MCT.\n"); |
| 6513 tcp->mct = 0; |
| 6514 } |
| 6515 } |
6378 for (i = 0; i < image->numcomps; i++) { | 6516 for (i = 0; i < image->numcomps; i++) { |
6379 opj_tccp_t *tccp = &tcp->tccps[i]; | 6517 opj_tccp_t *tccp = &tcp->tccps[i]; |
6380 opj_image_comp_t * l_comp = &(image->comps[i]); | 6518 opj_image_comp_t * l_comp = &(image->comps[i]); |
6381 | 6519 |
6382 if (! l_comp->sgnd) { | 6520 if (! l_comp->sgnd) { |
6383 tccp->m_dc_level_shift = 1 << (l_comp->p
rec - 1); | 6521 tccp->m_dc_level_shift = 1 << (l_comp->p
rec - 1); |
6384 } | 6522 } |
6385 } | 6523 } |
6386 } | 6524 } |
6387 | 6525 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6454 } | 6592 } |
6455 | 6593 |
6456 opj_dwt_calc_explicit_stepsizes(tccp, image->comps[i].pr
ec); | 6594 opj_dwt_calc_explicit_stepsizes(tccp, image->comps[i].pr
ec); |
6457 } | 6595 } |
6458 } | 6596 } |
6459 | 6597 |
6460 if (parameters->mct_data) { | 6598 if (parameters->mct_data) { |
6461 opj_free(parameters->mct_data); | 6599 opj_free(parameters->mct_data); |
6462 parameters->mct_data = 00; | 6600 parameters->mct_data = 00; |
6463 } | 6601 } |
| 6602 return OPJ_TRUE; |
6464 } | 6603 } |
6465 | 6604 |
6466 static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index, OPJ_UIN
T32 type, OPJ_OFF_T pos, OPJ_UINT32 len) | 6605 static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index, OPJ_UIN
T32 type, OPJ_OFF_T pos, OPJ_UINT32 len) |
6467 { | 6606 { |
6468 assert(cstr_index != 00); | 6607 assert(cstr_index != 00); |
6469 | 6608 |
6470 /* expand the list? */ | 6609 /* expand the list? */ |
6471 if ((cstr_index->marknum + 1) > cstr_index->maxmarknum) { | 6610 if ((cstr_index->marknum + 1) > cstr_index->maxmarknum) { |
6472 opj_marker_info_t *new_marker; | 6611 opj_marker_info_t *new_marker; |
6473 cstr_index->maxmarknum = (OPJ_UINT32)(100 + (OPJ_FLOAT32) cstr_i
ndex->maxmarknum); | 6612 cstr_index->maxmarknum = (OPJ_UINT32)(100 + (OPJ_FLOAT32) cstr_i
ndex->maxmarknum); |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7547 | 7686 |
7548 /* If we didn't skip data before, we need to read the SOD marker
*/ | 7687 /* If we didn't skip data before, we need to read the SOD marker
*/ |
7549 if (! p_j2k->m_specific_param.m_decoder.m_skip_data) { | 7688 if (! p_j2k->m_specific_param.m_decoder.m_skip_data) { |
7550 /* Try to read the SOD marker and skip data ? FIXME */ | 7689 /* Try to read the SOD marker and skip data ? FIXME */ |
7551 if (! opj_j2k_read_sod(p_j2k, p_stream, p_manager)) { | 7690 if (! opj_j2k_read_sod(p_j2k, p_stream, p_manager)) { |
7552 return OPJ_FALSE; | 7691 return OPJ_FALSE; |
7553 } | 7692 } |
7554 | 7693 |
7555 if (! p_j2k->m_specific_param.m_decoder.m_can_decode){ | 7694 if (! p_j2k->m_specific_param.m_decoder.m_can_decode){ |
7556 /* Try to read 2 bytes (the next marker ID) from
stream and copy them into the buffer */ | 7695 /* Try to read 2 bytes (the next marker ID) from
stream and copy them into the buffer */ |
7557 while(1) //liang | |
7558 { | |
7559 if (opj_stream_read_data(p_stream,p_j2k->m_speci
fic_param.m_decoder.m_header_data,2,p_manager) != 2) { | 7696 if (opj_stream_read_data(p_stream,p_j2k->m_speci
fic_param.m_decoder.m_header_data,2,p_manager) != 2) { |
7560 opj_event_msg(p_manager, EVT_ERROR, "Str
eam too short\n"); | 7697 opj_event_msg(p_manager, EVT_ERROR, "Str
eam too short\n"); |
7561 return OPJ_FALSE; | 7698 return OPJ_FALSE; |
7562 } | 7699 } |
7563 | 7700 |
7564 /* Read 2 bytes from buffer as the new marker ID
*/ | 7701 /* Read 2 bytes from buffer as the new marker ID
*/ |
7565 opj_read_bytes(p_j2k->m_specific_param.m_decoder
.m_header_data,&l_current_marker,2); | 7702 opj_read_bytes(p_j2k->m_specific_param.m_decoder
.m_header_data,&l_current_marker,2); |
7566 if((l_current_ma
rker & 0xff00) == 0xff00) break; | |
7567 } | |
7568 } | 7703 } |
7569 } | 7704 } |
7570 else { | 7705 else { |
7571 /* Indicate we will try to read a new tile-part header*/ | 7706 /* Indicate we will try to read a new tile-part header*/ |
7572 p_j2k->m_specific_param.m_decoder.m_skip_data = 0; | 7707 p_j2k->m_specific_param.m_decoder.m_skip_data = 0; |
7573 p_j2k->m_specific_param.m_decoder.m_can_decode = 0; | 7708 p_j2k->m_specific_param.m_decoder.m_can_decode = 0; |
7574 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TP
HSOT; | 7709 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TP
HSOT; |
7575 | 7710 |
7576 /* Try to read 2 bytes (the next marker ID) from stream
and copy them into the buffer */ | 7711 /* Try to read 2 bytes (the next marker ID) from stream
and copy them into the buffer */ |
7577 if (opj_stream_read_data(p_stream,p_j2k->m_specific_para
m.m_decoder.m_header_data,2,p_manager) != 2) { | 7712 if (opj_stream_read_data(p_stream,p_j2k->m_specific_para
m.m_decoder.m_header_data,2,p_manager) != 2) { |
(...skipping 30 matching lines...) Expand all Loading... |
7608 } | 7743 } |
7609 } | 7744 } |
7610 | 7745 |
7611 /*FIXME ???*/ | 7746 /*FIXME ???*/ |
7612 if (! opj_tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_numbe
r)) { | 7747 if (! opj_tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_numbe
r)) { |
7613 opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory
error\n"); | 7748 opj_event_msg(p_manager, EVT_ERROR, "Cannot decode tile, memory
error\n"); |
7614 return OPJ_FALSE; | 7749 return OPJ_FALSE; |
7615 } | 7750 } |
7616 | 7751 |
7617 opj_event_msg(p_manager, EVT_INFO, "Header of tile %d / %d has been read
.\n", | 7752 opj_event_msg(p_manager, EVT_INFO, "Header of tile %d / %d has been read
.\n", |
7618 p_j2k->m_current_tile_number, (p_j2k->m_cp.th * p_j2k->m
_cp.tw) - 1); | 7753 p_j2k->m_current_tile_number+1, (p_j2k->m_cp.th * p_j2k-
>m_cp.tw)); |
7619 | 7754 |
7620 *p_tile_index = p_j2k->m_current_tile_number; | 7755 *p_tile_index = p_j2k->m_current_tile_number; |
7621 *p_go_on = OPJ_TRUE; | 7756 *p_go_on = OPJ_TRUE; |
7622 *p_data_size = opj_tcd_get_decoded_tile_size(p_j2k->m_tcd); | 7757 *p_data_size = opj_tcd_get_decoded_tile_size(p_j2k->m_tcd); |
7623 *p_tile_x0 = p_j2k->m_tcd->tcd_image->tiles->x0; | 7758 *p_tile_x0 = p_j2k->m_tcd->tcd_image->tiles->x0; |
7624 *p_tile_y0 = p_j2k->m_tcd->tcd_image->tiles->y0; | 7759 *p_tile_y0 = p_j2k->m_tcd->tcd_image->tiles->y0; |
7625 *p_tile_x1 = p_j2k->m_tcd->tcd_image->tiles->x1; | 7760 *p_tile_x1 = p_j2k->m_tcd->tcd_image->tiles->x1; |
7626 *p_tile_y1 = p_j2k->m_tcd->tcd_image->tiles->y1; | 7761 *p_tile_y1 = p_j2k->m_tcd->tcd_image->tiles->y1; |
7627 *p_nb_comps = p_j2k->m_tcd->tcd_image->tiles->numcomps; | 7762 *p_nb_comps = p_j2k->m_tcd->tcd_image->tiles->numcomps; |
7628 | 7763 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7693 return OPJ_FALSE; | 7828 return OPJ_FALSE; |
7694 } | 7829 } |
7695 | 7830 |
7696 opj_read_bytes(l_data,&l_current_marker,2); | 7831 opj_read_bytes(l_data,&l_current_marker,2); |
7697 | 7832 |
7698 if (l_current_marker == J2K_MS_EOC) { | 7833 if (l_current_marker == J2K_MS_EOC) { |
7699 p_j2k->m_current_tile_number = 0; | 7834 p_j2k->m_current_tile_number = 0; |
7700 p_j2k->m_specific_param.m_decoder.m_state = 0x0100;/*FI
XME J2K_DEC_STATE_EOC;*/ | 7835 p_j2k->m_specific_param.m_decoder.m_state = 0x0100;/*FI
XME J2K_DEC_STATE_EOC;*/ |
7701 } | 7836 } |
7702 else if (l_current_marker != J2K_MS_SOT) | 7837 else if (l_current_marker != J2K_MS_SOT) |
7703 { | 7838 { |
7704 opj_event_msg(p_manager, EVT_ERROR, "Stream too short, e
xpected SOT\n"); | |
7705 | |
7706 if(opj_stream_get_number_byte_left(p_stream) == 0) { | 7839 if(opj_stream_get_number_byte_left(p_stream) == 0) { |
7707 p_j2k->m_specific_param.m_decoder.m_state = J2K_STAT
E_NEOC; | 7840 p_j2k->m_specific_param.m_decoder.m_state = J2K_STAT
E_NEOC; |
| 7841 opj_event_msg(p_manager, EVT_WARNING, "Stream does n
ot end with EOC\n"); |
7708 return OPJ_TRUE; | 7842 return OPJ_TRUE; |
7709 } | 7843 } |
| 7844 opj_event_msg(p_manager, EVT_ERROR, "Stream too short, e
xpected SOT\n"); |
7710 return OPJ_FALSE; | 7845 return OPJ_FALSE; |
7711 } | 7846 } |
7712 } | 7847 } |
7713 | 7848 |
7714 return OPJ_TRUE; | 7849 return OPJ_TRUE; |
7715 } | 7850 } |
7716 | 7851 |
7717 OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data, opj_im
age_t* p_output_image) | 7852 OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data, opj_im
age_t* p_output_image) |
7718 { | 7853 { |
7719 OPJ_UINT32 i,j,k = 0; | 7854 OPJ_UINT32 i,j,k = 0; |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8127 } | 8262 } |
8128 | 8263 |
8129 opj_event_msg( p_manager, EVT_INFO,"Setting decoding area to %d,%d,%d,%d
\n", | 8264 opj_event_msg( p_manager, EVT_INFO,"Setting decoding area to %d,%d,%d,%d
\n", |
8130 p_image->x0, p_image->y0, p_image->x1, p_image->y1); | 8265 p_image->x0, p_image->y0, p_image->x1, p_image->y1); |
8131 | 8266 |
8132 return OPJ_TRUE; | 8267 return OPJ_TRUE; |
8133 } | 8268 } |
8134 | 8269 |
8135 opj_j2k_t* opj_j2k_create_decompress(void) | 8270 opj_j2k_t* opj_j2k_create_decompress(void) |
8136 { | 8271 { |
8137 opj_j2k_t *l_j2k = (opj_j2k_t*) opj_malloc(sizeof(opj_j2k_t)); | 8272 opj_j2k_t *l_j2k = (opj_j2k_t*) opj_calloc(1,sizeof(opj_j2k_t)); |
8138 if (!l_j2k) { | 8273 if (!l_j2k) { |
8139 return 00; | 8274 return 00; |
8140 } | 8275 } |
8141 memset(l_j2k,0,sizeof(opj_j2k_t)); | |
8142 | 8276 |
8143 l_j2k->m_is_decoder = 1; | 8277 l_j2k->m_is_decoder = 1; |
8144 l_j2k->m_cp.m_is_decoder = 1; | 8278 l_j2k->m_cp.m_is_decoder = 1; |
8145 | 8279 |
8146 l_j2k->m_specific_param.m_decoder.m_default_tcp = (opj_tcp_t*) opj_mallo
c(sizeof(opj_tcp_t)); | 8280 l_j2k->m_specific_param.m_decoder.m_default_tcp = (opj_tcp_t*) opj_callo
c(1,sizeof(opj_tcp_t)); |
8147 if (!l_j2k->m_specific_param.m_decoder.m_default_tcp) { | 8281 if (!l_j2k->m_specific_param.m_decoder.m_default_tcp) { |
8148 opj_j2k_destroy(l_j2k); | 8282 opj_j2k_destroy(l_j2k); |
8149 return 00; | 8283 return 00; |
8150 } | 8284 } |
8151 memset(l_j2k->m_specific_param.m_decoder.m_default_tcp,0,sizeof(opj_tcp_
t)); | |
8152 | 8285 |
8153 l_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE *) opj_mallo
c(OPJ_J2K_DEFAULT_HEADER_SIZE); | 8286 l_j2k->m_specific_param.m_decoder.m_header_data = (OPJ_BYTE *) opj_callo
c(1,OPJ_J2K_DEFAULT_HEADER_SIZE); |
8154 if (! l_j2k->m_specific_param.m_decoder.m_header_data) { | 8287 if (! l_j2k->m_specific_param.m_decoder.m_header_data) { |
8155 opj_j2k_destroy(l_j2k); | 8288 opj_j2k_destroy(l_j2k); |
8156 return 00; | 8289 return 00; |
8157 } | 8290 } |
8158 | 8291 |
8159 l_j2k->m_specific_param.m_decoder.m_header_data_size = OPJ_J2K_DEFAULT_H
EADER_SIZE; | 8292 l_j2k->m_specific_param.m_decoder.m_header_data_size = OPJ_J2K_DEFAULT_H
EADER_SIZE; |
8160 | 8293 |
8161 l_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = -1 ; | 8294 l_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = -1 ; |
8162 | 8295 |
8163 l_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = 0 ; | 8296 l_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = 0 ; |
8164 | 8297 |
8165 /* codestream index creation */ | 8298 /* codestream index creation */ |
8166 l_j2k->cstr_index = opj_j2k_create_cstr_index(); | 8299 l_j2k->cstr_index = opj_j2k_create_cstr_index(); |
8167 | |
8168 /*(opj_codestream_index_t*) opj_malloc(sizeof(opj_codest
ream_index_t)); | |
8169 if (!l_j2k->cstr_index){ | 8300 if (!l_j2k->cstr_index){ |
8170 opj_j2k_destroy(l_j2k); | 8301 opj_j2k_destroy(l_j2k); |
8171 return NULL; | 8302 return 00; |
8172 } | 8303 } |
8173 | 8304 |
8174 l_j2k->cstr_index->marker = (opj_marker_info_t*) opj_malloc(100 * sizeof
(opj_marker_info_t)); | |
8175 */ | |
8176 | |
8177 /* validation list creation */ | 8305 /* validation list creation */ |
8178 l_j2k->m_validation_list = opj_procedure_list_create(); | 8306 l_j2k->m_validation_list = opj_procedure_list_create(); |
8179 if (! l_j2k->m_validation_list) { | 8307 if (! l_j2k->m_validation_list) { |
8180 opj_j2k_destroy(l_j2k); | 8308 opj_j2k_destroy(l_j2k); |
8181 return 00; | 8309 return 00; |
8182 } | 8310 } |
8183 | 8311 |
8184 /* execution list creation */ | 8312 /* execution list creation */ |
8185 l_j2k->m_procedure_list = opj_procedure_list_create(); | 8313 l_j2k->m_procedure_list = opj_procedure_list_create(); |
8186 if (! l_j2k->m_procedure_list) { | 8314 if (! l_j2k->m_procedure_list) { |
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9581 opj_stream_private_t
*p_stream, | 9709 opj_stream_private_t
*p_stream, |
9582 opj_image_t * p_imag
e, | 9710 opj_image_t * p_imag
e, |
9583 opj_event_mgr_t * p_
manager) | 9711 opj_event_mgr_t * p_
manager) |
9584 { | 9712 { |
9585 /* preconditions */ | 9713 /* preconditions */ |
9586 assert(p_j2k != 00); | 9714 assert(p_j2k != 00); |
9587 assert(p_stream != 00); | 9715 assert(p_stream != 00); |
9588 assert(p_manager != 00); | 9716 assert(p_manager != 00); |
9589 | 9717 |
9590 p_j2k->m_private_image = opj_image_create0(); | 9718 p_j2k->m_private_image = opj_image_create0(); |
| 9719 if (! p_j2k->m_private_image) { |
| 9720 opj_event_msg(p_manager, EVT_ERROR, "Failed to allocate image he
ader." ); |
| 9721 return OPJ_FALSE; |
| 9722 } |
9591 opj_copy_image_header(p_image, p_j2k->m_private_image); | 9723 opj_copy_image_header(p_image, p_j2k->m_private_image); |
9592 | 9724 |
9593 /* TODO_MSD: Find a better way */ | 9725 /* TODO_MSD: Find a better way */ |
9594 if (p_image->comps) { | 9726 if (p_image->comps) { |
9595 OPJ_UINT32 it_comp; | 9727 OPJ_UINT32 it_comp; |
9596 for (it_comp = 0 ; it_comp < p_image->numcomps; it_comp++) { | 9728 for (it_comp = 0 ; it_comp < p_image->numcomps; it_comp++) { |
9597 if (p_image->comps[it_comp].data) { | 9729 if (p_image->comps[it_comp].data) { |
9598 p_j2k->m_private_image->comps[it_comp].data =p_i
mage->comps[it_comp].data; | 9730 p_j2k->m_private_image->comps[it_comp].data =p_i
mage->comps[it_comp].data; |
9599 p_image->comps[it_comp].data = NULL; | 9731 p_image->comps[it_comp].data = NULL; |
9600 | 9732 |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9802 } | 9934 } |
9803 | 9935 |
9804 void opj_j2k_setup_end_compress (opj_j2k_t *p_j2k) | 9936 void opj_j2k_setup_end_compress (opj_j2k_t *p_j2k) |
9805 { | 9937 { |
9806 /* preconditions */ | 9938 /* preconditions */ |
9807 assert(p_j2k != 00); | 9939 assert(p_j2k != 00); |
9808 | 9940 |
9809 /* DEVELOPER CORNER, insert your custom procedures */ | 9941 /* DEVELOPER CORNER, insert your custom procedures */ |
9810 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_eoc ); | 9942 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_eoc ); |
9811 | 9943 |
9812 if (p_j2k->m_cp.m_specific_param.m_enc.m_cinema) { | 9944 if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) { |
9813 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_updated_tlm); | 9945 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_updated_tlm); |
9814 } | 9946 } |
9815 | 9947 |
9816 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_epc ); | 9948 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_epc ); |
9817 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_end_encoding ); | 9949 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_end_encoding ); |
9818 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_destroy_header_memory); | 9950 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_destroy_header_memory); |
9819 } | 9951 } |
9820 | 9952 |
9821 void opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k) | 9953 void opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k) |
9822 { | 9954 { |
(...skipping 11 matching lines...) Expand all Loading... |
9834 { | 9966 { |
9835 /* preconditions */ | 9967 /* preconditions */ |
9836 assert(p_j2k != 00); | 9968 assert(p_j2k != 00); |
9837 | 9969 |
9838 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_init_info ); | 9970 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_init_info ); |
9839 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_soc ); | 9971 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_soc ); |
9840 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_siz ); | 9972 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_siz ); |
9841 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_cod ); | 9973 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_cod ); |
9842 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_qcd ); | 9974 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_qcd ); |
9843 | 9975 |
9844 if (p_j2k->m_cp.m_specific_param.m_enc.m_cinema) { | 9976 if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) { |
9845 /* No need for COC or QCC, QCD and COD are used | 9977 /* No need for COC or QCC, QCD and COD are used |
9846 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_all_coc ); | 9978 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_all_coc ); |
9847 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_all_qcc ); | 9979 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_all_qcc ); |
9848 */ | 9980 */ |
9849 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_tlm ); | 9981 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_tlm ); |
9850 | 9982 |
9851 if (p_j2k->m_cp.m_specific_param.m_enc.m_cinema == OPJ_CINEMA4K_
24) { | 9983 if (p_j2k->m_cp.rsiz == OPJ_PROFILE_CINEMA_4K) { |
9852 opj_procedure_list_add_procedure(p_j2k->m_procedure_list
,(opj_procedure)opj_j2k_write_poc ); | 9984 opj_procedure_list_add_procedure(p_j2k->m_procedure_list
,(opj_procedure)opj_j2k_write_poc ); |
9853 } | 9985 } |
9854 } | 9986 } |
9855 | 9987 |
9856 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_regions); | 9988 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_write_regions); |
9857 | 9989 |
9858 if (p_j2k->m_cp.comment != 00) { | 9990 if (p_j2k->m_cp.comment != 00) { |
9859 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_com); | 9991 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_com); |
9860 } | 9992 } |
9861 | 9993 |
9862 /* DEVELOPER CORNER, insert your custom procedures */ | 9994 /* DEVELOPER CORNER, insert your custom procedures */ |
9863 if (p_j2k->m_cp.rsiz & OPJ_MCT) { | 9995 if (p_j2k->m_cp.rsiz & OPJ_EXTENSION_MCT) { |
9864 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_mct_data_group ); | 9996 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_write_mct_data_group ); |
9865 } | 9997 } |
9866 /* End of Developer Corner */ | 9998 /* End of Developer Corner */ |
9867 | 9999 |
9868 if (p_j2k->cstr_index) { | 10000 if (p_j2k->cstr_index) { |
9869 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_get_end_header ); | 10001 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_pr
ocedure)opj_j2k_get_end_header ); |
9870 } | 10002 } |
9871 | 10003 |
9872 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_create_tcd); | 10004 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_create_tcd); |
9873 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_update_rates); | 10005 opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)
opj_j2k_update_rates); |
(...skipping 28 matching lines...) Expand all Loading... |
9902 l_begin_data = p_data; | 10034 l_begin_data = p_data; |
9903 if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_strea
m,p_manager)) | 10035 if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_strea
m,p_manager)) |
9904 { | 10036 { |
9905 return OPJ_FALSE; | 10037 return OPJ_FALSE; |
9906 } | 10038 } |
9907 | 10039 |
9908 l_nb_bytes_written += l_current_nb_bytes_written; | 10040 l_nb_bytes_written += l_current_nb_bytes_written; |
9909 p_data += l_current_nb_bytes_written; | 10041 p_data += l_current_nb_bytes_written; |
9910 p_total_data_size -= l_current_nb_bytes_written; | 10042 p_total_data_size -= l_current_nb_bytes_written; |
9911 | 10043 |
9912 if (l_cp->m_specific_param.m_enc.m_cinema == 0) { | 10044 if (!OPJ_IS_CINEMA(l_cp->rsiz)) { |
9913 #if 0 | 10045 #if 0 |
9914 for (compno = 1; compno < p_j2k->m_private_image->numcomps; comp
no++) { | 10046 for (compno = 1; compno < p_j2k->m_private_image->numcomps; comp
no++) { |
9915 l_current_nb_bytes_written = 0; | 10047 l_current_nb_bytes_written = 0; |
9916 opj_j2k_write_coc_in_memory(p_j2k,compno,p_data,&l_curre
nt_nb_bytes_written,p_manager); | 10048 opj_j2k_write_coc_in_memory(p_j2k,compno,p_data,&l_curre
nt_nb_bytes_written,p_manager); |
9917 l_nb_bytes_written += l_current_nb_bytes_written; | 10049 l_nb_bytes_written += l_current_nb_bytes_written; |
9918 p_data += l_current_nb_bytes_written; | 10050 p_data += l_current_nb_bytes_written; |
9919 p_total_data_size -= l_current_nb_bytes_written; | 10051 p_total_data_size -= l_current_nb_bytes_written; |
9920 | 10052 |
9921 l_current_nb_bytes_written = 0; | 10053 l_current_nb_bytes_written = 0; |
9922 opj_j2k_write_qcc_in_memory(p_j2k,compno,p_data,&l_curre
nt_nb_bytes_written,p_manager); | 10054 opj_j2k_write_qcc_in_memory(p_j2k,compno,p_data,&l_curre
nt_nb_bytes_written,p_manager); |
(...skipping 16 matching lines...) Expand all Loading... |
9939 if (! opj_j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p
_total_data_size,p_stream,p_manager)) { | 10071 if (! opj_j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p
_total_data_size,p_stream,p_manager)) { |
9940 return OPJ_FALSE; | 10072 return OPJ_FALSE; |
9941 } | 10073 } |
9942 | 10074 |
9943 l_nb_bytes_written += l_current_nb_bytes_written; | 10075 l_nb_bytes_written += l_current_nb_bytes_written; |
9944 * p_data_written = l_nb_bytes_written; | 10076 * p_data_written = l_nb_bytes_written; |
9945 | 10077 |
9946 /* Writing Psot in SOT marker */ | 10078 /* Writing Psot in SOT marker */ |
9947 opj_write_bytes(l_begin_data + 6,l_nb_bytes_written,4);
/* PSOT */ | 10079 opj_write_bytes(l_begin_data + 6,l_nb_bytes_written,4);
/* PSOT */ |
9948 | 10080 |
9949 if (l_cp->m_specific_param.m_enc.m_cinema){ | 10081 if (OPJ_IS_CINEMA(l_cp->rsiz)){ |
9950 opj_j2k_update_tlm(p_j2k,l_nb_bytes_written); | 10082 opj_j2k_update_tlm(p_j2k,l_nb_bytes_written); |
9951 } | 10083 } |
9952 | 10084 |
9953 return OPJ_TRUE; | 10085 return OPJ_TRUE; |
9954 } | 10086 } |
9955 | 10087 |
9956 OPJ_BOOL opj_j2k_write_all_tile_parts( opj_j2k_t *p_j2k, | 10088 OPJ_BOOL opj_j2k_write_all_tile_parts( opj_j2k_t *p_j2k, |
9957 OPJ_BYTE
* p_data, | 10089 OPJ_BYTE
* p_data, |
9958 OPJ_UINT
32 * p_data_written, | 10090 OPJ_UINT
32 * p_data_written, |
9959 OPJ_UINT
32 p_total_data_size, | 10091 OPJ_UINT
32 p_total_data_size, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10003 } | 10135 } |
10004 | 10136 |
10005 p_data += l_current_nb_bytes_written; | 10137 p_data += l_current_nb_bytes_written; |
10006 l_nb_bytes_written += l_current_nb_bytes_written; | 10138 l_nb_bytes_written += l_current_nb_bytes_written; |
10007 p_total_data_size -= l_current_nb_bytes_written; | 10139 p_total_data_size -= l_current_nb_bytes_written; |
10008 l_part_tile_size += l_current_nb_bytes_written; | 10140 l_part_tile_size += l_current_nb_bytes_written; |
10009 | 10141 |
10010 /* Writing Psot in SOT marker */ | 10142 /* Writing Psot in SOT marker */ |
10011 opj_write_bytes(l_begin_data + 6,l_part_tile_size,4);
/* PSOT */ | 10143 opj_write_bytes(l_begin_data + 6,l_part_tile_size,4);
/* PSOT */ |
10012 | 10144 |
10013 if (l_cp->m_specific_param.m_enc.m_cinema) { | 10145 if (OPJ_IS_CINEMA(l_cp->rsiz)) { |
10014 opj_j2k_update_tlm(p_j2k,l_part_tile_size); | 10146 opj_j2k_update_tlm(p_j2k,l_part_tile_size); |
10015 } | 10147 } |
10016 | 10148 |
10017 ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number; | 10149 ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number; |
10018 } | 10150 } |
10019 | 10151 |
10020 for (pino = 1; pino <= l_tcp->numpocs; ++pino) { | 10152 for (pino = 1; pino <= l_tcp->numpocs; ++pino) { |
10021 l_tcd->cur_pino = pino; | 10153 l_tcd->cur_pino = pino; |
10022 | 10154 |
10023 /*Get number of tile parts*/ | 10155 /*Get number of tile parts*/ |
(...skipping 20 matching lines...) Expand all Loading... |
10044 } | 10176 } |
10045 | 10177 |
10046 l_nb_bytes_written += l_current_nb_bytes_written; | 10178 l_nb_bytes_written += l_current_nb_bytes_written; |
10047 p_data += l_current_nb_bytes_written; | 10179 p_data += l_current_nb_bytes_written; |
10048 p_total_data_size -= l_current_nb_bytes_written; | 10180 p_total_data_size -= l_current_nb_bytes_written; |
10049 l_part_tile_size += l_current_nb_bytes_written; | 10181 l_part_tile_size += l_current_nb_bytes_written; |
10050 | 10182 |
10051 /* Writing Psot in SOT marker */ | 10183 /* Writing Psot in SOT marker */ |
10052 opj_write_bytes(l_begin_data + 6,l_part_tile_size,4);
/* PSOT */ | 10184 opj_write_bytes(l_begin_data + 6,l_part_tile_size,4);
/* PSOT */ |
10053 | 10185 |
10054 if (l_cp->m_specific_param.m_enc.m_cinema) { | 10186 if (OPJ_IS_CINEMA(l_cp->rsiz)) { |
10055 opj_j2k_update_tlm(p_j2k,l_part_tile_size); | 10187 opj_j2k_update_tlm(p_j2k,l_part_tile_size); |
10056 } | 10188 } |
10057 | 10189 |
10058 ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_
number; | 10190 ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_
number; |
10059 } | 10191 } |
10060 } | 10192 } |
10061 | 10193 |
10062 *p_data_written = l_nb_bytes_written; | 10194 *p_data_written = l_nb_bytes_written; |
10063 | 10195 |
10064 return OPJ_TRUE; | 10196 return OPJ_TRUE; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10246 } | 10378 } |
10247 else { | 10379 else { |
10248 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream,
p_manager)) { | 10380 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream,
p_manager)) { |
10249 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); | 10381 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); |
10250 return OPJ_FALSE; | 10382 return OPJ_FALSE; |
10251 } | 10383 } |
10252 } | 10384 } |
10253 | 10385 |
10254 return OPJ_TRUE; | 10386 return OPJ_TRUE; |
10255 } | 10387 } |
OLD | NEW |