示例#1
0
read_tile_header_lp (j_image_ptr iinfo, jxr_image_plane_header * plane_hdr, jxr_image_plane_vars * plane_vars )
{
  /* Check that low pass QPs aren't the same for all tiles */
  if (plane_hdr->lp_image_plane_uniform_flag == FALSE) {
    
    UINT8 b;
    INPUT_VARS(iinfo);
    
    /* Check if a new QP set is present */
    INPUT_BITS((j_common_ptr) iinfo, b, 1, return FALSE);
    boolean use_dc_qp_flag = b;
    
    if (use_dc_qp_flag == FALSE) {
      
      /* Get number of low pass QPs */
      INPUT_BITS((j_common_ptr) iinfo, b, 4, return FALSE);
      plane_vars->num_lp_qps = b + 1;
      
      /* Parse QP set */
      INPUT_SYNC(iinfo);
      parse_lp_qp(  iinfo,
                    plane_vars->num_components,
                    plane_vars->num_lp_qps,
                    &plane_hdr->lp_qp );    
    }
示例#2
0
static boolean handle_app1(j_decompress_ptr cinfo)
{
	INT32 length; /* initialized by the macro */
	INT32 i;
	char neogeo[128];

	INPUT_VARS(cinfo);

	INPUT_2BYTES(cinfo, length, return false);
	length -= 2;

	if (length < 16) {
		for (i = 0; i < length; i++) {
			INPUT_BYTE(cinfo, neogeo[i], return false);
		}
		length = 0;
		if (STREQLEN(neogeo, "NeoGeo", 6)) {
			struct NeoGeo_Word *neogeo_word = (struct NeoGeo_Word *)(neogeo + 6);
			ibuf_quality = neogeo_word->quality;
		}
	}
	INPUT_SYNC(cinfo);  /* do before skip_input_data */
	if (length > 0) {
		(*cinfo->src->skip_input_data)(cinfo, length);
	}
	return true;
}
示例#3
0
LOCAL           boolean get_sof(j_decompress_ptr cinfo, boolean is_prog, boolean is_arith)
/* Process a SOFn marker */
{
	INT32           length;
	int             c, ci;
	jpeg_component_info *compptr;

	INPUT_VARS(cinfo);

	cinfo->progressive_mode = is_prog;
	cinfo->arith_code = is_arith;

	INPUT_2BYTES(cinfo, length, return FALSE);

	INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);
	INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);
	INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);
	INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);

	length -= 8;

	TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker, (int)cinfo->image_width, (int)cinfo->image_height, cinfo->num_components);

	if(cinfo->marker->saw_SOF)
		ERREXIT(cinfo, JERR_SOF_DUPLICATE);

	/* We don't support files in which the image height is initially specified */
	/* as 0 and is later redefined by DNL.  As long as we have to check that,  */
	/* might as well have a general sanity check. */
	if(cinfo->image_height <= 0 || cinfo->image_width <= 0 || cinfo->num_components <= 0)
		ERREXIT(cinfo, JERR_EMPTY_IMAGE);

	if(length != (cinfo->num_components * 3))
		ERREXIT(cinfo, JERR_BAD_LENGTH);

	if(cinfo->comp_info == NULL)	/* do only once, even if suspend */
		cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
			((j_common_ptr) cinfo, JPOOL_IMAGE, cinfo->num_components * SIZEOF(jpeg_component_info));

	for(ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++)
	{
		compptr->component_index = ci;
		INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
		INPUT_BYTE(cinfo, c, return FALSE);
		compptr->h_samp_factor = (c >> 4) & 15;
		compptr->v_samp_factor = (c) & 15;
		INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);

		TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
				 compptr->component_id, compptr->h_samp_factor, compptr->v_samp_factor, compptr->quant_tbl_no);
	}

	cinfo->marker->saw_SOF = TRUE;

	INPUT_SYNC(cinfo);
	return TRUE;
}
示例#4
0
METHODDEF       boolean get_app0(j_decompress_ptr cinfo)
/* Process an APP0 marker */
{
#define JFIF_LEN 14
	INT32           length;
	UINT8           b[JFIF_LEN];
	int             buffp;

	INPUT_VARS(cinfo);

	INPUT_2BYTES(cinfo, length, return FALSE);
	length -= 2;

	/* See if a JFIF APP0 marker is present */

	if(length >= JFIF_LEN)
	{
		for(buffp = 0; buffp < JFIF_LEN; buffp++)
			INPUT_BYTE(cinfo, b[buffp], return FALSE);
		length -= JFIF_LEN;

		if(b[0] == 0x4A && b[1] == 0x46 && b[2] == 0x49 && b[3] == 0x46 && b[4] == 0)
		{
			/* Found JFIF APP0 marker: check version */
			/* Major version must be 1, anything else signals an incompatible change.
			 * We used to treat this as an error, but now it's a nonfatal warning,
			 * because some bozo at Hijaak couldn't read the spec.
			 * Minor version should be 0..2, but process anyway if newer.
			 */
			if(b[5] != 1)
				WARNMS2(cinfo, JWRN_JFIF_MAJOR, b[5], b[6]);
			else if(b[6] > 2)
				TRACEMS2(cinfo, 1, JTRC_JFIF_MINOR, b[5], b[6]);
			/* Save info */
			cinfo->saw_JFIF_marker = TRUE;
			cinfo->density_unit = b[7];
			cinfo->X_density = (b[8] << 8) + b[9];
			cinfo->Y_density = (b[10] << 8) + b[11];
			TRACEMS3(cinfo, 1, JTRC_JFIF, cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
			if(b[12] | b[13])
				TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, b[12], b[13]);
			if(length != ((INT32) b[12] * (INT32) b[13] * (INT32) 3))
				TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int)length);
		}
		else
		{
			/* Start of APP0 does not match "JFIF" */
			TRACEMS1(cinfo, 1, JTRC_APP0, (int)length + JFIF_LEN);
		}
	}
	else
	{
示例#5
0
METHODDEF boolean
get_app0 (j_decompress_ptr cinfo)
/* Process an APP0 marker */
{
#define JFIF_LEN 14
  INT32 length;
  UINT8 b[JFIF_LEN];
  int buffp;
  INPUT_VARS(cinfo);

  INPUT_2BYTES(cinfo, length, return FALSE);
  length -= 2;

  /* See if a JFIF APP0 marker is present */

  if (length >= JFIF_LEN) {
    for (buffp = 0; buffp < JFIF_LEN; buffp++)
      INPUT_BYTE(cinfo, b[buffp], return FALSE);
    length -= JFIF_LEN;

    if (b[0]==0x4A && b[1]==0x46 && b[2]==0x49 && b[3]==0x46 && b[4]==0) {
      /* Found JFIF APP0 marker: check version */
      /* Major version must be 1 */
      if (b[5] != 1)
	ERREXIT2(cinfo, JERR_JFIF_MAJOR, b[5], b[6]);
      /* Minor version should be 0..2, but try to process anyway if newer */
      if (b[6] > 2)
	TRACEMS2(cinfo, 1, JTRC_JFIF_MINOR, b[5], b[6]);
      /* Save info */
      cinfo->saw_JFIF_marker = TRUE;
      cinfo->density_unit = b[7];
      cinfo->X_density = (b[8] << 8) + b[9];
      cinfo->Y_density = (b[10] << 8) + b[11];
      TRACEMS3(cinfo, 1, JTRC_JFIF,
	       cinfo->X_density, cinfo->Y_density, cinfo->density_unit);
      if (b[12] | b[13])
	TRACEMS2(cinfo, 1, JTRC_JFIF_THUMBNAIL, b[12], b[13]);
      if (length != ((INT32) b[12] * (INT32) b[13] * (INT32) 3))
	TRACEMS1(cinfo, 1, JTRC_JFIF_BADTHUMBNAILSIZE, (int) length);
    } else {
      /* Start of APP0 does not match "JFIF" */
      TRACEMS1(cinfo, 1, JTRC_APP0, (int) length + JFIF_LEN);
    }
  } else {
示例#6
0
decode_tile_start (j_image_ptr iinfo, UINT32 * startcode)
{
  UINT8 c, cc , ccc;
  
  INPUT_VARS(iinfo);
  
  /* Check the start code */
  INPUT_BYTE((j_common_ptr) iinfo,c  ,return FALSE);
  INPUT_BYTE((j_common_ptr) iinfo,cc ,return FALSE);
  INPUT_BYTE((j_common_ptr) iinfo,ccc ,return FALSE);

  *startcode = (c  << 16) |
                     (cc  << 8) |
                     (ccc << 0);
  
  /* Read the arbitrary byte. This is ignored, in accordance with the 
   * specification*/
  INPUT_BYTE((j_common_ptr) iinfo,c  ,return FALSE);
  
}
示例#7
0
static boolean
handle_app1 (j_decompress_ptr cinfo)
{
    INT32 length, i;
    char neogeo[128];

    INPUT_VARS(cinfo);

    length = 0;
    INPUT_2BYTES(cinfo, length, return FALSE);
    length -= 2;

    if (length < 16) {
        for (i = 0; i < length; i++) INPUT_BYTE(cinfo, neogeo[i], return FALSE);
        length = 0;
        if (strncmp(neogeo, "NeoGeo", 6) == 0) memcpy(&ibuf_ftype, neogeo + 6, 4);
        ibuf_ftype = BIG_LONG(ibuf_ftype);
    }
    INPUT_SYNC(cinfo);		/* do before skip_input_data */
    if (length > 0) (*cinfo->src->skip_input_data) (cinfo, length);
    return TRUE;
}
示例#8
0
get_sos (j_decompress_ptr cinfo)
/* Process a SOS marker */
{
  INT32 length;
  int i, ci, n, c, cc;
  jpeg_component_info * compptr;
  INPUT_VARS(cinfo);

  if (! cinfo->marker->saw_SOF)
    ERREXIT(cinfo, JERR_SOS_NO_SOF);

  INPUT_2BYTES(cinfo, length, return FALSE);

  INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */

  if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)
    ERREXIT(cinfo, JERR_BAD_LENGTH);

  TRACEMS1(cinfo, 1, JTRC_SOS, n);

  cinfo->comps_in_scan = n;

  /* Collect the component-spec parameters */

  for (i = 0; i < n; i++) {
    INPUT_BYTE(cinfo, cc, return FALSE);
    INPUT_BYTE(cinfo, c, return FALSE);
    
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
	 ci++, compptr++) {
      if (cc == compptr->component_id)
	goto id_found;
    }

    ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);

  id_found:

    cinfo->cur_comp_info[i] = compptr;
    compptr->dc_tbl_no = (c >> 4) & 15;
    compptr->ac_tbl_no = (c     ) & 15;
    
    TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
	     compptr->dc_tbl_no, compptr->ac_tbl_no);
  }

  /* Collect the additional scan parameters Ss, Se, Ah/Al. */
  INPUT_BYTE(cinfo, c, return FALSE);
  cinfo->Ss = c;
  INPUT_BYTE(cinfo, c, return FALSE);
  cinfo->Se = c;
  INPUT_BYTE(cinfo, c, return FALSE);
  cinfo->Ah = (c >> 4) & 15;
  cinfo->Al = (c     ) & 15;

  TRACEMS4(cinfo, 1, JTRC_SOS_PARAMS, cinfo->Ss, cinfo->Se,
	   cinfo->Ah, cinfo->Al);

  /* Prepare to scan data & restart markers */
  cinfo->marker->next_restart_num = 0;

  /* Count another SOS marker */
  cinfo->input_scan_number++;

  INPUT_SYNC(cinfo);
  return TRUE;
}
示例#9
0
LOCAL boolean
get_sos (j_decompress_ptr cinfo)
/* Process a SOS marker */
{
  INT32 length;
  int i, ci, n, c, cc, ccc;
  jpeg_component_info * compptr;
  INPUT_VARS(cinfo);

  if (! cinfo->marker->saw_SOF)
    ERREXIT(cinfo, JERR_SOS_NO_SOF);

  INPUT_2BYTES(cinfo, length, return FALSE);

  INPUT_BYTE(cinfo, n, return FALSE); /* Number of components */

  if (length != (n * 2 + 6) || n < 1 || n > MAX_COMPS_IN_SCAN)
    ERREXIT(cinfo, JERR_BAD_LENGTH);

  TRACEMS1(cinfo, 1, JTRC_SOS, n);

  cinfo->comps_in_scan = n;

  /* Collect the component-spec parameters */

  for (i = 0; i < n; i++) {
    INPUT_BYTE(cinfo, cc, return FALSE);
    INPUT_BYTE(cinfo, c, return FALSE);
    
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
	 ci++, compptr++) {
      if (cc == compptr->component_id)
	goto id_found;
    }

    ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);

  id_found:

    cinfo->cur_comp_info[i] = compptr;
    compptr->dc_tbl_no = (c >> 4) & 15;
    compptr->ac_tbl_no = (c     ) & 15;
    
    TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
	     compptr->dc_tbl_no, compptr->ac_tbl_no);
  }

  /* Collect the additional scan parameters Ss, Se, Ah/Al.
   * Currently we just validate that they are right for sequential JPEG.
   * This ought to be an error condition, but we make it a warning because
   * there are some baseline files out there with all zeroes in these bytes.
   * (Thank you, Logitech :-(.)
   */
  INPUT_BYTE(cinfo, c, return FALSE);
  INPUT_BYTE(cinfo, cc, return FALSE);
  INPUT_BYTE(cinfo, ccc, return FALSE);
  if (c != 0 || cc != DCTSIZE2-1 || ccc != 0)
    WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);

  /* Prepare to scan data & restart markers */
  cinfo->marker->next_restart_num = 0;

  INPUT_SYNC(cinfo);
  return TRUE;
}
示例#10
0
LOCAL boolean
get_sof (j_decompress_ptr cinfo)
/* Process a SOFn marker */
{
  INT32 length;
  int c, ci;
  jpeg_component_info * compptr;
  INPUT_VARS(cinfo);

  INPUT_2BYTES(cinfo, length, return FALSE);

  INPUT_BYTE(cinfo, cinfo->data_precision, return FALSE);
  INPUT_2BYTES(cinfo, cinfo->image_height, return FALSE);
  INPUT_2BYTES(cinfo, cinfo->image_width, return FALSE);
  INPUT_BYTE(cinfo, cinfo->num_components, return FALSE);

  length -= 8;

  TRACEMS4(cinfo, 1, JTRC_SOF, cinfo->unread_marker,
	   (int) cinfo->image_width, (int) cinfo->image_height,
	   cinfo->num_components);

  if (cinfo->marker->saw_SOF)
    ERREXIT(cinfo, JERR_SOF_DUPLICATE);

  /* We don't support files in which the image height is initially specified */
  /* as 0 and is later redefined by DNL.  As long as we have to check that,  */
  /* might as well have a general sanity check. */
  if (cinfo->image_height <= 0 || cinfo->image_width <= 0
      || cinfo->num_components <= 0)
    ERREXIT(cinfo, JERR_EMPTY_IMAGE);

  /* Make sure image isn't bigger than I can handle */
  if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||
      (long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
    ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);

  /* For now, precision must match compiled-in value... */
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);

  /* Check that number of components won't exceed internal array sizes */
  if (cinfo->num_components > MAX_COMPONENTS)
    ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
	     MAX_COMPONENTS);

  if (length != (cinfo->num_components * 3))
    ERREXIT(cinfo, JERR_BAD_LENGTH);

  if (cinfo->comp_info == NULL)	/* do only once, even if suspend */
    cinfo->comp_info = (jpeg_component_info *) (*cinfo->mem->alloc_small)
			((j_common_ptr) cinfo, JPOOL_IMAGE,
			 cinfo->num_components * SIZEOF(jpeg_component_info));
  
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
       ci++, compptr++) {
    compptr->component_index = ci;
    INPUT_BYTE(cinfo, compptr->component_id, return FALSE);
    INPUT_BYTE(cinfo, c, return FALSE);
    compptr->h_samp_factor = (c >> 4) & 15;
    compptr->v_samp_factor = (c     ) & 15;
    INPUT_BYTE(cinfo, compptr->quant_tbl_no, return FALSE);

    TRACEMS4(cinfo, 1, JTRC_SOF_COMPONENT,
	     compptr->component_id, compptr->h_samp_factor,
	     compptr->v_samp_factor, compptr->quant_tbl_no);
  }

  cinfo->marker->saw_SOF = TRUE;

  INPUT_SYNC(cinfo);
  return TRUE;
}