/*!
***********************************************************************
* \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
没有合适的资源?快使用搜索试试~ 我知道了~
音视频编解码技术及实践随书光盘.rar
共2000个文件
c:816个
h:803个
cpp:388个
5星 · 超过95%的资源 需积分: 11 18 下载量 9 浏览量
2014-04-09
11:16:42
上传
评论 1
收藏 14.32MB RAR 举报
温馨提示
1.读者使用实例程序时,请先将文件拷贝到硬盘上,去掉只读属性;否则可能出错。 2.为了方便读者阅读,光盘中包括了书中的几乎所有的源代码,分别按照章节进行编排。 3.程序使用 有的章节目录下,有Readme说明文件,请按照此说明查找和使用程序。 4.如果学习中遇到问题,欢迎登录求是科技网站参与讨论。 求是科技网址:http://www.cs-book.com
资源推荐
资源详情
资源评论
收起资源包目录
音视频编解码技术及实践随书光盘.rar (2000个子文件)
macroblock.c 180KB
mv-search.c 145KB
macroblock.c 140KB
phi_lpc.c 130KB
rdopt.c 120KB
mbuffer.c 116KB
mbuffer.c 115KB
rtp.c 113KB
MOTION.C 96KB
hufftables.c 90KB
epzs.c 90KB
lencod.c 87KB
block.c 82KB
fastfft.c 82KB
image.c 80KB
SDL_dx5video.c 72KB
block.c 71KB
mode_decision.c 66KB
macroblock.c 65KB
transform8x8.c 64KB
image.c 60KB
erc_do_p.c 59KB
motion_est.c 57KB
h26l.c 56KB
mv-search.c 56KB
b_frame.c 54KB
cabac.c 54KB
rdopt.c 53KB
SDL_blit_N.c 53KB
l3loop.c 52KB
tables.c 51KB
ratectl.c 51KB
sei.c 51KB
mpeg3demux.c 51KB
sei.c 49KB
SDL_video.c 48KB
sdp_decode.c 48KB
celp_decoder.c 48KB
cabac.c 48KB
gtkanal.c 46KB
PREDICT.C 45KB
block.c 45KB
transform.c 44KB
SDL_RLEaccel.c 43KB
SDL_fbvideo.c 43KB
Encode.c 43KB
motion.c 43KB
bitstream.c 43KB
quicktime.c 42KB
aac_qc.c 42KB
pred.c 42KB
SDL_yuv_sw.c 41KB
lame.c 41KB
hufftables.c 41KB
psych.c 40KB
psych.c 40KB
SDL_dspvideo.c 40KB
reconstruct.c 39KB
Readpic.c 38KB
configfile.c 38KB
slice.c 38KB
XF86VMode.c 38KB
phi_xits.c 37KB
output.c 37KB
transform8x8.c 36KB
quantize-pvt.c 36KB
quantize.c 36KB
SDL_x11video.c 36KB
vlc.c 35KB
SDL_cgxvideo.c 35KB
parset.c 34KB
mpeg3css.c 34KB
avilib.c 33KB
psymodel.c 33KB
cabac.c 33KB
getpic.c 32KB
image.c 32KB
text_fdct_mmx.c 32KB
display.c 32KB
fast_me.c 31KB
huffman.c 31KB
huffman.c 31KB
getopt.c 30KB
mbus.c 30KB
vlc.c 30KB
countbit.c 30KB
qfDES.c 29KB
qostcp.c 29KB
SDL_dgavideo.c 29KB
SDL_fbevents.c 29KB
huffdec.c 29KB
main.c 29KB
ieeefloat.c 29KB
getpic.c 29KB
simplified_fast_me.c 29KB
coder.c 28KB
gethdr.c 28KB
ldecod.c 27KB
colorspace.c 27KB
parset.c 27KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
- weixin_394163442022-04-09真的源码,感谢分享
- 会飞的蜗牛up2014-07-30下来看看,还没看,应该会有帮助,感谢分享。
cfy_jewin
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功