[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 926, Sun Mar 16 12:05:09 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.9 2003-03-16 12:04:13 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        if (pEnc->num_plugins == 0) {
624            for (j=0; j<pEnc->mbParam.mb_height; j++)
625            for (i=0; i<pEnc->mbParam.mb_width; i++) {
626                frame->mbs[j*pEnc->mbParam.mb_width + i].dquant = 0;
627            }
628            return;
629        }
630    
631        /* set data struct */
632    
633      memset(&data, 0, sizeof(xvid_plg_data_t));      memset(&data, 0, sizeof(xvid_plg_data_t));
634      data.version = XVID_VERSION;      data.version = XVID_VERSION;
635    
636      data.width = pEnc->mbParam.width;      data.width = pEnc->mbParam.width;
637      data.height = pEnc->mbParam.height;      data.height = pEnc->mbParam.height;
638      data.fincr = pEnc->mbParam.fincr;      data.mb_width = pEnc->mbParam.mb_width;
639        data.mb_height = pEnc->mbParam.mb_height;
640        data.fincr = frame->fincr;
641      data.fbase = pEnc->mbParam.fbase;      data.fbase = pEnc->mbParam.fbase;
642    
643      data.reference.csp = XVID_CSP_USER;      data.reference.csp = XVID_CSP_USER;
# Line 654  Line 661 
661      if (opt == XVID_PLG_BEFORE) {      if (opt == XVID_PLG_BEFORE) {
662          data.type = XVID_TYPE_AUTO;          data.type = XVID_TYPE_AUTO;
663          data.quant = 2;          data.quant = 2;
664          //memset(pEnc->temp_dquants, NO_CHANGE, pEnc->mbParam.width * pEnc->mbParam.height);  
665          //data.qscale_stride = pEnc->mbParam.width;          if ((pEnc->mbParam.plugin_flags & XVID_REQDQUANTS)) {
666          //data.qscale_table = pEnc->temp_dquants;              data.dquant = pEnc->temp_dquants;
667          /* todo: vol,vop,motion flags */              data.dquant_stride = pEnc->mbParam.mb_width;
668                memset(data.dquant, 0, data.mb_width*data.mb_height);
669            }
670    
671            /* todo: [vol,vop,motion]_flags*/
672    
673      } else { // XVID_PLG_AFTER      } else { // XVID_PLG_AFTER
674          if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) {          if ((pEnc->mbParam.plugin_flags & XVID_REQORIGINAL)) {
# Line 670  Line 681 
681              data.original.stride[2] = pEnc->mbParam.edged_width/2;              data.original.stride[2] = pEnc->mbParam.edged_width/2;
682          }          }
683    
684            if ((frame->vol_flags & XVID_EXTRASTATS) ||
685                (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {
686    
687                            data.sse_y =
688                                plane_sse( original->y, frame->image.y,
689                                                   pEnc->mbParam.edged_width, pEnc->mbParam.width,
690                                                   pEnc->mbParam.height);
691    
692                data.sse_u =
693                    plane_sse( original->u, frame->image.u,
694                                               pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
695                                                   pEnc->mbParam.height/2);
696    
697                            data.sse_v =
698                    plane_sse( original->v, frame->image.v,
699                                               pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
700                                                   pEnc->mbParam.height/2);
701            }
702    
703          data.type = coding2type(frame->coding_type);          data.type = coding2type(frame->coding_type);
704          data.quant = frame->quant;          data.quant = frame->quant;
705          /* todo: data.qscale */  
706            if ((pEnc->mbParam.plugin_flags & XVID_REQDQUANTS)) {
707                data.dquant = pEnc->temp_dquants;
708                data.dquant_stride = pEnc->mbParam.mb_width;
709    
710                for (j=0; j<pEnc->mbParam.mb_height; j++)
711                for (i=0; i<pEnc->mbParam.mb_width; i++) {
712                    data.dquant[j*data.dquant_stride + i] = frame->mbs[j*pEnc->mbParam.mb_width + i].dquant;;
713                }
714            }
715    
716          data.vol_flags = frame->vol_flags;          data.vol_flags = frame->vol_flags;
717          data.vop_flags = frame->vop_flags;          data.vop_flags = frame->vop_flags;
718          data.motion_flags = frame->motion_flags;          data.motion_flags = frame->motion_flags;
# Line 681  Line 721 
721          data.kblks = frame->sStat.kblks;          data.kblks = frame->sStat.kblks;
722          data.mblks = frame->sStat.mblks;          data.mblks = frame->sStat.mblks;
723          data.ublks = frame->sStat.ublks;          data.ublks = frame->sStat.ublks;
724    
725            if (stats) {
726                    stats->type = coding2type(frame->coding_type);
727                    stats->quant = frame->quant;
728                    stats->vol_flags = frame->vol_flags;
729                    stats->vop_flags = frame->vop_flags;
730                    stats->length = frame->length;
731                    stats->hlength = frame->length - (frame->sStat.iTextBits / 8);
732                    stats->kblks = frame->sStat.kblks;
733                    stats->mblks = frame->sStat.mblks;
734                    stats->ublks = frame->sStat.ublks;
735                stats->sse_y = data.sse_y;
736                stats->sse_u = data.sse_u;
737                stats->sse_v = data.sse_v;
738            }
739      }      }
740    
741        /* call plugins */
742      for (i=0; i<pEnc->num_plugins;i++) {      for (i=0; i<pEnc->num_plugins;i++) {
743            emms();
744          if (pEnc->plugins[i].func) {          if (pEnc->plugins[i].func) {
745              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) {
746                  continue;                  continue;
747              }              }
748          }          }
749      }      }
750        emms();
751    
752        /* copy modified values back into frame*/
753      if (opt == XVID_PLG_BEFORE) {      if (opt == XVID_PLG_BEFORE) {
754          *type = data.type;          *type = data.type;
755          *quant = data.quant;          *quant = data.quant;
         /* todo: copy modified qscale,vol,vop,motion flags into the frame*/  
     }  
756    
757            if ((pEnc->mbParam.plugin_flags & XVID_REQDQUANTS)) {
758                for (j=0; j<pEnc->mbParam.mb_height; j++)
759                for (i=0; i<pEnc->mbParam.mb_width; i++) {
760                    frame->mbs[j*pEnc->mbParam.mb_width + i].dquant = data.dquant[j*data.mb_width + i];
761                }
762            }else{
763                for (j=0; j<pEnc->mbParam.mb_height; j++)
764                for (i=0; i<pEnc->mbParam.mb_width; i++) {
765                    frame->mbs[j*pEnc->mbParam.mb_width + i].dquant = 0;
766                }
767            }
768            /* todo: [vol,vop,motion]_flags*/
769        }
770  }  }
771    
772    
# Line 707  Line 777 
777      pEnc->current->frame_num = pEnc->m_framenum;      pEnc->current->frame_num = pEnc->m_framenum;
778          pEnc->current->stamp = pEnc->mbParam.m_stamp;   /* first frame is zero */          pEnc->current->stamp = pEnc->mbParam.m_stamp;   /* first frame is zero */
779    
780      pEnc->mbParam.m_stamp += pEnc->mbParam.fincr;      pEnc->mbParam.m_stamp += pEnc->current->fincr;
781      pEnc->m_framenum++; /* debug ticker */      pEnc->m_framenum++; /* debug ticker */
782  }  }
783    
# Line 739  Line 809 
809  }  }
810    
811    
 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;  
         }  
 }  
   
   
812    
813  /*****************************************************************************  /*****************************************************************************
814   * IPB frame encoder entry point   * IPB frame encoder entry point
# Line 852  Line 904 
904                          }                          }
905    
906                          FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs);                          FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs);
907                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();  
   
908                          pEnc->bframenum_head++;                          pEnc->bframenum_head++;
909    
910                          goto done;                          goto done;
# Line 889  Line 936 
936    
937                          /* add the not-coded length to the reference frame size */                          /* add the not-coded length to the reference frame size */
938                          pEnc->current->length += (BitstreamPos(&bs) - bits) / 8;                          pEnc->current->length += (BitstreamPos(&bs) - bits) / 8;
939              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();  
940    
941              /* flush complete: reset counters */              /* flush complete: reset counters */
942                  pEnc->flush_bframes = 0;                  pEnc->flush_bframes = 0;
# Line 916  Line 960 
960                  {                  {
961    
962              if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->mbParam.max_bframes > 0) {              if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->mbParam.max_bframes > 0) {
963                  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();  
964              }              }
965    
966              /* 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 1004 
1004           * init pEnc->current fields           * init pEnc->current fields
1005           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
1006    
1007        pEnc->current->fincr = pEnc->mbParam.fincr>0 ? pEnc->mbParam.fincr : frame->fincr;
1008      pEnc->current->vol_flags = pEnc->mbParam.vol_flags;      pEnc->current->vol_flags = pEnc->mbParam.vol_flags;
1009      pEnc->current->vop_flags = frame->vop_flags;      pEnc->current->vop_flags = frame->vop_flags;
1010          pEnc->current->motion_flags = frame->motion;          pEnc->current->motion_flags = frame->motion;
# Line 974  Line 1016 
1016                      pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);                      pEnc->mbParam.width, pEnc->mbParam.height, pEnc->mbParam.edged_width);
1017      }      }
1018    
         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  
                 }  
   
         }  
   
1019          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1020           * frame type & quant selection           * frame type & quant selection
1021           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
1022    
1023          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();  
1024    
1025      if (frame->type > 0)      if (frame->type > 0)
1026                  type = frame->type;                  type = frame->type;
# Line 1059  Line 1071 
1071                          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");
1072                  }                  }
1073    
1074                  if (frame->bquant < 1) {                  if (frame->quant < 1) {
1075                          pEnc->current->quant = ((((pEnc->reference->quant + pEnc->current->quant) *                          pEnc->current->quant = ((((pEnc->reference->quant + pEnc->current->quant) *
1076                                  pEnc->mbParam.bquant_ratio) / 2) + pEnc->mbParam.bquant_offset)/100;                                  pEnc->mbParam.bquant_ratio) / 2) + pEnc->mbParam.bquant_offset)/100;
1077    
1078                  } else {                  } else {
1079                          pEnc->current->quant = frame->bquant;                          pEnc->current->quant = frame->quant;
1080                  }                  }
1081    
1082                  if (pEnc->current->quant < 1)                  if (pEnc->current->quant < 1)
# Line 1089  Line 1101 
1101      if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0)      if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0)
1102      {      {
1103          if (pEnc->current->stamp > 0) {          if (pEnc->current->stamp > 0) {
1104              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();  
1105          }          }
1106                  else                  else
1107                          stats->type = XVID_TYPE_NOTHING;                          stats->type = XVID_TYPE_NOTHING;
# Line 1107  Line 1116 
1116    
1117                  // place this frame back on the encoding-queue (head)                  // place this frame back on the encoding-queue (head)
1118                  // we will deal with it next time                  // we will deal with it next time
1119            dec_frame_num(pEnc);
1120            pEnc->iFrameNum--;
1121    
1122                  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);
1123          pEnc->queue_size++;          pEnc->queue_size++;
1124                  image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_head].image);                  image_swap(&pEnc->current->image, &pEnc->queue[pEnc->queue_head].image);
1125    
         dec_frame_num(pEnc);  
         pEnc->iFrameNum--;  
   
1126                  // grab the last frame from the bframe-queue                  // grab the last frame from the bframe-queue
1127    
1128                  pEnc->bframenum_tail--;                  pEnc->bframenum_tail--;
# Line 1169  Line 1178 
1178                             pEnc->mbParam.edged_width, pEnc->mbParam.height);                             pEnc->mbParam.edged_width, pEnc->mbParam.height);
1179          }          }
1180    
   
1181                  FrameCodeI(pEnc, &bs);                  FrameCodeI(pEnc, &bs);
1182                  xFrame->out_flags |= XVID_KEYFRAME;                  xFrame->out_flags |= XVID_KEYFRAME;
1183    
# Line 1210  Line 1218 
1218          }          }
1219    
1220      /* packed or no-bframes: output stats */      /* packed or no-bframes: output stats */
1221      if ((pEnc->mbParam.global_flags & XVID_PACKED) || pEnc->mbParam.max_bframes == 0)      if ((pEnc->mbParam.global_flags & XVID_PACKED) || pEnc->mbParam.max_bframes == 0) {
1222          {          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();  
1223          }          }
1224    
1225          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# Line 1232  Line 1236 
1236  }  }
1237    
1238    
1239    static void SetMacroblockQuants(MBParam * const pParam, FRAMEINFO * frame)
1240    {
1241        unsigned int i,j;
1242        int quant = frame->quant;
1243    
1244        for (j=0; j<pParam->mb_height; j++)
1245        for (i=0; i<pParam->mb_width; i++) {
1246            MACROBLOCK * pMB = &frame->mbs[j*pParam->mb_width + i];
1247            quant += pMB->dquant;
1248            if (quant > 31)
1249                            quant = 31;
1250                    if (quant < 1)
1251                            quant = 1;
1252            pMB->quant = quant;
1253        }
1254    }
1255    
1256    
1257  static __inline void  static __inline void
1258  CodeIntraMB(Encoder * pEnc,  CodeIntraMB(Encoder * pEnc,
1259                          MACROBLOCK * pMB)                          MACROBLOCK * pMB)
# Line 1245  Line 1267 
1267          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;
1268          pMB->sad16 = 0;          pMB->sad16 = 0;
1269    
1270          if ((pEnc->current->vop_flags & XVID_LUMIMASKING)) {          if (pMB->dquant != 0) {
                 if (pMB->dquant != NO_CHANGE) {  
1271                          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;  
                 }  
1272          }          }
   
         pMB->quant = pEnc->current->quant;  
