Coverage Report

Created: 2026-04-09 07:06

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ghostpdl/jpegxr/r_tile_spatial.c
Line
Count
Source
1
/*************************************************************************
2
*
3
* This software module was originally contributed by Microsoft
4
* Corporation in the course of development of the
5
* ITU-T T.832 | ISO/IEC 29199-2 ("JPEG XR") format standard for
6
* reference purposes and its performance may not have been optimized.
7
*
8
* This software module is an implementation of one or more
9
* tools as specified by the JPEG XR standard.
10
*
11
* ITU/ISO/IEC give You a royalty-free, worldwide, non-exclusive
12
* copyright license to copy, distribute, and make derivative works
13
* of this software module or modifications thereof for use in
14
* products claiming conformance to the JPEG XR standard as
15
* specified by ITU-T T.832 | ISO/IEC 29199-2.
16
*
17
* ITU/ISO/IEC give users the same free license to this software
18
* module or modifications thereof for research purposes and further
19
* ITU/ISO/IEC standardization.
20
*
21
* Those intending to use this software module in products are advised
22
* that its use may infringe existing patents. ITU/ISO/IEC have no
23
* liability for use of this software module or modifications thereof.
24
*
25
* Copyright is not released for products that do not conform to
26
* to the JPEG XR standard as specified by ITU-T T.832 |
27
* ISO/IEC 29199-2.
28
*
29
******** Section to be removed when the standard is published ************
30
*
31
* Assurance that the contributed software module can be used
32
* (1) in the ITU-T "T.JXR" | ISO/IEC 29199 ("JPEG XR") standard once the
33
* standard has been adopted; and
34
* (2) to develop the JPEG XR standard:
35
*
36
* Microsoft Corporation and any subsequent contributors to the development
37
* of this software grant ITU/ISO/IEC all rights necessary to include
38
* the originally developed software module or modifications thereof in the
39
* JPEG XR standard and to permit ITU/ISO/IEC to offer such a royalty-free,
40
* worldwide, non-exclusive copyright license to copy, distribute, and make
41
* derivative works of this software module or modifications thereof for
42
* use in products claiming conformance to the JPEG XR standard as
43
* specified by ITU-T T.832 | ISO/IEC 29199-2, and to the extent that
44
* such originally developed software module or portions of it are included
45
* in an ITU/ISO/IEC standard. To the extent that the original contributors
46
* may own patent rights that would be required to make, use, or sell the
47
* originally developed software module or portions thereof included in the
48
* ITU/ISO/IEC standard in a conforming product, the contributors will
49
* assure ITU/ISO/IEC that they are willing to negotiate licenses under
50
* reasonable and non-discriminatory terms and conditions with
51
* applicants throughout the world and in accordance with their patent
52
* rights declarations made to ITU/ISO/IEC (if any).
53
*
54
* Microsoft, any subsequent contributors, and ITU/ISO/IEC additionally
55
* gives You a free license to this software module or modifications
56
* thereof for the sole purpose of developing the JPEG XR standard.
57
*
58
******** end of section to be removed when the standard is published *****
59
*
60
* Microsoft Corporation retains full right to modify and use the code
61
* for its own purpose, to assign or donate the code to a third party,
62
* and to inhibit third parties from using the code for products that
63
* do not conform to the JPEG XR standard as specified by ITU-T T.832 |
64
* ISO/IEC 29199-2.
65
*
66
* This copyright notice must be included in all copies or derivative
67
* works.
68
*
69
* Copyright (c) ITU-T/ISO/IEC 2008, 2009.
70
**********************************************************************/
71
72
#ifdef _MSC_VER
73
#pragma comment (user,"$Id: r_tile_spatial.c,v 1.10 2011-11-08 20:17:29 thor Exp $")
74
#endif
75
76
# include "jxr_priv.h"
77
# include <assert.h>
78
79
80
81
/*
82
* Process a single spatial time. The tx/ty is the coordintes of the
83
* tile in units of tiles. tx=0 for the first time, tx=1 for the
84
* second, and so forth.
85
*/
86
int _jxr_r_TILE_SPATIAL(jxr_image_t image, struct rbitstream*str,
87
                        unsigned tx, unsigned ty)
88
0
{
89
0
    int rc = 0;
90
0
    unsigned mx, my, plane_idx;
91
0
    unsigned char s0, s1, s2, s3;
92
0
    unsigned mb_height;
93
0
    unsigned mb_width;
94
95
0
    DEBUG("START TILE_SPATIAL at tile=[%u %u] bitpos=%zu\n", tx, ty, _jxr_rbitstream_bitpos(str));
96
97
    /* TILE_STARTCODE == 1 */
98
0
    s0 = _jxr_rbitstream_uint8(str); /* 0x00 */
99
0
    s1 = _jxr_rbitstream_uint8(str); /* 0x00 */
100
0
    s2 = _jxr_rbitstream_uint8(str); /* 0x01 */
101
0
    s3 = _jxr_rbitstream_uint8(str); /* reserved */
102
0
    DEBUG(" TILE_STARTCODE == %02x %02x %02x (reserved: %02x)\n", s0, s1, s2, s3);
103
0
    if (s0 != 0x00 || s1 != 0x00 || s2 != 0x01) {
104
0
      DEBUG(" TILE_LOWPASS ERROR: Invalid marker.\n");
105
0
      return JXR_EC_ERROR;
106
      /* FIX THOR: Invalid TILE_STARTCODE detected */
107
0
    }
108
109
0
    image->trim_flexbits = 0;
110
0
    if (TRIM_FLEXBITS_FLAG(image)) {
111
0
        image->trim_flexbits =_jxr_rbitstream_uint4(str);
112
0
        DEBUG(" TRIM_FLEXBITS = %u\n", image->trim_flexbits);
113
0
    }
114
115
    /* Read the tile header (which includes sub-headers for
116
    all the major passes). */
117
118
0
    _jxr_r_TILE_HEADER_DC(image, str, 0, tx, ty);
119
0
    if (image->bands_present != 3 /* DCONLY */) {
120
0
        _jxr_r_TILE_HEADER_LOWPASS(image, str, 0, tx, ty);
121
122
0
        if (image->bands_present != 2 /* NO_HIGHPASS */) {
123
0
            _jxr_r_TILE_HEADER_HIGHPASS(image, str, 0, tx, ty);
124
0
        }
125
0
    }
126
127
    /* If the alpha channel is present, then run another set of
128
    headers for the alpha channel. */
129
0
    if (ALPHACHANNEL_FLAG(image)) {
130
0
        _jxr_r_TILE_HEADER_DC(image->alpha, str, 1, tx, ty);
131
0
        if (image->bands_present != 3 /* DCONLY */) {
132
0
            _jxr_r_TILE_HEADER_LOWPASS(image->alpha, str, 1, tx, ty);
133
134
0
            if (image->bands_present != 2 /* NO_HIGHPASS */) {
135
0
                _jxr_r_TILE_HEADER_HIGHPASS(image->alpha, str, 1, tx, ty);
136
0
            }
137
0
        }
138
0
    }
139
140
141
    /* Now form and write out all the compressed data for the
142
    tile. This involves scanning the macroblocks, and the
143
    blocks within the macroblocks, generating bits as we go. */
144
145
0
    mb_height = EXTENDED_HEIGHT_BLOCKS(image);
146
0
    mb_width = EXTENDED_WIDTH_BLOCKS(image);
147
148
0
    if (TILING_FLAG(image)) {
149
0
        mb_height = image->tile_row_height[ty];
150
0
        mb_width = image->tile_column_width[tx];
151
0
    }
152
153
0
    for (my = 0 ; my < mb_height ; my += 1) {
154
0
        if (ALPHACHANNEL_FLAG(image))
155
0
            _jxr_rflush_mb_strip(image->alpha, tx, ty, my);
156
0
        _jxr_rflush_mb_strip(image, tx, ty, my);
157
158
0
        for (mx = 0 ; mx < mb_width ; mx += 1) {
159
0
        for(plane_idx = 0U; plane_idx < (ALPHACHANNEL_FLAG(image) ? 2U : 1U); plane_idx ++){
160
0
            int ch;
161
162
            /* There is one LP_QP_INDEX per macroblock (if any)
163
            and that value applies to all the channels.
164
            Same for HP_QP_INDEX. There is no DC_QP_INDEX
165
            because DC QP values are per-tile, not per MB. */
166
0
            int qp_index_lp = 0;
167
0
            int qp_index_hp = 0;
168
0
            jxr_image_t plane = (plane_idx == 0 ? image : image->alpha);
169
170
0
            if (plane->bands_present!=3) {
171
0
                if (plane->num_lp_qps>1 && !plane->lp_use_dc_qp) {
172
0
                    qp_index_lp = _jxr_DECODE_QP_INDEX(str, plane->num_lp_qps);
173
0
                    DEBUG(" DECODE_QP_INDEX(%d) --> %u (LP)\n", plane->num_lp_qps, qp_index_lp);
174
0
                }
175
0
                qp_index_hp = 0;
176
0
                if (plane->bands_present!=2 && plane->num_hp_qps>1) {
177
0
                    if (!plane->hp_use_lp_qp) {
178
0
                        qp_index_hp = _jxr_DECODE_QP_INDEX(str, plane->num_hp_qps);
179
0
                        DEBUG(" DECODE_QP_INDEX(%d) --> %u (HP)\n", plane->num_hp_qps, qp_index_hp);
180
0
                    }
181
0
                    else {
182
0
                        qp_index_hp = qp_index_lp;
183
0
                    }
184
0
                }
185
0
            }
186
0
            for (ch = 0 ; ch < plane->num_channels ; ch += 1) {
187
                /* Save the LP Quant *INDEX* here. Prediction needs it. */
188
0
                MACROBLK_CUR_LP_QUANT(plane,ch,tx,mx) = qp_index_lp;
189
0
                DEBUG(" LP_QUANT INDEX for tx=%u ty=%u ch=%u MBx=%d is %d\n", tx, ty, ch, mx,
190
0
                    MACROBLK_CUR_LP_QUANT(plane,ch,tx,mx));
191
0
                MACROBLK_CUR_HP_QUANT(plane,ch,tx,mx) = plane->hp_quant_ch[ch][qp_index_hp];
192
0
                DEBUG(" HP_QUANT VALUE for tx=%u ty=%u ch=%u MBx=%d is %d\n", tx, ty, ch, mx,
193
0
                    MACROBLK_CUR_HP_QUANT(plane,ch,tx,mx));
194
0
            }
195
196
0
            _jxr_r_MB_DC(plane, str, plane_idx, tx, ty, mx, my);
197
0
            if (plane->bands_present != 3 /* DCONLY */) {
198
0
                _jxr_r_MB_LP(plane, str, plane_idx, tx, ty, mx, my);
199
0
                _jxr_complete_cur_dclp(plane, tx, mx, my);
200
0
                if (plane->bands_present != 2 /* NOHIGHPASS */) {
201
0
                    rc = _jxr_r_MB_CBP(plane, str, plane_idx, tx, ty, mx, my);
202
0
                    if (rc < 0) {
203
0
                        DEBUG("r_MB_CBP returned ERROR rc=%d\n", rc);
204
0
                        return rc;
205
0
                    }
206
0
                    rc = _jxr_r_MB_HP(plane, str, plane_idx, tx, ty, mx, my);
207
0
                    if (rc < 0) {
208
0
                        DEBUG("r_MB_HP returned ERROR rc=%d\n", rc);
209
0
                        return rc;
210
0
                    }
211
0
                }
212
0
            } else {
213
0
                _jxr_complete_cur_dclp(plane, tx, mx, my);
214
0
            }
215
0
        }
216
0
    }
217
0
    }
218
219
    /* Flush the remaining strips to output. */
220
0
    if (tx+1 == image->tile_columns && ty+1 == image->tile_rows) {
221
0
        DEBUG(" Cleanup flush after last tile (tx=%d, ty=%d)\n", tx, ty);
222
0
        if (ALPHACHANNEL_FLAG(image))
223
0
            _jxr_rflush_mb_strip(image->alpha, tx, ty, mb_height);
224
0
        _jxr_rflush_mb_strip(image, tx, ty, mb_height);
225
226
0
        if (ALPHACHANNEL_FLAG(image))
227
0
            _jxr_rflush_mb_strip(image->alpha, tx, ty, mb_height+1);
228
0
        _jxr_rflush_mb_strip(image, tx, ty, mb_height+1);
229
230
0
        if (ALPHACHANNEL_FLAG(image))
231
0
            _jxr_rflush_mb_strip(image->alpha, tx, ty, mb_height+2);
232
0
        _jxr_rflush_mb_strip(image, tx, ty, mb_height+2);
233
234
0
        if (ALPHACHANNEL_FLAG(image))
235
0
            _jxr_rflush_mb_strip(image->alpha, tx, ty, mb_height+3);
236
0
        _jxr_rflush_mb_strip(image, tx, ty, mb_height+3);
237
0
    }
238
0
    _jxr_rbitstream_syncbyte(str);
239
0
    DEBUG("END TILE_SPATIAL\n");
240
0
    return 0;
241
0
}
242
243
/*
244
** Added by thor April 2nd 2010: Process one stripe at a time.
245
*/
246
int _jxr_r_TILE_SPATIAL_stripe(jxr_image_t image, struct rbitstream*str,
247
                               unsigned tx, unsigned ty)
