~rsalveti/libjpeg-turbo/libjpeg-turbo-trunk

« back to all changes in this revision

Viewing changes to jdarith.c

  • Committer: dcommander
  • Date: 2015-06-25 03:44:36 UTC
  • Revision ID: svn-v4:632fc199-4ca6-4c93-a231-07263d6284db:trunk:1582
Add a new libjpeg API function (jpeg_skip_scanlines()) to allow for partially decoding a JPEG image.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * This file was part of the Independent JPEG Group's software:
5
5
 * Developed 1997-2009 by Guido Vollbeding.
6
 
 * It was modified by The libjpeg-turbo Project to include only code relevant
7
 
 * to libjpeg-turbo.
 
6
 * libjpeg-turbo Modifications:
 
7
 * Copyright (C) 2015, D. R. Commander.
8
8
 * For conditions of distribution and use, see the accompanying README file.
9
9
 *
10
10
 * This file contains portable arithmetic entropy decoding routines for JPEG
516
516
  /* Outer loop handles each block in the MCU */
517
517
 
518
518
  for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
519
 
    block = MCU_data[blkn];
 
519
    block = MCU_data ? MCU_data[blkn] : NULL;
520
520
    ci = cinfo->MCU_membership[blkn];
521
521
    compptr = cinfo->cur_comp_info[ci];
522
522
 
563
563
      entropy->last_dc_val[ci] += v;
564
564
    }
565
565
 
566
 
    (*block)[0] = (JCOEF) entropy->last_dc_val[ci];
 
566
    if (block)
 
567
      (*block)[0] = (JCOEF) entropy->last_dc_val[ci];
567
568
 
568
569
    /* Sections F.2.4.2 & F.1.4.4.2: Decoding of AC coefficients */
569
570
 
607
608
      while (m >>= 1)
608
609
        if (arith_decode(cinfo, st)) v |= m;
609
610
      v += 1; if (sign) v = -v;
610
 
      (*block)[jpeg_natural_order[k]] = (JCOEF) v;
 
611
      if (block)
 
612
        (*block)[jpeg_natural_order[k]] = (JCOEF) v;
611
613
    }
612
614
  }
613
615