Skip to content

picture: expand plane_t visible area

Romain Vimont requested to merge rom1v/vlc:visible_pitch into master

A plane_t stores "visible pitch" and "visible lines" fields, but it does not know anything about possible offsets in the picture (i_x_offset and i_y_offset in video_format_t).

Therefore, copying a picture having a non-zero offset resulted in the wrong area being copied, so the right and bottom "visible" pixels were lost.

       source plane                           destination plane
   +-------------------+                    +-------------------+
   |                   |                    |          '''''''''|
   |     ...........   | plane_CopyPixels() |     .....'''''''''|
   |     : visible :   |  --------------->  |     :    '''''''''|
   |     :  area   :   |                    |'''''''''''''''''''|
   |     ...........   |                    |'''''''''''''''''''|
   |                   |                    |'''''''''''''''''''|
   +-------------------+                    +-------------------+

To avoid the problem, set the i_visible_pitch and i_visible_lines values so that they include the visible area:

                      i_visible_pitch
                     <--------------->
                   ^ +-------------------+
                   | |                '''|
   i_visible_lines | |     ...........'''|
                   | |     : visible :'''|
                   | |     :  area   :'''|
                   v |     ...........'''|
                     |'''''''''''''''''''|
                     +-------------------+

Alternatives considered:

  • Set the "visible" area to the whole video_format_t i_width × i_height (!2879 (closed)); but this changes the semantics of the existing fields, and potentially impacts all picture_t usages.
  • Adapt plane_CopyPixels() to copy the whole i_pitch × i_lines area (initially proposed in !2898 (merged)); but this impacts the behavior of all picture_t users, even without offsets.

By contrast, extending the visible pitch and lines to include the visible area has no impact for pictures without offsets, and it makes the copy of picture_t having offsets correct.


(sample from #27264 (closed))

Before (notice the 2px green band on the right):

visible_pitch_before

After:

visible_pitch_after

Merge request reports