[vlc-commits] [Git][videolan/vlc][master] 2 commits: videotoolbox: don't let it handle crop

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Mon Mar 7 18:46:29 UTC 2022



Rémi Denis-Courmont pushed to branch master at VideoLAN / VLC


Commits:
e72ce2df by Zhao Zhili at 2022-03-07T17:59:04+00:00
videotoolbox: don't let it handle crop

1. Videotoolbox doesn't handle codec info. It do crop the right
and bottom side if codec_size > output_size
2. There is no API to configure i_x_offset/i_y_offset to videotoolbox
3. It was a bug to let videotoolbox to crop and don't reset
i_x_offset/i_y_offset.

- - - - -
85f85230 by Zhao Zhili at 2022-03-07T17:59:04+00:00
opengl: importer: fix crop handling

- - - - -


2 changed files:

- modules/codec/videotoolbox.c
- modules/video_output/opengl/importer.c


Changes:

=====================================
modules/codec/videotoolbox.c
=====================================
@@ -478,9 +478,9 @@ static bool ConfigureVoutH264(decoder_t *p_dec)
                                                 &i_vis_width, &i_vis_height))
         {
             p_dec->fmt_out.video.i_visible_width = i_vis_width;
-            p_dec->fmt_out.video.i_width = vlc_align( i_vis_width, VT_ALIGNMENT );
+            p_dec->fmt_out.video.i_width = vlc_align(i_width, VT_ALIGNMENT);
             p_dec->fmt_out.video.i_visible_height = i_vis_height;
-            p_dec->fmt_out.video.i_height = vlc_align( i_vis_height, VT_ALIGNMENT );
+            p_dec->fmt_out.video.i_height = vlc_align(i_height, VT_ALIGNMENT);
         }
         else return false;
     }
@@ -1181,8 +1181,8 @@ static int StartVideoToolbox(decoder_t *p_dec)
     OSStatus status = CMVideoFormatDescriptionCreate(
                                             kCFAllocatorDefault,
                                             p_sys->codec,
-                                            p_dec->fmt_out.video.i_visible_width,
-                                            p_dec->fmt_out.video.i_visible_height,
+                                            p_dec->fmt_out.video.i_width,
+                                            p_dec->fmt_out.video.i_height,
                                             decoderConfiguration,
                                             &p_sys->videoFormatDescription);
     if (status)
@@ -1204,9 +1204,9 @@ static int StartVideoToolbox(decoder_t *p_dec)
 #endif
 
     cfdict_set_int32(destinationPixelBufferAttributes,
-                     kCVPixelBufferWidthKey, p_dec->fmt_out.video.i_visible_width);
+                     kCVPixelBufferWidthKey, p_dec->fmt_out.video.i_width);
     cfdict_set_int32(destinationPixelBufferAttributes,
-                     kCVPixelBufferHeightKey, p_dec->fmt_out.video.i_visible_height);
+                     kCVPixelBufferHeightKey, p_dec->fmt_out.video.i_height);
 
     if (p_sys->i_cvpx_format != 0)
     {
@@ -1603,8 +1603,8 @@ static int ConfigureVout(decoder_t *p_dec)
         p_dec->fmt_out.video.i_visible_height = p_dec->fmt_out.video.i_height;
     }
 
-    p_dec->fmt_out.video.i_width = vlc_align( p_dec->fmt_out.video.i_visible_width, VT_ALIGNMENT );
-    p_dec->fmt_out.video.i_height = vlc_align( p_dec->fmt_out.video.i_visible_height, VT_ALIGNMENT );
+    p_dec->fmt_out.video.i_width = vlc_align(p_dec->fmt_out.video.i_width, VT_ALIGNMENT);
+    p_dec->fmt_out.video.i_height = vlc_align(p_dec->fmt_out.video.i_height, VT_ALIGNMENT);
 
     return VLC_SUCCESS;
 }


=====================================
modules/video_output/opengl/importer.c
=====================================
@@ -236,12 +236,16 @@ vlc_gl_importer_New(struct vlc_gl_interop *interop)
 
     /* Texture size */
     for (unsigned j = 0; j < interop->tex_count; j++) {
-        GLsizei w = interop->fmt_out.i_visible_width  * interop->texs[j].w.num
+        GLsizei vw = interop->fmt_out.i_visible_width  * interop->texs[j].w.num
                   / interop->texs[j].w.den;
-        GLsizei h = interop->fmt_out.i_visible_height * interop->texs[j].h.num
+        GLsizei vh = interop->fmt_out.i_visible_height * interop->texs[j].h.num
                   / interop->texs[j].h.den;
-        glfmt->visible_widths[j] = w;
-        glfmt->visible_heights[j] = h;
+        GLsizei w = (interop->fmt_out.i_visible_width + interop->fmt_out.i_x_offset) * interop->texs[j].w.num
+                  / interop->texs[j].w.den;
+        GLsizei h = (interop->fmt_out.i_visible_height + interop->fmt_out.i_y_offset) *  interop->texs[j].h.num
+                  / interop->texs[j].h.den;
+        glfmt->visible_widths[j] = vw;
+        glfmt->visible_heights[j] = vh;
         if (supports_npot) {
             glfmt->tex_widths[j]  = w;
             glfmt->tex_heights[j] = h;
@@ -408,8 +412,8 @@ vlc_gl_importer_Update(struct vlc_gl_importer *importer, picture_t *picture)
 
     /* Update the texture */
     int ret = interop->ops->update_textures(interop, pic->textures,
-                                            glfmt->visible_widths,
-                                            glfmt->visible_heights, picture,
+                                            glfmt->tex_widths,
+                                            glfmt->tex_heights, picture,
                                             NULL);
 
     const float *tm = GetTransformMatrix(interop);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0b67987f4d11d892c16590ffd11e0986032d1ed1...85f85230df103124658ae77df40991cfc84237b2

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/0b67987f4d11d892c16590ffd11e0986032d1ed1...85f85230df103124658ae77df40991cfc84237b2
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