[vlc-commits] [Git][videolan/vlc][master] 7 commits: video_output: always set the SPU destination in the placed video for SPU-handling displays
Steve Lhomme (@robUx4)
gitlab at videolan.org
Mon Mar 25 13:22:25 UTC 2024
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
63855d99 by Steve Lhomme at 2024-03-25T12:21:29+00:00
video_output: always set the SPU destination in the placed video for SPU-handling displays
It doesn't matter if we scale up or down. They do the same kind of scaling.
- - - - -
653c5ed7 by Steve Lhomme at 2024-03-25T12:21:29+00:00
direct3d11: assume the video area is the same as the "original" area
- - - - -
dda557aa by Steve Lhomme at 2024-03-25T12:21:29+00:00
direct3d9: assume the video area is the same as the "original" area
- - - - -
df71e597 by Steve Lhomme at 2024-03-25T12:21:29+00:00
VLCSampleBufferDisplay: assume the video area is the same as the "original" area
- - - - -
5b65b93e by Steve Lhomme at 2024-03-25T12:21:29+00:00
xcb/render: assume the video area is the same as the "original" area
- - - - -
2b6405c7 by Steve Lhomme at 2024-03-25T12:21:29+00:00
opengl: assume the video area is the same as the "original" area
- - - - -
664f2519 by Steve Lhomme at 2024-03-25T12:21:29+00:00
vout_subpicture: remove write-only original size in rendered subpicture
It was only used by the display modules rendering (scaled) regions.
That was always set to the video placement dimensions in the display, which they already know about.
- - - - -
12 changed files:
- include/vlc_subpicture.h
- modules/video_output/apple/VLCSampleBufferDisplay.m
- modules/video_output/opengl/sub_renderer.c
- modules/video_output/opengl/sub_renderer.h
- modules/video_output/opengl/vout_helper.c
- modules/video_output/win32/direct3d11.cpp
- modules/video_output/win32/direct3d9.c
- modules/video_output/xcb/render.c
- src/misc/subpicture.c
- src/video_output/video_output.c
- src/video_output/vout_subpictures.c
- test/modules/video_output/opengl/sub_renderer.c
Changes:
=====================================
include/vlc_subpicture.h
=====================================
@@ -216,8 +216,6 @@ struct vlc_render_subpicture
{
struct VLC_VECTOR(struct subpicture_region_rendered *) regions; /**< list of regions to render */
int64_t i_order; /** an increasing unique number */
- unsigned i_original_picture_width; /**< original width of the movie */
- unsigned i_original_picture_height;/**< original height of the movie */
};
typedef struct vlc_render_subpicture vlc_render_subpicture;
=====================================
modules/video_output/apple/VLCSampleBufferDisplay.m
=====================================
@@ -404,20 +404,16 @@ static void RenderPicture(vout_display_t *vd, picture_t *pic, vlc_tick_t date) {
}
static CGRect RegionBackingFrame(VLCSampleBufferDisplay* sys,
- const vlc_render_subpicture *subpicture,
const struct subpicture_region_rendered *r)
{
- const float scale_w = (float)(sys->place.width ) / (subpicture->i_original_picture_width );
- const float scale_h = (float)(sys->place.height) / (subpicture->i_original_picture_height);
-
// Invert y coords for CoreGraphics
- const float y = subpicture->i_original_picture_height - scale_h * (r->place.height + r->place.y);
+ const float y = sys->place.height - r->place.height - r->place.y;
return CGRectMake(
- scale_w * r->place.x + sys->place.x,
- /*scale_h */ y + sys->place.y,
- scale_w * r->place.width,
- scale_h * r->place.height
+ r->place.x + sys->place.x,
+ y + sys->place.y,
+ r->place.width,
+ r->place.height
);
}
@@ -455,7 +451,7 @@ static void UpdateSubpictureRegions(vout_display_t *vd,
region.subpicture = sys.subpicture;
region.image = image;
- region.backingFrame = RegionBackingFrame(sys, subpicture, r);
+ region.backingFrame = RegionBackingFrame(sys, r);
[regions addObject:region];
CGDataProviderRelease(provider);
CFRelease(data);
@@ -502,7 +498,7 @@ static bool IsSubpictureDrawNeeded(vout_display_t *vd, const vlc_render_subpictu
VLCSampleBufferSubpictureRegion *region =
sys.subpicture.regions[i++];
- CGRect newRegion = RegionBackingFrame(sys, subpicture, r);
+ CGRect newRegion = RegionBackingFrame(sys, r);
if ( !CGRectEqualToRect(region.backingFrame, newRegion) )
{
=====================================
modules/video_output/opengl/sub_renderer.c
=====================================
@@ -68,6 +68,7 @@ struct vlc_gl_sub_renderer
gl_region_t *regions;
unsigned region_count;
+ unsigned output_width, output_height;
GLuint program_id;
struct {
@@ -130,6 +131,8 @@ vlc_gl_sub_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api,
sr->api = api;
sr->vt = vt;
sr->region_count = 0;
+ sr->output_width = 0;
+ sr->output_height = 0;
sr->regions = NULL;
static const char *const VERTEX_SHADER_SRC =
@@ -223,12 +226,23 @@ vlc_gl_sub_renderer_Delete(struct vlc_gl_sub_renderer *sr)
free(sr);
}
+void
+vlc_gl_sub_renderer_SetOutputSize(struct vlc_gl_sub_renderer *sr,
+ unsigned width, unsigned height)
+{
+ sr->output_width = width;
+ sr->output_height = height;
+}
+
int
vlc_gl_sub_renderer_Prepare(struct vlc_gl_sub_renderer *sr,
const vlc_render_subpicture *subpicture)
{
GL_ASSERT_NOERROR(sr->vt);
+ if (unlikely(sr->output_width == 0 || sr->output_height == 0))
+ return VLC_EINVAL;
+
const struct vlc_gl_interop *interop = sr->interop;
int last_count = sr->region_count;
@@ -261,10 +275,10 @@ vlc_gl_sub_renderer_Prepare(struct vlc_gl_sub_renderer *sr,
glr->tex_height = 1.0;
}
glr->alpha = (float)r->i_alpha / 255;
- glr->left = 2.0 * (r->place.x ) / subpicture->i_original_picture_width - 1.0;
- glr->top = -2.0 * (r->place.y ) / subpicture->i_original_picture_height + 1.0;
- glr->right = 2.0 * (r->place.x + r->place.width ) / subpicture->i_original_picture_width - 1.0;
- glr->bottom = -2.0 * (r->place.y + r->place.height) / subpicture->i_original_picture_height + 1.0;
+ glr->left = 2.0 * (r->place.x ) / sr->output_width - 1.0;
+ glr->top = -2.0 * (r->place.y ) / sr->output_height + 1.0;
+ glr->right = 2.0 * (r->place.x + r->place.width ) / sr->output_width - 1.0;
+ glr->bottom = -2.0 * (r->place.y + r->place.height) / sr->output_height + 1.0;
glr->texture = 0;
/* Try to recycle the textures allocated by the previous
=====================================
modules/video_output/opengl/sub_renderer.h
=====================================
@@ -72,6 +72,13 @@ int
vlc_gl_sub_renderer_Prepare(struct vlc_gl_sub_renderer *sr,
const struct vlc_render_subpicture *subpicture);
+/**
+ * Change the output size
+ */
+void
+vlc_gl_sub_renderer_SetOutputSize(struct vlc_gl_sub_renderer *sr,
+ unsigned width, unsigned height);
+
/**
* Draw the prepared subpicture
*
=====================================
modules/video_output/opengl/vout_helper.c
=====================================
@@ -358,6 +358,7 @@ void vout_display_opengl_SetOutputSize(vout_display_opengl_t *vgl,
/* The renderer, last filter in the chain, necessarily accepts the new
* output size */
assert(ret == VLC_SUCCESS);
+ vlc_gl_sub_renderer_SetOutputSize(vgl->sub_renderer, width, height);
(void) ret;
}
=====================================
modules/video_output/win32/direct3d11.cpp
=====================================
@@ -1646,10 +1646,10 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
video_format_GetTransform(ORIENT_NORMAL, sys->display.orientation));
RECT spuViewport;
- spuViewport.left = (FLOAT) r->place.x * sys->area.place.width / subpicture->i_original_picture_width;
- spuViewport.top = (FLOAT) r->place.y * sys->area.place.height / subpicture->i_original_picture_height;
- spuViewport.right = (FLOAT) (r->place.x + r->place.width) * sys->area.place.width / subpicture->i_original_picture_width;
- spuViewport.bottom = (FLOAT) (r->place.y + r->place.height) * sys->area.place.height / subpicture->i_original_picture_height;
+ spuViewport.left = r->place.x;
+ spuViewport.top = r->place.y;
+ spuViewport.right = r->place.x + r->place.width;
+ spuViewport.bottom = r->place.y + r->place.height;
/* move the SPU inside the video area */
spuViewport.left += sys->area.place.x;
=====================================
modules/video_output/win32/direct3d9.c
=====================================
@@ -954,14 +954,11 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
}
/* Map the subpicture to sys->sys.sys.place */
- const float scale_w = (float)(sys->area.place.width ) / subpicture->i_original_picture_width;
- const float scale_h = (float)(sys->area.place.height) / subpicture->i_original_picture_height;
-
RECT rect_in_display;
- rect_in_display.left = scale_w * r->place.x;
- rect_in_display.right = scale_w * (r->place.x + r->place.width);
- rect_in_display.top = scale_h * r->place.y;
- rect_in_display.bottom = scale_h * (r->place.y + r->place.height);
+ rect_in_display.left = r->place.x;
+ rect_in_display.right = r->place.x + r->place.width;
+ rect_in_display.top = r->place.y;
+ rect_in_display.bottom = r->place.y + r->place.height;
rect_in_display.left += sys->area.place.x;
rect_in_display.right += sys->area.place.x;
=====================================
modules/video_output/xcb/render.c
=====================================
@@ -172,15 +172,13 @@ static void RenderRegion(vout_display_t *vd, const vlc_render_subpicture *subpic
sys->picture.subpic_crop, alpha_color,
ARRAY_SIZE(rects), rects);
- const float scale_w = (float)(place->width ) / (subpic->i_original_picture_width );
- const float scale_h = (float)(place->height) / (subpic->i_original_picture_height);
/* Mask in the original alpha channel then renver over the scaled pixmap.
* Mask (pre)multiplies RGB channels and restores the alpha channel.
*/
- int_fast16_t dx = place->x + reg->place.x * scale_w;
- int_fast16_t dy = place->y + reg->place.y * scale_h;
- uint_fast16_t dw = (reg->place.width) * scale_w;
- uint_fast16_t dh = (reg->place.height) * scale_h;
+ int_fast16_t dx = place->x + reg->place.x;
+ int_fast16_t dy = place->y + reg->place.y;
+ uint_fast16_t dw = reg->place.width;
+ uint_fast16_t dh = reg->place.height;
xcb_render_transform_t transform = {
0, 0, 0,
=====================================
src/misc/subpicture.c
=====================================
@@ -103,8 +103,6 @@ vlc_render_subpicture *vlc_render_subpicture_New( void )
vlc_render_subpicture *p_subpic = malloc( sizeof(*p_subpic) );
if( unlikely(p_subpic == NULL ) )
return NULL;
- p_subpic->i_original_picture_width = 0;
- p_subpic->i_original_picture_height = 0;
vlc_vector_init(&p_subpic->regions);
return p_subpic;
}
=====================================
src/video_output/video_output.c
=====================================
@@ -1178,14 +1178,12 @@ static int PrerenderPicture(vout_thread_sys_t *sys, picture_t *filtered,
vout_display_PlacePicture(&place, vd->source, &vd->cfg->display);
fmt_spu = *vd->source;
- if (fmt_spu.i_width * fmt_spu.i_height < place.width * place.height) {
- fmt_spu.i_sar_num = vd->cfg->display.sar.num;
- fmt_spu.i_sar_den = vd->cfg->display.sar.den;
- fmt_spu.i_width =
- fmt_spu.i_visible_width = place.width;
- fmt_spu.i_height =
- fmt_spu.i_visible_height = place.height;
- }
+ fmt_spu.i_sar_num = vd->cfg->display.sar.num;
+ fmt_spu.i_sar_den = vd->cfg->display.sar.den;
+ fmt_spu.i_width =
+ fmt_spu.i_visible_width = place.width;
+ fmt_spu.i_height =
+ fmt_spu.i_visible_height = place.height;
} else {
if (blending_before_converter) {
fmt_spu = *vd->source;
=====================================
src/video_output/vout_subpictures.c
=====================================
@@ -1270,8 +1270,6 @@ static vlc_render_subpicture *SpuRenderSubpictures(spu_t *spu,
if (unlikely(output == NULL))
return NULL;
output->i_order = p_entries[i_subpicture - 1].subpic->i_order;
- output->i_original_picture_width = fmt_dst->i_visible_width;
- output->i_original_picture_height = fmt_dst->i_visible_height;
struct subpicture_region_rendered *output_last_ptr;
/* Allocate area array for subtitle overlap */
=====================================
test/modules/video_output/opengl/sub_renderer.c
=====================================
@@ -173,10 +173,10 @@ static void test_opengl_offscreen(
memcpy(&picture->p[0].p_pixels[0 * 4 + picture->p[0].i_pitch], blue, sizeof(blue));
memcpy(&picture->p[0].p_pixels[1 * 4 + picture->p[0].i_pitch], white, sizeof(white));
+ vlc_gl_sub_renderer_SetOutputSize(sr, 4, 4);
+
vlc_render_subpicture *subpicture = vlc_render_subpicture_New();
assert(subpicture != NULL);
- subpicture->i_original_picture_width = 4;
- subpicture->i_original_picture_height = 4;
struct subpicture_region_rendered *p_region = calloc(1, sizeof(*p_region));
assert(p_region != NULL);
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bb88cd5aa904eeb22b67117f6096dfdf23a6db62...664f2519663464501d800edd98669857175136e5
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/bb88cd5aa904eeb22b67117f6096dfdf23a6db62...664f2519663464501d800edd98669857175136e5
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