[svn] / branches / dev-api-4 / xvidcore / src / encoder.c Repository:
ViewVC logotype

Diff of /branches/dev-api-4/xvidcore/src/encoder.c

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

revision 1107, Sat Aug 2 15:08:48 2003 UTC revision 1165, Fri Oct 3 13:47:24 2003 UTC
# Line 21  Line 21 
21   *  along with this program ; if not, write to the Free Software   *  along with this program ; if not, write to the Free Software
22   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23   *   *
24   * $Id: encoder.c,v 1.95.2.36 2003-08-02 15:08:19 edgomez Exp $   * $Id: encoder.c,v 1.95.2.43 2003-10-03 13:47:24 syskin Exp $
25   *   *
26   ****************************************************************************/   ****************************************************************************/
27    
# Line 226  Line 226 
226          pEnc->mbParam.frame_drop_ratio = MAX(create->frame_drop_ratio, 0);          pEnc->mbParam.frame_drop_ratio = MAX(create->frame_drop_ratio, 0);
227    
228      /* max keyframe interval */      /* max keyframe interval */
229      pEnc->mbParam.iMaxKeyInterval = create->max_key_interval <= 0 ?      pEnc->mbParam.iMaxKeyInterval = create->max_key_interval <= 0 ? (10 * (int)pEnc->mbParam.fbase) / (int)pEnc->mbParam.fincr : create->max_key_interval;
                 (10 * pEnc->mbParam.fbase) / pEnc->mbParam.fincr : create->max_key_interval;  
230    
231      /* allocate working frame-image memory */      /* allocate working frame-image memory */
232    
# Line 390  Line 389 
389                  image_null(&pEnc->queue[n].image);                  image_null(&pEnc->queue[n].image);
390    
391    
392          for (n = 0; n < pEnc->mbParam.max_bframes+1; n++)          for (n = 0; n < pEnc->mbParam.max_bframes+1; n++) {
         {  
393                  if (image_create                  if (image_create
394                          (&pEnc->queue[n].image, pEnc->mbParam.edged_width,                          (&pEnc->queue[n].image, pEnc->mbParam.edged_width,
395                           pEnc->mbParam.edged_height) < 0)                           pEnc->mbParam.edged_height) < 0)
396                          goto xvid_err_memory5;                          goto xvid_err_memory5;
   
397          }          }
398    
   
399          /* timestamp stuff */          /* timestamp stuff */
400    
401          pEnc->mbParam.m_stamp = 0;          pEnc->mbParam.m_stamp = 0;
# Line 424  Line 420 
420    
421    xvid_err_memory5:    xvid_err_memory5:
422    
423          if (pEnc->mbParam.max_bframes > 0) {          for (n = 0; n < pEnc->mbParam.max_bframes+1; n++) {
424          int i;                          image_destroy(&pEnc->queue[n].image, pEnc->mbParam.edged_width,
   
                 for (i = 0; i < pEnc->mbParam.max_bframes+1; i++) {  
                         image_destroy(&pEnc->queue[i].image, pEnc->mbParam.edged_width,  
425                                                    pEnc->mbParam.edged_height);                                                    pEnc->mbParam.edged_height);
426                  }                  }
427    
428                  xvid_free(pEnc->queue);                  xvid_free(pEnc->queue);
         }  
429    
430    xvid_err_memory4:    xvid_err_memory4:
431    
# Line 446  Line 439 
439    
440                          image_destroy(&pEnc->bframes[i]->image, pEnc->mbParam.edged_width,                          image_destroy(&pEnc->bframes[i]->image, pEnc->mbParam.edged_width,
441                                                    pEnc->mbParam.edged_height);                                                    pEnc->mbParam.edged_height);
   
442                          xvid_free(pEnc->bframes[i]->mbs);                          xvid_free(pEnc->bframes[i]->mbs);
   
443                          xvid_free(pEnc->bframes[i]);                          xvid_free(pEnc->bframes[i]);
   
444                  }                  }
445    
446                  xvid_free(pEnc->bframes);                  xvid_free(pEnc->bframes);
# Line 539  Line 529 
529          int i;          int i;
530    
531          /* B Frames specific */          /* B Frames specific */
         if (pEnc->mbParam.max_bframes > 0) {  
   
532                  for (i = 0; i < pEnc->mbParam.max_bframes+1; i++) {                  for (i = 0; i < pEnc->mbParam.max_bframes+1; i++) {
   
533                          image_destroy(&pEnc->queue[i].image, pEnc->mbParam.edged_width,                          image_destroy(&pEnc->queue[i].image, pEnc->mbParam.edged_width,
534                                            pEnc->mbParam.edged_height);                                            pEnc->mbParam.edged_height);
535                  }                  }
                 xvid_free(pEnc->queue);  
         }  
536    
537            xvid_free(pEnc->queue);
538    
539          if (pEnc->mbParam.max_bframes > 0) {          if (pEnc->mbParam.max_bframes > 0) {
540    
# Line 559  Line 545 
545    
546                          image_destroy(&pEnc->bframes[i]->image, pEnc->mbParam.edged_width,                          image_destroy(&pEnc->bframes[i]->image, pEnc->mbParam.edged_width,
547                                            pEnc->mbParam.edged_height);                                            pEnc->mbParam.edged_height);
   
548                          xvid_free(pEnc->bframes[i]->mbs);                          xvid_free(pEnc->bframes[i]->mbs);
   
549                          xvid_free(pEnc->bframes[i]);                          xvid_free(pEnc->bframes[i]);
550                  }                  }
551    
# Line 771  Line 755 
755      }      }
756    
757      /* call plugins */      /* call plugins */
758      for (i=0; i<pEnc->num_plugins;i++) {      for (i=0; i<(unsigned int)pEnc->num_plugins;i++) {
759          emms();          emms();
760          if (pEnc->plugins[i].func) {          if (pEnc->plugins[i].func) {
761              if (pEnc->plugins[i].func(pEnc->plugins[i].param, opt, &data, 0) < 0) {              if (pEnc->plugins[i].func(pEnc->plugins[i].param, opt, &data, 0) < 0) {
# Line 1200  Line 1184 
1184    
1185                  /* ---- update vol flags at IVOP ----------- */                  /* ---- update vol flags at IVOP ----------- */
1186                  pEnc->current->vol_flags = pEnc->mbParam.vol_flags = frame->vol_flags;                  pEnc->current->vol_flags = pEnc->mbParam.vol_flags = frame->vol_flags;
1187                    switch(frame->par) {
1188                    case XVID_PAR_11_VGA:
1189                    case XVID_PAR_43_PAL:
1190                    case XVID_PAR_43_NTSC:
1191                    case XVID_PAR_169_PAL:
1192                    case XVID_PAR_169_NTSC:
1193                    case XVID_PAR_EXT:
1194                            pEnc->mbParam.par = frame->par;
1195                            break;
1196                    default:
1197                            pEnc->mbParam.par = XVID_PAR_EXT;
1198                            break;
1199                    }
1200                    pEnc->mbParam.par_width = (frame->par_width)?frame->par_width:1;
1201                    pEnc->mbParam.par_height = (frame->par_height)?frame->par_height:1;
1202    
1203          if ((pEnc->mbParam.vol_flags & XVID_VOL_MPEGQUANT)) {          if ((pEnc->mbParam.vol_flags & XVID_VOL_MPEGQUANT)) {
1204                          if (frame->quant_intra_matrix != NULL)                          if (frame->quant_intra_matrix != NULL)
# Line 1253  Line 1252 
1252           * on next enc_encode call we must flush bframes           * on next enc_encode call we must flush bframes
1253           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
1254    
1255  done_flush:  /*done_flush:*/
1256    
1257      pEnc->flush_bframes = 1;      pEnc->flush_bframes = 1;
1258    
# Line 1285  Line 1284 
1284  {  {
1285      unsigned int i,j;      unsigned int i,j;
1286      int quant = frame->quant;      int quant = frame->quant;
1287        if (quant > 31)
1288                    frame->quant = quant = 31;
1289            else if (quant < 1)
1290                    frame->quant = quant = 1;
1291    
1292      for (j=0; j<pParam->mb_height; j++)      for (j=0; j<pParam->mb_height; j++)
1293      for (i=0; i<pParam->mb_width; i++) {      for (i=0; i<pParam->mb_width; i++) {
# Line 1292  Line 1295 
1295          quant += pMB->dquant;          quant += pMB->dquant;
1296          if (quant > 31)          if (quant > 31)
1297                          quant = 31;                          quant = 31;
1298                  if (quant < 1)                  else if (quant < 1)
1299                          quant = 1;                          quant = 1;
1300          pMB->quant = quant;          pMB->quant = quant;
1301      }      }
# Line 1565  Line 1568 
1568    
1569                                  current->sStat.kblks++;                                  current->sStat.kblks++;
1570    
1571                                    if (pEnc->current->vop_flags & XVID_VOP_GREYSCALE)
1572                                    {       pMB->cbp &= 0x3C;               /* keep only bits 5-2 */
1573                                            qcoeff[4*64+0]=0;               /* zero, because for INTRA MBs DC value is saved */
1574                                            qcoeff[5*64+0]=0;
1575                                    }
1576                                  MBCoding(current, pMB, qcoeff, bs, &current->sStat);                                  MBCoding(current, pMB, qcoeff, bs, &current->sStat);
1577                                  stop_coding_timer();                                  stop_coding_timer();
1578                                  continue;                                  continue;
# Line 1891  Line 1899 
1899                                  }                                  }
1900                          }                          }
1901    
1902  #ifdef BFRAMES_DEC_DEBUG                          /* keep only bits 5-2 -- Chroma blocks will just be skipped by the
1903          BFRAME_DEBUG                           * coding function for BFrames, that's why we don't zero teh DC
1904  #endif                           * coeffs */
1905                            if ((frame->vop_flags & XVID_VOP_GREYSCALE))
1906                                    mb->cbp &= 0x3C;
1907    
1908                          start_timer();                          start_timer();
1909                          MBCodingBVOP(mb, qcoeff, frame->fcode, frame->bcode, bs,                          MBCodingBVOP(frame, mb, qcoeff, frame->fcode, frame->bcode, bs,
1910                                                   &frame->sStat, direction);                                                   &frame->sStat);
1911                          stop_coding_timer();                          stop_coding_timer();
1912                  }                  }
1913          }          }

Legend:
Removed from v.1107  
changed lines
  Added in v.1165

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