[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.55, Fri Jul 12 12:26:23 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 204  Line 212 
212          if (pParam->max_key_interval == 0)          if (pParam->max_key_interval == 0)
213                  pParam->max_key_interval = 10 * pParam->fincr / pParam->fbase;                  pParam->max_key_interval = 10 * pParam->fincr / pParam->fbase;
214    
   
215          pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE);          pEnc = (Encoder *) xvid_malloc(sizeof(Encoder), CACHE_LINE);
216          if (pEnc == NULL)          if (pEnc == NULL)
217                  return XVID_ERR_MEMORY;                  return XVID_ERR_MEMORY;
# Line 229  Line 236 
236    
237          pEnc->mbParam.m_quant_type = H263_QUANT;          pEnc->mbParam.m_quant_type = H263_QUANT;
238    
239    #ifdef _SMP
240            pEnc->mbParam.num_threads = MIN(pParam->num_threads, MAXNUMTHREADS);
241    #endif
242    
243          pEnc->sStat.fMvPrevSigma = -1;          pEnc->sStat.fMvPrevSigma = -1;
244    
245          /* Fill rate control parameters */          /* Fill rate control parameters */
# Line 330  Line 341 
341          /* B Frames specific init */          /* B Frames specific init */
342  #ifdef BFRAMES  #ifdef BFRAMES
343    
344          pEnc->packed = pParam->packed;          pEnc->global = pParam->global;
345          pEnc->mbParam.max_bframes = pParam->max_bframes;          pEnc->mbParam.max_bframes = pParam->max_bframes;
346          pEnc->bquant_ratio = pParam->bquant_ratio;          pEnc->bquant_ratio = pParam->bquant_ratio;
347          pEnc->bframes = NULL;          pEnc->bframes = NULL;
# Line 375  Line 386 
386          pEnc->bframenum_head = 0;          pEnc->bframenum_head = 0;
387          pEnc->bframenum_tail = 0;          pEnc->bframenum_tail = 0;
388          pEnc->flush_bframes = 0;          pEnc->flush_bframes = 0;
389            pEnc->bframenum_dx50bvop = -1;
390    
391          pEnc->queue = NULL;          pEnc->queue = NULL;
392    
# Line 408  Line 420 
420    
421          pEnc->mbParam.m_seconds = 0;          pEnc->mbParam.m_seconds = 0;
422          pEnc->mbParam.m_ticks = 0;          pEnc->mbParam.m_ticks = 0;
423            pEnc->m_framenum = 0;
424  #endif  #endif
425    
426          pParam->handle = (void *) pEnc;          pParam->handle = (void *) pEnc;
# Line 608  Line 621 
621  {  {
622          pEnc->iFrameNum++;          pEnc->iFrameNum++;
623          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;  
         }  
624    
625            pEnc->mbParam.m_seconds = pEnc->mbParam.m_ticks / pEnc->mbParam.fbase;
626            pEnc->mbParam.m_ticks = pEnc->mbParam.m_ticks % pEnc->mbParam.fbase;
627  }  }
628  #endif  #endif
629    
# Line 622  Line 633 
633  {  {
634          if (pEnc->queue_size >= pEnc->mbParam.max_bframes)          if (pEnc->queue_size >= pEnc->mbParam.max_bframes)
635          {          {
636                  DPRINTF("FATAL: QUEUE FULL");                  DPRINTF(DPRINTF_DEBUG,"FATAL: QUEUE FULL");
637                  return;                  return;
638          }          }
639    
640          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",
641                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
642                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
643    
# Line 694  Line 705 
705                           * frame as a pframe                           * frame as a pframe
706                           */                           */
707    
708                          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",
709                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
710                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
711    
# Line 713  Line 724 
724                  }                  }
725    
726    
727                  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",
728                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
729                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
730    
# Line 733  Line 744 
744          if (pEnc->bframenum_head > 0) {          if (pEnc->bframenum_head > 0) {
745                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;                  pEnc->bframenum_head = pEnc->bframenum_tail = 0;
746    
747                  if (pEnc->packed) {                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {
748    
749                          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",
750                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
751                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
752    
   
753                          BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0);                          BitstreamWriteVopHeader(&bs, &pEnc->mbParam, pEnc->current, 0);
754                          BitstreamPad(&bs);                          BitstreamPad(&bs);
755                          BitstreamPutBits(&bs, 0x7f, 8);                          BitstreamPutBits(&bs, 0x7f, 8);
# Line 757  Line 767 
767    
768  bvop_loop:  bvop_loop:
769    
770          if (input_valid) {          if (pEnc->bframenum_dx50bvop != -1)
771            {
772    
773                    SWAP(pEnc->current, pEnc->reference);
774                    SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_dx50bvop]);
775    
776                    if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
777                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 IVOP");
778                    }
779    
780                    if (input_valid)
781                    {
782                            queue_image(pEnc, pFrame);
783                            input_valid = 0;
784                    }
785    
786            } else if (input_valid) {
787    
788                  SWAP(pEnc->current, pEnc->reference);                  SWAP(pEnc->current, pEnc->reference);
789    
# Line 790  Line 816 
816    
817          } else if (BitstreamPos(&bs) == 0) {          } else if (BitstreamPos(&bs) == 0) {
818    
819                  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",
820                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
821                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
822    
   
823                  pFrame->intra = 0;                  pFrame->intra = 0;
824    
825                  BitstreamPutBits(&bs, 0x7f, 8);                  BitstreamPutBits(&bs, 0x7f, 8);
# Line 816  Line 841 
841           * comment style :-)           * comment style :-)
842           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
843    
 //$$    SWAP(pEnc->current, pEnc->reference);  
   
