[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

trunk/vfw/src/codec.c revision 105, Sat Apr 6 06:21:29 2002 UTC branches/dev-api-3/vfw/src/codec.c revision 392, Wed Sep 4 18:44:41 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 51  Line 56 
56  int pmvfast_presets[7] = {  int pmvfast_presets[7] = {
57          0, PMV_QUICKSTOP16, PMV_EARLYSTOP16, PMV_EARLYSTOP16 | PMV_EARLYSTOP8,          0, PMV_QUICKSTOP16, PMV_EARLYSTOP16, PMV_EARLYSTOP16 | PMV_EARLYSTOP8,
58          PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8,          PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EARLYSTOP8 | PMV_HALFPELDIAMOND8,
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_ADVANCEDDIAMOND16, PMV_EARLYSTOP16 | PMV_HALFPELREFINE16 | PMV_EXTSEARCH16 |
61          PMV_EARLYSTOP8 | PMV_HALFPELREFINE8 | PMV_HALFPELDIAMOND8          PMV_EARLYSTOP8 | PMV_HALFPELREFINE8 | PMV_HALFPELDIAMOND8 | PMV_USESQUARES16
62  };  };
63    
64  /*      return xvid compatbile colorspace,  /*      return xvid compatbile colorspace,
# Line 215  Line 220 
220    
221  LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)  LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)
222  {  {
223          return lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3;          return
224    #ifdef BFRAMES
225             2 *
226    #endif
227            lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3;
228  }  }
229    
230    
# Line 236  Line 245 
245          switch (codec->config.mode)          switch (codec->config.mode)
246          {          {
247          case DLG_MODE_CBR :          case DLG_MODE_CBR :
248                  param.bitrate = codec->config.bitrate;                  param.rc_bitrate = codec->config.rc_bitrate;
249                  param.rc_buffersize = codec->config.rc_buffersize;                  param.rc_reaction_delay_factor = codec->config.rc_reaction_delay_factor;
250                    param.rc_averaging_period = codec->config.rc_averaging_period;
251                    param.rc_buffer = codec->config.rc_buffer;
252                  break;                  break;
253    
254          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
255                  codec->config.fquant = 0;                  codec->config.fquant = 0;
256                  param.bitrate = 0;                  param.rc_bitrate = 0;
257                  break;                  break;
258    
259          case DLG_MODE_VBR_QUANT :          case DLG_MODE_VBR_QUANT :
260                  codec->config.fquant = (float) codec->config.quant;                  codec->config.fquant = (float) codec->config.quant;
261                  param.bitrate = 0;                  param.rc_bitrate = 0;
262                  break;                  break;
263    
264          case DLG_MODE_2PASS_1 :          case DLG_MODE_2PASS_1 :
265          case DLG_MODE_2PASS_2_INT :          case DLG_MODE_2PASS_2_INT :
266          case DLG_MODE_2PASS_2_EXT :          case DLG_MODE_2PASS_2_EXT :
267                  param.bitrate = 0;                  param.rc_bitrate = 0;
268                    codec->twopass.max_framesize = (int)((double)codec->config.twopass_max_bitrate / 8.0 / ((double)codec->fbase / (double)codec->fincr));
269                  break;                  break;
270    
271          case DLG_MODE_NULL :          case DLG_MODE_NULL :
# Line 279  Line 291 
291          param.fincr = codec->fincr;          param.fincr = codec->fincr;
292          param.fbase = codec->fbase;          param.fbase = codec->fbase;
293    
         param.rc_buffersize = codec->config.rc_buffersize;  
   
294          param.min_quantizer = codec->config.min_pquant;          param.min_quantizer = codec->config.min_pquant;
295          param.max_quantizer = codec->config.max_pquant;          param.max_quantizer = codec->config.max_pquant;
296          param.max_key_interval = codec->config.max_key_interval;          param.max_key_interval = codec->config.max_key_interval;
297    
298    #ifdef _SMP
299            param.num_threads = codec->config.num_threads;
300    #endif
301    
302    #ifdef BFRAMES
303            param.global = 0;
304            if (codec->config.packed) param.global |= XVID_GLOBAL_PACKED;
305            if (codec->config.dx50bvop) param.global |= XVID_GLOBAL_DX50BVOP;
306            if (codec->config.debug) param.global |= XVID_GLOBAL_DEBUG;
307            param.max_bframes = codec->config.max_bframes;
308            param.bquant_ratio = codec->config.bquant_ratio;
309            param.frame_drop_ratio = codec->config.frame_drop_ratio;
310    #endif
311    
312          switch(xvid_encore(0, XVID_ENC_CREATE, &param, NULL))          switch(xvid_encore(0, XVID_ENC_CREATE, &param, NULL))
313          {          {
314          case XVID_ERR_FAIL :          case XVID_ERR_FAIL :
# Line 361  Line 385 
385          frame.intra = -1;          frame.intra = -1;
386    
387          frame.general |= XVID_HALFPEL;          frame.general |= XVID_HALFPEL;
388    //      frame.general |= XVID_ME_EPZS;
389    
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    
401    
402    // added by koepi for credits greyscale
403    
404            check_greyscale_mode(&codec->config, &frame, codec->framenum);
405    
406    // end of koepi's addition
407    
408    
409    // fix 1pass modes/hinted MV by koepi
410            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))
411            {
412                    codec->config.hinted_me = 0;
413            }
414    // end of ugly hack
415    
416          if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1)          if (codec->config.hinted_me && codec->config.mode == DLG_MODE_2PASS_1)
417          {          {
418                  frame.hint.hintstream = codec->twopass.hintstream;                  frame.hint.hintstream = codec->twopass.hintstream;
# Line 480  Line 522 
522          {          {
523                  frame.intra = 1;                  frame.intra = 1;
524          }          }
525          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 || codec->config.mode == DLG_MODE_CBR || codec->config.mode == DLG_MODE_VBR_QUANT ||  
                 codec->config.mode == DLG_MODE_VBR_QUAL || codec->config.mode == DLG_MODE_NULL))  
526          {          {
527                  DEBUG("current frame forced to p-frame");                  DEBUG("current frame forced to p-frame");
528                  frame.intra = 0;                  frame.intra = 0;
529          }          }
530    
531    #ifdef BFRAMES
532            frame.bquant = 0;
533    #endif
534    
535    //      OutputDebugString(" ");
536          switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats))          switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats))
537          {          {
538          case XVID_ERR_FAIL :          case XVID_ERR_FAIL :
# Line 666  Line 711 
711          frame.image = icd->lpOutput;          frame.image = icd->lpOutput;
712          frame.stride = icd->lpbiOutput->biWidth;          frame.stride = icd->lpbiOutput->biWidth;
713    
714          if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE)))          if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL)))
715          {          {
716                  if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL)                  if ((frame.colorspace = get_colorspace(icd->lpbiOutput)) == XVID_CSP_NULL)
717                  {                  {
# Line 700  Line 745 
745          case DLG_MODE_VBR_QUAL :          case DLG_MODE_VBR_QUAL :
746                  if (codec_is_in_credits(&codec->config, codec->framenum))                  if (codec_is_in_credits(&codec->config, codec->framenum))
747                  {                  {
748    // added by koepi for credits greyscale
749    
750                            check_greyscale_mode(&codec->config, frame, codec->framenum);
751    
752    // end of koepi's addition
753    
754                          switch (codec->config.credits_mode)                          switch (codec->config.credits_mode)
755                          {                          {
756                          case CREDITS_MODE_RATE :                          case CREDITS_MODE_RATE :
# Line 717  Line 768 
768                  }                  }
769                  else                  else
770                  {                  {
771    // added by koepi for credits greyscale
772    
773                            check_greyscale_mode(&codec->config, frame, codec->framenum);
774    
775    // end of koepi's addition
776    
777                          frame->quant = codec_get_vbr_quant(&codec->config, codec->config.quality);                          frame->quant = codec_get_vbr_quant(&codec->config, codec->config.quality);
778                  }                  }
779                  return ICERR_OK;                  return ICERR_OK;
# Line 724  Line 781 
781          case DLG_MODE_VBR_QUANT :          case DLG_MODE_VBR_QUANT :
782                  if (codec_is_in_credits(&codec->config, codec->framenum))                  if (codec_is_in_credits(&codec->config, codec->framenum))
783                  {                  {
784    // added by koepi for credits greyscale
785    
786                            check_greyscale_mode(&codec->config, frame, codec->framenum);
787    
788    // end of koepi's addition
789    
790                          switch (codec->config.credits_mode)                          switch (codec->config.credits_mode)
791                          {                          {
792                          case CREDITS_MODE_RATE :                          case CREDITS_MODE_RATE :
# Line 743  Line 806 
806                  }                  }
807                  else                  else
808                  {                  {
809    // added by koepi for credits greyscale
810    
811                            check_greyscale_mode(&codec->config, frame, codec->framenum);
812    
813    // end of koepi's addition
814    
815                          frame->quant = codec->config.quant;                          frame->quant = codec->config.quant;
816                  }                  }
817                  return ICERR_OK;                  return ICERR_OK;
818    
819          case DLG_MODE_2PASS_1 :          case DLG_MODE_2PASS_1 :
820    // added by koepi for credits greyscale
821    
822                    check_greyscale_mode(&codec->config, frame, codec->framenum);
823    
824    // end of koepi's addition
825    
826                  if (codec->config.credits_mode == CREDITS_MODE_QUANT)                  if (codec->config.credits_mode == CREDITS_MODE_QUANT)
827                  {                  {
828                          if (codec_is_in_credits(&codec->config, codec->framenum))                          if (codec_is_in_credits(&codec->config, codec->framenum))
# Line 838  Line 913 
913          return quant;          return quant;
914  }  }
915    
916    // added by koepi for credits greyscale
917    
918    int check_greyscale_mode(CONFIG* config, XVID_ENC_FRAME* frame, int framenum)
919    
920    {
921    
922            if ((codec_is_in_credits(config, framenum)) && (config->mode!=DLG_MODE_CBR))
923    
924            {
925    
926                    if (config->credits_greyscale)
927    
928                    {
929    
930                            if ((frame->general && XVID_GREYSCALE))  // use only if not already in greyscale
931    
932                                    frame->general |= XVID_GREYSCALE;
933    
934                    } else {
935    
936                            if (!(frame->general && XVID_GREYSCALE))  // if movie is in greyscale, switch back
937    
938                                    frame->general |= XVID_GREYSCALE;
939    
940                    }
941    
942            } else {
943    
944                    if (config->greyscale)
945    
946                    {
947    
948                            if ((frame->general && XVID_GREYSCALE))  // use only if not already in greyscale
949    
950                                    frame->general |= XVID_GREYSCALE;
951    
952                    } else {
953    
954                            if (!(frame->general && XVID_GREYSCALE))  // if credits is in greyscale, switch back
955    
956                                    frame->general |= XVID_GREYSCALE;
957    
958                    }
959    
960            }
961    
962            return 0;
963    
964    }
965    
966    // end of koepi's addition
967    

Legend:
Removed from v.105  
changed lines
  Added in v.392

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