[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 920, Sat Mar 15 14:32:56 2003 UTC revision 931, Thu Mar 20 08:04:18 2003 UTC
# Line 26  Line 26 
26   *  along with this program; if not, write to the Free Software   *  along with this program; if not, write to the Free Software
27   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
28   *   *
29   *  $Id: encoder.c,v 1.95.2.5 2003-03-15 14:32:56 suxen_drol Exp $   *  $Id: encoder.c,v 1.95.2.10 2003-03-20 08:04:18 suxen_drol Exp $
30   *   *
31   ****************************************************************************/   ****************************************************************************/
32    
# Line 54  Line 54 
54  #include "utils/mem_align.h"  #include "utils/mem_align.h"
55    
56  /*****************************************************************************  /*****************************************************************************
  * Local macros  
  ****************************************************************************/  
   
 #define SWAP(_T_,A,B)    { _T_ tmp = A; A = B; B = tmp; }  
   
 /*****************************************************************************  
57   * Local function prototypes   * Local function prototypes
58   ****************************************************************************/   ****************************************************************************/
59    
# Line 75  Line 69 
69                                             FRAMEINFO * frame,                                             FRAMEINFO * frame,
70                                             Bitstream * bs);                                             Bitstream * bs);
71    
 /*****************************************************************************  
  * Local data  
  ****************************************************************************/  
   
 static int DQtab[4] = {  
         -1, -2, 1, 2  
 };  
   
 static int iDQtab[5] = {  
         1, 0, NO_CHANGE, 2, 3  
 };  
   
