/*!
***********************************************************************
* \file macroblock.c
*
* \brief
* Decode a Macroblock
*
* \author
* Main contributors (see contributors.h for copyright, address and affiliation details)
* - Inge Lille-Lang�y <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>
* - Thomas Wedi <wedi@tnt.uni-hannover.de>
* - Detlev Marpe <marpe@hhi.de>
* - Gabi Blaettermann <blaetter@hhi.de>
* - Ye-Kui Wang <wyk@ieee.org>
* - Lowell Winger <lwinger@lsil.com>
***********************************************************************
*/
#include "contributors.h"
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "global.h"
#include "mbuffer.h"
#include "elements.h"
#include "errorconcealment.h"
#include "macroblock.h"
#include "fmo.h"
#include "cabac.h"
#include "vlc.h"
#include "image.h"
#include "mb_access.h"
#include "biaridecod.h"
#include "transform8x8.h"
#if TRACE
#define TRACE_STRING(s) strncpy(currSE.tracestring, s, TRACESTRING_SIZE)
#else
#define TRACE_STRING(s) // do nothing
#endif
extern int last_dquant;
extern ColocatedParams *Co_located;
static void SetMotionVectorPredictor (struct img_par *img,
short *pmv_x,
short *pmv_y,
char ref_frame,
byte list,
char ***refPic,
short ****tmp_mv,
int block_x,
int block_y,
int blockshape_x,
int blockshape_y);
/*!
************************************************************************
* \brief
* initializes the current macroblock
************************************************************************
*/
void start_macroblock(struct img_par *img,struct inp_par *inp, int CurrentMBInScanOrder)
{
int i,j,k,l;
Macroblock *currMB; // intialization code deleted, see below, StW
assert (img->current_mb_nr < img->PicSizeInMbs);
currMB = &img->mb_data[img->current_mb_nr];
/* Update coordinates of the current macroblock */
if (img->MbaffFrameFlag)
{
img->mb_x = (img->current_mb_nr)%((2*img->width)/MB_BLOCK_SIZE);
img->mb_y = 2*((img->current_mb_nr)/((2*img->width)/MB_BLOCK_SIZE));
if (img->mb_x % 2)
{
img->mb_y++;
}
img->mb_x /= 2;
}
else
{
img->mb_x = (img->current_mb_nr)%(img->width/MB_BLOCK_SIZE);
img->mb_y = (img->current_mb_nr)/(img->width/MB_BLOCK_SIZE);
}
/* Define vertical positions */
img->block_y = img->mb_y * BLOCK_SIZE; /* luma block position */
img->pix_y = img->mb_y * MB_BLOCK_SIZE; /* luma macroblock position */
img->pix_c_y = img->mb_y * img->mb_cr_size_y; /* chroma macroblock position */
/* Define horizontal positions */
img->block_x = img->mb_x * BLOCK_SIZE; /* luma block position */
img->pix_x = img->mb_x * MB_BLOCK_SIZE; /* luma pixel position */
img->pix_c_x = img->mb_x * img->mb_cr_size_x; /* chroma pixel position */
// Save the slice number of this macroblock. When the macroblock below
// is coded it will use this to decide if prediction for above is possible
currMB->slice_nr = img->current_slice_nr;
if (img->current_slice_nr >= MAX_NUM_SLICES)
{
error ("maximum number of supported slices exceeded, please recompile with increased value for MAX_NUM_SLICES", 200);
}
dec_picture->slice_id[img->mb_y][img->mb_x] = img->current_slice_nr;
if (img->current_slice_nr > dec_picture->max_slice_id)
{
dec_picture->max_slice_id=img->current_slice_nr;
}
CheckAvailabilityOfNeighbors(img);
// Reset syntax element entries in MB struct
currMB->qp = img->qp ;
currMB->mb_type = 0;
currMB->delta_quant = 0;
currMB->cbp = 0;
currMB->cbp_blk = 0;
currMB->c_ipred_mode= DC_PRED_8; //GB
for (l=0; l < 2; l++)
for (j=0; j < BLOCK_MULTIPLE; j++)
for (i=0; i < BLOCK_MULTIPLE; i++)
for (k=0; k < 2; k++)
currMB->mvd[l][j][i][k] = 0;
currMB->cbp_bits = 0;
// initialize img->m7 for ABT
for (j=0; j<MB_BLOCK_SIZE; j++)
for (i=0; i<MB_BLOCK_SIZE; i++)
img->m7[i][j] = 0;
// store filtering parameters for this MB
currMB->LFDisableIdc = img->currentSlice->LFDisableIdc;
currMB->LFAlphaC0Offset = img->currentSlice->LFAlphaC0Offset;
currMB->LFBetaOffset = img->currentSlice->LFBetaOffset;
}
/*!
************************************************************************
* \brief
* set coordinates of the next macroblock
* check end_of_slice condition
************************************************************************
*/
int exit_macroblock(struct img_par *img,struct inp_par *inp,int eos_bit)
{
//! The if() statement below resembles the original code, which tested
//! img->current_mb_nr == img->PicSizeInMbs. Both is, of course, nonsense
//! In an error prone environment, one can only be sure to have a new
//! picture by checking the tr of the next slice header!
// printf ("exit_macroblock: FmoGetLastMBOfPicture %d, img->current_mb_nr %d\n", FmoGetLastMBOfPicture(), img->current_mb_nr);
img->num_dec_mb++;
if (img->num_dec_mb == img->PicSizeInMbs)
// if (img->current_mb_nr == FmoGetLastMBOfPicture(currSlice->structure))
{
//thb
/*
if (currSlice->next_header != EOS)
currSlice->next_header = SOP;
*/
//the
assert (nal_startcode_follows (img, inp, eos_bit) == TRUE);
return TRUE;
}
// ask for last mb in the slice UVLC
else
{
// printf ("exit_macroblock: Slice %d old MB %d, now using MB %d\n", img->current_slice_nr, img->current_mb_nr, FmoGetNextMBNr (img->current_mb_nr));
img->current_mb_nr = FmoGetNextMBNr (img->current_mb_nr);
if (img->current_mb_nr == -1) // End of Slice group, MUST be end of slice
{
assert (nal_startcode_follows (img, inp, eos_bit) == TRUE);
return TRUE;
}
if(nal_startcode_follows(img, inp, eos_bit) == FALSE)
return FALSE;
if(img->type == I_SLICE || img->type == SI_SLICE || active_pps->entropy_coding_mode_flag == CABAC)
return TRUE;
if(img->cod_counter<=0)
return TRUE;
return FALSE;
}
}
/*!
************************************************************************
* \brief
* Interpret the mb mode for P-Frames
************************************************************************
*/
void interpret_mb_mode_P(struct img_par *img)
{
int i;
const int ICBPTAB[6] = {0,16,32,15,31,47};
Macroblock *currMB = &img->mb_data[img->current_mb_nr];
int mbmode = currMB->mb_type;
#define ZERO_P8x8 (mbmode==5)
#define MODE_IS_P8x8 (mbmode==4 || mbmode==5)
#define MODE_IS_I4x4 (mbmode==6)
#define I16OFFSET (mbmode-7)
#define MODE_IS_IPCM (mbmode==31)
if(mbmode <4)
{
currMB->mb_type = mbmode;
for (i=0;i<4;i++)
{
currMB->b8mode[i] = mbmode;
currMB->b8pdir[i] = 0;
}
}
else if(MODE_IS_P8x8)
{
currMB->mb_type = P8x8;
img->allrefzero = ZERO_P8x8;
}
else if(MODE_IS_I4x4)
{
currMB->mb_type = I4MB;
for (i=0;i<4;i++)
{
currMB->b8mode
没有合适的资源?快使用搜索试试~ 我知道了~
《VisualC.音视频编解码技术及实践》随书光盘源码
共3770个文件
c:816个
h:803个
cpp:388个
需积分: 11 6 下载量 133 浏览量
2017-03-08
23:16:20
上传
评论
收藏 30.86MB RAR 举报
温馨提示
VisualC音视频编解码技术及实践源码(光盘源码)音视频编解码技术及实践随书源码完整资源
资源推荐
资源详情
资源评论
收起资源包目录
《VisualC.音视频编解码技术及实践》随书光盘源码 (3770个子文件)
in_aac.001 5KB
mbaacenc.001 4KB
Avi2mpg.001 4KB
amp.1 2KB
15fps.263 26KB
20kbit.263 24KB
cla7.263 20KB
fmn20.263 20KB
mad13.263 19KB
mis7.263 18KB
fmnx20.263 17KB
car16.263 16KB
suz14.263 16KB
carx16.263 14KB
clax7.263 14KB
madx13.263 14KB
suzx14.263 13KB
misx7.263 12KB
stream.263 7KB
SDLKey.3 6KB
SDL_Event.3 6KB
SDL_OpenAudio.3 6KB
SDL_PixelFormat.3 5KB
SDL_SetAlpha.3 4KB
SDL_SetVideoMode.3 4KB
SDL_CreateCursor.3 3KB
SDL_CreateRGBSurface.3 3KB
SDL_ConvertAudio.3 3KB
SDL_AudioCVT.3 3KB
SDL_SetPalette.3 3KB
SDL_Surface.3 3KB
SDL_AudioSpec.3 3KB
SDL_BlitSurface.3 3KB
SDL_SetColors.3 2KB
SDL_AddTimer.3 2KB
SDL_LockSurface.3 2KB
SDL_keysym.3 2KB
SDL_Overlay.3 2KB
SDL_ListModes.3 2KB
SDL_SetTimer.3 2KB
SDL_SemWaitTimeout.3 2KB
SDL_SetEventFilter.3 2KB
SDL_VideoInfo.3 2KB
SDL_JoyHatEvent.3 2KB
SDL_MouseMotionEvent.3 2KB
SDL_ActiveEvent.3 2KB
SDL_SetColorKey.3 2KB
SDL_CDOpen.3 2KB
SDL_CDPlayTracks.3 2KB
SDL_SemTryWait.3 2KB
SDL_GLattr.3 2KB
SDL_LoadWAV.3 2KB
SDL_WasInit.3 1KB
SDL_CDStatus.3 1KB
SDL_CD.3 1KB
SDL_MouseButtonEvent.3 1KB
SDL_GL_SetAttribute.3 1KB
SDL_VideoModeOK.3 1KB
SDL_KeyboardEvent.3 1KB
SDL_JoyBallEvent.3 1KB
SDL_JoyButtonEvent.3 1KB
SDL_CreateSemaphore.3 1KB
SDL_FillRect.3 1KB
SDL_UserEvent.3 1KB
SDL_GL_GetProcAddress.3 1KB
SDL_BuildAudioCVT.3 1KB
SDL_SemWait.3 1KB
SDL_DisplayFormatAlpha.3 1KB
SDL_JoystickOpen.3 1KB
SDL_PeepEvents.3 1KB
SDL_JoystickGetAxis.3 1KB
SDL_PollEvent.3 1KB
SDL_EnableUNICODE.3 1KB
SDL_JoyAxisEvent.3 1KB
SDL_UpdateRects.3 1KB
SDL_MapRGBA.3 1KB
SDL_MixAudio.3 1KB
SDL_GetModState.3 1KB
SDL_MapRGB.3 1KB
SDL_SetGammaRamp.3 1KB
SDL_Init.3 1KB
SDL_InitSubSystem.3 1KB
SDL_SysWMEvent.3 1KB
SDL_CreateRGBSurfaceFrom.3 1KB
SDL_QuitEvent.3 1KB
SDL_ResizeEvent.3 1KB
SDL_PumpEvents.3 1KB
SDL_SemPost.3 1KB
SDL_JoystickEventState.3 1KB
SDL_DisplayFormat.3 1KB
SDL_GetKeyState.3 1KB
SDL_Palette.3 1KB
SDL_ConvertSurface.3 1KB
SDL_Flip.3 1KB
SDL_CDtrack.3 1017B
SDL_EventState.3 1007B
SDL_CreateYUVOverlay.3 1002B
SDL_SetModState.3 1001B
SDL_JoystickGetBall.3 993B
SDL_SetGamma.3 983B
共 3770 条
- 1
- 2
- 3
- 4
- 5
- 6
- 38
资源评论
polarisnevermoves
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功