2024-07-03 07:42 AM - last edited on 2024-07-03 08:10 AM by SofLit
i have compiled opus lib on H5. but i can not decode data.
DecConfigOpus.channels = 2;
DecConfigOpus.ms_frame = 20;
DecConfigOpus.sample_freq = 48000;
uint32_t dec_size = DEC_Opus_getMemorySize(&DecConfigOpus);
DecConfigOpus.pInternalMemory = (uint8_t *)malloc(dec_size);
int opus_err;
if (DEC_Opus_Init(&DecConfigOpus, &opus_err) != OPUS_SUCCESS)
{
printf("ERROR! DEC_Opus_Init()\r\n");
break;
}
int packetSize = 80; // Adjust based on your actual packet size
for (int i = 0; i < sizeof(music); i += packetSize)
{
int x = DEC_Opus_Decode((uint8_t*)&music[i], packetSize, DecConfigOpus.pInternalMemory);
if (x < 0)
{
printf("Error decoding packet at index %d: %d\n", i, x);
break; // Exit the loop or handle error as appropriate
}
else
{
printf("Decoded packet at index %d, x = %d\n", i, x);
}
}
2024-07-03 07:47 AM
Hello @nimaltd ,
A gentle reminder on how to post a thread in this community mainly on how to share a code source. I suggest to review these recommendations.
Thank your for your understanding.
2024-07-03 11:13 PM
i think i found the problem, my start point of data was wrong. ( skip header/tag did not work property)
how to find the packetSize?