| 186 | } |
| 187 | |
| 188 | static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, |
| 189 | AVSubtitleRect *r) |
| 190 | { |
| 191 | uint32_t *pal, *dst2; |
| 192 | uint8_t *src, *src2; |
| 193 | int x, y; |
| 194 | |
| 195 | if (r->type != SUBTITLE_BITMAP) { |
| 196 | av_log(NULL, AV_LOG_WARNING, "sub2video: non-bitmap subtitle\n"); |
| 197 | return; |
| 198 | } |
| 199 | if (r->x < 0 || r->x + r->w > w || r->y < 0 || r->y + r->h > h) { |
| 200 | av_log(NULL, AV_LOG_WARNING, "sub2video: rectangle (%d %d %d %d) overflowing %d %d\n", |
| 201 | r->x, r->y, r->w, r->h, w, h |
| 202 | ); |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | dst += r->y * dst_linesize + r->x * 4; |
| 207 | src = r->data[0]; |
| 208 | pal = (uint32_t *)r->data[1]; |
| 209 | for (y = 0; y < r->h; y++) { |
| 210 | dst2 = (uint32_t *)dst; |
| 211 | src2 = src; |
| 212 | for (x = 0; x < r->w; x++) |
| 213 | *(dst2++) = pal[*(src2++)]; |
| 214 | dst += dst_linesize; |
| 215 | src += r->linesize[0]; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | static void sub2video_push_ref(InputStream *ist, int64_t pts) |
| 220 | { |