コード例 #1
0
jpeg_start_tile_decompress(j_decompress_ptr
cinfo) {
if (cinfo->global_state == DSTATE_READY) {
/* First call: initialize master control, select active modules */
cinfo->
tile_decode = TRUE;
jinit_master_decompress(cinfo);
if (cinfo->buffered_image) {
cinfo->
global_state = DSTATE_BUFIMAGE;
return
TRUE;
}
cinfo->
global_state = DSTATE_PRELOAD;
}
if (cinfo->global_state == DSTATE_PRELOAD) {
cinfo->
output_scan_number = cinfo->input_scan_number;
} else if (cinfo->global_state != DSTATE_PRESCAN)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo
->global_state);
/* Perform any dummy output passes, and set up for the final pass */
return
output_pass_setup(cinfo);
}
コード例 #2
0
jpeg_start_decompress(j_decompress_ptr
cinfo) {
if (cinfo->global_state == DSTATE_READY) {
/* First call: initialize master control, select active modules */
jinit_master_decompress(cinfo);
if (cinfo->buffered_image) {
/* No more work here; expecting jpeg_start_output next */
cinfo->
global_state = DSTATE_BUFIMAGE;
return
TRUE;
}
cinfo->
global_state = DSTATE_PRELOAD;
}
if (cinfo->global_state == DSTATE_PRELOAD) {
/* If file has multiple scans, absorb them all into the coef buffer */
if (cinfo->inputctl->has_multiple_scans) {
#ifdef D_MULTISCAN_FILES_SUPPORTED
for (; ;) {
    int retcode;
    /* Call progress monitor hook if present */
    if (cinfo->progress != NULL)
        (*cinfo->progress->progress_monitor)((j_common_ptr) cinfo);
    /* Absorb some more input */
    retcode = (*cinfo->inputctl->consume_input)(cinfo);
    if (retcode == JPEG_SUSPENDED)
        return FALSE;
    if (retcode == JPEG_REACHED_EOI)
        break;
    /* Advance progress counter if appropriate */
    if (cinfo->progress != NULL &&
        (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
        if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
            /* jdmaster underestimated number of scans; ratchet up one scan */
            cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
        }
    }
}
#else
ERREXIT(cinfo, JERR_NOT_COMPILED
);
#endif /* D_MULTISCAN_FILES_SUPPORTED */
}
cinfo->
output_scan_number = cinfo->input_scan_number;
} else if (cinfo->global_state != DSTATE_PRESCAN)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo
->global_state);
/* Perform any dummy output passes, and set up for the final pass */
return
output_pass_setup(cinfo);
}
コード例 #3
0
ファイル: jdapistd.c プロジェクト: qtekfun/htcDesire820Kernel
jpeg_start_decompress (j_decompress_ptr cinfo)
{
  if (cinfo->global_state == DSTATE_READY) {
    
    jinit_master_decompress(cinfo);
    if (cinfo->buffered_image) {
      
      cinfo->global_state = DSTATE_BUFIMAGE;
      return TRUE;
    }
    cinfo->global_state = DSTATE_PRELOAD;
  }
  if (cinfo->global_state == DSTATE_PRELOAD) {
    
    if (cinfo->inputctl->has_multiple_scans) {
#ifdef D_MULTISCAN_FILES_SUPPORTED
      for (;;) {
	int retcode;
	
	if (cinfo->progress != NULL)
	  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
	
	retcode = (*cinfo->inputctl->consume_input) (cinfo);
	if (retcode == JPEG_SUSPENDED)
	  return FALSE;
	if (retcode == JPEG_REACHED_EOI)
	  break;
	
	if (cinfo->progress != NULL &&
	    (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
	  if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
	    
	    cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
	  }
	}
      }
#else
      ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif 
    }
    cinfo->output_scan_number = cinfo->input_scan_number;
  } else if (cinfo->global_state != DSTATE_PRESCAN)
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  
  return output_pass_setup(cinfo);
}
コード例 #4
0
ファイル: jdapistd.c プロジェクト: qtekfun/htcDesire820Kernel
jpeg_start_tile_decompress (j_decompress_ptr cinfo)
{
  if (cinfo->global_state == DSTATE_READY) {
    
    cinfo->tile_decode = TRUE;
    jinit_master_decompress(cinfo);
    if (cinfo->buffered_image) {
      cinfo->global_state = DSTATE_BUFIMAGE;
      return TRUE;
    }
    cinfo->global_state = DSTATE_PRELOAD;
  }
  if (cinfo->global_state == DSTATE_PRELOAD) {
    cinfo->output_scan_number = cinfo->input_scan_number;
  } else if (cinfo->global_state != DSTATE_PRESCAN)
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  
  return output_pass_setup(cinfo);
}
コード例 #5
0
ファイル: jdapi.c プロジェクト: Jonnyliu/Rmtsvc
GLOBAL void
jpeg_start_decompress (j_decompress_ptr cinfo)
{
  JDIMENSION chunk_ctr, last_chunk_ctr;

  if (cinfo->global_state != DSTATE_READY)
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  /* Perform master selection of active modules */
  jinit_master_decompress(cinfo);
  /* Do all but the final (output) pass, and set up for that one. */
  for (;;) {
    (*cinfo->master->prepare_for_pass) (cinfo);
    if (cinfo->master->is_last_pass)
      break;
    chunk_ctr = 0;
    while (chunk_ctr < cinfo->main->num_chunks) {
      /* Call progress monitor hook if present */
      if (cinfo->progress != NULL) {
	cinfo->progress->pass_counter = (long) chunk_ctr;
	cinfo->progress->pass_limit = (long) cinfo->main->num_chunks;
	(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
      }
      /* Process some data */
      last_chunk_ctr = chunk_ctr;
      (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,
				    &chunk_ctr, (JDIMENSION) 0);
      if (chunk_ctr == last_chunk_ctr) /* check for failure to make progress */
	ERREXIT(cinfo, JERR_CANT_SUSPEND);
    }
    (*cinfo->master->finish_pass) (cinfo);
  }
  /* Ready for application to drive last pass through jpeg_read_scanlines
   * or jpeg_read_raw_data.
   */
  cinfo->output_scanline = 0;
  cinfo->global_state = (cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING);
}
コード例 #6
0
jpeg_start_decompress (j_decompress_ptr cinfo)
{
 JDIMENSION output_pitch;
	
    SkJpegDebugf("\n*******jpeg_start_decompress*******,out_color_space = %d\n",cinfo->out_color_space);
    SkJpegDebugf("2.1 image_width = %d, image_height = %d\n", cinfo->image_width,  cinfo->image_height);

#ifdef MTM_HWDEC
RESTART_DEC:
 // SkJpegDebugf("------restartdec %d---------",IS_HW_DECODE());
if (IS_HW_DECODE())
{
#ifdef SMALL_JPG_USE_SW
        if (((cinfo->image_width <640) && (cinfo->image_height<480))||(cinfo->out_color_space == JCS_RGB_565))
        {       
                    SkJpegDebugf("Small jpg Switch to SW mode\n");
            cinfo->fgforceswmode = TRUE;
            goto RESTART_DEC;
        }
#endif

#ifdef JPEG_FORCE_SW_FLOW
    cinfo->fgforceswmode=TRUE;
#endif    
    if(!fgJpgMutexInit)
    {            
        pthread_mutex_init(&JpgLibMutex, NULL);
        SkJpegDebugf("pthread_mutex_init JpgLibMutex ....\n");
        fgJpgMutexInit = TRUE;
    }
    pthread_mutex_lock(&JpgLibMutex);            
    SkJpegDebugf("JpgLibMutex lock....\n");
                    
    MEMZERO(&hwcinfo, SIZEOF(HWCINFO));
    pthread_cond_init(&JpgStopCond, NULL);
    pthread_cond_init(&JpgStopMutex, NULL);

      /* Hardwire it to "no scaling" */

      switch (cinfo->out_color_space) {
      case JCS_GRAYSCALE:
        cinfo->out_color_components = 1;
        break;
      case JCS_RGB:
        cinfo->out_color_components = 3;
        break;
      case JCS_RGB_565:
        cinfo->out_color_components = 3;
        break;
      case JCS_RGBA_8888:
        cinfo->out_color_components = 4;
        break;
      default:          /* else must be same colorspace as in file */
        cinfo->out_color_components = cinfo->num_components;
        break;
      }
      cinfo->output_components  = cinfo->out_color_components;
#ifndef MTIMAGE_READ_HEADER
    if(cinfo->scale_denom)
    {
        cinfo->output_width = cinfo->image_width / cinfo->scale_denom ;
        cinfo->output_height = cinfo->image_height / cinfo->scale_denom ;
    }
#endif
    //SkJpegDebugf("1.output_width = %d, output_height = %d\n", cinfo->output_width,  cinfo->output_height);
    //SkJpegDebugf("image_width = %d, image_height = %d, output_component =%d\n", cinfo->image_width,  cinfo->image_height, cinfo->out_color_components);

    switch(cinfo->out_color_space)
    {
        case JCS_RGBA_8888:
            Jpg_DesBytePerPixel = 4;
            Jpg_SrcBytePerPixel = 4;
            break;
        case JCS_RGB:
            Jpg_DesBytePerPixel = 3;            
            Jpg_SrcBytePerPixel = 4;            
            break;
        case JCS_RGB_565:
            Jpg_DesBytePerPixel = 2;                        
            Jpg_SrcBytePerPixel = 2;            
            break;
        default:
            break;
    }
#ifndef JPGMEM_IMPROVE
    output_pitch= (cinfo->output_width+0xf)&~0xf;
    if(!hwcinfo.image)
    {
        hwcinfo.image = malloc( output_pitch * cinfo->output_height * Jpg_SrcBytePerPixel * sizeof(UINTJ8));   // *4 for ARGB8888 buffer, YC422 to ARGB8888
        if (!hwcinfo.image)
        {
            SkJpegDebugf("allocate fail\n");
            return FALSE;
        }
        cinfo->input_iMCU_row = (JDIMENSION) hwcinfo.image;
    }
#endif

	
    if (mtmplay_jpg_dec(cinfo))
    {
        cinfo->output_scanline = 0;
        #ifndef JPGMEM_IMPROVE
        if(!hwcinfo.pimageRow)
        {
            hwcinfo.pimageRow = malloc( cinfo->output_width  * Jpg_DesBytePerPixel);
            SkJpegDebugf("pimageRow ptr = %x\n", (JDIMENSION)hwcinfo.pimageRow);
            if (!hwcinfo.pimageRow)
            {
                printf("pimageRow malloc fail\n");
                return -1;
            }
        }
        #endif

	#ifdef JPGMEM_IMPROVE
	 hwcinfo.image = cinfo->input_iMCU_row;
     //hwcinfo.pimageRow = cinfo->input_iMCU_row - (cinfo->output_width *  Jpg_DesBytePerPixel);
     hwcinfo.pimageRow = cinfo->input_iMCU_row + 0x7F8000; 
	#endif
	
        SkJpegDebugf("HW original image_width = %d, image_height = %d\n", cinfo->image_width,  cinfo->image_height);
        SkJpegDebugf("HW output_width = %d, output_height = %d,hwcinfo.image = %x %x\n", cinfo->output_width,  cinfo->output_height,hwcinfo.image,hwcinfo.pimageRow);

        return TRUE;
    }
    else
    {
        SkJpegDebugf("\n!!!-->HW Err.\n");
#if 1
        //return 0;

        /* Initialize marker processor so application can override methods
        * for COM, APPn markers before calling jpeg_read_header.
        */
        cinfo->marker_list = NULL;
        jinit_marker_reader(cinfo);

        /* And initialize the overall input controller. */
        jinit_input_controller(cinfo);

        /* OK, I'm ready */
        cinfo->global_state = DSTATE_START;
            
        cinfo->fgforceswmode=TRUE;
		pthread_mutex_unlock(&JpgLibMutex);

        jpeg_read_header(cinfo, TRUE);
		if (!cinfo->progressive_mode && (cinfo->image_width > 17000 || cinfo->image_height > 10000))
		{
			return FALSE;
		}
		if (cinfo->progressive_mode && (cinfo->image_width * cinfo->image_height) > 4000 * 4000)
		{
			return FALSE;
		}
        //jpeg_calc_output_dimensions(cinfo);
        goto RESTART_DEC;

        return TRUE;
		#else
		      return FALSE;
		#endif
    }
}
else
#endif//MTM_HWDEC
{
#ifdef JPEG_FORCE_HW_FLOW
    if((cinfo->out_color_space == JCS_RGB)||(cinfo->out_color_space == JCS_RGBA_8888))
    {
        printf("***cinfo->out_color_space=[%d], never sw mode\n");
        return 0;
    }
#endif

#ifdef MTM_HWDEC
        printf("\n****-->SW MODE\n");
#ifndef ANDROID_READ
        cinfo->src->next_input_byte =  hwcinfo.gSOS_next_input_byte;
        cinfo->src->bytes_in_buffer =  hwcinfo.gSOS_bytes_in_buffer;
        SkJpegDebugf("4. Cinfo src buf addr= 0x%x: len=%lu \n", cinfo->src->next_input_byte, cinfo->src->bytes_in_buffer);
#endif
#endif
	
  if (cinfo->global_state == DSTATE_READY) {
    /* First call: initialize master control, select active modules */
    jinit_master_decompress(cinfo);
    if (cinfo->buffered_image) {
      /* No more work here; expecting jpeg_start_output next */
      cinfo->global_state = DSTATE_BUFIMAGE;
      return TRUE;
    }
    cinfo->global_state = DSTATE_PRELOAD;
  }
  if (cinfo->global_state == DSTATE_PRELOAD) {
    /* If file has multiple scans, absorb them all into the coef buffer */
    if (cinfo->inputctl->has_multiple_scans) {
#ifdef D_MULTISCAN_FILES_SUPPORTED
      for (;;) {
	int retcode;
	/* Call progress monitor hook if present */
	if (cinfo->progress != NULL)
	  (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
	/* Absorb some more input */
	retcode = (*cinfo->inputctl->consume_input) (cinfo);
	if (retcode == JPEG_SUSPENDED)
	  return FALSE;
	if (retcode == JPEG_REACHED_EOI)
	  break;
	/* Advance progress counter if appropriate */
	if (cinfo->progress != NULL &&
	    (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
	  if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
	    /* jdmaster underestimated number of scans; ratchet up one scan */
	    cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
	  }
	}
      }
#else
      ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif /* D_MULTISCAN_FILES_SUPPORTED */
    }
    cinfo->output_scan_number = cinfo->input_scan_number;
  } else if (cinfo->global_state != DSTATE_PRESCAN)
    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
  /* Perform any dummy output passes, and set up for the final pass */
  return output_pass_setup(cinfo);
}//if (!IS_HW_DECODE())
}