diff options
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux_disc.c | 5 | ||||
-rw-r--r-- | demux/demux_lavf.c | 8 | ||||
-rw-r--r-- | demux/demux_mkv.c | 13 | ||||
-rw-r--r-- | demux/stheader.h | 2 |
4 files changed, 16 insertions, 12 deletions
diff --git a/demux/demux_disc.c b/demux/demux_disc.c index b994b3cf11..4c27393f5c 100644 --- a/demux/demux_disc.c +++ b/demux/demux_disc.c @@ -147,7 +147,10 @@ static void add_streams(demuxer_t *demuxer) double ar; if (stream_control(demuxer->stream, STREAM_CTRL_GET_ASPECT_RATIO, &ar) == STREAM_OK) - sh->video->aspect = ar; + { + sh->video->par_w = 1728 * ar; // being lazy here + sh->video->par_h = 1728 / ar; + } } if (src->audio) sh->audio = src->audio; diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 0eb93b6e91..ea66ded09b 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -589,12 +589,8 @@ static void handle_stream(demuxer_t *demuxer, int i) sh_video->fps = fps; if (priv->format_hack.image_format) sh_video->fps = demuxer->opts->mf_fps; - if (st->sample_aspect_ratio.num) - sh_video->aspect = codec->width * st->sample_aspect_ratio.num - / (float)(codec->height * st->sample_aspect_ratio.den); - else - sh_video->aspect = codec->width * codec->sample_aspect_ratio.num - / (float)(codec->height * codec->sample_aspect_ratio.den); + sh_video->par_w = st->sample_aspect_ratio.num; + sh_video->par_h = st->sample_aspect_ratio.den; uint8_t *sd = av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, NULL); if (sd) { diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c index a11691b317..562bddbfc6 100644 --- a/demux/demux_mkv.c +++ b/demux/demux_mkv.c @@ -48,6 +48,7 @@ #include "misc/bstr.h" #include "stream/stream.h" #include "video/csputils.h" +#include "video/mp_image.h" #include "demux.h" #include "stheader.h" #include "ebml.h" @@ -1367,10 +1368,14 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track) sh_v->fps = track->v_frate; sh_v->disp_w = track->v_width; sh_v->disp_h = track->v_height; - uint32_t dw = track->v_dwidth_set ? track->v_dwidth : track->v_width; - uint32_t dh = track->v_dheight_set ? track->v_dheight : track->v_height; - sh_v->aspect = (dw && dh) ? (double) dw / dh : 0; - MP_VERBOSE(demuxer, "Aspect: %f\n", sh_v->aspect); + + int dw = track->v_dwidth_set ? track->v_dwidth : track->v_width; + int dh = track->v_dheight_set ? track->v_dheight : track->v_height; + struct mp_image_params p = {.w = track->v_width, .h = track->v_height}; + mp_image_params_set_dsize(&p, dw, dh); + sh_v->par_w = p.p_w; + sh_v->par_h = p.p_h; + sh_v->stereo_mode = track->stereo_mode; return 0; diff --git a/demux/stheader.h b/demux/stheader.h index 7a11832c24..e325b52bf1 100644 --- a/demux/stheader.h +++ b/demux/stheader.h @@ -83,7 +83,7 @@ typedef struct sh_audio { typedef struct sh_video { bool avi_dts; // use DTS timing; first frame and DTS is 0 float fps; // frames per second (set only if constant fps) - float aspect; // aspect ratio stored in the file (for prescaling) + int par_w, par_h; // pixel aspect ratio (0 if unknown/square) int bits_per_coded_sample; int disp_w, disp_h; // display size int rotate; // intended display rotation, in degrees, [0, 359] |