summaryrefslogtreecommitdiff
path: root/dxr3interface_spu_encoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'dxr3interface_spu_encoder.c')
-rw-r--r--dxr3interface_spu_encoder.c788
1 files changed, 394 insertions, 394 deletions
diff --git a/dxr3interface_spu_encoder.c b/dxr3interface_spu_encoder.c
index 7f78352..771ca07 100644
--- a/dxr3interface_spu_encoder.c
+++ b/dxr3interface_spu_encoder.c
@@ -24,14 +24,14 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
+*/
#include "dxr3interface_spu_encoder.h"
#include "dxr3tools.h"
/*
- ToDo:
- - cSPUEncoder::encode_do_row: FIXME: watch this space for EOL
+ToDo:
+ - cSPUEncoder::encode_do_row: FIXME: watch this space for EOL
*/
@@ -52,159 +52,159 @@ namespace XineScaler
template <const int yInc = 1, class T = int>
class cBresenham
- {
- const int m_dx;
- const int m_dy;
+ {
+ const int m_dx;
+ const int m_dy;
- int m_eps;
- T m_y;
+ int m_eps;
+ T m_y;
- public:
- cBresenham(const int dy, const int dx, const int eps, T const y0 = 0)
+ public:
+ cBresenham(const int dy, const int dx, const int eps, T const y0 = 0)
: m_dx(dx)
, m_dy(dy)
, m_eps(eps - m_dx)
, m_y(y0)
- {
- }
+ {
+ }
- int eps() const
- {
- return m_eps;
- }
+ int eps() const
+ {
+ return m_eps;
+ }
- T step()
- {
- m_eps += m_dy;
-
- while (m_eps >= 0)
- {
- m_eps -= m_dx;
+ T step()
+ {
+ m_eps += m_dy;
- m_y += yInc;
- }
+ while (m_eps >= 0)
+ {
+ m_eps -= m_dx;
- return m_y;
+ m_y += yInc;
}
- T step(int n)
- {
- if (n <= 0)
+ return m_y;
+ }
+
+ T step(int n)
+ {
+ if (n <= 0)
return m_y;
- while (--n > 0)
+ while (--n > 0)
step();
- return step();
- }
+ return step();
+ }
- T stepRelative(int n = 1)
- {
- T const y = m_y;
+ T stepRelative(int n = 1)
+ {
+ T const y = m_y;
- return step(n) - y;
- }
- };
+ return step(n) - y;
+ }
+ };
static uint8_t *ScaleBitmapLQ(const uint8_t *src, uint8_t *dest, int x0, int y0, int w, int h, int ws, int hs, int x1, int y1, int w1, int h1, const uint8_t transparentIndex)
+ {
+ uint8_t *const screen = new uint8_t[ OSDHEIGHT * OSDWIDTH ];
{
- uint8_t *const screen = new uint8_t[ OSDHEIGHT * OSDWIDTH ];
+ int x1 = x0 + w;
+ int y1 = y0 + h;
+ int x2 = OSDWIDTH;
+ int y2 = OSDHEIGHT;
+
+ if (x1 > x2)
+ x1 = x2;
+
+ if (y1 > y2)
+ y1 = y2;
+
+ uint8_t *dst = screen;
+
+ for (int y = 0; y < y0; y++)
{
- int x1 = x0 + w;
- int y1 = y0 + h;
- int x2 = OSDWIDTH;
- int y2 = OSDHEIGHT;
-
- if (x1 > x2)
- x1 = x2;
-
- if (y1 > y2)
- y1 = y2;
-
- uint8_t *dst = screen;
-
- for (int y = 0; y < y0; y++)
- {
- for (int x = 0; x < x2; x++)
- *dst++ = transparentIndex;
- }
-
- for (int y = y0; y < y1; y++)
- {
- for (int x = 0; x < x0; x++)
- *dst++ = transparentIndex;
-
- for (int x = x0; x < x1; x++)
- *dst++ = *src++;
-
- for (int x = x1; x < x2; x++)
- *dst++ = transparentIndex;
- }
-
- for (int y = y1; y < y2; y++)
- {
- for (int x = 0; x < x2; x++)
- *dst++ = transparentIndex;
- }
+ for (int x = 0; x < x2; x++)
+ *dst++ = transparentIndex;
}
-
- uint8_t *scaled = dest; //new uint8_t[ hs * ws ];
+
+ for (int y = y0; y < y1; y++)
+ {
+ for (int x = 0; x < x0; x++)
+ *dst++ = transparentIndex;
+
+ for (int x = x0; x < x1; x++)
+ *dst++ = *src++;
+
+ for (int x = x1; x < x2; x++)
+ *dst++ = transparentIndex;
+ }
+
+ for (int y = y1; y < y2; y++)
{
- int x2 = x1 + w1;
- int y2 = y1 + h1;
+ for (int x = 0; x < x2; x++)
+ *dst++ = transparentIndex;
+ }
+ }
+
+ uint8_t *scaled = dest; //new uint8_t[ hs * ws ];
+ {
+ int x2 = x1 + w1;
+ int y2 = y1 + h1;
- if (x2 > ws)
- {
- x2 = ws;
+ if (x2 > ws)
+ {
+ x2 = ws;
- w1 = x2 - x1;
- if (w1 < 0)
- w1 = 0;
- }
+ w1 = x2 - x1;
+ if (w1 < 0)
+ w1 = 0;
+ }
- if (y2 > hs)
- {
- y2 = hs;
+ if (y2 > hs)
+ {
+ y2 = hs;
- h1 = y2 - y1;
- if (h1 < 0)
- h1 = 0;
- }
+ h1 = y2 - y1;
+ if (h1 < 0)
+ h1 = 0;
+ }
- cBresenham<OSDWIDTH, uint8_t *> yyBh(2 * OSDHEIGHT, 2 * hs, hs, screen);
- uint8_t *screen0 = yyBh.step(y1); //(((2 * y1 + 1) * OSDHEIGHT / hs) / 2);
+ cBresenham<OSDWIDTH, uint8_t *> yyBh(2 * OSDHEIGHT, 2 * hs, hs, screen);
+ uint8_t *screen0 = yyBh.step(y1); //(((2 * y1 + 1) * OSDHEIGHT / hs) / 2);
- cBresenham<> xxBh0(2 * OSDWIDTH, 2 * ws, ws);
- xxBh0.step(x1); //(((2 * x1 + 1) * OSDWIDTH / ws) / 2);
+ cBresenham<> xxBh0(2 * OSDWIDTH, 2 * ws, ws);
+ xxBh0.step(x1); //(((2 * x1 + 1) * OSDWIDTH / ws) / 2);
- uint8_t *scaled0 = scaled + y1 * OSDWIDTH; //ws; ******
+ uint8_t *scaled0 = scaled + y1 * OSDWIDTH; //ws; ******
- for (int y = y1; y < y2; y++)
- {
- cBresenham<> xxBh(xxBh0);
- int xxx = xxBh.step(0); //(((2 * x1 + 1) * OSDWIDTH / ws) / 2);
+ for (int y = y1; y < y2; y++)
+ {
+ cBresenham<> xxBh(xxBh0);
+ int xxx = xxBh.step(0); //(((2 * x1 + 1) * OSDWIDTH / ws) / 2);
- uint8_t *screen00 = screen0 + xxx;
+ uint8_t *screen00 = screen0 + xxx;
- uint8_t *scaled00 = scaled0 + x1;
+ uint8_t *scaled00 = scaled0 + x1;
- for (int x = x1; x < x2; x++)
- {
- *scaled00++ = *screen00;
+ for (int x = x1; x < x2; x++)
+ {
+ *scaled00++ = *screen00;
- screen00 += xxBh.stepRelative();
- }
+ screen00 += xxBh.stepRelative();
+ }
- scaled0 += OSDWIDTH; //ws; *******
+ scaled0 += OSDWIDTH; //ws; *******
- screen0 = yyBh.step();
- }
+ screen0 = yyBh.step();
}
+ }
- delete [] screen;
+ delete [] screen;
- return scaled;
- }
+ return scaled;
+ }
};
@@ -220,30 +220,30 @@ namespace XineScaler
// dec.
cSpuData::~cSpuData()
{
- Clear();
+ Clear();
}
// ==================================
// free buffer and set it to 0
void cSpuData::Clear()
{
- if (data)
- {
- free(data);
- count = malloc_size = 0;
- }
+ if (data)
+ {
+ free(data);
+ count = malloc_size = 0;
+ }
}
// ==================================
// wirte a byte to spu buffer
void cSpuData::WriteByte(uint8_t byte)
{
- if (count >= malloc_size)
- {
- data = (u_char*)realloc(data, malloc_size += 2048);
- }
+ if (count >= malloc_size)
+ {
+ data = (u_char*)realloc(data, malloc_size += 2048);
+ }
- data[count++] = byte;
+ data[count++] = byte;
}
// ==================================
@@ -262,13 +262,13 @@ void cSpuData::WriteRle(int *higher_nibble, int length, int color)
// ==================================
cSPUEncoder::cSPUEncoder()
{
- // clear osd
- memset(OSD_Screen, 0x00 ,OSDWIDTH * OSDHEIGHT);
- memset(OSD_Screen2, 0x00 ,OSDWIDTH * OSDHEIGHT);
- memset(OSD_Screen3, 0x00 ,OSDWIDTH * OSDHEIGHT);
+ // clear osd
+ memset(OSD_Screen, 0x00 ,OSDWIDTH * OSDHEIGHT);
+ memset(OSD_Screen2, 0x00 ,OSDWIDTH * OSDHEIGHT);
+ memset(OSD_Screen3, 0x00 ,OSDWIDTH * OSDHEIGHT);
- // set active area to 0
- //m_x0 = m_x1 = m_y0 = m_y1 = 0;
+ // set active area to 0
+ //m_x0 = m_x1 = m_y0 = m_y1 = 0;
}
@@ -279,15 +279,15 @@ cSPUEncoder::cSPUEncoder()
void cSPUEncoder::SetPalette(int numWindow, cPalette* commonPalette, cPalette* windowPalette)
{
- int NumColors;
- const tColor *Colors = windowPalette->Colors(NumColors);
- if (Colors) {
- for (int i=0; i<NumColors; i++) {
- int idx=commonPalette->Index(Colors[i] & 0x00FFFFFF);
- int opacity=((Colors[i] & 0xFF000000) >> 24) * 0xF / 0xFF;
- bitmapcolor[numWindow][i]=(opacity<<4) | idx;
- }
- }
+ int NumColors;
+ const tColor *Colors = windowPalette->Colors(NumColors);
+ if (Colors) {
+ for (int i=0; i<NumColors; i++) {
+ int idx=commonPalette->Index(Colors[i] & 0x00FFFFFF);
+ int opacity=((Colors[i] & 0xFF000000) >> 24) * 0xF / 0xFF;
+ bitmapcolor[numWindow][i]=(opacity<<4) | idx;
+ }
+ }
}
//========================================
@@ -324,146 +324,146 @@ int cSPUEncoder::Flush(cPalette *Palette)
EncodePixelbufRle(0,0, OSDWIDTH, OSDHEIGHT-1, OSD_Screen, 0, &m_encodeddata);
if (cDxr3ConfigData::Instance().GetDebug())
- {
- cLog::Instance() << "OSD Datasize: " << m_encodeddata.count << "\n";
- }
+ {
+ cLog::Instance() << "OSD Datasize: " << m_encodeddata.count << "\n";
+ }
if (m_encodeddata.count <= DATASIZE)
- {
- cDxr3Interface::Instance().WriteSpu((uint8_t*) &m_encodeddata, m_encodeddata.count);
- return 0;
- } else
- {
- cLog::Instance() << "Warning: SPU data (" << m_encodeddata.count << ") size exceeds limit\n";
- return -1;
- }
+ {
+ cDxr3Interface::Instance().WriteSpu((uint8_t*) &m_encodeddata, m_encodeddata.count);
+ return 0;
+ } else
+ {
+ cLog::Instance() << "Warning: SPU data (" << m_encodeddata.count << ") size exceeds limit\n";
+ return -1;
+ }
}
// ==================================
// stamps window content into full osd bitmap
void cSPUEncoder::CopyBlockIntoOSD(int numWindow, int linewidth, int x0, int y0, int x1, int y1, const tIndex *data)
{
- tIndex *cp;
- const tIndex *sp = data;
+ tIndex *cp;
+ const tIndex *sp = data;
- if (x1>=OSDWIDTH) x1=OSDWIDTH-1;
- if (y1>=OSDHEIGHT) y1=OSDHEIGHT-1;
- cp = &OSD_Screen[y0*OSDWIDTH+x0];
+ if (x1>=OSDWIDTH) x1=OSDWIDTH-1;
+ if (y1>=OSDHEIGHT) y1=OSDHEIGHT-1;
+ cp = &OSD_Screen[y0*OSDWIDTH+x0];
- for (int y = y0; y <= y1; y++) {
- for (int x=x0; x <= x1; x++) {
- *(cp++) = bitmapcolor[numWindow][*(sp++) & 0x0f];
+ for (int y = y0; y <= y1; y++) {
+ for (int x=x0; x <= x1; x++) {
+ *(cp++) = bitmapcolor[numWindow][*(sp++) & 0x0f];
+ }
+ cp+=OSDWIDTH-(x1-x0+1);
+ sp+=linewidth-(x1-x0+1);
}
- cp+=OSDWIDTH-(x1-x0+1);
- sp+=linewidth-(x1-x0+1);
- }
}
// ==================================
// taken from mplayer (spuenc.c)
void cSPUEncoder::EncodePixelbufRle(int x, int y, int w, int h, u_char *inbuf, int stride, encodedata *ed)
{
- pixbuf pb;
- int i, row;
- pb.x = w;
- pb.y = h;
+ pixbuf pb;
+ int i, row;
+ pb.x = w;
+ pb.y = h;
#ifdef USE_XINE_SCALER
- int ws = cDxr3Interface::Instance().GetHorizontalSize();
- int hs = cDxr3Interface::Instance().GetVerticalSize();
- if (ws < 720 || hs < 576 )
- inbuf = XineScaler::ScaleBitmapLQ(inbuf, OSD_Screen2, 0, 0, OSDWIDTH, OSDHEIGHT, ws, hs, 0, 0, ws, hs, 0 /* clrTransparent */);
+ int ws = cDxr3Interface::Instance().GetHorizontalSize();
+ int hs = cDxr3Interface::Instance().GetVerticalSize();
+ if (ws < 720 || hs < 576 )
+ inbuf = XineScaler::ScaleBitmapLQ(inbuf, OSD_Screen2, 0, 0, OSDWIDTH, OSDHEIGHT, ws, hs, 0, 0, ws, hs, 0 /* clrTransparent */);
#else
- if (cDxr3Interface::Instance().GetHorizontalSize() < 700)
- {
- double fac = (double)OSDWIDTH / (double)OSDWIDTH2;
- ScaleOSD(fac, inbuf,10);
- inbuf = OSD_Screen2;
+ if (cDxr3Interface::Instance().GetHorizontalSize() < 700)
+ {
+ double fac = (double)OSDWIDTH / (double)OSDWIDTH2;
+ ScaleOSD(fac, inbuf,10);
+ inbuf = OSD_Screen2;
}
#endif /* USE_XINE_SCALER */
- m_ColorManager = new cColorManager();
+ m_ColorManager = new cColorManager();
- // Encode colors into highlight regions
- m_ColorManager->EncodeColors(w, h, inbuf, OSD_Screen3);
- inbuf = OSD_Screen3;
+ // Encode colors into highlight regions
+ m_ColorManager->EncodeColors(w, h, inbuf, OSD_Screen3);
+ inbuf = OSD_Screen3;
- pb.pixels = inbuf;
- ed->count= 4;
- ed->nibblewaiting= 0;
+ pb.pixels = inbuf;
+ ed->count= 4;
+ ed->nibblewaiting= 0;
- row= 0;
- for (i= 0; i < pb.y; i++)
- {
- encode_do_row(ed, &pb, row);
- row+= 2;
- if (row > pb.y)
+ row= 0;
+ for (i= 0; i < pb.y; i++)
{
- row= 1;
- ed->oddstart= ed->count;
+ encode_do_row(ed, &pb, row);
+ row+= 2;
+ if (row > pb.y)
+ {
+ row= 1;
+ ed->oddstart= ed->count;
}
}
- encode_do_control(x,y, ed, &pb);
+ encode_do_control(x,y, ed, &pb);
- delete m_ColorManager;
+ delete m_ColorManager;
}
#ifndef USE_XINE_SCALER
// ==================================
void cSPUEncoder::ScaleOSD(double fac, unsigned char* buf, unsigned char NumColors)
{
- int y,x,s,d;
- unsigned char dline[2 * OSDWIDTH + 10];
+ int y,x,s,d;
+ unsigned char dline[2 * OSDWIDTH + 10];
- memset(OSD_Screen2, 0x00 ,OSDWIDTH * OSDHEIGHT);
+ memset(OSD_Screen2, 0x00 ,OSDWIDTH * OSDHEIGHT);
- if (cDxr3Interface::Instance().GetHorizontalSize() < 470)
+ if (cDxr3Interface::Instance().GetHorizontalSize() < 470)
{
- for (y = 0; y < OSDHEIGHT; y++)
- for (s = 0, d = 0; d < OSDWIDTH; s++, d += 2)
- OSD_Screen2[y * OSDWIDTH + s] = buf[y * OSDWIDTH + d];
+ for (y = 0; y < OSDHEIGHT; y++)
+ for (s = 0, d = 0; d < OSDWIDTH; s++, d += 2)
+ OSD_Screen2[y * OSDWIDTH + s] = buf[y * OSDWIDTH + d];
} else {
- for (y = 0; y < OSDHEIGHT; y++)
+ for (y = 0; y < OSDHEIGHT; y++)
{
- memset(dline,0,2*OSDWIDTH+10);
+ memset(dline,0,2*OSDWIDTH+10);
- for (s=0,d=0; s < OSDWIDTH; s++,d+=2)
- {
- // stretch line to double width to 1440
- dline[d] = buf[y*OSDWIDTH + s];
- }
-
- for (d=1; d < (2*OSDWIDTH); d+=2)
- {
-#if VDRVERSNUM <= 10307
- // 'interpolate' values
- if ((dline[d-1] == BLACK) || (dline[d+1] == BLACK))
- {
- dline[d] = BLACK;
- }
- else if ((dline[d-1] == WHITE) || (dline[d+1] == WHITE))
- {
- dline[d] = WHITE;
- }
- else if ((dline[d-1] == CYAN) || (dline[d+1] == CYAN))
- {
- dline[d] = CYAN;
- }
- else
- {
- dline[d] = dline[d+1];
- }
-#else /*VDRVERSNUM*/
- dline[d] = dline[d+1];
-#endif /*VDRVERSNUM*/
- }
-
- for (s=0, x = 0; x < OSDWIDTH2; x++,s+=3)
- {
- // now take every third pixel (1440/3=480)
- OSD_Screen2[y * OSDWIDTH + x] = dline[s];
- }
- }
+ for (s=0,d=0; s < OSDWIDTH; s++,d+=2)
+ {
+ // stretch line to double width to 1440
+ dline[d] = buf[y*OSDWIDTH + s];
+ }
+
+ for (d=1; d < (2*OSDWIDTH); d+=2)
+ {
+ #if VDRVERSNUM <= 10307
+ // 'interpolate' values
+ if ((dline[d-1] == BLACK) || (dline[d+1] == BLACK))
+ {
+ dline[d] = BLACK;
+ }
+ else if ((dline[d-1] == WHITE) || (dline[d+1] == WHITE))
+ {
+ dline[d] = WHITE;
+ }
+ else if ((dline[d-1] == CYAN) || (dline[d+1] == CYAN))
+ {
+ dline[d] = CYAN;
+ }
+ else
+ {
+ dline[d] = dline[d+1];
+ }
+ #else /*VDRVERSNUM*/
+ dline[d] = dline[d+1];
+ #endif /*VDRVERSNUM*/
+ }
+
+ for (s=0, x = 0; x < OSDWIDTH2; x++,s+=3)
+ {
+ // now take every third pixel (1440/3=480)
+ OSD_Screen2[y * OSDWIDTH + x] = dline[s];
+ }
+ }
}
}
#endif /* not USE_XINE_SCALER */
@@ -472,15 +472,15 @@ void cSPUEncoder::ScaleOSD(double fac, unsigned char* buf, unsigned char NumColo
// taken from mplayer (spuenc.c)
void cSPUEncoder::encode_put_nibble(encodedata* ed, u_char nibble)
{
- if (ed->nibblewaiting)
- {
- ed->data[ed->count++]|= nibble;
- ed->nibblewaiting= 0;
+ if (ed->nibblewaiting)
+ {
+ ed->data[ed->count++]|= nibble;
+ ed->nibblewaiting= 0;
}
- else
- {
- ed->data[ed->count]= nibble<<4;
- ed->nibblewaiting= 1;
+ else
+ {
+ ed->data[ed->count]= nibble<<4;
+ ed->nibblewaiting= 1;
}
}
@@ -488,74 +488,74 @@ void cSPUEncoder::encode_put_nibble(encodedata* ed, u_char nibble)
// taken from mplayer (spuenc.c)
void cSPUEncoder::encode_pixels(encodedata* ed, int color, int number)
{
- if (number > 3)
- {
- if (number > 15)
+ if (number > 3)
{
- encode_put_nibble(ed, 0);
- if (number > 63)
- {
- encode_put_nibble(ed, (number & 0xC0)>>6);
+ if (number > 15)
+ {
+ encode_put_nibble(ed, 0);
+ if (number > 63)
+ {
+ encode_put_nibble(ed, (number & 0xC0)>>6);
}
}
- encode_put_nibble(ed, (number & 0x3C)>>2);
+ encode_put_nibble(ed, (number & 0x3C)>>2);
}
- encode_put_nibble(ed, ((number & 0xF)<<2) | color);
+ encode_put_nibble(ed, ((number & 0xF)<<2) | color);
}
// ==================================
// taken from mplayer (spuenc.c)
void cSPUEncoder::encode_eol(encodedata* ed)
{
- if (ed->nibblewaiting)
- {
- ed->count++;
- ed->nibblewaiting= 0;
+ if (ed->nibblewaiting)
+ {
+ ed->count++;
+ ed->nibblewaiting= 0;
}
- ed->data[ed->count++]= 0x00;
- ed->data[ed->count++]= 0x00;
+ ed->data[ed->count++]= 0x00;
+ ed->data[ed->count++]= 0x00;
}
// ==================================
// taken from mplayer (spuenc.c)
void cSPUEncoder::encode_do_row(encodedata* ed, pixbuf* pb, int row)
{
- int i= 0;
- u_char* pix= pb->pixels + row * pb->x;
- int color= *pix & 0x03;
- int n= 0; /* the number of pixels of this color */
+ int i= 0;
+ u_char* pix= pb->pixels + row * pb->x;
+ int color= *pix & 0x03;
+ int n= 0; /* the number of pixels of this color */
- while (i++ < pb->x)
- {
- /* FIXME: watch this space for EOL */
- if ((*pix & 0x03) != color || n == 255 )
+ while (i++ < pb->x)
{
- encode_pixels( ed, color, n );
- color= *pix & 0x03;
- n= 1;
+ /* FIXME: watch this space for EOL */
+ if ((*pix & 0x03) != color || n == 255 )
+ {
+ encode_pixels( ed, color, n );
+ color= *pix & 0x03;
+ n= 1;
}
- else
- {
- n++;
+ else
+ {
+ n++;
}
- pix++;
+ pix++;
}
- /* this small optimization: (n>63) can save up to two bytes per line
- * I wonder if this is compatible with all the hardware... */
- if (color == 0 && n > 63)
- {
- encode_eol( ed );
+ /* this small optimization: (n>63) can save up to two bytes per line
+ * I wonder if this is compatible with all the hardware... */
+ if (color == 0 && n > 63)
+ {
+ encode_eol( ed );
}
- else
- {
- encode_pixels( ed, color, n );
+ else
+ {
+ encode_pixels( ed, color, n );
}
- if (ed->nibblewaiting)
- {
- ed->count++;
- ed->nibblewaiting= 0;
+ if (ed->nibblewaiting)
+ {
+ ed->count++;
+ ed->nibblewaiting= 0;
}
}
@@ -563,136 +563,136 @@ void cSPUEncoder::encode_do_row(encodedata* ed, pixbuf* pb, int row)
// taken from mplayer (spuenc.c)
void cSPUEncoder::encode_do_control(int x,int y, encodedata* ed, pixbuf* pb)
{
- int controlstart= ed->count;
- int x1;
- int i;
- u_int top, left, bottom, right;
-
- top= y; //this forces the first bit to be visible on a TV
- left= x; //you could actually pass in x/y and do some nice
-
- bottom= top + pb->y - 1;
- right= left + pb->x - 1;
-
- /* start at x0+2*/
- i= controlstart;
-
- x1= (i); //marker for last command block address
-
- /* display duration... */
- ed->data[i++]= 0x00;
- ed->data[i++]= 0x00; //duration before turn on command occurs (will not be used)
-
- /* x1 */
- ed->data[i++]= x1 >> 8; //since this is the last command block, this
- ed->data[i++]= x1 & 0xff;//points back to itself
-
- /* 0x00: force displaying */
- ed->data[i++]= 0x00;
-
- /* 0x03: palette info */
- ed->data[i++]= 0x03;
- ed->data[i++]= 0x01;
- ed->data[i++]= 0x23;
-
- /* 0x04: transparency info (reversed) */
- ed->data[i++]= 0x04; // SET_CONTR
- ed->data[i++]= 0xFF;
- ed->data[i++]= 0x70;
-
- /* 0x05: coordinates */
- ed->data[i++]= 0x05; // SET_DAREA
- ed->data[i++]= left >> 4;
- ed->data[i++]= ((left&0xf)<<4)+(right>>8);
- ed->data[i++]= (right&0xff);
- ed->data[i++]= top >> 4;
- ed->data[i++]= ((top&0xf)<<4)+(bottom>>8);
- ed->data[i++]= (bottom&0xff);
-
- /* 0x06: both fields' offsets */
- ed->data[i++]= 0x06; // SET_DSPXA
- ed->data[i++]= 0x00;
- ed->data[i++]= 0x04;
- ed->data[i++]= ed->oddstart >> 8;
- ed->data[i++]= ed->oddstart & 0xff;
-
- int len;
- unsigned char *spudata;
-
- spudata = m_ColorManager->GetSpuData(len);
- //check that the highlight regions data wont overflow the buffer
- if(i+len+2>DATASIZE) {
- ed->count=DATASIZE+1;
- return;
- }
+ int controlstart= ed->count;
+ int x1;
+ int i;
+ u_int top, left, bottom, right;
+
+ top= y; //this forces the first bit to be visible on a TV
+ left= x; //you could actually pass in x/y and do some nice
+
+ bottom= top + pb->y - 1;
+ right= left + pb->x - 1;
+
+ /* start at x0+2*/
+ i= controlstart;
+
+ x1= (i); //marker for last command block address
+
+ /* display duration... */
+ ed->data[i++]= 0x00;
+ ed->data[i++]= 0x00; //duration before turn on command occurs (will not be used)
+
+ /* x1 */
+ ed->data[i++]= x1 >> 8; //since this is the last command block, this
+ ed->data[i++]= x1 & 0xff;//points back to itself
+
+ /* 0x00: force displaying */
+ ed->data[i++]= 0x00;
+
+ /* 0x03: palette info */
+ ed->data[i++]= 0x03;
+ ed->data[i++]= 0x01;
+ ed->data[i++]= 0x23;
+
+ /* 0x04: transparency info (reversed) */
+ ed->data[i++]= 0x04; // SET_CONTR
+ ed->data[i++]= 0xFF;
+ ed->data[i++]= 0x70;
+
+ /* 0x05: coordinates */
+ ed->data[i++]= 0x05; // SET_DAREA
+ ed->data[i++]= left >> 4;
+ ed->data[i++]= ((left&0xf)<<4)+(right>>8);
+ ed->data[i++]= (right&0xff);
+ ed->data[i++]= top >> 4;
+ ed->data[i++]= ((top&0xf)<<4)+(bottom>>8);
+ ed->data[i++]= (bottom&0xff);
+
+ /* 0x06: both fields' offsets */
+ ed->data[i++]= 0x06; // SET_DSPXA
+ ed->data[i++]= 0x00;
+ ed->data[i++]= 0x04;
+ ed->data[i++]= ed->oddstart >> 8;
+ ed->data[i++]= ed->oddstart & 0xff;
+
+ int len;
+ unsigned char *spudata;
+
+ spudata = m_ColorManager->GetSpuData(len);
+ //check that the highlight regions data wont overflow the buffer
+ if(i+len+2>DATASIZE) {
+ ed->count=DATASIZE+1;
+ return;
+ }
- for (int si= 0; si < len; si++)
- {
- ed->data[i++] = *(spudata + si);
+ for (int si= 0; si < len; si++)
+ {
+ ed->data[i++] = *(spudata + si);
}
- /* 0xFF: end sequence */
- ed->data[i++]= 0xFF;
- if (! i&1 )
- {
- ed->data[i++]= 0xff;
+ /* 0xFF: end sequence */
+ ed->data[i++]= 0xFF;
+ if (! i&1 )
+ {
+ ed->data[i++]= 0xff;
}
- /* x0 */
- ed->data[2]= (controlstart) >> 8;
- ed->data[3]= (controlstart) & 0xff;
+ /* x0 */
+ ed->data[2]= (controlstart) >> 8;
+ ed->data[3]= (controlstart) & 0xff;
- /* packet size */
- ed->data[0]= i >> 8;
- ed->data[1]= i & 0xff;
+ /* packet size */
+ ed->data[0]= i >> 8;
+ ed->data[1]= i & 0xff;
- ed->count= i;
+ ed->count= i;
}
// ==================================
// Stop spu display
void cSPUEncoder::StopSpu(void)
{
- uint8_t ed[10];
- /* packet size */
- ed[0]= 0;
- ed[1]= 10;
+ uint8_t ed[10];
+ /* packet size */
+ ed[0]= 0;
+ ed[1]= 10;
- /* pointer to the SP_DCSQT */
- ed[2]= 0;
- ed[3]= 4;
+ /* pointer to the SP_DCSQT */
+ ed[2]= 0;
+ ed[3]= 4;
- /* SP_DCSQT */
- /* display duration... */
- ed[4]= 0x00;
- ed[5]= 0x00; //duration before turn on command occurs (will not be used)
+ /* SP_DCSQT */
+ /* display duration... */
+ ed[4]= 0x00;
+ ed[5]= 0x00; //duration before turn on command occurs (will not be used)
- /* pointer to next command block */
- ed[6]= 0; //since this is the last command block, this
- ed[7]= 4;//points back to itself
+ /* pointer to next command block */
+ ed[6]= 0; //since this is the last command block, this
+ ed[7]= 4;//points back to itself
- /* 0x02: stop displaying */
- ed[8]= 0x02;
+ /* 0x02: stop displaying */
+ ed[8]= 0x02;
- /* 0xFF: end sequence */
- ed[9]= 0xFF;
- cDxr3Interface::Instance().WriteSpu(ed, 10);
+ /* 0xFF: end sequence */
+ ed[9]= 0xFF;
+ cDxr3Interface::Instance().WriteSpu(ed, 10);
}
// ==================================
// we _only_ write usefull data
void cSPUEncoder::CalculateActiveOsdArea()
{
- // reset
- //m_x0 = m_x1 = m_y0 = m_y1 = 0;
+ // reset
+ //m_x0 = m_x1 = m_y0 = m_y1 = 0;
- // calculate
- /* for (int i = 1; i < 8; i++)
+ // calculate
+/* for (int i = 1; i < 8; i++)
{
- m_x0 = max(m_x0, m_windows[i].x0);
- m_x1 = max(m_x1, m_windows[i].y0);
- m_y0 = max(m_y0, m_windows[i].x1);
- m_y1 = max(m_y1, m_windows[i].y1);
+ m_x0 = max(m_x0, m_windows[i].x0);
+ m_x1 = max(m_x1, m_windows[i].y0);
+ m_y0 = max(m_y0, m_windows[i].x1);
+ m_y1 = max(m_y1, m_windows[i].y1);
}
- */
+*/
}