View Full Version : No AverageLuma with 4*4 & 8*8
MOmonster
17th October 2007, 18:26
I want to use AverageLuma only on a really small part of the image. AverageLuma works fine with a size of 16*16 pixels and this is small enough for me.
But I also tested it with sizes 4*4 and 8*8 Pixels and AverageLuma doesnīt output any useful values. There is no error message.
I couldnīt find something in the Avisynth readme, so Iīm just interested why it doesnīt works for such small resolutions?
IanB
17th October 2007, 23:36
Thanks for the report.
Yes, this code is very slack, I am also surprised you don't get a divide by zero error out of this (I think FP traps are turned off). There is a C code routine that is not used as well. int w = src->GetRowSize(plane);
int pitch = src->GetPitch(plane);
w=(w/16)*16;
int b = isse_average_plane(srcp, h, w, pitch);
if (!b) b=1;
float f = (float)b / (float)(h * w);Height is no problem. It only does upto mod 16 part of the width. And pure black clips, do not return 0.0, Doh!
Workaround :-Padded=StackHorizontal(Last, BlankClip(Last, width=16))and..., AverageLuma(Padded)*(Width(Padded)/16)*16/Width(Last), ...
MOmonster
18th October 2007, 08:19
Thanks for your answer.
So it is because of speed optimizations. I first thought itīs ok if width*height is mod16, but now itīs clear.
And thanks for the workaround, stacking a blankclip is a better solution then stacking two times a duplicate.:)
IanB
18th October 2007, 15:32
StackHorizontal(Last, Last, Last, Last) has the benefit of not needing to rescale the average value.
MOmonster
18th October 2007, 19:08
But I think blankclip+rescaling is faster, or not? (not that this would make a high difference here)
IanB
20th October 2007, 01:51
No they will be the same speed. The cost is in the blit to join the frames together. The AverageLuma will still scan the same number of pixels.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.