[svn] / branches / dev-api-3 / xvidcore / src / encoder.c Repository:
ViewVC logotype

Diff of /branches/dev-api-3/xvidcore/src/encoder.c

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

revision 621, Sat Nov 2 16:12:27 2002 UTC revision 658, Tue Nov 19 13:04:35 2002 UTC
# Line 39  Line 39 
39   *             MinChen <chenm001@163.com>   *             MinChen <chenm001@163.com>
40   *  14.04.2002 added FrameCodeB()   *  14.04.2002 added FrameCodeB()
41   *   *
42   *  $Id: encoder.c,v 1.76.2.15 2002-11-02 16:12:27 chl Exp $   *  $Id: encoder.c,v 1.76.2.19 2002-11-19 13:03:57 syskin Exp $
43   *   *
44   ****************************************************************************/   ****************************************************************************/
45    
# Line 107  Line 107 
107  };  };
108    
109    
 static void __inline  
 image_null(IMAGE * image)  
 {  
         image->y = image->u = image->v = NULL;  
 }  
   
   
110  /*****************************************************************************  /*****************************************************************************
111   * Encoder creation   * Encoder creation
112   *   *
# Line 623  Line 616 
616          start_timer();          start_timer();
617          if (image_input          if (image_input
618                  (&pEnc->queue[pEnc->queue_tail], pEnc->mbParam.width, pEnc->mbParam.height,                  (&pEnc->queue[pEnc->queue_tail], pEnc->mbParam.width, pEnc->mbParam.height,
619                   pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace))                   pEnc->mbParam.edged_width, pFrame->image, pFrame->stride, pFrame->colorspace, pFrame->general & XVID_INTERLACING))
620                  return;                  return;
621          stop_conv_timer();          stop_conv_timer();
622    
# Line 673  Line 666 
666          uint32_t bits, mode;          uint32_t bits, mode;
667    
668          int input_valid = 1;          int input_valid = 1;
669            int bframes_count = 0;
670    
671  #ifdef _DEBUG_PSNR  #ifdef _DEBUG_PSNR
672          float psnr;          float psnr;
# Line 713  Line 707 
707                          SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_tail]);                          SWAP(pEnc->current, pEnc->bframes[pEnc->bframenum_tail]);
708    
709                          FrameCodeP(pEnc, &bs, &bits, 1, 0);                          FrameCodeP(pEnc, &bs, &bits, 1, 0);
710                            bframes_count = 0;
711    
712                          BitstreamPad(&bs);                          BitstreamPad(&bs);
713                          pFrame->length = BitstreamLength(&bs);                          pFrame->length = BitstreamLength(&bs);
714                          pFrame->intra = 0;                          pFrame->intra = 0;
715    
716                            emms();
717    
718                          return XVID_ERR_OK;                          return XVID_ERR_OK;
719                  }                  }
720    
# Line 736  Line 733 
733                  if (input_valid)                  if (input_valid)
734                          queue_image(pEnc, pFrame);                          queue_image(pEnc, pFrame);
735    
736                    emms();
737    
738                  return XVID_ERR_OK;                  return XVID_ERR_OK;
739          }          }
740    
# Line 769  Line 768 
768                          if (input_valid)                          if (input_valid)
769                                  queue_image(pEnc, pFrame);                                  queue_image(pEnc, pFrame);
770    
771                            emms();
772    
773                          return XVID_ERR_OK;                          return XVID_ERR_OK;
774                  }                  }
775          }          }
# Line 799  Line 800 
800                  start_timer();                  start_timer();
801                  if (image_input                  if (image_input
802                          (&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height,                          (&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height,
803                          pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace))                          pEnc->mbParam.edged_width, pFrame->image, pFrame->stride, pFrame->colorspace, pFrame->general & XVID_INTERLACING))
804                    {
805                            emms();
806                          return XVID_ERR_FORMAT;                          return XVID_ERR_FORMAT;
807                    }
808                  stop_conv_timer();                  stop_conv_timer();
809    
810                  // queue input frame, and dequue next image                  // queue input frame, and dequue next image
# Line 839  Line 843 
843                  }                  }
844    
845                  pFrame->length = BitstreamLength(&bs);                  pFrame->length = BitstreamLength(&bs);
846                    emms();
847                  return XVID_ERR_OK;                  return XVID_ERR_OK;
848          }          }
849    
# Line 925  Line 930 
930          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 || pEnc->bframenum_dx50bvop >= 0 ||          if (pEnc->iFrameNum == 0 || pFrame->intra == 1 || pEnc->bframenum_dx50bvop >= 0 ||
931                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&                  (pFrame->intra < 0 && pEnc->iMaxKeyInterval > 0 &&
932                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)                   pEnc->iFrameNum >= pEnc->iMaxKeyInterval)
933                  || /*image_mad(&pEnc->reference->image, &pEnc->current->image,                  || 2 == (mode = MEanalysis(&pEnc->reference->image, pEnc->current,
934                                           pEnc->mbParam.edged_width, pEnc->mbParam.width,                                                                          &pEnc->mbParam, pEnc->iMaxKeyInterval,
935                                           pEnc->mbParam.height) > 30) {*/                                                                          (pFrame->intra < 0) ? pEnc->iFrameNum : 0,
936                          2 == (mode = MEanalysis(&pEnc->reference->image, &pEnc->current->image,                                                                          bframes_count++))) {
                                          &pEnc->mbParam, pEnc->current->mbs, pEnc->current->fcode))) {  
937    
938                  /*                  /*
939                   * This will be coded as an Intra Frame                   * This will be coded as an Intra Frame
940                   */                   */
941                    if ((pEnc->current->global_flags & XVID_QUARTERPEL))
942                            pEnc->mbParam.m_quarterpel = 1;
943                    else
944                            pEnc->mbParam.m_quarterpel = 0;
945    
946                  DPRINTF(DPRINTF_DEBUG,"*** IFRAME bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",                  DPRINTF(DPRINTF_DEBUG,"*** IFRAME bf: head=%i tail=%i   queue: head=%i tail=%i size=%i",
947                                  pEnc->bframenum_head, pEnc->bframenum_tail,                                  pEnc->bframenum_head, pEnc->bframenum_tail,
# Line 955  Line 963 
963                                  image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 BVOP->PVOP");                                  image_printf(&pEnc->current->image, pEnc->mbParam.edged_width, pEnc->mbParam.height, 5, 100, "DX50 BVOP->PVOP");
964                          }                          }
965                          FrameCodeP(pEnc, &bs, &bits, 1, 0);                          FrameCodeP(pEnc, &bs, &bits, 1, 0);
966                            bframes_count = 0;
967    
968                          pFrame->intra = 0;                          pFrame->intra = 0;
969    
970                  } else {                  } else {
971    
972                          FrameCodeI(pEnc, &bs, &bits);                          FrameCodeI(pEnc, &bs, &bits);
973                            bframes_count = 0;
974                          pFrame->intra = 1;                          pFrame->intra = 1;
975    
976                          pEnc->bframenum_dx50bvop = -1;                          pEnc->bframenum_dx50bvop = -1;
# Line 992  Line 1002 
1002                  }                  }
1003    
1004                  FrameCodeP(pEnc, &bs, &bits, 1, 0);                  FrameCodeP(pEnc, &bs, &bits, 1, 0);
1005                    bframes_count = 0;
1006                  pFrame->intra = 0;                  pFrame->intra = 0;
1007                  pEnc->flush_bframes = 1;                  pEnc->flush_bframes = 1;
1008    
1009                  if ((pEnc->global & XVID_GLOBAL_PACKED)) {                  if ((pEnc->global & XVID_GLOBAL_PACKED) && (pEnc->bframenum_tail > 0)) {
1010                          BitstreamPadAlways(&bs);                          BitstreamPadAlways(&bs);
1011                          input_valid = 0;                          input_valid = 0;
1012                          goto ipvop_loop;                          goto ipvop_loop;
# Line 1076  Line 1087 
1087          stop_global_timer();          stop_global_timer();
1088          write_timer();          write_timer();
1089    
1090            emms();
1091          return XVID_ERR_OK;          return XVID_ERR_OK;
1092  }  }
1093    
# Line 1130  Line 1142 
1142          start_timer();          start_timer();
1143          if (image_input          if (image_input
1144                  (&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height,                  (&pEnc->current->image, pEnc->mbParam.width, pEnc->mbParam.height,
1145                   pEnc->mbParam.edged_width, pFrame->image, pFrame->colorspace) < 0)                   pEnc->mbParam.edged_width, pFrame->image, pFrame->stride, pFrame->colorspace, pFrame->general & XVID_INTERLACING) < 0)
1146                  return XVID_ERR_FORMAT;                  return XVID_ERR_FORMAT;
1147          stop_conv_timer();          stop_conv_timer();
1148    
# Line 1621  Line 1633 
1633    
1634          if (pEnc->current->global_flags & XVID_GMC) {          if (pEnc->current->global_flags & XVID_GMC) {
1635  //              printf("Global Motion = %d %d quarterpel=%d\n", pEnc->current->GMC_MV.x, pEnc->current->GMC_MV.y,pEnc->current->quarterpel);  //              printf("Global Motion = %d %d quarterpel=%d\n", pEnc->current->GMC_MV.x, pEnc->current->GMC_MV.y,pEnc->current->quarterpel);
1636                    DPRINTF(DPRINTF_HEADER, "Global Motion = %d %d quarterpel=%d\n", pEnc->current->GMC_MV.x, pEnc->current->GMC_MV.y,pEnc->current->quarterpel);
1637                  pEnc->current->coding_type = S_VOP;                  pEnc->current->coding_type = S_VOP;
1638          } else          } else
1639                  pEnc->current->coding_type = P_VOP;                  pEnc->current->coding_type = P_VOP;
# Line 1902  Line 1915 
1915                  ((int32_t)(pEnc->current->stamp - pEnc->reference->stamp)),     // time_pp                  ((int32_t)(pEnc->current->stamp - pEnc->reference->stamp)),     // time_pp
1916                          pEnc->reference->mbs, f_ref,                          pEnc->reference->mbs, f_ref,
1917                                                   &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,                                                   &pEnc->f_refh, &pEnc->f_refv, &pEnc->f_refhv,
1918                                                   pEnc->current->mbs, b_ref, &pEnc->vInterH,                                                   pEnc->current, b_ref, &pEnc->vInterH,
1919                                                   &pEnc->vInterV, &pEnc->vInterHV);                                                   &pEnc->vInterV, &pEnc->vInterHV);
1920    
1921    

Legend:
Removed from v.621  
changed lines
  Added in v.658

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