[vlc-devel] [PATCH] core: only add extra height if there wasn't enough added for the modulo

Steve Lhomme robux4 at videolabs.io
Tue Mar 31 13:46:58 CEST 2015


On Tue, Mar 31, 2015 at 1:40 PM, Steve Lhomme <robux4 at videolabs.io> wrote:
> This hack is already done in FFMpeg and libav. So do we still need it ?
>
> http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/utils.c;h=99f254b6b45ba4a5f43711e90cb16199a98a99ef;hb=HEAD#l425
> https://git.libav.org/?p=libav.git;a=blob;f=libavcodec/utils.c;h=f1acd780dc12f631dff6f7f3ba055234c180996f;hb=HEAD#l272

For a H264 720p image. avcodec asks for a modulo 32 720 lines buffer
(=> 736 lines) then add 2 for its internal stuff (=> 738 lines).

Then we check that on our side it's also a modulo 32 (=> 768 lines)
and then we add 2 for the hack mentioned above (=> 770 lines). That's
32 lines too much, multiplied by the amount of images buffers in the
pool. For a device/GPU with not a lot of memory that may be a big
waste.

> On Tue, Mar 31, 2015 at 1:30 PM, Steve Lhomme <robUx4 at videolabs.io> wrote:
>> --
>> this whole hack may even be useless
>> ---
>>  src/misc/picture.c | 10 +++++++---
>>  1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/misc/picture.c b/src/misc/picture.c
>> index 8b4e0bf..a625f2d 100644
>> --- a/src/misc/picture.c
>> +++ b/src/misc/picture.c
>> @@ -181,13 +181,17 @@ int picture_Setup( picture_t *p_picture, const video_format_t *restrict fmt )
>>      i_modulo_h = LCM( i_modulo_h, 32 );
>>
>>      const int i_width_aligned  = ( fmt->i_width  + i_modulo_w - 1 ) / i_modulo_w * i_modulo_w;
>> -    const int i_height_aligned = ( fmt->i_height + i_modulo_h - 1 ) / i_modulo_h * i_modulo_h;
>> -    const int i_height_extra   = 2 * i_ratio_h; /* This one is a hack for some ASM functions */
>> +    int i_height_aligned = ( fmt->i_height + i_modulo_h - 1 ) / i_modulo_h * i_modulo_h;
>> +    if( i_height_aligned - fmt->i_height < 2 * i_ratio_h )
>> +    {
>> +        /* This one is a hack for some ASM functions */
>> +        i_height_aligned += 2 * i_ratio_h;
>> +    }
>>      for( unsigned i = 0; i < p_dsc->plane_count; i++ )
>>      {
>>          plane_t *p = &p_picture->p[i];
>>
>> -        p->i_lines         = (i_height_aligned + i_height_extra ) * p_dsc->p[i].h.num / p_dsc->p[i].h.den;
>> +        p->i_lines         = i_height_aligned * p_dsc->p[i].h.num / p_dsc->p[i].h.den;
>>          p->i_visible_lines = fmt->i_visible_height * p_dsc->p[i].h.num / p_dsc->p[i].h.den;
>>          p->i_pitch         = i_width_aligned * p_dsc->p[i].w.num / p_dsc->p[i].w.den * p_dsc->pixel_size;
>>          p->i_visible_pitch = fmt->i_visible_width * p_dsc->p[i].w.num / p_dsc->p[i].w.den * p_dsc->pixel_size;
>> --
>> 2.3.2
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> 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