[cvs] / xvidcore / vfw / src / codec.c Repository:
ViewVC logotype

Diff of /xvidcore/vfw/src/codec.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.32, Sat Jan 24 13:36:00 2004 UTC revision 1.1.2.36, Mon Feb 9 10:14:54 2004 UTC
# Line 57  Line 57 
57  #include "codec.h"  #include "codec.h"
58  #include "status.h"  #include "status.h"
59    
60    HINSTANCE m_hdll;
61    int (*xvid_global_func)(void *handle, int opt, void *param1, void *param2);
62    int (*xvid_encore_func)(void *handle, int opt, void *param1, void *param2);
63    int (*xvid_decore_func)(void *handle, int opt, void *param1, void *param2);
64    
65    xvid_plugin_func *xvid_plugin_single_func,
66                                    *xvid_plugin_2pass1_func,
67                                    *xvid_plugin_2pass2_func,
68                                    *xvid_plugin_lumimasking_func,
69                                    *xvid_plugin_psnr_func;
70    
71    
72    
73  static const int pmvfast_presets[7] = {  static const int pmvfast_presets[7] = {
74          0, 0, 0, 0,          0, 0, 0, 0,
# Line 72  Line 84 
84          or XVID_CSP_NULL if failure          or XVID_CSP_NULL if failure
85  */  */
86    
87  int get_colorspace(BITMAPINFOHEADER * hdr)  static int get_colorspace(BITMAPINFOHEADER * hdr)
88  {  {
89          /* rgb only: negative height specifies top down image */          /* rgb only: negative height specifies top down image */
90          int rgb_flip = (hdr->biHeight < 0 ? 0 : XVID_CSP_VFLIP);          int rgb_flip = (hdr->biHeight < 0 ? 0 : XVID_CSP_VFLIP);
# Line 254  Line 266 
266  }  }
267    
268    
269  const char type2char(int type)  static char type2char(int type)
270  {  {
271          if (type==XVID_TYPE_IVOP)          if (type==XVID_TYPE_IVOP)
272                  return 'I';                  return 'I';
# Line 265  Line 277 
277          return 'S';          return 'S';
278  }  }
279    
280  int vfw_debug(void *handle,  static int vfw_debug(void *handle,
281                           int opt,                           int opt,
282                           void *param1,                           void *param1,
283                           void *param2)                           void *param2)
# Line 346  Line 358 
358          return 0;          return 0;
359  }  }
360    
361  void  /* constant-quant zones for fixed quant encoding */
 sort_zones(zone_t * zones, int zone_num, int * sel);  
   
362  static void  static void
363  prepare_cquant_zones(CONFIG * config) {  prepare_cquant_zones(CONFIG * config) {
364    
# Line 380  Line 390 
390                  }                  }
391  }  }
392    
393    /* full first pass zones */
394    static void
395    prepare_full1pass_zones(CONFIG * config) {
396    
397            int i = 0;
398            if (config->num_zones == 0 || config->zones[0].frame != 0) {
399                    /* first zone does not start at frame 0 or doesn't exist */
400    
401                    if (config->num_zones >= MAX_ZONES) config->num_zones--; /* we scrifice last zone */
402    
403                    config->zones[config->num_zones].frame = 0;
404                    config->zones[config->num_zones].mode = RC_ZONE_QUANT;
405                    config->zones[config->num_zones].weight = 100;
406                    config->zones[config->num_zones].quant = 200;
407                    config->zones[config->num_zones].type = XVID_TYPE_AUTO;
408                    config->zones[config->num_zones].greyscale = 0;
409                    config->zones[config->num_zones].chroma_opt = 0;
410                    config->zones[config->num_zones].bvop_threshold = 0;
411                    config->num_zones++;
412    
413                    sort_zones(config->zones, config->num_zones, &i);
414            }
415    
416            /* step 2: let's change all weight zones into quant zones */
417    
418            for(i = 0; i < config->num_zones; i++)
419                    if (config->zones[i].mode == RC_ZONE_WEIGHT) {
420                            config->zones[i].mode = RC_ZONE_QUANT;
421                            config->zones[i].quant = 200;
422                    }
423    }
424    
425    
426  LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)  LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)
427  {  {
# Line 433  Line 475 
475                  memset(&pass1, 0, sizeof(pass1));                  memset(&pass1, 0, sizeof(pass1));
476                  pass1.version = XVID_VERSION;                  pass1.version = XVID_VERSION;
477                  pass1.filename = codec->config.stats;                  pass1.filename = codec->config.stats;
478                    if (codec->config.full1pass)
479                            prepare_full1pass_zones(&tmpCfg);
480                  plugins[create.num_plugins].func = xvid_plugin_2pass1_func;                  plugins[create.num_plugins].func = xvid_plugin_2pass1_func;
481                  plugins[create.num_plugins].param = &pass1;                  plugins[create.num_plugins].param = &pass1;
482                  create.num_plugins++;                  create.num_plugins++;
# Line 745  Line 788 
788          if ((frame.input.csp = get_colorspace(inhdr)) == XVID_CSP_NULL)          if ((frame.input.csp = get_colorspace(inhdr)) == XVID_CSP_NULL)
789                  return ICERR_BADFORMAT;                  return ICERR_BADFORMAT;
790    
791          if (frame.input.csp == XVID_CSP_I420 || frame.input.csp == XVID_CSP_YV12)          if (frame.input.csp == XVID_CSP_I420 || frame.input.csp == XVID_CSP_YV12) {
792                  frame.input.stride[0] = (frame.input.stride[0]*2)/3;                  frame.input.stride[0] = (4 * icc->lpbiInput->biWidth + 3) / 4;
793                    frame.input.stride[1] = frame.input.stride[2] = frame.input.stride[0] / 2 ;
794            }
795    
796          frame.bitstream = icc->lpOutput;          frame.bitstream = icc->lpOutput;
797          frame.length = icc->lpbiOutput->biSizeImage;          frame.length = icc->lpbiOutput->biSizeImage;

Legend:
Removed from v.1.1.2.32  
changed lines
  Added in v.1.1.2.36

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4