Status H264SegmentDecoder::DeblockSlice(Ipp32s nCurMBNumber, Ipp32s &nMBToDeblock)
{
    // when there is slice groups
    if (NULL == m_pSlice)
        DeblockFrame(nCurMBNumber, nMBToDeblock);
    else
        DeblockSegment(nCurMBNumber, nMBToDeblock);

    return UMC_OK;

} // Status H264SegmentDecoder::DeblockSlice(Ipp32s nCurMBNumber, Ipp32s &nMBToDeblock)
Beispiel #2
0
void c_avs_enc:: bot_field(Picture *pic)
{
  myboolean end_of_picture = myfalse;
  int_32_t CurrentMbNumber=0;
  int_32_t MBRowSize = img->width / MB_BLOCK_SIZE;
  int_32_t slice_nr =0;
  int_32_t slice_qp = img->qp;
  int_32_t len;

  img->top_bot = 1; //Yulj 2004.07.20
  while (end_of_picture == myfalse) // loop over macroblocks
  {
    set_MB_parameters (CurrentMbNumber);
    if (input->slice_row_nr && (img->current_mb_nr ==0
      ||(img->current_mb_nr>0 && img->mb_data[img->current_mb_nr].slice_nr != img->mb_data[img->current_mb_nr-1].slice_nr)))
    {
      // slice header start  jlzheng 7.11
      start_slice ();
      img->current_slice_qp = img->qp;
      img->current_slice_start_mb = img->current_mb_nr;
      len = SliceHeader(slice_nr, slice_qp);
      stat->bit_slice += len;
      slice_nr++;
      // slice header end
    }

    img->current_mb_nr_fld = img->current_mb_nr+img->total_number_mb;
    start_macroblock ();
    (this->*encode_one_macroblock) ();
    write_one_macroblock (1);
    terminate_macroblock (&end_of_picture);
    proceed2nextMacroblock ();
    CurrentMbNumber++;
  }

  terminate_picture ();
  if(!input->loop_filter_disable)
  DeblockFrame (img, imgY, imgUV);

  pic->bits_per_picture = 8 * (currBitStream->byte_pos);
}
Beispiel #3
0
void c_avs_enc:: picture_data( )
{
  myboolean end_of_picture = myfalse;
  int_32_t CurrentMbNumber=0;
  int_32_t MBRowSize = img->img_width_in_mb;
  int_32_t slice_nr = 0;
  int_32_t slice_qp = img->qp;
  int_32_t len, i;
  //init the intra pred mode
  for(i=0; i<img->width/B8_SIZE+100; i++)
  {
    memset(img->ipredmode[i], -1, (img->height/B8_SIZE+100)*sizeof(int_32_t));
  }

  for(i=0; i<img->total_number_mb; i++)
  {
    img->mb_data[i].slice_nr = -1;
  }
  if (input->rdopt)
  {
    switch(img->type)
    {
    case INTRA_IMG:
      encode_one_macroblock = &c_avs_enc::encode_one_intra_macroblock_rdo;
      break;
    case INTER_IMG:
      encode_one_macroblock = &c_avs_enc::encode_one_inter_macroblock_rdo;
      break;
    case B_IMG:
      encode_one_macroblock = &c_avs_enc::encode_one_b_frame_macroblock_rdo;
      break;
    }
  }
  else
  {
    // xzhao
    //img->type=INTRA_IMG;
    switch(img->type)
    {
    case INTRA_IMG:
      encode_one_macroblock = &c_avs_enc::encode_one_intra_macroblock_not_rdo;
      break;
    case INTER_IMG:
      encode_one_macroblock = &c_avs_enc::encode_one_inter_macroblock_not_rdo;
      break;
    case B_IMG:
      encode_one_macroblock = &c_avs_enc::encode_one_b_frame_macroblock_not_rdo;
      break;
    }
  }

  while (end_of_picture == myfalse) // loop over macroblocks
  {
    set_MB_parameters(CurrentMbNumber);
    if (input->slice_row_nr && (img->current_mb_nr ==0 ||(img->current_mb_nr>0 && img->mb_data[img->current_mb_nr].slice_nr != img->mb_data[img->current_mb_nr-1].slice_nr)))
    {
#ifdef _ME_FOR_RATE_CONTROL_
      if (glb_me_for_rate_control_flag)
      {
        start_slice ();
      }
#else
      start_slice ();
#endif
      img->current_slice_qp = img->qp;
      img->current_slice_start_mb = img->current_mb_nr;

      len = SliceHeader(slice_nr, slice_qp);

      img->current_slice_nr = slice_nr;
      stat->bit_slice += len;
      slice_nr++;
    }
    start_macroblock();
    (this->*encode_one_macroblock)();

    write_one_macroblock(1);
    terminate_macroblock (&end_of_picture);

    proceed2nextMacroblock ();
    CurrentMbNumber++;
  }

  terminate_picture ();
  DeblockFrame (img, imgY, imgUV);
}
Beispiel #4
0
int decode_one_frame(struct img_par *img,struct inp_par *inp, struct snr_par *snr)
{
  int current_header;
  Slice *currSlice = img->currentSlice;
  int ercStartMB;
  int ercSegment;
//  frame recfr;

  time_t ltime1;                  // for time measurement
  time_t ltime2;

#ifdef WIN32
  struct _timeb tstruct1;
  struct _timeb tstruct2;
#else
  struct timeb tstruct1;
  struct timeb tstruct2;
#endif

  int tmp_time;                   // time used by decoding the last frame


#ifdef WIN32
  _ftime (&tstruct1);             // start time ms
#else
  ftime (&tstruct1);              // start time ms
#endif
  time( &ltime1 );                // start time s

  img->current_slice_nr = 0;
  img->current_mb_nr = -4711;     // initialized to an impossible value for debugging -- correct value is taken from slice header
  currSlice->next_header = -8888; // initialized to an impossible value for debugging -- correct value is taken from slice header
  img->num_dec_mb = 0;

  while ((currSlice->next_header != EOS && currSlice->next_header != SOP))
  {
    current_header = read_new_slice();

    if (current_header == EOS)
      return EOS;

    if (img->structure == FRAME)
      decode_frame_slice(img, inp, current_header);
    else 
      decode_field_slice(img, inp, current_header);

    img->current_slice_nr++;
  }

  if (img->MbaffFrameFlag)
    MbAffPostProc();

  //deblocking for frame or first field
  DeblockFrame( img, dec_picture->imgY, dec_picture->imgUV ) ;
  store_picture_in_dpb(dec_picture);
  dec_picture=NULL;

  if(img->structure != FRAME)       //if the previous pict is top or bottom field, 
  {
    img->current_slice_nr = 0;
    currSlice->next_header = -8889;
    img->num_dec_mb = 0;
    while ((currSlice->next_header != EOS && currSlice->next_header != SOP))
    {   
      current_header = read_new_slice();
      
      if (current_header == EOS)
        return EOS;
      
      decode_field_slice(img, inp, current_header);
      
      img->current_slice_nr++;  
    }

    //deblocking second field
    DeblockFrame( img, dec_picture->imgY, dec_picture->imgUV ) ;
    store_picture_in_dpb(dec_picture);
    dec_picture=NULL;
  }

  g_new_frame=1;

/*  recfr.yptr = &imgY[0][0];
  recfr.uptr = &imgUV[0][0][0];
  recfr.vptr = &imgUV[1][0][0];
*/
  //! this is always true at the beginning of a frame
  ercStartMB = 0;
  ercSegment = 0;

/* !KS: This needs to be fixed for multiple slices
  
  //! mark the start of the first segment
  ercStartSegment(0, ercSegment, 0 , erc_errorVar);
  //! generate the segments according to the macroblock map
  for(i = 1; i<img->PicSizeInMbs; i++)
  {
    if(img->mb_data[i].ei_flag != img->mb_data[i-1].ei_flag)
    {
      ercStopSegment(i-1, ercSegment, 0, erc_errorVar); //! stop current segment
      
      //! mark current segment as lost or OK
      if(img->mb_data[i-1].ei_flag)
        ercMarkCurrSegmentLost(img->width, erc_errorVar);
      else
        ercMarkCurrSegmentOK(img->width, erc_errorVar);
      
      ercSegment++;  //! next segment
      ercStartSegment(i, ercSegment, 0 , erc_errorVar); //! start new segment
      ercStartMB = i;//! save start MB for this segment 
    }
  }
  //! mark end of the last segent
  ercStopSegment(img->PicSizeInMbs-1, ercSegment, 0, erc_errorVar);
  if(img->mb_data[i-1].ei_flag)
    ercMarkCurrSegmentLost(img->width, erc_errorVar);
  else
    ercMarkCurrSegmentOK(img->width, erc_errorVar);

  //! call the right error concealment function depending on the frame type.
  erc_mvperMB /= img->PicSizeInMbs;

  erc_img = img;
  if(img->type == I_SLICE || img->type == SI_SLICE) // I-frame
    ercConcealIntraFrame(&recfr, img->width, img->height, erc_errorVar);
  else
    ercConcealInterFrame(&recfr, erc_object_list, img->width, img->height, erc_errorVar);
*/
  

  if (img->structure == FRAME)         // buffer mgt. for frame mode
    frame_postprocessing(img, inp);
  else
    field_postprocessing(img, inp);   // reset all interlaced variables

  post_poc( img );                    // POC200301


#ifdef WIN32
  _ftime (&tstruct2);   // end time ms
#else
  ftime (&tstruct2);    // end time ms
#endif
  time( &ltime2 );                                // end time sec
  tmp_time=(ltime2*1000+tstruct2.millitm) - (ltime1*1000+tstruct1.millitm);
  tot_time=tot_time + tmp_time;

  if(img->type == I_SLICE) // I picture
    fprintf(stdout,"%3d(I)  %3d %5d %7.4f %7.4f %7.4f %5d\n",
        frame_no, img->ThisPOC, img->qp,snr->snr_y,snr->snr_u,snr->snr_v,tmp_time);
  else if(img->type == P_SLICE) // P pictures
    fprintf(stdout,"%3d(P)  %3d %5d %7.4f %7.4f %7.4f %5d\n",
    frame_no, img->ThisPOC, img->qp,snr->snr_y,snr->snr_u,snr->snr_v,tmp_time);
  else if(img->type == SP_SLICE) // SP pictures
    fprintf(stdout,"%3d(SP) %3d %5d %7.4f %7.4f %7.4f %5d\n",
    frame_no, img->ThisPOC, img->qp,snr->snr_y,snr->snr_u,snr->snr_v,tmp_time);
  else if (img->type == SI_SLICE)
    fprintf(stdout,"%3d(SI) %3d %5d %7.4f %7.4f %7.4f %5d\n",
    frame_no, img->ThisPOC, img->qp,snr->snr_y,snr->snr_u,snr->snr_v,tmp_time);
  else if(!img->disposable_flag) // stored B pictures
    fprintf(stdout,"%3d(BS) %3d %5d %7.4f %7.4f %7.4f %5d\n",
        frame_no, img->ThisPOC, img->qp,snr->snr_y,snr->snr_u,snr->snr_v,tmp_time);
  else // B pictures
    fprintf(stdout,"%3d(B)  %3d %5d %7.4f %7.4f %7.4f %5d\n",
        frame_no, img->ThisPOC, img->qp,snr->snr_y,snr->snr_u,snr->snr_v,tmp_time);

  fflush(stdout);

  //! TO 19.11.2001 Known Problem: for init_frame we have to know the picture type of the actual frame
  //! in case the first slice of the P-Frame following the I-Frame was lost we decode this P-Frame but 
  //! do not write it because it was assumed to be an I-Frame in init_frame. So we force the decoder to
  //! guess the right picture type. This is a hack a should be removed by the time there is a clean
  //! solution where we do not have to know the picture type for the function init_frame.
  if(img->type == I_SLICE)
    img->type = P_SLICE;
  //! End TO 19.11.2001

  if(img->type == I_SLICE || img->type == SI_SLICE || img->type == P_SLICE || !img->disposable_flag)   // I or P pictures
    img->number++;
  else
    Bframe_ctr++;    // B pictures

  exit_frame(img, inp);

  if (img->structure != FRAME)
  {
    img->height /= 2;
    img->height_cr /= 2;
  }

  img->current_mb_nr = -4712;   // impossible value for debugging, StW
  img->current_slice_nr = 0;

  return (SOP);
}