亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? image.c

?? h264標準的VC實現
?? C
?? 第 1 頁 / 共 5 頁
字號:

/*!
 *************************************************************************************
 * \file image.c
 *
 * \brief
 *    Code one image/slice
 *
 * \author
 *    Main contributors (see contributors.h for copyright, address and affiliation details)
 *     - Inge Lille-Lang鴜               <inge.lille-langoy@telenor.com>
 *     - Rickard Sjoberg                 <rickard.sjoberg@era.ericsson.se>
 *     - Jani Lainema                    <jani.lainema@nokia.com>
 *     - Sebastian Purreiter             <sebastian.purreiter@mch.siemens.de>
 *     - Byeong-Moon Jeon                <jeonbm@lge.com>
 *     - Yoon-Seong Soh                  <yunsung@lge.com>
 *     - Thomas Stockhammer              <stockhammer@ei.tum.de>
 *     - Detlev Marpe                    <marpe@hhi.de>
 *     - Guido Heising                   <heising@hhi.de>
 *     - Thomas Wedi                     <wedi@tnt.uni-hannover.de>
 *     - Ragip Kurceren                  <ragip.kurceren@nokia.com>
 *     - Antti Hallapuro                 <antti.hallapuro@nokia.com>
 *     - Alexis Michael Tourapis         <alexis@mobilygen.com, alexismt@ieee.org> 
 *************************************************************************************
 */
#include "contributors.h"

#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/timeb.h>
#include <string.h>
#include <assert.h>

#ifdef WIN32
#include <io.h>
#else
#include <unistd.h>
#endif

#include "global.h"

#include "refbuf.h"
#include "mbuffer.h"
#include "intrarefresh.h"
#include "fmo.h"
#include "sei.h"
#include "memalloc.h"
#include "nalu.h"
#include "ratectl.h"
#include "mb_access.h"

void code_a_picture(Picture *pic);
void frame_picture (Picture *frame);
void field_picture(Picture *top, Picture *bottom);

static int  writeout_picture(Picture *pic);

static int  picture_structure_decision(Picture *frame, Picture *top, Picture *bot);
static void distortion_fld (float *dis_fld_y, float *dis_fld_u, float *dis_fld_v);
static void find_snr();
static void find_distortion();

static void field_mode_buffer(int bit_field, float snr_field_y, float snr_field_u, float snr_field_v);
static void frame_mode_buffer (int bit_frame, float snr_frame_y, float snr_frame_u, float snr_frame_v);

static void init_frame();
static void init_field();

static void put_buffer_frame();
static void put_buffer_top();
static void put_buffer_bot();

static void copy_motion_vectors_MB();

static void CopyFrameToOldImgOrgVariables (Sourceframe *sf);
static void CopyTopFieldToOldImgOrgVariables (Sourceframe *sf);
static void CopyBottomFieldToOldImgOrgVariables (Sourceframe *sf);
static Sourceframe *AllocSourceframe (int xs, int ys, int xs_cr, int ys_cr);
static void FreeSourceframe (Sourceframe *sf);
static void ReadOneFrame (int FrameNoInFile, int HeaderSize, int xs, int ys, int xs_cr, int ys_cr, Sourceframe *sf);
static void writeUnit(Bitstream* currStream ,int partition);

#ifdef _ADAPT_LAST_GROUP_
int *last_P_no;
int *last_P_no_frm;
int *last_P_no_fld;
#endif

static void ReportFirstframe(int tmp_time, int me_time);
static void ReportIntra(int tmp_time, int me_time);
static void ReportSP(int tmp_time, int me_time);
static void ReportBS(int tmp_time, int me_time);
static void ReportP(int tmp_time, int me_time);
static void ReportB(int tmp_time, int me_time);
static void ReportNALNonVLCBits(int tmp_time, int me_time);

/*
static void ReportFirstframe(int tmp_time);
static void ReportIntra(int tmp_time);
static void ReportSP(int tmp_time);
static void ReportBS(int tmp_time);
static void ReportP(int tmp_time);
static void ReportB(int tmp_time);
*/

static int CalculateFrameNumber();  // Calculates the next frame number
static int FrameNumberInFile;       // The current frame number in the input file
static Sourceframe *srcframe;

