Buffer overflow fixes
This commit is contained in:
parent
828d168869
commit
4f4c1784b8
2 changed files with 17 additions and 11 deletions
|
@ -238,23 +238,29 @@ const char* TS::Packet::ToString(){
|
|||
/// Generates a PES Lead-in for a video frame.
|
||||
/// Starts at the first Free byte.
|
||||
/// \param NewLen The length of this video frame.
|
||||
void TS::Packet::PESVideoLeadIn(int NewLen, long long unsigned int PTS){
|
||||
NewLen += (PTS == 1 ? 9 : 14);
|
||||
void TS::Packet::PESVideoLeadIn(unsigned int NewLen, long long unsigned int PTS){
|
||||
//NewLen += (PTS == 1 ? 9 : 19);
|
||||
NewLen = 0;
|
||||
strBuf += (char)0x00; //PacketStartCodePrefix
|
||||
strBuf += (char)0x00; //PacketStartCodePrefix (Cont)
|
||||
strBuf += (char)0x01; //PacketStartCodePrefix (Cont)
|
||||
strBuf += (char)0xe0; //StreamType Video
|
||||
strBuf += (char)((NewLen & 0xFF00) >> 8); //PES PacketLength
|
||||
strBuf += (char)(NewLen & 0x00FF); //PES PacketLength (Cont)
|
||||
strBuf += (char)0x80; //Reserved + Flags
|
||||
strBuf += (char)0x84; //Reserved + Flags
|
||||
if (PTS != 1){
|
||||
strBuf += (char)0x80; //PTSOnlyFlag + Flags
|
||||
strBuf += (char)0x05; //PESHeaderDataLength
|
||||
strBuf += (char)(0x20 + ((PTS & 0x1C0000000LL) >> 29) + 1); //PTS
|
||||
strBuf += (char)0xC0; //PTSOnlyFlag + Flags
|
||||
strBuf += (char)0x0A; //PESHeaderDataLength
|
||||
strBuf += (char)(0x30 + ((PTS & 0x1C0000000LL) >> 29) + 1); //Fixed + PTS
|
||||
strBuf += (char)((PTS & 0x03FC00000LL) >> 22); //PTS (Cont)
|
||||
strBuf += (char)(((PTS & 0x0003F8000LL) >> 14) + 1); //PTS (Cont)
|
||||
strBuf += (char)((PTS & 0x000007F80LL) >> 7); //PTS (Cont)
|
||||
strBuf += (char)(((PTS & 0x00000007FLL) << 1) + 1); //PTS (Cont)
|
||||
strBuf += (char)(0x10 + ((PTS & 0x1C0000000LL) >> 29) + 1); //Fixed + DTS
|
||||
strBuf += (char)((PTS & 0x03FC00000LL) >> 22); //DTS (Cont)
|
||||
strBuf += (char)(((PTS & 0x0003F8000LL) >> 14) + 1); //DTS (Cont)
|
||||
strBuf += (char)((PTS & 0x000007F80LL) >> 7); //DTS (Cont)
|
||||
strBuf += (char)(((PTS & 0x00000007FLL) << 1) + 1); //DTS (Cont)
|
||||
}else{
|
||||
strBuf += (char)0x00; //PTSOnlyFlag + Flags
|
||||
strBuf += (char)0x00; //PESHeaderDataLength
|
||||
|
@ -273,7 +279,7 @@ void TS::Packet::PESVideoLeadIn(int NewLen, long long unsigned int PTS){
|
|||
/// Starts at the first Free byte.
|
||||
/// \param NewLen The length of this audio frame.
|
||||
/// \param PTS The timestamp of the audio frame.
|
||||
void TS::Packet::PESAudioLeadIn(int NewLen, uint64_t PTS){
|
||||
void TS::Packet::PESAudioLeadIn(unsigned int NewLen, uint64_t PTS){
|
||||
NewLen += 8;
|
||||
strBuf += (char)0x00; //PacketStartCodePrefix
|
||||
strBuf += (char)0x00; //PacketStartCodePrefix (Cont)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
#include <stdint.h> //for uint64_t
|
||||
#include <stdint.h>//for uint64_t
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
@ -40,8 +40,8 @@ namespace TS {
|
|||
|
||||
void Print();
|
||||
const char* ToString();
|
||||
void PESVideoLeadIn(int NewLen, long long unsigned int PTS = 1);
|
||||
void PESAudioLeadIn(int NewLen, uint64_t PTS = 0);
|
||||
void PESVideoLeadIn(unsigned int NewLen, long long unsigned int PTS = 1);
|
||||
void PESAudioLeadIn(unsigned int NewLen, uint64_t PTS = 0);
|
||||
void FillFree(std::string & PackageData);
|
||||
int FillFree(const char* PackageData, int maxLen);
|
||||
void AddStuffing(int NumBytes);
|
||||
|
@ -62,7 +62,7 @@ namespace TS {
|
|||
StandardHeader[2] = ((((initData[0] >> 3) - 1) << 6) & 0xC0); //AAC Profile - 1 ( First two bits )
|
||||
StandardHeader[2] |= ((((initData[0] & 0x07) << 1) | ((initData[1] >> 7) & 0x01)) << 2); //AAC Frequency Index
|
||||
StandardHeader[2] |= ((initData[1] & 0x20) >> 5); //AAC Channel Config
|
||||
StandardHeader[3] = ((initData[1] & 0x18) << 3); //AAC CHannel Config (cont.)
|
||||
StandardHeader[3] = ((initData[1] & 0x18) << 3); //AAC Channel Config (cont.)
|
||||
StandardHeader[3] |= ((FrameLen & 0x00001800) >> 11);
|
||||
StandardHeader[4] = ((FrameLen & 0x000007F8) >> 3);
|
||||
StandardHeader[5] |= ((FrameLen & 0x00000007) << 5);
|
||||
|
|
Loading…
Add table
Reference in a new issue