~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to extern/libopenjpeg/tcd.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "opj_includes.h"
34
34
 
35
35
void tcd_dump(FILE *fd, opj_tcd_t *tcd, opj_tcd_image_t * img) {
36
 
        int tileno, compno, resno, bandno, precno;//, cblkno;
 
36
        int tileno, compno, resno, bandno, precno;/*, cblkno;*/
37
37
 
38
38
        fprintf(fd, "image {\n");
39
39
        fprintf(fd, "  tw=%d, th=%d x0=%d x1=%d y0=%d y1=%d\n", 
290
290
                                        for (i = 0; i < res->pw * res->ph * 3; i++) {
291
291
                                                band->precincts[i].imsbtree = NULL;
292
292
                                                band->precincts[i].incltree = NULL;
 
293
                                                band->precincts[i].cblks.enc = NULL;
293
294
                                        }
294
295
                                        
295
296
                                        for (precno = 0; precno < res->pw * res->ph; precno++) {
418
419
                /* Modification of the RATE >> */
419
420
                for (j = 0; j < tcp->numlayers; j++) {
420
421
                        tcp->rates[j] = tcp->rates[j] ? 
421
 
                                                ((float) (tile->numcomps 
422
 
                                                                * (tile->x1 - tile->x0) 
423
 
                                                                * (tile->y1 - tile->y0) 
424
 
                                                                * image->comps[0].prec))/ 
425
 
                                                (tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy) 
426
 
                                                : 0;
 
422
                                cp->tp_on ? 
 
423
                                        (((float) (tile->numcomps 
 
424
                                        * (tile->x1 - tile->x0) 
 
425
                                        * (tile->y1 - tile->y0)
 
426
                                        * image->comps[0].prec))
 
427
                                        /(tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)) - (((tcd->cur_totnum_tp - 1) * 14 )/ tcp->numlayers)
 
428
                                        :
 
429
                                ((float) (tile->numcomps 
 
430
                                        * (tile->x1 - tile->x0) 
 
431
                                        * (tile->y1 - tile->y0) 
 
432
                                        * image->comps[0].prec))/ 
 
433
                                        (tcp->rates[j] * 8 * image->comps[0].dx * image->comps[0].dy)
 
434
                                        : 0;
427
435
 
428
436
                        if (tcp->rates[j]) {
429
437
                                if (j && tcp->rates[j] < tcp->rates[j - 1] + 10) {
584
592
                                                        cblk->y0 = int_max(cblkystart, prc->y0);
585
593
                                                        cblk->x1 = int_min(cblkxend, prc->x1);
586
594
                                                        cblk->y1 = int_min(cblkyend, prc->y1);
587
 
                                                        cblk->data = (unsigned char*) opj_calloc(8192, sizeof(unsigned char));
 
595
                                                        cblk->data = (unsigned char*) opj_calloc(8192+2, sizeof(unsigned char));
 
596
                                                        /* FIXME: mqc_init_enc and mqc_byteout underrun the buffer if we don't do this. Why? */
 
597
                                                        cblk->data += 2;
588
598
                                                        cblk->layers = (opj_tcd_layer_t*) opj_calloc(100, sizeof(opj_tcd_layer_t));
589
599
                                                        cblk->passes = (opj_tcd_pass_t*) opj_calloc(100, sizeof(opj_tcd_pass_t));
590
600
                                                }
647
657
                        tilec->y1 = int_ceildiv(tile->y1, image->comps[i].dy);
648
658
 
649
659
                        x0 = j == 0 ? tilec->x0 : int_min(x0, (unsigned int) tilec->x0);
650
 
                        y0 = j == 0 ? tilec->y0 : int_min(y0,   (unsigned int) tilec->x0);
 
660
                        y0 = j == 0 ? tilec->y0 : int_min(y0,   (unsigned int) tilec->y0);
651
661
                        x1 = j == 0 ? tilec->x1 : int_max(x1,   (unsigned int) tilec->x1);
652
662
                        y1 = j == 0 ? tilec->y1 : int_max(y1,   (unsigned int) tilec->y1);
653
663
                }
667
677
        opj_tcp_t *tcp;
668
678
        opj_tcd_tile_t *tile;
669
679
 
 
680
        OPJ_ARG_NOT_USED(cstr_info);
 
681
 
670
682
        tcd->cp = cp;
671
683
        
672
684
        tcp = &(cp->tcps[cp->tileno[tileno]]);
988
1000
        }
989
1001
}
990
1002
 
991
 
bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
 
1003
opj_bool tcd_rateallocate(opj_tcd_t *tcd, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
992
1004
        int compno, resno, bandno, precno, cblkno, passno, layno;
993
1005
        double min, max;
994
1006
        double cumdisto[100];   /* fixed_quality */
1085
1097
                        opj_t2_t *t2 = t2_create(tcd->cinfo, tcd->image, cp);
1086
1098
                        double thresh = 0;
1087
1099
 
1088
 
                        for (i = 0; i < 32; i++) {
 
1100
                        for (i = 0; i < 128; i++) {
1089
1101
                                int l = 0;
1090
1102
                                double distoachieved = 0;       /* fixed_quality */
1091
1103
                                thresh = (lo + hi) / 2;
1140
1152
                }
1141
1153
                
1142
1154
                if (!success) {
1143
 
                        return false;
 
1155
                        return OPJ_FALSE;
1144
1156
                }
1145
1157
                
1146
1158
                if(cstr_info) { /* Threshold for Marcela Index */
1152
1164
                cumdisto[layno] = (layno == 0) ? tcd_tile->distolayer[0] : (cumdisto[layno - 1] + tcd_tile->distolayer[layno]); 
1153
1165
        }
1154
1166
 
1155
 
        return true;
 
1167
        return OPJ_TRUE;
1156
1168
}
1157
1169
 
1158
1170
int tcd_encode_tile(opj_tcd_t *tcd, int tileno, unsigned char *dest, int len, opj_codestream_info_t *cstr_info) {
1304
1316
        return l;
1305
1317
}
1306
1318
 
1307
 
bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
 
1319
opj_bool tcd_decode_tile(opj_tcd_t *tcd, unsigned char *src, int len, int tileno, opj_codestream_info_t *cstr_info) {
1308
1320
        int l;
1309
1321
        int compno;
1310
1322
        int eof = 0;
1340
1352
                                }
1341
1353
                                else {
1342
1354
                                        cstr_info->tile[tileno].pdx[resno] = 15;
1343
 
                                        cstr_info->tile[tileno].pdx[resno] = 15;
 
1355
                                        cstr_info->tile[tileno].pdy[resno] = 15;
1344
1356
                                }
1345
1357
                        }
1346
1358
                }
1387
1399
                        if (tcd->image->comps[compno].resno_decoded < 0) {                              
1388
1400
                                opj_event_msg(tcd->cinfo, EVT_ERROR, "Error decoding tile. The number of resolutions to remove [%d+1] is higher than the number "
1389
1401
                                        " of resolutions in the original codestream [%d]\nModify the cp_reduce parameter.\n", tcd->cp->reduce, tile->comps[compno].numresolutions);
1390
 
                                return false;
 
1402
                                return OPJ_FALSE;
1391
1403
                        }
1392
1404
                }
