[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.59, Wed Dec 17 15:16:16 2003 UTC
# Line 740  Line 740 
740                  data.mblks = frame->sStat.mblks;                  data.mblks = frame->sStat.mblks;
741                  data.ublks = frame->sStat.ublks;                  data.ublks = frame->sStat.ublks;
742    
743                  if (stats) {                  /* New code */
744                          stats->type = coding2type(frame->coding_type);                  data.stats.type      = coding2type(frame->coding_type);
745                          stats->quant = frame->quant;                  data.stats.quant     = frame->quant;
746                          stats->vol_flags = frame->vol_flags;                  data.stats.vol_flags = frame->vol_flags;
747                          stats->vop_flags = frame->vop_flags;                  data.stats.vop_flags = frame->vop_flags;
748                          stats->length = frame->length;                  data.stats.length    = frame->length;
749                          stats->hlength = frame->length - (frame->sStat.iTextBits / 8);                  data.stats.hlength   = frame->length - (frame->sStat.iTextBits / 8);
750                          stats->kblks = frame->sStat.kblks;                  data.stats.kblks     = frame->sStat.kblks;
751                          stats->mblks = frame->sStat.mblks;                  data.stats.mblks     = frame->sStat.mblks;
752                          stats->ublks = frame->sStat.ublks;                  data.stats.ublks     = frame->sStat.ublks;
753                          stats->sse_y = data.sse_y;                  data.stats.sse_y     = data.sse_y;
754                          stats->sse_u = data.sse_u;                  data.stats.sse_u     = data.sse_u;
755                          stats->sse_v = data.sse_v;                  data.stats.sse_v     = data.sse_v;
756                  }  
757                    if (stats)
758                            *stats = data.stats;
759          }          }
760    
761          /* call plugins */          /* call plugins */
# Line 848  Line 850 
850          pCur->ticks = (int32_t)pCur->stamp % time_base;          pCur->ticks = (int32_t)pCur->stamp % time_base;
851                  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) ;
852    
853                  /* HEAVY DEBUG OUTPUT remove when timecodes prove to be stable */  #if 0   /* HEAVY DEBUG OUTPUT */
854            fprintf(stderr,"WriteVop:   %d - %d \n",
 /*              fprintf(stderr,"WriteVop:   %d - %d \n",  
855                          ((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base));                          ((int32_t)pCur->stamp / time_base), ((int32_t)pRef->stamp / time_base));
856                  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",
857                          pCur->coding_type, pCur->stamp, pRef->stamp, time_base);                          pCur->coding_type, pCur->stamp, pRef->stamp, time_base);
858                  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",
859                          pCur->coding_type, pCur->seconds, pCur->ticks, pRef->seconds, pRef->ticks);                          pCur->coding_type, pCur->seconds, pCur->ticks, pRef->seconds, pRef->ticks);
860    #endif
861    }
862    
863  */  static int
864    gcd(int a, int b)
865    {
866            int r ;
867    
868            if (b > a) {
869                    r = a;
870                    a = b;
871                    b = r;
872            }
873    
874            while ((r = a % b)) {
875                    a = b;
876                    b = r;
877            }
878            return b;
879  }  }
880    
881    static void
882    simplify_par(int *par_width, int *par_height)
883    {
884    
885            int _par_width  = (!*par_width)  ? 1 : (*par_width<0)  ? -*par_width:  *par_width;
886            int _par_height = (!*par_height) ? 1 : (*par_height<0) ? -*par_height: *par_height;
887            int divisor = gcd(_par_width, _par_height);
888    
889            _par_width  /= divisor;
890            _par_height /= divisor;
891    
892            /* 2^8 precision maximum */
893            if (_par_width>255 || _par_height>255) {
894                    float div;
895                    emms();
896                    if (_par_width>_par_height)
897                            div = (float)_par_width/255;
898                    else
899                            div = (float)_par_height/255;
900    
901                    _par_width  = (int)((float)_par_width/div);
902                    _par_height = (int)((float)_par_height/div);
903            }
904    
905            *par_width = _par_width;
906            *par_height = _par_height;
907    
908            return;
909    }
910    
911    
912  /*****************************************************************************  /*****************************************************************************
# Line 1221  Line 1268 
1268                  pEnc->iFrameNum = 1;                  pEnc->iFrameNum = 1;
1269    
1270                  /* ---- update vol flags at IVOP ----------- */                  /* ---- update vol flags at IVOP ----------- */
1271                  pEnc->current->vol_flags = pEnc->mbParam.vol_flags = frame->vol_flags;                  pEnc->mbParam.vol_flags = frame->vol_flags;
1272    
1273                    /* Aspect ratio */
1274                  switch(frame->par) {                  switch(frame->par) {
                 case 0:  
                         pEnc->mbParam.par = XVID_PAR_11_VGA;  
                         break;  
1275                  case XVID_PAR_11_VGA:                  case XVID_PAR_11_VGA:
1276                  case XVID_PAR_43_PAL:                  case XVID_PAR_43_PAL:
1277                  case XVID_PAR_43_NTSC:                  case XVID_PAR_43_NTSC:
# Line 1235  Line 1281 
1281                          pEnc->mbParam.par = frame->par;                          pEnc->mbParam.par = frame->par;
1282                          break;                          break;
1283                  default:                  default:
1284                          pEnc->mbParam.par = XVID_PAR_EXT;                          pEnc->mbParam.par = XVID_PAR_11_VGA;
1285                          break;                          break;
1286                  }                  }
1287                  pEnc->mbParam.par_width = (frame->par_width)?frame->par_width:1;  
1288                  pEnc->mbParam.par_height = (frame->par_height)?frame->par_height:1;                  /* For extended PAR only, we try to sanityse/simplify par values */
1289                    if (pEnc->mbParam.par == XVID_PAR_EXT) {
1290                            pEnc->mbParam.par_width  = frame->par_width;
1291                            pEnc->mbParam.par_height = frame->par_height;
1292                            simplify_par(&pEnc->mbParam.par_width, &pEnc->mbParam.par_height);
1293                    }
1294    
1295                  if ((pEnc->mbParam.vol_flags & XVID_VOL_MPEGQUANT)) {                  if ((pEnc->mbParam.vol_flags & XVID_VOL_MPEGQUANT)) {
1296                          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.59

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