[PATCH v2 2/6] mfplat: Properly align memory allocated by IMFMediaBuffer.

Nikolay Sivov nsivov at codeweavers.com
Sun Feb 27 08:21:42 CST 2022



On 2/25/22 19:37, Giovanni Mascellani wrote:
> v2:
>   * Handle alignments that are not powers of 2 minus 1. According to
>     my tests, this result in the alignment being increased to the
>     smalles power of 2 minus 1 bigger than the requested alignment.
>     I can add tests if it is wanted.
Please do, if such tests pass reliably.

> +
> +    /* Saturate bits to the right, so that alignment is a power of 2
> +     * minus 1. */
> +    for (i = 1; i < 8 * sizeof(alignment); i *= 2)
> +        alignment |= alignment >> i;
This looks like it would loop longer than it has it.

I think it should loop until remaining alignment is not zero, like this 
(untested):

while (alignment)
{
     // accumulate result here
     alignment = alignment >> 1;
}

Also it's not clear if alignment == 0 should work at all.



More information about the wine-devel mailing list