#define BPP 1
-static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, int imgh)
+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;
dsth = av_clip(rect->h, 0, imgh);
dstx = av_clip(rect->x, 0, imgw - dstw);
dsty = av_clip(rect->y, 0, imgh - dsth);
- lum = dst->data[0] + dstx + dsty * dst->linesize[0];
- cb = dst->data[1] + dstx/2 + (dsty >> 1) * dst->linesize[1];
- cr = dst->data[2] + dstx/2 + (dsty >> 1) * dst->linesize[2];
+ 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++) {
lum[0] = ALPHA_BLEND(A, lum[0], Y, 0);
lum++;
}
- lum += dst->linesize[0] - dstw;
+ lum += linesize[0] - dstw;
}
for (y = 0; y<dsth/2; y++) {
cb++;
cr++;
}
- cb += dst->linesize[1] - dstw/2;
- cr += dst->linesize[2] - dstw/2;
+ cb += linesize[1] - dstw/2;
+ cr += linesize[2] - dstw/2;
}
}
/* XXX: we suppose the screen has a 1.0 pixel ratio */
height = scr_height;
- width = ((int)rint(height * aspect_ratio)) & ~1;
+ width = lrint(height * aspect_ratio) & ~1;
if (width > scr_width) {
width = scr_width;
- height = ((int)rint(width / aspect_ratio)) & ~1;
+ height = lrint(width / aspect_ratio) & ~1;
}
x = (scr_width - width) / 2;
y = (scr_height - height) / 2;
{
Frame *vp;
Frame *sp;
- AVPicture pict;
SDL_Rect rect;
int i;
sp = frame_queue_peek(&is->subpq);
if (vp->pts >= sp->pts + ((float) sp->sub.start_display_time / 1000)) {
+ uint8_t *data[4];
+ int linesize[4];
+
SDL_LockYUVOverlay (vp->bmp);
- pict.data[0] = vp->bmp->pixels[0];
- pict.data[1] = vp->bmp->pixels[2];
- pict.data[2] = vp->bmp->pixels[1];
+ data[0] = vp->bmp->pixels[0];
+ data[1] = vp->bmp->pixels[2];
+ data[2] = vp->bmp->pixels[1];
- pict.linesize[0] = vp->bmp->pitches[0];
- pict.linesize[1] = vp->bmp->pitches[2];
- pict.linesize[2] = vp->bmp->pitches[1];
+ linesize[0] = vp->bmp->pitches[0];
+ linesize[1] = vp->bmp->pitches[2];
+ linesize[2] = vp->bmp->pitches[1];
for (i = 0; i < sp->sub.num_rects; i++)
- blend_subrect(&pict, sp->subrects[i],
+ blend_subrect(data, linesize, sp->subrects[i],
vp->bmp->w, vp->bmp->h);
SDL_UnlockYUVOverlay (vp->bmp);
/* if the frame is not skipped, then display it */
if (vp->bmp) {
- AVPicture pict = { { 0 } };
+ uint8_t *data[4];
+ int linesize[4];
/* get a pointer on the bitmap */
SDL_LockYUVOverlay (vp->bmp);
- pict.data[0] = vp->bmp->pixels[0];
- pict.data[1] = vp->bmp->pixels[2];
- pict.data[2] = vp->bmp->pixels[1];
+ data[0] = vp->bmp->pixels[0];
+ data[1] = vp->bmp->pixels[2];
+ data[2] = vp->bmp->pixels[1];
- pict.linesize[0] = vp->bmp->pitches[0];
- pict.linesize[1] = vp->bmp->pitches[2];
- pict.linesize[2] = vp->bmp->pitches[1];
+ linesize[0] = vp->bmp->pitches[0];
+ linesize[1] = vp->bmp->pitches[2];
+ linesize[2] = vp->bmp->pitches[1];
#if CONFIG_AVFILTER
// FIXME use direct rendering
- av_picture_copy(&pict, (AVPicture *)src_frame,
+ av_image_copy(data, linesize, (const uint8_t **)src_frame->data, src_frame->linesize,
src_frame->format, vp->width, vp->height);
#else
{
exit(1);
}
sws_scale(is->img_convert_ctx, src_frame->data, src_frame->linesize,
- 0, vp->height, pict.data, pict.linesize);
+ 0, vp->height, data, linesize);
#endif
/* workaround SDL PITCH_WORKAROUND */
duplicate_right_border_pixels(vp->bmp);
do_exit(cur_stream);
break;
}
+ if (event.button.button == SDL_BUTTON_LEFT) {
+ static int64_t last_mouse_left_click = 0;
+ if (av_gettime_relative() - last_mouse_left_click <= 500000) {
+ toggle_full_screen(cur_stream);
+ cur_stream->force_refresh = 1;
+ last_mouse_left_click = 0;
+ } else {
+ last_mouse_left_click = av_gettime_relative();
+ }
+ }
case SDL_MOUSEMOTION:
if (cursor_hidden) {
SDL_ShowCursor(1);
}
cursor_last_shown = av_gettime_relative();
if (event.type == SDL_MOUSEBUTTONDOWN) {
+ if (event.button.button != SDL_BUTTON_RIGHT)
+ break;
x = event.button.x;
} else {
- if (event.motion.state != SDL_PRESSED)
+ if (!(event.motion.state & SDL_BUTTON_RMASK))
break;
x = event.motion.x;
}
"left/right seek backward/forward 10 seconds\n"
"down/up seek backward/forward 1 minute\n"
"page down/page up seek backward/forward 10 minutes\n"
- "mouse click seek to percentage in file corresponding to fraction of width\n"
+ "right mouse click seek to percentage in file corresponding to fraction of width\n"
+ "left double-click toggle full screen\n"
);
}