MCPcopy Create free account
hub / github.com/creatale/node-dv / octreeFindColorCell

Function octreeFindColorCell

deps/leptonica/src/colorquant1.c:1189–1247  ·  view source on GitHub ↗

! * \brief octreeFindColorCell() * * \param[in] octindex * \param[in] cqcaa * \param[out] pindex index of CTE; returned to set pixel value * \param[out] prval of CTE * \param[out] pgval of CTE * \param[out] pbval of CTE * \return 0 if OK; 1 on error * * * Notes: * (1) As this is in inner loop, we don't check input pointers! * (2) This trave

Source from the content-addressed store, hash-verified

1187 * </pre>
1188 */
1189static l_int32
1190octreeFindColorCell(l_int32 octindex,
1191 CQCELL ***cqcaa,
1192 l_int32 *pindex,
1193 l_int32 *prval,
1194 l_int32 *pgval,
1195 l_int32 *pbval)
1196{
1197l_int32 level;
1198l_int32 baseindex, subindex;
1199CQCELL *cqc, *cqcsub;
1200
1201 /* Use rgb values stored in the cubes; a little faster */
1202 for (level = 2; level < CQ_NLEVELS; level++) {
1203 getOctcubeIndices(octindex, level, &baseindex, &subindex);
1204 cqc = cqcaa[level][baseindex];
1205 cqcsub = cqcaa[level + 1][subindex];
1206 if (cqcsub->bleaf == 0) { /* use cell at level above */
1207 *pindex = cqc->index;
1208 *prval = cqc->rc;
1209 *pgval = cqc->gc;
1210 *pbval = cqc->bc;
1211 break;
1212 } else if (level == CQ_NLEVELS - 1) { /* reached the bottom */
1213 *pindex = cqcsub->index;
1214 *prval = cqcsub->rc;
1215 *pgval = cqcsub->gc;
1216 *pbval = cqcsub->bc;
1217 break;
1218 }
1219 }
1220
1221#if 0
1222 /* Generate rgb values for each cube on the fly; slower */
1223 for (level = 2; level < CQ_NLEVELS; level++) {
1224 l_int32 rv, gv, bv;
1225 getOctcubeIndices(octindex, level, &baseindex, &subindex);
1226 cqc = cqcaa[level][baseindex];
1227 cqcsub = cqcaa[level + 1][subindex];
1228 if (cqcsub->bleaf == 0) { /* use cell at level above */
1229 getRGBFromOctcube(baseindex, level, &rv, &gv, &bv);
1230 *pindex = cqc->index;
1231 *prval = rv;
1232 *pgval = gv;
1233 *pbval = bv;
1234 break;
1235 } else if (level == CQ_NLEVELS - 1) { /* reached the bottom */
1236 getRGBFromOctcube(subindex, level + 1, &rv, &gv, &bv);
1237 *pindex = cqcsub->index;
1238 *prval = rv;
1239 *pgval = gv;
1240 *pbval = bv;
1241 break;
1242 }
1243 }
1244#endif
1245
1246 return 0;

Callers 1

pixOctreeQuantizePixelsFunction · 0.85

Calls 2

getOctcubeIndicesFunction · 0.85
getRGBFromOctcubeFunction · 0.85

Tested by

no test coverage detected