Declare rgbPixelBytes and grayPixelBytes as size_t#3184
Open
wantehchang wants to merge 1 commit intoAOMediaCodec:mainfrom
Open
Declare rgbPixelBytes and grayPixelBytes as size_t#3184wantehchang wants to merge 1 commit intoAOMediaCodec:mainfrom
wantehchang wants to merge 1 commit intoAOMediaCodec:mainfrom
Conversation
In avifImageRGBToYUV(), declare the local variables rgbPixelBytes and grayPixelBytes as size_t and replace the constant 2 with sizeof(uint16_t) so that multiplications with them are performed in the size_t type and avoid integer overflows. Based on the changes to avifImageRGBToYUV() in the first two commits in the pull request AOMediaCodec#3072. Co-authored-by: uwezkhan06 <uwezkhan055@gmail.com>
wantehchang
commented
May 4, 2026
| struct YUVBlock yuvBlock[2][2]; | ||
| float rgbPixel[3]; | ||
| const uint32_t rgbPixelBytes = state.rgb.pixelBytes; | ||
| const size_t rgbPixelBytes = state.rgb.pixelBytes; |
Member
Author
There was a problem hiding this comment.
Vincent: This PR is no longer necessary now that pull request #3072 has been updated to declare the index variables i, j, uvI, uvJ as size_t. But I think it is still good to declare rgbPixelBytes and grayPixelBytes as size_t because the related *RowBytes variables are declared as size_t.
|
|
||
| if (state.yuv.channelBytes > 1) { | ||
| uint16_t * pY = (uint16_t *)&yPlane[(i * 2) + (j * yRowBytes)]; | ||
| uint16_t * pY = (uint16_t *)&yPlane[(i * sizeof(uint16_t)) + (j * yRowBytes)]; |
Member
Author
There was a problem hiding this comment.
However, if you think changing 2 to sizeof(uint16_t) is too verbose, I can revert these changes.
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.
In avifImageRGBToYUV(), declare the local variables rgbPixelBytes and grayPixelBytes as size_t and replace the constant 2 with sizeof(uint16_t) so that multiplications with them are performed in the size_t type and avoid integer overflows.
Based on the changes to avifImageRGBToYUV() in the first two commits in the pull request #3072.