[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 611, Thu Oct 24 14:45:24 2002 UTC revision 716, Sat Dec 14 06:09:33 2002 UTC
# Line 172  Line 172 
172          }          }
173    
174          if (inhdr->biWidth != outhdr->biWidth || inhdr->biHeight != outhdr->biHeight ||          if (inhdr->biWidth != outhdr->biWidth || inhdr->biHeight != outhdr->biHeight ||
175                  (outhdr->biCompression != FOURCC_XVID && outhdr->biCompression != FOURCC_DIVX))                  (outhdr->biCompression != FOURCC_XVID && outhdr->biCompression != FOURCC_DIVX && outhdr->biCompression != FOURCC_DX50))
176          {          {
177                  return ICERR_BADFORMAT;                  return ICERR_BADFORMAT;
178          }          }
# Line 223  Line 223 
223    
224  LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)  LRESULT compress_get_size(CODEC * codec, BITMAPINFO * lpbiInput, BITMAPINFO * lpbiOutput)
225  {  {
226          return          return 2 * lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3;
 #ifdef BFRAMES  
          2 *  
 #endif  
         lpbiOutput->bmiHeader.biWidth * lpbiOutput->bmiHeader.biHeight * 3;  
227  }  }
228    
229    
# Line 302  Line 298 
298          param.num_threads = codec->config.num_threads;          param.num_threads = codec->config.num_threads;
299  #endif  #endif
300    
 #ifdef BFRAMES  
301          param.global = 0;          param.global = 0;
302          if (codec->config.packed) param.global |= XVID_GLOBAL_PACKED;          if (codec->config.packed) param.global |= XVID_GLOBAL_PACKED;
303          if (codec->config.dx50bvop) param.global |= XVID_GLOBAL_DX50BVOP;          if (codec->config.dx50bvop) param.global |= XVID_GLOBAL_DX50BVOP;
304          if (codec->config.debug) param.global |= XVID_GLOBAL_DEBUG;          if (codec->config.debug) param.global |= XVID_GLOBAL_DEBUG;
305            if (codec->config.reduced_resolution) param.global |= XVID_GLOBAL_REDUCED;
306          param.max_bframes = codec->config.max_bframes;          param.max_bframes = codec->config.max_bframes;
307          param.bquant_ratio = codec->config.bquant_ratio;          param.bquant_ratio = codec->config.bquant_ratio;
308            param.bquant_offset = codec->config.bquant_offset;
309          param.frame_drop_ratio = codec->config.frame_drop_ratio;          param.frame_drop_ratio = codec->config.frame_drop_ratio;
 #endif  
310    
311          switch(xvid_encore(0, XVID_ENC_CREATE, &param, NULL))          switch(xvid_encore(0, XVID_ENC_CREATE, &param, NULL))
312          {          {
# Line 400  Line 396 
396          if (codec->config.interlacing)          if (codec->config.interlacing)
397                  frame.general |= XVID_INTERLACING;                  frame.general |= XVID_INTERLACING;
398    
399            if (codec->config.qpel) {
400                    frame.general |= XVID_QUARTERPEL;
401                    frame.motion |= PMV_QUARTERPELREFINE16 | PMV_QUARTERPELREFINE8;
402            }
403    
404            if (codec->config.gmc)
405                    frame.general |= XVID_GMC;
406    
407            if (codec->config.chromame)
408                    frame.general |= XVID_ME_COLOUR;
409    
410            if (codec->config.reduced_resolution)
411                    frame.general |= XVID_REDUCED;
412    
413  // added by koepi for credits greyscale  // added by koepi for credits greyscale
414    
# Line 448  Line 456 
456                  }                  }
457          }          }
458    
459          frame.motion = pmvfast_presets[codec->config.motion_search];          frame.motion |= pmvfast_presets[codec->config.motion_search];
460    
461          frame.image = icc->lpInput;          frame.image = icc->lpInput;
462            // dev-api-3
463            frame.stride = (((icc->lpbiInput->biWidth * icc->lpbiInput->biBitCount) + 31) & ~31) >> 3;
464    
465          if ((frame.colorspace = get_colorspace(inhdr)) == XVID_CSP_NULL)          if ((frame.colorspace = get_colorspace(inhdr)) == XVID_CSP_NULL)
466                  return ICERR_BADFORMAT;                  return ICERR_BADFORMAT;
# Line 531  Line 541 
541                  frame.intra = 0;                  frame.intra = 0;
542          }          }
543    
 #ifdef BFRAMES  
544          frame.bquant = 0;          frame.bquant = 0;
 #endif  
