📄 packetprocessing.cpp
字号:
int last_character[25];
if (m_nValidLines > 0)
{
for (int line = (display_heading_line ? 0 : 1); line <= last_line; line++)
{
if (m_PageBuffer[line].m_bTransmitted)
{
row_numbers[subtitle_lines] = line;
memcpy(page[subtitle_lines], &m_PageBuffer[line].m_Line, 40);
subtitle_lines++;
}
}
}
if (subtitle_lines == 0)
{
return;
}
char tmp[41];
for (int row = 0; row < subtitle_lines; row++)
{
first_character[row] = -1;
int n = 0;
for (int character = 1; character <= 40; character++)
{
char ch = page[row][character - 1] & 0x7f;
if ((first_character[row] < 0) && (ch > 32))
{
first_character[row] = character;
}
if (ch < 32)
{
ch = 32;
}
tmp[n++] = ch;
}
last_character[row] = 40;
while
(
(last_character[row] > 0)
&&
(tmp[last_character[row] - 1] == ' ')
)
{
last_character[row]--;
}
tmp[n] = 0;
}
bool alpha = false;
for (int row = 0; row < subtitle_lines; row++)
{
colour_types colour = Colour_White;
colour_types background_colour = Colour_Black;
colour_types mosaic_colour = Colour_Black;
colour_types latest_colour = colour;
int text_index = 0;
STeletextSubtitleLine teletext_subtitle_line;
teletext_subtitle_line.row = row_numbers[row];
teletext_subtitle_line.column = first_character[row];
#define ATLTRACE1
ATLTRACE1("<row=%d><column=%d>", teletext_subtitle_line.row, teletext_subtitle_line.column);
for (int column = 1; column <= 40; column++)
{
char ch = page[row][column - 1] & 0x7f;
if (ch >= ' ')
{
if ( (column >= first_character[row]) && (column <= last_character[row]) )
{
teletext_subtitle_line.text[text_index++] = vtx2iso8559_1_table[m_Language][ch - 0x20];
}
}
else
{
if ( (column >= first_character[row]) && (column <= last_character[row]) )
{
if (text_index < (sizeof(teletext_subtitle_line.text) / sizeof(teletext_subtitle_line.text[0])))
{
teletext_subtitle_line.text[text_index++] = ' ';
}
}
switch (ch)
{
// Alpha Colour (Set After)
case 0 :
latest_colour = colour = Colour_Black;
alpha = true;
ATLTRACE1("<alpha black>");
break;
case 1 :
latest_colour = colour = Colour_Red;
alpha = true;
ATLTRACE1("<alpha red>");
break;
case 2 :
latest_colour = colour = Colour_Green;
alpha = true;
ATLTRACE1("<alpha green>");
break;
case 3 :
latest_colour = colour = Colour_Yellow;
alpha = true;
ATLTRACE1("<alpha yellow>");
break;
case 4 :
latest_colour = colour = Colour_Blue;
alpha = true;
ATLTRACE1("<alpha blue>");
break;
case 5 :
latest_colour = colour = Colour_Magenta;
alpha = true;
ATLTRACE1("<alpha magenta>");
break;
case 6 :
latest_colour = colour = Colour_Cyan;
alpha = true;
ATLTRACE1("<alpha cyan>");
break;
case 7 :
latest_colour = colour = Colour_White;
alpha = true;
ATLTRACE1("<alpha white>");
break;
case 0x8 :
// Start Flash (Set After)
ATLTRACE1("<Start Flash>");
break;
case 0x9 :
// Steady (Set At)
ATLTRACE1("<Steady>");
break;
case 0xa :
// End Box (Set After)
ATLTRACE1("<End Box>");
break;
case 0xb :
// Start Box (Set After)
ATLTRACE1("<Start Box>");
break;
case 0xc :
// Normal Size (Set At)
ATLTRACE1("<Normal Size>");
break;
case 0xd :
// Double height (Set After)
ATLTRACE1("<Double height>");
break;
case 0xe :
// Double width (Set After)
ATLTRACE1("<Double width>");
break;
case 0xf :
// Double size (Set After)
ATLTRACE1("<Double size>");
break;
// Mosaic colour(Set After)
case 0x10 : latest_colour = mosaic_colour = Colour_Black; alpha = false; ATLTRACE1("<mosaic Black>"); break;
case 0x11 : latest_colour = mosaic_colour = Colour_Red; alpha = false; ATLTRACE1("<mosaic red>"); break;
case 0x12 : latest_colour = mosaic_colour = Colour_Green; alpha = false; ATLTRACE1("<mosaic green>"); break;
case 0x13 : latest_colour = mosaic_colour = Colour_Yellow; alpha = false; ATLTRACE1("<mosaic yellow>"); break;
case 0x14 : latest_colour = mosaic_colour = Colour_Blue; alpha = false; ATLTRACE1("<mosaic blue>"); break;
case 0x15 : latest_colour = mosaic_colour = Colour_Magenta; alpha = false; ATLTRACE1("<mosaic magenta>"); break;
case 0x16 : latest_colour = mosaic_colour = Colour_Cyan; alpha = false; ATLTRACE1("<mosaic cyan>"); break;
case 0x17 : latest_colour = mosaic_colour = Colour_White; alpha = false; ATLTRACE1("<mosaic white>"); break;
case 0x18 :
// Conceal (Set At)
ATLTRACE1("<Conceal>");
break;
case 0x19 :
// Contiguous Mosaic Graphics (Set At)
ATLTRACE1("<Contiguous Mosaic>");
break;
case 0x1A :
// Seperated Mosaic Graphics (Set At)
ATLTRACE1("<Seperated Mosaic>");
break;
case 0x1B :
// Escape (Set After)
ATLTRACE1("<Escape>");
break;
case 0x1C :
// Black background (Set At)
background_colour = Colour_Black;
ATLTRACE1("<Black background>");
break;
case 0x1D :
// New background
// The foreground colour becomes the background colour
// any new characters until foreground would be invisible.
background_colour = latest_colour;
ATLTRACE1("<New background>");
break;
case 0x1E :
// Hold Mosaics (Set At)
ATLTRACE1("<Hold Mosaics>");
break;
case 0x1F :
// Release Mosaics (Set At)
ATLTRACE1("<Release Mosaics>");
break;
default :
ATLTRACE1("<default!!!>");
break;
}
}
}
teletext_subtitle_line.m_Colour = colour;
teletext_subtitle_line.m_BackgroundColour = background_colour;
if (text_index < (sizeof(teletext_subtitle_line.text) / sizeof(teletext_subtitle_line.text[0])))
{
teletext_subtitle_line.text[text_index++] = '\0';
}
if (alpha)
{
ATLTRACE1("<text=%s>", teletext_subtitle_line.text);
}
else
{
ATLTRACE1("<mosaic=%s>", teletext_subtitle_line.text);
}
ATLTRACE1("\n");
texts.push_back(teletext_subtitle_line);
}
}
bool
SMagazineSubPage::SetLine
(
int line,
unsigned char* data,
int mag,
int last_line,
SMagazine* magazine,
unsigned __int64 program_time_ms
)
{
bool updated = false;
if (line == 0)
{
if (m_Valid) // valid from last time, that means all the lines have been transmitted.
{
m_Displayed = false;
magazine->AddPageUnderConstruction(); // add this subpage, it is ready
updated = true;
}
// Using this buffer to start a brand new page.
m_nPage = (mag << 8) | unham(data[0], data[1]); // The lower two (hex) numbers of page
m_nSubPage = ((unham(data[4], data[5]) << 8) | unham(data[2], data[3])) & 0x3F7F;
m_Language = ((unham(data[6], data[7]) >> 5) & 0x07);
m_StartMilliseconds = program_time_ms;
m_EndMilliseconds = 0;
m_Valid = true;
m_bErasePage = (data[3] & 0x80) == 0x80; // Byte 9, bit 8
m_bNewsflash = (data[5] & 0x20) == 0x20; // Byte 11, bit 6
m_bSubtitle = (data[5] & 0x80) == 0x80; // Byte 11, bit 8
m_bSupressHeader = (data[6] & 0x02) == 0x02; // Byte 12, bit 2
m_bUpdateIndicator = (data[6] & 0x08) == 0x08; // Byte 12, bit 4
m_bInterruptedSequence = (data[6] & 0x20) == 0x20; // Byte 12, bit 6
m_bInhibitDisplay = (data[6] & 0x80) == 0x80; // Byte 12, bit 8
m_bMagazineSerial = (data[7] & 0x02) == 0x02; // Byte 13, bit 2
ClearPageBuffer();
}
if (m_Valid)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -