jdmainct.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * jdmainct.h
  3. *
  4. * This file was part of the Independent JPEG Group's software:
  5. * Copyright (C) 1994-1996, Thomas G. Lane.
  6. * For conditions of distribution and use, see the accompanying README.ijg
  7. * file.
  8. */
  9. #define JPEG_INTERNALS
  10. #include "jpeglib.h"
  11. #include "jpegcomp.h"
  12. /* Private buffer controller object */
  13. typedef struct {
  14. struct jpeg_d_main_controller pub; /* public fields */
  15. /* Pointer to allocated workspace (M or M+2 row groups). */
  16. JSAMPARRAY buffer[MAX_COMPONENTS];
  17. boolean buffer_full; /* Have we gotten an iMCU row from decoder? */
  18. JDIMENSION rowgroup_ctr; /* counts row groups output to postprocessor */
  19. /* Remaining fields are only used in the context case. */
  20. /* These are the master pointers to the funny-order pointer lists. */
  21. JSAMPIMAGE xbuffer[2]; /* pointers to weird pointer lists */
  22. int whichptr; /* indicates which pointer set is now in use */
  23. int context_state; /* process_data state machine status */
  24. JDIMENSION rowgroups_avail; /* row groups available to postprocessor */
  25. JDIMENSION iMCU_row_ctr; /* counts iMCU rows to detect image top/bot */
  26. } my_main_controller;
  27. typedef my_main_controller *my_main_ptr;
  28. /* context_state values: */
  29. #define CTX_PREPARE_FOR_IMCU 0 /* need to prepare for MCU row */
  30. #define CTX_PROCESS_IMCU 1 /* feeding iMCU to postprocessor */
  31. #define CTX_POSTPONED_ROW 2 /* feeding postponed row group */
  32. LOCAL(void)
  33. set_wraparound_pointers(j_decompress_ptr cinfo)
  34. /* Set up the "wraparound" pointers at top and bottom of the pointer lists.
  35. * This changes the pointer list state from top-of-image to the normal state.
  36. */
  37. {
  38. my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
  39. int ci, i, rgroup;
  40. int M = cinfo->_min_DCT_scaled_size;
  41. jpeg_component_info *compptr;
  42. JSAMPARRAY xbuf0, xbuf1;
  43. for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
  44. ci++, compptr++) {
  45. rgroup = (compptr->v_samp_factor * compptr->_DCT_scaled_size) /
  46. cinfo->_min_DCT_scaled_size; /* height of a row group of component */
  47. xbuf0 = main_ptr->xbuffer[0][ci];
  48. xbuf1 = main_ptr->xbuffer[1][ci];
  49. for (i = 0; i < rgroup; i++) {
  50. xbuf0[i - rgroup] = xbuf0[rgroup * (M + 1) + i];
  51. xbuf1[i - rgroup] = xbuf1[rgroup * (M + 1) + i];
  52. xbuf0[rgroup * (M + 2) + i] = xbuf0[i];
  53. xbuf1[rgroup * (M + 2) + i] = xbuf1[i];
  54. }
  55. }
  56. }