Hi…
Are there any reasons to have only even width for images?
That is your current formula works only for even sized widths…
Thanks and happy holidays…
Hi…
Are there any reasons to have only even width for images?
That is your current formula works only for even sized widths…
Thanks and happy holidays…
Example:
width = 321
pixelStride = 3 (RGB)
(321 * 3 +3) & ~3 = 964
Should be 963…
Bye
Please correct me if I’m wrong…
Not sure I understand what you mean… Images are stored with word-boundary alignments, but the actual image can be any width at all (?)
Thanks, word-boundary explains it…
Although it means I can’t do things like:
frame = new Image(Image::RGB, imageWidth, imageHeight, false);
pixels = frame->lockPixelDataReadWrite(0, 0, imageWidth,
imageHeight, lineStride, pixelStride);
avpicture_fill((AVPicture *)videoFrameRGB24, pixels,
PIX_FMT_RGB24, imageWidth, imageHeight);
jassert(lineStride == videoFrameRGB24->linesize[0]);
sws_scale(swsContext, videoFrame->data, videoFrame->linesize, 0,
imageHeight, videoFrameRGB24->data,
videoFrameRGB24->linesize);
frame->releasePixelDataReadWrite(pixels);
Thanks
I can’t see what your example is supposed to be doing, or why a word alignment would be a problem?
Basically if you pass a word-aligned pixel data to a function that expects non aligned pixel data, or similar things…
Above code uses ffmpeg functions to populate video frame pixel data with pixels from juce::Image. Without word-alignment there is no need for an extra setPixelData() step to take care of lineStride and linesize not being the same…
Bye
Doesn’t that step just tell FFMPEG what the stride is? It’s a good thing: keep all your video data word aligned, at the least (64 or 128 bits can be better).
In that case, it’s not an extra step, it’s saving time as all your transfers will be quicker.
Bruce
Yes - I don’t know anything about ffmpeg, but would be surprised if it didn’t let you specify the line stride value that you want to use.
Hey I figured it out.
videoFrameRGB24->linesize[0] = lineStride;
A note for Windows users: use PIX_FMT_BGR24
Thanks for support, bye