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

📄 jdmainct.c

📁 These are all the utilities you need to generate MPEG-I movies on a UNIX box with full motion video
💻 C
📖 第 1 页 / 共 2 页
字号:
METHODDEF voidstart_pass_main (j_decompress_ptr cinfo, J_BUF_MODE pass_mode){  my_main_ptr main = (my_main_ptr) cinfo->main;  switch (pass_mode) {  case JBUF_PASS_THRU:  if(cinfo->want_raw_output){    main->pub.process_data = process_data_raw_main;    }else if (cinfo->upsample->need_context_rows) {      main->pub.process_data = process_data_context_main;      make_funny_pointers(cinfo); /* Create the xbuffer[] lists */      main->whichptr = 0;       /* Read first iMCU row into xbuffer[0] */      main->context_state = CTX_PREPARE_FOR_IMCU;      main->iMCU_row_ctr = 0;    } else {      /* Simple case with no context needed */      main->pub.process_data = process_data_simple_main;    }    main->buffer_full = FALSE;  /* Mark buffer empty */    main->rowgroup_ctr = 0;    break;  default:    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);    break;  }}/* * Process some data where raw output is desired. * This handles the simple case where no context is required. * This process assumes out_rows_avail = 2,4,8,or 16 * 16 will produce the fastest results but take more memory */METHODDEF voidprocess_data_raw_main (j_decompress_ptr cinfo,			  JSAMPIMAGE scanarray, JDIMENSION *out_row_ctr,			  JDIMENSION out_rows_avail){  my_main_ptr main = (my_main_ptr) cinfo->main;  JDIMENSION total_rows_avail;  int ci,cp,cd;  jpeg_component_info *compptr;  JDIMENSION ncols, nrows;  JDIMENSION current_row;  JSAMPLE *main_buf_ptr;  int diff;/* Get raw data */  if (! main->buffer_full) {    if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer))      return;                       main->buffer_full = TRUE;     }/* Total rows availble = 8*max_v_samp_factor */  total_rows_avail = (JDIMENSION)(cinfo->min_DCT_scaled_size*                         cinfo->max_v_samp_factor);/* Check to see if wee are near the bottom of the image*/  diff = cinfo->image_height - cinfo->output_scanline;/* if the image height is not a factor of 16 we will need   to output only the number of lines we want so adjust   the number of output rows available accordingly*/  if (out_rows_avail > diff){      out_rows_avail = diff;    }/*copy each component from the input buffer to the output buffer*/  for(ci=0, compptr = cinfo->comp_info;ci< cinfo->num_components;      ci++,compptr++){   /* calculate the number of colums wide each component is*/      ncols =(JDIMENSION)((cinfo->image_width*compptr->h_samp_factor)/           cinfo->max_h_samp_factor) ;   /* calculate the number of rows to output for each component*/   nrows =(JDIMENSION)((out_rows_avail*compptr->v_samp_factor)/           cinfo->max_v_samp_factor) ;   /* for buffers not 16 rows high, must calculate buffer offset*/     current_row =(JDIMENSION)((main->rowgroup_ctr)*(compptr->v_samp_factor/           cinfo->max_v_samp_factor));   jcopy_sample_rows(main->buffer[ci],current_row,scanarray[ci],           0,nrows,ncols);    }   /* assign new value to out_row_ctr so read_raw_scanlines can     update cinfo->output_scanline */   *out_row_ctr += out_rows_avail;   /* for buffers not 16 rows high, update buffer offset pinter */   (main->rowgroup_ctr) += out_rows_avail;   /* if we are at the bottom of the raw data buffer, reset state*/  if (main->rowgroup_ctr >= total_rows_avail) {    main->buffer_full = FALSE;    main->rowgroup_ctr = 0;  }}   /* * Process some data. * This handles the simple case where no context is required. */METHODDEF voidprocess_data_simple_main (j_decompress_ptr cinfo,			  JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,			  JDIMENSION out_rows_avail){  my_main_ptr main = (my_main_ptr) cinfo->main;  JDIMENSION rowgroups_avail;  /* Read input data if we haven't filled the main buffer yet */  if (! main->buffer_full) {    if (! (*cinfo->coef->decompress_data) (cinfo, main->buffer))      return;                   /* suspension forced, can do nothing more */    main->buffer_full = TRUE;   /* OK, we have an iMCU row to work with */  }  /* There are always min_DCT_scaled_size row groups in an iMCU row. */  rowgroups_avail = (JDIMENSION) cinfo->min_DCT_scaled_size;  /* Note: at the bottom of the image, we may pass extra garbage row groups   * to the postprocessor.  The postprocessor has to check for bottom   * of image anyway (at row resolution), so no point in us doing it too.   */  /* Feed the postprocessor */  (*cinfo->post->post_process_data) (cinfo, main->buffer,				     &main->rowgroup_ctr, rowgroups_avail,				     output_buf, out_row_ctr, out_rows_avail);  /* Has postprocessor consumed all the data yet? If so, mark buffer empty */  if (main->rowgroup_ctr >= rowgroups_avail) {    main->buffer_full = FALSE;    main->rowgroup_ctr = 0;  }}/* * Process some data. * This handles the case where context rows must be provided. */METHODDEF voidprocess_data_context_main (j_decompress_ptr cinfo,			   JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,			   JDIMENSION out_rows_avail){  my_main_ptr main = (my_main_ptr) cinfo->main;  /* Read input data if we haven't filled the main buffer yet */  if (! main->buffer_full) {    if (! (*cinfo->coef->decompress_data) (cinfo,					   main->xbuffer[main->whichptr]))      return;                   /* suspension forced, can do nothing more */    main->buffer_full = TRUE;   /* OK, we have an iMCU row to work with */    main->iMCU_row_ctr++;       /* count rows received */  }  /* Postprocessor typically will not swallow all the input data it is handed   * in one call (due to filling the output buffer first).  Must be prepared   * to exit and restart.  This switch lets us keep track of how far we got.   * Note that each case falls through to the next on successful completion.   */  switch (main->context_state) {  case CTX_POSTPONED_ROW:    /* Call postprocessor using previously set pointers for postponed row */    (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr],			&main->rowgroup_ctr, main->rowgroups_avail,			output_buf, out_row_ctr, out_rows_avail);    if (main->rowgroup_ctr < main->rowgroups_avail)      return;                   /* Need to suspend */    main->context_state = CTX_PREPARE_FOR_IMCU;    /*FALLTHROUGH*/  case CTX_PREPARE_FOR_IMCU:    /* Prepare to process first M-1 row groups of this iMCU row */    main->rowgroup_ctr = 0;    main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size - 1);    /* Check for bottom of image: if so, tweak pointers to "duplicate"     * the last sample row, and adjust rowgroups_avail to ignore padding rows.     */    if (main->iMCU_row_ctr == cinfo->total_iMCU_rows)      set_bottom_pointers(cinfo);    main->context_state = CTX_PROCESS_IMCU;    /*FALLTHROUGH*/  case CTX_PROCESS_IMCU:    /* Call postprocessor using previously set pointers */    (*cinfo->post->post_process_data) (cinfo, main->xbuffer[main->whichptr],			&main->rowgroup_ctr, main->rowgroups_avail,			output_buf, out_row_ctr, out_rows_avail);    if (main->rowgroup_ctr < main->rowgroups_avail)      return;                   /* Need to suspend */    /* After the first iMCU, change wraparound pointers to normal state */    if (main->iMCU_row_ctr == 1)      set_wraparound_pointers(cinfo);    /* Prepare to load new iMCU row using other xbuffer list */    main->whichptr ^= 1;        /* 0=>1 or 1=>0 */    main->buffer_full = FALSE;    /* Still need to process last row group of this iMCU row, */    /* which is saved at index M+1 of the other xbuffer */    main->rowgroup_ctr = (JDIMENSION) (cinfo->min_DCT_scaled_size + 1);    main->rowgroups_avail = (JDIMENSION) (cinfo->min_DCT_scaled_size + 2);    main->context_state = CTX_POSTPONED_ROW;  }}/* * Clean up at the end of a pass. */METHODDEF voidfinish_pass_main (j_decompress_ptr cinfo){  /* No work for myself, but pass it on to subsidiary objects */  (*cinfo->coef->finish_pass) (cinfo);  (*cinfo->post->finish_pass) (cinfo);}/* * Initialize main buffer controller. */GLOBAL voidjinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer){  my_main_ptr main;  int ci, rgroup, ngroups;  jpeg_component_info *compptr;  main = (my_main_ptr)    (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,				SIZEOF(my_main_controller));  cinfo->main = (struct jpeg_d_main_controller *) main;  main->pub.start_pass = start_pass_main;  main->pub.finish_pass = finish_pass_main;  if (need_full_buffer)         /* shouldn't happen */    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);  /* Allocate the workspace.   * ngroups is the number of row groups we need.   */  if (cinfo->upsample->need_context_rows) {    if (cinfo->min_DCT_scaled_size < 2) /* unsupported, see comments above */      ERREXIT(cinfo, JERR_NOTIMPL);    ngroups = cinfo->min_DCT_scaled_size + 2;  } else {    ngroups = cinfo->min_DCT_scaled_size;  }  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;       ci++, compptr++) {    rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) /      cinfo->min_DCT_scaled_size; /* height of a row group of component */    main->buffer[ci] = (*cinfo->mem->alloc_sarray)			((j_common_ptr) cinfo, JPOOL_IMAGE,			 compptr->width_in_blocks * compptr->DCT_scaled_size,			 (JDIMENSION) (rgroup * ngroups));  }}

⌨️ 快捷键说明

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