248
0
{
249
0
  int rc = 0;
250
0
  unsigned char s0, s1, s2, s3;
251
252
0
  if (image->spatial_buffered_flag == 0) {
253
    /* Header is not yet parsed off. Do now.
254
     */
255
0
    DEBUG("START TILE_SPATIAL at tile=[%u %u] bitpos=%zu\n", tx, ty, _jxr_rbitstream_bitpos(str));
256
257
0
    if(INDEXTABLE_PRESENT_FLAG(image)) {
258
0
      _jxr_rbitstream_seek(str, image->tile_index_table[image->tile_columns * ty + tx]);
259
0
    }
260
    /* TILE_STARTCODE == 1 */
261
0
    s0 = _jxr_rbitstream_uint8(str); /* 0x00 */
262
0
    s1 = _jxr_rbitstream_uint8(str); /* 0x00 */
263
0
    s2 = _jxr_rbitstream_uint8(str); /* 0x01 */
264
0
    s3 = _jxr_rbitstream_uint8(str); /* reserved */
265
0
    DEBUG(" TILE_STARTCODE == %02x %02x %02x (reserved: %02x)\n", s0, s1, s2, s3);
266
0
    if (s0 != 0x00 || s1 != 0x00 || s2 != 0x01) {
267
0
      DEBUG(" TILE_LOWPASS ERROR: Invalid marker.\n");
268
0
      return JXR_EC_ERROR;
269
      /* FIX THOR: Invalid TILE_STARTCODE detected */
270
0
    }
271
272
0
    image->trim_flexbits = 0;
273
0
    if (TRIM_FLEXBITS_FLAG(image)) {
274
0
      image->trim_flexbits =_jxr_rbitstream_uint4(str);
275
0
      DEBUG(" TRIM_FLEXBITS = %u\n", image->trim_flexbits);
276
0
    }
277
278
    /* Read the tile header (which includes sub-headers for
279
       all the major passes). */
280
281
0
    _jxr_r_TILE_HEADER_DC(image, str, 0, tx, ty);
282
0
    if (image->bands_present != 3 /* DCONLY */) {
283
0
      _jxr_r_TILE_HEADER_LOWPASS(image, str, 0, tx, ty);
284
285
0
      if (image->bands_present != 2 /* NO_HIGHPASS */) {
286
0
        _jxr_r_TILE_HEADER_HIGHPASS(image, str, 0, tx, ty);
287
0
      }
288
0
    }
289
290
    /* If the alpha channel is present, then run another set of
291
    headers for the alpha channel. */
292
0
    if (ALPHACHANNEL_FLAG(image)) {
293
0
      _jxr_r_TILE_HEADER_DC(image->alpha, str, 1, tx, ty);
294
0
      if (image->bands_present != 3 /* DCONLY */) {
295
0
        _jxr_r_TILE_HEADER_LOWPASS(image->alpha, str, 1, tx, ty);
296
297
0
        if (image->bands_present != 2 /* NO_HIGHPASS */) {
298
0
          _jxr_r_TILE_HEADER_HIGHPASS(image->alpha, str, 1, tx, ty);
299
0
        }
300
0
      }
301
0
    }
302
303
304
    /* Now form and write out all the compressed data for the
305
    tile. This involves scanning the macroblocks, and the
306
    blocks within the macroblocks, generating bits as we go. */
307
0
    {
308
0
      unsigned mb_height = EXTENDED_HEIGHT_BLOCKS(image);
309
0
      unsigned mb_width = EXTENDED_WIDTH_BLOCKS(image);
310
311
0
      if (TILING_FLAG(image)) {
312
0
        mb_height = image->tile_row_height[ty];
313
0
        mb_width = image->tile_column_width[tx];
314
0
      }
315
316
0
      image->spatial_mb_height = mb_height;
317
0
      image->spatial_mb_width  = mb_width;
318
0
    }
319
    /*
320
    ** Done with the header. Initialize for the loop below.
321
    */
322
0
    image->spatial_buffered_flag = 1;
323
0
    image->stripe_my             = 0;
324
0
    image->cleanup_state         = 0;
325
0
    image->output_sent           = 0;
326
    // runs into the following.
327
0
  }
328
329
0
  switch(image->cleanup_state) {
330
0
  case 0:
331
0
    do {
332
0
      unsigned mx, plane_idx, my = image->stripe_my;
333
0
      unsigned mb_width = image->spatial_mb_width;
334
      /*
335
        for (my = 0 ; my < mb_height ; my += 1) {
336
      */
337
0
      if (ALPHACHANNEL_FLAG(image))
338
0
        _jxr_rflush_mb_strip(image->alpha, tx, ty, my);
339
0
      _jxr_rflush_mb_strip(image, tx, ty, my);
340
341
0
      for (mx = 0 ; mx < mb_width ; mx += 1) {
342
0
        for(plane_idx = 0U; plane_idx < (ALPHACHANNEL_FLAG(image) ? 2U : 1U); plane_idx ++){
343
0
          int ch;
344
345
          /* There is one LP_QP_INDEX per macroblock (if any)
346
             and that value applies to all the channels.
347
             Same for HP_QP_INDEX. There is no DC_QP_INDEX
348
             because DC QP values are per-tile, not per MB. */
349
0
          int qp_index_lp = 0;
350
0
          int qp_index_hp = 0;
351
0
          jxr_image_t plane = (plane_idx == 0 ? image : image->alpha);
352
353
0
          if (plane->bands_present!=3) {
354
0
            if (plane->num_lp_qps>1 && !plane->lp_use_dc_qp) {
355
0
              qp_index_lp = _jxr_DECODE_QP_INDEX(str, plane->num_lp_qps);
356
0
              DEBUG(" DECODE_QP_INDEX(%d) --> %u (LP)\n", plane->num_lp_qps, qp_index_lp);
357
0
            }
358
0
            qp_index_hp = 0;
359
0
            if (plane->bands_present!=2 && plane->num_hp_qps>1) {
360
0
              if (!plane->hp_use_lp_qp) {
361
0
                qp_index_hp = _jxr_DECODE_QP_INDEX(str, plane->num_hp_qps);
362
0
                DEBUG(" DECODE_QP_INDEX(%d) --> %u (HP)\n", plane->num_hp_qps, qp_index_hp);
363
0
              }
364
0
              else {
365
0
                qp_index_hp = qp_index_lp;
366
0
              }
367
0
            }
368
0
          }
369
0
          for (ch = 0 ; ch < plane->num_channels ; ch += 1) {
370
            /* Save the LP Quant *INDEX* here. Prediction needs it. */
371
0
            MACROBLK_CUR_LP_QUANT(plane,ch,tx,mx) = qp_index_lp;
372
0
            DEBUG(" LP_QUANT INDEX for tx=%u ty=%u ch=%u MBx=%d is %d\n", tx, ty, ch, mx,
373
0
                  MACROBLK_CUR_LP_QUANT(plane,ch,tx,mx));
374
0
            MACROBLK_CUR_HP_QUANT(plane,ch,tx,mx) = plane->hp_quant_ch[ch][qp_index_hp];
375
0
            DEBUG(" HP_QUANT VALUE for tx=%u ty=%u ch=%u MBx=%d is %d\n", tx, ty, ch, mx,
376
0
                  MACROBLK_CUR_HP_QUANT(plane,ch,tx,mx));
377
0
          }
378
379
0
          _jxr_r_MB_DC(plane, str, plane_idx, tx, ty, mx, my);
380
0
          if (plane->bands_present != 3 /* DCONLY */) {
381
0
            _jxr_r_MB_LP(plane, str, plane_idx, tx, ty, mx, my);
382
0
            _jxr_complete_cur_dclp(plane, tx, mx, my);
383
0
            if (plane->bands_present != 2 /* NOHIGHPASS */) {
384
0
              rc = _jxr_r_MB_CBP(plane, str, plane_idx, tx, ty, mx, my);
385
0
              if (rc < 0) {
386
0
                DEBUG("r_MB_CBP returned ERROR rc=%d\n", rc);
387
0
                return rc;
388
0
              }
389
0
              rc = _jxr_r_MB_HP(plane, str, plane_idx, tx, ty, mx, my);
390
0
              if (rc < 0) {
391
0
                DEBUG("r_MB_HP returned ERROR rc=%d\n", rc);
392
0
                return rc;
393
0
              }
394
0
            }
395
0
          } else {
396
0
            _jxr_complete_cur_dclp(plane, tx, mx, my);
397
0
          }
398
0
        }
399
0
      }
400
      /*
401
      ** Advance to the next MB row.
402
      */
403
0
      image->stripe_my++;
404
      /*
405
      ** The flush happens only as part of the last tile, so continue iterating
406
      ** until that tile is hit.
407
      */
408
0
    } while (image->stripe_my < image->spatial_mb_height && image->output_sent == 0);
409
410
    /*
411
    ** End of tile reached? If so, get the sycn marker
412
    */
413
0
    if (image->stripe_my == image->spatial_mb_height)
414
0
      _jxr_rbitstream_syncbyte(str);
415
416
    /*
417
    ** If this is an intermediate tile and not the right edge, continue with the next tile.
418
    */
419
0
    if (tx+1 != image->tile_columns) {
420
0
      image->spatial_buffered_flag = 0;
421
0
      image->stripe_my             = 0;
422
0
      return 1;
423
0
    }
424
    /*
425
    ** Otherwise, a stripe is complete, go to the user.
426
    */
427
0
    if (image->stripe_my < image->spatial_mb_height && image->output_sent) {
428
0
      image->output_sent = 0;
429
0
      return 0; /* not yet done with this strip, but return to the user. */
430
0
    }
431
0
    assert(image->stripe_my == image->spatial_mb_height);
432
    /*
433
    ** Done with this tile, go to the next. We're done in case this is not the last tile,
434
    ** otherwise iterate on until we get to the last one.
435
    */
436
0
    if (tx+1 == image->tile_columns && ty+1 == image->tile_rows) {
437
      // Last tile row. Continue with cleanup.
438
0
      image->cleanup_state = 1;
439
0
    } else {
440
0
      image->spatial_buffered_flag = 0;
441
0
      image->stripe_my             = 0;
442
0
      return JXR_EC_DONE;
443
0
    }
444
0
    if (image->output_sent)
445
0
      return 0;
446
    // runs into the following
447
0
  case 1:
448
    /* Flush the remaining strips to output. */
449
0
    if (tx+1 == image->tile_columns && ty+1 == image->tile_rows) {
450
0
      DEBUG(" Cleanup flush after last tile (tx=%d, ty=%d)\n", tx, ty);
451
0
      if (ALPHACHANNEL_FLAG(image))
452
0
        _jxr_rflush_mb_strip(image->alpha, tx, ty, image->spatial_mb_height);
453
0
      _jxr_rflush_mb_strip(image, tx, ty, image->spatial_mb_height);
454
0
      image->cleanup_state++;
455
0
      if (image->output_sent) {
456
0
        image->output_sent = 0;
457
0
        return 0;
458
0
      }
459
0
    } else {
460
0
      return 1;
461
0
    }
462
    // runs into the following
463
0
  case 2:
464
0
    if (tx+1 == image->tile_columns && ty+1 == image->tile_rows) {
465
0
      if (ALPHACHANNEL_FLAG(image))
466
0
        _jxr_rflush_mb_strip(image->alpha, tx, ty, image->spatial_mb_height+1);
467
0
      _jxr_rflush_mb_strip(image, tx, ty, image->spatial_mb_height+1);
468
0
      image->cleanup_state++;
469
0
      if (image->output_sent) {
470
0
        image->output_sent = 0;
471
0
        return 0;
472
0
      }
473
0
    } else {
474
0
      return 1;
475
0
    }
476
    // runs into the following
477
0
  case 3:
478
0
    if (tx+1 == image->tile_columns && ty+1 == image->tile_rows) {
479
0
      if (ALPHACHANNEL_FLAG(image))
480
0
        _jxr_rflush_mb_strip(image->alpha, tx, ty, image->spatial_mb_height+2);
481
0
      _jxr_rflush_mb_strip(image, tx, ty, image->spatial_mb_height+2);
482
0
      image->cleanup_state++;
483
0
      if (image->output_sent) {
484
0
        image->output_sent = 0;
485
0
        return 0;
486
0
      }
487
0
    } else {
488
0
      return 1;
489
0
    }
490
    // runs into the following
491
0
  case 4:
492
0
    if (tx+1 == image->tile_columns && ty+1 == image->tile_rows) {
493
0
      if (ALPHACHANNEL_FLAG(image))
494
0
        _jxr_rflush_mb_strip(image->alpha, tx, ty, image->spatial_mb_height+3);
495
0
      _jxr_rflush_mb_strip(image, tx, ty, image->spatial_mb_height+3);
496
0
      image->cleanup_state++;
497
0
       if (image->output_sent) {
498
0
        image->output_sent = 0;
499
0
        return 0;
500
0
      }
501
0
    } else {
502
0
      return 1;
503
0
    }
504
    // runs into the following
505
0
  default:
506
0
    image->spatial_buffered_flag = 0;
507
0
    image->stripe_my             = 0;
508
0
    return JXR_EC_DONE;
509
0
  }
510
0
}
511
512
513
/*
514
* $Log: r_tile_spatial.c,v $
515
* Revision 1.10  2011-11-08 20:17:29  thor
516
* Merged a couple of fixes from the JNB.
517
*
518
* Revision 1.9  2011-04-28 08:45:43  thor
519
* Fixed compiler warnings, ported to gcc 4.4, removed obsolete files.
520
*
521
* Revision 1.8  2010-05-01 11:16:08  thor
522
* Fixed the tiff tag order. Added spatial/line mode.
523
*
524
* Revision 1.7  2010-03-31 07:50:59  thor
525
* Replaced by the latest MS version.
526
*
527
* Revision 1.55 2009/05/29 12:00:00 microsoft
528
* Reference Software v1.6 updates.
529
*
530
* Revision 1.54 2009/04/13 12:00:00 microsoft
531
* Reference Software v1.5 updates.
532
*
533
* Revision 1.53 2008/03/20 22:39:41 steve
534
* Fix various debug prints of QP data.
535
*
536
* Revision 1.52 2008/03/20 18:11:25 steve
537
* Handle case of NumLPQP==1 and NumHPQPS>1
538
*
539
* Revision 1.51 2008/03/18 21:09:12 steve
540
* Fix distributed color prediction.
541
*
542
* Revision 1.50 2008/03/07 19:00:52 steve
543
* Improved comments.
544
*
545
* Revision 1.49 2008/03/06 22:47:39 steve
546
* Clean up parsing/encoding of QP counts
547
*
548
* Revision 1.48 2008/03/06 02:05:48 steve
549
* Distributed quantization
550
*
551
* Revision 1.47 2008/02/26 23:52:44 steve
552
* Remove ident for MS compilers.
553
*
554
* Revision 1.46 2007/11/26 01:47:15 steve
555
* Add copyright notices per MS request.
556
*
557
* Revision 1.45 2007/11/21 23:26:14 steve
558
* make all strip buffers store MB data.
559
*
560
* Revision 1.44 2007/11/20 17:08:02 steve
561
* Fix SPATIAL processing of QUANT values for color.
562
*
563
* Revision 1.43 2007/11/16 21:33:48 steve
564
* Store MB Quant, not qp_index.
565
*
566
* Revision 1.42 2007/11/16 20:03:57 steve
567
* Store MB Quant, not qp_index.
568
*
569
* Revision 1.41 2007/11/16 00:29:06 steve
570
* Support FREQUENCY mode HP and FLEXBITS
571
*
572
* Revision 1.40 2007/11/14 23:56:17 steve
573
* Fix TILE ordering, using seeks, for FREQUENCY mode.
574
*
575
* Revision 1.39 2007/11/14 00:17:27 steve
576
* Fix parsing of QP indices.
577
*
578
* Revision 1.38 2007/11/13 03:27:24 steve
579
* Add Frequency mode LP support.
580
*
581
* Revision 1.37 2007/11/12 23:21:55 steve
582
* Infrastructure for frequency mode ordering.
583
*
584
* Revision 1.36 2007/11/08 19:38:38 steve
585
* Get stub DCONLY compression to work.
586
*
587
* Revision 1.35 2007/11/01 21:09:40 steve
588
* Multiple rows of tiles.
589
*
590
* Revision 1.34 2007/10/31 21:20:54 steve
591
* Init, not Adapt, on tile boundaries.
592
*
593
* Revision 1.33 2007/10/30 21:32:46 steve
594
* Support for multiple tile columns.
595
*
596
* Revision 1.32 2007/10/19 16:20:21 steve
597
* Parse YUV420 HP
598
*
599
* Revision 1.31 2007/10/04 23:03:26 steve
600
* HP blocks uf YUV42X chroma are not shuffled.
601
*
602
* Revision 1.30 2007/10/04 00:30:47 steve
603
* Fix prediction of HP CBP for YUV422 data.
604
*
605
* Revision 1.29 2007/10/02 20:36:29 steve
606
* Fix YUV42X DC prediction, add YUV42X HP parsing.
607
*
608
* Revision 1.28 2007/10/01 20:39:34 steve
609
* Add support for YUV422 LP bands.
610
*
611
* Revision 1.27 2007/09/18 17:00:50 steve
612
* Fix bad calculation of lap_mean for chroma.
613
*
614
* Revision 1.26 2007/09/13 23:12:34 steve
615
* Support color HP bands.
616
*
617
* Revision 1.25 2007/09/12 01:09:24 steve
618
* Dump the TRIM_FLEXBITS value.
619
*
620
* Revision 1.24 2007/09/11 01:06:12 steve
621
* Forgot to properly save LP data.
622
*
623
* Revision 1.23 2007/09/11 00:40:06 steve
624
* Fix rendering of chroma to add the missing *2.
625
* Fix handling of the chroma LP samples
626
* Parse some of the HP CBP data in chroma.
627
*
628
* Revision 1.22 2007/09/10 23:42:00 steve
629
* Fix LP processing steps when color involved.
630
*
631
* Revision 1.21 2007/09/08 01:01:44 steve
632
* YUV444 color parses properly.
633
*
634
* Revision 1.20 2007/09/04 22:48:09 steve
635
* Fix calculation of flex bits on 0 coefficients.
636
*
637
* Revision 1.19 2007/09/04 19:10:46 steve
638
* Finish level1 overlap filtering.
639
*
640
* Revision 1.18 2007/08/31 23:31:49 steve
641
* Initialize CBP VLC tables at the right time.
642
*
643
* Revision 1.17 2007/08/31 23:20:57 steve
644
* Dump MB_CBP details.
645
*
646
* Revision 1.16 2007/08/15 01:54:11 steve
647
* Add level2 filter to decoder.
648
*
649
* Revision 1.15 2007/08/13 22:24:43 steve
650
* Fix Reset Context of absLevelInd.
651
*
652
* Revision 1.14 2007/07/31 15:27:19 steve
653
* Get transpose of FLEXBITS right.
654
*
655
* Revision 1.13 2007/07/30 23:09:57 steve
656
* Interleave FLEXBITS within HP block.
657
*
658
* Revision 1.12 2007/07/24 20:56:28 steve
659
* Fix HP prediction and model bits calculations.
660
*
661
* Revision 1.11 2007/07/21 00:25:48 steve
662
* snapshot 2007 07 20
663
*
664
* Revision 1.10 2007/07/12 22:48:17 steve
665
* Decode FLEXBITS
666
*
667
* Revision 1.9 2007/07/11 00:53:36 steve
668
* HP adaptation and precition corrections.
669
*
670
* Revision 1.8 2007/07/06 23:18:41 steve
671
* calculate and propagate HP band predictions.
672
*
673
* Revision 1.7 2007/07/05 20:19:13 steve
674
* Fix accumulation of HP CBP, and add HP predictions.
675
*
676
* Revision 1.6 2007/07/03 20:45:11 steve
677
* Parse and place HP data.
678
*
679
* Revision 1.5 2007/06/28 20:03:11 steve
680
* LP processing seems to be OK now.
681
*
682
* Revision 1.4 2007/06/21 17:31:22 steve
683
* Successfully parse LP components.
684
*
685
* Revision 1.3 2007/06/11 20:00:09 steve
686
* Parse FLEXBITS
687
*
688
* Revision 1.2 2007/06/07 18:53:06 steve
689
* Parse HP coeffs that are all 0.
690
*
691
* Revision 1.1 2007/06/06 17:19:12 steve
692
* Introduce to CVS.
693
*
694
*/
695