844          emms();          emms();
845    
846            // only inc frame num, adapt quant, etc. if we havent seen it before
847            if (pEnc->bframenum_dx50bvop < 0 )
848            {
849          if (pFrame->quant == 0)          if (pFrame->quant == 0)
850                  pEnc->current->quant = RateControlGetQ(&pEnc->rate_control, 0);                  pEnc->current->quant = RateControlGetQ(&pEnc->rate_control, 0);
851          else          else
# Line 833  Line 859 
859    
860          pEnc->current->global_flags = pFrame->general;          pEnc->current->global_flags = pFrame->general;
861          pEnc->current->motion_flags = pFrame->motion;          pEnc->current->motion_flags = pFrame->motion;
862          pEnc->current->seconds = pEnc->mbParam.m_seconds;  
         pEnc->current->ticks = pEnc->mbParam.m_ticks;  
863          /* ToDo : dynamic fcode (in both directions) */          /* ToDo : dynamic fcode (in both directions) */
864          pEnc->current->fcode = pEnc->mbParam.m_fcode;          pEnc->current->fcode = pEnc->mbParam.m_fcode;
865          pEnc->current->bcode = pEnc->mbParam.m_fcode;          pEnc->current->bcode = pEnc->mbParam.m_fcode;
866    
867  //$$$   start_timer();                  pEnc->current->seconds = pEnc->mbParam.m_seconds;
868  //$$$   if (image_input                  pEnc->current->ticks = pEnc->mbParam.m_ticks;
869  //$$$           (&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height,  
870  //$$$            pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace))                  inc_frame_num(pEnc);
 //$$$           return XVID_ERR_FORMAT;  
 //$$$   stop_conv_timer();  
871    
872  #ifdef _DEBUG_PSNR  #ifdef _DEBUG_PSNR
873          image_copy(&pEnc->sOriginal, &pEnc->current->image,          image_copy(&pEnc->sOriginal, &pEnc->current->image,
# Line 853  Line 876 
876    
877          emms();          emms();
878    
879                    if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
880                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 5,
881                                    "%i  if:%i  st:%i:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->seconds, pEnc->current->ticks);
882                    }
883    
884          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
885           * Luminance masking           * Luminance masking
886           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
# Line 882  Line 910 
910                          }                          }
911    
912  #undef OFFSET  #undef OFFSET
   
