[svn] / trunk / xvidcore / src / encoder.c Repository:
ViewVC logotype

Diff of /trunk/xvidcore/src/encoder.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 236, Sun Jun 23 19:48:06 2002 UTC revision 238, Mon Jun 24 09:53:18 2002 UTC
# Line 37  Line 37 
37   *             MinChen <chenm001@163.com>   *             MinChen <chenm001@163.com>
38   *  14.04.2002 added FrameCodeB()   *  14.04.2002 added FrameCodeB()
39   *   *
40   *  $Id: encoder.c,v 1.47 2002-06-23 19:48:06 edgomez Exp $   *  $Id: encoder.c,v 1.48 2002-06-24 09:53:17 suxen_drol Exp $
41   *   *
42   ****************************************************************************/   ****************************************************************************/
43    
# Line 51  Line 51 
51  #include "global.h"  #include "global.h"
52  #include "utils/timer.h"  #include "utils/timer.h"
53  #include "image/image.h"  #include "image/image.h"
54    #ifdef BFRAMES
55    #include "image/font.h"
56    #endif
57  #include "motion/motion.h"  #include "motion/motion.h"
58  #include "bitstream/cbp.h"  #include "bitstream/cbp.h"
59  #include "utils/mbfunctions.h"  #include "utils/mbfunctions.h"
# Line 375  Line 378 
378          pEnc->bframenum_head = 0;          pEnc->bframenum_head = 0;
379          pEnc->bframenum_tail = 0;          pEnc->bframenum_tail = 0;
380          pEnc->flush_bframes = 0;          pEnc->flush_bframes = 0;
381            pEnc->bframenum_dx50bvop = -1;
382    
383          pEnc->queue = NULL;          pEnc->queue = NULL;
384    
# Line 756  Line 760 
760    
761  bvop_loop:  bvop_loop:
762    
763          if (input_valid) {          if (pEnc->bframenum_dx50bvop != -1)
764            {
765    
766                    SWAP(pEnc->current, pEnc->reference);
767                    SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_dx50bvop]);
768    
769                    if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
770                            image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 IVOP");
771                    }
772    
773                    if (input_valid)
774                    {
775                            queue_image(pEnc, pFrame);
776                            input_valid = 0;
777                    }
778    
779            } else if (input_valid) {
780    
781                  SWAP(pEnc->current, pEnc->reference);                  SWAP(pEnc->current, pEnc->reference);
782    
# Line 815  Line 835 
835           * comment style :-)           * comment style :-)
836           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
837    
 //$$    SWAP(pEnc->current, pEnc->reference);  
   
838          emms();          emms();
839    
840            // only inc frame num, adapt quant, etc. if we havent seen it before
841            if (pEnc->bframenum_dx50bvop < 0 )
842            {
843          if (pFrame->quant == 0)          if (pFrame->quant == 0)
844                  pEnc->current->quant = RateControlGetQ(&pEnc->rate_control, 0);                  pEnc->current->quant = RateControlGetQ(&pEnc->rate_control, 0);
845          else          else
# Line 832  Line 853 
853    
854          pEnc->current->global_flags = pFrame->general;          pEnc->current->global_flags = pFrame->general;
855          pEnc->current->motion_flags = pFrame->motion;          pEnc->current->motion_flags = pFrame->motion;
856          pEnc->current->seconds = pEnc->mbParam.m_seconds;  
         pEnc->current->ticks = pEnc->mbParam.m_ticks;  
857          /* ToDo : dynamic fcode (in both directions) */          /* ToDo : dynamic fcode (in both directions) */
858          pEnc->current->fcode = pEnc->mbParam.m_fcode;          pEnc->current->fcode = pEnc->mbParam.m_fcode;
859          pEnc->current->bcode = pEnc->mbParam.m_fcode;          pEnc->current->bcode = pEnc->mbParam.m_fcode;
860    
861  //$$$   start_timer();                  pEnc->current->seconds = pEnc->mbParam.m_seconds;
862  //$$$   if (image_input                  pEnc->current->ticks = pEnc->mbParam.m_ticks;
863  //$$$           (&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height,  
864  //$$$            pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace))                  inc_frame_num(pEnc);
 //$$$           return XVID_ERR_FORMAT;  
 //$$$   stop_conv_timer();  
865    
866  #ifdef _DEBUG_PSNR  #ifdef _DEBUG_PSNR
867          image_copy(&pEnc->sOriginal, &pEnc->current->image,          image_copy(&pEnc->sOriginal, &pEnc->current->image,
# Line 857  Line 875 
875                          "%i  if:%i  st:%i:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->seconds, pEnc->current->ticks);                          "%i  if:%i  st:%i:%i", pEnc->m_framenum++, pEnc->iFrameNum, pEnc->current->seconds, pEnc->current->ticks);
876          }          }
877    
   
878          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
879           * Luminance masking           * Luminance masking
880           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
# Line 887  Line 904 
904                          }                          }
905    
906  #undef OFFSET  #undef OFFSET
   
907                  }                  }
908    
909                  xvid_free(temp_dquants);                  xvid_free(temp_dquants);
910          }          }
911    
912            }
913    
914          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%          /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
915           * ivop/pvop/bvop selection           * ivop/pvop/bvop selection
916           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */           * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
917    
918    
919          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 ||          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 || pEnc->bframenum_dx50bvop != -1 ||
920                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&
921                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)
922                  || image_mad(&pEnc->reference->image, &pEnc->current->image,                  || image_mad(&pEnc->reference->image, &pEnc->current->image,
# Line 916  Line 934 
934                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "IVOP");                          image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 200, "IVOP");
935                  }                  }
936    
937                  FrameCodeI(pEnc, &bs, &bits);                  // when we reach an iframe in DX50BVOP mode, encode the last bframe as a pframe
938    
939                    if ((pEnc->global & XVID_GLOBAL_DX50BVOP) && pEnc->bframenum_tail > 0) {
940    
941                            pEnc->bframenum_tail--;
942                            pEnc->bframenum_dx50bvop = pEnc->bframenum_tail;
943    
944                            SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_dx50bvop]);
945                            if ((pEnc->global & XVID_GLOBAL_DEBUG)) {
946                                    image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 BVOP->PVOP");
947                            }
948                            FrameCodeP(pEnc, &bs, &bits, 1, 0);
949    
950                            pFrame->intra = 0;
951    
952                    } else {
953                            pEnc->bframenum_dx50bvop = -1;
954                            FrameCodeI(pEnc, &bs, &bits);
955                  pFrame->intra = 1;                  pFrame->intra = 1;
956                  pEnc->flush_bframes = 1;                  }
957    
958                  inc_frame_num(pEnc);                  pEnc->flush_bframes = 1;
959    
960                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {
961                          BitstreamPad(&bs);                          BitstreamPad(&bs);
# Line 950  Line 984 
984                  pFrame->intra = 0;                  pFrame->intra = 0;
985                  pEnc->flush_bframes = 1;                  pEnc->flush_bframes = 1;
986    
                 inc_frame_num(pEnc);  
   
987                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {
988                          BitstreamPad(&bs);                          BitstreamPad(&bs);
989                          input_valid = 0;                          input_valid = 0;
# Line 988  Line 1020 
1020                  pFrame->intra = 0;                  pFrame->intra = 0;
1021                  pFrame->length = 0;                  pFrame->length = 0;
1022    
                 inc_frame_num(pEnc);  
   
1023                  input_valid = 0;                  input_valid = 0;
1024                  goto bvop_loop;                  goto bvop_loop;
1025          }          }

Legend:
Removed from v.236  
changed lines
  Added in v.238

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