⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdapistd.c

📁 Sigma SMP8634 Mrua v. 2.8.2.0
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * jdapistd.c * * Copyright (C) 1994-1996, Thomas G. Lane. * This file is part of the Independent JPEG Group's software. * For conditions of distribution and use, see the accompanying README file. * * This file contains application interface code for the decompression half * of the JPEG library.  These are the "standard" API routines that are * used in the normal full-decompression case.  They are not used by a * transcoding-only application.  Note that if an application links in * jpeg_start_decompress, it will end up linking in the entire decompressor. * We thus must separate this file from jdapimin.c to avoid linking the * whole decompression library into a transcoder. */#ifdef __CC_ARM#include <alloca.h>        //for alloca(...)#else#include <malloc.h>         //for alloca(...)#endif#define JPEG_INTERNALS#include "jinclude.h"#include "jpeglib.h"/* Forward declarations */LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo));//#define FRAME_WIDTH (720) //define somewhere in .h file !!!!!!!!!!!//#define FRAME_HEIGHT (480)//define somewhere in .h file !!!!!!!!!!!#define Y_PLANE 0#define U_PLANE 1#define V_PLANE 2/* * Decompression initialization. * jpeg_read_header must be completed before calling this. * * If a multipass operating mode was selected, this will do all but the * last pass, and thus may take a great deal of time. * * Returns FALSE if suspended.  The return value need be inspected only if * a suspending data source is used. */GLOBAL(boolean)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);}/* * Set up for an output pass, and perform any dummy pass(es) needed. * Common subroutine for jpeg_start_decompress and jpeg_start_output. * Entry: global_state = DSTATE_PRESCAN only if previously suspended. * Exit: If done, returns TRUE and sets global_state for proper output mode. *       If suspended, returns FALSE and sets global_state = DSTATE_PRESCAN. */LOCAL(boolean)output_pass_setup (j_decompress_ptr cinfo){  if (cinfo->global_state != DSTATE_PRESCAN) {    /* First call: do pass setup */    (*cinfo->master->prepare_for_output_pass) (cinfo);    cinfo->output_scanline = 0;    cinfo->global_state = DSTATE_PRESCAN;  }  /* Loop over any required dummy passes */  while (cinfo->master->is_dummy_pass) {#ifdef QUANT_2PASS_SUPPORTED    /* Crank through the dummy pass */    while (cinfo->output_scanline < cinfo->output_height) {      JDIMENSION last_scanline;      /* Call progress monitor hook if present */      if (cinfo->progress != NULL) {	cinfo->progress->pass_counter = (long) cinfo->output_scanline;	cinfo->progress->pass_limit = (long) cinfo->output_height;	(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);      }      /* Process some data */      last_scanline = cinfo->output_scanline;      (*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,				    &cinfo->output_scanline, (JDIMENSION) 0);      if (cinfo->output_scanline == last_scanline)	return FALSE;		/* No progress made, must suspend */    }    /* Finish up dummy pass, and set up for another one */    (*cinfo->master->finish_output_pass) (cinfo);    (*cinfo->master->prepare_for_output_pass) (cinfo);    cinfo->output_scanline = 0;#else    ERREXIT(cinfo, JERR_NOT_COMPILED);#endif /* QUANT_2PASS_SUPPORTED */  }  /* Ready for application to drive output pass through   * jpeg_read_scanlines or jpeg_read_raw_data.   */  cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;  return TRUE;}/* * Read some scanlines of data from the JPEG decompressor. * * The return value will be the number of lines actually read. * This may be less than the number requested in several cases, * including bottom of image, data source suspension, and operating * modes that emit multiple scanlines at a time. * * Note: we warn about excess calls to jpeg_read_scanlines() since * this likely signals an application programmer error.  However, * an oversize buffer (max_lines > scanlines remaining) is not an error. */GLOBAL(JDIMENSION)jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,		     JDIMENSION max_lines){  JDIMENSION row_ctr;  if (cinfo->global_state != DSTATE_SCANNING)    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);  if (cinfo->output_scanline >= cinfo->output_height) {    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);    return 0;  }  /* Call progress monitor hook if present */  if (cinfo->progress != NULL) {    cinfo->progress->pass_counter = (long) cinfo->output_scanline;    cinfo->progress->pass_limit = (long) cinfo->output_height;    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);  }  /* Process some data */  row_ctr = 0;  (*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);  cinfo->output_scanline += row_ctr;  return row_ctr;}/* * Alternate entry point to read raw data. * Processes exactly one iMCU row per call, unless suspended. */GLOBAL(JDIMENSION)jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,		    JDIMENSION max_lines){  JDIMENSION lines_per_iMCU_row;  if (cinfo->global_state != DSTATE_RAW_OK)    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);  if (cinfo->output_scanline >= cinfo->output_height) {    WARNMS(cinfo, JWRN_TOO_MUCH_DATA);    return 0;  }  /* Call progress monitor hook if present */  if (cinfo->progress != NULL) {    cinfo->progress->pass_counter = (long) cinfo->output_scanline;    cinfo->progress->pass_limit = (long) cinfo->output_height;    (*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);  }  /* Verify that at least one iMCU row can be returned. */  lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size;  if (max_lines < lines_per_iMCU_row)    ERREXIT(cinfo, JERR_BUFFER_SIZE);  /* Decompress directly into user's buffer. */  if (! (*cinfo->coef->decompress_data) (cinfo, data))    return 0;			/* suspension forced, can do nothing more */  /* OK, we processed one iMCU row. */  cinfo->output_scanline += lines_per_iMCU_row;  return lines_per_iMCU_row;}#ifdef  YYYY_UVGLOBAL(JDIMENSION) jpeg_read_image_420 (j_decompress_ptr cinfo, JSAMPLE *Y_plane, JSAMPLE *UV_plane){#define COLOR_COMPONENTS 3  int                 i;  JDIMENSION          num_scanlines;  JDIMENSION          plane_height[COLOR_COMPONENTS];  JDIMENSION          plane_width[COLOR_COMPONENTS];  int                 H_samp[COLOR_COMPONENTS];  int                 V_samp[COLOR_COMPONENTS];    JSAMPLE             *UV_ptr = NULL;  JSAMPARRAY          buff[COLOR_COMPONENTS];  JSAMPROW            plane_buff[COLOR_COMPONENTS];    JDIMENSION          lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_scaled_size;  JDIMENSION          center_ajust_h = 0; // (((FRAME_WIDTH  - cinfo->cur_comp_info[Y_PLANE]->downsampled_width)>>1)&~0x7);  JDIMENSION          center_ajust_v = 0; // FRAME_WIDTH*(((FRAME_HEIGHT - cinfo->cur_comp_info[Y_PLANE]->downsampled_height)>>1)&~0x7);  /*  JDIMENSION    yrow_width  = plane_width[Y_PLANE];  JDIMENSION    yrow_height = plane_height[Y_PLANE];  JDIMENSION    urow_width  = plane_width[U_PLANE];  JDIMENSION    urow_height = plane_height[U_PLANE];  JDIMENSION    vrow_width  = plane_width[V_PLANE];  JDIMENSION    vrow_height = plane_height[V_PLANE];*/    for(i=0; i<cinfo->comps_in_scan; i++)  {    buff[i]       = NULL;    plane_buff[i] = NULL;//keep pointers for free(...)     plane_height[i]  = cinfo->cur_comp_info[i]->downsampled_height;    plane_width[i]   = cinfo->cur_comp_info[i]->downsampled_width;        H_samp[i]= cinfo->cur_comp_info[i]->DCT_scaled_size * cinfo->cur_comp_info[i]->h_samp_factor;    V_samp[i]= cinfo->cur_comp_info[i]->DCT_scaled_size * cinfo->cur_comp_info[i]->v_samp_factor;    //XXX  }    // padd size to next DCT block

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -