[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.95.2.5, Sat Mar 15 14:32:56 2003 UTC revision 1.95.2.7, Sat Mar 15 17:03:17 2003 UTC
# Line 166  Line 166 
166      /* framerate */      /* framerate */
167      pEnc->mbParam.fincr = MAX(create->fincr, 0);      pEnc->mbParam.fincr = MAX(create->fincr, 0);
168          pEnc->mbParam.fbase = create->fincr <= 0 ? 25 : create->fbase;          pEnc->mbParam.fbase = create->fincr <= 0 ? 25 : create->fbase;
169        if (pEnc->mbParam.fincr>0)
170          simplify_time(&pEnc->mbParam.fincr, &pEnc->mbParam.fbase);          simplify_time(&pEnc->mbParam.fincr, &pEnc->mbParam.fbase);
171    
172      /* plugin */      /* plugin */
# Line 198  Line 199 
199          }          }
200      }      }
201    
202        if ((pEnc->mbParam.global_flags & XVID_EXTRASTATS_ENABLE) ||
203            (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {
204            pEnc->mbParam.plugin_flags |= XVID_REQORIGINAL; /* psnr calculation requires the original */
205        }
206    
207      /* temp dquants */      /* temp dquants */
208          pEnc->temp_dquants = (int *) xvid_malloc(pEnc->mbParam.mb_width *          pEnc->temp_dquants = (int *) xvid_malloc(pEnc->mbParam.mb_width *
209                                          pEnc->mbParam.mb_height * sizeof(int), CACHE_LINE);                                          pEnc->mbParam.mb_height * sizeof(int), CACHE_LINE);
# Line 620  Line 626 
626    call the plugins    call the plugins
627    */    */
628    
629  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,
630                             int opt, int * type, int * quant, xvid_enc_stats_t * stats)
631  {  {
632      int i;      int i;
633      xvid_plg_data_t data;      xvid_plg_data_t data;
# Line 630  Line 637 
637    
638      data.width = pEnc->mbParam.width;      data.width = pEnc->mbParam.width;
639      data.height = pEnc->mbParam.height;      data.height = pEnc->mbParam.height;
640      data.fincr = pEnc->mbParam.fincr;      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 670  Line 677 
677              data.original.stride[2] = pEnc->mbParam.edged_width/2;              data.original.stride[2] = pEnc->mbParam.edged_width/2;
678          }          }
679    
680            if ((frame->vol_flags & XVID_EXTRASTATS) ||
681                (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {
682    
683                            data.sse_y =
684                                plane_sse( original->y, frame->image.y,
685                                                   pEnc->mbParam.edged_width, pEnc->mbParam.width,
686                                                   pEnc->mbParam.height);
687    
688                data.sse_u =
689                    plane_sse( original->u, frame->image.u,
690                                               pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
691                                                   pEnc->mbParam.height/2);
692    
693                            data.sse_v =
694                    plane_sse( original->v, frame->image.v,
695                                               pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
696                                                   pEnc->mbParam.height/2);
697            }
698    
699          data.type = coding2type(frame->coding_type);          data.type = coding2type(frame->coding_type);
700          data.quant = frame->quant;          data.quant = frame->quant;
701          /* todo: data.qscale */          /* todo: data.qscale */
# Line 681  Line 707 
707          data.kblks = frame->sStat.kblks;          data.kblks = frame->sStat.kblks;
708          data.mblks = frame->sStat.mblks;          data.mblks = frame->sStat.mblks;
709          data.ublks = frame->sStat.ublks;          data.ublks = frame->sStat.ublks;
710    
711            if (stats)
712            {
713                    stats->type = coding2type(frame->coding_type);
714                    stats->quant = frame->quant;
715                    stats->vol_flags = frame->vol_flags;
716                    stats->vop_flags = frame->vop_flags;
717                    stats->length = frame->length;
718                    stats->hlength = frame->length - (frame->sStat.iTextBits / 8);
719                    stats->kblks = frame->sStat.kblks;
720                    stats->mblks = frame->sStat.mblks;
721                    stats->ublks = frame->sStat.ublks;
722                stats->sse_y = data.sse_y;
723                stats->sse_u = data.sse_u;
724                stats->sse_v = data.sse_v;
725            }
726      }      }
727    
728        emms();
729      for (i=0; i<pEnc->num_plugins;i++) {      for (i=0; i<pEnc->num_plugins;i++) {
730          if (pEnc->plugins[i].func) {          if (pEnc->plugins[i].func) {
731              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) {
# Line 690  Line 733 
733              }              }
734          }          }
735      }      }
736        emms();
737    
738      if (opt == XVID_PLG_BEFORE) {      if (opt == XVID_PLG_BEFORE) {
739          *type = data.type;          *type = data.type;
# Line 707  Line 751 
751      pEnc->current->frame_num = pEnc->m_framenum;      pEnc->current->frame_num = pEnc->m_framenum;
752          pEnc->current->stamp = pEnc->mbParam.m_stamp;   /* first frame is zero */          pEnc->current->stamp = pEnc->mbParam.m_stamp;   /* first frame is zero */
753    
754      pEnc->mbParam.m_stamp += pEnc->mbParam.fincr;      pEnc->mbParam.m_stamp += pEnc->current->fincr;
755      pEnc->m_framenum++; /* debug ticker */      pEnc->m_framenum++; /* debug ticker */
756  }  }
757    
# Line 739  Line 783 
783  }  }
784    
785    
 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;  
         }  
 }  
   
   