72    
73  /*****************************************************************************  /*****************************************************************************
74   * Encoder creation   * Encoder creation
# Line 166  Line 148 
148      /* framerate */      /* framerate */
149      pEnc->mbParam.fincr = MAX(create->fincr, 0);      pEnc->mbParam.fincr = MAX(create->fincr, 0);
150          pEnc->mbParam.fbase = create->fincr <= 0 ? 25 : create->fbase;          pEnc->mbParam.fbase = create->fincr <= 0 ? 25 : create->fbase;
151        if (pEnc->mbParam.fincr>0)
152          simplify_time(&pEnc->mbParam.fincr, &pEnc->mbParam.fbase);          simplify_time(&pEnc->mbParam.fincr, &pEnc->mbParam.fbase);
153    
154      /* plugin */      /* plugin */
# Line 198  Line 181 
181          }          }
182      }      }
183    
184        if ((pEnc->mbParam.global_flags & XVID_EXTRASTATS_ENABLE) ||
185            (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {
186            pEnc->mbParam.plugin_flags |= XVID_REQORIGINAL; /* psnr calculation requires the original */
187        }
188    
189      /* temp dquants */      /* temp dquants */
190        if ((pEnc->mbParam.plugin_flags & XVID_REQDQUANTS)) {
191          pEnc->temp_dquants = (int *) xvid_malloc(pEnc->mbParam.mb_width *          pEnc->temp_dquants = (int *) xvid_malloc(pEnc->mbParam.mb_width *
192                                          pEnc->mbParam.mb_height * sizeof(int), CACHE_LINE);                                          pEnc->mbParam.mb_height * sizeof(int), CACHE_LINE);
193        }
194      /* XXX: error checking */      /* XXX: error checking */
195    
196          /* bframes */          /* bframes */
# Line 498  Line 488 
488          xvid_free(pEnc->current);          xvid_free(pEnc->current);
489          xvid_free(pEnc->reference);          xvid_free(pEnc->reference);
490    
491        if ((pEnc->mbParam.plugin_flags & XVID_REQDQUANTS)) {
492          xvid_free(pEnc->temp_dquants);          xvid_free(pEnc->temp_dquants);
493        }
494    
495    xvid_err_memory0:    xvid_err_memory0:
496      for (n=0; n<pEnc->num_plugins;n++) {      for (n=0; n<pEnc->num_plugins;n++) {
# Line 601  Line 593 
593          xvid_free(pEnc->reference->mbs);          xvid_free(pEnc->reference->mbs);
594          xvid_free(pEnc->reference);          xvid_free(pEnc->reference);
595    
596        if ((pEnc->mbParam.plugin_flags & XVID_REQDQUANTS)) {
597      xvid_free(pEnc->temp_dquants);      xvid_free(pEnc->temp_dquants);
598        }
599    
600      for (i=0; i<pEnc->num_plugins;i++) {      for (i=0; i<pEnc->num_plugins;i++) {
601          if (pEnc->plugins[i].func) {          if (pEnc->plugins[i].func) {
# Line 620  Line 614 
614    call the plugins    call the plugins
615    */    */
616    
617  static void call_plugins(Encoder * pEnc, FRAMEINFO * frame, IMAGE * original, int opt, int * type, int * quant)  static void call_plugins(Encoder * pEnc, FRAMEINFO * frame, IMAGE * original,
618                             int opt, int * type, int * quant, xvid_enc_stats_t * stats)
619  {  {
620      int i;      unsigned int i, j;
621      xvid_plg_data_t data;      xvid_plg_data_t data;
622    
623        /* set data struct */
624    
625      memset(&data, 0, sizeof(xvid_plg_data_t));      memset(&data, 0, sizeof(xvid_plg_data_t));
626      data.version = XVID_VERSION;      data.version = XVID_VERSION;
627    
628      data.width = pEnc->mbParam.width;      data.width = pEnc->mbParam.width;
629      data.height = pEnc->mbParam.height;      data.height = pEnc->mbParam.height;
630      data.fincr = pEnc->mbParam.fincr;      data.mb_width = pEnc->mbParam.mb_width;
631        data.mb_height = pEnc->mbParam.mb_height;
632        data.fincr = frame->fincr;
633      data.fbase = pEnc->mbParam.fbase;      data.fbase = pEnc->mbParam.fbase;
634    
635      data.reference.csp = XVID_CSP_USER;      data.reference.csp = XVID_CSP_USER;
# Line 654  Line 653 
653      if (opt == XVID_PLG_BEFORE) {      if (opt == XVID_PLG_BEFORE) {
654          data.type = XVID_TYPE_AUTO;          data.type = XVID_TYPE_AUTO;
655          data.quant = 2;          data.quant = 2;
656          //memset(pEnc->temp_dquants, NO_CHANGE, pEnc->mbParam.width * pEnc->mbParam.height);  
657          //data.qscale_stride = pEnc->mbParam.width;          if ((pEnc->mbParam.plugin_flags & XVID_REQDQUANTS)) {
658          //data.qscale_table = pEnc->temp_dquants;              data.dquant = pEnc->temp_dquants;
659          /* todo: vol,vop,motion flags */              data.dquant_stride = pEnc->mbParam.mb_width;
660                memset(data.dquant, 0, data.mb_width*data.mb_height);
661            }
662    
663            /* todo: [vol,vop,motion]_flags*/
664    
665      } else { // XVID_PLG_AFTER      } else { // XVID_PLG_AFTER
666          if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) {          if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) {
# Line 670  Line 673 
673              data.original.stride[2] = pEnc->mbParam.edged_width/2;              data.original.stride[2] = pEnc->mbParam.edged_width/2;
674          }          }
675    
676            if ((frame->vol_flags & XVID_EXTRASTATS) ||
677                (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {
678    
679                            data.sse_y =
680                                plane_sse( original->y, frame->image.y,
681                                                   pEnc->mbParam.edged_width, pEnc->mbParam.width,
682                                                   pEnc->mbParam.height);
683    
684                data.sse_u =
685                    plane_sse( original->u, frame->image.u,
686                                               pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
687                                                   pEnc->mbParam.height/2);
688    
689                            data.sse_v =
690                    plane_sse( original->v, frame->image.v,
691                                               pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
692                                                   pEnc->mbParam.height/2);
693            }
694    
695          data.type = coding2type(frame->coding_type);          data.type = coding2type(frame->coding_type);
696          data.quant = frame->quant;          data.quant = frame->quant;
697          /* todo: data.qscale */  
698            if ((pEnc->mbParam.plugin_flags & XVID_REQDQUANTS)) {
699                data.dquant = pEnc->temp_dquants;
700                data.dquant_stride = pEnc->mbParam.mb_width;
701    
702                for (j=0; j<pEnc->mbParam.mb_height; j++)
703                for (i=0; i<pEnc->mbParam.mb_width; i++) {
704                    data.dquant[j*data.dquant_stride + i] = frame->mbs[j*pEnc->mbParam.mb_width + i].dquant;;
705                }
706            }
707    
708          data.vol_flags = frame->vol_flags;          data.vol_flags = frame->vol_flags;
709          data.vop_flags = frame->vop_flags;          data.vop_flags = frame->vop_flags;
710          data.motion_flags = frame->motion_flags;          data.motion_flags = frame->motion_flags;
# Line 681  Line 713 
713          data.kblks = frame->sStat.kblks;          data.kblks = frame->sStat.kblks;
714          data.mblks = frame->sStat.mblks;          data.mblks = frame->sStat.mblks;
715          data.ublks = frame->sStat.ublks;          data.ublks = frame->sStat.ublks;
716    
717            if (stats) {
718                    stats->type = coding2type(frame->coding_type);
719                    stats->quant = frame->quant;
720                    stats->vol_flags = frame->vol_flags;
721                    stats->vop_flags = frame->vop_flags;
722                    stats->length = frame->length;
723                    stats->hlength = frame->length - (frame->sStat.iTextBits / 8);
724                    stats->kblks = frame->sStat.kblks;
725                    stats->mblks = frame->sStat.mblks;
726                    stats->ublks = frame->sStat.ublks;
727                stats->sse_y = data.sse_y;
728                stats->sse_u = data.sse_u;
729                stats->sse_v = data.sse_v;
730            }
731      }      }
732    
733        /* call plugins */
734      for (i=0; i<pEnc->num_plugins;i++) {      for (i=0; i<pEnc->num_plugins;i++) {
735            emms();
736          if (pEnc->plugins[i].func) {          if (pEnc->plugins[i].func) {
737              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) {
738                  continue;                  continue;
739              }              }
740          }          }
741      }      }
742        emms();
743    
744        /* copy modified values back into frame*/
745      if (opt == XVID_PLG_BEFORE) {      if (opt == XVID_PLG_BEFORE) {
746          *type = data.type;          *type = data.type;
747          *quant = data.quant;          *quant = data.quant;
         /* todo: copy modified qscale,vol,vop,motion flags into the frame*/  
     }  
748    
749            if ((pEnc->mbParam.plugin_flags & XVID_REQDQUANTS)) {
750                for (j=0; j<pEnc->mbParam.mb_height; j++)
751                for (i=0; i<pEnc->mbParam.mb_width; i++) {
752                    frame->mbs[j*pEnc->mbParam.mb_width + i].dquant = data.dquant[j*data.mb_width + i];
753                }
754            }else{
755                for (j=0; j<pEnc->mbParam.mb_height; j++)
756                for (i=0; i<pEnc->mbParam.mb_width; i++) {
757                    frame->mbs[j*pEnc->mbParam.mb_width + i].dquant = 0;
758                }
759            }
760            /* todo: [vol,vop,motion]_flags*/
761        }
762  }  }
763    
764    
# Line 707  Line 769 
769      pEnc->current->frame_num = pEnc->m_framenum;      pEnc->current->frame_num = pEnc->m_framenum;
770          pEnc->current->stamp = pEnc->mbParam.m_stamp;   /* first frame is zero */          pEnc->current->stamp = pEnc->mbParam.m_stamp;   /* first frame is zero */
771    
772      pEnc->mbParam.m_stamp += pEnc->mbParam.fincr;      pEnc->mbParam.m_stamp += pEnc->current->fincr;
773      pEnc->m_framenum++; /* debug ticker */      pEnc->m_framenum++; /* debug ticker */
774  }  }
775    
# Line 739  Line 801 
801  }  }
802    
803    
 static void  
 set_stats(xvid_enc_stats_t * stats, const MBParam * pParam, const FRAMEINFO * frame)  
 {  
         if (stats)  
         {  
                 stats->type = coding2type(frame->coding_type);  
                 stats->quant = frame->quant;  
                 stats->vol_flags = frame->vol_flags;  
                 stats->vop_flags = frame->vop_flags;  
                 stats->length = frame->length;  
                 stats->hlength = frame->length - (frame->sStat.iTextBits / 8);  
                 stats->kblks = frame->sStat.kblks;  
                 stats->mblks = frame->sStat.mblks;  
                 stats->ublks = frame->sStat.ublks;  
         }  
 }  
   
   
804    
805  /*****************************************************************************  /*****************************************************************************
806   * IPB frame encoder entry point   * IPB frame encoder entry point
# Line 852  Line 896 
896                          }                          }
897    
898                          FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs);                          FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs);
899                call_plugins(pEnc, pEnc->bframes[pEnc->bframenum_head], &pEnc->sOriginal2, XVID_PLG_AFTER, 0, 0, stats);
             emms();  
             set_stats(stats, &pEnc->mbParam, pEnc->bframes[pEnc->bframenum_head]);  
             call_plugins(pEnc, pEnc->bframes[pEnc->bframenum_head], &pEnc->sOriginal2, XVID_PLG_AFTER, 0, 0);  
             emms();  
   
900                          pEnc->bframenum_head++;                          pEnc->bframenum_head++;
901    
902                          goto done;                          goto done;
# Line 889  Line 928 
928    
929                          /* add the not-coded length to the reference frame size */                          /* add the not-coded length to the reference frame size */
930                          pEnc->current->length += (BitstreamPos(&bs) - bits) / 8;                          pEnc->current->length += (BitstreamPos(&bs) - bits) / 8;
931              emms();              call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);
             set_stats(stats, &pEnc->mbParam, pEnc->current);  
             call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0);  
             emms();  