913                  }                  }
914    
915                  xvid_free(temp_dquants);                  xvid_free(temp_dquants);
916          }          }
917    
918            }
919    
920          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
921           * ivop/pvop/bvop selection           * ivop/pvop/bvop selection
922           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
923    
924    
925          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 ||          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 || pEnc->bframenum_dx50bvop >= 0 ||
926                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&
927                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)
928                  || image_mad(&pEnc->reference->image, &pEnc->current->image,                  || image_mad(&pEnc->reference->image, &pEnc->current->image,
# Line 903  Line 932 
932                   * This will be coded as an Intra Frame                   * This will be coded as an Intra Frame
933                   */                   */
934    
935                  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",
936                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
937                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
938    
939                  FrameCodeI(pEnc, &bs, &bits);                  if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
940                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "IVOP");
941                    }
942    
943                    // when we reach an iframe in DX50BVOP mode, encode the last bframe as a pframe
944    
945                    if ((pEnc->global & XVID_GLOBAL_DX50BVOP) && pEnc->bframenum_tail > 0) {
946    
947                            pEnc->bframenum_tail--;
948                            pEnc->bframenum_dx50bvop = pEnc->bframenum_tail;
949    
950                            SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_dx50bvop]);
951                            if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
952                                    image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 BVOP->PVOP");
953                            }
954                            FrameCodeP(pEnc, &bs, &bits, 1, 0);
955    
956                            pFrame->intra = 0;
957    
958                    } else {
959    
960                            FrameCodeI(pEnc, &bs, &bits);
961                  pFrame->intra = 1;                  pFrame->intra = 1;
                 pEnc->flush_bframes = 1;  
962    
963                  inc_frame_num(pEnc);                          pEnc->bframenum_dx50bvop = -1;
964                    }
965    
966                  if (pEnc->packed) {                  pEnc->flush_bframes = 1;
967    
968                    if ((pEnc->global & XVID_GLOBAL_PACKED) && pEnc->bframenum_tail > 0) {
969                          BitstreamPad(&bs);                          BitstreamPad(&bs);
970                          input_valid = 0;                          input_valid = 0;
971                          goto ipvop_loop;                          goto ipvop_loop;
# Line 929  Line 980 
980                   * This will be coded as a Predicted Frame                   * This will be coded as a Predicted Frame
981                   */                   */
982    
983                  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",
984                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
985                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
986    
987                    if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
988                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "PVOP");
989                    }
990    
991                  FrameCodeP(pEnc, &bs, &bits, 1, 0);                  FrameCodeP(pEnc, &bs, &bits, 1, 0);
992                  pFrame->intra = 0;                  pFrame->intra = 0;
993                  pEnc->flush_bframes = 1;                  pEnc->flush_bframes = 1;
994    
995                  inc_frame_num(pEnc);                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {
   
                 if (pEnc->packed) {  
996                          BitstreamPad(&bs);                          BitstreamPad(&bs);
997                          input_valid = 0;                          input_valid = 0;
998                          goto ipvop_loop;                          goto ipvop_loop;
# Line 950  Line 1003 
1003                   * This will be coded as a Bidirectional Frame                   * This will be coded as a Bidirectional Frame
1004                   */                   */
1005    
1006                  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",
1007                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
1008                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);                                  pEnc->queue_head, pEnc->queue_tail, pEnc->queue_size);
1009    
1010                    if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
1011                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "BVOP");
1012                    }
1013    
1014                  if (pFrame->bquant < 1) {                  if (pFrame->bquant < 1) {
1015                          pEnc->current->quant =                          pEnc->current->quant =
1016                                  ((pEnc->reference->quant +                                  ((pEnc->reference->quant +
# Line 971  Line 1028 
1028                  pFrame->intra = 0;                  pFrame->intra = 0;
1029                  pFrame->length = 0;                  pFrame->length = 0;
1030    
                 inc_frame_num(pEnc);  
   
1031                  input_valid = 0;                  input_valid = 0;
1032                  goto bvop_loop;                  goto bvop_loop;
1033          }          }
# Line 1265  Line 1320 
1320                                  &pEnc->current->mbs[x + y * pEnc->mbParam.mb_width];                                  &pEnc->current->mbs[x + y * pEnc->mbParam.mb_width];
1321                          MVBLOCKHINT *bhint =                          MVBLOCKHINT *bhint =
1322                                  &hint->mvhint.block[x + y * pEnc->mbParam.mb_width];                                  &hint->mvhint.block[x + y * pEnc->mbParam.mb_width];
1323                          VECTOR pred[4];                          VECTOR pred;
1324                          VECTOR tmp;                          VECTOR tmp;
                         int32_t dummy[4];  
1325                          int vec;                          int vec;
1326    
1327                          pMB->mode =                          pMB->mode =
# Line 1287  Line 1341 
1341                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                  tmp.x -= (tmp.x >= high) ? high * 2 : 0;
1342                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                  tmp.y -= (tmp.y >= high) ? high * 2 : 0;
1343    
1344                                  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);  
1345    
1346                                  for (vec = 0; vec < 4; ++vec) {                                  for (vec = 0; vec < 4; ++vec) {
1347                                          pMB->mvs[vec].x = tmp.x;                                          pMB->mvs[vec].x = tmp.x;
1348                                          pMB->mvs[vec].y = tmp.y;                                          pMB->mvs[vec].y = tmp.y;
1349                                          pMB->pmvs[vec].x = pMB->mvs[0].x - pred[0].x;                                          pMB->pmvs[vec].x = pMB->mvs[0].x - pred.x;
1350                                          pMB->pmvs[vec].y = pMB->mvs[0].y - pred[0].y;                                          pMB->pmvs[vec].y = pMB->mvs[0].y - pred.y;
1351                                  }                                  }
1352                          } else if (pMB->mode == MODE_INTER4V) {                          } else if (pMB->mode == MODE_INTER4V) {
1353                                  for (vec = 0; vec < 4; ++vec) {                                  for (vec = 0; vec < 4; ++vec) {
# Line 1307  Line 1360 
1360                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;                                          tmp.x -= (tmp.x >= high) ? high * 2 : 0;
1361                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;                                          tmp.y -= (tmp.y >= high) ? high * 2 : 0;
1362    
1363                                          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);  
1364    
1365                                          pMB->mvs[vec].x = tmp.x;                                          pMB->mvs[vec].x = tmp.x;
1366                                          pMB->mvs[vec].y = tmp.y;                                          pMB->mvs[vec].y = tmp.y;
1367                                          pMB->pmvs[vec].x = pMB->mvs[vec].x - pred[0].x;                                          pMB->pmvs[vec].x = pMB->mvs[vec].x - pred.x;
1368                                          pMB->pmvs[vec].y = pMB->mvs[vec].y - pred[0].y;                                          pMB->pmvs[vec].y = pMB->mvs[vec].y - pred.y;
1369                                  }                                  }
1370                          } else                          // intra / stuffing / not_coded                          } else                          // intra / stuffing / not_coded
1371                          {                          {
# Line 1445  Line 1497 
1497          BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);          BitstreamWriteVolHeader(bs, &pEnc->mbParam, pEnc->current);
1498  #ifdef BFRAMES  #ifdef BFRAMES
1499  #define DIVX501B481P "DivX501b481p"  #define DIVX501B481P "DivX501b481p"
1500          if (pEnc->packed) {          if ((pEnc->global & XVID_GLOBAL_PACKED)) {
1501                  BitstreamWriteUserData(bs, DIVX501B481P, strlen(DIVX501B481P));                  BitstreamWriteUserData(bs, DIVX501B481P, strlen(DIVX501B481P));
1502          }          }
1503  #endif  #endif
# Line 1544  Line 1596 
1596          if (pEnc->current->global_flags & XVID_HINTEDME_SET) {          if (pEnc->current->global_flags & XVID_HINTEDME_SET) {
1597                  HintedMESet(pEnc, &bIntra);                  HintedMESet(pEnc, &bIntra);
1598          } else {          } else {
1599    
1600    #ifdef _SMP
1601            if (pEnc->mbParam.num_threads > 1)
1602                    bIntra =
1603                            SMP_MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,
1604                                                     &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
1605                                                     iLimit);
1606            else
1607    #endif
1608                  bIntra =                  bIntra =
1609                          MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,                          MotionEstimation(&pEnc->mbParam, pEnc->current, pEnc->reference,
1610                                                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,                                                           &pEnc->vInterH, &pEnc->vInterV, &pEnc->vInterHV,
1611                                                           iLimit);                                                           iLimit);
1612    
1613          }          }
1614          stop_motion_timer();          stop_motion_timer();
1615    
# Line 1681  Line 1743 
1743          IMAGE *f_ref = &pEnc->reference->image;          IMAGE *f_ref = &pEnc->reference->image;
1744          IMAGE *b_ref = &pEnc->current->image;          IMAGE *b_ref = &pEnc->current->image;
1745    
1746    #ifdef BFRAMES_DEC_DEBUG
1747            FILE *fp;
1748            static char first=0;
1749    #define BFRAME_DEBUG    if (!first && fp){ \
1750                    fprintf(fp,"Y=%3d   X=%3d   MB=%2d   CBP=%02X\n",y,x,mb->mode,mb->cbp); \
1751            }
1752    
1753            if (!first){
1754                    fp=fopen("C:\\XVIDDBGE.TXT","w");
1755            }
1756    #endif
1757    
1758          // forward          // forward
1759          image_setedges(f_ref, pEnc->mbParam.edged_width,          image_setedges(f_ref, pEnc->mbParam.edged_width,
1760                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,                                     pEnc->mbParam.edged_height, pEnc->mbParam.width,
# Line 1747  Line 1821 
1821                          if (mb->mode == MODE_NOT_CODED) {                          if (mb->mode == MODE_NOT_CODED) {
1822                                  mb->mvs[0].x = 0;                                  mb->mvs[0].x = 0;
1823                                  mb->mvs[0].y = 0;                                  mb->mvs[0].y = 0;
1824    
1825                                    mb->cbp = 0;
1826    #ifdef BFRAMES_DEC_DEBUG
1827            BFRAME_DEBUG
1828    #endif
1829                                  continue;                                  continue;
1830                          }                          }
1831    
# Line 1781  Line 1860 
1860                                  backward.x = mb->b_mvs[0].x;                                  backward.x = mb->b_mvs[0].x;
1861                                  backward.y = mb->b_mvs[0].y;                                  backward.y = mb->b_mvs[0].y;
1862                          }                          }
1863  //          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);
1864    
1865    #ifdef BFRAMES_DEC_DEBUG
1866            BFRAME_DEBUG
1867    #endif
1868                          start_timer();                          start_timer();
1869                          MBCodingBVOP(mb, qcoeff, frame->fcode, frame->bcode, bs,                          MBCodingBVOP(mb, qcoeff, frame->fcode, frame->bcode, bs,
1870                                                   &pEnc->sStat);                                                   &pEnc->sStat);
# Line 1795  Line 1877 
1877          // TODO: dynamic fcode/bcode ???          // TODO: dynamic fcode/bcode ???
1878    
1879          *pBits = BitstreamPos(bs) - *pBits;          *pBits = BitstreamPos(bs) - *pBits;
1880    
1881    #ifdef BFRAMES_DEC_DEBUG
1882            if (!first){
1883                    first=1;
1884                    if (fp)
1885                            fclose(fp);
1886            }
1887    #endif
1888  }  }
1889  #endif  #endif

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

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