-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix DASH thumbnails cropping the incorrect tile for non-square images #1300
Fix DASH thumbnails cropping the incorrect tile for non-square images #1300
Conversation
Thank you for identifying the issue and providing a pull request to remedy it. Your solution makes sense to me. All that I ask is if you can just create an individual unit test and sample with the six frames rather than altering the current tests. That would be great! |
@microkatz I've created a new test now instead, but I'm not really if what I did with Let me know if you'd prefer to have these two commits squashed to avoid |
Ah. I see the current issue of how its setup in |
@microkatz sure, that seems like a better solution to me, I've pushed that change now. I just copied |
1d242bd
to
ddbb0ef
Compare
I'm going to send this for internal review now. You may see some more commits being added as I make changes in response to review feedback. Please refrain from pushing any more substantive changes as it will complicate the internal review - thanks! |
* Add support for non-square DASH thumbnail grids | ||
([#1255](https://github.com/androidx/media/pull/1300)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@microkatz The PR number for the link text doesn't match the actual PR (and issue 1255 is unrelated to this PR)
e5a30d4
to
420c58b
Compare
… for cropping the correct tile from outputBitmap To find the column of an index in a matrix the formula "column = index % width" should be used, not "column = index % height" If inputFormat.tileCountVertical was equal to 1 then it would not throw an error, but instead result in the first tile of the bitmap always being returned. If inputFormat.tileCountVertical was larger than 1 then Bitmap.createBitmap() would throw an error as it would attempt to go outside the bounds of outputBitmap ImageRenderTest has been updated to test for 2x3 images so that tileCountVertical != tileCountHorizontal. These tests passed previously because they were equal, so using tileCountVertical produced the same results as tileCountHorizontal
…test for non square images instead
…esToOutput to allow it to use a separate bitmap from the other tests
420c58b
to
acc5a3b
Compare
The calculation for finding the column a
tileIndex
corresponds to is currentlytileIndex % inputFormat.tileCountVertical
. This should instead betileIndex % inputFormat.tileCountHorizontal
(see this SO answer) to work for non-square images. It works for square images sincetileCountVertical == tileCountHorizontal
, so the same values are produced.Using
tileCountVertical
for non-square images results in either:tileCountVertical
is equal to 1 (sprites with one row of images) it always crops out the first tiletileCountVertical
is larger than 1 it will attempt to crop out a bitmap outside the bounds of the larger bitmap, resulting inBitmap.createBitmap()
throwing an exception.Exception thrown
I have updated
ImageRenderTest
to use a 2x3 image instead of 2x2. Reverting my change will make the updated tests fail, as expected, but please verify they still work as intended.I have created a separate branch that displays thumbnails in the demo app that can be used for testing. Two samples are added, one for the one row case and one for non-squares with more than one row. The videos below are taken from this branch.
Before
Screen_recording_20240420_085532.mp4
After
Screen_recording_20240420_085434.mp4