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

📄 jctrans.c

📁 基于Linux的ffmepg decoder
💻 C
字号:
/* * jctrans.c * * Copyright (C) 1995-1998, 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 library routines for transcoding compression, * that is, writing raw DCT coefficient arrays to an output JPEG file. * The routines in jcapimin.c will also be needed by a transcoder. */#define JPEG_INTERNALS#include "jinclude.h"#include "jpeglib.h"/* Forward declarations *///LOCAL(void) transencode_master_selection//	JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));//LOCAL(void) transencode_coef_controller//	JPP((j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays));/* * Compression initialization for writing raw-coefficient data. * Before calling this, all parameters and a data destination must be set up. * Call jpeg_finish_compress() to actually write the data. * * The number of passed virtual arrays must match cinfo->num_components. * Note that the virtual arrays need not be filled or even realized at * the time write_coefficients is called; indeed, if the virtual arrays * were requested from this compression object's memory manager, they * typically will be realized during this routine and filled afterwards. */#if 0GLOBAL(void)jpeg_write_coefficients (j_compress_ptr cinfo, jvirt_barray_ptr * coef_arrays){  if (cinfo->global_state != CSTATE_START)    ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);  /* Mark all tables to be written */  jpeg_suppress_tables(cinfo, FALSE);  /* (Re)initialize error mgr and destination modules */  (*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo); // (*cinfo->dest->init_destination) (cinfo);  /* Perform master selection of active modules */  transencode_master_selection(cinfo, coef_arrays);  /* Wait for jpeg_finish_compress() call */  cinfo->next_scanline = 0;	/* so jpeg_write_marker works */  cinfo->global_state = CSTATE_WRCOEFS;}/* * Master selection of compression modules for transcoding. * This substitutes for jcinit.c's initialization of the full compressor. */LOCAL(void)transencode_master_selection (j_compress_ptr cinfo,			      jvirt_barray_ptr * coef_arrays){  /* Although we don't actually use input_components for transcoding,   * jcmaster.c's initial_setup will complain if input_components is 0.   */  cinfo->input_components = 1;  /* Initialize master control (includes parameter checking/processing) */  jinit_c_master_control(cinfo, TRUE /* transcode only */);#if 0  /* Entropy encoding: either Huffman or arithmetic coding. */  if (cinfo->arith_code) {    ERREXIT(cinfo, JERR_ARITH_NOTIMPL);  } else {    if (cinfo->progressive_mode) {#ifdef C_PROGRESSIVE_SUPPORTED//      jinit_phuff_encoder(cinfo);#else      ERREXIT(cinfo, JERR_NOT_COMPILED);#endif    } else#endif	//only support huffman coding      jinit_huff_encoder(cinfo);  //}  /* We need a special coefficient buffer controller. */  //transencode_coef_controller(cinfo, coef_arrays);  jinit_marker_writer(cinfo);  /* We can now tell the memory manager to allocate virtual arrays. */  //(*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo);  /* Write the datastream header (SOI, JFIF) immediately.   * Frame and scan headers are postponed till later.   * This lets application insert special markers after the SOI.   */  //(*cinfo->marker->write_file_header) (cinfo);  write_file_header1(cinfo);}#endif/* * The rest of this file is a special implementation of the coefficient * buffer controller.  This is similar to jccoefct.c, but it handles only * output from presupplied virtual arrays.  Furthermore, we generate any * dummy padding blocks on-the-fly rather than expecting them to be present * in the arrays. *//* Private buffer controller object */#if 0typedef struct {  struct jpeg_c_coef_controller pub; /* public fields */  JDIMENSION iMCU_row_num;	/* iMCU row # within image */  JDIMENSION mcu_ctr;		/* counts MCUs processed in current row */  int MCU_vert_offset;		/* counts MCU rows within iMCU row */  int MCU_rows_per_iMCU_row;	/* number of such rows needed */  /* Virtual block array for each component. */  jvirt_barray_ptr * whole_image;  /* Workspace for constructing dummy blocks at right/bottom edges. */  JBLOCKROW dummy_buffer[C_MAX_BLOCKS_IN_MCU];} my_coef_controller;typedef my_coef_controller * my_coef_ptr;LOCAL(void)start_iMCU_row (j_compress_ptr cinfo)/* Reset within-iMCU-row counters for a new row */{  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;  /* In an interleaved scan, an MCU row is the same as an iMCU row.   * In a noninterleaved scan, an iMCU row has v_samp_factor MCU rows.   * But at the bottom of the image, process only what's left.   */  if (cinfo->comps_in_scan > 1) {    coef->MCU_rows_per_iMCU_row = 1;  } else {    if (coef->iMCU_row_num < (cinfo->total_iMCU_rows-1))      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->v_samp_factor;    else      coef->MCU_rows_per_iMCU_row = cinfo->cur_comp_info[0]->last_row_height;  }  coef->mcu_ctr = 0;  coef->MCU_vert_offset = 0;}#endif/* * Initialize for a processing pass. */#if 0METHODDEF(void)start_pass_coef (j_compress_ptr cinfo, J_BUF_MODE pass_mode){  my_coef_ptr coef = (my_coef_ptr) cinfo->coef;  if (pass_mode != JBUF_CRANK_DEST)    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);  coef->iMCU_row_num = 0;  start_iMCU_row(cinfo);}#endif/* * Initialize coefficient buffer controller. * * Each passed coefficient array must be the right size for that * coefficient: width_in_blocks wide and height_in_blocks high, * with unitheight at least v_samp_factor. */#if 0LOCAL(void)transencode_coef_controller (j_compress_ptr cinfo,			     jvirt_barray_ptr * coef_arrays){  my_coef_ptr coef;  JBLOCKROW buffer;  int i;  //coef = (my_coef_ptr)  //  (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,  //				SIZEOF(my_coef_controller));  cinfo->coef = (struct jpeg_c_coef_controller *) coef;  coef->pub.start_pass = start_pass_coef;    //coef->pub.compress_data = compress_output;  /* Save pointer to virtual arrays */  //coef->whole_image = coef_arrays;#if 0  /* Allocate and pre-zero space for dummy DCT blocks. */  buffer = (JBLOCKROW)    (*cinfo->mem->alloc_large) ((j_common_ptr) cinfo, JPOOL_IMAGE,				C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));   //local mem  jzero_far((void FAR *) buffer, C_MAX_BLOCKS_IN_MCU * SIZEOF(JBLOCK));  for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {    coef->dummy_buffer[i] = buffer + i;  }#endif}#endif

⌨️ 快捷键说明

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