Repository navigation
Conversation
The vertical scaling of the destination rectangle derived bpad from tpad, so an asymmetric padding put the picture at the wrong size and position. Only subpictures whose flow definition carries pic padding attributes are affected; for everything else both are zero.
A rect of another type, or a bitmap rect without its index or palette plane, was composed from a NULL pointer. Skip it with a warning.
The padding attributes of a subpicture flow were scaled by dest_size / src_size, but the source is fitted into the destination rectangle by DAR, so when their aspect ratios differ the suggested size and position were wrong in the non-fitted axis. Scale them by the fitted size instead. The vertical position was also rounded by the horizontal rounding parameter.
The subpicture was composed on a cleared full canvas, but everything downstream works on the whole picture for every frame the subtitle stays on screen, so the transparent part of the canvas was rescaled and alpha blended at every frame. Crop to the bounding box of the rects instead, and describe where the box sits in the canvas with padding attributes: flow format providers such as upipe_blit reconstruct the virtual canvas from size + padding, so the cropped bitmap gets the same scale factor and screen position as the full canvas would. An empty subtitle keeps a minimal transparent picture, since it must still replace the previous subpicture downstream. Offsets and sizes are kept even for the chroma siting of a possible 4:2:0 conversion, and rects with negative coordinates are dropped like the ones past the canvas - they used to write before the start of the plane.
The bounding box of the rects crops nothing for teletext: the libzvbi decoder renders the whole page into a single rect, whose transparent part is then rescaled and blended for every frame the page stays on screen - the very thing the box was meant to avoid. The rects are no bound on what is visible, so scan the pixels: an index of the palette is visible if its alpha is not zero, and the box is the union of the boxes of the visible pixels. The box can now be tighter than a rect, so clip the rects to it when composing; the rows and columns kept by the rounding to even offsets and sizes are transparent and blend as before. Subtitle pages come out a couple of rows tall instead of a full page, and dvb subtitles lose the transparent part of their regions as well. The dimensions of a teletext subpicture are no longer constant, so a downstream scaler is reconfigured once per page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
avcdec composes every subtitle on a cleared full canvas, so downstream (upipe_blit, and any scaler in front of it) rescales and blends the whole, mostly transparent canvas for every frame the subtitle stays on screen. This crops the subpicture to the bounding box of its visible pixels and describes where the box sits in the canvas with the pic padding attributes, which upipe_blit's flow format provider already uses to reconstruct the virtual canvas, so the cropped picture keeps the scale and position of the full one.
Checked with upipe_blit's flow format provider on a 1920x1080 destination: a 520x60 box at 100,500 in a 720x576 4:3 canvas is placed at 440,936 with size 1040x112, where the full canvas would put it; on master any padded subpicture currently gets a wrapped vertical size. Builds without warnings; upipe_blit_test passes