[cvs] / xvidcore / src / encoder.c Repository:
ViewVC logotype

Diff of /xvidcore/src/encoder.c

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

revision 1.95.2.57, Fri Dec 12 09:58:40 2003 UTC revision 1.95.2.58, Fri Dec 12 14:16:40 2003 UTC
# Line 848  Line 848 
848          pCur->ticks = (int32_t)pCur->stamp % time_base;          pCur->ticks = (int32_t)pCur->stamp % time_base;
849                  pCur->seconds =  ((int32_t)pCur->stamp / time_base)     - ((int32_t)pRef->stamp / time_base) ;                  pCur->seconds =  ((int32_t)pCur->stamp / time_base)     - ((int32_t)pRef->stamp / time_base) ;
850    
851                  /* HEAVY DEBUG OUTPUT remove when timecodes prove to be stable */  #if 0   /* HEAVY DEBUG OUTPUT */
852            fprintf(stderr,"WriteVop:   %d - %d \n",
 /*              fprintf(stderr,"WriteVop:   %d - %d \n",  
853                          ((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base));                          ((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base));
854                  fprintf(stderr,"set_timecodes: VOP %1d   stamp=%lld ref_stamp=%lld  base=%d\n",                  fprintf(stderr,"set_timecodes: VOP %1d   stamp=%lld ref_stamp=%lld  base=%d\n",
855                          pCur->coding_type, pCur->stamp, pRef->stamp, time_base);                          pCur->coding_type, pCur->stamp, pRef->stamp, time_base);
856                  fprintf(stderr,"set_timecodes: VOP %1d   seconds=%d   ticks=%d   (ref-sec=%d  ref-tick=%d)\n",                  fprintf(stderr,"set_timecodes: VOP %1d   seconds=%d   ticks=%d   (ref-sec=%d  ref-tick=%d)\n",
857                          pCur->coding_type, pCur->seconds, pCur->ticks, pRef->seconds, pRef->ticks);                          pCur->coding_type, pCur->seconds, pCur->ticks, pRef->seconds, pRef->ticks);
858    #endif
859    }
860    
861  */  static int
862    gcd(int a, int b)
863    {
864            int r ;
865    
866            if (b > a) {
867                    r = a;
868                    a = b;
869                    b = r;
870            }
871    
872            while ((r = a % b)) {
873                    a = b;
874                    b = r;
875            }
876            return b;
877    }
878    
879    static void
880    simplify_par(int *par_width, int *par_height)
881    {
882    
883            int _par_width  = (!*par_width)  ? 1 : (*par_width<0)  ? -*par_width:  *par_width;
884            int _par_height = (!*par_height) ? 1 : (*par_height<0) ? -*par_height: *par_height;
885            int divisor = gcd(_par_width, _par_height);
886    
887            _par_width  /= divisor;
888            _par_height /= divisor;
889    
890            /* 2^8 precision maximum */
891            if (_par_width>255 || _par_height>255) {
892                    float div;
893                    emms();
894                    if (_par_width>_par_height)
895                            div = (float)_par_width/255;
896                    else
897                            div = (float)_par_height/255;
898    
899                    _par_width  = (int)((float)_par_width/div);
900                    _par_height = (int)((float)_par_height/div);
901  }  }
902    
903            *par_width = _par_width;
904            *par_height = _par_height;
905    
906            return;
907    }
908    
909    
910  /*****************************************************************************  /*****************************************************************************
# Line 1222  Line 1267 
1267    
1268                  /* ---- update vol flags at IVOP ----------- */                  /* ---- update vol flags at IVOP ----------- */
1269                  pEnc->current->vol_flags = pEnc->mbParam.vol_flags = frame->vol_flags;                  pEnc->current->vol_flags = pEnc->mbParam.vol_flags = frame->vol_flags;
1270    
1271                    /* Aspect ratio */
1272                  switch(frame->par) {                  switch(frame->par) {
                 case 0:  
                         pEnc->mbParam.par = XVID_PAR_11_VGA;  
                         break;  
1273                  case XVID_PAR_11_VGA:                  case XVID_PAR_11_VGA:
1274                  case XVID_PAR_43_PAL:                  case XVID_PAR_43_PAL:
1275                  case XVID_PAR_43_NTSC:                  case XVID_PAR_43_NTSC:
# Line 1235  Line 1279 
1279                          pEnc->mbParam.par = frame->par;                          pEnc->mbParam.par = frame->par;
1280                          break;                          break;
1281                  default:                  default:
1282                          pEnc->mbParam.par = XVID_PAR_EXT;                          pEnc->mbParam.par = XVID_PAR_11_VGA;
1283                          break;                          break;
1284                  }                  }
1285                  pEnc->mbParam.par_width = (frame->par_width)?frame->par_width:1;  
1286                  pEnc->mbParam.par_height = (frame->par_height)?frame->par_height:1;                  /* For extended PAR only, we try to sanityse/simplify par values */
1287                    if (pEnc->mbParam.par == XVID_PAR_EXT) {
1288                            pEnc->mbParam.par_width  = frame->par_width;
1289                            pEnc->mbParam.par_height = frame->par_height;
1290                            simplify_par(&pEnc->mbParam.par_width, &pEnc->mbParam.par_height);
1291                    }
1292    
1293                  if ((pEnc->mbParam.vol_flags & XVID_VOL_MPEGQUANT)) {                  if ((pEnc->mbParam.vol_flags & XVID_VOL_MPEGQUANT)) {
1294                          if (frame->quant_intra_matrix != NULL)                          if (frame->quant_intra_matrix != NULL)

Legend:
Removed from v.1.95.2.57  
changed lines
  Added in v.1.95.2.58

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