Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(536)

Side by Side Diff: third_party/libopenjpeg20/tgt.c

Issue 1416783002: Merge to M46: upgrade openjpeg to commit# cf352af (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@2490
Patch Set: Fix pdfium:168 since we are already half way there Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/libopenjpeg20/tgt.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 27 matching lines...) Expand all
38 */ 38 */
39 39
40 #include "opj_includes.h" 40 #include "opj_includes.h"
41 41
42 /* 42 /*
43 ========================================================== 43 ==========================================================
44 Tag-tree coder interface 44 Tag-tree coder interface
45 ========================================================== 45 ==========================================================
46 */ 46 */
47 47
48 opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv) { 48 opj_tgt_tree_t *opj_tgt_create(OPJ_UINT32 numleafsh, OPJ_UINT32 numleafsv, opj_e vent_mgr_t *manager) {
49 OPJ_INT32 nplh[32]; 49 OPJ_INT32 nplh[32];
50 OPJ_INT32 nplv[32]; 50 OPJ_INT32 nplv[32];
51 opj_tgt_node_t *node = 00; 51 opj_tgt_node_t *node = 00;
52 opj_tgt_node_t *l_parent_node = 00; 52 opj_tgt_node_t *l_parent_node = 00;
53 opj_tgt_node_t *l_parent_node0 = 00; 53 opj_tgt_node_t *l_parent_node0 = 00;
54 opj_tgt_tree_t *tree = 00; 54 opj_tgt_tree_t *tree = 00;
55 OPJ_UINT32 i; 55 OPJ_UINT32 i;
56 OPJ_INT32 j,k; 56 OPJ_INT32 j,k;
57 OPJ_UINT32 numlvls; 57 OPJ_UINT32 numlvls;
58 OPJ_UINT32 n; 58 OPJ_UINT32 n;
59 59
60 tree = (opj_tgt_tree_t *) opj_calloc(1,sizeof(opj_tgt_tree_t)); 60 tree = (opj_tgt_tree_t *) opj_calloc(1,sizeof(opj_tgt_tree_t));
61 if(!tree) { 61 if(!tree) {
62 fprintf(stderr, "ERROR in tgt_create while allocating tree\n"); 62 opj_event_msg(manager, EVT_ERROR, "Not enough memory to create T ag-tree\n");
63 return 00; 63 return 00;
64 } 64 }
65 65
66 tree->numleafsh = numleafsh; 66 tree->numleafsh = numleafsh;
67 tree->numleafsv = numleafsv; 67 tree->numleafsv = numleafsv;
68 68
69 numlvls = 0; 69 numlvls = 0;
70 nplh[0] = (OPJ_INT32)numleafsh; 70 nplh[0] = (OPJ_INT32)numleafsh;
71 nplv[0] = (OPJ_INT32)numleafsv; 71 nplv[0] = (OPJ_INT32)numleafsv;
72 tree->numnodes = 0; 72 tree->numnodes = 0;
73 do { 73 do {
74 n = (OPJ_UINT32)(nplh[numlvls] * nplv[numlvls]); 74 n = (OPJ_UINT32)(nplh[numlvls] * nplv[numlvls]);
75 nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2; 75 nplh[numlvls + 1] = (nplh[numlvls] + 1) / 2;
76 nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2; 76 nplv[numlvls + 1] = (nplv[numlvls] + 1) / 2;
77 tree->numnodes += n; 77 tree->numnodes += n;
78 ++numlvls; 78 ++numlvls;
79 } while (n > 1); 79 } while (n > 1);
80 80
81 /* ADD */ 81 /* ADD */
82 if (tree->numnodes == 0) { 82 if (tree->numnodes == 0) {
83 opj_free(tree); 83 opj_free(tree);
84 fprintf(stderr, "WARNING in tgt_create tree->numnodes == 0, no t ree created.\n"); 84 opj_event_msg(manager, EVT_WARNING, "tgt_create tree->numnodes = = 0, no tree created.\n");
85 return 00; 85 return 00;
86 } 86 }
87 87
88 tree->nodes = (opj_tgt_node_t*) opj_calloc(tree->numnodes, sizeof(opj_tg t_node_t)); 88 tree->nodes = (opj_tgt_node_t*) opj_calloc(tree->numnodes, sizeof(opj_tg t_node_t));
89 if(!tree->nodes) { 89 if(!tree->nodes) {
90 fprintf(stderr, "ERROR in tgt_create while allocating node of th e tree\n"); 90 opj_event_msg(manager, EVT_ERROR, "Not enough memory to create T ag-tree nodes\n");
91 opj_free(tree); 91 opj_free(tree);
92 return 00; 92 return 00;
93 } 93 }
94 tree->nodes_size = tree->numnodes * (OPJ_UINT32)sizeof(opj_tgt_node_t); 94 tree->nodes_size = tree->numnodes * (OPJ_UINT32)sizeof(opj_tgt_node_t);
95 95
96 node = tree->nodes; 96 node = tree->nodes;
97 l_parent_node = &tree->nodes[tree->numleafsh * tree->numleafsv]; 97 l_parent_node = &tree->nodes[tree->numleafsh * tree->numleafsv];
98 l_parent_node0 = l_parent_node; 98 l_parent_node0 = l_parent_node;
99 99
100 for (i = 0; i < numlvls - 1; ++i) { 100 for (i = 0; i < numlvls - 1; ++i) {
(...skipping 22 matching lines...) Expand all
123 } 123 }
124 124
125 /** 125 /**
126 * Reinitialises a tag-tree from an existing one. 126 * Reinitialises a tag-tree from an existing one.
127 * 127 *
128 * @param p_tree the tree to reinitialize. 128 * @param p_tree the tree to reinitialize.
129 * @param p_num_leafs_h the width of the array of leafs of the t ree 129 * @param p_num_leafs_h the width of the array of leafs of the t ree
130 * @param p_num_leafs_v the height of the array of leafs of the tree 130 * @param p_num_leafs_v the height of the array of leafs of the tree
131 * @return a new tag-tree if successful, NULL otherwise 131 * @return a new tag-tree if successful, NULL otherwise
132 */ 132 */
133 opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, O PJ_UINT32 p_num_leafs_v) 133 opj_tgt_tree_t *opj_tgt_init(opj_tgt_tree_t * p_tree,OPJ_UINT32 p_num_leafs_h, O PJ_UINT32 p_num_leafs_v, opj_event_mgr_t *p_manager)
134 { 134 {
135 OPJ_INT32 l_nplh[32]; 135 OPJ_INT32 l_nplh[32];
136 OPJ_INT32 l_nplv[32]; 136 OPJ_INT32 l_nplv[32];
137 opj_tgt_node_t *l_node = 00; 137 opj_tgt_node_t *l_node = 00;
138 opj_tgt_node_t *l_parent_node = 00; 138 opj_tgt_node_t *l_parent_node = 00;
139 opj_tgt_node_t *l_parent_node0 = 00; 139 opj_tgt_node_t *l_parent_node0 = 00;
140 OPJ_UINT32 i; 140 OPJ_UINT32 i;
141 OPJ_INT32 j,k; 141 OPJ_INT32 j,k;
142 OPJ_UINT32 l_num_levels; 142 OPJ_UINT32 l_num_levels;
143 OPJ_UINT32 n; 143 OPJ_UINT32 n;
(...skipping 24 matching lines...) Expand all
168 /* ADD */ 168 /* ADD */
169 if (p_tree->numnodes == 0) { 169 if (p_tree->numnodes == 0) {
170 opj_tgt_destroy(p_tree); 170 opj_tgt_destroy(p_tree);
171 return 00; 171 return 00;
172 } 172 }
173 l_node_size = p_tree->numnodes * (OPJ_UINT32)sizeof(opj_tgt_node _t); 173 l_node_size = p_tree->numnodes * (OPJ_UINT32)sizeof(opj_tgt_node _t);
174 174
175 if (l_node_size > p_tree->nodes_size) { 175 if (l_node_size > p_tree->nodes_size) {
176 opj_tgt_node_t* new_nodes = (opj_tgt_node_t*) opj_reallo c(p_tree->nodes, l_node_size); 176 opj_tgt_node_t* new_nodes = (opj_tgt_node_t*) opj_reallo c(p_tree->nodes, l_node_size);
177 if (! new_nodes) { 177 if (! new_nodes) {
178 fprintf(stderr, "ERROR Not enough memory to rein itialize the tag tree\n"); 178 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to reinitialize the tag tree\n");
179 opj_tgt_destroy(p_tree); 179 opj_tgt_destroy(p_tree);
180 return 00; 180 return 00;
181 } 181 }
182 p_tree->nodes = new_nodes; 182 p_tree->nodes = new_nodes;
183 memset(((char *) p_tree->nodes) + p_tree->nodes_size, 0 , l_node_size - p_tree->nodes_size); 183 memset(((char *) p_tree->nodes) + p_tree->nodes_size, 0 , l_node_size - p_tree->nodes_size);
184 p_tree->nodes_size = l_node_size; 184 p_tree->nodes_size = l_node_size;
185 } 185 }
186 l_node = p_tree->nodes; 186 l_node = p_tree->nodes;
187 l_parent_node = &p_tree->nodes[p_tree->numleafsh * p_tree->numle afsv]; 187 l_parent_node = &p_tree->nodes[p_tree->numleafsh * p_tree->numle afsv];
188 l_parent_node0 = l_parent_node; 188 l_parent_node0 = l_parent_node;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 } 326 }
327 node->low = low; 327 node->low = low;
328 if (stkptr == stk) { 328 if (stkptr == stk) {
329 break; 329 break;
330 } 330 }
331 node = *--stkptr; 331 node = *--stkptr;
332 } 332 }
333 333
334 return (node->value < threshold) ? 1 : 0; 334 return (node->value < threshold) ? 1 : 0;
335 } 335 }
OLDNEW
« no previous file with comments | « third_party/libopenjpeg20/tgt.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698