786    
787  /*****************************************************************************  /*****************************************************************************
788   * IPB frame encoder entry point   * IPB frame encoder entry point
# Line 852  Line 878 
878                          }                          }
879    
880                          FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs);                          FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs);
881                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();  
   
882                          pEnc->bframenum_head++;                          pEnc->bframenum_head++;
883    
884                          goto done;                          goto done;
# Line 889  Line 910 
910    
911                          /* add the not-coded length to the reference frame size */                          /* add the not-coded length to the reference frame size */
912                          pEnc->current->length += (BitstreamPos(&bs) - bits) / 8;                          pEnc->current->length += (BitstreamPos(&bs) - bits) / 8;
913              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();  
914    
915              /* flush complete: reset counters */              /* flush complete: reset counters */
916                  pEnc->flush_bframes = 0;                  pEnc->flush_bframes = 0;
# Line 916  Line 934 
934                  {                  {
935    
936              if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->mbParam.max_bframes > 0) {              if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->mbParam.max_bframes > 0) {
937                  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();  
938              }              }
939    
940              /* 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 978 
978           * init pEnc->current fields           * init pEnc->current fields
979           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
980    
981    
982        pEnc->current->fincr = pEnc->mbParam.fincr>0 ? pEnc->mbParam.fincr : frame->fincr;
983      pEnc->current->vol_flags = pEnc->mbParam.vol_flags;      pEnc->current->vol_flags = pEnc->mbParam.vol_flags;
984      pEnc->current->vop_flags = frame->vop_flags;      pEnc->current->vop_flags = frame->vop_flags;
985          pEnc->current->motion_flags = frame->motion;          pEnc->current->motion_flags = frame->motion;
# Line 975  Line 992 
992      }      }
993    
994          emms();         /* float-point region */          emms();         /* float-point region */
   
995          if ((pEnc->current->vop_flags & XVID_LUMIMASKING)) {          if ((pEnc->current->vop_flags & XVID_LUMIMASKING)) {
996          unsigned int x, y;          unsigned int x, y;
997    
# Line 1001  Line 1017 
1017                  }                  }
1018    
1019          }          }
1020        emms();             /* END floating-point region */
1021    
1022          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1023           * frame type & quant selection           * frame type & quant selection
1024           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
1025    
1026          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();  
1027    
1028      if (frame->type > 0)      if (frame->type > 0)
1029                  type = frame->type;                  type = frame->type;
# Line 1089  Line 1104 
1104      if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0)      if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->bframenum_tail > 0)
1105      {      {
1106          if (pEnc->current->stamp > 0) {          if (pEnc->current->stamp > 0) {
1107              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();  
1108          }          }
1109                  else                  else
1110                          stats->type = XVID_TYPE_NOTHING;                          stats->type = XVID_TYPE_NOTHING;
# Line 1169  Line 1181 
1181                             pEnc->mbParam.edged_width, pEnc->mbParam.height);                             pEnc->mbParam.edged_width, pEnc->mbParam.height);
1182          }          }
1183    
   
1184                  FrameCodeI(pEnc, &bs);                  FrameCodeI(pEnc, &bs);
1185                  xFrame->out_flags |= XVID_KEYFRAME;                  xFrame->out_flags |= XVID_KEYFRAME;
1186    
# Line 1210  Line 1221 
1221          }          }
1222    
1223      /* packed or no-bframes: output stats */      /* packed or no-bframes: output stats */
1224      if ((pEnc->mbParam.global_flags & XVID_PACKED) || pEnc->mbParam.max_bframes == 0)      if ((pEnc->mbParam.global_flags & XVID_PACKED) || pEnc->mbParam.max_bframes == 0) {
1225          {          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();  
1226          }          }
1227    
1228          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Legend:
Removed from v.1.95.2.5  
changed lines
  Added in v.1.95.2.7

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