Skip to content
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

MemoryAlignment: Fixes #10810

Merged
merged 4 commits into from
Oct 30, 2016
Merged

MemoryAlignment: Fixes #10810

merged 4 commits into from
Oct 30, 2016

Conversation

fritsch
Copy link
Member

@fritsch fritsch commented Oct 29, 2016

Whenever we provide a user buffer directly into ffmpeg we should take care that its alignment is 32 byte, cause our ffmpeg build with AVX support might do nasty things.

This PR does two things:
a) Use av_malloc when we directly communicate with ffmpeg / sws_scale and so on
b) Use _aligned_malloc(size, 32) whenever we don't want ffmpeg dependencies in that other code, e.g. Texture.cpp and friends.

@fritsch
Copy link
Member Author

fritsch commented Oct 29, 2016

Hi @FernetMenta please have a look. I think I did not get the remarks correctly yet.

@@ -108,7 +108,7 @@ void CBaseTexture::Allocate(unsigned int width, unsigned int height, unsigned in
if (GetPitch() * GetRows() > 0)
{
size_t size = GetPitch() * GetRows();
m_pixels = (unsigned char*) _aligned_malloc(size, 16);
m_pixels = (unsigned char*) _aligned_malloc(size, 32);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@@ -68,7 +65,7 @@ DemuxPacket* CDVDDemuxUtils::AllocateDemuxPacket(int iDataSize)
* Note, if the first 23 bits of the additional bytes are not 0 then damaged
* MPEG bitstreams could cause overread and segfault
*/
pPacket->pData =(uint8_t*)_aligned_malloc(iDataSize + FF_INPUT_BUFFER_PADDING_SIZE, 16);
pPacket->pData =(uint8_t*)av_malloc(iDataSize + FF_INPUT_BUFFER_PADDING_SIZE);

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@FernetMenta FernetMenta added Type: Fix non-breaking change which fixes an issue v17 Krypton labels Oct 29, 2016
@FernetMenta FernetMenta added this to the Krypton 17.0-beta6 milestone Oct 29, 2016
@fritsch
Copy link
Member Author

fritsch commented Oct 29, 2016

jenkins build this please

@@ -68,7 +68,7 @@ DemuxPacket* CDVDDemuxUtils::AllocateDemuxPacket(int iDataSize)
* Note, if the first 23 bits of the additional bytes are not 0 then damaged
* MPEG bitstreams could cause overread and segfault
*/
pPacket->pData =(uint8_t*)_aligned_malloc(iDataSize + FF_INPUT_BUFFER_PADDING_SIZE, 16);
pPacket->pData =(uint8_t*)_aligned_malloc(iDataSize + FF_INPUT_BUFFER_PADDING_SIZE, 32);

This comment was marked as spam.

This comment was marked as spam.

@fritsch
Copy link
Member Author

fritsch commented Oct 29, 2016

jenkins build this please

@fritsch fritsch merged commit abc5af8 into xbmc:master Oct 30, 2016
@akva2
Copy link
Contributor

akva2 commented Oct 31, 2016

with aadfc21 image support is completely broken on my machine. reverting it restores operation.

@fritsch
Copy link
Member Author

fritsch commented Oct 31, 2016

See: #10826 thx for reporting back.

@@ -404,7 +404,7 @@ bool CFFmpegImage::DecodeFrame(AVFrame* frame, unsigned int width, unsigned int

bool needsCopy = false;
int pixelsSize = pitch * height;
bool aligned = (((uintptr_t)(const void *)(pixels)) % (16) == 0);
bool aligned = (((uintptr_t)(const void *)(pixels)) % (32) == 0);

This comment was marked as spam.

@fritsch
Copy link
Member Author

fritsch commented Feb 3, 2017 via email

@koying
Copy link
Contributor

koying commented Feb 3, 2017

Are we on the same page? ;)
I mean https://github.com/fritsch/xbmc/blob/2bf1886fb80dff007a4f37ca55a5e38830d0609f/xbmc/guilib/FFmpegImage.cpp#L422 should be aligned on 32 as well, I guess

@fritsch
Copy link
Member Author

fritsch commented Feb 3, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Fix non-breaking change which fixes an issue v17 Krypton
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants