[vlc-devel] [PATCH] decoder: simplify the plane constraints processing
Steve Lhomme
robux4 at gmail.com
Thu Mar 23 08:56:33 CET 2017
On Wed, Mar 22, 2017 at 3:05 PM, Rémi Denis-Courmont <remi at remlab.net> wrote:
> Le keskiviikkona 22. maaliskuuta 2017, 14.20.25 EET Steve Lhomme a écrit :
>> On Wed, Mar 22, 2017 at 8:28 AM, Rémi Denis-Courmont <remi at remlab.net>
> wrote:
>> > Le tiistaina 21. maaliskuuta 2017, 16.22.53 EET Steve Lhomme a écrit :
>> >> This is really rounding to the upper modulo.
>> >> ---
>> >>
>> >> src/input/decoder.c | 8 ++++----
>> >> 1 file changed, 4 insertions(+), 4 deletions(-)
>> >>
>> >> diff --git a/src/input/decoder.c b/src/input/decoder.c
>> >> index 9f95bb824c..fee2a4b8e7 100644
>> >> --- a/src/input/decoder.c
>> >> +++ b/src/input/decoder.c
>> >> @@ -403,10 +403,10 @@ static int vout_update_format( decoder_t *p_dec )
>> >>
>> >> const vlc_chroma_description_t *dsc =
>> >>
>> >> vlc_fourcc_GetChromaDescription( fmt.i_chroma ); for( unsigned int i = 0;
>> >> dsc && i < dsc->plane_count; i++ ) {
>> >> - while( fmt.i_width % dsc->p[i].w.den )
>> >> - fmt.i_width++;
>> >> - while( fmt.i_height % dsc->p[i].h.den )
>> >> - fmt.i_height++;
>> >> + fmt.i_width = dsc->p[i].w.den *
>> >> + ((fmt.i_width + dsc->p[i].w.den - 1) /
>> >> dsc->p[i].w.den);
>> >> + fmt.i_height = dsc->p[i].h.den *
>> >> + ((fmt.i_height + dsc->p[i].h.den - 1) /
>> >> dsc->p[i].h.den); }
>> >>
>> >> }
>> >
>> > AFAICT, this would be simpler:
>> > a += b - (a % b)
>>
>> I like Francois's version: a = (a + d-1) & ~(d-1)
>> It's probably more efficient.
>>
>> But it works only for powers of 2.
>
> As I wrote before (I think?), with power of twos, the simplest possible
> formula is:
>
> a += (-a) & (d - 1);
>
> It works because bit masking works like Euclidian/European division.
>
>> Which I think is the case with pixel subsampling (?).
>
> It is true in all cases that I am aware of. It should be true in all VLC-
> supported pixel formats.
Yes, I checked. Sub pixels denominators are either 1, 2 and 4 nothing
else. I doubt anyone would create sub pixels denominators of 3.
Should we use your formula then rather than the ugly while ?
> --
> 雷米‧德尼-库尔蒙
> https://www.remlab.net/
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
More information about the vlc-devel
mailing list