[vlc-commits] [Git][videolan/vlc][master] 18 commits: display: simplify/harmonize multiple control error checks
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sat Sep 21 08:31:19 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
4ca19697 by Steve Lhomme at 2024-09-21T08:13:50+00:00
display: simplify/harmonize multiple control error checks
We always keep the last error we received.
- - - - -
8ff8e77c by Steve Lhomme at 2024-09-21T08:13:50+00:00
test: add mandatory control callback in vlc_display_operations
- - - - -
228f134c by Steve Lhomme at 2024-09-21T08:13:50+00:00
video_output: always set the Display Aspect Ratio on display module creation
0/0 is a valid value, it means use the aspect ratio of the source format.
vout_SetDisplayAspect() does sanity checks.
- - - - -
41b35814 by Steve Lhomme at 2024-09-21T08:13:50+00:00
vout: use a define for the Display Aspect Ratio to match the video Aspect Ratio
- - - - -
9577444e by Steve Lhomme at 2024-09-21T08:13:50+00:00
direct3d11: respect the source aspect ratio/crop changes
When no upscaling we don't use vd->source to place the picture but
sys->picQuad.quad_fmt which is a local copy of vd->source in that case.
- - - - -
a0216b56 by Steve Lhomme at 2024-09-21T08:13:50+00:00
libplacebo: use vd->source to place the video
When the aspect ratio changes, it's set in vd->source, not vd->fmt.
The only potential difference between vd->source and vd->fmt
in libplacebo is the chroma set in Open().
- - - - -
af212b9e by Steve Lhomme at 2024-09-21T08:13:50+00:00
vout/drm: use vd->source to place the video
When the aspect ratio changes, it's set in vd->source, not vd->fmt.
The only potential differences between vd->source and vd->fmt
in vout/drm are the chroma and rotation set in Open().
The rotation is applied to vd->source anyway when placing pictures.
- - - - -
603c0c14 by Steve Lhomme at 2024-09-21T08:13:50+00:00
xcb/render: explicitly use vd->source to place the video
- - - - -
4c26591a by Steve Lhomme at 2024-09-21T08:13:50+00:00
mmal/vout: use vd->source to place the video
When the aspect ratio changes, it's set in vd->source, not vd->fmt.
The only potential difference between vd->source and vd->fmt
in mmal/vout is the chroma set in OpenMmalVout() and vd_reset_pictures().
The rest of the code is simplified accordingly.
- - - - -
c10f5f62 by Steve Lhomme at 2024-09-21T08:13:50+00:00
vout_intf: check the ratio is not 0:0 or x:y
We should not check the pointer is not NULL, this is never the case.
Regression from ef2c9f7818409ab17b13f276109f6dff4bf09e3f.
- - - - -
90932eb0 by Steve Lhomme at 2024-09-21T08:13:50+00:00
video_output: keep the forced Display Aspect Ratio
When the source aspect ratio changes, this value is lost and can't
tell if the sar in vd->source is from a forced DAR or from the original source.
- - - - -
730a97a6 by Steve Lhomme at 2024-09-21T08:13:50+00:00
display: use the forced DAR when the source aspect ratio changes
The fixed_src value was only used when "forced_dar->num == 0".
The only possible case the forced DAR would have this value is
when using the source aspect ratio for the DAR.
The new code is equivalent to that check, even for a forced 1:0 DAR.
- - - - -
6f4775ce by Steve Lhomme at 2024-09-21T08:13:50+00:00
display: let vout_SetSourceAspect() set the source aspect ratio
It's supposed to return an error if something is wrong. We should not do things on its back.
- - - - -
ace3b5ac by Steve Lhomme at 2024-09-21T08:13:50+00:00
display: don't call vout_SetSourceAspect() the user selects source Aspect Ratio
At this point we don't know the source SAR anymore.
vout_SetSourceAspect() will be called for the next displayed picture during
vout_UpdateDisplaySourceProperties().
We should only call vout_SetSourceAspect() with actual SAR values.
- - - - -
3acd6532 by Steve Lhomme at 2024-09-21T08:13:50+00:00
display: validate vout_SetSourceAspect() only gets actual SAR values
The values come from either VoutFixFormatAR() or vout_SetDisplayAspect()
which filters the values via GetAspectRatio().
- - - - -
dbb03f82 by Steve Lhomme at 2024-09-21T08:13:50+00:00
display: check the SAR changed in vout_SetSourceAspect()
So we never send the event if the value didn't change.
- - - - -
4df3783b by Steve Lhomme at 2024-09-21T08:13:50+00:00
display: avoid potential multiplying overflow in 32-bit
- - - - -
136c82e9 by Steve Lhomme at 2024-09-21T08:13:50+00:00
libvlc: define what is the default aspect ratio (video source)
- - - - -
12 changed files:
- include/vlc/libvlc_media_player.h
- modules/hw/mmal/vout.c
- modules/video_output/drm/display.c
- modules/video_output/libplacebo/display.c
- modules/video_output/win32/direct3d11.cpp
- modules/video_output/xcb/render.c
- src/video_output/display.c
- src/video_output/display.h
- src/video_output/video_output.c
- src/video_output/vout_internal.h
- src/video_output/vout_intf.c
- test/src/video_output/video_output.c
Changes:
=====================================
include/vlc/libvlc_media_player.h
=====================================
@@ -1904,7 +1904,7 @@ LIBVLC_API char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi );
* Set new video aspect ratio.
*
* \param p_mi the media player
- * \param psz_aspect new video aspect-ratio or NULL to reset to default
+ * \param psz_aspect new video aspect-ratio or NULL to reset to source aspect ratio
* \note Invalid aspect ratios are ignored.
*/
LIBVLC_API void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi, const char *psz_aspect );
=====================================
modules/hw/mmal/vout.c
=====================================
@@ -462,7 +462,7 @@ static MMAL_STATUS_T isp_check(vout_display_t * const vd, vout_display_sys_t * c
/* TV service */
static void tvservice_cb(void *callback_data, uint32_t reason, uint32_t param1,
uint32_t param2);
-static void adjust_refresh_rate(vout_display_t *vd, const video_format_t *fmt);
+static void adjust_refresh_rate(vout_display_t *vd);
static int set_latency_target(vout_display_t *vd, bool enable);
// Mmal
@@ -518,7 +518,7 @@ place_to_mmal_rect(const vout_display_place_t place)
}
static void
-place_dest(vout_display_t *vd, const video_format_t * fmt)
+place_dest(vout_display_t *vd)
{
vout_display_sys_t * const sys = vd->sys;
// Ignore what VLC thinks might be going on with display size
@@ -528,12 +528,12 @@ place_dest(vout_display_t *vd, const video_format_t * fmt)
dp.width = sys->display_width;
dp.height = sys->display_height;
dp.fitting = VLC_VIDEO_FIT_SMALLER;
- vout_display_PlacePicture(&place, fmt, &dp);
+ vout_display_PlacePicture(&place, vd->source, &dp);
sys->dest_rect = place_to_mmal_rect(place);
}
-static int configure_display(vout_display_t *vd, const video_format_t *fmt)
+static int configure_display(vout_display_t *vd)
{
vout_display_sys_t * const sys = vd->sys;
MMAL_DISPLAYREGION_T display_region;
@@ -541,8 +541,8 @@ static int configure_display(vout_display_t *vd, const video_format_t *fmt)
isp_check(vd, sys);
- sys->input->format->es->video.par.num = fmt->i_sar_num;
- sys->input->format->es->video.par.den = fmt->i_sar_den;
+ sys->input->format->es->video.par.num = vd->source->i_sar_num;
+ sys->input->format->es->video.par.den = vd->source->i_sar_den;
status = mmal_port_format_commit(sys->input);
if (status != MMAL_SUCCESS) {
@@ -550,7 +550,7 @@ static int configure_display(vout_display_t *vd, const video_format_t *fmt)
sys->input->name, status, mmal_status_to_string(status));
return -EINVAL;
}
- place_dest(vd, fmt);
+ place_dest(vd);
display_region.hdr.id = MMAL_PARAMETER_DISPLAYREGION;
display_region.hdr.size = sizeof(MMAL_DISPLAYREGION_T);
@@ -571,7 +571,7 @@ static int configure_display(vout_display_t *vd, const video_format_t *fmt)
sys->adjust_refresh_rate = var_InheritBool(vd, MMAL_ADJUST_REFRESHRATE_NAME);
sys->native_interlaced = var_InheritBool(vd, MMAL_NATIVE_INTERLACED);
if (sys->adjust_refresh_rate) {
- adjust_refresh_rate(vd, fmt);
+ adjust_refresh_rate(vd);
set_latency_target(vd, true);
}
@@ -691,7 +691,7 @@ static int vd_control(vout_display_t *vd, int query)
case VOUT_DISPLAY_CHANGE_SOURCE_CROP:
case VOUT_DISPLAY_CHANGE_SOURCE_PLACE:
{
- if (configure_display(vd, vd->source) >= 0)
+ if (configure_display(vd) >= 0)
ret = VLC_SUCCESS;
break;
}
@@ -786,7 +786,7 @@ static void vd_prepare(vout_display_t *vd, picture_t *p_pic,
sys->b_progressive = p_pic->b_progressive;
sys->i_frame_rate = p_pic->format.i_frame_rate;
sys->i_frame_rate_base = p_pic->format.i_frame_rate_base;
- configure_display(vd, &p_pic->format);
+ configure_display(vd);
}
// Subpics can either turn up attached to the main pic or in the
@@ -873,14 +873,14 @@ static int set_latency_target(vout_display_t *vd, bool enable)
return VLC_SUCCESS;
}
-static void adjust_refresh_rate(vout_display_t *vd, const video_format_t *fmt)
+static void adjust_refresh_rate(vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
TV_DISPLAY_STATE_T display_state;
TV_SUPPORTED_MODE_NEW_T supported_modes[VC_TV_MAX_MODE_IDS];
char response[20]; /* answer is hvs_update_fields=%1d */
int num_modes;
- double frame_rate = (double)fmt->i_frame_rate / fmt->i_frame_rate_base;
+ double frame_rate = (double)vd->source->i_frame_rate / vd->source->i_frame_rate_base;
int best_id = -1;
double best_score, score;
int i;
@@ -898,8 +898,8 @@ static void adjust_refresh_rate(vout_display_t *vd, const video_format_t *fmt)
mode->scan_mode == HDMI_INTERLACED)
continue;
} else {
- if (mode->width != vd->fmt->i_visible_width ||
- mode->height != vd->fmt->i_visible_height)
+ if (mode->width != vd->source->i_visible_width ||
+ mode->height != vd->source->i_visible_height)
continue;
if (mode->scan_mode != sys->b_progressive ? HDMI_NONINTERLACED : HDMI_INTERLACED)
continue;
@@ -1184,7 +1184,7 @@ static int OpenMmalVout(vout_display_t *vd,
sys->display_height = vd->cfg->display.height;
}
- place_dest(vd, vd->source); // Sets sys->dest_rect
+ place_dest(vd); // Sets sys->dest_rect
display_region.hdr.id = MMAL_PARAMETER_DISPLAYREGION;
display_region.hdr.size = sizeof(MMAL_DISPLAYREGION_T);
=====================================
modules/video_output/drm/display.c
=====================================
@@ -104,7 +104,7 @@ static void Display(vout_display_t *vd, picture_t *picture)
picture_t *pic = sys->buffers[sys->front_buf];
vout_display_place_t place;
- vout_display_PlacePicture(&place, vd->fmt, &vd->cfg->display);
+ vout_display_PlacePicture(&place, vd->source, &vd->cfg->display);
struct drm_mode_set_plane sp = {
.plane_id = sys->plane_id,
=====================================
modules/video_output/libplacebo/display.c
=====================================
@@ -297,7 +297,7 @@ static void PictureRender(vout_display_t *vd, picture_t *pic,
// Set the target crop dynamically based on the swapchain flip state
vout_display_place_t place;
- vout_display_PlacePicture(&place, vd->fmt, &vd->cfg->display);
+ vout_display_PlacePicture(&place, vd->source, &vd->cfg->display);
if (need_vflip)
{
place.y = place.height + place.y;
=====================================
modules/video_output/win32/direct3d11.cpp
=====================================
@@ -636,6 +636,7 @@ static int Control(vout_display_t *vd, int query)
{
vout_display_sys_t *sys = static_cast<vout_display_sys_t *>(vd->sys);
+ bool use_scaler = false;
if (sys->upscaleMode == upscale_VideoProcessor || sys->upscaleMode == upscale_SuperResolution)
{
D3D11_UpscalerUpdate(VLC_OBJECT(vd), sys->scaleProc, sys->d3d_dev,
@@ -652,9 +653,21 @@ static int Control(vout_display_t *vd, int query)
sys->picQuad.generic.i_width = sys->picQuad.quad_fmt.i_width;
sys->picQuad.generic.i_height = sys->picQuad.quad_fmt.i_height;
+
+ use_scaler = true;
}
}
+ if (!use_scaler)
+ {
+ sys->picQuad.quad_fmt.i_sar_num = vd->source->i_sar_num;
+ sys->picQuad.quad_fmt.i_sar_den = vd->source->i_sar_den;
+ sys->picQuad.quad_fmt.i_x_offset = vd->source->i_x_offset;
+ sys->picQuad.quad_fmt.i_y_offset = vd->source->i_y_offset;
+ sys->picQuad.quad_fmt.i_visible_width = vd->source->i_visible_width;
+ sys->picQuad.quad_fmt.i_visible_height = vd->source->i_visible_height;
+ }
+
CommonControl( vd, &sys->area, query );
if ( sys->area.place_changed )
=====================================
modules/video_output/xcb/render.c
=====================================
@@ -319,7 +319,7 @@ static void CreateBuffers(vout_display_t *vd)
sys->format.argb, 0, NULL);
vout_display_place_t *place = &sys->place;
- vout_display_PlacePicture(place, fmt, &vd->cfg->display);
+ vout_display_PlacePicture(place, vd->source, &vd->cfg->display);
/* Homogeneous coordinates transform from destination(place)
* to source(fmt) */
=====================================
src/video_output/display.c
=====================================
@@ -249,6 +249,7 @@ typedef struct {
struct vout_crop crop;
/* */
+ vlc_rational_t dar;
video_format_t source; // format coming from the decoder
video_format_t display_fmt; // format required on the input of the display module
vlc_video_context *src_vctx;
@@ -458,6 +459,7 @@ static int vout_UpdateSourceCrop(vout_display_t *vd)
{
vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
unsigned left, top, right, bottom;
+ int err1 = VLC_SUCCESS, err2;
video_format_Print(VLC_OBJECT(vd), "SOURCE ", &osys->source);
@@ -505,46 +507,55 @@ static int vout_UpdateSourceCrop(vout_display_t *vd)
bool place_changed = PlaceVideoInDisplay(osys);
- int res1 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_CROP);
+ err2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_CROP);
+ if (err2 != VLC_SUCCESS)
+ err1 = err2;
+
if (place_changed)
{
- int res2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
- if (res2 != VLC_SUCCESS)
- res1 = res2;
+ err2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
+ if (err2 != VLC_SUCCESS)
+ err1 = err2;
}
- return res1;
+ return err1;
}
static int vout_SetSourceAspect(vout_display_t *vd,
unsigned sar_num, unsigned sar_den)
{
vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
- int err1, err2 = VLC_SUCCESS;
+ int err1 = VLC_SUCCESS, err2;
- if (sar_num > 0 && sar_den > 0) {
- osys->source.i_sar_num = sar_num;
- osys->source.i_sar_den = sar_den;
- }
+ assert(sar_num > 0 && sar_den > 0);
+ if (osys->source.i_sar_num * sar_den == osys->source.i_sar_den * sar_num)
+ // value unchanged
+ return err1;
+
+ osys->source.i_sar_num = sar_num;
+ osys->source.i_sar_den = sar_den;
bool place_changed = PlaceVideoInDisplay(osys);
- err1 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_ASPECT);
+ err2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_ASPECT);
+ if (err2 != VLC_SUCCESS)
+ err1 = err2;
/* If a crop ratio is requested, recompute the parameters */
if (osys->crop.mode != VOUT_CROP_NONE)
+ {
err2 = vout_UpdateSourceCrop(vd);
+ if (err2 != VLC_SUCCESS)
+ err1 = err2;
+ }
if (place_changed)
{
- int res2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
- if (res2 != VLC_SUCCESS)
- err1 = res2;
+ err2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
+ if (err2 != VLC_SUCCESS)
+ err1 = err2;
}
- if (err1 != VLC_SUCCESS)
- return err1;
-
- return err2;
+ return err1;
}
void VoutFixFormatAR(video_format_t *fmt)
@@ -557,23 +568,17 @@ void VoutFixFormatAR(video_format_t *fmt)
}
}
-void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *source, const vlc_rational_t *forced_dar)
+void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *source)
{
vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
- int err1 = VLC_SUCCESS, err2 = VLC_SUCCESS;
-
- video_format_t fixed_src = *source;
- VoutFixFormatAR( &fixed_src );
- if (fixed_src.i_sar_num * osys->source.i_sar_den !=
- fixed_src.i_sar_den * osys->source.i_sar_num) {
-
- if (forced_dar->num == 0) {
- osys->source.i_sar_num = fixed_src.i_sar_num;
- osys->source.i_sar_den = fixed_src.i_sar_den;
-
- err1 = vout_SetSourceAspect(vd, osys->source.i_sar_num,
- osys->source.i_sar_den);
- }
+ int err1 = VLC_SUCCESS, err2;
+
+ if (osys->dar.den == VLC_DAR_FROM_SOURCE.den && osys->dar.num == VLC_DAR_FROM_SOURCE.num) {
+ video_format_t fixed_src = *source;
+ VoutFixFormatAR( &fixed_src );
+ err2 = vout_SetSourceAspect(vd, fixed_src.i_sar_num, fixed_src.i_sar_den);
+ if (err2 != VLC_SUCCESS)
+ err1 = err2;
}
if (source->i_x_offset != osys->source.i_x_offset ||
source->i_y_offset != osys->source.i_y_offset ||
@@ -585,31 +590,36 @@ void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t
/* Force the vout to reapply the current user crop settings
* over the new decoder crop settings. */
err2 = vout_UpdateSourceCrop(vd);
+ if (err2 != VLC_SUCCESS)
+ err1 = err2;
}
- if (err1 != VLC_SUCCESS || err2 != VLC_SUCCESS)
+ if (err1 != VLC_SUCCESS)
vout_display_Reset(vd);
}
void vout_display_SetSize(vout_display_t *vd, unsigned width, unsigned height)
{
vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
+ int err1 = VLC_SUCCESS, err2;
osys->cfg.display.width = width;
osys->cfg.display.height = height;
bool place_changed = PlaceVideoInDisplay(osys);
- int res1 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_SIZE);
+ err2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_DISPLAY_SIZE);
+ if (err2 != VLC_SUCCESS)
+ err1 = err2;
if (place_changed)
{
- int res2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
- if (res2 != VLC_SUCCESS)
- res1 = res2;
+ err2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
+ if (err2 != VLC_SUCCESS)
+ err1 = err2;
}
- if (res1 != VLC_SUCCESS)
+ if (err1 != VLC_SUCCESS)
vout_display_Reset(vd);
}
@@ -625,8 +635,8 @@ void vout_SetDisplayFitting(vout_display_t *vd, enum vlc_video_fitting fit)
bool place_changed = PlaceVideoInDisplay(osys);
if (place_changed)
{
- int res2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
- if (res2 != VLC_SUCCESS)
+ int err1 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
+ if (err1 != VLC_SUCCESS)
vout_display_Reset(vd);
}
}
@@ -648,8 +658,8 @@ void vout_SetDisplayZoom(vout_display_t *vd, unsigned num, unsigned den)
bool place_changed = PlaceVideoInDisplay(osys);
if (place_changed)
{
- int res2 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
- if (res2 != VLC_SUCCESS)
+ int err1 = vout_display_Control(vd, VOUT_DISPLAY_CHANGE_SOURCE_PLACE);
+ if (err1 != VLC_SUCCESS)
vout_display_Reset(vd);
}
}
@@ -657,18 +667,25 @@ void vout_SetDisplayZoom(vout_display_t *vd, unsigned num, unsigned den)
void vout_SetDisplayAspect(vout_display_t *vd, unsigned dar_num, unsigned dar_den)
{
vout_display_priv_t *osys = container_of(vd, vout_display_priv_t, display);
+ osys->dar = (vlc_rational_t){dar_num, dar_den};
+
+ if (dar_num == VLC_DAR_FROM_SOURCE.num && dar_den == VLC_DAR_FROM_SOURCE.den)
+ // use the source aspect ratio that we don't have yet
+ // see vout_UpdateDisplaySourceProperties()
+ return;
unsigned sar_num, sar_den;
- if (dar_num > 0 && dar_den > 0) {
- sar_num = dar_num * osys->source.i_visible_height;
- sar_den = dar_den * osys->source.i_visible_width;
- vlc_ureduce(&sar_num, &sar_den, sar_num, sar_den, 0);
+ if (unlikely(dar_num == 0 || dar_den == 0)) {
+ // bogus values should be filtered in GetAspectRatio()
+ vlc_assert_unreachable();
} else {
- sar_num = 0;
- sar_den = 0;
+ vlc_ureduce(&sar_num, &sar_den,
+ (uint64_t)dar_num * osys->source.i_visible_height,
+ (uint64_t)dar_den * osys->source.i_visible_width, 0);
}
- if (vout_SetSourceAspect(vd, sar_num, sar_den) != VLC_SUCCESS)
+ int err1 = vout_SetSourceAspect(vd, sar_num, sar_den);
+ if (err1 != VLC_SUCCESS)
vout_display_Reset(vd);
}
@@ -680,7 +697,8 @@ void vout_SetDisplayCrop(vout_display_t *vd,
if (!vout_CropEqual(crop, &osys->crop)) {
osys->crop = *crop;
- if (vout_UpdateSourceCrop(vd) != VLC_SUCCESS)
+ int err1 = vout_UpdateSourceCrop(vd);
+ if (err1 != VLC_SUCCESS)
vout_display_Reset(vd);
}
}
=====================================
src/video_output/display.h
=====================================
@@ -22,5 +22,5 @@
#include "vout_wrapper.h"
-void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *, const vlc_rational_t *forced_dar);
+void vout_UpdateDisplaySourceProperties(vout_display_t *vd, const video_format_t *);
void VoutFixFormatAR(video_format_t *);
=====================================
src/video_output/video_output.c
=====================================
@@ -1301,7 +1301,7 @@ static int PrerenderPicture(vout_thread_sys_t *sys, picture_t *filtered,
}
/* Render the direct buffer */
- vout_UpdateDisplaySourceProperties(vd, &todisplay->format, &sys->source.dar);
+ vout_UpdateDisplaySourceProperties(vd, &todisplay->format);
todisplay = vout_ConvertForDisplay(vd, todisplay);
if (todisplay == NULL) {
@@ -1828,8 +1828,7 @@ static int vout_Start(vout_thread_sys_t *vout, vlc_video_context *vctx, const vo
vout_SetDisplayCrop(sys->display, &crop);
- if (num != 0 && den != 0)
- vout_SetDisplayAspect(sys->display, num, den);
+ vout_SetDisplayAspect(sys->display, num, den);
vlc_queuedmutex_unlock(&sys->display_lock);
sys->displayed.current = NULL;
@@ -2137,8 +2136,7 @@ vout_thread_t *vout_Create(vlc_object_t *object)
}
video_format_Init(&sys->original, 0);
- sys->source.dar.num = 0;
- sys->source.dar.den = 0;
+ sys->source.dar = VLC_DAR_FROM_SOURCE;
sys->source.crop.mode = VOUT_CROP_NONE;
sys->snapshot = vout_snapshot_New();
vout_statistic_Init(&sys->statistic);
=====================================
src/video_output/vout_internal.h
=====================================
@@ -30,6 +30,9 @@
typedef struct input_thread_t input_thread_t;
typedef struct vlc_spu_highlight_t vlc_spu_highlight_t;
+///< Use the aspect ratio from the source video format
+#define VLC_DAR_FROM_SOURCE ((vlc_rational_t){0, 0})
+
/**
* Vout configuration
*/
=====================================
src/video_output/vout_intf.c
=====================================
@@ -569,10 +569,11 @@ static int CropBorderCallback(vlc_object_t *object, char const *cmd,
bool GetAspectRatio(const char *ar_str, unsigned *num, unsigned *den)
{
if (sscanf(ar_str, "%u:%u", num, den) == 2 &&
- (num != 0) == (den != 0))
+ (*num != 0) == (*den != 0))
return true;
else if (*ar_str == '\0') {
- *num = *den = 0;
+ *num = VLC_DAR_FROM_SOURCE.num;
+ *den = VLC_DAR_FROM_SOURCE.den;
return true;
}
return false;
=====================================
test/src/video_output/video_output.c
=====================================
@@ -170,12 +170,20 @@ static void Display(vout_display_t *vd, picture_t *picture)
(void) picture;
}
+static int Control(vout_display_t *vd, int query)
+{
+ (void) vd;
+ (void) query;
+ return VLC_SUCCESS;
+}
+
static int OpenDisplay(vout_display_t *vd, video_format_t *fmtp,
struct vlc_video_context *vctx)
{
static const struct vlc_display_operations ops =
{
.display = Display,
+ .control = Control,
};
vd->ops = &ops;
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7341cf3149666f2490bcfa27af9b997cde05c21a...136c82e9ad1ac47a23f2f6879b6f6314de45b1da
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/7341cf3149666f2490bcfa27af9b997cde05c21a...136c82e9ad1ac47a23f2f6879b6f6314de45b1da
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list