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

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

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

revision 102, Fri Apr 5 14:42:37 2002 UTC revision 228, Thu Jun 20 10:51:08 2002 UTC
# Line 23  Line 23 
23   *   *
24   *      History:   *      History:
25   *   *
26     *      25.04.2002      ICDECOMPRESS_PREROLL
27     *      17.04.2002      re-enabled lumi masking for 1st pass
28     *      15.04.2002      updated cbr support
29   *      04.04.2002      separated 2-pass code to 2pass.c   *      04.04.2002      separated 2-pass code to 2pass.c
30   *                              interlacing support   *                              interlacing support
31   *                              hinted ME support   *                              hinted ME support
# Line 215  Line 218 
218    
219  LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)  LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)
220  {  {
221          return lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3;          return
222    #ifdef BFRAMES
223             2 *
224    #endif
225            lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3;
226  }  }
227    
228    
# Line 236  Line 243 
243          switch (codec->config.mode)          switch (codec->config.mode)
244          {          {
245          case DLG_MODE_CBR :          case DLG_MODE_CBR :
246                  param.bitrate = codec->config.bitrate;                  param.rc_bitrate = codec->config.rc_bitrate;
247                  param.rc_buffersize = codec->config.rc_buffersize;                  param.rc_reaction_delay_factor = codec->config.rc_reaction_delay_factor;
248                    param.rc_averaging_period = codec->config.rc_averaging_period;
249                    param.rc_buffer = codec->config.rc_buffer;
250                  break;                  break;
251    
252          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
253                  codec->config.fquant = 0;                  codec->config.fquant = 0;
254                  param.bitrate = 0;                  param.rc_bitrate = 0;
255                  break;                  break;
256    
257          case DLG_MODE_VBR_QUANT :          case DLG_MODE_VBR_QUANT :
258                  codec->config.fquant = (float) codec->config.quant;                  codec->config.fquant = (float) codec->config.quant;
259                  param.bitrate = 0;                  param.rc_bitrate = 0;
260                  break;                  break;
261    
262          case DLG_MODE_2PASS_1 :          case DLG_MODE_2PASS_1 :
263          case DLG_MODE_2PASS_2_INT :          case DLG_MODE_2PASS_2_INT :
264          case DLG_MODE_2PASS_2_EXT :          case DLG_MODE_2PASS_2_EXT :
265                  param.bitrate = 0;                  param.rc_bitrate = 0;
266                    codec->twopass.max_framesize = (int)((double)codec->config.twopass_max_bitrate / 8.0 / ((double)codec->fbase / (double)codec->fincr));
267                  break;                  break;
268    
269          case DLG_MODE_NULL :          case DLG_MODE_NULL :
# Line 279  Line 289 
289          param.fincr = codec->fincr;          param.fincr = codec->fincr;
290          param.fbase = codec->fbase;          param.fbase = codec->fbase;
291    
         param.rc_buffersize = codec->config.rc_buffersize;  
   
292          param.min_quantizer = codec->config.min_pquant;          param.min_quantizer = codec->config.min_pquant;
293          param.max_quantizer = codec->config.max_pquant;          param.max_quantizer = codec->config.max_pquant;
294          param.max_key_interval = codec->config.max_key_interval;          param.max_key_interval = codec->config.max_key_interval;
295    
296    #ifdef BFRAMES
297        param.packed = codec->config.packed;
298            param.max_bframes = codec->config.max_bframes;
299            param.bquant_ratio = codec->config.bquant_ratio;
300    #endif
301    
302          switch(xvid_encore(0, XVID_ENC_CREATE, &param, NULL))          switch(xvid_encore(0, XVID_ENC_CREATE, &param, NULL))
303          {          {
304          case XVID_ERR_FAIL :          case XVID_ERR_FAIL :
# Line 332  Line 346 
346                  }                  }
347    
348                  codec->ehandle = NULL;                  codec->ehandle = NULL;
349    
350                    codec_2pass_finish(codec);
351          }          }
352    
353          return ICERR_OK;          return ICERR_OK;
# Line 363  Line 379 
379          if(codec->config.motion_search > 4)          if(codec->config.motion_search > 4)
380                  frame.general |= XVID_INTER4V;                  frame.general |= XVID_INTER4V;
381    
382          if(((codec->config.mode == DLG_MODE_2PASS_1) ? 0 : codec->config.lum_masking) == 1)          if (codec->config.lum_masking)
383                  frame.general |= XVID_LUMIMASKING;                  frame.general |= XVID_LUMIMASKING;
384    
385          if (codec->config.interlacing)          if (codec->config.interlacing)
386                  frame.general |= XVID_INTERLACING;                  frame.general |= XVID_INTERLACING;
387    // fix 1pass modes/hinted MV by koepi
388            if (codec->config.hinted_me && (codec->config.mode == DLG_MODE_CBR || codec->config.mode == DLG_MODE_VBR_QUAL || codec->config.mode == DLG_MODE_VBR_QUANT))
389            {
390                    codec->config.hinted_me = 0;
391            }
392    // end of ugly hack
393    
394          if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1)          if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1)
395          {          {
# Line 375  Line 397 
397                  frame.hint.rawhints = 0;                  frame.hint.rawhints = 0;
398                  frame.general |= XVID_HINTEDME_GET;                  frame.general |= XVID_HINTEDME_GET;
399          }          }
400          else if (codec->config.mode == DLG_MODE_2PASS_2_EXT || codec->config.mode == DLG_MODE_2PASS_2_INT)          else if (codec->config.hinted_me && (codec->config.mode == DLG_MODE_2PASS_2_EXT || codec->config.mode == DLG_MODE_2PASS_2_INT))
401          {          {
402                  DWORD read;                  DWORD read;
403                  DWORD blocksize;                  DWORD blocksize;
# Line 478  Line 500 
500          {          {
501                  frame.intra = 1;                  frame.intra = 1;
502          }          }
503          else if ((codec->keyspacing < codec->config.min_key_interval && codec->framenum) &&          else if (codec->keyspacing < codec->config.min_key_interval && codec->framenum)
                 (codec->config.mode == DLG_MODE_2PASS_1))  
504          {          {
505                  DEBUG("current frame forced to p-frame");                  DEBUG("current frame forced to p-frame");
506                  frame.intra = 0;                  frame.intra = 0;
507          }          }
508    
509            OutputDebugString(" ");
510          switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats))          switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats))
511          {          {
512          case XVID_ERR_FAIL :          case XVID_ERR_FAIL :
# Line 663  Line 685 
685          frame.image = icd->lpOutput;          frame.image = icd->lpOutput;
686          frame.stride = icd->lpbiOutput->biWidth;          frame.stride = icd->lpbiOutput->biWidth;
687    
688          if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE)))          if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL)))
689          {          {
690                  if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL)                  if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL)
691                  {                  {

Legend:
Removed from v.102  
changed lines
  Added in v.228

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