1393
1405
 
1407
1419
 
1408
1420
        if (tcd->tcp->mct) {
1409
1421
                int n = (tile->comps[0].x1 - tile->comps[0].x0) * (tile->comps[0].y1 - tile->comps[0].y0);
1410
 
                if (tcd->tcp->tccps[0].qmfbid == 1) {
1411
 
                        mct_decode(
1412
 
                                        tile->comps[0].data,
1413
 
                                        tile->comps[1].data,
1414
 
                                        tile->comps[2].data, 
1415
 
                                        n);
1416
 
                } else {
1417
 
                        mct_decode_real(
1418
 
                                        (float*)tile->comps[0].data,
1419
 
                                        (float*)tile->comps[1].data,
1420
 
                                        (float*)tile->comps[2].data, 
1421
 
                                        n);
 
1422
 
 
1423
                if (tile->numcomps >= 3 ){
 
1424
                        if (tcd->tcp->tccps[0].qmfbid == 1) {
 
1425
                                mct_decode(
 
1426
                                                tile->comps[0].data,
 
1427
                                                tile->comps[1].data,
 
1428
                                                tile->comps[2].data,
 
1429
                                                n);
 
1430
                        } else {
 
1431
                                mct_decode_real(
 
1432
                                                (float*)tile->comps[0].data,
 
1433
                                                (float*)tile->comps[1].data,
 
1434
                                                (float*)tile->comps[2].data,
 
1435
                                                n);
 
1436
                        }
 
1437
                } else{
 
1438
                        opj_event_msg(tcd->cinfo, EVT_WARNING,"Number of components (%d) is inconsistent with a MCT. Skip the MCT step.\n",tile->numcomps);
1422
1439
                }
1423
1440
        }
1424
1441
 
1467
1484
        opj_event_msg(tcd->cinfo, EVT_INFO, "- tile decoded in %f s\n", tile_time);
1468
1485
 
1469
1486
        if (eof) {
1470
 
                return false;
 
1487
                return OPJ_FALSE;
1471
1488
        }
1472
1489
        
1473
 
        return true;
 
1490
        return OPJ_TRUE;
1474
1491
}
1475
1492
 
1476
1493
void tcd_free_decode(opj_tcd_t *tcd) {
1504
1521
}
1505
1522
 
1506
1523
 
 
1524