StorablePicture *enc_picture;
StorablePicture *enc_frame_picture;
StorablePicture *enc_top_picture;
StorablePicture *enc_bottom_picture;
//Rate control
int    QP;

const int ONE_FOURTH_TAP[3][2] =
{
  {20,20},
  {-5,-4},
  { 1, 0},
};


void MbAffPostProc()
{
  imgpel temp[16][32];

  imgpel ** imgY  = enc_picture->imgY;
  imgpel ***imgUV = enc_picture->imgUV;
  int i, x, y, x0, y0, uv;

  if (img->yuv_format != YUV400)
  {
    for (i=0; i<(int)img->PicSizeInMbs; i+=2)
    {
      if (enc_picture->mb_field[i])
      {
        get_mb_pos(i, &x0, &y0);
        for (y=0; y<(2*MB_BLOCK_SIZE);y++)
          for (x=0; x<MB_BLOCK_SIZE; x++)
            temp[x][y] = imgY[y0+y][x0+x];

        for (y=0; y<MB_BLOCK_SIZE;y++)
          for (x=0; x<MB_BLOCK_SIZE; x++)
          {
            imgY[y0+(2*y)][x0+x]   = temp[x][y];
            imgY[y0+(2*y+1)][x0+x] = temp[x][y+MB_BLOCK_SIZE];
          }

        x0 = x0 / (16/img->mb_cr_size_x);
        y0 = y0 / (16/img->mb_cr_size_y);

        for (uv=0; uv<2; uv++)
        {
          for (y=0; y<(2*img->mb_cr_size_y);y++)    
            for (x=0; x<img->mb_cr_size_x; x++)
              temp[x][y] = imgUV[uv][y0+y][x0+x];
          
          for (y=0; y<img->mb_cr_size_y;y++)
            for (x=0; x<img->mb_cr_size_x; x++)
            {
              imgUV[uv][y0+(2*y)][x0+x]   = temp[x][y];
              imgUV[uv][y0+(2*y+1)][x0+x] = temp[x][y+img->mb_cr_size_y];
            }
        }
      }
    }
  }
  else
  {
    for (i=0; i<(int)img->PicSizeInMbs; i+=2)
    {
      if (enc_picture->mb_field[i])
      {
        get_mb_pos(i, &x0, &y0);
        for (y=0; y<(2*MB_BLOCK_SIZE);y++)
          for (x=0; x<MB_BLOCK_SIZE; x++)
            temp[x][y] = imgY[y0+y][x0+x];

        for (y=0; y<MB_BLOCK_SIZE;y++)
          for (x=0; x<MB_BLOCK_SIZE; x++)
          {
            imgY[y0+(2*y)][x0+x]   = temp[x][y];
            imgY[y0+(2*y+1)][x0+x] = temp[x][y+MB_BLOCK_SIZE];
          }
      }
    }
  }
}

/*!
 ************************************************************************
 * \brief
 *    Encodes a picture
 *
 *    This is the main picture coding loop.. It is called by all this
 *    frame and field coding stuff after the img-> elements have been
 *    set up.  Not sure whether it is useful for MB-adaptive frame/field
 *    coding
 ************************************************************************
 */
