- SDL_FillRect(screen, &rect, color);
- if (update && w > 0 && h > 0)
- SDL_UpdateRect(screen, x, y, w, h);
-}
-
-/* draw only the border of a rectangle */
-static void fill_border(int xleft, int ytop, int width, int height, int x, int y, int w, int h, int color, int update)
-{
- int w1, w2, h1, h2;
-
- /* fill the background */
- w1 = x;
- if (w1 < 0)
- w1 = 0;
- w2 = width - (x + w);
- if (w2 < 0)
- w2 = 0;
- h1 = y;
- if (h1 < 0)
- h1 = 0;
- h2 = height - (y + h);
- if (h2 < 0)
- h2 = 0;
- fill_rectangle(screen,
- xleft, ytop,
- w1, height,
- color, update);
- fill_rectangle(screen,
- xleft + width - w2, ytop,
- w2, height,
- color, update);
- fill_rectangle(screen,
- xleft + w1, ytop,
- width - w1 - w2, h1,
- color, update);
- fill_rectangle(screen,
- xleft + w1, ytop + height - h2,
- width - w1 - w2, h2,
- color, update);
-}
-
-#define ALPHA_BLEND(a, oldp, newp, s)\
-((((oldp << s) * (255 - (a))) + (newp * (a))) / (255 << s))
-
-
-
-#define BPP 1
-
-static void blend_subrect(uint8_t **data, int *linesize, const AVSubtitleRect *rect, int imgw, int imgh)
-{
- int x, y, Y, U, V, A;
- uint8_t *lum, *cb, *cr;
- int dstx, dsty, dstw, dsth;
- const AVSubtitleRect *src = rect;
-
- dstw = av_clip(rect->w, 0, imgw);
- dsth = av_clip(rect->h, 0, imgh);
- dstx = av_clip(rect->x, 0, imgw - dstw);
- dsty = av_clip(rect->y, 0, imgh - dsth);
- lum = data[0] + dstx + dsty * linesize[0];
- cb = data[1] + dstx/2 + (dsty >> 1) * linesize[1];
- cr = data[2] + dstx/2 + (dsty >> 1) * linesize[2];
-
- for (y = 0; y<dsth; y++) {
- for (x = 0; x<dstw; x++) {
- Y = src->data[0][x + y*src->linesize[0]];
- A = src->data[3][x + y*src->linesize[3]];
- lum[0] = ALPHA_BLEND(A, lum[0], Y, 0);
- lum++;
- }
- lum += linesize[0] - dstw;
- }
-
- for (y = 0; y<dsth/2; y++) {
- for (x = 0; x<dstw/2; x++) {
- U = src->data[1][x + y*src->linesize[1]];
- V = src->data[2][x + y*src->linesize[2]];
- A = src->data[3][2*x + 2*y *src->linesize[3]]
- + src->data[3][2*x + 1 + 2*y *src->linesize[3]]
- + src->data[3][2*x + 1 + (2*y+1)*src->linesize[3]]
- + src->data[3][2*x + (2*y+1)*src->linesize[3]];
- cb[0] = ALPHA_BLEND(A>>2, cb[0], U, 0);
- cr[0] = ALPHA_BLEND(A>>2, cr[0], V, 0);
- cb++;
- cr++;
- }
- cb += linesize[1] - dstw/2;
- cr += linesize[2] - dstw/2;
- }