+#include <fstream>
#include "Utils.h"
namespace TsRemux
return array;
}
-void Utility::ToArray(std::vector<byte>& vctr, byte* str)
+void Utility::AddRange(std::vector<byte>& vctr, const byte* str)
{
for(int i = 0; i < sizeof(str); i++)
vctr.push_back(str[i]);
}
-void Utility::AddRange(std::vector<byte>& new_vctr, std::vector<byte>& old_vctr)
+void Utility::AddRange(std::vector<byte>& vctr, const pByte str)
{
- for(std::vector<byte>::iterator it = old_vctr.begin(); it < old_vctr.end(); it++)
- new_vctr.push_back(*it);
+ for(int i = 0; i < sizeof(str.get()); i++)
+ vctr.push_back(str[i]);
+}
+
+void Utility::AddRange(std::vector<byte>& new_vctr, const std::vector<byte>& old_vctr)
+{
+ for(int i = 0; i < old_vctr.size(); i++)
+ new_vctr.push_back(old_vctr.at(i));
}
const int DATA_HEADER = 5;
}
// implement class PmPacket : TsTable
-PmPacket::PmPacket(void)
+PmtPacket::PmtPacket(void)
{
// table id = 02
SetTableId(Constants::PMT_TABLE_ID);
RefreshCrc();
}
-PmPacket::PmPacket(pByte data)throw(std::invalid_argument)
+PmtPacket::PmtPacket(pByte data)throw(std::invalid_argument)
{
if (GetTableId() != Constants::PMT_TABLE_ID)
throw std::invalid_argument("packet does not contain a valid PMT table ID");
}
-DTCP_Descriptor PmPacket::GetDtcpInfo(void)
+boost::shared_array<DTCP_Descriptor> PmtPacket::GetDtcpInfo(void)
{
pByte descriptors = GetProgramDescriptorsData();
+ boost::shared_array<DTCP_Descriptor> dt;
if (!descriptors)
- return reinterpret_cast<DTCP_Descriptor>(NULL);
- DTCP_Descriptor dt = NULL;
+ return dt;
for (int i = 0; i < sizeof(descriptors.get()); )
{
try
{
- dt = new DTCP_Descriptor(descriptors, i);
+ dt = boost::shared_array<DTCP_Descriptor>(new DTCP_Descriptor(descriptors, i));
break;
}
catch (std::invalid_argument)
return dt;
}
-pByte PmPacket::GetProgramDescriptorsData(void)
+pByte PmtPacket::GetProgramDescriptorsData(void)
{
+ pByte descriptors;
if (GetProgramDescriptorsLength() == 0)
- return NULL;
- pByte descriptors = pByte(new byte[GetProgramDescriptorsLength()]);
+ return descriptors;
+ descriptors = pByte(new byte[GetProgramDescriptorsLength()]);
for (int i = 0; i < sizeof(descriptors.get()); i++)
{
descriptors[i] = mData[i + 17 + GetPointerSize()];
return descriptors;
}
-void PmPacket::SetProgramDescriptorsData(pByte value)
+void PmtPacket::SetProgramDescriptorsData(pByte value)
{
if (!value || 0 == sizeof(value.get()))
{
RefreshCrc();
}
}
+ushort PmtPacket::GetProgramNumber(void)
+{
+ return GetNumberId();
+}
+
+void PmtPacket::SetProgramNumber(ushort id)
+{
+ SetNumberId(id);
+ return;
+}
+
+ushort PmtPacket::GetPcrPID(void)
+{
+ return PcrPID;
+}
+
+void PmtPacket::SetPcrPID(ushort pid)
+{
+ PcrPID = pid;
+ return;
+}
+
+ushort PmtPacket::GetProgramDescriptorsLength(void)
+{
+ return (ushort)(((mData[15 + GetPointerSize()] & 0x0f) << 8) + mData[16 + GetPointerSize()]);
+}
+
+void PmtPacket::SetProgramDescriptorsLength(ushort value)
+{
+ mData[15 + GetPointerSize()] = (byte)(0xf0 | (byte)((value >> 8) & 0x0f));
+ mData[16 + GetPointerSize()] = (byte)(value & 0xff);
+}
+
+ushort PmtPacket::GetStreamInfoLength(void)
+{
+ return (ushort)(GetLength() - 13 - GetProgramDescriptorsLength());
+}
// implement class BluRayOutput
BluRayOutput::BluRayOutput(std::string arg_path, TimeSpan arg_chapterLen)
{
+/** not modefied
path = arg_path;
chapterLen = arg_chapterLen;
boost::filesystem::path full_path(boost::filesystem::initial_path<boost::filesystem::path>());
boost::filesystem::create_directory(full_path / "CERTIFICATE");
boost::filesystem::create_directory(full_path / "CERTIFICATE" / "BACKUP");
- boost::filesystem::ofstream file_index_bdmv(full_path / "BDMV/index.bdmv");
+ std::ofstream file_index_bdmv(full_path / "BDMV/index.bdmv");
file_index_bdmv << index_bdmv;
- boost::filesystem::ofstream file_index_bdmv_backup(full_path / "BDMV/BACKUP/index.bdmv");
+ std::ofstream file_index_bdmv_backup(full_path / "BDMV/BACKUP/index.bdmv");
file_index_bdmv_backup << index_bdmv;
- boost::filesystem::ofstream file_movieobject_bdmv(full_path / "BDMV/MovieObject.bdmv");
+ std::ofstream file_movieobject_bdmv(full_path / "BDMV/MovieObject.bdmv");
file_movieobject_bdmv << MovieObject_bdmv;
- boost::filesystem::ofstream file_movieobject_bdmv_backup(full_path / "BDMV/BACKUP/MovieObject.bdmv");
+ std::ofstream file_movieobject_bdmv_backup(full_path / "BDMV/BACKUP/MovieObject.bdmv");
file_movieobject_bdmv_backup << MovieObject_bdmv;
+**/
}
-/** not modefied
-void BluRayOutput::Author(EpElement* EpInfo, StreamInfo* sis, UInt32 numOfSourcePackets)
+void BluRayOutput::Author(std::vector<EpElement>& EpInfo, std::vector<StreamInfo>& sis, UInt32 numOfSourcePackets)
{
+/**
List<ushort> Pids = new List<ushort>();
List<byte[]> StreamCodingInfos = new List<byte[]>();
List<byte[]> AudioEntries = new List<byte[]>();
byte[] clpi = Build_clpi(ClipInfo, SequenceInfo, ProgramInf, CPI);
File.WriteAllBytes(Path.Combine(path, @"BDMV\CLIPINF\00001.clpi"), clpi);
File.Copy(Path.Combine(path, @"BDMV\CLIPINF\00001.clpi"), Path.Combine(path, @"BDMV\BACKUP\CLIPINF\00001.clpi"),true);
-}
**/
+}
pByte BluRayOutput::BuildStreamEntry(ushort pid)
{
- pByte StreamEntry = pByte(new byte[10] {
- 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
+ byte entry[] = {
+ 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ pByte StreamEntry = pByte(entry);
StreamEntry[2] = (byte)((pid >> 8) & 0xff);
StreamEntry[3] = (byte)(pid & 0xff);
return StreamEntry;
pByte BluRayOutput::BuildVideoStreamAttributes(byte type, VideoFormat vf, FrameRate fr)
throw(std::invalid_argument)
{
- if (type != reinterpret_cast<byte>VIDEO_STREAM_VC1
- && type != repreinterpret_cast<byte>VIDEO_STREAM_MPEG2
- && type != reinterpret_cast<byte>VIDEO_STREAM_H264)
+ if (type != (byte)VIDEO_STREAM_VC1
+ && type != (byte)VIDEO_STREAM_MPEG2
+ && type != (byte)VIDEO_STREAM_H264)
throw std::invalid_argument("Video stream of type is not supported by Blu Ray");
pByte attributes = pByte(new byte[6]);
attributes[0] = 0x05;
pByte BluRayOutput::BuildAudioStreamAttributes(byte type, AudioPresentationType vf, SamplingFrequency fr)
throw(std::invalid_argument)
{
- if (type != reinterpret_cast<byte>AUDIO_STREAM_AC3
- && type != reiterpret_cast<byte>AUDIO_STREAM_AC3_PLUS
- && type != reiterpret_cast<byte>AUDIO_STREAM_AC3_TRUE_HD
- && type != reiterpret_cast<byte>AUDIO_STREAM_DTS
- && type != reiterpret_cast<byte>AUDIO_STREAM_DTS_HD
- && type != reiterpret_cast<byte>AUDIO_STREAM_DTS_HD_MASTER_AUDIO
- && type != reiterpret_cast<byte>AUDIO_STREAM_LPCM)
+ if (type != (byte)AUDIO_STREAM_AC3
+ && type != (byte)AUDIO_STREAM_AC3_PLUS
+ && type != (byte)AUDIO_STREAM_AC3_TRUE_HD
+ && type != (byte)AUDIO_STREAM_DTS
+ && type != (byte)AUDIO_STREAM_DTS_HD
+ && type != (byte)AUDIO_STREAM_DTS_HD_MASTER_AUDIO
+ && type != (byte)AUDIO_STREAM_LPCM)
throw std::invalid_argument("Audio stream of type is not supported by Blu Ray");
pByte attributes = pByte(new byte[6]);
attributes[0] = 0x05;
return attributes;
}
-/** not modefied
-pByte BluRayOutput::BuildStnTable(pByte VideoEntry, pByte VideoAttributes, byte[][] AudioEntries, byte[][] AudioAttributes, byte[][] PgEntries, byte[][] PgAttributes)
-{
- List<byte> table = new List<byte>();
- List<byte> temp = new List<byte>();
- table.Add(0x00);
- table.Add(0x00);
- table.Add(0x01);
- if (AudioEntries.Length > 0)
- table.Add((byte)AudioEntries.Length);
- else
- table.Add(0x00);
- if (PgEntries.Length > 0)
- table.Add((byte)PgEntries.Length);
- else
- table.Add(0x00);
- for (int i = 0; i < 9; i++)
- table.Add(0x00);
- table.AddRange(VideoEntry);
- table.AddRange(VideoAttributes);
- for (int i = 0; i < AudioEntries.Length; i++)
- {
- table.AddRange(AudioEntries[i]);
- table.AddRange(AudioAttributes[i]);
- }
- for (int i = 0; i < PgEntries.Length; i++)
- {
- table.AddRange(PgEntries[i]);
- table.AddRange(PgAttributes[i]);
- }
- UInt32 len = (UInt32)table.Count;
- temp.Add((byte)((len >> 8) & 0xff));
- temp.Add((byte)(len & 0xff));
- temp.AddRange(table);
- return temp.ToString();
+pByte BluRayOutput::BuildStnTable(pByte VideoEntry, pByte VideoAttributes,
+ std::vector<pByte>& AudioEntries, std::vector<pByte>& AudioAttributes,
+ std::vector<pByte>& PgEntries, std::vector<pByte>& PgAttributes)
+{
+ std::vector<byte> table;
+ std::vector<byte> temp;
+ table.push_back(0x00);
+ table.push_back(0x00);
+ table.push_back(0x01);
+ if (AudioEntries.size() > 0)
+ table.push_back((byte)AudioEntries.size());
+ else
+ table.push_back(0x00);
+ if (PgEntries.size() > 0)
+ table.push_back((byte)PgEntries.size());
+ else
+ table.push_back(0x00);
+ for (int i = 0; i < 9; i++)
+ table.push_back(0x00);
+ Utility::AddRange(table, VideoEntry);
+ Utility::AddRange(table, VideoAttributes);
+ for (int i = 0; i < AudioEntries.size(); i++)
+ {
+ Utility::AddRange(table, AudioEntries.at(i));
+ Utility::AddRange(table, AudioAttributes.at(i));
+ }
+ for (int i = 0; i < PgEntries.size(); i++)
+ {
+ Utility::AddRange(table, PgEntries.at(i));
+ Utility::AddRange(table, PgAttributes.at(i));
+ }
+ UInt32 len = (UInt32)table.size();
+ temp.push_back((byte)((len >> 8) & 0xff));
+ temp.push_back((byte)(len & 0xff));
+ Utility::AddRange(temp, table);
+ return Utility::ToString(temp);
}
pByte BluRayOutput:: UintToByteArraryNetwork(UInt32 value)
{
pByte ret = pByte(new byte[4]);
- ret[0] = reinterpret_cast<byte>((value >> 24) & 0xff);
- ret[1] = reinterpret_cast<byte>((value >> 16) & 0xff);
- ret[2] = reinterpret_cast<byte>((value >> 8) & 0xff);
- ret[3] = reinterpret_cast<byte>(value & 0xff);
+ ret[0] = (byte)((value >> 24) & 0xff);
+ ret[1] = (byte)((value >> 16) & 0xff);
+ ret[2] = (byte)((value >> 8) & 0xff);
+ ret[3] = (byte)(value & 0xff);
return ret;
}
Utility::AddRange(mlps, PlayList_00000_mpls);
UInt32 temp = sizeof(AppInfoPlayList);
temp += 40;
- Utility::AddRange(mlps, UintToByteArraryNetwork(temp).get());
- temp += (UInt32)PlayList.Length;
- Utility::AddRange(mlps, UintToByteArraryNetwork(temp).get());
+ Utility::AddRange(mlps, UintToByteArraryNetwork(temp));
+ temp += sizeof(PlayList.get());
+ Utility::AddRange(mlps, UintToByteArraryNetwork(temp));
for (int i = 0; i < 24; i++)
mlps.push_back(0x00);
Utility::AddRange(mlps, AppInfoPlayList);
return Utility::ToString(mlps);
}
-pByte BluRayOutput::BuildPlayList(pByte PlayItems)
+pByte BluRayOutput::BuildPlayList(std::vector<pByte> PlayItems)
{
std::vector<byte> playList;
- UInt32 playItemNum = sizeof(PlayItems.get());
+ UInt32 playItemNum = PlayItems.size();
playItemNum <<= 16;
playItemNum &= 0xffff0000;
- UInt32 len = sizeof(PlayItems.get()) + 6;
- Utility::AddRange(playList, UintToByteArraryNetwork(len).get());
+ UInt32 len = PlayItems.size() + 6;
+ Utility::AddRange(playList, UintToByteArraryNetwork(len));
playList.push_back(0x00);
playList.push_back(0x00);
- Utility::AddRange(playList, UintToByteArraryNetwork(playItemNum)get());
- Utility::.AddRange(playList, PlayItems.get());
+ Utility::AddRange(playList, UintToByteArraryNetwork(playItemNum));
+ for (int i = 0; i < PlayItems.size(); i++)
+ Utility::AddRange(playList, PlayItems.at(i));
return Utility::ToString(playList);
}
playItem.push_back(0x00);
playItem.push_back(0x01);
playItem.push_back(stc_id);
- Utility::AddRange(playItem, UintToByteArraryNetwork(start).get());
- Utility::AddRange(playItem, UintToByteArraryNetwork(end).get());
+ Utility::AddRange(playItem, UintToByteArraryNetwork(start));
+ Utility::AddRange(playItem, UintToByteArraryNetwork(end));
for (int i = 0; i < 12; i++)
- playItem.Add(0x00);
- playItem.AddRange(StnTable);
- UInt32 len = (UInt32)playItem.Count;
- playTemp.Add((byte)((len >> 8) & 0xff));
- playTemp.Add((byte)(len & 0xff));
- playTemp.AddRange(playItem);
- return playTemp.ToString();
+ playItem.push_back(0x00);
+ Utility::AddRange(playItem, StnTable);
+ UInt32 len = (UInt32)playItem.size();
+ playTemp.push_back((byte)((len >> 8) & 0xff));
+ playTemp.push_back((byte)(len & 0xff));
+ Utility::AddRange(playTemp, playItem);
+ return Utility::ToString(playTemp);
}
pByte BluRayOutput::BuildFirstPlayMarks(UInt32 start, UInt32 end, UInt32 interval)
Utility::AddRange(clpi, ClipInfo_0000_clpi);
UInt32 len = 40;
len += sizeof(ClipInfo.get());
- Utility::AddRange(clpi, UintToByteArraryNetwork(len).get());
+ Utility::AddRange(clpi, UintToByteArraryNetwork(len));
len += sizeof(SequenceInfo.get());
- Utility::AddRange(clpi, UintToByteArraryNetwork(len).get());
+ Utility::AddRange(clpi, UintToByteArraryNetwork(len));
len += sizeof(ProgramInfo.get());
- Utility::AddRange(clpi, UintToByteArraryNetwork(len).get());
- len += (UInt32)CPI.Length;
- Utility::AddRange(clpi, UintToByteArraryNetwork(len).get());
+ Utility::AddRange(clpi, UintToByteArraryNetwork(len));
+ len += sizeof(CPI.get());
+ Utility::AddRange(clpi, UintToByteArraryNetwork(len));
for (int i = 0; i < 16; i++)
clpi.push_back(0x00);
Utility::AddRange(clpi, ClipInfo);
return Utility::ToString(clpi);
}
-pByte BluRayOutput::BuildClipInfo(UInt32 numOfSourcePackets, EpElement* EpInfo)
+pByte BluRayOutput::BuildClipInfo(UInt32 numOfSourcePackets, std::vector<EpElement> EpInfo)
{
std::vector<byte> clip;
std::vector<byte> temp;
clip.push_back(0x00);
clip.push_back(0x00);
clip.push_back(0x00);
- Int64 rate = EpInfo[sizeof(EpInfo)/sizeof(EpElement) - 1].spn_ - EpInfo[0].spn_;
+ Int64 rate = EpInfo.at(EpInfo.size() - 1).spn_ - EpInfo.at(0).spn_;
rate *= 192;
- rate /= ((EpInfo[sizeof(EpInfo)/sizeof(EpElement) - 1].PTS_ - EpInfo[0].pts_) / 90000);
+ rate /= ((EpInfo.at(EpInfo.size()- 1).pts_ - EpInfo.at(0).pts_) / 90000);
Utility::AddRange(clip, UintToByteArraryNetwork((UInt32)rate));
Utility::AddRange(clip, UintToByteArraryNetwork(numOfSourcePackets));
for (int i = 0; i < 128; i++)
clip.push_back(0x00);
Utility::AddRange(clip, TsTypeInfoBlock);
UInt32 len = (UInt32)clip.size();
- Utility::AddRange(temp, UintToByteArraryNetwork(len).get());
+ Utility::AddRange(temp, UintToByteArraryNetwork(len));
Utility::AddRange(temp, clip);
- return ToString(temp);
+ return Utility::ToString(temp);
}
pByte BluRayOutput::BuildSequenceInfo(UInt32 start, UInt32 end)
return Utility::ToString(temp);
}
-pByte BluRayOutput::BuildProgramInfo(ushort* pids, pByte StreamCodingInfos)
+pByte BluRayOutput::BuildProgramInfo(std::vector<ushort> pids, std::vector<pByte> StreamCodingInfos)
{
std::vector<byte> info;
std::vector<byte> temp;
info.push_back(0x00);
info.push_back((byte)((Constants::DEFAULT_PMT_PID >> 8) & 0xff));
info.push_back((byte)(Constants::DEFAULT_PMT_PID & 0xff));
- info.push_back((byte)sizeof(pids));
+ info.push_back((byte)pids.size());
info.push_back(0x00);
- for (int i = 0; i < sizeof(pids); i++)
+ for (int i = 0; i < pids.size(); i++)
{
- info.push_back((byte)((pids[i] >> 8) & 0xff));
- info.push_back((byte)(pids[i] & 0xff));
- Utility::AddRange(info, StreamCodingInfos[i]);
+ info.push_back((byte)((pids.at(i) >> 8) & 0xff));
+ info.push_back((byte)(pids.at(i) & 0xff));
+ Utility::AddRange(info, StreamCodingInfos.at(i));
}
UInt32 len = info.size();
- Utility::AddRange(temp, UintToByteArraryNetwork(len)get());
+ Utility::AddRange(temp, UintToByteArraryNetwork(len));
Utility::AddRange(temp, info);
return Utility::ToString(temp);
}
-byte[] BuildVideoStreamCodingInfo(ElementaryStreamTypes type, VideoFormat format, FrameRate rate, AspectRatio ratio)
+pByte BluRayOutput::BuildVideoStreamCodingInfo(
+ ElementaryStreamTypes type, VideoFormat format, FrameRate rate, AspectRatio ratio)
{
- List<byte> info = new List<byte>();
- info.Add(0x15);
- info.Add((byte)type);
- info.Add((byte)((((byte)format) << 4) | (byte)rate));
- info.Add((byte)(((byte)(ratio)) << 4));
- for(int i = 0; i < 18; i++)
- info.Add(0x00);
- return info.ToString();
+ std::vector<byte> info;
+ info.push_back(0x15);
+ info.push_back((byte)type);
+ info.push_back((byte)((((byte)format) << 4) | (byte)rate));
+ info.push_back((byte)(((byte)(ratio)) << 4));
+ for(int i = 0; i < 18; i++)
+ info.push_back(0x00);
+ return Utility::ToString(info);
}
-byte[] BuildAudioStreamCodingInfo(ElementaryStreamTypes type, AudioPresentationType format, SamplingFrequency rate)
+pByte BluRayOutput::BuildAudioStreamCodingInfo(
+ ElementaryStreamTypes type, AudioPresentationType format, SamplingFrequency rate)
{
- List<byte> info = new List<byte>();
- info.Add(0x15);
- info.Add((byte)type);
- info.Add((byte)((((byte)format) << 4) | (byte)rate));
- info.Add(0x65);
- info.Add(0x6e);
- info.Add(0x67);
- for (int i = 0; i < 16; i++)
- info.Add(0x00);
- return info.ToString();
+ std::vector<byte> info;
+ info.push_back(0x15);
+ info.push_back((byte)type);
+ info.push_back((byte)((((byte)format) << 4) | (byte)rate));
+ info.push_back(0x65);
+ info.push_back(0x6e);
+ info.push_back(0x67);
+ for (int i = 0; i < 16; i++)
+ info.push_back(0x00);
+ return Utility::ToString(info);
}
-byte[] BuildPgStreamCodingInfo()
+pByte BluRayOutput::BuildPgStreamCodingInfo(void)
{
- List<byte> info = new List<byte>();
- info.Add(0x15);
- info.Add(0x90);
- info.Add(0x65);
- info.Add(0x6e);
- info.Add(0x67);
- for (int i = 0; i < 17; i++)
- info.Add(0x00);
- return info.ToString();
+ std::vector<byte> info;
+ info.push_back(0x15);
+ info.push_back(0x90);
+ info.push_back(0x65);
+ info.push_back(0x6e);
+ info.push_back(0x67);
+ for (int i = 0; i < 17; i++)
+ info.push_back(0x00);
+ return Utility::ToString(info);
}
-byte[] BuildCpi(byte[] EpMap)
+pByte BluRayOutput::BuildCpi(pByte EpMap)
{
- List<byte> info = new List<byte>();
- UInt32 len = (UInt32)EpMap.Length + 2;
- info.AddRange(UintToByteArraryNetwork(len));
- info.Add(0x00);
- info.Add(0x01);
- info.AddRange(EpMap);
- return info.ToString();
+ std::vector<byte> info;
+ UInt32 len = sizeof(EpMap.get()) + 2;
+ Utility::AddRange(info, UintToByteArraryNetwork(len));
+ info.push_back(0x00);
+ info.push_back(0x01);
+ Utility::AddRange(info, EpMap);
+ return Utility::ToString(info);
}
-byte[] BuildEpMap(EpElement[] EpInfo)
+pByte BluRayOutput::BuildEpMap(std::vector<EpElement>& EpInfo)
{
- UInt32 lastepfine = 0x7ff;
- UInt32 lastspnfine = 0x1ffff;
- UInt32 numofcoarse = 0;
- List<byte> coarseloop = new List<byte>();
- List<byte> fineloop = new List<byte>(EpInfo.Length);
- List<byte> EpMap = new List<byte>();
-
- for (int i = 0; i < EpInfo.Length; i++)
- {
- UInt32 epfine = (UInt32)((EpInfo[i].PTS >> 9) % 0x800);
- UInt32 epcoarse = (UInt32)((EpInfo[i].PTS >> 19) % 0x4000);
- UInt32 spnfine = EpInfo[i].SPN % 0x20000;
- if (lastepfine > epfine || lastspnfine > spnfine)
- {
- UInt32 reftofine = (UInt32)i;
- reftofine <<= 14;
- reftofine |= epcoarse;
- coarseloop.AddRange(UintToByteArraryNetwork(reftofine));
- coarseloop.AddRange(UintToByteArraryNetwork(EpInfo[i].SPN));
- numofcoarse++;
- }
- UInt32 value = 0x1000;
- value |= (epfine << 17);
- value |= spnfine;
- fineloop.AddRange(UintToByteArraryNetwork(value));
- lastepfine = epfine;
- lastspnfine = spnfine;
- }
+ UInt32 lastepfine = 0x7ff;
+ UInt32 lastspnfine = 0x1ffff;
+ UInt32 numofcoarse = 0;
+ std::vector<byte> coarseloop;
+ std::vector<byte> fineloop;
+ std::vector<byte> EpMap;
- EpMap.Add(0x00);
- EpMap.Add(0x01);
- EpMap.Add((byte)((Constants.DEFAULT_VIDEO_PID >> 8) & 0xff));
- EpMap.Add((byte)(Constants.DEFAULT_VIDEO_PID & 0xff));
- EpMap.Add(0x00);
- byte btemp = 4;
- btemp |= (byte)((numofcoarse >> 14) & 0xff);
- EpMap.Add(btemp);
- btemp = (byte)((numofcoarse >> 6) & 0xff);
- EpMap.Add(btemp);
- btemp = (byte)((numofcoarse & 0x3f) << 2);
- btemp |= (byte)((EpInfo.Length >> 16) & 0x03);
- EpMap.Add(btemp);
- btemp = (byte)((EpInfo.Length >> 8) & 0xff);
- EpMap.Add(btemp);
- btemp = (byte)(EpInfo.Length& 0xff);
- EpMap.Add(btemp);
- UInt32 count = 4 + (UInt32)EpMap.Count;
- EpMap.AddRange(UintToByteArraryNetwork(count));
- UInt32 start = 4 + (UInt32)coarseloop.Count;
- EpMap.AddRange(UintToByteArraryNetwork(start));
- EpMap.AddRange(coarseloop);
- EpMap.AddRange(fineloop);
- return EpMap.ToString();
+ for (int i = 0; i < EpInfo.size(); i++)
+ {
+ UInt32 epfine = (UInt32)((EpInfo.at(i).pts_ >> 9) % 0x800);
+ UInt32 epcoarse = (UInt32)((EpInfo.at(i).pts_ >> 19) % 0x4000);
+ UInt32 spnfine = EpInfo.at(i).spn_ % 0x20000;
+ if (lastepfine > epfine || lastspnfine > spnfine)
+ {
+ UInt32 reftofine = (UInt32)i;
+ reftofine <<= 14;
+ reftofine |= epcoarse;
+ Utility::AddRange(coarseloop, UintToByteArraryNetwork(reftofine));
+ Utility::AddRange(coarseloop, UintToByteArraryNetwork(EpInfo.at(i).spn_));
+ numofcoarse++;
}
+ UInt32 value = 0x1000;
+ value |= (epfine << 17);
+ value |= spnfine;
+ Utility::AddRange(fineloop, UintToByteArraryNetwork(value));
+ lastepfine = epfine;
+ lastspnfine = spnfine;
+ }
+
+ EpMap.push_back(0x00);
+ EpMap.push_back(0x01);
+ EpMap.push_back((byte)((Constants::DEFAULT_VIDEO_PID >> 8) & 0xff));
+ EpMap.push_back((byte)(Constants::DEFAULT_VIDEO_PID & 0xff));
+ EpMap.push_back(0x00);
+ byte btemp = 4;
+ btemp |= (byte)((numofcoarse >> 14) & 0xff);
+ EpMap.push_back(btemp);
+ btemp = (byte)((numofcoarse >> 6) & 0xff);
+ EpMap.push_back(btemp);
+ btemp = (byte)((numofcoarse & 0x3f) << 2);
+ btemp |= (byte)((EpInfo.size() >> 16) & 0x03);
+ EpMap.push_back(btemp);
+ btemp = (byte)((EpInfo.size() >> 8) & 0xff);
+ EpMap.push_back(btemp);
+ btemp = (byte)(EpInfo.size() & 0xff);
+ EpMap.push_back(btemp);
+ UInt32 count = 4 + (UInt32)EpMap.size();
+ Utility::AddRange(EpMap, UintToByteArraryNetwork(count));
+ UInt32 start = 4 + (UInt32)coarseloop.size();
+ Utility::AddRange(EpMap, UintToByteArraryNetwork(start));
+ Utility::AddRange(EpMap, coarseloop);
+ Utility::AddRange(EpMap, fineloop);
+ return Utility::ToString(EpMap);
}
-**/
-