2 * Copyright (c) 2003-2004, Fran�ois-Olivier Devaux
3 * Copyright (c) 2002-2004, Communications and remote sensing Laboratory, Universite catholique de Louvain, Belgium
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
33 #ifndef DONT_HAVE_GETOPT
36 #include "compat/getopt.h"
38 #include "mj2_convert.h"
42 printf("HELP\n----\n\n");
43 printf("- the option -help displays the readme.txt file on screen\n\n");
46 printf("List of parameters for the MJ2 coder :\n");
49 ("- The markers COD and QCD are writed both of two in the main_header and never appear in the tile_header. The markers in the main header are : SOC SIZ COD QCD COM.\n");
52 ("- This coder can encode mega image, a test was made on a 24000x24000 pixels color image. You need enough disk space memory (twice the original) to encode the image. (i.e. for a 1.5 Gb image you need a minimum of 3Gb of disk memory)\n");
54 printf("REMARKS :\n");
55 printf("---------\n");
58 ("* the value of rate enter in the code line is the compression factor !\n");
59 printf("exemple :\n");
62 ("-r 20,10,1 means quality 1 : compress 20x, quality 2 : compress 10x and quality 3 : compress 1x = lossless\n");
64 printf("By default :\n");
65 printf("------------\n");
67 printf(" * lossless\n");
68 printf(" * 1 tile\n");
69 printf(" * size of precinct 2^15 x 2^15 (means 1 precinct)\n");
70 printf(" * size of code-block 64 x 64\n");
71 printf(" * Number of resolution : 6\n");
72 printf(" * No SOP marker in the codestream\n");
73 printf(" * No EPH marker in the codestream\n");
74 printf(" * No sub-sampling in x and y direction\n");
75 printf(" * No mode switch activated\n");
76 printf(" * progression order : LRCP\n");
77 printf(" * No index file\n");
78 printf(" * No ROI upshifted\n");
79 printf(" * No offset of the origin of the image\n");
80 printf(" * No offset of the origin of the tiles\n");
81 printf(" * Reversible DWT 5-3\n");
83 printf("Parameters :\n");
84 printf("------------\n");
87 ("-i : source file (-i source.pnm also *.pgm, *.ppm) required\n");
90 ("-o : destination file (-o dest.j2k or .jp2) required\n");
92 printf("-help : Display the help information optional\n ");
94 printf("-r : different rates (-r 20,10,5) optional\n ");
96 printf("-n : Number of resolution (-n 3) optional\n");
98 printf("-b : size of code block (-b 32,32) optional\n");
100 printf("-c : size of precinct (-c 128,128) optional\n");
102 printf("-t : size of tile (-t 512,512) optional\n");
105 ("-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] optional\n");
108 ("-s : subsampling factor (-s 2,2) [-s X,Y] optional\n");
111 ("-SOP : write SOP marker before each packet optional\n");
114 ("-EPH : write EPH marker after each header packet optional\n");
117 ("-M : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL) 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] optional\n");
119 (" for several mode switch you have to add the value of each mode you want\n");
121 (" ex : RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
124 ("-x : Create an index file *.Idx (-x index_name.Idx) optional\n");
127 ("-ROI:c=%%d,U=%%d : quantization indices upshifted for component c=%%d [%%d = 0,1,2]\n");
129 (" with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) optional\n");
132 ("-d : offset of the origin of the image (-d 150,300) optional\n");
135 ("-T : offset of the origin of the tiles (-T 100,75) optional\n");
137 printf("-I : Use the irreversible DWT 9-7 (-I) optional\n");
140 ("-W : Specify image width, height and the dx and dy subsampling of the Cb and Cr components for YUV files (default 352x288 and 420 Cif format)\n");
143 ("-F : Specify video frame rate (set to 25 by default)\n");
145 printf("IMPORTANT :\n");
146 printf("-----------\n");
148 printf("* subsampling bigger than 2 can produce error\n");
150 printf("The index file respect the structure below :\n");
151 printf("---------------------------------------------\n");
153 printf("Image_height Image_width\n");
154 printf("progression order\n");
155 printf("Tiles_size_X Tiles_size_Y\n");
156 printf("Components_nb\n");
157 printf("Layers_nb\n");
158 printf("decomposition_levels\n");
159 printf("Precincts_size_X Precincts_size_Y\n");
160 printf("Main_header_end_position\n");
161 printf("Codestream_size\n");
162 printf("Tile0 start_pos end_Theader end_pos\n");
163 printf("Tile1 '' '' ''\n");
165 printf("TileN '' '' ''\n");
166 printf("Tpacket_0 Tile layer res. comp. prec. start_pos end_pos\n");
168 printf("Tpacket_M '' '' '' '' '' '' ''\n");
171 int give_progression(char progression[4])
173 if (progression[0] == 'L' && progression[1] == 'R'
174 && progression[2] == 'C' && progression[3] == 'P') {
177 if (progression[0] == 'R' && progression[1] == 'L'
178 && progression[2] == 'C' && progression[3] == 'P') {
181 if (progression[0] == 'R' && progression[1] == 'P'
182 && progression[2] == 'C' && progression[3] == 'L') {
185 if (progression[0] == 'P' && progression[1] == 'C'
186 && progression[2] == 'R' && progression[3] == 'L') {
189 if (progression[0] == 'C' && progression[1] == 'P'
190 && progression[2] == 'R' && progression[3] == 'L') {
201 double dwt_norms_97[4][10] = {
202 {1.000, 1.965, 4.177, 8.403, 16.90, 33.84, 67.69, 135.3, 270.6, 540.9},
203 {2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
204 {2.022, 3.989, 8.355, 17.04, 34.27, 68.63, 137.3, 274.6, 549.0},
205 {2.080, 3.865, 8.307, 17.18, 34.71, 69.59, 139.3, 278.6, 557.2}
211 for (l = 0; a > 1; l++) {
217 void encode_stepsize(int stepsize, int numbps, int *expn, int *mant)
220 p = floorlog2(stepsize) - 13;
221 n = 11 - floorlog2(stepsize);
222 *mant = (n < 0 ? stepsize >> -n : stepsize << n) & 0x7ff;
226 void calc_explicit_stepsizes(j2k_tccp_t * tccp, int prec)
228 int numbands, bandno;
229 numbands = 3 * tccp->numresolutions - 2;
230 for (bandno = 0; bandno < numbands; bandno++) {
233 int resno, level, orient, gain;
234 resno = bandno == 0 ? 0 : (bandno - 1) / 3 + 1;
235 orient = bandno == 0 ? 0 : (bandno - 1) % 3 + 1;
236 level = tccp->numresolutions - 1 - resno;
238 tccp->qmfbid == 0 ? 0 : (orient ==
240 || orient == 2 ? 1 : 2));
241 if (tccp->qntsty == J2K_CCP_QNTSTY_NOQNT) {
244 double norm = dwt_norms_97[orient][level];
245 stepsize = (1 << (gain + 1)) / norm;
247 encode_stepsize((int) floor(stepsize * 8192.0), prec + gain,
248 &tccp->stepsizes[bandno].expn,
249 &tccp->stepsizes[bandno].mant);
253 int main(int argc, char **argv)
255 int NumResolution, numD_min; /* NumResolution : number of resolution */
256 int Tile_arg; /* Tile_arg = 0 (not in argument) ou = 1 (in argument) */
257 int CSty; /* CSty : coding style */
258 int Prog_order; /* progression order (default LRCP) */
260 int numpocs, numpocs_tile; /* Number of progression order change (POC) default 0 */
261 int prcw_init[J2K_MAXRLVLS]; /* Initialisation Precinct width */
262 int prch_init[J2K_MAXRLVLS]; /* Initialisation Precinct height */
263 //int prcw_init, prch_init; /* Initialisation precincts' size */
264 int cblockw_init, cblockh_init; /* Initialisation codeblocks' size */
265 int mode, value; /* Mode switch (cblk_style) */
266 int subsampling_dx, subsampling_dy; /* subsampling value for dx and dy */
267 int ROI_compno, ROI_shift; /* region of interrest */
268 int Dim[2]; /* portion of the image coded */
269 int TX0, TY0; /* tile off-set */
271 j2k_cp_t cp, cp_init; /* cp_init is used to initialise in multiple tiles */
272 j2k_tcp_t *tcp, *tcp_init; /* tcp_init is used to initialise in multiple tile */
273 j2k_poc_t POC[32]; /* POC : used in case of Progression order change */
282 int res_spec = 0; /* For various precinct sizes specification */
284 int w; /* Width of YUV file */
285 int h; /* Height of YUV file */
286 int CbCr_subsampling_dx; /* Sample rate of YUV 4:4:4 4:2:2 or 4:2:0 */
287 int CbCr_subsampling_dy; /* Sample rate of YUV 4:4:4 4:2:2 or 4:2:0 */
288 int output_image_type = -1;
289 int frame_rate; /* Video Frame Rate */
290 int numcomps; /* In YUV files, numcomps always considered as 3 */
291 int prec; /* In YUV files, precision always considered as 8 */
309 ROI_compno = -1; /* no ROI */
318 cp.fixed_quality = 0; //add fixed_quality
319 w = 352; // CIF default value
320 h = 288; // CIF default value
321 CbCr_subsampling_dx = 2; // CIF default value
322 CbCr_subsampling_dy = 2; // CIF default value
327 cp_init.tcps = (j2k_tcp_t *) malloc(sizeof(j2k_tcp_t)); /* initialisation if only one tile */
328 tcp_init = &cp_init.tcps[0];
329 tcp_init->numlayers = 0;
331 cp.intermed_file = 0; // Don't store each tile in a file during processing
334 int c = getopt(argc, argv,
335 "i:o:r:q:f:t:n:c:b:x:p:s:d:h:P:S:E:M:R:T:C:I:W:F:");
339 case 'i': /* IN fill */
352 if ((S1 == 'y' && S2 == 'u' && S3 == 'v')
353 || (S1 == 'Y' && S2 == 'U' && S3 == 'V')) {
358 "!! Unrecognized format for infile : %c%c%c [accept only *.yuv] !!\n\n",
362 /* ----------------------------------------------------- */
363 case 'o': /* OUT fill */
377 if ((S1 == 'm' && S2 == 'j' && S3 == '2')
378 || (S1 == 'M' && S2 == 'J' && S3 == '2'))
379 cp.JPEG2000_format = 2;
382 "Unknown output format image *.%c%c%c [only *.mj2]!! \n",
390 /* ----------------------------------------------------- */
391 case 'r': /* rates rates/distorsion */
393 while (sscanf(s, "%d", &tcp_init->rates[tcp_init->numlayers])
395 tcp_init->numlayers++;
396 while (*s && *s != ',') {
406 /* ----------------------------------------------------- */
407 case 'q': /* add fixed_quality */
410 (s, "%f", &tcp_init->distoratio[tcp_init->numlayers]) == 1) {
411 tcp_init->numlayers++;
412 while (*s && *s != ',') {
419 cp.fixed_quality = 1;
423 /* ----------------------------------------------------- */
424 case 'f': /* mod fixed_quality (before : -q) */
426 sscanf(s, "%d", &tcp_init->numlayers);
428 if (tcp_init->numlayers > 9)
431 (int *) malloc(tcp_init->numlayers * NumResolution * 3 *
434 for (i = 0; i < tcp_init->numlayers; i++) {
435 tcp_init->rates[i] = 1;
436 sscanf(s, "%d,", &cp.matrice[i * NumResolution * 3]);
438 if (cp.matrice[i * NumResolution * 3] > 9)
440 cp.matrice[i * NumResolution * 3 + 1] = 0;
441 cp.matrice[i * NumResolution * 3 + 2] = 0;
442 for (j = 1; j < NumResolution; j++) {
443 sscanf(s, "%d,%d,%d",
444 &cp.matrice[i * NumResolution * 3 + j * 3 + 0],
445 &cp.matrice[i * NumResolution * 3 + j * 3 + 1],
446 &cp.matrice[i * NumResolution * 3 + j * 3 + 2]);
448 if (cp.matrice[i * NumResolution * 3 + j * 3] > 9)
450 if (cp.matrice[i * NumResolution * 3 + j * 3 + 1] > 9)
452 if (cp.matrice[i * NumResolution * 3 + j * 3 + 2] > 9)
455 if (i < tcp_init->numlayers - 1)
460 /* ----------------------------------------------------- */
461 case 't': /* tiles */
462 sscanf(optarg, "%d,%d", &cp.tdx, &cp.tdy);
465 /* ----------------------------------------------------- */
466 case 'n': /* resolution */
467 sscanf(optarg, "%d", &NumResolution);
469 /* ----------------------------------------------------- */
470 case 'c': /* precinct dimension */
474 sscanf(s, "[%d,%d]%c", &prcw_init[res_spec],
475 &prch_init[res_spec], &sep);
478 s = strpbrk(s, "]") + 2;
479 } while (sep == ',');
481 /* ----------------------------------------------------- */
482 case 'b': /* code-block dimension */
483 sscanf(optarg, "%d,%d", &cblockw_init, &cblockh_init);
484 if (cblockw_init * cblockh_init > 4096 || cblockw_init > 1024
485 || cblockw_init < 4 || cblockh_init > 1024 || cblockh_init < 4) {
487 "!! Size of code_block error (option -b) !!\n\nRestriction :\n * width*height<=4096\n * 4<=width,height<= 1024\n\n");
491 /* ----------------------------------------------------- */
492 case 'x': /* creation of index file */
496 /* ----------------------------------------------------- */
497 case 'p': /* progression order */
499 for (i = 0; i < 4; i++) {
503 Prog_order = give_progression(progression);
505 if (Prog_order == -1) {
507 "Unrecognized progression order [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n");
511 /* ----------------------------------------------------- */
512 case 's': /* subsampling factor */
513 if (sscanf(optarg, "%d,%d", &subsampling_dx, &subsampling_dy)
516 "'-s' sub-sampling argument error ! [-s dx,dy]\n");
520 /* ----------------------------------------------------- */
521 case 'd': /* coordonnate of the reference grid */
522 if (sscanf(optarg, "%d,%d", &Dim[0], &Dim[1]) != 2) {
524 "-d 'coordonnate of the reference grid' argument error !! [-d x0,y0]\n");
528 /* ----------------------------------------------------- */
529 case 'h': /* Display an help description */
533 /* ----------------------------------------------------- */
535 fprintf(stderr, "/----------------------------------\\\n");
536 fprintf(stderr, "| POC option not fully tested !! |\n");
537 fprintf(stderr, "\\----------------------------------/\n");
540 while (sscanf(s, "T%d=%d,%d,%d,%d,%d,%s", &POC[numpocs].tile,
541 &POC[numpocs].resno0, &POC[numpocs].compno0,
542 &POC[numpocs].layno1, &POC[numpocs].resno1,
543 &POC[numpocs].compno1, POC[numpocs].progorder) == 7) {
544 POC[numpocs].prg = give_progression(POC[numpocs].progorder);
545 /* POC[numpocs].tile; */
547 while (*s && *s != '/') {
555 /* ------------------------------------------------------ */
556 case 'S': /* SOP marker */
559 /* ------------------------------------------------------ */
560 case 'E': /* EPH marker */
563 /* ------------------------------------------------------ */
564 case 'M': /* Mode switch pas tous au point !! */
565 if (sscanf(optarg, "%d", &value) == 1) {
566 for (i = 0; i <= 5; i++) {
567 int cache = value & (1 << i);
573 /* ------------------------------------------------------ */
575 if (sscanf(optarg, "OI:c=%d,U=%d", &ROI_compno, &ROI_shift) != 2) {
576 fprintf(stderr, "ROI error !! [-ROI:c='compno',U='shift']\n");
580 /* ------------------------------------------------------ */
581 case 'T': /* Tile offset */
582 if (sscanf(optarg, "%d,%d", &TX0, &TY0) != 2) {
583 fprintf(stderr, "-T 'tile offset' argument error !! [-T X0,Y0]");
587 /* ------------------------------------------------------ */
588 case 'C': /* Add a comment */
591 /* ------------------------------------------------------ */
592 case 'I': /* reversible or not */
595 /* ------------------------------------------------------ */
596 case 'W': /* Width and Height and Cb and Cr subsampling in case of YUV format files */
598 (optarg, "%d,%d,%d,%d", &w, &h, &CbCr_subsampling_dx,
599 &CbCr_subsampling_dy) != 4) {
600 fprintf(stderr, "-W argument error");
604 /* ------------------------------------------------------ */
605 case 'F': /* Video frame rate */
606 if (sscanf(optarg, "%d", &frame_rate) != 1) {
607 fprintf(stderr, "-F argument error");
611 /* ------------------------------------------------------ */
622 if (!infile || !outfile) {
624 "usage: frames_to_mj2 -i yuv-file -o mj2-file (+ options)\n");
628 if ((cp.disto_alloc || cp.fixed_alloc || cp.fixed_quality)
629 && (!(cp.disto_alloc ^ cp.fixed_alloc ^ cp.fixed_quality))) {
631 "Error: options -r -q and -f can not be used together !!\n");
633 } // mod fixed_quality
635 /* if no rate entered, lossless by default */
636 if (tcp_init->numlayers == 0) {
637 tcp_init->rates[tcp_init->numlayers] = 0; //MOD antonin : losslessbug
638 tcp_init->numlayers++;
642 if (TX0 > Dim[0] || TY0 > Dim[1]) {
644 "Error: Tile offset dimension is unnappropriate --> TX0(%d)<=IMG_X0(%d) TYO(%d)<=IMG_Y0(%d) \n",
645 TX0, Dim[0], TY0, Dim[1]);
649 for (i = 0; i < numpocs; i++) {
650 if (POC[i].prg == -1) {
652 "Unrecognized progression order in option -P (POC n %d) [LRCP, RLCP, RPCL, PCRL, CPRL] !!\n",
657 /* to respect profile - 0 */
658 /* ---------------------- */
661 x1 = !Dim[0] ? (w - 1) * subsampling_dx + 1 : Dim[0] + (w -
664 y1 = !Dim[1] ? (h - 1) * subsampling_dy + 1 : Dim[1] + (h -
669 cp.tw = int_ceildiv(x1 - cp.tx0, cp.tdx);
670 cp.th = int_ceildiv(y1 - cp.ty0, cp.tdy);
672 cp.tdx = x1 - cp.tx0;
673 cp.tdy = y1 - cp.ty0;
677 /* Initialization for PPM marker */
683 numcomps = 3; /* Because YUV files only have 3 components */
685 tcp_init->mct = 0; /* No component transform needed */
687 prec = 8; /* Because in YUV files, components have 8-bit depth */
689 /* Init the mutiple tiles */
690 /* ---------------------- */
691 cp.tcps = (j2k_tcp_t *) malloc(cp.tw * cp.th * sizeof(j2k_tcp_t));
693 for (tileno = 0; tileno < cp.tw * cp.th; tileno++) {
694 tcp = &cp.tcps[tileno];
695 tcp->numlayers = tcp_init->numlayers;
696 for (j = 0; j < tcp->numlayers; j++) {
697 if (cp.fixed_quality) // add fixed_quality
698 tcp->distoratio[j] = tcp_init->distoratio[j];
700 tcp->rates[j] = tcp_init->rates[j];
703 tcp->prg = Prog_order;
704 tcp->mct = tcp_init->mct;
706 tcp->ppt_data = NULL;
712 /* intialisation of POC */
714 for (i = 0; i < numpocs; i++) {
715 if (tileno == POC[i].tile - 1 || POC[i].tile == -1) {
716 tcp_poc = &tcp->pocs[numpocs_tile];
717 tcp_poc->resno0 = POC[numpocs_tile].resno0;
718 tcp_poc->compno0 = POC[numpocs_tile].compno0;
719 tcp_poc->layno1 = POC[numpocs_tile].layno1;
720 tcp_poc->resno1 = POC[numpocs_tile].resno1;
721 tcp_poc->compno1 = POC[numpocs_tile].compno1;
722 tcp_poc->prg = POC[numpocs_tile].prg;
723 tcp_poc->tile = POC[numpocs_tile].tile;
728 tcp->numpocs = numpocs_tile;
729 tcp->tccps = (j2k_tccp_t *) malloc(numcomps * sizeof(j2k_tccp_t));
731 for (i = 0; i < numcomps; i++) {
732 tccp = &tcp->tccps[i];
733 tccp->csty = CSty & 0x01; /* 0 => one precinct || 1 => custom precinct */
734 tccp->numresolutions = NumResolution;
735 tccp->cblkw = int_floorlog2(cblockw_init);
736 tccp->cblkh = int_floorlog2(cblockh_init);
737 tccp->cblksty = mode;
738 tccp->qmfbid = ir ? 0 : 1;
739 tccp->qntsty = ir ? J2K_CCP_QNTSTY_SEQNT : J2K_CCP_QNTSTY_NOQNT;
742 tccp->roishift = ROI_shift;
745 if (CSty & J2K_CCP_CSTY_PRT) {
747 for (j = tccp->numresolutions - 1; j >= 0; j--) {
749 if (prcw_init[p] < 1)
752 tccp->prcw[j] = int_floorlog2(prcw_init[p]);
754 if (prch_init[p] < 1)
757 tccp->prch[j] = int_floorlog2(prch_init[p]);
759 int size_prcw, size_prch;
760 size_prcw = prcw_init[res_spec - 1] >> (p - (res_spec - 1));
761 size_prch = prch_init[res_spec - 1] >> (p - (res_spec - 1));
765 tccp->prcw[j] = int_floorlog2(size_prcw);
769 tccp->prch[j] = int_floorlog2(size_prch);
772 /*printf("\nsize precinct pour level %d : %d,%d\n", j,
773 tccp->prcw[j], tccp->prch[j]); */
776 for (j = 0; j < tccp->numresolutions; j++) {
781 calc_explicit_stepsizes(tccp, prec);
785 movie.tk = (mj2_tk_t *) malloc(sizeof(mj2_tk_t));
790 movie.tk[0].imagefile = infile;
791 movie.tk[0].track_type = 0; // Video Track
792 movie.tk[0].track_ID = 1;
793 movie.mj2file = outfile;
794 movie.tk[0].subsampling_dx = subsampling_dx;
795 movie.tk[0].subsampling_dy = subsampling_dy;
796 movie.tk[0].Dim[0] = Dim[0];
797 movie.tk[0].Dim[1] = Dim[1];
800 movie.tk[0].CbCr_subsampling_dx = CbCr_subsampling_dx;
801 movie.tk[0].CbCr_subsampling_dy = CbCr_subsampling_dy;
802 movie.tk[0].sample_rate = frame_rate;
804 if (mj2_init_stdmovie(&movie)) {
805 fprintf(stderr, "Error with movie initialization");
808 if (mj2_encode(&movie, &cp, index)) {
809 fprintf(stderr, "Error encoding movie");
812 mj2_memory_free(&movie);
816 if (tcp_init->numlayers > 9)
818 for (tileno = 0; tileno < cp.tw * cp.th; tileno++)
819 free(cp.tcps[tileno].tccps);