~cosme/ubuntu/precise/freeimage/freeimage-3.15.1

« back to all changes in this revision

Viewing changes to Source/LibOpenJPEG/jp2.c

  • Committer: Stefano Rivera
  • Date: 2010-07-24 15:35:51 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: stefanor@ubuntu.com-20100724153551-6s3fth1653huk31a
Tags: upstream-3.13.1
ImportĀ upstreamĀ versionĀ 3.31.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
@return Returns true if successful, returns false otherwise
72
72
*/
73
73
static bool jp2_read_ftyp(opj_jp2_t *jp2, opj_cio_t *cio);
74
 
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index);
 
74
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info);
75
75
static bool jp2_read_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, unsigned int *j2k_codestream_length, unsigned int *j2k_codestream_offset);
76
76
static void jp2_write_jp(opj_cio_t *cio);
77
77
/**
404
404
        return true;
405
405
}
406
406
 
407
 
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index) {
 
407
static int jp2_write_jp2c(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
408
408
        unsigned int j2k_codestream_offset, j2k_codestream_length;
409
409
        opj_jp2_box_t box;
410
410
 
416
416
 
417
417
        /* J2K encoding */
418
418
        j2k_codestream_offset = cio_tell(cio);
419
 
        if(!j2k_encode(j2k, cio, image, index)) {
 
419
        if(!j2k_encode(j2k, cio, image, cstr_info)) {
420
420
                opj_event_msg(j2k->cinfo, EVT_ERROR, "Failed to encode image\n");
421
421
                return 0;
422
422
        }
507
507
/* ----------------------------------------------------------------------- */
508
508
 
509
509
opj_jp2_t* jp2_create_decompress(opj_common_ptr cinfo) {
510
 
        opj_jp2_t *jp2 = (opj_jp2_t*)opj_malloc(sizeof(opj_jp2_t));
 
510
        opj_jp2_t *jp2 = (opj_jp2_t*) opj_calloc(1, sizeof(opj_jp2_t));
511
511
        if(jp2) {
512
512
                jp2->cinfo = cinfo;
513
513
                /* create the J2K codec */
541
541
        /* further JP2 initializations go here */
542
542
}
543
543
 
544
 
opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio) {
 
544
opj_image_t* jp2_decode(opj_jp2_t *jp2, opj_cio_t *cio, opj_codestream_info_t *cstr_info) {
545
545
        opj_common_ptr cinfo;
546
546
        opj_image_t *image = NULL;
547
547
 
558
558
        }
559
559
 
560
560
        /* J2K decoding */
561
 
        image = j2k_decode(jp2->j2k, cio);
 
561
        image = j2k_decode(jp2->j2k, cio, cstr_info);
562
562
        if(!image) {
563
563
                opj_event_msg(cinfo, EVT_ERROR, "Failed to decode J2K image\n");
 
564
                return NULL;
564
565
        }
565
566
 
566
567
        /* Set Image Color Space */
686
687
 
687
688
}
688
689
 
689
 
bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, char *index) {
 
690
bool jp2_encode(opj_jp2_t *jp2, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) {
690
691
 
691
692
        /* JP2 encoding */
692
693
 
699
700
 
700
701
        /* J2K encoding */
701
702
 
702
 
        if(!jp2_write_jp2c(jp2, cio, image, index)) {
 
703
        if(!jp2_write_jp2c(jp2, cio, image, cstr_info)) {
703
704
                opj_event_msg(jp2->cinfo, EVT_ERROR, "Failed to encode image\n");
704
705
                return false;
705
706
        }