[svn] / trunk / xvidcore / vfw / src / codec.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/vfw/src/codec.c

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

revision 1922, Mon Dec 27 16:11:05 2010 UTC revision 2140, Tue Sep 27 16:09:30 2016 UTC
# Line 19  Line 19 
19   *      along with this program; if not, write to the Free Software   *      along with this program; if not, write to the Free Software
20   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21   *   *
22   * $Id: codec.c,v 1.30 2010-12-27 16:11:05 Isibaar Exp $   * $Id$
23   *   *
24   *************************************************************************/   *************************************************************************/
25    
# Line 159  Line 159 
159                  return ICERR_BADFORMAT;                  return ICERR_BADFORMAT;
160          }          }
161    
162            if ((inhdr->biWidth % 4) || (inhdr->biHeight % 4))
163            {
164                    return ICERR_BADFORMAT;
165            }
166    
167          if (lpbiOutput == NULL)          if (lpbiOutput == NULL)
168          {          {
169                  return ICERR_OK;                  return ICERR_OK;
# Line 437  Line 442 
442          if ((profiles[codec->config.profile].flags & PROFILE_RESYNCMARKER) && codec->config.num_slices != 1) {          if ((profiles[codec->config.profile].flags & PROFILE_RESYNCMARKER) && codec->config.num_slices != 1) {
443    
444                  if (codec->config.num_slices == 0) { /* auto */                  if (codec->config.num_slices == 0) { /* auto */
445                          int rows = (lpbiInput->bmiHeader.biHeight + 15) / 16;                          int mb_width = (lpbiInput->bmiHeader.biWidth + 15) / 16;
446                          int slices = (rows > 36) ? 4 : 1; /* use multiple slices only for HD resolutions */                          int mb_height = (lpbiInput->bmiHeader.biHeight + 15) / 16;
447    
448                            int slices = (int)((mb_width*mb_height) / 811); /* use multiple slices only above SD resolutions for now */
449    
450                          create.num_slices = (rows > 45) ? 8 : slices;                          if (slices > 1) {
451                                    if (create.num_threads <= 1)
452                                            slices &= ~1; /* make even */
453                                    else if (create.num_threads <= slices)
454                                            slices = (slices / create.num_threads) * create.num_threads; /* multiple of threads */
455                                    else if (create.num_threads % slices)
456                                            slices = (!(create.num_threads%2)) ? (create.num_threads/2) : (create.num_threads/3);
457                            }
458    
459                          if (create.num_slices > create.num_threads)                          create.num_slices = slices;
                                 create.num_slices = create.num_threads;  
460                  }                  }
461                  else {                  else {
462                          create.num_slices = codec->config.num_slices; /* force manual value - by registry edit */                          create.num_slices = codec->config.num_slices; /* force manual value - by registry edit */
# Line 552  Line 565 
565                  create.num_plugins++;                  create.num_plugins++;
566          }          }
567    
568            if (codec->config.debug > 0) {
569          plugins[create.num_plugins].func = vfw_debug;          plugins[create.num_plugins].func = vfw_debug;
570          plugins[create.num_plugins].param = NULL;          plugins[create.num_plugins].param = NULL;
571          create.num_plugins++;          create.num_plugins++;
572            }
573    
574          create.profile = profiles[codec->config.profile].id;          create.profile = profiles[codec->config.profile].id;
575    
# Line 600  Line 615 
615      if ((profiles[codec->config.profile].flags & PROFILE_EXTRA))      if ((profiles[codec->config.profile].flags & PROFILE_EXTRA))
616        create.global |= XVID_GLOBAL_DIVX5_USERDATA;        create.global |= XVID_GLOBAL_DIVX5_USERDATA;
617    
618            if ((profiles[codec->config.profile].flags & PROFILE_EXTRA) ||
619                    (profiles[codec->config.profile].flags & PROFILE_XVID)) {
620              create.frame_drop_ratio = 0;
621            } else {
622          create.frame_drop_ratio = quality_preset->frame_drop_ratio;          create.frame_drop_ratio = quality_preset->frame_drop_ratio;
623            }
624    
625          switch(codec->xvid_encore_func(0, XVID_ENC_CREATE, &create, NULL))          switch(codec->xvid_encore_func(0, XVID_ENC_CREATE, &create, NULL))
626          {          {
# Line 911  Line 931 
931  {  {
932          BITMAPINFOHEADER * inhdr = &lpbiInput->bmiHeader;          BITMAPINFOHEADER * inhdr = &lpbiInput->bmiHeader;
933          BITMAPINFOHEADER * outhdr = &lpbiOutput->bmiHeader;          BITMAPINFOHEADER * outhdr = &lpbiOutput->bmiHeader;
934            int in_csp = XVID_CSP_NULL, out_csp = XVID_CSP_NULL;
935    
936          if (lpbiInput == NULL)          if (lpbiInput == NULL)
937          {          {
938                  return ICERR_ERROR;                  return ICERR_ERROR;
939          }          }
940    
941          if (inhdr->biCompression != FOURCC_XVID && inhdr->biCompression != FOURCC_DIVX && inhdr->biCompression != FOURCC_DX50 && get_colorspace(inhdr) == XVID_CSP_NULL)          if (inhdr->biCompression != FOURCC_XVID && inhdr->biCompression != FOURCC_DIVX && inhdr->biCompression != FOURCC_DX50 && inhdr->biCompression != FOURCC_MP4V &&
942                    inhdr->biCompression != FOURCC_xvid && inhdr->biCompression != FOURCC_divx && inhdr->biCompression != FOURCC_dx50 && inhdr->biCompression != FOURCC_mp4v &&
943                    (in_csp = get_colorspace(inhdr)) != XVID_CSP_YV12)
944          {          {
945                  return ICERR_BADFORMAT;                  return ICERR_BADFORMAT;
946          }          }
# Line 927  Line 950 
950                  return ICERR_OK;                  return ICERR_OK;
951          }          }
952    
953            out_csp = get_colorspace(outhdr);
954    
955          if (inhdr->biWidth != outhdr->biWidth ||          if (inhdr->biWidth != outhdr->biWidth ||
956                  inhdr->biHeight != outhdr->biHeight ||                  inhdr->biHeight != outhdr->biHeight ||
957                  get_colorspace(outhdr) == XVID_CSP_NULL)                  out_csp == XVID_CSP_NULL ||
958                    (in_csp == XVID_CSP_YV12 && in_csp != out_csp))
959          {          {
960                  return ICERR_BADFORMAT;                  return ICERR_BADFORMAT;
961          }          }
# Line 1072  Line 1098 
1098          /* --- yv12 --- */          /* --- yv12 --- */
1099          if (icd->lpbiInput->biCompression != FOURCC_XVID &&          if (icd->lpbiInput->biCompression != FOURCC_XVID &&
1100                   icd->lpbiInput->biCompression != FOURCC_DIVX &&                   icd->lpbiInput->biCompression != FOURCC_DIVX &&
1101                   icd->lpbiInput->biCompression != FOURCC_DX50)                   icd->lpbiInput->biCompression != FOURCC_DX50 &&
1102                     icd->lpbiInput->biCompression != FOURCC_MP4V &&
1103                     icd->lpbiInput->biCompression != FOURCC_xvid &&
1104                     icd->lpbiInput->biCompression != FOURCC_divx &&
1105                     icd->lpbiInput->biCompression != FOURCC_dx50 &&
1106                     icd->lpbiInput->biCompression != FOURCC_mp4v)
1107          {          {
1108                  xvid_gbl_convert_t convert;                  xvid_gbl_convert_t convert;
1109    

Legend:
Removed from v.1922  
changed lines
  Added in v.2140

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