我正在使用Lame的mpglib来解码mp3到PCM在Android中的播放。但是当我调用hip_decode()时,它的意思是“在我们完成解码之前需要更多的数据”。我不知道怎么解决这个问题。有人能帮我吗?这是我的代码:
void CBufferWrapper::ConvertMp3toPCM (AAssetManager* mgr, const char *filename){
Print ("ConvertMp3toPCM:file:%s", filename);
AAsset* asset = AAssetManager_open (mgr, filename, AASSET_MODE_UNKNOWN);
// the asset might not be found
assert (asset != NULL);
// open asset as file descriptor
off_t start, length;
int fd = AAsset_openFileDescriptor (asset, &start, &length);
assert (0 <= fd);
long size = AAsset_getLength (asset);
char* buffer = (char*)malloc (sizeof(char)*size);
memset (buffer, 0, size*sizeof(char));
AAsset_read (asset, buffer, size);
AAsset_close (asset);
hip_t ht = hip_decode_init ();
int count = hip_decode (ht, (unsigned char*)buffer, size, pcm_l, pcm_r);
free (buffer);
Print ("ConvertMp3toPCM: length:%ld,pcmcount=%d",length, count);
}我使用宏"HAVE_MPGLIB“在NDK中编译Lame。所以我认为它应该适用于解码字面意思。
发布于 2015-10-12 15:55:35
昨天我也遇到了同样的问题。同样的问题,但使用lame_enc.dll。我不知道如何解决这个0返回,这是这个帖子的原因。
以下是我计划的重要部分:
int total = 0;
int hecho = 0;
int leido = 0;
int lon = 0;
int x;
do
{
total = fread(mp3b, 1, MAXIMO, fich);
leido += total;
x = hip_decode(hgf, mp3b, total, izquierda, derecha);
if(x > 0)
{
int tamanio;
int y;
tamanio = 1.45 * x + 9200;
unsigned char * bu = (unsigned char *) malloc(tamanio);
y = lame_encode_buffer(lamglofla, izquierda, derecha, x, bu, tamanio);
fwrite(bu, 1, y, fichs);
free(bu);
}
}while(total > 0);我的程序解码一个mp3文件并将输出编码成另一个mp3文件。
我希望这可能是有用的。
https://stackoverflow.com/questions/28506613
复制相似问题