/normxcorr/trunk

To get this branch, use:
bzr branch http://suren.me/webbzr/normxcorr/trunk

« back to all changes in this revision

Viewing changes to dict_hw/src/dict_image.cpp

  • Committer: Suren A. Chilingaryan
  • Date: 2010-04-26 03:58:12 UTC
  • Revision ID: csa@dside.dyndns.org-20100426035812-st93op9yj551wi3b
Multipass mode and re-initialization fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
}
26
26
 
27
27
int dictImageFree(DICTContext ps) {
28
 
    if (ps->image_buf) dictImageFreeBuffer(ps, ps->image_type, ps->image_buf);
29
 
    if (ps->image2) free(ps->image2);
30
 
    if (ps->image) free(ps->image);
 
28
    if (ps->image_buf) {
 
29
        dictImageFreeBuffer(ps, ps->image_type, ps->image_buf);
 
30
        ps->image_buf = NULL;
 
31
    }
 
32
    if (ps->image2) {
 
33
        free(ps->image2);
 
34
        ps->image2 = NULL;
 
35
    }
 
36
    if (ps->image) {
 
37
        free(ps->image);
 
38
        ps->image = NULL;
 
39
    }
31
40
    
32
41
    return 0;
33
42
}
244
253
 
245
254
int dictImageLoadTemplateImage(DICTContext ps, const char *name) {
246
255
#ifdef DICT_TIFF_SUPPORT
 
256
    int err;
247
257
    uint32_t w, h;
248
258
 
249
259
#ifdef DICT_HW_MEASURE_TIMINGS
277
287
    ps->image = (unsigned char*)malloc(alloc_size * sizeof(unsigned char));
278
288
    ps->image2 = (unsigned char*)malloc(alloc_size * sizeof(unsigned char));
279
289
 
280
 
    dictSetDimensions(ps, w, h);    
281
 
    
282
290
    if ((!ps->image)||(!ps->image2)||(!ps->image_buf)) {
283
291
        reportError("Problem allocating memory for image %ix%i", w, h);
284
292
        return DICT_ERROR_MALLOC;
285
293
    }
286
294
 
 
295
    err = dictSetDimensions(ps, w, h);    
 
296
    if (err) return err;
 
297
 
287
298
    if (TIFFReadRGBAImage(tif, w, h, (uint32_t*)ps->image_buf, 0)) {
288
299
#ifdef DICT_HW_MEASURE_TIMINGS
289
300
        gettimeofday(&tv3, NULL);
305
316
#endif /* DICT_HW_MEASURE_TIMINGS */
306
317
 
307
318
    return 0;
308
 
#else
 
319
#else /* DICT_TIFF_SUPPORT */
309
320
    return DICT_ERROR_IMAGE;
310
321
#endif /* DICT_TIFF_SUPPORT */
311
322
}
340
351
    ps->time[14] += (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec) - time;
341
352
#endif /* DICT_HW_MEASURE_TIMINGS */
342
353
    return 0;
343
 
#else
 
354
#else /* DICT_TIFF_SUPPORT */
344
355
    return DICT_ERROR_IMAGE;
345
356
#endif /* DICT_TIFF_SUPPORT */
346
357
}