[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.94, Wed Feb 19 10:08:20 2003 UTC revision 1.96, Tue Mar 4 10:55:21 2003 UTC
# Line 116  Line 116 
116  {  {
117          Encoder *pEnc;          Encoder *pEnc;
118          int i;          int i;
   
119          pParam->handle = NULL;          pParam->handle = NULL;
120    
121          ENC_CHECK(pParam);          ENC_CHECK(pParam);
# Line 366  Line 365 
365    
366          pEnc->queue = NULL;          pEnc->queue = NULL;
367    
   
368          if (pEnc->mbParam.max_bframes > 0) {          if (pEnc->mbParam.max_bframes > 0) {
369                  int n;                  int n;
370    
# Line 419  Line 417 
417    
418    xvid_err_memory5:    xvid_err_memory5:
419    
   
420          if (pEnc->mbParam.max_bframes > 0) {          if (pEnc->mbParam.max_bframes > 0) {
421    
422                  for (i = 0; i < pEnc->mbParam.max_bframes; i++) {                  for (i = 0; i < pEnc->mbParam.max_bframes; i++) {
# Line 527  Line 524 
524                  xvid_free(pEnc->queue);                  xvid_free(pEnc->queue);
525          }          }
526    
   
527          if (pEnc->mbParam.max_bframes > 0) {          if (pEnc->mbParam.max_bframes > 0) {
528    
529                  for (i = 0; i < pEnc->mbParam.max_bframes; i++) {                  for (i = 0; i < pEnc->mbParam.max_bframes; i++) {
# Line 677  Line 673 
673          uint16_t x, y;          uint16_t x, y;
674          Bitstream bs;          Bitstream bs;
675          uint32_t bits;          uint32_t bits;
676          int mode;          int mode = -1; /* Just to shut up compiler warning */
677    
678          int input_valid = 1;          int input_valid = 1;
679          int bframes_count = 0;          int bframes_count = 0;
# Line 768  Line 764 
764                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;
765    
766                  /* write an empty marker to the bitstream.                  /* write an empty marker to the bitstream.
   
767                     for divx5 decoder compatibility, this marker must consist                     for divx5 decoder compatibility, this marker must consist
768                     of a not-coded p-vop, with a time_base of zero, and time_increment                     of a not-coded p-vop, with a time_base of zero, and time_increment
769                     indentical to the future-referece frame.                     indentical to the future-referece frame.
# Line 781  Line 776 
776                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
777                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
778    
   
779                          tmp = pEnc->current->seconds;                          tmp = pEnc->current->seconds;
780                          pEnc->current->seconds = 0; /* force time_base = 0 */                          pEnc->current->seconds = 0; /* force time_base = 0 */
781    
# Line 881  Line 875 
875                          /* That disabled line of code was supposed to inform VirtualDub                          /* That disabled line of code was supposed to inform VirtualDub
876                           * that the frame was a dummy delay frame - now disabled (thx god :-)                           * that the frame was a dummy delay frame - now disabled (thx god :-)
877                           */                           */
878                          /* BitstreamPutBits(&bs, 0x7f, 8); */                          //BitstreamPutBits(&bs, 0x7f, 8);
879                          pFrame->intra = 5;                          pFrame->intra = 5;
880    
881                          if (pResult) {                          if (pResult) {
# Line 903  Line 897 
897                                  pResult->mblks = 0;                                  pResult->mblks = 0;
898                                  pResult->ublks = 0;                                  pResult->ublks = 0;
899                          }                          }
   
900                  } else {                  } else {
901    
902                          if (pResult) {                          if (pResult) {
# Line 990  Line 983 
983    
984                                          pMB->dquant = iDQtab[temp_dquants[OFFSET(x, y)] + 2];                                          pMB->dquant = iDQtab[temp_dquants[OFFSET(x, y)] + 2];
985                                  }                                  }
   
986  #undef OFFSET  #undef OFFSET
987                          }                          }
   
988                          xvid_free(temp_dquants);                          xvid_free(temp_dquants);
989                  }                  }
   
990          }          }
991    
992          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Line 1006  Line 996 
996    
997          if (pEnc->iFrameNum == 0 || pEnc->bframenum_dx50bvop >= 0 ||          if (pEnc->iFrameNum == 0 || pEnc->bframenum_dx50bvop >= 0 ||
998                  (mode < 0 && pEnc->mbParam.iMaxKeyInterval > 0 &&                  (mode < 0 && pEnc->mbParam.iMaxKeyInterval > 0 &&
999                          pEnc->iFrameNum >= pEnc->mbParam.iMaxKeyInterval))                          pEnc->iFrameNum >= pEnc->mbParam.iMaxKeyInterval)) {
         {  
1000                  mode = I_VOP;                  mode = I_VOP;
1001          }else{          }else{
1002                  mode = MEanalysis(&pEnc->reference->image, pEnc->current,                  mode = MEanalysis(&pEnc->reference->image, pEnc->current,
1003                                          &pEnc->mbParam, pEnc->mbParam.iMaxKeyInterval,                                          &pEnc->mbParam, pEnc->mbParam.iMaxKeyInterval,
1004                                          (mode < 0) ? pEnc->iFrameNum : 0,                                          (/*mode < 0*/1/*hack*/) ? pEnc->iFrameNum : 0,
1005                                          bframes_count++);                                          bframes_count++, pFrame->bframe_threshold);
1006          }          }
1007    
1008          if (mode == I_VOP) {          if (mode == I_VOP) {
# Line 1434  Line 1423 
1423                  return;                  return;
1424          }          }
1425    
1426          pEnc->current->fcode =          pEnc->current->fcode = (hint->rawhints) ?
1427                  (hint->rawhints) ? hint->mvhint.fcode : BitstreamGetBits(&bs,                  (uint32_t)hint->mvhint.fcode : BitstreamGetBits(&bs, FCODEBITS);
                                                                                                                                  FCODEBITS);  
1428    
1429          length = pEnc->current->fcode + 5;          length = pEnc->current->fcode + 5;
1430          high = 1 << (length - 1);          high = 1 << (length - 1);
# Line 1451  Line 1439 
1439                          VECTOR tmp;                          VECTOR tmp;
1440                          int vec;                          int vec;
1441    
1442                          pMB->mode =                          pMB->mode =     (hint->rawhints) ?
1443                                  (hint->rawhints) ? bhint->mode : BitstreamGetBits(&bs,                                  (uint32_t)bhint->mode : BitstreamGetBits(&bs, MODEBITS);
                                                                                                                                   MODEBITS);  
1444    
1445                          pMB->mode = (pMB->mode == MODE_INTER_Q) ? MODE_INTER : pMB->mode;                          pMB->mode = (pMB->mode == MODE_INTER_Q) ? MODE_INTER : pMB->mode;
1446                          pMB->mode = (pMB->mode == MODE_INTRA_Q) ? MODE_INTRA : pMB->mode;                          pMB->mode = (pMB->mode == MODE_INTRA_Q) ? MODE_INTRA : pMB->mode;
1447    
1448                          if (pMB->mode == MODE_INTER) {                          if (pMB->mode == MODE_INTER) {
1449                                  tmp.x =                                  tmp.x = (hint->rawhints) ?
1450                                          (hint->rawhints) ? bhint->mvs[0].x : BitstreamGetBits(&bs,                                          bhint->mvs[0].x : (int)BitstreamGetBits(&bs, length);
1451                                                                                                                                                    length);                                  tmp.y = (hint->rawhints) ?
1452                                  tmp.y =                                          bhint->mvs[0].y : (int)BitstreamGetBits(&bs, length);
                                         (hint->rawhints) ? bhint->mvs[0].y : BitstreamGetBits(&bs,  
                                                                                                                                                   length);  
1453                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;
1454                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;
1455    
# Line 1478  Line 1463 
1463                                  }                                  }
1464                          } else if (pMB->mode == MODE_INTER4V) {                          } else if (pMB->mode == MODE_INTER4V) {
1465                                  for (vec = 0; vec < 4; ++vec) {                                  for (vec = 0; vec < 4; ++vec) {
1466                                          tmp.x =                                          tmp.x = (hint->rawhints) ?
1467                                                  (hint->rawhints) ? bhint->mvs[vec].                                                  bhint->mvs[vec].x : (int)BitstreamGetBits(&bs, length);
1468                                                  x : BitstreamGetBits(&bs, length);                                          tmp.y = (hint->rawhints) ?
1469                                          tmp.y =                                                  bhint->mvs[vec].y : (int)BitstreamGetBits(&bs, length);
                                                 (hint->rawhints) ? bhint->mvs[vec].  
                                                 y : BitstreamGetBits(&bs, length);  
1470                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;
1471                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;
1472    
# Line 1631  Line 1614 
1614                          pEnc->mbParam.width, pEnc->mbParam.height);                          pEnc->mbParam.width, pEnc->mbParam.height);
1615                  stop_edges_timer();                  stop_edges_timer();
1616          }          }
   
1617          pEnc->iFrameNum = 0;          pEnc->iFrameNum = 0;
1618          pEnc->mbParam.m_rounding_type = 1;          pEnc->mbParam.m_rounding_type = 1;
1619          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;
# Line 1729  Line 1711 
1711                  mb_height = (pEnc->mbParam.height + 31) / 32;                  mb_height = (pEnc->mbParam.height + 31) / 32;
1712          }          }
1713    
   
1714          start_timer();          start_timer();
1715          image_setedges(pRef, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,          image_setedges(pRef, pEnc->mbParam.edged_width, pEnc->mbParam.edged_height,
1716                                     pEnc->mbParam.width, pEnc->mbParam.height);                                     pEnc->mbParam.width, pEnc->mbParam.height);
# Line 2151  Line 2132 
2132    
2133    
2134          stop_motion_timer();          stop_motion_timer();
   
2135          /*          /*
2136          if (test_quant_type(&pEnc->mbParam, pEnc->current)) {          if (test_quant_type(&pEnc->mbParam, pEnc->current)) {
2137                  BitstreamWriteVolHeader(bs, pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.quant_type);                  BitstreamWriteVolHeader(bs, pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.quant_type);

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.96

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