1273  }  }
1274    
1275    
# Line 1293  Line 1305 
1305          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;          pEnc->current->rounding_type = pEnc->mbParam.m_rounding_type;
1306          pEnc->current->coding_type = I_VOP;          pEnc->current->coding_type = I_VOP;
1307    
1308        SetMacroblockQuants(&pEnc->mbParam, pEnc->current);
1309    
1310          BitstreamWriteVolHeader(bs, &pEnc->mbParam);          BitstreamWriteVolHeader(bs, &pEnc->mbParam);
1311    
1312          set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);          set_timecodes(pEnc->current,pEnc->reference,pEnc->mbParam.fbase);
# Line 1417  Line 1431 
1431    
1432          pEnc->current->coding_type = P_VOP;          pEnc->current->coding_type = P_VOP;
1433    
1434    
1435        SetMacroblockQuants(&pEnc->mbParam, pEnc->current);
1436    
1437          start_timer();          start_timer();
1438          /*if (pEnc->current->global_flags & XVID_HINTEDME_SET)          /*if (pEnc->current->global_flags & XVID_HINTEDME_SET)
1439                  HintedMESet(pEnc, &bIntra);                  HintedMESet(pEnc, &bIntra);
# Line 1530  Line 1547 
1547    
1548                          stop_comp_timer();                          stop_comp_timer();
1549    
1550                          if ((pEnc->current->vop_flags & XVID_LUMIMASKING)) {                          if (pMB->dquant != 0) {
                                 if (pMB->dquant != NO_CHANGE) {  
1551                                          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;  
                                 }  
1552                          }                          }
                         pMB->quant = pEnc->current->quant;  
1553    
1554                          pMB->field_pred = 0;                          pMB->field_pred = 0;
1555    
# Line 1563  Line 1572 
1572                          /* Finished processing the MB, now check if to CODE or SKIP */                          /* Finished processing the MB, now check if to CODE or SKIP */
1573    
1574                          skip_possible = (pMB->cbp == 0) && (pMB->mode == MODE_INTER) &&                          skip_possible = (pMB->cbp == 0) && (pMB->mode == MODE_INTER) &&
1575                                                          (pMB->dquant == NO_CHANGE);                                                          (pMB->dquant == 0);
1576    
1577                          if (pEnc->current->coding_type == S_VOP)                          if (pEnc->current->coding_type == S_VOP)
1578                                  skip_possible &= (pMB->mcsel == 1);                                  skip_possible &= (pMB->mcsel == 1);

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

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