[svn] / branches / dev-api-4 / xvidcore / vfw / src / codec.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/vfw/src/codec.c

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

revision 1329, Sat Jan 24 13:36:00 2004 UTC revision 1356, Sun Feb 8 12:57:07 2004 UTC
# Line 72  Line 72 
72          or XVID_CSP_NULL if failure          or XVID_CSP_NULL if failure
73  */  */
74    
75  int get_colorspace(BITMAPINFOHEADER * hdr)  static int get_colorspace(BITMAPINFOHEADER * hdr)
76  {  {
77          /* rgb only: negative height specifies top down image */          /* rgb only: negative height specifies top down image */
78          int rgb_flip = (hdr->biHeight < 0 ? 0 : XVID_CSP_VFLIP);          int rgb_flip = (hdr->biHeight < 0 ? 0 : XVID_CSP_VFLIP);
# Line 254  Line 254 
254  }  }
255    
256    
257  const char type2char(int type)  static char type2char(int type)
258  {  {
259          if (type==XVID_TYPE_IVOP)          if (type==XVID_TYPE_IVOP)
260                  return 'I';                  return 'I';
# Line 265  Line 265 
265          return 'S';          return 'S';
266  }  }
267    
268  int vfw_debug(void *handle,  static int vfw_debug(void *handle,
269                           int opt,                           int opt,
270                           void *param1,                           void *param1,
271                           void *param2)                           void *param2)
# Line 346  Line 346 
346          return 0;          return 0;
347  }  }
348    
349  void  /* constant-quant zones for fixed quant encoding */
 sort_zones(zone_t * zones, int zone_num, int * sel);  
   
350  static void  static void
351  prepare_cquant_zones(CONFIG * config) {  prepare_cquant_zones(CONFIG * config) {
352    
# Line 380  Line 378 
378                  }                  }
379  }  }
380    
381    /* full first pass zones */
382    static void
383    prepare_full1pass_zones(CONFIG * config) {
384    
385            int i = 0;
386            if (config->num_zones == 0 || config->zones[0].frame != 0) {
387                    /* first zone does not start at frame 0 or doesn't exist */
388    
389                    if (config->num_zones >= MAX_ZONES) config->num_zones--; /* we scrifice last zone */
390    
391                    config->zones[config->num_zones].frame = 0;
392                    config->zones[config->num_zones].mode = RC_ZONE_QUANT;
393                    config->zones[config->num_zones].weight = 100;
394                    config->zones[config->num_zones].quant = 200;
395                    config->zones[config->num_zones].type = XVID_TYPE_AUTO;
396                    config->zones[config->num_zones].greyscale = 0;
397                    config->zones[config->num_zones].chroma_opt = 0;
398                    config->zones[config->num_zones].bvop_threshold = 0;
399                    config->num_zones++;
400    
401                    sort_zones(config->zones, config->num_zones, &i);
402            }
403    
404            /* step 2: let's change all weight zones into quant zones */
405    
406            for(i = 0; i < config->num_zones; i++)
407                    if (config->zones[i].mode == RC_ZONE_WEIGHT) {
408                            config->zones[i].mode = RC_ZONE_QUANT;
409                            config->zones[i].quant = 200;
410                    }
411    }
412    
413    
414  LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)  LRESULT compress_begin(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)
415  {  {
# Line 433  Line 463 
463                  memset(&pass1, 0, sizeof(pass1));                  memset(&pass1, 0, sizeof(pass1));
464                  pass1.version = XVID_VERSION;                  pass1.version = XVID_VERSION;
465                  pass1.filename = codec->config.stats;                  pass1.filename = codec->config.stats;
466                    if (codec->config.full1pass)
467                            prepare_full1pass_zones(&tmpCfg);
468                  plugins[create.num_plugins].func = xvid_plugin_2pass1_func;                  plugins[create.num_plugins].func = xvid_plugin_2pass1_func;
469                  plugins[create.num_plugins].param = &pass1;                  plugins[create.num_plugins].param = &pass1;
470                  create.num_plugins++;                  create.num_plugins++;
# Line 745  Line 776 
776          if ((frame.input.csp = get_colorspace(inhdr)) == XVID_CSP_NULL)          if ((frame.input.csp = get_colorspace(inhdr)) == XVID_CSP_NULL)
777                  return ICERR_BADFORMAT;                  return ICERR_BADFORMAT;
778    
779          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) {
780                  frame.input.stride[0] = (frame.input.stride[0]*2)/3;                  frame.input.stride[0] = (4 * icc->lpbiInput->biWidth + 3) / 4;
781                    frame.input.stride[1] = frame.input.stride[2] = frame.input.stride[0] / 2 ;
782            }
783    
784          frame.bitstream = icc->lpOutput;          frame.bitstream = icc->lpOutput;
785          frame.length = icc->lpbiOutput->biSizeImage;          frame.length = icc->lpbiOutput->biSizeImage;

Legend:
Removed from v.1329  
changed lines
  Added in v.1356

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