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.
@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
tileIndexcorresponds 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
tileCountVerticalfor non-square images results in either:tileCountVerticalis equal to 1 (sprites with one row of images) it always crops out the first tiletileCountVerticalis 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
ImageRenderTestto 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