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

Side by Side Diff: third_party/libopenjpeg20/image.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/function_list.c ('k') | third_party/libopenjpeg20/indexbox_manager.h » ('j') | 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) 2005, Herve Drolon, FreeImage Team 7 * Copyright (c) 2005, Herve Drolon, FreeImage Team
8 * All rights reserved. 8 * All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 29 matching lines...) Expand all
40 OPJ_UINT32 compno; 40 OPJ_UINT32 compno;
41 opj_image_t *image = NULL; 41 opj_image_t *image = NULL;
42 42
43 image = (opj_image_t*) opj_calloc(1, sizeof(opj_image_t)); 43 image = (opj_image_t*) opj_calloc(1, sizeof(opj_image_t));
44 if(image) { 44 if(image) {
45 image->color_space = clrspc; 45 image->color_space = clrspc;
46 image->numcomps = numcmpts; 46 image->numcomps = numcmpts;
47 /* allocate memory for the per-component information */ 47 /* allocate memory for the per-component information */
48 image->comps = (opj_image_comp_t*)opj_calloc(1,image->numcomps * sizeof(opj_image_comp_t)); 48 image->comps = (opj_image_comp_t*)opj_calloc(1,image->numcomps * sizeof(opj_image_comp_t));
49 if(!image->comps) { 49 if(!image->comps) {
50 » » » fprintf(stderr,"Unable to allocate memory for image.\n") ; 50 » » » /* TODO replace with event manager, breaks API */
51 » » » /* fprintf(stderr,"Unable to allocate memory for image.\ n"); */
51 opj_image_destroy(image); 52 opj_image_destroy(image);
52 return NULL; 53 return NULL;
53 } 54 }
54 /* create the individual image components */ 55 /* create the individual image components */
55 for(compno = 0; compno < numcmpts; compno++) { 56 for(compno = 0; compno < numcmpts; compno++) {
56 opj_image_comp_t *comp = &image->comps[compno]; 57 opj_image_comp_t *comp = &image->comps[compno];
57 comp->dx = cmptparms[compno].dx; 58 comp->dx = cmptparms[compno].dx;
58 comp->dy = cmptparms[compno].dy; 59 comp->dy = cmptparms[compno].dy;
59 comp->w = cmptparms[compno].w; 60 comp->w = cmptparms[compno].w;
60 comp->h = cmptparms[compno].h; 61 comp->h = cmptparms[compno].h;
61 comp->x0 = cmptparms[compno].x0; 62 comp->x0 = cmptparms[compno].x0;
62 comp->y0 = cmptparms[compno].y0; 63 comp->y0 = cmptparms[compno].y0;
63 comp->prec = cmptparms[compno].prec; 64 comp->prec = cmptparms[compno].prec;
64 comp->bpp = cmptparms[compno].bpp; 65 comp->bpp = cmptparms[compno].bpp;
65 comp->sgnd = cmptparms[compno].sgnd; 66 comp->sgnd = cmptparms[compno].sgnd;
66 comp->data = (OPJ_INT32*) opj_calloc(comp->w * comp->h, sizeof(OPJ_INT32)); 67 comp->data = (OPJ_INT32*) opj_calloc(comp->w * comp->h, sizeof(OPJ_INT32));
67 if(!comp->data) { 68 if(!comp->data) {
68 » » » » fprintf(stderr,"Unable to allocate memory for im age.\n"); 69 » » » » /* TODO replace with event manager, breaks API * /
70 » » » » /* fprintf(stderr,"Unable to allocate memory for image.\n"); */
69 opj_image_destroy(image); 71 opj_image_destroy(image);
70 return NULL; 72 return NULL;
71 } 73 }
72 } 74 }
73 } 75 }
74 76
75 return image; 77 return image;
76 } 78 }
77 79
78 void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) { 80 void OPJ_CALLCONV opj_image_destroy(opj_image_t *image) {
(...skipping 21 matching lines...) Expand all
100 102
101 /** 103 /**
102 * Updates the components characteristics of the image from the coding parameter s. 104 * Updates the components characteristics of the image from the coding parameter s.
103 * 105 *
104 * @param p_image_header the image header to update. 106 * @param p_image_header the image header to update.
105 * @param p_cp the coding parameters from which to upda te the image. 107 * @param p_cp the coding parameters from which to upda te the image.
106 */ 108 */
107 void opj_image_comp_header_update(opj_image_t * p_image_header, const struct opj _cp * p_cp) 109 void opj_image_comp_header_update(opj_image_t * p_image_header, const struct opj _cp * p_cp)
108 { 110 {
109 OPJ_UINT32 i, l_width, l_height; 111 OPJ_UINT32 i, l_width, l_height;
110 » OPJ_INT32 l_x0, l_y0, l_x1, l_y1; 112 » OPJ_UINT32 l_x0, l_y0, l_x1, l_y1;
111 » OPJ_INT32 l_comp_x0, l_comp_y0, l_comp_x1, l_comp_y1; 113 » OPJ_UINT32 l_comp_x0, l_comp_y0, l_comp_x1, l_comp_y1;
112 opj_image_comp_t* l_img_comp = NULL; 114 opj_image_comp_t* l_img_comp = NULL;
113 115
114 » l_x0 = opj_int_max((OPJ_INT32)p_cp->tx0 , (OPJ_INT32)p_image_header->x0) ; 116 » l_x0 = opj_uint_max(p_cp->tx0 , p_image_header->x0);
115 » l_y0 = opj_int_max((OPJ_INT32)p_cp->ty0 , (OPJ_INT32)p_image_header->y0) ; 117 » l_y0 = opj_uint_max(p_cp->ty0 , p_image_header->y0);
116 » l_x1 = opj_int_min((OPJ_INT32)(p_cp->tx0 + p_cp->tw * p_cp->tdx), (OPJ_I NT32)p_image_header->x1); 118 » l_x1 = p_cp->tx0 + (p_cp->tw - 1U) * p_cp->tdx; /* validity of p_cp memb ers used here checked in opj_j2k_read_siz. Can't overflow. */
117 » l_y1 = opj_int_min((OPJ_INT32)(p_cp->ty0 + p_cp->th * p_cp->tdy), (OPJ_I NT32)p_image_header->y1); 119 » l_y1 = p_cp->ty0 + (p_cp->th - 1U) * p_cp->tdy; /* can't overflow */
120 » l_x1 = opj_uint_min(opj_uint_adds(l_x1, p_cp->tdx), p_image_header->x1); /* use add saturated to prevent overflow */
121 » l_y1 = opj_uint_min(opj_uint_adds(l_y1, p_cp->tdy), p_image_header->y1); /* use add saturated to prevent overflow */
118 122
119 l_img_comp = p_image_header->comps; 123 l_img_comp = p_image_header->comps;
120 for (i = 0; i < p_image_header->numcomps; ++i) { 124 for (i = 0; i < p_image_header->numcomps; ++i) {
121 » » l_comp_x0 = opj_int_ceildiv(l_x0, (OPJ_INT32)l_img_comp->dx); 125 » » l_comp_x0 = opj_uint_ceildiv(l_x0, l_img_comp->dx);
122 » » l_comp_y0 = opj_int_ceildiv(l_y0, (OPJ_INT32)l_img_comp->dy); 126 » » l_comp_y0 = opj_uint_ceildiv(l_y0, l_img_comp->dy);
123 » » l_comp_x1 = opj_int_ceildiv(l_x1, (OPJ_INT32)l_img_comp->dx); 127 » » l_comp_x1 = opj_uint_ceildiv(l_x1, l_img_comp->dx);
124 » » l_comp_y1 = opj_int_ceildiv(l_y1, (OPJ_INT32)l_img_comp->dy); 128 » » l_comp_y1 = opj_uint_ceildiv(l_y1, l_img_comp->dy);
125 » » l_width = (OPJ_UINT32)opj_int_ceildivpow2(l_comp_x1 - l_comp_x0, (OPJ_INT32)l_img_comp->factor); 129 » » l_width = opj_uint_ceildivpow2(l_comp_x1 - l_comp_x0, l_img_co mp->factor);
126 » » l_height = (OPJ_UINT32)opj_int_ceildivpow2(l_comp_y1 - l_comp_y0 , (OPJ_INT32)l_img_comp->factor); 130 » » l_height = opj_uint_ceildivpow2(l_comp_y1 - l_comp_y0, l_img_co mp->factor);
127 l_img_comp->w = l_width; 131 l_img_comp->w = l_width;
128 l_img_comp->h = l_height; 132 l_img_comp->h = l_height;
129 » » l_img_comp->x0 = (OPJ_UINT32)l_comp_x0/*l_x0*/; 133 » » l_img_comp->x0 = l_comp_x0;
130 » » l_img_comp->y0 = (OPJ_UINT32)l_comp_y0/*l_y0*/; 134 » » l_img_comp->y0 = l_comp_y0;
131 ++l_img_comp; 135 ++l_img_comp;
132 } 136 }
133 } 137 }
134 138
135 139
136 /** 140 /**
137 * Copy only header of image and its component header (no data are copied) 141 * Copy only header of image and its component header (no data are copied)
138 * if dest image have data, they will be freed 142 * if dest image have data, they will be freed
139 * 143 *
140 * @param p_image_src the src image 144 * @param p_image_src the src image
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 comp->x0 = cmptparms[compno].x0; 233 comp->x0 = cmptparms[compno].x0;
230 comp->y0 = cmptparms[compno].y0; 234 comp->y0 = cmptparms[compno].y0;
231 comp->prec = cmptparms[compno].prec; 235 comp->prec = cmptparms[compno].prec;
232 comp->sgnd = cmptparms[compno].sgnd; 236 comp->sgnd = cmptparms[compno].sgnd;
233 comp->data = 0; 237 comp->data = 0;
234 } 238 }
235 } 239 }
236 240
237 return image; 241 return image;
238 } 242 }
OLDNEW
« no previous file with comments | « third_party/libopenjpeg20/function_list.c ('k') | third_party/libopenjpeg20/indexbox_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698