932    
933              /* flush complete: reset counters */              /* flush complete: reset counters */
934                  pEnc->flush_bframes = 0;                  pEnc->flush_bframes = 0;
# Line 916  Line 952 
952                  {                  {
953    
954              if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->mbParam.max_bframes > 0) {              if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->mbParam.max_bframes > 0) {
955                  emms();                  call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);
                             set_stats(stats, &pEnc->mbParam, pEnc->current);  
                 call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0);  
                 emms();  
956              }              }
957    
958              /* if the very last frame is to be b-vop, we must change it to a p-vop */              /* if the very last frame is to be b-vop, we must change it to a p-vop */
# Line 963  Line 996 
996           * init pEnc->current fields           * init pEnc->current fields
997           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
998    
999        pEnc->current->fincr = pEnc->mbParam.fincr>0 ? pEnc->mbParam.fincr : frame->fincr;
1000      pEnc->current->vol_flags = pEnc->mbParam.vol_flags;      pEnc->current->vol_flags = pEnc->mbParam.vol_flags;
1001      pEnc->current->vop_flags = frame->vop_flags;      pEnc->current->vop_flags = frame->vop_flags;
1002          pEnc->current->motion_flags = frame->motion;          pEnc->current->motion_flags = frame->motion;
# Line 974  Line 1008 
1008                      pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);                      pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
1009      }      }
1010    
         emms();         /* float-point region */  
   
         if ((pEnc->current->vop_flags & XVID_LUMIMASKING)) {  
         unsigned int x, y;  
   
                 pEnc->current->quant =  
                         adaptive_quantization(pEnc->current->image.y,  
                                                           pEnc->mbParam.edged_width, pEnc->temp_dquants,  
                                                           pEnc->current->quant, pEnc->current->quant,  
                                                           2 * pEnc->current->quant,  
                                                           pEnc->mbParam.mb_width,  
                                                           pEnc->mbParam.mb_height);  
   
                 for (y = 0; y < pEnc->mbParam.mb_height; y++) {  
   
 #define OFFSET(x,y) ((x) + (y)*pEnc->mbParam.mb_width)  
   
                         for (x = 0; x < pEnc->mbParam.mb_width; x++) {  
                                 MACROBLOCK *pMB = &pEnc->current->mbs[OFFSET(x, y)];  
   
                                 pMB->dquant = iDQtab[pEnc->temp_dquants[OFFSET(x, y)] + 2];  
                         }  
   
 #undef OFFSET  
                 }  
   
         }  
   
1011          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1012           * frame type & quant selection           * frame type & quant selection
1013           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
1014    
1015          emms();         /* END floating-point region */      call_plugins(pEnc, pEnc->current, NULL, XVID_PLG_BEFORE, &type, &pEnc->current->quant, stats);
     call_plugins(pEnc, pEnc->current, NULL, XVID_PLG_BEFORE, &type, &pEnc->current->quant);  
     emms();  
1016    
1017      if (frame->type > 0)      if (frame->type > 0)
1018                  type = frame->type;                  type = frame->type;
# Line 1059  Line 1063 
1063                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "BVOP");                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "BVOP");
1064                  }                  }
1065    
1066                  if (frame->bquant < 1) {                  if (frame->quant < 1) {
1067                          pEnc->current->quant = ((((pEnc->reference->quant + pEnc->current->quant) *                          pEnc->current->quant = ((((pEnc->reference->quant + pEnc->current->quant) *
1068                                  pEnc->mbParam.bquant_ratio) / 2) + pEnc->mbParam.bquant_offset)/100;                                  pEnc->mbParam.bquant_ratio) / 2) + pEnc->mbParam.bquant_offset)/100;
1069    
1070                  } else {                  } else {
1071                          pEnc->current->quant = frame->bquant;                          pEnc->current->quant = frame->quant;
1072                  }                  }
1073    
1074                  if (pEnc->current->quant < 1)                  if (pEnc->current->quant < 1)
# Line 1089  Line 1093 
1093      if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0)      if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0)
1094      {      {
1095          if (pEnc->current->stamp > 0) {          if (pEnc->current->stamp > 0) {
1096              emms();              call_plugins(pEnc, pEnc->reference, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);
                         set_stats(stats, &pEnc->mbParam, pEnc->reference);  
             call_plugins(pEnc, pEnc->reference, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0);  
             emms();  
1097          }          }
1098                  else                  else
1099                          stats->type = XVID_TYPE_NOTHING;                          stats->type = XVID_TYPE_NOTHING;
# Line 1107  Line 1108 
1108    
1109                  // place this frame back on the encoding-queue (head)                  // place this frame back on the encoding-queue (head)
1110                  // we will deal with it next time                  // we will deal with it next time
1111            dec_frame_num(pEnc);
1112            pEnc->iFrameNum--;
1113    
1114                  pEnc->queue_head = (pEnc->queue_head + (pEnc->mbParam.max_bframes+1) - 1) % (pEnc->mbParam.max_bframes+1);                  pEnc->queue_head = (pEnc->queue_head + (pEnc->mbParam.max_bframes+1) - 1) % (pEnc->mbParam.max_bframes+1);
1115          pEnc->queue_size++;          pEnc->queue_size++;
1116                  image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_head].image);                  image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_head].image);
1117    
         dec_frame_num(pEnc);  
         pEnc->iFrameNum--;  
   
1118                  // grab the last frame from the bframe-queue                  // grab the last frame from the bframe-queue
1119    
1120                  pEnc->bframenum_tail--;                  pEnc->bframenum_tail--;
# Line 1169  Line 1170 
1170                             pEnc->mbParam.edged_width, pEnc->mbParam.height);                             pEnc->mbParam.edged_width, pEnc->mbParam.height);
1171          }          }
1172    
   
1173                  FrameCodeI(pEnc, &bs);                  FrameCodeI(pEnc, &bs);
1174                  xFrame->out_flags |= XVID_KEYFRAME;                  xFrame->out_flags |= XVID_KEYFRAME;
1175    
# Line 1210  Line 1210 
1210          }          }
1211    
1212      /* packed or no-bframes: output stats */      /* packed or no-bframes: output stats */
1213      if ((pEnc->mbParam.global_flags & XVID_PACKED) || pEnc->mbParam.max_bframes == 0)      if ((pEnc->mbParam.global_flags & XVID_PACKED) || pEnc->mbParam.max_bframes == 0) {
1214          {          call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0, stats);
         emms();  
                 set_stats(stats, &pEnc->mbParam, pEnc->current);  
         call_plugins(pEnc, pEnc->current, &pEnc->sOriginal, XVID_PLG_AFTER, 0, 0);  
         emms();  
1215          }          }
1216    
1217          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Line 1232  Line 1228 
1228  }  }
1229    
1230    
1231    static void SetMacroblockQuants(MBParam * const pParam, FRAMEINFO * frame)
1232    {
1233        unsigned int i,j;
1234        int quant = frame->quant;
1235    
1236        for (j=0; j<pParam->mb_height; j++)
1237        for (i=0; i<pParam->mb_width; i++) {
1238            MACROBLOCK * pMB = &frame->mbs[j*pParam->mb_width + i];
1239            quant += pMB->dquant;
1240            if (quant > 31)
1241                            quant = 31;
1242                    if (quant < 1)
1243                            quant = 1;
1244            pMB->quant = quant;
1245        }
1246    }
1247    
1248    
1249  static __inline void  static __inline void
1250  CodeIntraMB(Encoder * pEnc,  CodeIntraMB(Encoder * pEnc,
1251                          MACROBLOCK * pMB)                          MACROBLOCK * pMB)
# Line 1245  Line 1259 
1259          pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = 0;          pMB->sad8[0] = pMB->sad8[1] = pMB->sad8[2] = pMB->sad8[3] = 0;
1260          pMB->sad16 = 0;          pMB->sad16 = 0;
1261    
1262          if ((pEnc->current->vop_flags & XVID_LUMIMASKING)) {          if (pMB->dquant != 0) {
                 if (pMB->dquant != NO_CHANGE) {  
1263                          pMB->mode = MODE_INTRA_Q;                          pMB->mode = MODE_INTRA_Q;
                         pEnc->current->quant += DQtab[pMB->dquant];  
   
                         if (pEnc->current->quant > 31)  
                                 pEnc->current->quant = 31;  
                         if (pEnc->current->quant < 1)  
                                 pEnc->current->quant = 1;  
                 }  
1264          }          }
   
         pMB->quant = pEnc->current->quant;  
