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

📄 portio.c

📁 jpeg and mpeg 编解码技术源代码
💻 C
字号:

#include <windows.h>
#include "all.h"
#include "audio.h"


FILE* bin = NULL;
//static int outfd;
AudioFile *outfd;
int stop_now = 0;


#define IN_BUF_SIZE 1024*128

unsigned long input_file_length = 0;

HANDLE input_file;

unsigned char input_area [IN_BUF_SIZE];
int input_index;
int input_len;



void read_input_area ()
{
	input_file_length += input_len;
	input_index = 0;
	ReadFile(
		input_file,
		input_area,
		IN_BUF_SIZE,
		&input_len,
		NULL
		);
}

long OpenInputFile (char *fn)
{
	input_file = CreateFile(
		fn,
		GENERIC_READ,
		FILE_SHARE_READ,
		NULL,
		OPEN_EXISTING,
		0,
		NULL
		);
	if (input_file == INVALID_HANDLE_VALUE)
	{
		CommonExit(-1, "Error opening file");
	}

	read_input_area ();

	return 1;
}


int ReadInputFile (void)
{
	if (input_index == input_len)
	{
		read_input_area ();
		if (input_len == 0) return -1;
	}

	return input_area [input_index ++];
}

void CloseInputFile (void)
{
	CloseHandle(input_file);
}

unsigned long GetInputLength (void)
{
	return input_file_length + input_index;
}

void initio(char *filename)
{
    /* set defaults */
    current_program = -1;
    default_config = 1;
    mc_info.profile = Main_Profile;
    mc_info.sampling_rate_idx = Fs_44;

	if (binisopen) {
		//fclose(bin);
		CloseInputFile();
		binisopen = 0;
	}
    //bin = fopen(filename, "rb");
	OpenInputFile(filename);
	binisopen = 1;
//	if(bin == NULL) {
//		CommonExit(1,"2019: Unable to open input file");
//	}
}

int
open_output_files(MC_Info *mip)
{
	outfd = AudioOpenWrite (2, 44100);
    return(1);
}


void writeout(Float **data, MC_Info *mip)
{
	static int opened = 0;

	if (!opened) {
		open_output_files(mip);
		opened=1;
	}

	AudioWriteData(outfd,data,LN2);
}


int	istrans = 0;
int framebits;

long getshort(void)
{
    int c1, c2;

	if (!stop_now) {
		if ((c1 = ReadInputFile()) < 0)
			goto err;
		if ((c2 = ReadInputFile()) < 0)
			goto err;
	}
	framebits += 16;
    return (c1<<8) | c2;
err:
	stop_now = 1;
	return 0;
}

void
restarttio(void)
{
    cword = 0;
    nbits = 0;
}

int startblock(void)
{
    /* get adif header */
    if (adif_header_present) {
		if (get_adif_header() < 0)
			adif_header_present = 0;
		else
			adif_header_present = 1;
    }
    
    byte_align();	/* start of block is byte aligned */
    return 1;
}

⌨️ 快捷键说明

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