📄 decoder.c
字号:
//******************************************
//File name: decoder.c
//Author: Anna
//Date;
//******************************************
#include <assert.h>
#define DEC_MBC 45
#define DEC_MBR 36
#define INTRA 3
extern int dc_store_lum[2*DEC_MBR+1][2*DEC_MBC+1];
extern int ac_left_lum[2*DEC_MBR+1][2*DEC_MBC+1][7];
extern int ac_top_lum[2*DEC_MBR+1][2*DEC_MBC+1][7];
extern int dc_store_chr[2][DEC_MBR+1][DEC_MBC+1];
extern int ac_left_chr[2][DEC_MBR+1][DEC_MBC+1][7];
extern int ac_top_chr[2][DEC_MBR+1][DEC_MBC+1][7];
extern int modemap[DEC_MBR+1][DEC_MBC+2];
extern int quant_store[DEC_MBR+1][DEC_MBC+1]; // [Review]
extern int MV[2][6][DEC_MBR+1][DEC_MBC+2];
extern unsigned char *edged_ref[3],
*edged_for[3],
*frame_ref[3],
*frame_for[3],
*display_frame[3];
extern int horizontal_size;
extern int vertical_size;
extern int chrom_width;
extern int chrom_height;
extern int mb_width;
extern int mb_height;
extern int coded_picture_width;
extern int coded_picture_height;
extern void * mp4_edged_ref_buffers;
extern void * mp4_edged_for_buffers;
extern void *mp4_display_buffers;
void initdecoder (int n)
{
int i,j,cc;
// save_tables(mp4_tables);
/*dc prediction border*/
for (i = 0; i < (2*DEC_MBC+1); i++)
dc_store_lum[0][i] = 1024;
for (i = 1; i < (2*DEC_MBR+1); i++)
dc_store_lum[i][0] = 1024;
for (i = 0; i < (DEC_MBC+1); i++) {
dc_store_chr[0][0][i] = 1024;
dc_store_chr[1][0][i] = 1024;
}
for (i = 1; i < (DEC_MBR+1); i++) {
dc_store_chr[0][i][0] = 1024;
dc_store_chr[1][i][0] = 1024;
}
/*ac prediction border*/
for (i = 0; i < (2*DEC_MBC+1); i++)
for (j = 0; j < 7; j++) {
ac_left_lum[0][i][j] = 0;
ac_top_lum[0][i][j] = 0;
}
for (i = 1; i < (2*DEC_MBR+1); i++)
for (j = 0; j < 7; j++) {
ac_left_lum[i][0][j] = 0;
ac_top_lum[i][0][j] = 0;
}
/*
[Review] too many computation to access to the
correct array value, better use two different
pointer for Cb and Cr components
*/
for (i = 0; i < (DEC_MBC+1); i++)
for (j = 0; j < 7; j++) {
ac_left_chr[0][0][i][j] = 0;
ac_top_chr[0][0][i][j] = 0;
ac_left_chr[1][0][i][j] = 0;
ac_top_chr[1][0][i][j] = 0;
}
for (i = 1; i < (DEC_MBR+1); i++)
for (j = 0; j < 7; j++) {
ac_left_chr[0][i][0][j] = 0;
ac_top_chr[0][i][0][j] = 0;
ac_left_chr[1][i][0][j] = 0;
ac_top_chr[1][i][0][j] = 0;
}
/* mode border */
for (i = 0; i < mb_width + 1; i++)
modemap[0][i] = INTRA;
for (i = 0; i < mb_height + 1; i++) {
modemap[i][0] = INTRA;
modemap[i][mb_width+1] = INTRA;
}
// edged forward and reference frame
for (cc = 0; cc < 3; cc++)
{
if (cc == 0)
{
edged_ref[cc] = (unsigned char *) mp4_edged_ref_buffers;
assert(edged_ref[cc]);//this can be ignored
edged_for[cc] = (unsigned char *) mp4_edged_for_buffers;
assert(edged_for[cc]);
frame_ref[cc] = edged_ref[cc] + coded_picture_width * 32 + 32;
frame_for[cc] = edged_for[cc] +coded_picture_width * 32 + 32;
}
else
{
unsigned int offset;
if (cc == 1)
offset = coded_picture_width * coded_picture_height;
else
offset = coded_picture_width * coded_picture_height +
chrom_width * chrom_height;
edged_ref[cc] = (unsigned char *) mp4_edged_ref_buffers + offset;
assert(edged_ref[cc]);
edged_for[cc] = (unsigned char *) mp4_edged_for_buffers + offset;
assert(edged_for[cc]);
frame_ref[cc] = edged_ref[cc] + chrom_width * 16 + 16;
frame_for[cc] = edged_for[cc] + chrom_width * 16 + 16;
}
}
// display frame
for (cc = 0; cc < 3; cc++)
{
unsigned int offset;
switch (cc)
{
case 0:
offset = 0;
break;
case 1:
offset = horizontal_size * vertical_size;
break;
case 2:
offset = (horizontal_size * vertical_size) +
((horizontal_size * vertical_size) >> 2);
break;
}
display_frame[cc] = (unsigned char *) mp4_display_buffers + offset;
//assert(display_frame[cc]);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -