Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
6b444b86 by Steve Lhomme at 2024-03-18T11:22:04+00:00
libplacebo: fix region cropping

Missing from 41525773d6632cef914390b61f431e8175823205. It was probably broken
before that.

- - - - -
d3bcf9c5 by Steve Lhomme at 2024-03-18T11:22:04+00:00
libplacebo: regroup vlc_placebo_PlaneData and vlc_placebo_PlaneFormat

Since we're only keeping the visible part of the picture, we need to be 
aware
of the pixel offset for each plane. The VLC planes keep the visible extent, but
not the position of the first visible pixels. We need to compute it ourselves.

- - - - -
e57ef838 by Steve Lhomme at 2024-03-18T11:22:04+00:00
libplacebo: remove always NULL parameter

Following 4187faaaf3b93f479d5987758e3489bd03d3c897.

- - - - -


3 changed files:

- modules/video_output/libplacebo/display.c
- modules/video_output/libplacebo/utils.c
- modules/video_output/libplacebo/utils.h


Changes:

=====================================
modules/video_output/libplacebo/display.c
=====================================
@@ -265,7 +265,7 @@ static void PictureRender(vout_display_t *vd, picture_t 
*pic,
 
     // Upload the image data for each plane
     struct pl_plane_data data[4];
-    if (!vlc_placebo_PlaneData(pic, data, NULL)) {
+    if (!vlc_placebo_PlaneData(pic, data)) {
         // This should never happen, in theory
         assert(!"Failed processing the picture_t into pl_plane_data!?");
     }
@@ -390,7 +390,7 @@ static void PictureRender(vout_display_t *vd, picture_t 
*pic,
         vlc_vector_foreach(r, &subpicture->regions) {
             assert(r->p_picture->i_planes == 1);
             struct pl_plane_data subdata[4];
-            if (!vlc_placebo_PlaneData(r->p_picture, subdata, NULL))
+            if (!vlc_placebo_PlaneData(r->p_picture, subdata))
                 assert(!"Failed processing the subpicture_t into 
pl_plane_data!?");
 
             if (!pl_upload_plane(gpu, NULL, &sys->overlay_tex[i], subdata)) {
@@ -411,8 +411,10 @@ static void PictureRender(vout_display_t *vd, picture_t 
*pic,
 
             sys->overlay_parts[i] = (struct pl_overlay_part) {
                 .src = {
-                    .x1 = r->place.width,
-                    .y1 = r->place.height,
+                    .x0 = r->source_offset_x,
+                    .y0 = r->source_offset_y,
+                    .x1 = r->source_offset_x + r->place.width,
+                    .y1 = r->source_offset_y + r->place.height,
                 },
                 .dst = {
                     .x0 = place.x + r->place.x,


=====================================
modules/video_output/libplacebo/utils.c
=====================================
@@ -128,7 +128,7 @@ struct fmt_desc {
 
 // NOTE: This list contains some special formats that don't follow the normal
 // rules, but which are included regardless. The corrections for these
-// exceptions happen below, in the function vlc_placebo_PlaneFormat!
+// exceptions happen below, in the function vlc_placebo_PlaneData!
 static const struct { vlc_fourcc_t fcc; struct fmt_desc desc; } formats[] = {
     { VLC_CODEC_I410,           {PLANAR(3,  8, _410)} },
     { VLC_CODEC_I411,           {PLANAR(3,  8, _411)} },
@@ -317,44 +317,30 @@ static void FillDesc(vlc_fourcc_t fcc, const struct 
fmt_desc *desc,
     }
 }
 
-int vlc_placebo_PlaneFormat(const video_format_t *fmt, struct pl_plane_data 
data[4])
+int vlc_placebo_PlaneData(const picture_t *pic, struct pl_plane_data data[4])
 {
-    const struct fmt_desc *desc = FindDesc(fmt->i_chroma);
-    if (!desc)
+    const struct fmt_desc *desc = FindDesc(pic->format.i_chroma);
+    if (!desc || desc->num_planes == 0)
         return 0;
+    assert(desc->num_planes == pic->i_planes);
 
-    FillDesc(fmt->i_chroma, desc, data);
+    FillDesc(pic->format.i_chroma, desc, data);
     for (int i = 0; i < desc->num_planes; i++) {
         const struct plane_desc *p = &desc->planes[i];
-        data[i].width  = (fmt->i_visible_width  + p->w_denom - 1) / p->w_denom;
-        data[i].height = (fmt->i_visible_height + p->h_denom - 1) / p->h_denom;
-    }
+        data[i].width  = (pic->format.i_visible_width  + p->w_denom - 1) / 
p->w_denom;
+        data[i].height = (pic->format.i_visible_height + p->h_denom - 1) / 
p->h_denom;
 
-    return desc->num_planes;
-}
+        // assert(data[i].height == pic->p[i].i_visible_lines);
+        data[i].row_stride = pic->p[i].i_pitch;
 
-int vlc_placebo_PlaneData(const picture_t *pic, struct pl_plane_data data[4],
-                          pl_buf buf)
-{
-    int planes = vlc_placebo_PlaneFormat(&pic->format, data);
-    if (!planes)
-        return 0;
+        const size_t pixels_offset =
+                ((pic->format.i_y_offset + p->w_denom - 1) / p->w_denom) * 
pic->p[i].i_pitch +
+                ((pic->format.i_x_offset + p->h_denom - 1) / p->h_denom) * 
pic->p[i].i_pixel_pitch;
 
-    assert(planes == pic->i_planes);
-    for (int i = 0; i < planes; i++) {
-        assert(data[i].height == pic->p[i].i_visible_lines);
-        data[i].row_stride = pic->p[i].i_pitch;
-        if (buf) {
-            assert(buf->data);
-            assert(pic->p[i].p_pixels <= buf->data + buf->params.size);
-            data[i].buf = buf;
-            data[i].buf_offset = (uintptr_t) pic->p[i].p_pixels - (ptrdiff_t) 
buf->data;
-        } else {
-            data[i].pixels = pic->p[i].p_pixels;
-        }
+        data[i].pixels = pic->p[i].p_pixels + pixels_offset;
     }
 
-    return planes;
+    return desc->num_planes;
 }
 
 bool vlc_placebo_FormatSupported(pl_gpu gpu, vlc_fourcc_t fcc)


=====================================
modules/video_output/libplacebo/utils.h
=====================================
@@ -56,8 +56,7 @@ int vlc_placebo_PlaneComponents(const video_format_t *, 
struct pl_plane[4]);
 // Fill a pl_plane_data array with various data. Returns the number of planes,
 // or 0 if the format is unsupported by the libplacebo API. If `buf` is set,
 // then all addresses of the picture_t must lie within `buf`'s mapped memory.
-int vlc_placebo_PlaneFormat(const video_format_t *, struct pl_plane_data[4]);
-int vlc_placebo_PlaneData(const picture_t *, struct pl_plane_data[4], pl_buf 
buf);
+int vlc_placebo_PlaneData(const picture_t *, struct pl_plane_data[4]);
 
 // See if a given FourCC is physically supported by a given GPU
 bool vlc_placebo_FormatSupported(pl_gpu, vlc_fourcc_t);



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/39a6ab3d7c9b6214cf2bf3d3f41b5b308fef81d4...e57ef838dd733d9b7c42c182516e645452363964

-- 
View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/39a6ab3d7c9b6214cf2bf3d3f41b5b308fef81d4...e57ef838dd733d9b7c42c182516e645452363964
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to