作者 ookk303

修改

# 编译链的配置
#1、编译链与设备类型的选择
set(DEVICE_NAME JZ_C1)
set(DEVICE_NAME JZ_H1T)
#上一行为禁止修改行
if("${DEVICE_NAME}" STREQUAL "JZ_H1E")
... ...
... ... @@ -75,7 +75,7 @@ T_JZsdkReturnCode Main_M30_all_filter_mode(int *mode)
if (*mode == JZ_FLAGCODE_ON)
{
//先关闭播放
Megaphone_StopPlay(JZ_FLAGCODE_OFF);
//Megaphone_StopPlay(JZ_FLAGCODE_OFF);
//修改滤波
AudioDeal_SetFilterMode(0x01);
... ... @@ -83,7 +83,7 @@ T_JZsdkReturnCode Main_M30_all_filter_mode(int *mode)
else
{
//先关闭播放
Megaphone_StopPlay(JZ_FLAGCODE_OFF);
//Megaphone_StopPlay(JZ_FLAGCODE_OFF);
//修改滤波
AudioDeal_SetFilterMode(0x00);
... ...
... ... @@ -7,7 +7,7 @@
#define VERSION_CHOOSE_H
#include "./ConfigParams.h"
//1~10行 除了D可以修改版本选择 禁止动任何东西
#define DEVICE_VERSION JZ_C1
#define DEVICE_VERSION JZ_H1T
//禁止修改行 选择是串口程序 还是 psdk程序
#define APP_VERSION APP_PSDK
... ... @@ -19,13 +19,13 @@
#define MAJOR_VERSION 0x01
#define MINOR_VERSION 0x03
#define MODIFY_VERSION 0x09
#define DEBUG_VERSION 0x02
#define DEBUG_VERSION 0x01
//禁止修改行 滤波方式
#define FILTERING_TYPE HIGH_PASS_FILTERING
//禁止修改行固件属地 目前 国内版/海外版
#define FIRMWARE_ORIGIN OVERSEAS_VERSION
#define FIRMWARE_ORIGIN DOMESTIC_VERSION
//禁止修改行指定特殊固件
#define SPECIAL_VERSION SPECIAL_NORMAL
... ...
... ... @@ -58,8 +58,10 @@ int PCM_PooL_Interface_PcmData(struct AudioDealInfo *AD_Info,unsigned int in_sam
}
//重采样 //仅处理一半样本量
//void *resampledData = FF_Resample_Send_And_Get_ResampleData(AD_Info, &data, dealLen/2, &out_nb_samples);
void *resampledData = FF_Resample_Send_And_Get_ResampleData(AD_Info, &data, dealLen, &out_nb_samples);
void *resampledData = FF_Resample_Send_And_Get_ResampleData(AD_Info, &data, dealLen/2, &out_nb_samples);
//void *resampledData = FF_Resample_Send_And_Get_ResampleData(AD_Info, &data, dealLen, &out_nb_samples);
//JZSDK_LOG_INFO("播放 %d 数据",out_nb_samples
//如果滤波打开
//滤波处理
... ...
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "JZsdkLib.h"
T_JZsdkReturnCode PcmNoiseReduction(unsigned char *data, int len, int threshold)
{
for (int i = 0; i < len; i++)
{
if (abs(data) >= 0xFF)
{
data[i] = 0;
}
}
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
... ...
... ... @@ -152,8 +152,6 @@ void *FF_Resample_Send_And_Get_ResampleData(struct AudioDealInfo *AD_Info, unsig
return NULL;
}
JZSDK_LOG_INFO("原长度 *out_nb_samples:%d",*out_nb_samples);
//重采样
ret = swr_convert(ResampleInfo->m_swr, &dst, *out_nb_samples, (const uint8_t**)src, nb_samples);
if (ret < 0) {
... ... @@ -162,8 +160,6 @@ void *FF_Resample_Send_And_Get_ResampleData(struct AudioDealInfo *AD_Info, unsig
return NULL;
}
JZSDK_LOG_INFO("重采样后长度:%d", ret);
*out_nb_samples = ret;
return (void*)dst;
... ...
... ... @@ -159,7 +159,7 @@ T_JZsdkReturnCode IRC_SPC_ParamCorrect(struct IRC_param *dealInfo, U16_t *MarkDa
}
}
JZSDK_LOG_INFO("重新计算IPC参数 Avg%f",Avg);
//JZSDK_LOG_INFO("重新计算IPC参数 Avg%f",Avg);
}
... ...
... ... @@ -260,10 +260,10 @@ static T_JZsdkReturnCode IRC_Postdeal(unsigned char *rgb_data, struct IRC_param
//修复上边
for (x = 2; x <= dealInfo->Width - 2; x++)
{
int SourceIndex = Get_2DImage_PointToArray(x, 3, dealInfo->Width, dealInfo->Height);
int SourceIndex = Get_2DImage_PointToArray(x, 3, dealInfo->Width, dealInfo->Height) * 3;
int FirstIndex = Get_2DImage_PointToArray(x, 0, dealInfo->Width, dealInfo->Height);
int SecondIndex = Get_2DImage_PointToArray(x, 1, dealInfo->Width, dealInfo->Height);
int FirstIndex = Get_2DImage_PointToArray(x, 0, dealInfo->Width, dealInfo->Height) * 3;
int SecondIndex = Get_2DImage_PointToArray(x, 1, dealInfo->Width, dealInfo->Height) * 3;
rgb_data[FirstIndex] = rgb_data[SourceIndex];
rgb_data[FirstIndex + 1] = rgb_data[SourceIndex + 1];
... ... @@ -277,10 +277,10 @@ static T_JZsdkReturnCode IRC_Postdeal(unsigned char *rgb_data, struct IRC_param
//修复下边
for (x = 2; x <= dealInfo->Width - 2; x++)
{
int SourceIndex = Get_2DImage_PointToArray(x, dealInfo->Height - 3, dealInfo->Width, dealInfo->Height);
int SourceIndex = Get_2DImage_PointToArray(x, dealInfo->Height - 3, dealInfo->Width, dealInfo->Height) * 3;
int FirstIndex = Get_2DImage_PointToArray(x, dealInfo->Height - 1, dealInfo->Width, dealInfo->Height);
int SecondIndex = Get_2DImage_PointToArray(x, dealInfo->Height - 2, dealInfo->Width, dealInfo->Height);
int FirstIndex = Get_2DImage_PointToArray(x, dealInfo->Height - 1, dealInfo->Width, dealInfo->Height) * 3;
int SecondIndex = Get_2DImage_PointToArray(x, dealInfo->Height - 2, dealInfo->Width, dealInfo->Height) * 3;
rgb_data[FirstIndex] = rgb_data[SourceIndex];
rgb_data[FirstIndex + 1] = rgb_data[SourceIndex + 1];
... ... @@ -292,12 +292,13 @@ static T_JZsdkReturnCode IRC_Postdeal(unsigned char *rgb_data, struct IRC_param
}
//修复左边
for (int y = 0; y <= dealInfo->Height; y++)
for (int y = 0; y < dealInfo->Height; y++)
{
int SourceIndex = Get_2DImage_PointToArray(2, y, dealInfo->Width, dealInfo->Height);
int SourceIndex = Get_2DImage_PointToArray(3, y, dealInfo->Width, dealInfo->Height) * 3;
int FirstIndex = Get_2DImage_PointToArray(0, y, dealInfo->Width, dealInfo->Height);
int SecondIndex = Get_2DImage_PointToArray(1, y, dealInfo->Width, dealInfo->Height);
int FirstIndex = Get_2DImage_PointToArray(0, y, dealInfo->Width, dealInfo->Height) * 3;
int SecondIndex = Get_2DImage_PointToArray(1, y, dealInfo->Width, dealInfo->Height) * 3;
int ThirdIndex = Get_2DImage_PointToArray(2, y, dealInfo->Width, dealInfo->Height) * 3;
rgb_data[FirstIndex] = rgb_data[SourceIndex];
rgb_data[FirstIndex + 1] = rgb_data[SourceIndex + 1];
... ... @@ -306,14 +307,24 @@ static T_JZsdkReturnCode IRC_Postdeal(unsigned char *rgb_data, struct IRC_param
rgb_data[SecondIndex] = rgb_data[SourceIndex];
rgb_data[SecondIndex + 1] = rgb_data[SourceIndex + 1];
rgb_data[SecondIndex + 2] = rgb_data[SourceIndex + 2];
rgb_data[ThirdIndex] = rgb_data[SourceIndex];
rgb_data[ThirdIndex + 1] = rgb_data[SourceIndex + 1];
rgb_data[ThirdIndex + 2] = rgb_data[SourceIndex + 2];
}
//修复右边
for (int y = 0; y <= dealInfo->Height; y++)
// 修复右边
for (int y = 0; y < dealInfo->Height; y++)
{
int SourceIndex = Get_2DImage_PointToArray(dealInfo->Width - 3, y, dealInfo->Width, dealInfo->Height);
int FirstIndex = Get_2DImage_PointToArray(dealInfo->Width - 1, y, dealInfo->Width, dealInfo->Height);
int SecondIndex = Get_2DImage_PointToArray(dealInfo->Width - 2, y, dealInfo->Width, dealInfo->Height);
int SourceIndex = Get_2DImage_PointToArray(dealInfo->Width - 7, y, dealInfo->Width, dealInfo->Height) * 3;
int FirstIndex = Get_2DImage_PointToArray(dealInfo->Width - 1, y, dealInfo->Width, dealInfo->Height) * 3;
int SecondIndex = Get_2DImage_PointToArray(dealInfo->Width - 2, y, dealInfo->Width, dealInfo->Height) * 3;
int ThirdIndex = Get_2DImage_PointToArray(dealInfo->Width - 3, y, dealInfo->Width, dealInfo->Height) * 3;
int FourthIndex = Get_2DImage_PointToArray(dealInfo->Width - 4, y, dealInfo->Width, dealInfo->Height) * 3;
int FifthIndex = Get_2DImage_PointToArray(dealInfo->Width - 5, y, dealInfo->Width, dealInfo->Height) * 3;
int SixthIndex = Get_2DImage_PointToArray(dealInfo->Width - 6, y, dealInfo->Width, dealInfo->Height) * 3;
int SeventhIndex = Get_2DImage_PointToArray(dealInfo->Width - 7, y, dealInfo->Width, dealInfo->Height) * 3;
rgb_data[FirstIndex] = rgb_data[SourceIndex];
rgb_data[FirstIndex + 1] = rgb_data[SourceIndex + 1];
... ... @@ -322,44 +333,66 @@ static T_JZsdkReturnCode IRC_Postdeal(unsigned char *rgb_data, struct IRC_param
rgb_data[SecondIndex] = rgb_data[SourceIndex];
rgb_data[SecondIndex + 1] = rgb_data[SourceIndex + 1];
rgb_data[SecondIndex + 2] = rgb_data[SourceIndex + 2];
}
}
// 在rgb图上画图形
rgb_data[ThirdIndex] = rgb_data[SourceIndex];
rgb_data[ThirdIndex + 1] = rgb_data[SourceIndex + 1];
rgb_data[ThirdIndex + 2] = rgb_data[SourceIndex + 2];
//不画
if (dealInfo->RegionMode == 0)
{
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
rgb_data[FourthIndex] = rgb_data[SourceIndex];
rgb_data[FourthIndex + 1] = rgb_data[SourceIndex + 1];
rgb_data[FourthIndex + 2] = rgb_data[SourceIndex + 2];
//画十字
if (dealInfo->RegionMode == 1)
{
Stream_rgb888_WriteCross(rgb_data,
dealInfo->Width, dealInfo->Height,
dealInfo->RegionBox[0],
dealInfo->RegionBox[1],
255, 215, 0, 20, 20);
rgb_data[FifthIndex] = rgb_data[SourceIndex];
rgb_data[FifthIndex + 1] = rgb_data[SourceIndex + 1];
rgb_data[FifthIndex + 2] = rgb_data[SourceIndex + 2];
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
//画十字
if (dealInfo->RegionMode == 2)
{
Stream_rgb888_WriteRectangle(rgb_data,
dealInfo->Width, dealInfo->Height,
dealInfo->RegionBox[0],
dealInfo->RegionBox[1],
dealInfo->RegionBox[2],
dealInfo->RegionBox[3],
255, 215, 0, 1);
rgb_data[SixthIndex] = rgb_data[SourceIndex];
rgb_data[SixthIndex + 1] = rgb_data[SourceIndex + 1];
rgb_data[SixthIndex + 2] = rgb_data[SourceIndex + 2];
rgb_data[SeventhIndex] = rgb_data[SourceIndex];
rgb_data[SeventhIndex + 1] = rgb_data[SourceIndex + 1];
rgb_data[SeventhIndex + 2] = rgb_data[SourceIndex + 2];
}
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
// 在rgb图上画图形
// //不画
// if (dealInfo->RegionMode == 0)
// {
// return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
// }
// //画十字
// if (dealInfo->RegionMode == 1)
// {
// Stream_rgb888_WriteCross(rgb_data,
// dealInfo->Width, dealInfo->Height,
// dealInfo->RegionBox[0],
// dealInfo->RegionBox[1],
// 255, 215, 0, 20, 20);
// return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
// }
// //画十字
// if (dealInfo->RegionMode == 2)
// {
// Stream_rgb888_WriteRectangle(rgb_data,
// dealInfo->Width, dealInfo->Height,
// dealInfo->RegionBox[0],
// dealInfo->RegionBox[1],
// dealInfo->RegionBox[2],
// dealInfo->RegionBox[3],
// 255, 215, 0, 1);
// return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
// }
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
... ...
... ... @@ -419,10 +419,14 @@ static T_JZsdkReturnCode Opus_Decode()
//解码完成
printf("decode data to file: %d\r\n", frame_size * OPUS_CHANNELS);
/* Convert to little-endian ordering. */
for (i = 0; i < OPUS_CHANNELS * frame_size; i++) {
for (i = 0; i < OPUS_CHANNELS * frame_size; i++)
{
pcm_bytes[2 * i] = out[i] & 0xFF;
pcm_bytes[2 * i + 1] = (out[i] >> 8) & 0xFF;
}
//PcmNoiseReduction(pcm_bytes, frame_size*2 , 1) ;
//保存解码内容
fwrite(pcm_bytes, sizeof(short), frame_size * OPUS_CHANNELS, fout);
... ...
... ... @@ -284,9 +284,20 @@ static void *DecodeAudioData_task(void *arg)
USER_LOG_INFO("decode data to file: %d\r\n", frame_size * WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS);
/* Convert to little-endian ordering. */
for (i = 0; i < WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS * frame_size; i++) {
if (out[i] == 0xFFFF)
{
pcm_bytes[2 * i] = 0x00;
pcm_bytes[2 * i + 1] = 0x00;
continue;
}
pcm_bytes[2 * i] = out[i] & 0xFF;
pcm_bytes[2 * i + 1] = (out[i] >> 8) & 0xFF;
}
/* Write the decoded audio to file. */
fwrite(pcm_bytes, sizeof(short), frame_size * WIDGET_SPEAKER_AUDIO_OPUS_CHANNELS, fout);
}
... ...
# cmake 最低版本要求 第三行名字不能动
cmake_minimum_required(VERSION 2.8)
project(JZ_C1)
project(JZ_H1T)
set(CMAKE_C_FLAGS "-pthread -std=gnu99 -lm -ldl -lstdc++")
#"-pthread":指定在编译时链接POSIX线程库,以支持多线程程序。
... ...