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

📄 huffdec1.c

📁 jpeg and mpeg 编解码技术源代码
💻 C
字号:
#include "all.h"

/*
 * read and decode the data for the next 1024 output samples
 * return -1 if there was an error
 */
int huffdecode(int id, MC_Info *mip, byte *win, Wnd_Shape *wshape, 
			   byte **cb_map, short **factors, 
			   byte **group, byte *hasmask, byte **mask, byte *max_sfb, 
			   int **lpflag, int **prstflag,
			   TNS_frame_info **tns, Float **coef)
{
    int i, tag, common_window, ch, widx, first=0, last=0;

    short global_gain;  /* not used in this routine */
    Info info;

    tag = getbits(LEN_TAG);

    switch(id) {
	case ID_SCE:
		common_window = 0;
		break;
	case ID_CPE:
		common_window = getbits(LEN_COM_WIN);
		break;
	default:
		//CommonWarning("Unknown id");
		return(-1);
    }

    if ((ch = chn_config(id, tag, common_window, mip)) < 0)
		return -1;
    
    switch(id) {
	case ID_SCE:
		widx = mip->ch_info[ch].widx;
		first = ch;
		last = ch;
		hasmask[widx] = 0;
		break;
	case ID_CPE:
		first = ch;
		last = mip->ch_info[ch].paired_ch;
		if (common_window) {
			widx = mip->ch_info[ch].widx;
			get_ics_info(&win[widx], &wshape[widx].this_bk, group[widx],
				&max_sfb[widx], lpflag[widx], prstflag[widx]
				);
			hasmask[widx] = getmask(winmap[win[widx]], group[widx], 
				max_sfb[widx], mask[widx]);
		}
		else { 
			hasmask[mip->ch_info[first].widx] = 0;
			hasmask[mip->ch_info[last].widx] = 0;
		}
		break;
    }

    for (i=first; i<=last; i++) {
		widx = mip->ch_info[i].widx;
//		memset(coef[i], 0, LN2*sizeof(*coef[i]));

		if(!getics(&info, common_window, &win[widx], &wshape[widx].this_bk,
			group[widx], &max_sfb[widx], lpflag[widx], prstflag[widx], 
			cb_map[i], coef[i], &global_gain, factors[i],
			tns[i]
			))
			return -1;
    }
    return 0;
}

void get_ics_info(byte *win, byte *wshape, byte *group,
				  byte *max_sfb, int *lpflag, int *prstflag
				  )
{
    int i, j;
    int max_pred_sfb = pred_max_bands();
    Info *info;

    getbits(LEN_ICS_RESERV);	    /* reserved bit */
    *win = getbits(LEN_WIN_SEQ);
    *wshape = getbits(LEN_WIN_SH);
    if ((info = winmap[*win]) == NULL)
        CommonExit(1,"2027: Illegal window code");
	
	/*
	* max scale factor, scale factor grouping and prediction flags
	*/
    prstflag[0] = 0;
    if (info->islong) {
		*max_sfb = getbits(LEN_MAX_SFBL);
		group[0] = 1;
		if ((lpflag[0] = getbits(LEN_PRED_PRES))) {
			if ((prstflag[0] = getbits(LEN_PRED_RST))) {
				for(i=1; i<LEN_PRED_RSTGRP+1; i++)
					prstflag[i] = getbits(LEN_PRED_RST);
			}
			j = ( (*max_sfb < max_pred_sfb) ? 
				*max_sfb : max_pred_sfb ) + 1;
			for (i = 1; i < j; i++)
				lpflag[i] = getbits(LEN_PRED_ENAB);
			for ( ; i < max_pred_sfb+1; i++)
				lpflag[i] = /* 0 */ 1 /* SRQ FIX!!!! */;
		}
    }
    else {
		*max_sfb = getbits(LEN_MAX_SFBS);
		getgroup(info, group);
		lpflag[0] = 0;
    }
}

⌨️ 快捷键说明

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