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

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

?? mbuffer.c

?? H.264 codec source code
?? C
?? 第 1 頁 / 共 5 頁
字號:

/*!
 ***********************************************************************
 *  \file
 *      mbuffer.c
 *
 *  \brief
 *      Frame buffer functions
 *
 *  \author
 *      Main contributors (see contributors.h for copyright, address and affiliation details)
 *      - Karsten S黨ring                 <suehring@hhi.de>
 *      - Alexis Tourapis                 <alexismt@ieee.org>
 *      - Jill Boyce                      <jill.boyce@thomson.net>
 *      - Saurav K Bandyopadhyay          <saurav@ieee.org>
 *      - Zhenyu Wu                       <Zhenyu.Wu@thomson.net
 *      - Purvin Pandit                   <Purvin.Pandit@thomson.net>
 *
 ***********************************************************************
 */

#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <string.h>

#include "global.h"
#include "mbuffer.h"
#include "memalloc.h"
#include "output.h"
#include "image.h"
#include "header.h"

// picture error concealment
#include "erc_api.h"

static void insert_picture_in_dpb(FrameStore* fs, StorablePicture* p);
static void output_one_frame_from_dpb();
static int  is_used_for_reference(FrameStore* fs);
static void get_smallest_poc(int *poc,int * pos);
static int  remove_unused_frame_from_dpb();
static int  is_short_term_reference(FrameStore* fs);
static int  is_long_term_reference(FrameStore* fs);
void gen_field_ref_ids(StorablePicture *p);

DecodedPictureBuffer dpb;

StorablePicture **listX[6];

StorablePicture *no_reference_picture; //!< dummy storable picture for recovery point

ColocatedParams *Co_located = NULL;

extern StorablePicture *dec_picture;

int listXsize[6];

#define MAX_LIST_SIZE 33

/*!
 ************************************************************************
 * \brief
 *    Print out list of pictures in DPB. Used for debug purposes.
 ************************************************************************
 */
void dump_dpb()
{
  unsigned i;

  return;
  
  for (i=0; i<dpb.used_size;i++)
  {
    printf("(");
    printf("fn=%d  ", dpb.fs[i]->frame_num);
    if (dpb.fs[i]->is_used & 1)
    {
      if (dpb.fs[i]->top_field)
        printf("T: poc=%d  ", dpb.fs[i]->top_field->poc);
      else
        printf("T: poc=%d  ", dpb.fs[i]->frame->top_poc);
    }
    if (dpb.fs[i]->is_used & 2)
    {
      if (dpb.fs[i]->bottom_field)
        printf("B: poc=%d  ", dpb.fs[i]->bottom_field->poc);
      else
        printf("B: poc=%d  ", dpb.fs[i]->frame->bottom_poc);
    }
    if (dpb.fs[i]->is_used == 3)
      printf("F: poc=%d  ", dpb.fs[i]->frame->poc);
    printf("G: poc=%d)  ", dpb.fs[i]->poc);
    if (dpb.fs[i]->is_reference) printf ("ref (%d) ", dpb.fs[i]->is_reference);
    if (dpb.fs[i]->is_long_term) printf ("lt_ref (%d) ", dpb.fs[i]->is_reference);
    if (dpb.fs[i]->is_output) printf ("out  ");
    if (dpb.fs[i]->is_used == 3)
    {
      if (dpb.fs[i]->frame->non_existing) printf ("ne  ");
    }
    printf ("\n");
  }
}

/*!
 ************************************************************************
 * \brief
 *    Returns the size of the dpb depending on level and picture size
 *
 *
 ************************************************************************
 */
int getDpbSize()
{
  int pic_size = (active_sps->pic_width_in_mbs_minus1 + 1) * (active_sps->pic_height_in_map_units_minus1 + 1) * (active_sps->frame_mbs_only_flag?1:2) * 384;

  int size = 0;

  switch (active_sps->level_idc)
  {
  case 10:
    size = 152064;
    break;
  case 11:
    size = 345600;
    break;
  case 12:
    size = 912384;
    break;
  case 13:
    size = 912384;
    break;
  case 20:
    size = 912384;
    break;
  case 21:
    size = 1824768;
    break;
  case 22:
    size = 3110400;
    break;
  case 30:
    size = 3110400;
    break;
  case 31:
    size = 6912000;
    break;
  case 32:
    size = 7864320;
    break;
  case 40:
    size = 12582912;
    break;
  case 41:
    size = 12582912;
    break;
 case 42:
   if(  (active_sps->profile_idc==FREXT_HP   ) || (active_sps->profile_idc==FREXT_Hi10P)
     || (active_sps->profile_idc==FREXT_Hi422) || (active_sps->profile_idc==FREXT_Hi444))
     size = 13369344;
   else
     size = 12582912;
   break; 
  case 50:
    size = 42393600;
    break;
  case 51:
    size = 70778880;
    break;
  default:
    error ("undefined level", 500);
    break;
  }

  size /= pic_size;
  size = min( size, 16);

  if (active_sps->vui_parameters_present_flag && active_sps->vui_seq_parameters.bitstream_restriction_flag)
  {
    if ((int)active_sps->vui_seq_parameters.max_dec_frame_buffering > size)
    {
      error ("max_dec_frame_buffering larger than MaxDpbSize", 500);
    }
    size = max (1, active_sps->vui_seq_parameters.max_dec_frame_buffering);
  }

  return size;
}

/*!
 ************************************************************************
 * \brief
 *    Check then number of frames marked "used for reference" and break 
 *    if maximum is exceeded
 *
 ************************************************************************
 */
void check_num_ref()
{
  if ((int)(dpb.ltref_frames_in_buffer +  dpb.ref_frames_in_buffer ) > (max(1,dpb.num_ref_frames)))
  {
    error ("Max. number of reference frames exceeded. Invalid stream.", 500);
  }
}


/*!
 ************************************************************************
 * \brief
 *    Allocate memory for decoded picture buffer and initialize with sane values.
 *
 ************************************************************************
 */
void init_dpb()
{
  unsigned i,j;

  if (dpb.init_done)
  {
    free_dpb();
  }

  dpb.size      = getDpbSize();

  dpb.num_ref_frames = active_sps->num_ref_frames;

  if (dpb.size < active_sps->num_ref_frames)
  {
    error ("DPB size at specified level is smaller than the specified number of reference frames. This is not allowed.\n", 1000);
  }

  dpb.used_size = 0;
  dpb.last_picture = NULL;

  dpb.ref_frames_in_buffer = 0;
  dpb.ltref_frames_in_buffer = 0;
  
  dpb.fs = calloc(dpb.size, sizeof (FrameStore*));
  if (NULL==dpb.fs) 
    no_mem_exit("init_dpb: dpb->fs");

  dpb.fs_ref = calloc(dpb.size, sizeof (FrameStore*));
  if (NULL==dpb.fs_ref) 
    no_mem_exit("init_dpb: dpb->fs_ref");

  dpb.fs_ltref = calloc(dpb.size, sizeof (FrameStore*));
  if (NULL==dpb.fs_ltref) 
    no_mem_exit("init_dpb: dpb->fs_ltref");

  for (i=0; i<dpb.size; i++)
  {
    dpb.fs[i]       = alloc_frame_store();
    dpb.fs_ref[i]   = NULL;
    dpb.fs_ltref[i] = NULL;
  }
  
  for (i=0; i<6; i++)
  {
    listX[i] = calloc(MAX_LIST_SIZE, sizeof (StorablePicture*)); // +1 for reordering
    if (NULL==listX[i]) 
      no_mem_exit("init_dpb: listX[i]");
  }

  /* allocate a dummy storable picture */
  no_reference_picture = alloc_storable_picture (FRAME, img->width, img->height, img->width_cr, img->height_cr);
  no_reference_picture->top_field    = no_reference_picture;
  no_reference_picture->bottom_field = no_reference_picture;
  no_reference_picture->frame        = no_reference_picture;


  for (j=0;j<6;j++)
  {
    for (i=0; i<MAX_LIST_SIZE; i++)
    {
      listX[j][i] = NULL;
    }
    listXsize[j]=0;
  }

  dpb.last_output_poc = INT_MIN;

  img->last_has_mmco_5 = 0;

  dpb.init_done = 1;

  // picture error concealment
  if(img->conceal_mode !=0)
      last_out_fs = alloc_frame_store();
}
/*!
 ************************************************************************
 * \brief
 *    Free memory for decoded picture buffer.
 ************************************************************************
 */
void free_dpb()
{
  unsigned i;
  if (dpb.fs)
  {
    for (i=0; i<dpb.size; i++)
    {
      free_frame_store(dpb.fs[i]);
    }
    free (dpb.fs);
    dpb.fs=NULL;
  }
  if (dpb.fs_ref)
  {
    free (dpb.fs_ref);
  }
  if (dpb.fs_ltref)
  {
    free (dpb.fs_ltref);
  }
  dpb.last_output_poc = INT_MIN;

  for (i=0; i<6; i++)
    if (listX[i])
    {
      free (listX[i]);
      listX[i] = NULL;
    }

  dpb.init_done = 0;

  // picture error concealment
  if(img->conceal_mode != 0)
      free_frame_store(last_out_fs);

  free_storable_picture(no_reference_picture);
}


/*!
 ************************************************************************
 * \brief
 *    Allocate memory for decoded picture buffer frame stores an initialize with sane values.
 *
 * \return
 *    the allocated FrameStore structure
 ************************************************************************
 */
FrameStore* alloc_frame_store()
{
  FrameStore *f;

  f = calloc (1, sizeof(FrameStore));
  if (NULL==f) 
    no_mem_exit("alloc_frame_store: f");

  f->is_used      = 0;
  f->is_reference = 0;
  f->is_long_term = 0;
  f->is_orig_reference = 0;

  f->is_output = 0;

  f->frame        = NULL;;
  f->top_field    = NULL;
  f->bottom_field = NULL;

  return f;
}

/*!
 ************************************************************************
 * \brief
 *    Allocate memory for a stored picture. 
 *
 * \param structure
 *    picture structure
 * \param size_x
 *    horizontal luma size
 * \param size_y
 *    vertical luma size
 * \param size_x_cr
 *    horizontal chroma size
 * \param size_y_cr
 *    vertical chroma size
 *
 * \return
 *    the allocated StorablePicture structure
 ************************************************************************
 */
StorablePicture* alloc_storable_picture(PictureStructure structure, int size_x, int size_y, int size_x_cr, int size_y_cr)
{
  StorablePicture *s;

  //printf ("Allocating (%s) picture (x=%d, y=%d, x_cr=%d, y_cr=%d)\n", (type == FRAME)?"FRAME":(type == TOP_FIELD)?"TOP_FIELD":"BOTTOM_FIELD", size_x, size_y, size_x_cr, size_y_cr);

  s = calloc (1, sizeof(StorablePicture));
  if (NULL==s) 
    no_mem_exit("alloc_storable_picture: s");

  if (structure!=FRAME)
  {
    size_y    /= 2;
    size_y_cr /= 2; 
  }

  s->PicSizeInMbs = (size_x*size_y)/256;
  s->imgUV = NULL;

  get_mem2Dpel (&(s->imgY), size_y, size_x);
  if (active_sps->chroma_format_idc != YUV400)
    get_mem3Dpel (&(s->imgUV), 2, size_y_cr, size_x_cr);

  s->mb_field = calloc (s->PicSizeInMbs, sizeof(int));
  if (NULL==s->mb_field) 
    no_mem_exit("alloc_storable_picture: s->mb_field");

  get_mem2Dshort (&(s->slice_id), size_y / MB_BLOCK_SIZE, size_x / MB_BLOCK_SIZE);

  get_mem3D      ((byte****)(&(s->ref_idx))   , 2, size_y / BLOCK_SIZE, size_x / BLOCK_SIZE);
  get_mem3Dint64 (&(s->ref_pic_id), 6, size_y / BLOCK_SIZE, size_x / BLOCK_SIZE);
  get_mem3Dint64 (&(s->ref_id)    , 6, size_y / BLOCK_SIZE, size_x / BLOCK_SIZE);
  get_mem4Dshort (&(s->mv)        , 2, size_y / BLOCK_SIZE, size_x / BLOCK_SIZE, 2);

  get_mem2D      (&(s->moving_block), size_y / BLOCK_SIZE, size_x / BLOCK_SIZE);
  get_mem2D      (&(s->field_frame) , size_y / BLOCK_SIZE, size_x / BLOCK_SIZE);

  s->pic_num=0;
  s->frame_num=0;
  s->long_term_frame_idx=0;
  s->long_term_pic_num=0;
  s->used_for_reference=0;
  s->is_long_term=0;
  s->non_existing=0;
  s->is_output = 0;
  s->max_slice_id = 0;

  s->structure=structure;

  s->size_x = size_x;
  s->size_y = size_y;
  s->size_x_cr = size_x_cr;
  s->size_y_cr = size_y_cr;
  
//  s->top_field    = NULL;
//  s->bottom_field = NULL;
//  s->frame        = NULL;
  s->top_field    = no_reference_picture;
  s->bottom_field = no_reference_picture;
  s->frame        = no_reference_picture;

  s->dec_ref_pic_marking_buffer = NULL;

  s->coded_frame                   = 0;
  s->MbaffFrameFlag                = 0;

  return s;
}

