应对oom,使用静态分配的内存,降低码率

master
a74589669 2019-09-29 00:55:18 +08:00
parent ab30a63304
commit c3baada6e9
2 changed files with 18 additions and 11 deletions

View File

@ -328,8 +328,14 @@ HI_S32 SAMPLE_COMM_VENC_SaveH264(FILE* fpH264File, VENC_STREAM_S *pstStream)
printf("pslice ");
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_PPS)
printf("pps ");
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_ISLICE)
printf("islice ");
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_ISLICE) {
printf("islice ");
int packCnt = Pack264AndSend(
pstStream->pstPack[i].pu8Addr + pstStream->pstPack[i].u32Offset
,pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset
, gRtspclient);
}
if(pstStream->pstPack[i].DataType.enH264EType == H264E_NALU_SEI) {
printf("sei ");
}
@ -341,11 +347,11 @@ HI_S32 SAMPLE_COMM_VENC_SaveH264(FILE* fpH264File, VENC_STREAM_S *pstStream)
fwrite(pstStream->pstPack[i].pu8Addr + pstStream->pstPack[i].u32Offset ,
pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset, 1, fpH264File);
unsigned char *p = pstStream->pstPack[i].pu8Addr;
printf("h264 header file %d length %d nal count %d offset %x %x %x %x %x %x %x %x\r\n",
/*printf("h264 header file %d length %d nal count %d offset %x %x %x %x %x %x %x %x\r\n",
pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset,
i,
pstStream->pstPack[i].u32Offset,
p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]);
p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7]); */
int packCnt = Pack264AndSend(
pstStream->pstPack[i].pu8Addr + pstStream->pstPack[i].u32Offset
,pstStream->pstPack[i].u32Len - pstStream->pstPack[i].u32Offset
@ -537,13 +543,13 @@ HI_S32 SAMPLE_COMM_VENC_Start(VENC_CHN VencChn, PAYLOAD_TYPE_E enType,
switch (enSize)
{
case PIC_QCIF:
stH264Cbr.u32BitRate = 80; /* average bit rate */
stH264Cbr.u32BitRate = 50; /* average bit rate */
break;
case PIC_QVGA: /* 320 * 240 */
stH264Cbr.u32BitRate = 80;
stH264Cbr.u32BitRate = 50;
case PIC_CIF:
stH264Cbr.u32BitRate = 80;
stH264Cbr.u32BitRate = 50;
break;
case PIC_D1:

View File

@ -124,19 +124,20 @@ int Pack264(unsigned char *frame,int size, Vector **outbuf){
}
}
char *sendBuf = 0;
int Pack264AndSend(unsigned char *frame,int size,RtspClient * p){
int i = 0;
static short seq = 0;
char *sendBuf;
int sendLength = 0;
int length = MAX_RTP_LEN + sizeof(CH264NalUnit) + sizeof(CRtpHeader)
+ sizeof(RtspInterleavedFrameHeader);
if(0 == frame || NULL == p) {
return 0;
}
sendBuf = malloc(MAX_RTP_LEN + sizeof(CH264NalUnit) + sizeof(CRtpHeader)
+ sizeof(RtspInterleavedFrameHeader));
if( 0 == sendBuf)
sendBuf = malloc(MAX_RTP_LEN + sizeof(CH264NalUnit) + sizeof(CRtpHeader)
+ sizeof(RtspInterleavedFrameHeader));
// fill rtsp interleaved header
RtspInterleavedFrameHeader rtspInterleavedFrameHeader;
rtspInterleavedFrameHeader.magic = 0x24;
@ -239,7 +240,7 @@ int Pack264AndSend(unsigned char *frame,int size,RtspClient * p){
SendRtpPackage(p,sendBuf,sendLength);
}
}
free(sendBuf);
// free(sendBuf);
return packCnt;
}