[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.6, Sat Mar 15 16:04:38 2003 UTC
# Line 198  Line 198 
198          }          }
199      }      }
200    
201        if ((pEnc->mbParam.global_flags & XVID_EXTRASTATS_ENABLE) ||
202            (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {
203            pEnc->mbParam.plugin_flags |= XVID_REQORIGINAL; /* psnr calculation requires the original */
204        }
205    
206      /* temp dquants */      /* temp dquants */
207          pEnc->temp_dquants = (int *) xvid_malloc(pEnc->mbParam.mb_width *          pEnc->temp_dquants = (int *) xvid_malloc(pEnc->mbParam.mb_width *
208                                          pEnc->mbParam.mb_height * sizeof(int), CACHE_LINE);                                          pEnc->mbParam.mb_height * sizeof(int), CACHE_LINE);
# Line 620  Line 625 
625    call the plugins    call the plugins
626    */    */
627    
628  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,
629                             int opt, int * type, int * quant, xvid_enc_stats_t * stats)
630  {  {
631      int i;      int i;
632      xvid_plg_data_t data;      xvid_plg_data_t data;
# Line 670  Line 676 
676              data.original.stride[2] = pEnc->mbParam.edged_width/2;              data.original.stride[2] = pEnc->mbParam.edged_width/2;
677          }          }
678    
679            if ((frame->vol_flags & XVID_EXTRASTATS) ||
680                (pEnc->mbParam.plugin_flags & XVID_REQPSNR)) {
681    
682                            data.sse_y =
683                                plane_sse( original->y, frame->image.y,
684                                                   pEnc->mbParam.edged_width, pEnc->mbParam.width,
685                                                   pEnc->mbParam.height);
686    
687                data.sse_u =
688                    plane_sse( original->u, frame->image.u,
689                                               pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
690                                                   pEnc->mbParam.height/2);
691    
692                            data.sse_v =
693                    plane_sse( original->v, frame->image.v,
694                                               pEnc->mbParam.edged_width/2, pEnc->mbParam.width/2,
695                                                   pEnc->mbParam.height/2);
696            }
697    
698          data.type = coding2type(frame->coding_type);          data.type = coding2type(frame->coding_type);
699          data.quant = frame->quant;          data.quant = frame->quant;
700          /* todo: data.qscale */          /* todo: data.qscale */
# Line 681  Line 706 
706          data.kblks = frame->sStat.kblks;          data.kblks = frame->sStat.kblks;
707          data.mblks = frame->sStat.mblks;          data.mblks = frame->sStat.mblks;
708          data.ublks = frame->sStat.ublks;          data.ublks = frame->sStat.ublks;
709    
710            if (stats)
711            {
712                    stats->type = coding2type(frame->coding_type);
713                    stats->quant = frame->quant;
714                    stats->vol_flags = frame->vol_flags;
715                    stats->vop_flags = frame->vop_flags;
716                    stats->length = frame->length;
717                    stats->hlength = frame->length - (frame->sStat.iTextBits / 8);
718                    stats->kblks = frame->sStat.kblks;
719                    stats->mblks = frame->sStat.mblks;
720                    stats->ublks = frame->sStat.ublks;
721                stats->sse_y = data.sse_y;
722                stats->sse_u = data.sse_u;
723                stats->sse_v = data.sse_v;
724            }
725      }      }
726    
727        emms();
728      for (i=0; i<pEnc->num_plugins;i++) {      for (i=0; i<pEnc->num_plugins;i++) {
729          if (pEnc->plugins[i].func) {          if (pEnc->plugins[i].func) {
730              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 732 
732              }              }
733          }          }
734      }      }
735        emms();
736    
737      if (opt == XVID_PLG_BEFORE) {      if (opt == XVID_PLG_BEFORE) {
738          *type = data.type;          *type = data.type;
# Line 739  Line 782 
782  }  }
783    
784    
 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;  
         }  
 }  
   
   
785    
786  /*****************************************************************************  /*****************************************************************************
787   * IPB frame encoder entry point   * IPB frame encoder entry point
# Line 852  Line 877 
877                          }                          }
878    
879                          FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs);                          FrameCodeB(pEnc, pEnc->bframes[pEnc->bframenum_head], &bs);
880                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();  
   
881                          pEnc->bframenum_head++;                          pEnc->bframenum_head++;
882    
883                          goto done;                          goto done;
# Line 889  Line 909 
909    
910                          /* add the not-coded length to the reference frame size */                          /* add the not-coded length to the reference frame size */
911                          pEnc->current->length += (BitstreamPos(&bs) - bits) / 8;                          pEnc->current->length += (BitstreamPos(&bs) - bits) / 8;
912              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();  
913    
914              /* flush complete: reset counters */              /* flush complete: reset counters */
915                  pEnc->flush_bframes = 0;                  pEnc->flush_bframes = 0;
# Line 916  Line 933 
933                  {                  {
934    
935              if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->mbParam.max_bframes > 0) {              if (!(pEnc->mbParam.global_flags & XVID_PACKED) && pEnc->mbParam.max_bframes > 0) {
936                  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();  
937              }              }
938    
939              /* 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 975  Line 989 
989      }      }
990    
991          emms();         /* float-point region */          emms();         /* float-point region */
   
992          if ((pEnc->current->vop_flags & XVID_LUMIMASKING)) {          if ((pEnc->current->vop_flags & XVID_LUMIMASKING)) {
993          unsigned int x, y;          unsigned int x, y;
994    
# Line 1001  Line 1014 
1014                  }                  }
1015    
1016          }          }
1017        emms();             /* END floating-point region */
1018    
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 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 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          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

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

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