/*!
 ************************************************************************
 * \brief
 *    Free frame store memory.
 *
 * \param f
 *    FrameStore to be freed
 *
 ************************************************************************

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久影视| 欧美少妇bbb| 亚洲在线视频免费观看| 精品久久一区二区三区| av不卡免费在线观看| 久久超碰97人人做人人爱| 国产精品无遮挡| 日韩一区二区三区av| 91色porny| 国产白丝精品91爽爽久久| 日韩一区欧美二区| 亚洲色图20p| 国产精品高潮久久久久无| 欧美不卡视频一区| 欧美日韩国产123区| 成人av资源在线| 国产精品一区二区在线观看不卡| 日本欧美在线看| 亚洲国产sm捆绑调教视频 | 亚洲天堂网中文字| 国产三级欧美三级| 欧美精品一区二区三区一线天视频 | 日韩码欧中文字| 成人欧美一区二区三区白人| 国产精品不卡视频| 亚洲精品久久嫩草网站秘色| 欧美精品日日鲁夜夜添| 欧美在线综合视频| 欧美日韩综合色| 欧美日韩一区不卡| 欧美一区二视频| 亚洲精品在线观看网站| 国产欧美日韩另类一区| 国产精品久久国产精麻豆99网站 | 久久99精品久久久| 韩国成人精品a∨在线观看| 国产中文字幕一区| 91丨九色丨尤物| 欧美精品一二三| 久久蜜桃av一区精品变态类天堂 | 天天亚洲美女在线视频| 蜜乳av一区二区| 成人中文字幕在线| 精品视频在线免费看| 日韩欧美色综合网站| 欧美国产成人精品| 日本成人在线电影网| 国产美女主播视频一区| 欧日韩精品视频| 久久综合九色综合97_久久久| 最新高清无码专区| 韩国理伦片一区二区三区在线播放 | 日本美女视频一区二区| 不卡免费追剧大全电视剧网站| 欧美放荡的少妇| 麻豆精品一区二区综合av| 日韩av中文在线观看| gogogo免费视频观看亚洲一| 欧美狂野另类xxxxoooo| 亚洲欧美一区二区视频| 国模套图日韩精品一区二区 | 亚洲妇熟xx妇色黄| eeuss影院一区二区三区| 欧美一级电影网站| 日韩精品免费视频人成| 在线免费观看不卡av| 国产精品乱人伦| 国产91富婆露脸刺激对白| 欧美videos中文字幕| 美女精品自拍一二三四| 国产成人精品午夜视频免费| 欧美一级高清大全免费观看| 亚洲高清在线视频| 日本久久一区二区| 亚洲黄色在线视频| 北条麻妃国产九九精品视频| 国产精品国产三级国产普通话蜜臀| 久久电影网电视剧免费观看| 欧美一区二区三区在线| 久久99久久久久| 精品粉嫩超白一线天av| 精品一区二区三区欧美| 欧美成人a∨高清免费观看| 久久福利资源站| 久久久综合激的五月天| 国产一区二区在线免费观看| 久久久av毛片精品| 亚洲午夜免费电影| 欧美一区二区性放荡片| 久久99热狠狠色一区二区| 久久久www成人免费毛片麻豆| 99视频超级精品| 图片区日韩欧美亚洲| 久久亚洲精品小早川怜子| 91麻豆高清视频| 午夜精品一区二区三区免费视频| 日韩欧美综合一区| 99re66热这里只有精品3直播| 亚洲国产欧美一区二区三区丁香婷| 91麻豆精品91久久久久同性| 大白屁股一区二区视频| 婷婷中文字幕一区三区| 中文字幕 久热精品 视频在线 | 日韩视频一区二区三区在线播放| 国产亚洲精品aa午夜观看| 粉嫩嫩av羞羞动漫久久久| 一区二区三区在线影院| 国产亚洲精品精华液| 欧美绝品在线观看成人午夜影视| 成人一级视频在线观看| 蜜桃久久久久久| 亚洲国产精品综合小说图片区| 精品久久久影院| 4438x亚洲最大成人网| 97精品超碰一区二区三区| 国产一区二区三区精品视频| 亚洲成av人片在线观看无码| 亚洲日本va午夜在线影院| 亚州成人在线电影| 综合电影一区二区三区| 欧美激情综合在线| 久久亚洲综合色一区二区三区| 欧美精品免费视频| 日本欧美肥老太交大片| 一区二区三区91| 亚洲精品国产无套在线观| 国产精品国产三级国产| 中文字幕日韩一区| 亚洲婷婷在线视频| 亚洲午夜久久久久久久久电影网| 亚洲乱码国产乱码精品精的特点 | 国产成人av电影| 成人美女视频在线观看18| 粉嫩13p一区二区三区| av动漫一区二区| 欧美在线影院一区二区| 欧美一区永久视频免费观看| 日韩三级视频在线看| 国产亚洲精久久久久久| 亚洲六月丁香色婷婷综合久久| 亚洲午夜久久久久久久久久久 | 欧美自拍偷拍一区| 欧美老人xxxx18| 精品国产电影一区二区| 国产精品视频看| 无码av中文一区二区三区桃花岛| 久久精品理论片| 粉嫩欧美一区二区三区高清影视| 一本大道久久a久久精品综合| 欧美日韩精品欧美日韩精品一| 久久夜色精品国产噜噜av| 亚洲欧美日韩久久| 精品一区二区三区蜜桃| 色中色一区二区| 国产日韩影视精品| 首页国产丝袜综合| 99精品欧美一区二区蜜桃免费| 91精品综合久久久久久| 国产精品国模大尺度视频| 天堂精品中文字幕在线| 欧美丰满少妇xxxbbb| 亚洲精品一区二区三区在线观看 | 亚洲成人自拍一区| 国产精品99久久久久久似苏梦涵| 欧美在线免费观看视频| 国产精品视频免费看| 精东粉嫩av免费一区二区三区| 色国产精品一区在线观看| 国产亚洲成av人在线观看导航 | 日韩欧美视频一区| 香蕉成人啪国产精品视频综合网| av动漫一区二区| 国产精品国产三级国产aⅴ入口| 国产一区二区看久久| 精品国产免费人成在线观看| 一区二区三区在线观看欧美| 91美女视频网站| 日韩精品在线看片z| 天堂一区二区在线| 91麻豆精品国产自产在线| 亚洲成人动漫在线观看| 欧美日韩国产a| 久久国产婷婷国产香蕉| 337p粉嫩大胆色噜噜噜噜亚洲| 日本伊人色综合网| 2020国产精品自拍| 国产成人精品综合在线观看| 国产精品久久久久影院老司| 94色蜜桃网一区二区三区| 一区二区三区在线免费播放| 在线亚洲+欧美+日本专区| 午夜视频在线观看一区| 日韩一级大片在线| 国产宾馆实践打屁股91| 亚洲在线免费播放| 欧美变态凌虐bdsm| 色8久久人人97超碰香蕉987| 日本特黄久久久高潮| 中文字幕免费不卡| 日本电影亚洲天堂一区|