用faad解碼AAC ADTS封裝

2021-06-01 18:09:39 字數 1950 閱讀 2773

/**

* faaddec.c

* use faad library to decode aac, only can decode frame with adts head

*/#include #include #include "faad.h"

#define frame_max_len 1024*5

#define buffer_max_len 1024*1024

void show_usage()

/** * fetch one adts frame

*/int get_one_adts_frame(unsigned char* buffer, size_t buf_size, unsigned char* data ,size_t* data_size)

while(1)

if((buffer[0] == 0xff) && ((buffer[1] & 0xf0) == 0xf0) )

--buf_size;

++buffer;

}if(buf_size < size)

memcpy(data, buffer, size);

*data_size = size;

return 0;

}int main(int argc, char* argv)

; char src_file[128] = ;

char dst_file[128] = ;

file* ifile = null;

file* ofile = null;

unsigned long samplerate;

unsigned char channels;

neaacdechandle decoder = 0;

size_t data_size = 0;

size_t size = 0;

neaacdecframeinfo frame_info;

unsigned char* input_data = buffer;

unsigned char* pcm_data = null;

//analyse parameter

if(argc < 3)

sscanf(argv[1], "%s", src_file);

sscanf(argv[2], "%s", dst_file);

ifile = fopen(src_file, "rb");

ofile = fopen(dst_file, "wb");

if(!ifile || !ofile)

data_size = fread(buffer, 1, buffer_max_len, ifile);

//open decoder

decoder = neaacdecopen();

if(get_one_adts_frame(buffer, data_size, frame, &size) < 0)

//initialize decoder

neaacdecinit(decoder, frame, size, &samplerate, &channels);

printf("samplerate %d, channels %d\n", samplerate, channels);

while(get_one_adts_frame(input_data, data_size, frame, &size) == 0)

else if(pcm_data && frame_info.samples > 0)

data_size -= size;

input_data += size;

}

neaacdecclose(decoder);

fclose(ifile);

fclose(ofile);

return 0;

}

AAC音訊編碼庫FAAC和解碼庫FAAD移植

編譯faac 1.28時遇到錯誤 mpeg4ip.h 126 error new declaration char strcasestr const char const char 解決方法 common mp4v2 mpeg4ip.h 從123行開始修改此檔案mpeg4ip.h,到129行結束。修...

用3 8解碼器實現L A C AB

module cy4 input 2 0 e,輸入埠宣告 input 2 0 a,輸入埠宣告 output reg 7 0 y,輸出埠宣告 output l parameter m0 8 b1111 1110 parameter m1 8 b1111 1101 parameter m2 8 b111...

用hutool進行RSA編碼及解碼

首先引入hutool依賴 cn.hutoolgroupid hutool allartifactid 5.5.1version dependency 先通過網上隨機生成一組金鑰對 公鑰與私鑰 分別定義為public key private key,隨後進行如下操作 以下操作是公鑰加密,私鑰解密,如果...