Nicolas George (2019-01-02): > Uwe Freese (2019-01-01): > > > This can be optimized, and since it is the inner loop of the filter, I > > > think it is worth it. You can declare a pointer that will stay the same > > > for the whole y loop: > > > > > > double *xweight = uglarmtable + (y - logo_y1) * (logo_w - 1); > > > > > > and then use it in that loop: > > > > > > interpd += ... * xweight[abs(bx - (x - logo_x1))]; > > > > > > It avoids a lot of multiplications. > > > Secondly, I don't exactly understand how *xweight in your example should be > > used (and would mean smaller or easier code). > > XXX
Sorry, forgot to fill that part before sending. Completely untested code: double *table_t, *table_b, *table_l, *table_r; table_t = uglarmtable + x + table_stride * y; table_b = uglarmtable + x + table_stride * (logo_h - y - 1); table_l = uglarmtable + table_stride * (y - 1) + x; table_r = uglarmtable + table_stride * (y - 1) + logo_w - x - 1; /* top+bottom on the left of the current point */ for (bx = 0; bx < x; bx++) { weightsum += table_t; weightsum += table_b; table_t--; table_b--; } /* top+bottom on the right of the current point */ for (; bx < logo_w; bx++) { weightsum += table_t; weightsum += table_b; table_t++; table_b++; } /* left+right above the current point */ for (by = 1; by < y; by++) { weightsum += *table_l; weightsum += *table_r; table_l -= table_stride; table_r -= table_stride; } /* left+right below the current point */ for (; by < logo_w - 1; by++) { weightsum += *table_l; weightsum += *table_r; table_l += table_stride; table_r += table_stride; } av_assert2(table_t == uglarmtable + (logo_w - x) + table_stride * y); av_assert2(table_b == uglarmtable + (logo_w - x) + table_stride * (logo_h - y - 1)); av_assert2(table_l == uglarmtable + table_stride * (logo_h - y - 1) + x); av_assert2(table_r == uglarmtable + table_stride * (logo_h - y - 1) + logo_w - x - 1; That makes more lines, but the lines are way simpler: no tricky arithmetic, all blocks almost identical, with the changes easy to see and understand. Regards, -- Nicolas George _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel