Beispiel #1
0
int jpeg_type(int *img_type, unsigned char *idata, const int ilen)
{
   int ret;
   unsigned short marker;
   unsigned char *cbufptr, *ebufptr;

   cbufptr = idata;
   ebufptr = idata + ilen;

   /* Get SOI */
   if((ret = getc_marker_jpegl(&marker, SOI, &cbufptr, ebufptr)))
      return(ret);

   /* Get next marker. */
   if((ret = getc_marker_jpegl(&marker, ANY, &cbufptr, ebufptr)))
      return(ret);

   /* While not at Start of Scan (SOS) -     */
   /*    the start of encoded image data ... */
   while(marker != SOS){
      if(marker == SOF3){
         *img_type = JPEGL_IMG;
         return(0);
      }
      else if(marker == SOF0){
         *img_type = JPEGB_IMG;
         return(0);
      }
      /* Skip marker segment. */
      if((ret = getc_skip_marker_segment(marker, &cbufptr, ebufptr)))
         return(ret);

      /* Get next marker. */
      if((ret = getc_marker_jpegl(&marker, ANY, &cbufptr, ebufptr)))
         return(ret);
   }

   /* JPEG type not found ... */
   fprintf(stderr, "ERROR : jpeg_type : Could not determine JPEG type ");
   fprintf(stderr, "(ie. baseline or lossless)\n");
   *img_type = -1;
   return(-2);
}
Beispiel #2
0
NISTWSQ_API int __cdecl wsq_get_comments(
		byte*** comments_data,
		int* comments_count,
		byte* wsq_data, 
		int wsq_data_length)
{
	byte* cbufptr = nullptr;
	byte* ebufptr = nullptr;
	cbufptr = wsq_data;
	ebufptr = wsq_data + wsq_data_length;

	int ret = 0;
	unsigned short marker = 0;
	byte** comments = nullptr;
	int ccount = 0;

	// Get SOI
	if(ret = getc_marker_wsq(&marker, SOI_WSQ, &cbufptr, ebufptr))
		return ret;

	// Get next marker. 
	if(ret = getc_marker_wsq(&marker, ANY_WSQ, &cbufptr, ebufptr))
		return ret;

	// While not at Start of Block (SOB)
	while(marker != SOB_WSQ)
	{
		if(marker == COM_WSQ)
		{
			byte* current_comment;
			if(ret = getc_comment(&current_comment, &cbufptr, ebufptr))
				return ret;

			ccount++;
			byte** array = (byte**)malloc(sizeof(byte*) * ccount);
			if (ccount > 1)
			{
				for (int i = 0; i < ccount - 1; i++)
					array[i] = comments[i];
				free(comments);
			}

			array[ccount - 1] = current_comment;
			comments = array;
		}
		else // skip
		{
			if(ret = getc_skip_marker_segment(marker, &cbufptr, ebufptr))
				return ret;
		}

		// get next marker
		if (ret = getc_marker_wsq(&marker, ANY_WSQ, &cbufptr, ebufptr))
			return ret;
	}

	*comments_count = ccount;
	*comments_data = comments;

	return 0;
}