Commit ba800def authored by Marton Balint's avatar Marton Balint

ffplay: pass simple integers to calculate_display_rect and set_default_window_size

No change in functionality.
Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 9dd97aa3
...@@ -807,19 +807,21 @@ static void free_subpicture(SubPicture *sp) ...@@ -807,19 +807,21 @@ static void free_subpicture(SubPicture *sp)
avsubtitle_free(&sp->sub); avsubtitle_free(&sp->sub);
} }
static void calculate_display_rect(SDL_Rect *rect, int scr_xleft, int scr_ytop, int scr_width, int scr_height, VideoPicture *vp) static void calculate_display_rect(SDL_Rect *rect,
int scr_xleft, int scr_ytop, int scr_width, int scr_height,
int pic_width, int pic_height, AVRational pic_sar)
{ {
float aspect_ratio; float aspect_ratio;
int width, height, x, y; int width, height, x, y;
if (vp->sar.num == 0) if (pic_sar.num == 0)
aspect_ratio = 0; aspect_ratio = 0;
else else
aspect_ratio = av_q2d(vp->sar); aspect_ratio = av_q2d(pic_sar);
if (aspect_ratio <= 0.0) if (aspect_ratio <= 0.0)
aspect_ratio = 1.0; aspect_ratio = 1.0;
aspect_ratio *= (float)vp->width / (float)vp->height; aspect_ratio *= (float)pic_width / (float)pic_height;
/* XXX: we suppose the screen has a 1.0 pixel ratio */ /* XXX: we suppose the screen has a 1.0 pixel ratio */
height = scr_height; height = scr_height;
...@@ -870,7 +872,7 @@ static void video_image_display(VideoState *is) ...@@ -870,7 +872,7 @@ static void video_image_display(VideoState *is)
} }
} }
calculate_display_rect(&rect, is->xleft, is->ytop, is->width, is->height, vp); calculate_display_rect(&rect, is->xleft, is->ytop, is->width, is->height, vp->width, vp->height, vp->sar);
SDL_DisplayYUVOverlay(vp->bmp, &rect); SDL_DisplayYUVOverlay(vp->bmp, &rect);
...@@ -1077,10 +1079,10 @@ static void sigterm_handler(int sig) ...@@ -1077,10 +1079,10 @@ static void sigterm_handler(int sig)
exit(123); exit(123);
} }
static void set_default_window_size(VideoPicture *vp) static void set_default_window_size(int width, int height, AVRational sar)
{ {
SDL_Rect rect; SDL_Rect rect;
calculate_display_rect(&rect, 0, 0, INT_MAX, vp->height, vp); calculate_display_rect(&rect, 0, 0, INT_MAX, height, width, height, sar);
default_width = rect.w; default_width = rect.w;
default_height = rect.h; default_height = rect.h;
} }
...@@ -1094,7 +1096,7 @@ static int video_open(VideoState *is, int force_set_video_mode, VideoPicture *vp ...@@ -1094,7 +1096,7 @@ static int video_open(VideoState *is, int force_set_video_mode, VideoPicture *vp
else flags |= SDL_RESIZABLE; else flags |= SDL_RESIZABLE;
if (vp && vp->width) if (vp && vp->width)
set_default_window_size(vp); set_default_window_size(vp->width, vp->height, vp->sar);
if (is_full_screen && fs_screen_width) { if (is_full_screen && fs_screen_width) {
w = fs_screen_width; w = fs_screen_width;
...@@ -2876,12 +2878,9 @@ static int read_thread(void *arg) ...@@ -2876,12 +2878,9 @@ static int read_thread(void *arg)
if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) { if (st_index[AVMEDIA_TYPE_VIDEO] >= 0) {
AVStream *st = ic->streams[st_index[AVMEDIA_TYPE_VIDEO]]; AVStream *st = ic->streams[st_index[AVMEDIA_TYPE_VIDEO]];
AVCodecContext *avctx = st->codec; AVCodecContext *avctx = st->codec;
VideoPicture vp = {0}; AVRational sar = av_guess_sample_aspect_ratio(ic, st, NULL);
vp.width = avctx->width; if (avctx->width)
vp.height = avctx->height; set_default_window_size(avctx->width, avctx->height, sar);
vp.sar = av_guess_sample_aspect_ratio(ic, st, NULL);
if (vp.width)
set_default_window_size(&vp);
} }
/* open the streams */ /* open the streams */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment