⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vtcdec.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************//*   MPEG4 Visual Texture Coding (VTC) Mode Software                        *//*                                                                          *//*   This software was jointly developed by the following participants:     *//*                                                                          *//*   Single-quant,  multi-quant and flow control                            *//*   are provided by  Sarnoff Corporation                                   *//*     Iraj Sodagar   (iraj@sarnoff.com)                                    *//*     Hung-Ju Lee    (hjlee@sarnoff.com)                                   *//*     Paul Hatrack   (hatrack@sarnoff.com)                                 *//*     Shipeng Li     (shipeng@sarnoff.com)                                 *//*     Bing-Bing Chai (bchai@sarnoff.com)                                   *//*     B.S. Srinivas  (bsrinivas@sarnoff.com)                               *//*                                                                          *//*   Bi-level is provided by Texas Instruments                              *//*     Jie Liang      (liang@ti.com)                                        *//*                                                                          *//*   Shape Coding is provided by  OKI Electric Industry Co., Ltd.           *//*     Zhixiong Wu    (sgo@hlabs.oki.co.jp)                                 *//*     Yoshihiro Ueda (yueda@hlabs.oki.co.jp)                               *//*     Toshifumi Kanamaru (kanamaru@hlabs.oki.co.jp)                        *//*                                                                          *//*   OKI, Sharp, Sarnoff, TI and Microsoft contributed to bitstream         *//*   exchange and bug fixing.                                               *//*                                                                          *//*                                                                          *//* In the course of development of the MPEG-4 standard, this software       *//* module is an implementation of a part of one or more MPEG-4 tools as     *//* specified by the MPEG-4 standard.                                        *//*                                                                          *//* The copyright of this software belongs to ISO/IEC. ISO/IEC gives use     *//* of the MPEG-4 standard free license to use this  software module or      *//* modifications thereof for hardware or software products claiming         *//* conformance to the MPEG-4 standard.                                      *//*                                                                          *//* Those intending to use this software module in hardware or software      *//* products are advised that use may infringe existing  patents. The        *//* original developers of this software module and their companies, the     *//* subsequent editors and their companies, and ISO/IEC have no liability    *//* and ISO/IEC have no liability for use of this software module or         *//* modification thereof in an implementation.                               *//*                                                                          *//* Permission is granted to MPEG members to use, copy, modify,              *//* and distribute the software modules ( or portions thereof )              *//* for standardization activity within ISO/IEC JTC1/SC29/WG11.              *//*                                                                          *//* Copyright 1995, 1996, 1997, 1998 ISO/IEC                                 *//****************************************************************************//************************************************************//*     Sarnoff Very Low Bit Rate Still Image Coder          *//*     Copyright 1995, 1996, 1997, 1998 Sarnoff Corporation *//************************************************************/#include <stdlib.h>#include <stdio.h>#include <math.h>#include "basic.hpp"#include "dataStruct.hpp"#include "startcode.hpp"#include "bitpack.hpp"#include "msg.hpp"#include "globals.hpp"extern FILTER DefaultSynthesisFilterInt;extern FILTER DefaultSynthesisFilterDbl;CVTCDecoder::CVTCDecoder(){  m_cInBitsFile = new Char [80];  m_cRecImageFile = new Char [80];}CVTCDecoder::~CVTCDecoder(){  delete m_cInBitsFile;  delete m_cRecImageFile;}void CVTCCommon::getSpatialLayerDims(){  Int i, shift;  /* Calc widths and heights for all spatial layers */  for (i=0; i<mzte_codec.m_iSpatialLev; ++i)  {    shift=mzte_codec.m_iWvtDecmpLev-mzte_codec.m_lastWvtDecompInSpaLayer[i][0]-1;    mzte_codec.m_spaLayerWidth[i][0]=mzte_codec.m_iWidth>>shift;    mzte_codec.m_spaLayerHeight[i][0]=mzte_codec.m_iHeight>>shift;    if (mzte_codec.m_lastWvtDecompInSpaLayer[i][1]<0)    {       mzte_codec.m_spaLayerWidth[i][1]=mzte_codec.m_iDCWidth;       mzte_codec.m_spaLayerHeight[i][1]=mzte_codec.m_iDCHeight;    }    else    {      shift=mzte_codec.m_iWvtDecmpLev-mzte_codec.m_lastWvtDecompInSpaLayer[i][1]-1;      mzte_codec.m_spaLayerWidth[i][1]=mzte_codec.m_iWidth>>shift;      mzte_codec.m_spaLayerHeight[i][1]=mzte_codec.m_iHeight>>shift;    }    if (mzte_codec.m_lastWvtDecompInSpaLayer[i][2]<0)    {       mzte_codec.m_spaLayerWidth[i][2]=mzte_codec.m_iDCWidth;       mzte_codec.m_spaLayerHeight[i][2]=mzte_codec.m_iDCHeight;    }    else    {      shift=mzte_codec.m_iWvtDecmpLev-mzte_codec.m_lastWvtDecompInSpaLayer[i][2]-1;      mzte_codec.m_spaLayerWidth[i][2]=mzte_codec.m_iWidth>>shift;      mzte_codec.m_spaLayerHeight[i][2]=mzte_codec.m_iHeight>>shift;    }  }}void CVTCCommon::setSpatialLayerDimsSQ(Int band){  /* added for compatability for new MQ spatial layer flexability - ph 7/16 */  Int i;    if (band) /* BAND - wvtDecompLev spatial layers */  {    for (i=0; i<mzte_codec.m_iWvtDecmpLev; ++i)    {      mzte_codec.m_lastWvtDecompInSpaLayer[i][0] = i;      mzte_codec.m_lastWvtDecompInSpaLayer[i][1]	=mzte_codec.m_lastWvtDecompInSpaLayer[i][2] = i-1;    }    mzte_codec.m_iSpatialLev=mzte_codec.m_iWvtDecmpLev;  }  else /* TREE - 1 spatial layer */  {    mzte_codec.m_lastWvtDecompInSpaLayer[0][0] = mzte_codec.m_iWvtDecmpLev-1;    mzte_codec.m_lastWvtDecompInSpaLayer[0][1]      =mzte_codec.m_lastWvtDecompInSpaLayer[0][2] = mzte_codec.m_iWvtDecmpLev-2;    mzte_codec.m_iSpatialLev=1;  }  getSpatialLayerDims();}/* Number of bitplanes required to x different values    (i.e. all values in {0,1, ...,x-1} */Int CVTCCommon::ceilLog2(Int x){  Int i;  for (i=0; x > (1<<i); ++i)    ;    return i;}// begin: added by Sharp (99/4/7)Void CVTCDecoder::texture_packet_header_Dec(FILTER ***wvtfilter, PICTURE **Image, Int *header_size){  //  Int  wavelet_uniform=1; // hjlee 0901  align_byte();  if(!mzte_codec.m_usErrResiDisable){		prev_TU_first = prev_TU_last = prev_TU_err = -1;		TU_first = TU_last = TU_max = TU_max_dc = 0;	 		get_err_resilience_header();		if (TU_first != 0)			errorHandler("Reading incorrect TU_first in the first packet.\n");		if (get_X_bits(1) != 1)			errorHandler("Reading incorrect HEC in the first packet.\n");		if (mzte_codec.m_iScanDirection==1) /* BB */			;		else			set_prev_good_TD_segment(-1,0,0);  }	header_Dec_Common(wvtfilter, Image, header_size, 1);  if(!mzte_codec.m_usErrResiDisable){		mzte_codec.m_usSegmentThresh=get_X_bits(16);		get_X_bits(1); // added for FDAM1 by Samsung AIT on 2000/02/03	}}// end: added by Sharp (99/4/7)// hjlee 0901Void CVTCDecoder::header_Dec_V1(FILTER ***wvtfilter, PICTURE **Image){  Int  texture_object_id;  Int  marker_bit;  Int  wavelet_download;  Int  texture_object_layer_shape;  Int  wavelet_stuffing;  Int  still_texture_object_start_code;  Int i; // hjlee 0901  FILTER **filters; // hjlee 0901  Int  wavelet_uniform=1; // hjlee 0901  Int  wavelet_type; // hjlee 0901  still_texture_object_start_code = get_X_bits(32);  if (still_texture_object_start_code != STILL_TEXTURE_OBJECT_START_CODE)    errorHandler("Wrong texture_object_layer_start_code.");  texture_object_id = get_X_bits(16);  marker_bit = get_X_bits(1);// hjlee 0901//  wvtfilter->DWT_Type = get_X_bits(1);//  wavelet_download = get_X_bits(1);  mzte_codec.m_iWvtType = wavelet_type = get_X_bits(1); // hjlee 0901  wavelet_download= mzte_codec.m_iWvtDownload = get_X_bits(1); // hjlee 0901  mzte_codec.m_iWvtDecmpLev = get_X_bits(4); // hjlee 0901  mzte_codec.m_iScanDirection=get_X_bits(1);  mzte_codec.m_bStartCodeEnable = get_X_bits(1);//   mzte_codec.m_iWvtDecmpLev = get_X_bits(8);  // hjlee 0901  texture_object_layer_shape = get_X_bits(2);  mzte_codec.m_iQuantType = get_X_bits(2);   if (mzte_codec.m_iQuantType==2) /* MQ */  {    Int i;    mzte_codec.m_iSpatialLev = get_X_bits(4);    /* Get/Calc number decomp layers for all spatial layers */    if (mzte_codec.m_iSpatialLev == 1)    {      mzte_codec.m_lastWvtDecompInSpaLayer[0][0]=mzte_codec.m_iWvtDecmpLev-1;    }    else if (mzte_codec.m_iSpatialLev != mzte_codec.m_iWvtDecmpLev)    {      mzte_codec.m_defaultSpatialScale = get_X_bits(1);      if (mzte_codec.m_defaultSpatialScale==0)      {	/* Fill in the luma componant of lastWvtDecompInSpaLayer. */	for (i=0; i<mzte_codec.m_iSpatialLev-1; ++i)	  mzte_codec.m_lastWvtDecompInSpaLayer[i][0]=get_X_bits(4);		mzte_codec.m_lastWvtDecompInSpaLayer\	  [mzte_codec.m_iSpatialLev-1][0]	  =mzte_codec.m_iWvtDecmpLev-1;      }      else      {	Int sp0;	sp0=mzte_codec.m_iWvtDecmpLev-mzte_codec.m_iSpatialLev;	mzte_codec.m_lastWvtDecompInSpaLayer[0][0]=sp0;	  	for (i=1; i<mzte_codec.m_iSpatialLev; ++i)	  mzte_codec.m_lastWvtDecompInSpaLayer[i][0]=sp0+i;      }    }    else    {      for (i=0; i<mzte_codec.m_iSpatialLev; ++i)	mzte_codec.m_lastWvtDecompInSpaLayer[i][0]=i;    }        /* Calculate for chroma (one less than luma) */    for (i=0; i<mzte_codec.m_iSpatialLev; ++i)      mzte_codec.m_lastWvtDecompInSpaLayer[i][1]	=mzte_codec.m_lastWvtDecompInSpaLayer[i][2]	=mzte_codec.m_lastWvtDecompInSpaLayer[i][0]-1;  }// hjlee 0901  filters = (FILTER **)malloc(sizeof(FILTER *)*mzte_codec.m_iWvtDecmpLev);  if(filters==NULL)      errorHandler("Memory allocation error\n");  if (wavelet_download == 1) {    mzte_codec.m_iWvtUniform=wavelet_uniform = get_X_bits(1);    if(wavelet_uniform) {      download_wavelet_filters(&(filters[0]), wavelet_type);    }    else {      for(i=0;i< mzte_codec.m_iWvtDecmpLev; i++) {	download_wavelet_filters(&(filters[mzte_codec.m_iWvtDecmpLev-1-i]), wavelet_type);      }    }  }  else if(wavelet_type==0){    mzte_codec.m_iWvtType = 0;    filters[0]=&DefaultSynthesisFilterInt;  }  else{    mzte_codec.m_iWvtType = 1;    filters[0]=&DefaultSynthesisFilterDbl;  }  if(wavelet_uniform) {     for(i=1;i< mzte_codec.m_iWvtDecmpLev; i++) {       filters[i] = filters[0];     }  }  *wvtfilter = filters;  wavelet_stuffing = get_X_bits(3);  if (texture_object_layer_shape==0) {    mzte_codec.m_iAlphaChannel       = 0;     mzte_codec.m_iWidth = get_X_bits(15);    marker_bit = get_X_bits(1);    mzte_codec.m_iHeight = get_X_bits(15);    marker_bit = get_X_bits(1);  }  else { /* Arbitrary shape header */    mzte_codec.m_iAlphaChannel       = 1;     mzte_codec.m_iOriginX = get_X_bits(15);    marker_bit = get_X_bits(1);    mzte_codec.m_iOriginY = get_X_bits(15);    marker_bit = get_X_bits(1);    mzte_codec.m_iWidth = get_X_bits(15);    marker_bit = get_X_bits(1);    mzte_codec.m_iHeight = get_X_bits(15);    marker_bit = get_X_bits(1);    mzte_codec.m_iRealWidth = mzte_codec.m_iWidth;    mzte_codec.m_iRealHeight = mzte_codec.m_iHeight;  }  /* decode the shape info from bitstream */  if(mzte_codec.m_iAlphaChannel)    noteProgress("Decoding Shape Information...");  *Image = (PICTURE *)malloc(sizeof(PICTURE)*3);    get_virtual_mask_V1(*Image, mzte_codec.m_iWvtDecmpLev,		   mzte_codec.m_iWidth, mzte_codec.m_iHeight, 		   mzte_codec.m_iAlphaChannel, mzte_codec.m_iColors,		   filters);}// begin: modified by Sharp (99/2/16)// hjlee 0901Void CVTCDecoder::header_Dec(FILTER ***wvtfilter, PICTURE **Image, Int *header_size){  //Int  texture_object_id;  Int  marker_bit;  //Int  wavelet_download;  //Int  texture_object_layer_shape;  //Int  wavelet_stuffing;  Int  still_texture_object_start_code;  //Int i; // hjlee 0901  //FILTER **filters; // hjlee 0901  //  Int  wavelet_uniform=1; // hjlee 0901  //Int  wavelet_type; // hjlee 0901  Int h_size = 0;  still_texture_object_start_code = get_X_bits(32);  if (still_texture_object_start_code != STILL_TEXTURE_OBJECT_START_CODE)    errorHandler("Wrong texture_object_layer_start_code.");  h_size += 32;  mzte_codec.m_tiling_disable = get_X_bits(1);  h_size += 1;// This part is moved to texture_packet_header_Dec()//Added by Sarnoff for error resilience, 3/5/99  mzte_codec.m_usErrResiDisable=get_X_bits(1);  h_size += 1; // added by Sharp (99/3/29)#if 0  if(mzte_codec.m_usErrResiDisable !=0 && mzte_codec.m_usErrResiDisable !=1)    errorHandler("Incorrect TEXTURE_ERROR_RESILIENCE_DISABLE.");//  align_byte(); deleted by Sharp (99/3/29)  if(!mzte_codec.m_usErrResiDisable){		align_byte(); // added by Sharp (99/3/29)		prev_TU_first = prev_TU_last = prev_TU_err = -1;		TU_first = TU_last = TU_max = TU_max_dc = 0;	 		get_err_resilience_header();		if (TU_first != 0)			errorHandler("Reading incorrect TU_first in the first packet.\n");		if (get_X_bits(1) != 1)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -