[FFmpeg-cvslog] avfilter/xbr: refactor src/dst pointers definitions into a macro
Clément Bœsch
git at videolan.org
Sat Nov 15 21:07:07 CET 2014
ffmpeg | branch: master | Clément Bœsch <u at pkh.me> | Fri Nov 14 00:00:44 2014 +0100| [7e91f77547b887cc6e834d058c237a73b8bbadcf] | committer: Clément Bœsch
avfilter/xbr: refactor src/dst pointers definitions into a macro
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e91f77547b887cc6e834d058c237a73b8bbadcf
---
libavfilter/vf_xbr.c | 105 ++++++++++++--------------------------------------
1 file changed, 25 insertions(+), 80 deletions(-)
diff --git a/libavfilter/vf_xbr.c b/libavfilter/vf_xbr.c
index 0a53e2f..d795acc 100644
--- a/libavfilter/vf_xbr.c
+++ b/libavfilter/vf_xbr.c
@@ -96,6 +96,28 @@ static uint32_t pixel_diff(uint32_t x, uint32_t y, const uint32_t *r2y)
#define eq(A, B)\
(df(A, B) < 155)\
+#define INIT_SRC_DST_POINTERS(level) \
+ uint32_t *E = (uint32_t *)(output->data[0] + y * output->linesize[0] * (level)); \
+ const uint32_t *sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8); /* center */ \
+ const uint32_t *sa1 = sa2 - (input->linesize[0]>>2); /* up x1 */ \
+ const uint32_t *sa0 = sa1 - (input->linesize[0]>>2); /* up x2 */ \
+ const uint32_t *sa3 = sa2 + (input->linesize[0]>>2); /* down x1 */ \
+ const uint32_t *sa4 = sa3 + (input->linesize[0]>>2); /* down x2 */ \
+ \
+ if (y <= 1) { \
+ sa0 = sa1; \
+ if (y == 0) { \
+ sa0 = sa1 = sa2; \
+ } \
+ } \
+ \
+ if (y >= input->height - 2) { \
+ sa4 = sa3; \
+ if (y == input->height - 1) { \
+ sa4 = sa3 = sa2; \
+ } \
+ }
+
#define INIT_21_PIXELS \
const uint32_t B1 = sa0[2]; \
const uint32_t PB = sa1[2]; \
@@ -167,32 +189,7 @@ static void xbr2x(AVFrame * input, AVFrame * output, const uint32_t * r2y)
int next_line = output->linesize[0]>>2;
for (y = 0; y < input->height; y++) {
- uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 2);
-
- /* middle. Offset of -8 is given */
- const uint32_t *sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8);
- /* up one */
- const uint32_t *sa1 = sa2 - (input->linesize[0]>>2);
- /* up two */
- const uint32_t *sa0 = sa1 - (input->linesize[0]>>2);
- /* down one */
- const uint32_t *sa3 = sa2 + (input->linesize[0]>>2);
- /* down two */
- const uint32_t *sa4 = sa3 + (input->linesize[0]>>2);
-
- if (y <= 1) {
- sa0 = sa1;
- if (y == 0) {
- sa0 = sa1 = sa2;
- }
- }
-
- if (y >= input->height - 2) {
- sa4 = sa3;
- if (y == input->height - 1) {
- sa4 = sa3 = sa2;
- }
- }
+ INIT_SRC_DST_POINTERS(2)
for (x = 0; x < input->width; x++) {
INIT_21_PIXELS
@@ -264,33 +261,7 @@ static void xbr3x(AVFrame *input, AVFrame *output, const uint32_t *r2y)
int x,y;
for (y = 0; y < input->height; y++) {
-
- uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 3);
-
- /* middle. Offset of -8 is given */
- const uint32_t *sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8);
- /* up one */
- const uint32_t *sa1 = sa2 - (input->linesize[0]>>2);
- /* up two */
- const uint32_t *sa0 = sa1 - (input->linesize[0]>>2);
- /* down one */
- const uint32_t *sa3 = sa2 + (input->linesize[0]>>2);
- /* down two */
- const uint32_t *sa4 = sa3 + (input->linesize[0]>>2);
-
- if (y <= 1){
- sa0 = sa1;
- if (y == 0){
- sa0 = sa1 = sa2;
- }
- }
-
- if (y >= input->height - 2){
- sa4 = sa3;
- if (y == input->height - 1){
- sa4 = sa3 = sa2;
- }
- }
+ INIT_SRC_DST_POINTERS(3)
for (x = 0; x < input->width; x++){
INIT_21_PIXELS
@@ -370,33 +341,7 @@ static void xbr4x(AVFrame *input, AVFrame *output, const uint32_t *r2y)
int x, y;
for (y = 0; y < input->height; y++) {
-
- uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 4);
-
- /* middle. Offset of -8 is given */
- const uint32_t *sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8);
- /* up one */
- const uint32_t *sa1 = sa2 - (input->linesize[0]>>2);
- /* up two */
- const uint32_t *sa0 = sa1 - (input->linesize[0]>>2);
- /* down one */
- const uint32_t *sa3 = sa2 + (input->linesize[0]>>2);
- /* down two */
- const uint32_t *sa4 = sa3 + (input->linesize[0]>>2);
-
- if (y <= 1) {
- sa0 = sa1;
- if (y == 0) {
- sa0 = sa1 = sa2;
- }
- }
-
- if (y >= input->height - 2) {
- sa4 = sa3;
- if (y == input->height - 1) {
- sa4 = sa3 = sa2;
- }
- }
+ INIT_SRC_DST_POINTERS(4)
for (x = 0; x < input->width; x++) {
INIT_21_PIXELS
More information about the ffmpeg-cvslog
mailing list