[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 361, Mon Aug 5 18:26:31 2002 UTC
# Line 23  Line 23 
23   *   *
24   *      History:   *      History:
25   *   *
26     *      12.07.2002      num_threads
27     *      23.06.2002      XVID_CPU_CHKONLY; loading speed up
28     *      25.04.2002      ICDECOMPRESS_PREROLL
29     *      17.04.2002      re-enabled lumi masking for 1st pass
30     *      15.04.2002      updated cbr support
31   *      04.04.2002      separated 2-pass code to 2pass.c   *      04.04.2002      separated 2-pass code to 2pass.c
32   *                              interlacing support   *                              interlacing support
33   *                              hinted ME support   *                              hinted ME support
# Line 54  Line 59 
59          PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8,          PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8,
60          PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 |          PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 |
61          PMV_EARLYSTOP8 | PMV_HALFPELREFINE8 | PMV_HALFPELDIAMOND8          PMV_EARLYSTOP8 | PMV_HALFPELREFINE8 | PMV_HALFPELDIAMOND8
62    //      | PMV_USESQUARES16
63  };  };
64    
65  /*      return xvid compatbile colorspace,  /*      return xvid compatbile colorspace,
# Line 215  Line 221 
221    
222  LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)  LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)
223  {  {
224          return lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3;          return
225    #ifdef BFRAMES
226             2 *
227    #endif
228            lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3;
229  }  }
230    
231    
# Line 236  Line 246 
246          switch (codec->config.mode)          switch (codec->config.mode)
247          {          {
248          case DLG_MODE_CBR :          case DLG_MODE_CBR :
249                  param.bitrate = codec->config.bitrate;                  param.rc_bitrate = codec->config.rc_bitrate;
250                  param.rc_buffersize = codec->config.rc_buffersize;                  param.rc_reaction_delay_factor = codec->config.rc_reaction_delay_factor;
251                    param.rc_averaging_period = codec->config.rc_averaging_period;
252                    param.rc_buffer = codec->config.rc_buffer;
253                  break;                  break;
254    
255          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
256                  codec->config.fquant = 0;                  codec->config.fquant = 0;
257                  param.bitrate = 0;                  param.rc_bitrate = 0;
258                  break;                  break;
259    
260          case DLG_MODE_VBR_QUANT :          case DLG_MODE_VBR_QUANT :
261                  codec->config.fquant = (float) codec->config.quant;                  codec->config.fquant = (float) codec->config.quant;
262                  param.bitrate = 0;                  param.rc_bitrate = 0;
263                  break;                  break;
264    
265          case DLG_MODE_2PASS_1 :          case DLG_MODE_2PASS_1 :
266          case DLG_MODE_2PASS_2_INT :          case DLG_MODE_2PASS_2_INT :
267          case DLG_MODE_2PASS_2_EXT :          case DLG_MODE_2PASS_2_EXT :
268                  param.bitrate = 0;                  param.rc_bitrate = 0;
269                    codec->twopass.max_framesize = (int)((double)codec->config.twopass_max_bitrate / 8.0 / ((double)codec->fbase / (double)codec->fincr));
270                  break;                  break;
271    
272          case DLG_MODE_NULL :          case DLG_MODE_NULL :
# Line 279  Line 292 
292          param.fincr = codec->fincr;          param.fincr = codec->fincr;
293          param.fbase = codec->fbase;          param.fbase = codec->fbase;
294    
         param.rc_buffersize = codec->config.rc_buffersize;  
   
295          param.min_quantizer = codec->config.min_pquant;          param.min_quantizer = codec->config.min_pquant;
296          param.max_quantizer = codec->config.max_pquant;          param.max_quantizer = codec->config.max_pquant;
297          param.max_key_interval = codec->config.max_key_interval;          param.max_key_interval = codec->config.max_key_interval;
298    
299    #ifdef _SMP
300            param.num_threads = codec->config.num_threads;
301    #endif
302    
303    #ifdef BFRAMES
304            param.global = 0;
305            if (codec->config.packed) param.global |= XVID_GLOBAL_PACKED;
306            if (codec->config.dx50bvop) param.global |= XVID_GLOBAL_DX50BVOP;
307            if (codec->config.debug) param.global |= XVID_GLOBAL_DEBUG;
308            param.max_bframes = codec->config.max_bframes;
309            param.bquant_ratio = codec->config.bquant_ratio;
310            param.frame_drop_ratio = codec->config.frame_drop_ratio;
311    #endif
312    
313          switch(xvid_encore(0, XVID_ENC_CREATE, &param, NULL))          switch(xvid_encore(0, XVID_ENC_CREATE, &param, NULL))
314          {          {
315          case XVID_ERR_FAIL :          case XVID_ERR_FAIL :
# Line 332  Line 357 
357                  }                  }
358    
359                  codec->ehandle = NULL;                  codec->ehandle = NULL;
360    
361                    codec_2pass_finish(codec);
362          }          }
363    
364          return ICERR_OK;          return ICERR_OK;
# Line 359  Line 386 
386          frame.intra = -1;          frame.intra = -1;
387    
388          frame.general |= XVID_HALFPEL;          frame.general |= XVID_HALFPEL;
389    //      frame.general |= XVID_ME_EPZS;
390    
391          if(codec->config.motion_search > 4)          if(codec->config.motion_search > 4)
392                  frame.general |= XVID_INTER4V;                  frame.general |= XVID_INTER4V;
393    
394          if(((codec->config.mode == DLG_MODE_2PASS_1) ? 0 : codec->config.lum_masking) == 1)          if (codec->config.lum_masking)
395                  frame.general |= XVID_LUMIMASKING;                  frame.general |= XVID_LUMIMASKING;
396    
397          if (codec->config.interlacing)          if (codec->config.interlacing)
398                  frame.general |= XVID_INTERLACING;                  frame.general |= XVID_INTERLACING;
399    
400    // added by koepi for credits greyscale
401            check_greyscale_mode(&codec->config, &frame, codec->framenum);
402    // end of koepi's addition
403    
404    // fix 1pass modes/hinted MV by koepi
405            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))
406            {
407                    codec->config.hinted_me = 0;
408            }
409    // end of ugly hack
410    
411          if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1)          if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1)
412          {          {
413                  frame.hint.hintstream = codec->twopass.hintstream;                  frame.hint.hintstream = codec->twopass.hintstream;
414                  frame.hint.rawhints = 0;                  frame.hint.rawhints = 0;
415                  frame.general |= XVID_HINTEDME_GET;                  frame.general |= XVID_HINTEDME_GET;
416          }          }
417          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))
418          {          {
419                  DWORD read;                  DWORD read;
420                  DWORD blocksize;                  DWORD blocksize;
# Line 478  Line 517 
517          {          {
518                  frame.intra = 1;                  frame.intra = 1;
519          }          }
520          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))  
521          {          {
522                  DEBUG("current frame forced to p-frame");                  DEBUG("current frame forced to p-frame");
523                  frame.intra = 0;                  frame.intra = 0;
524          }          }
525    
526    #ifdef BFRAMES
527            frame.bquant = 0;
528    #endif
529    
530    //      OutputDebugString(" ");
531          switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats))          switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats))
532          {          {
533          case XVID_ERR_FAIL :          case XVID_ERR_FAIL :
# Line 663  Line 706 
706          frame.image = icd->lpOutput;          frame.image = icd->lpOutput;
707          frame.stride = icd->lpbiOutput->biWidth;          frame.stride = icd->lpbiOutput->biWidth;
708    
709          if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE)))          if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL)))
710          {          {
711                  if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL)                  if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL)
712                  {                  {
# Line 697  Line 740 
740          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
741                  if (codec_is_in_credits(&codec->config, codec->framenum))                  if (codec_is_in_credits(&codec->config, codec->framenum))
742                  {                  {
743    // added by koepi for credits greyscale
744                            check_greyscale_mode(&codec->config, frame, codec->framenum);
745    // end of koepi's addition
746                          switch (codec->config.credits_mode)                          switch (codec->config.credits_mode)
747                          {                          {
748                          case CREDITS_MODE_RATE :                          case CREDITS_MODE_RATE :
# Line 714  Line 760 
760                  }                  }
761                  else                  else
762                  {                  {
763    // added by koepi for credits greyscale
764                            check_greyscale_mode(&codec->config, frame, codec->framenum);
765    // end of koepi's addition
766                          frame->quant = codec_get_vbr_quant(&codec->config, codec->config.quality);                          frame->quant = codec_get_vbr_quant(&codec->config, codec->config.quality);
767                  }                  }
768                  return ICERR_OK;                  return ICERR_OK;
# Line 721  Line 770 
770          case DLG_MODE_VBR_QUANT :          case DLG_MODE_VBR_QUANT :
771                  if (codec_is_in_credits(&codec->config, codec->framenum))                  if (codec_is_in_credits(&codec->config, codec->framenum))
772                  {                  {
773    // added by koepi for credits greyscale
774                            check_greyscale_mode(&codec->config, frame, codec->framenum);
775    // end of koepi's addition
776                          switch (codec->config.credits_mode)                          switch (codec->config.credits_mode)
777                          {                          {
778                          case CREDITS_MODE_RATE :                          case CREDITS_MODE_RATE :
# Line 740  Line 792 
792                  }                  }
793                  else                  else
794                  {                  {
795    // added by koepi for credits greyscale
796                            check_greyscale_mode(&codec->config, frame, codec->framenum);
797    // end of koepi's addition
798                          frame->quant = codec->config.quant;                          frame->quant = codec->config.quant;
799                  }                  }
800                  return ICERR_OK;                  return ICERR_OK;
801    
802          case DLG_MODE_2PASS_1 :          case DLG_MODE_2PASS_1 :
803    // added by koepi for credits greyscale
804                    check_greyscale_mode(&codec->config, frame, codec->framenum);
805    // end of koepi's addition
806                  if (codec->config.credits_mode == CREDITS_MODE_QUANT)                  if (codec->config.credits_mode == CREDITS_MODE_QUANT)
807                  {                  {
808                          if (codec_is_in_credits(&codec->config, codec->framenum))                          if (codec_is_in_credits(&codec->config, codec->framenum))
# Line 835  Line 893 
893          return quant;          return quant;
894  }  }
895    
896    // added by koepi for credits greyscale
897    int check_greyscale_mode(CONFIG* config, XVID_ENC_FRAME* frame, int framenum)
898    {
899            if ((codec_is_in_credits(config, framenum)) && (config->mode!=DLG_MODE_CBR))
900            {
901                    if (config->credits_greyscale)
902                    {
903                            if ((frame->general && XVID_GREYSCALE))  // use only if not already in greyscale
904                                    frame->general |= XVID_GREYSCALE;
905                    } else {
906                            if (!(frame->general && XVID_GREYSCALE))  // if movie is in greyscale, switch back
907                                    frame->general |= XVID_GREYSCALE;
908                    }
909            } else {
910                    if (config->greyscale)
911                    {
912                            if ((frame->general && XVID_GREYSCALE))  // use only if not already in greyscale
913                                    frame->general |= XVID_GREYSCALE;
914                    } else {
915                            if (!(frame->general && XVID_GREYSCALE))  // if credits is in greyscale, switch back
916                                    frame->general |= XVID_GREYSCALE;
917                    }
918            }
919            return 0;
920    }
921    // end of koepi's addition

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

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