545    
546  //      OutputDebugString(" ");  //      OutputDebugString(" ");
547          switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats))          switch (xvid_encore(codec->ehandle, XVID_ENC_ENCODE, &frame, &stats))
# Line 548  Line 556 
556                  return ICERR_BADFORMAT;                  return ICERR_BADFORMAT;
557          }          }
558    
559          if (frame.intra)          if (frame.intra==1)
560          {          {
561                  codec->keyspacing = 0;                  codec->keyspacing = 0;
562                  *icc->lpdwFlags = AVIIF_KEYFRAME;                  *icc->lpdwFlags = AVIIF_KEYFRAME;
# Line 587  Line 595 
595                  }                  }
596          }          }
597    
598    //quick fix for delayed frames
599    //      if (frame.intra != 5)
600          codec_2pass_update(codec, &frame, &stats);          codec_2pass_update(codec, &frame, &stats);
601    
602          ++codec->framenum;          ++codec->framenum;
# Line 609  Line 619 
619                  return ICERR_ERROR;                  return ICERR_ERROR;
620          }          }
621    
622          if (inhdr->biCompression != FOURCC_XVID && inhdr->biCompression != FOURCC_DIVX)          if (inhdr->biCompression != FOURCC_XVID && inhdr->biCompression != FOURCC_DIVX && inhdr->biCompression != FOURCC_DX50 && get_colorspace(inhdr) == XVID_CSP_NULL)
623          {          {
624                  return ICERR_BADFORMAT;                  return ICERR_BADFORMAT;
625          }          }
# Line 641  Line 651 
651                  return sizeof(BITMAPINFOHEADER);                  return sizeof(BITMAPINFOHEADER);
652          }          }
653    
654            /* --- yv12 --- */
655    
656            if (get_colorspace(inhdr) != XVID_CSP_NULL) {
657                    memcpy(outhdr, inhdr, sizeof(BITMAPINFOHEADER));
658                    // XXX: should we set outhdr->biSize ??
659                    return ICERR_OK;
660            }
661            /* --- yv12 --- */
662    
663          result = decompress_query(codec, lpbiInput, lpbiOutput);          result = decompress_query(codec, lpbiInput, lpbiOutput);
664          if (result != ICERR_OK)          if (result != ICERR_OK)
665          {          {
# Line 710  Line 729 
729    
730          frame.bitstream = icd->lpInput;          frame.bitstream = icd->lpInput;
731          frame.length = icd->lpbiInput->biSizeImage;          frame.length = icd->lpbiInput->biSizeImage;
732            frame.general = XVID_DEC_LOWDELAY;      /* force low_delay_default mode */
733            if (codec->config.deblock_y)
734                    frame.general |= XVID_DEC_DEBLOCKY;
735            if (codec->config.deblock_uv)
736                    frame.general |= XVID_DEC_DEBLOCKUV;
737    
738          frame.image = icd->lpOutput;          frame.image = icd->lpOutput;
739          frame.stride = icd->lpbiOutput->biWidth;  //      frame.stride = icd->lpbiOutput->biWidth;
740            // dev-api-3:
741            frame.stride = (((icd->lpbiOutput->biWidth * icd->lpbiOutput->biBitCount) + 31) & ~31) >> 3;
742    
743            /* --- yv12 --- */
744            if (icd->lpbiInput->biCompression != FOURCC_XVID &&
745                     icd->lpbiInput->biCompression != FOURCC_DIVX &&
746                     icd->lpbiInput->biCompression != FOURCC_DX50)
747            {
748                    XVID_INIT_CONVERTINFO convert;
749                    DEBUGFOURCC("input", icd->lpbiInput->biCompression);
750                    DEBUGFOURCC("output", icd->lpbiOutput->biCompression);
751                    convert.input.colorspace = get_colorspace(icd->lpbiInput);
752                    convert.input.y = icd->lpInput;
753                    convert.input.y_stride = (((icd->lpbiInput->biWidth *icd->lpbiInput->biBitCount) + 31) & ~31) >> 3;
754                    convert.output.colorspace = get_colorspace(icd->lpbiOutput);
755                    convert.output.y = icd->lpOutput;
756                    convert.output.y_stride = (((icd->lpbiOutput->biWidth *icd->lpbiOutput->biBitCount) + 31) & ~31) >> 3;
757                    convert.width = icd->lpbiInput->biWidth;
758                    convert.height = icd->lpbiInput->biHeight;
759                    convert.interlacing = 0;
760                    if (convert.input.colorspace == XVID_CSP_NULL ||
761                            convert.output.colorspace == XVID_CSP_NULL ||
762                            xvid_init(NULL, XVID_INIT_CONVERT, &convert, NULL) != XVID_ERR_OK)
763                    {
764                             return ICERR_BADFORMAT;
765                    }
766                    return ICERR_OK;
767            }
768            /* --- yv12 --- */
769    
770    
771          if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL)))          if (~((icd->dwFlags & ICDECOMPRESS_HURRYUP) | (icd->dwFlags & ICDECOMPRESS_UPDATE) | (icd->dwFlags & ICDECOMPRESS_PREROLL)))
772          {          {

Legend:
Removed from v.611  
changed lines
  Added in v.716

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