void code_a_picture(Picture *pic)
{
  int NumberOfCodedMBs = 0;
  int SliceGroup = 0;
  int j;

  img->currentPicture = pic;

  img->currentPicture->idr_flag = ((!IMG_NUMBER) && (!(img->structure==BOTTOM_FIELD))) || (input->idr_enable && (img->type == I_SLICE || img->type==SP_SLICE || img->type==SI_SLICE)&& (!(img->structure==BOTTOM_FIELD)));

  pic->no_slices = 0;
  pic->distortion_u = pic->distortion_v = pic->distortion_y = 0.0;

  RandomIntraNewPicture ();     //! Allocates forced INTRA MBs (even for fields!)

  // The slice_group_change_cycle can be changed here.
  // FmoInit() is called before coding each picture, frame or field
  img->slice_group_change_cycle=1;
  FmoInit(img, active_pps, active_sps);
  FmoStartPicture ();           //! picture level initialization of FMO

  CalculateQuantParam();

  if(input->AllowTransform8x8)
    CalculateQuant8Param();

  while (NumberOfCodedMBs < img->total_number_mb)       // loop over slices
  {
    // Encode one SLice Group
    while (!FmoSliceGroupCompletelyCoded (SliceGroup))
    {
      // Encode the current slice
      NumberOfCodedMBs += encode_one_slice (SliceGroup, pic);
      FmoSetLastMacroblockInSlice (img->current_mb_nr);
      // Proceed to next slice
      img->current_slice_nr++;
      stats->bit_slice = 0;
    }
    // Proceed to next SliceGroup
    SliceGroup++;
  }
  FmoEndPicture ();

  if (input->rdopt == 2 && (img->type != B_SLICE))
    for (j = 0; j < input->NoOfDecoders; j++)
      DeblockFrame (img, decs->decY_best[j], NULL);

  DeblockFrame (img, enc_picture->imgY, enc_picture->imgUV); //comment out to disable loop filter

  if (img->MbaffFrameFlag)
    MbAffPostProc();

}



/*!
 ************************************************************************
 * \brief
 *    Encodes one frame
 ************************************************************************
 */
int encode_one_frame ()
{
  static int prev_frame_no = 0; // POC200301
  static int consecutive_non_reference_pictures = 0; // POC200301

#ifdef _LEAKYBUCKET_
  extern long Bit_Buffer[10000];
  extern unsigned long total_frame_buffer;
#endif

  time_t ltime1;
  time_t ltime2;

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

  int tmp_time;
  int bits_frm = 0, bits_fld = 0;
  float dis_frm = 0, dis_frm_y = 0, dis_frm_u = 0, dis_frm_v = 0;
  float dis_fld = 0, dis_fld_y = 0, dis_fld_u = 0, dis_fld_v = 0;

  //Rate control
  int pic_type, bits = 0; 

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

  //Rate control 
  img->write_macroblock = 0;
/*
  //Shankar Regunathan (Oct 2002)
  //Prepare Panscanrect SEI payload
  UpdatePanScanRectInfo ();
  //Prepare Arbitrarydata SEI Payload
  UpdateUser_data_unregistered ();
  //Prepare Registered data SEI Payload
  UpdateUser_data_registered_itu_t_t35 ();
  //Prepare RandomAccess SEI Payload
  UpdateRandomAccess ();
*/

  put_buffer_frame ();      // sets the pointers to the frame structures 
                            // (and not to one of the field structures)
  init_frame ();
  FrameNumberInFile = CalculateFrameNumber();

  srcframe = AllocSourceframe (img->width, img->height, img->width_cr, img->height_cr);
  
  ReadOneFrame (FrameNumberInFile, input->infile_header,
                img->width, img->height, img->width_cr, img->height_cr, srcframe);
  CopyFrameToOldImgOrgVariables (srcframe);

  // Set parameters for directmode and Deblocking filter
  img->direct_spatial_mv_pred_flag     = input->direct_spatial_mv_pred_flag;
  img->LFDisableIdc    = input->LFDisableIdc;
  img->LFAlphaC0Offset = input->LFAlphaC0Offset;
  img->LFBetaOffset    = input->LFBetaOffset;

  if (img->type == B_SLICE)
    Bframe_ctr++;         // Bframe_ctr only used for statistics, should go to stats->

  if (input->PicInterlace == FIELD_CODING)
  {
    //Rate control
    img->FieldControl=1;

    img->field_picture = 1;  // we encode fields
    field_picture (top_pic, bottom_pic);
    img->fld_flag = 1;
  }
  else
  {
    //Rate control
    img->FieldControl=0;

    // For frame coding, turn MB level field/frame coding flag on
    if (input->MbInterlace)
      mb_adaptive = 1;

    img->field_picture = 0; // we encode a frame

    //Rate control
    if(input->RCEnable)
    { 
    /*update the number of MBs in the basic unit for MB adaptive 
      f/f coding*/
      if((input->MbInterlace)&&(input->basicunit<img->Frame_Total_Number_MB)\
        &&(img->type==P_SLICE)&&(img->IFLAG==0))
        img->BasicUnit=input->basicunit*2;
      else
        img->BasicUnit=input->basicunit;
      
      rc_init_pict(1,0,1); 
      img->qp  = updateQuantizationParameter(0); 
      
      
      pic_type = img->type;
      QP =0;
    }

    if( active_sps->frame_mbs_only_flag)
      img->TopFieldFlag=0;

    frame_picture (frame_pic);
   
    // For field coding, turn MB level field/frame coding flag off
    if (input->MbInterlace)
      mb_adaptive = 0;
    
    if (input->PicInterlace == ADAPTIVE_CODING)
    {
      //Rate control
      img->FieldControl=1;
      img->write_macroblock = 0;
      img->bot_MB = 0;

      img->field_picture = 1;  // we encode fields
      field_picture (top_pic, bottom_pic);
      
      //! Note: the distortion for a field coded picture is stored in the top field
      //! the distortion values in the bottom field are dummies
      dis_fld = top_pic->distortion_y + top_pic->distortion_u + top_pic->distortion_v;
      dis_frm = frame_pic->distortion_y + frame_pic->distortion_u + frame_pic->distortion_v;
      
      img->fld_flag = picture_structure_decision (frame_pic, top_pic, bottom_pic);
      update_field_frame_contexts (img->fld_flag);

      //Rate control
      if(img->fld_flag==0)
        img->FieldFrame=1;
      /*the current choice is field coding*/
      else
        img->FieldFrame=0;
    }
    else
   
      img->fld_flag = 0;
  }

  if (img->fld_flag)
    stats->bit_ctr_emulationprevention += stats->em_prev_bits_fld;
  else

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人亚洲综合a∨猫咪| 欧美影院午夜播放| 色成年激情久久综合| 这里只有精品视频在线观看| 欧美精彩视频一区二区三区| 午夜视频在线观看一区二区| av亚洲产国偷v产偷v自拍| 欧美电影免费观看高清完整版| 亚洲精品免费电影| 成人一区二区三区中文字幕| 日韩欧美国产精品| 五月激情丁香一区二区三区| 91网站最新网址| 中日韩av电影| 国产91对白在线观看九色| 精品久久人人做人人爰| 日韩国产一区二| 欧美性大战xxxxx久久久| 亚洲欧美国产77777| 成人三级伦理片| 国产蜜臀av在线一区二区三区| 九九精品视频在线看| 日韩一级片网站| 日韩av一区二区三区四区| 欧美在线小视频| 亚洲综合偷拍欧美一区色| 91麻豆国产福利精品| 亚洲欧美综合色| 99久久免费国产| 亚洲免费大片在线观看| 99国产精品久久久久久久久久| 国产精品久久久久aaaa| 福利一区在线观看| 国产精品三级久久久久三级| 国产成人免费xxxxxxxx| 国产欧美一区视频| 丁香六月久久综合狠狠色| 亚洲国产精华液网站w| 成人不卡免费av| 亚洲人成精品久久久久久| 色综合亚洲欧洲| 亚洲一二三四在线观看| 欧美一卡在线观看| 狠狠色丁香久久婷婷综| 国产午夜久久久久| 波多野结衣中文字幕一区二区三区| 欧美高清在线精品一区| 成人av综合一区| 一区二区三区日本| 91麻豆精品国产91久久久久久久久 | 91福利国产精品| 午夜欧美在线一二页| 欧美精品电影在线播放| 国产一区二区三区| 国产精品第四页| 欧美写真视频网站| 麻豆91精品91久久久的内涵| 国产香蕉久久精品综合网| 91麻豆国产精品久久| 亚洲不卡在线观看| 久久久三级国产网站| 91亚洲精品一区二区乱码| 午夜欧美2019年伦理| 精品粉嫩aⅴ一区二区三区四区| 成人免费va视频| 日本欧美在线观看| 中日韩av电影| 91麻豆精品国产91久久久使用方法| 国产精品911| 亚洲一区免费在线观看| 久久先锋资源网| 在线亚洲+欧美+日本专区| 久久国产视频网| 亚洲精品乱码久久久久久| 欧美成人高清电影在线| 91啦中文在线观看| 韩国av一区二区三区| 一卡二卡欧美日韩| 久久精品视频在线看| 欧美日韩亚洲综合一区| 成人激情文学综合网| 日韩va欧美va亚洲va久久| 亚洲天堂av老司机| 久久亚洲欧美国产精品乐播 | 欧美伦理影视网| 丁香天五香天堂综合| 免费亚洲电影在线| 夜夜夜精品看看| 国产精品久久久久一区二区三区共| 欧美日韩一本到| 色综合天天视频在线观看| 久久99精品国产.久久久久 | 国产一区二区毛片| 日韩va亚洲va欧美va久久| 亚洲欧美日韩一区| 欧美国产综合一区二区| 精品人在线二区三区| 欧美日韩高清影院| 欧美在线啊v一区| 99久久精品国产一区二区三区| 国产一区在线观看麻豆| 日本成人在线网站| 亚洲123区在线观看| 亚洲一卡二卡三卡四卡| 一区二区三区自拍| 18涩涩午夜精品.www| 国产精品国产三级国产| 日本一区二区成人在线| 久久久久一区二区三区四区| 日韩精品一区二区三区视频| 欧美mv日韩mv| 欧美高清性hdvideosex| 欧美日韩成人综合| 337p亚洲精品色噜噜噜| 欧美美女一区二区在线观看| 欧美日韩一级二级| 欧美精品在线观看一区二区| 欧美三区在线视频| 在线不卡中文字幕| 日韩美女在线视频| 久久久久久久久久久99999| 精品精品国产高清a毛片牛牛| 欧美mv和日韩mv的网站| 久久久久久久久久久99999| 久久免费视频色| 国产精品伦一区| 日韩理论电影院| 亚洲一级不卡视频| 日韩电影免费在线看| 奇米影视一区二区三区小说| 国内一区二区视频| www.色综合.com| 欧美亚洲国产一区在线观看网站 | 日韩午夜在线观看| 久久久高清一区二区三区| 欧美韩国一区二区| 亚洲精品国久久99热| 亚洲高清免费视频| 激情图片小说一区| a在线欧美一区| 69精品人人人人| 久久婷婷综合激情| 一区二区三区四区激情| 免费一级片91| 波多野结衣中文字幕一区二区三区 | 欧美日韩三级视频| 久久综合国产精品| 亚洲人快播电影网| 日韩精品国产欧美| 成人高清视频在线| 7777精品久久久大香线蕉 | 国产精品1024| 色欧美88888久久久久久影院| 91精品国产综合久久精品| 国产亚洲欧美一级| 午夜在线成人av| 懂色av一区二区三区免费观看| 欧美丝袜丝nylons| 国产女人水真多18毛片18精品视频| 综合久久综合久久| 黄色日韩网站视频| 欧美日韩一二区| 亚洲同性gay激情无套| 久久成人麻豆午夜电影| 色婷婷亚洲一区二区三区| 欧美v日韩v国产v| 一区二区三区小说| 成人免费电影视频| 精品1区2区在线观看| 亚洲第一会所有码转帖| 成人久久视频在线观看| 日韩欧美国产电影| 午夜激情一区二区三区| 91天堂素人约啪| 欧美国产97人人爽人人喊| 九九精品视频在线看| 欧美精品高清视频| 午夜精品久久一牛影视| 91网站在线播放| 国产精品国产三级国产有无不卡| 美女一区二区三区在线观看| 欧美在线观看视频一区二区 | 日韩一卡二卡三卡国产欧美| 一个色妞综合视频在线观看| 不卡av在线网| 国产精品麻豆一区二区| 国产精品99久久久久久似苏梦涵| 日韩视频在线一区二区| 亚洲第一激情av| 日韩无一区二区| 亚洲午夜视频在线| 色视频欧美一区二区三区| 国产精品久久久久久久岛一牛影视| 国产精品 欧美精品| 久久久久久久久久久久电影| 国产一区二区三区最好精华液| 欧美一区永久视频免费观看| 天堂成人国产精品一区| 欧美日韩中文精品| 舔着乳尖日韩一区|