[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.44, Thu Jun 20 14:05:57 2002 UTC revision 1.54, Thu Jul 11 00:15:59 2002 UTC
# Line 32  Line 32 
32   *   *
33   *  History   *  History
34   *   *
35     *  10.07.2002  added BFRAMES_DEC_DEBUG support
36     *              MinChen <chenm001@163.com>
37   *      20.06.2002 bframe patch   *      20.06.2002 bframe patch
38   *  08.05.2002 fix some problem in DEBUG mode;   *  08.05.2002 fix some problem in DEBUG mode;
39   *             MinChen <chenm001@163.com>   *             MinChen <chenm001@163.com>
# Line 51  Line 53 
53  #include "global.h"  #include "global.h"
54  #include "utils/timer.h"  #include "utils/timer.h"
55  #include "image/image.h"  #include "image/image.h"
56    #ifdef BFRAMES
57    #include "image/font.h"
58    #endif
59  #include "motion/motion.h"  #include "motion/motion.h"
60  #include "bitstream/cbp.h"  #include "bitstream/cbp.h"
61  #include "utils/mbfunctions.h"  #include "utils/mbfunctions.h"
# Line 63  Line 68 
68  #include "quant/quant_matrix.h"  #include "quant/quant_matrix.h"
69  #include "utils/mem_align.h"  #include "utils/mem_align.h"
70    
71    #ifdef _SMP
72    #include "motion/smp_motion_est.h"
73    #endif
74  /*****************************************************************************  /*****************************************************************************
75   * Local macros   * Local macros
76   ****************************************************************************/   ****************************************************************************/
# Line 330  Line 338 
338          /* B Frames specific init */          /* B Frames specific init */
339  #ifdef BFRAMES  #ifdef BFRAMES
340    
341          pEnc->packed = pParam->packed;          pEnc->global = pParam->global;
342          pEnc->mbParam.max_bframes = pParam->max_bframes;          pEnc->mbParam.max_bframes = pParam->max_bframes;
343          pEnc->bquant_ratio = pParam->bquant_ratio;          pEnc->bquant_ratio = pParam->bquant_ratio;
344          pEnc->bframes = NULL;          pEnc->bframes = NULL;
# Line 375  Line 383 
383          pEnc->bframenum_head = 0;          pEnc->bframenum_head = 0;
384          pEnc->bframenum_tail = 0;          pEnc->bframenum_tail = 0;
385          pEnc->flush_bframes = 0;          pEnc->flush_bframes = 0;
386            pEnc->bframenum_dx50bvop = -1;
387    
388          pEnc->queue = NULL;          pEnc->queue = NULL;
389    
# Line 408  Line 417 
417    
418          pEnc->mbParam.m_seconds = 0;          pEnc->mbParam.m_seconds = 0;
419          pEnc->mbParam.m_ticks = 0;          pEnc->mbParam.m_ticks = 0;
420            pEnc->m_framenum = 0;
421  #endif  #endif
422    
423          pParam->handle = (void *) pEnc;          pParam->handle = (void *) pEnc;
# Line 608  Line 618 
618  {  {
619          pEnc->iFrameNum++;          pEnc->iFrameNum++;
620          pEnc->mbParam.m_ticks += pEnc->mbParam.fincr;          pEnc->mbParam.m_ticks += pEnc->mbParam.fincr;
         if (pEnc->mbParam.m_ticks > pEnc->mbParam.fbase) {  
                 pEnc->mbParam.m_seconds++;  
                 pEnc->mbParam.m_ticks = 0;  
         }  
621    
622            pEnc->mbParam.m_seconds = pEnc->mbParam.m_ticks / pEnc->mbParam.fbase;
623            pEnc->mbParam.m_ticks = pEnc->mbParam.m_ticks % pEnc->mbParam.fbase;
624  }  }
625  #endif  #endif
626    
# Line 622  Line 630 
630  {  {
631          if (pEnc->queue_size >= pEnc->mbParam.max_bframes)          if (pEnc->queue_size >= pEnc->mbParam.max_bframes)
632          {          {
633                  DPRINTF("FATAL: QUEUE FULL");                  DPRINTF(DPRINTF_DEBUG,"FATAL: QUEUE FULL");
634                  return;                  return;
635          }          }
636    
637          DPRINTF("*** QUEUE bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",          DPRINTF(DPRINTF_DEBUG,"*** QUEUE bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
638                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
639                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
640    
# Line 694  Line 702 
702                           * frame as a pframe                           * frame as a pframe
703                           */                           */
704    
705                          DPRINTF("*** BFRAME (final frame) bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                          DPRINTF(DPRINTF_DEBUG,"*** BFRAME (final frame) bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
706                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
707                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
708    
# Line 713  Line 721 
721                  }                  }
722    
723    
724                  DPRINTF("*** BFRAME (flush) bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                  DPRINTF(DPRINTF_DEBUG,"*** BFRAME (flush) bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
725                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
726                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
727    
# Line 733  Line 741 
741          if (pEnc->bframenum_head > 0) {          if (pEnc->bframenum_head > 0) {
742                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;
743    
744                  if (pEnc->packed) {                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {
745    
746                          DPRINTF("*** EMPTY bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                          DPRINTF(DPRINTF_DEBUG,"*** EMPTY bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
747                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
748                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
749    
   
750                          BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0);                          BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0);
751                          BitstreamPad(&bs);                          BitstreamPad(&bs);
752                          BitstreamPutBits(&bs, 0x7f, 8);                          BitstreamPutBits(&bs, 0x7f, 8);
# Line 757  Line 764 
764    
765  bvop_loop:  bvop_loop:
766    
767          if (input_valid) {          if (pEnc->bframenum_dx50bvop != -1)
768            {
769    
770                    SWAP(pEnc->current, pEnc->reference);
771                    SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_dx50bvop]);
772    
773                    if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
774                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 IVOP");
775                    }
776    
777                    if (input_valid)
778                    {
779                            queue_image(pEnc, pFrame);
780                            input_valid = 0;
781                    }
782    
783            } else if (input_valid) {
784    
785                  SWAP(pEnc->current, pEnc->reference);                  SWAP(pEnc->current, pEnc->reference);
786    
# Line 790  Line 813 
813    
814          } else if (BitstreamPos(&bs) == 0) {          } else if (BitstreamPos(&bs) == 0) {
815    
816                  DPRINTF("*** SKIP bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                  DPRINTF(DPRINTF_DEBUG,"*** SKIP bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
817                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
818                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
819    
   
820                  pFrame->intra = 0;                  pFrame->intra = 0;
821    
822                  BitstreamPutBits(&bs, 0x7f, 8);                  BitstreamPutBits(&bs, 0x7f, 8);
# Line 816  Line 838 
838           * comment style :-)           * comment style :-)
839           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
840    
 //$$    SWAP(pEnc->current, pEnc->reference);  
   
841          emms();          emms();
842    
843            // only inc frame num, adapt quant, etc. if we havent seen it before
844            if (pEnc->bframenum_dx50bvop < 0 )
845            {
846          if (pFrame->quant == 0)          if (pFrame->quant == 0)
847                  pEnc->current->quant = RateControlGetQ(&pEnc->rate_control, 0);                  pEnc->current->quant = RateControlGetQ(&pEnc->rate_control, 0);
848          else          else
# Line 833  Line 856 
856    
857          pEnc->current->global_flags = pFrame->general;          pEnc->current->global_flags = pFrame->general;
858          pEnc->current->motion_flags = pFrame->motion;          pEnc->current->motion_flags = pFrame->motion;
859          pEnc->current->seconds = pEnc->mbParam.m_seconds;  
         pEnc->current->ticks = pEnc->mbParam.m_ticks;  
860          /* ToDo : dynamic fcode (in both directions) */          /* ToDo : dynamic fcode (in both directions) */
861          pEnc->current->fcode = pEnc->mbParam.m_fcode;          pEnc->current->fcode = pEnc->mbParam.m_fcode;
862          pEnc->current->bcode = pEnc->mbParam.m_fcode;          pEnc->current->bcode = pEnc->mbParam.m_fcode;
863    
864  //$$$   start_timer();                  pEnc->current->seconds = pEnc->mbParam.m_seconds;
865  //$$$   if (image_input                  pEnc->current->ticks = pEnc->mbParam.m_ticks;
866  //$$$           (&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height,  
867  //$$$            pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace))                  inc_frame_num(pEnc);
 //$$$           return XVID_ERR_FORMAT;  
 //$$$   stop_conv_timer();  
868    
869  #ifdef _DEBUG_PSNR  #ifdef _DEBUG_PSNR
870          image_copy(&pEnc->sOriginal, &pEnc->current->image,          image_copy(&pEnc->sOriginal, &pEnc->current->image,
# Line 853  Line 873 
873    
874          emms();          emms();
875    
876                    if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
877                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 5,
878                                    "%i  if:%i  st:%i:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->seconds, pEnc->current->ticks);
879                    }
880    
881          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
882           * Luminance masking           * Luminance masking
883           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
# Line 882  Line 907 
907                          }                          }
908    
909  #undef OFFSET  #undef OFFSET
   
910                  }                  }
911    
912                  xvid_free(temp_dquants);                  xvid_free(temp_dquants);
913          }          }
914    
915            }
916    
917          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
918           * ivop/pvop/bvop selection           * ivop/pvop/bvop selection
919           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
920    
921    
922          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 ||          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 || pEnc->bframenum_dx50bvop >= 0 ||
923                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&
924                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)
925                  || image_mad(&pEnc->reference->image, &pEnc->current->image,                  || image_mad(&pEnc->reference->image, &pEnc->current->image,
# Line 903  Line 929 
929                   * This will be coded as an Intra Frame                   * This will be coded as an Intra Frame
930                   */                   */
931    
932                  DPRINTF("*** IFRAME bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                  DPRINTF(DPRINTF_DEBUG,"*** IFRAME bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
933                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
934                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
935    
936                  FrameCodeI(pEnc, &bs, &bits);                  if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
937                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "IVOP");
938                    }
939    
940                    // when we reach an iframe in DX50BVOP mode, encode the last bframe as a pframe
941    
942                    if ((pEnc->global & XVID_GLOBAL_DX50BVOP) && pEnc->bframenum_tail > 0) {
943    
944                            pEnc->bframenum_tail--;
945                            pEnc->bframenum_dx50bvop = pEnc->bframenum_tail;
946    
947                            SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_dx50bvop]);
948                            if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
949                                    image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 BVOP->PVOP");
950                            }
951                            FrameCodeP(pEnc, &bs, &bits, 1, 0);
952    
953                            pFrame->intra = 0;
954    
955                    } else {
956    
957                            FrameCodeI(pEnc, &bs, &bits);
958                  pFrame->intra = 1;                  pFrame->intra = 1;
                 pEnc->flush_bframes = 1;  
959    
960                  inc_frame_num(pEnc);                          pEnc->bframenum_dx50bvop = -1;
961                    }
962    
963                  if (pEnc->packed) {                  pEnc->flush_bframes = 1;
964    
965                    if ((pEnc->global & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0) {
966                          BitstreamPad(&bs);                          BitstreamPad(&bs);
967                          input_valid = 0;                          input_valid = 0;
968                          goto ipvop_loop;                          goto ipvop_loop;
# Line 929  Line 977 
977                   * This will be coded as a Predicted Frame                   * This will be coded as a Predicted Frame
978                   */                   */
979    
980                  DPRINTF("*** PFRAME bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                  DPRINTF(DPRINTF_DEBUG,"*** PFRAME bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
981                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
982                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
983    
984                    if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
985                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "PVOP");
986                    }
987    
988                  FrameCodeP(pEnc, &bs, &bits, 1, 0);                  FrameCodeP(pEnc, &bs, &bits, 1, 0);
989                  pFrame->intra = 0;                  pFrame->intra = 0;
990                  pEnc->flush_bframes = 1;                  pEnc->flush_bframes = 1;
991    
992                  inc_frame_num(pEnc);                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {
   
                 if (pEnc->packed) {  
993                          BitstreamPad(&bs);                          BitstreamPad(&bs);
994                          input_valid = 0;                          input_valid = 0;
995                          goto ipvop_loop;                          goto ipvop_loop;
# Line 950  Line 1000 
1000                   * This will be coded as a Bidirectional Frame                   * This will be coded as a Bidirectional Frame
1001                   */                   */
1002    
1003                  DPRINTF("*** BFRAME (store) bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                  DPRINTF(DPRINTF_DEBUG,"*** BFRAME (store) bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
1004                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
1005                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
1006    
1007                    if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
1008                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "BVOP");
1009                    }
1010    
1011                  if (pFrame->bquant < 1) {                  if (pFrame->bquant < 1) {
1012                          pEnc->current->quant =                          pEnc->current->quant =
1013                                  ((pEnc->reference->quant +                                  ((pEnc->reference->quant +
# Line 971  Line 1025 
1025                  pFrame->intra = 0;                  pFrame->intra = 0;
1026                  pFrame->length = 0;                  pFrame->length = 0;
1027    
                 inc_frame_num(pEnc);  
   
1028                  input_valid = 0;                  input_valid = 0;
1029                  goto bvop_loop;                  goto bvop_loop;
1030          }          }
# Line 1265  Line 1317 
1317                                  &pEnc->current->mbs[x + y * pEnc->mbParam.mb_width];                                  &pEnc->current->mbs[x + y * pEnc->mbParam.mb_width];
1318                          MVBLOCKHINT *bhint =                          MVBLOCKHINT *bhint =
1319                                  &hint->mvhint.block[x + y * pEnc->mbParam.mb_width];                                  &hint->mvhint.block[x + y * pEnc->mbParam.mb_width];
1320                          VECTOR pred[4];                          VECTOR pred;
1321                          VECTOR tmp;                          VECTOR tmp;
                         int32_t dummy[4];  
1322                          int vec;                          int vec;
1323    
1324                          pMB->mode =                          pMB->mode =
# Line 1287  Line 1338 
1338                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;
1339                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;
1340    
1341                                  get_pmvdata(pEnc->current->mbs, x, y, pEnc->mbParam.mb_width,                                  pred = get_pmv2(pEnc->current->mbs,pEnc->mbParam.mb_width,0,x,y,0);
                                                         0, pred, dummy);  
1342    
1343                                  for (vec = 0; vec < 4; ++vec) {                                  for (vec = 0; vec < 4; ++vec) {
1344                                          pMB->mvs[vec].x = tmp.x;                                          pMB->mvs[vec].x = tmp.x;
1345                                          pMB->mvs[vec].y = tmp.y;                                          pMB->mvs[vec].y = tmp.y;
1346                                          pMB->pmvs[vec].x = pMB->mvs[0].x - pred[0].x;                                          pMB->pmvs[vec].x = pMB->mvs[0].x - pred.x;
1347                                          pMB->pmvs[vec].y = pMB->mvs[0].y - pred[0].y;                                          pMB->pmvs[vec].y = pMB->mvs[0].y - pred.y;
1348                                  }                                  }
1349                          } else if (pMB->mode == MODE_INTER4V) {                          } else if (pMB->mode == MODE_INTER4V) {
1350                                  for (vec = 0; vec < 4; ++vec) {                                  for (vec = 0; vec < 4; ++vec) {
# Line 1307  Line 1357 
1357                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;
1358                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;
1359    
1360                                          get_pmvdata(pEnc->current->mbs, x, y,                                          pred = get_pmv2(pEnc->current->mbs,pEnc->mbParam.mb_width,0,x,y,vec);
                                                                 pEnc->mbParam.mb_width, vec, pred, dummy);  
1361    
1362                                          pMB->mvs[vec].x = tmp.x;                                          pMB->mvs[vec].x = tmp.x;
1363                                          pMB->mvs[vec].y = tmp.y;                                          pMB->mvs[vec].y = tmp.y;
1364                                          pMB->pmvs[vec].x = pMB->mvs[vec].x - pred[0].x;                                          pMB->pmvs[vec].x = pMB->mvs[vec].x - pred.x;
1365                                          pMB->pmvs[vec].y = pMB->mvs[vec].y - pred[0].y;                                          pMB->pmvs[vec].y = pMB->mvs[vec].y - pred.y;
1366                                  }                                  }
1367                          } else                          // intra / stuffing / not_coded                          } else                          // intra / stuffing / not_coded
1368                          {                          {
# Line 1445  Line 1494 
1494          BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);          BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);
1495  #ifdef BFRAMES  #ifdef BFRAMES
1496  #define DIVX501B481P "DivX501b481p"  #define DIVX501B481P "DivX501b481p"
1497          if (pEnc->packed) {          if ((pEnc->global & XVID_GLOBAL_PACKED)) {
1498                  BitstreamWriteUserData(bs, DIVX501B481P, strlen(DIVX501B481P));                  BitstreamWriteUserData(bs, DIVX501B481P, strlen(DIVX501B481P));
1499          }          }
1500  #endif  #endif
# Line 1544  Line 1593 
1593          if (pEnc->current->global_flags & XVID_HINTEDME_SET) {          if (pEnc->current->global_flags & XVID_HINTEDME_SET) {
1594                  HintedMESet(pEnc, &bIntra);                  HintedMESet(pEnc, &bIntra);
1595          } else {          } else {
1596    
1597    #ifdef _SMP
1598                    if (NUMTHREADS > 1)
1599                            bIntra =
1600                                    SMP_MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,
1601                                                             &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
1602                                                             iLimit);
1603                    else
1604    #endif
1605    
1606                  bIntra =                  bIntra =
1607                          MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,                          MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,
1608                                                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,                                                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
1609                                                           iLimit);                                                           iLimit);
1610    
1611    
1612          }          }
1613          stop_motion_timer();          stop_motion_timer();
1614    
# Line 1681  Line 1742 
1742          IMAGE *f_ref = &pEnc->reference->image;          IMAGE *f_ref = &pEnc->reference->image;
1743          IMAGE *b_ref = &pEnc->current->image;          IMAGE *b_ref = &pEnc->current->image;
1744    
1745    #ifdef BFRAMES_DEC_DEBUG
1746            FILE *fp;
1747            static char first=0;
1748    #define BFRAME_DEBUG    if (!first && fp){ \
1749                    fprintf(fp,"Y=%3d   X=%3d   MB=%2d   CBP=%02X\n",y,x,mb->mode,mb->cbp); \
1750            }
1751    
1752            if (!first){
1753                    fp=fopen("C:\\XVIDDBGE.TXT","w");
1754            }
1755    #endif
1756    
1757          // forward          // forward
1758          image_setedges(f_ref, pEnc->mbParam.edged_width,          image_setedges(f_ref, pEnc->mbParam.edged_width,
1759                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,
# Line 1747  Line 1820 
1820                          if (mb->mode == MODE_NOT_CODED) {                          if (mb->mode == MODE_NOT_CODED) {
1821                                  mb->mvs[0].x = 0;                                  mb->mvs[0].x = 0;
1822                                  mb->mvs[0].y = 0;                                  mb->mvs[0].y = 0;
1823    
1824                                    mb->cbp = 0;
1825    #ifdef BFRAMES_DEC_DEBUG
1826            BFRAME_DEBUG
1827    #endif
1828                                  continue;                                  continue;
1829                          }                          }
1830    
# Line 1781  Line 1859 
1859                                  backward.x = mb->b_mvs[0].x;                                  backward.x = mb->b_mvs[0].x;
1860                                  backward.y = mb->b_mvs[0].y;                                  backward.y = mb->b_mvs[0].y;
1861                          }                          }
1862  //          printf("[%i %i] M=%i CBP=%i MVX=%i MVY=%i %i,%i  %i,%i\n", x, y, pMB->mode, pMB->cbp, pMB->mvs[0].x, bmb->pmvs[0].x, bmb->pmvs[0].y, forward.x, forward.y);  //                      DPRINTF("%05i : [%i %i] M=%i CBP=%i MVS=%i,%i forward=%i,%i", pEnc->m_framenum, x, y, mb->mode, mb->cbp, mb->mvs[0].x, mb->mvs[0].y, forward.x, forward.y);
1863    
1864    #ifdef BFRAMES_DEC_DEBUG
1865            BFRAME_DEBUG
1866    #endif
1867                          start_timer();                          start_timer();
1868                          MBCodingBVOP(mb, qcoeff, frame->fcode, frame->bcode, bs,                          MBCodingBVOP(mb, qcoeff, frame->fcode, frame->bcode, bs,
1869                                                   &pEnc->sStat);                                                   &pEnc->sStat);
# Line 1795  Line 1876 
1876          // TODO: dynamic fcode/bcode ???          // TODO: dynamic fcode/bcode ???
1877    
1878          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
1879    
1880    #ifdef BFRAMES_DEC_DEBUG
1881            if (!first){
1882                    first=1;
1883                    if (fp)
1884                            fclose(fp);
1885            }
1886    #endif
1887  }  }
1888  #endif  #endif

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.54

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