1265  }  }
1266    
1267    
# Line 1293  Line 1297 
1297          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;
1298          pEnc->current->coding_type = I_VOP;          pEnc->current->coding_type = I_VOP;
1299    
1300        SetMacroblockQuants(&pEnc->mbParam, pEnc->current);
1301    
1302          BitstreamWriteVolHeader(bs, &pEnc->mbParam);          BitstreamWriteVolHeader(bs, &pEnc->mbParam);
1303    
1304          set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);          set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);
# Line 1417  Line 1423 
1423    
1424          pEnc->current->coding_type = P_VOP;          pEnc->current->coding_type = P_VOP;
1425    
1426    
1427        SetMacroblockQuants(&pEnc->mbParam, pEnc->current);
1428    
1429          start_timer();          start_timer();
1430          /*if (pEnc->current->global_flags & XVID_HINTEDME_SET)          /*if (pEnc->current->global_flags & XVID_HINTEDME_SET)
1431                  HintedMESet(pEnc, &bIntra);                  HintedMESet(pEnc, &bIntra);
# Line 1530  Line 1539 
1539    
1540                          stop_comp_timer();                          stop_comp_timer();
1541    
1542                          if ((pEnc->current->vop_flags & XVID_LUMIMASKING)) {                          if (pMB->dquant != 0) {
                                 if (pMB->dquant != NO_CHANGE) {  
1543                                          pMB->mode = MODE_INTER_Q;                                          pMB->mode = MODE_INTER_Q;
                                         pEnc->current->quant += DQtab[pMB->dquant];  
                                         if (pEnc->current->quant > 31)  
                                                 pEnc->current->quant = 31;  
                                         else if (pEnc->current->quant < 1)  
                                                 pEnc->current->quant = 1;  
                                 }  
1544                          }                          }
                         pMB->quant = pEnc->current->quant;  
1545    
1546                          pMB->field_pred = 0;                          pMB->field_pred = 0;
1547    
# Line 1563  Line 1564 
1564                          /* Finished processing the MB, now check if to CODE or SKIP */                          /* Finished processing the MB, now check if to CODE or SKIP */
1565    
1566                          skip_possible = (pMB->cbp == 0) && (pMB->mode == MODE_INTER) &&                          skip_possible = (pMB->cbp == 0) && (pMB->mode == MODE_INTER) &&
1567                                                          (pMB->dquant == NO_CHANGE);                                                          (pMB->dquant == 0);
1568    
1569                          if (pEnc->current->coding_type == S_VOP)                          if (pEnc->current->coding_type == S_VOP)
1570                                  skip_possible &= (pMB->mcsel == 1);                                  skip_possible &= (pMB->mcsel == 1);

Legend:
Removed from v.920  
changed lines
  Added in v.931

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