History

libavfilter/transform: fix mirroring.

mirror() borrowed from dwt.c, this could be moved to libavutil and made public API, Ill submit a patch for this Fixes Ticket1278

Michael Niedermayer committed 14 years ago

Commit 5a90e551 parent 104c9141 file · +16 −2Browse files

Showing the changes to libavfilter/transform.c (1 of 1 file). Show all

Unified · Split

libavfilter/transform.c+16−2
@@ -25,6 +25,7 @@ · 24 unmodified lines
25 */25 */
26 26
27#include "libavutil/common.h"27#include "libavutil/common.h"
28#include "libavutil/avassert.h"
28 29
29#include "transform.h"30#include "transform.h"
30 31
@@ -135,6 +136,16 @@ void avfilter_mul_matrix(const float *m1, float scalar, float *result) · 104 unmodified lines
135 result[i] = m1[i] * scalar;136 result[i] = m1[i] * scalar;
136}137}
137 138
139static inline int mirror(int v, int m)
140{
141 while ((unsigned)v > (unsigned)m) {
142 v = -v;
143 if (v < 0)
144 v += 2 * m;
145 }
146 return v;
147}
148
138void avfilter_transform(const uint8_t *src, uint8_t *dst,149void avfilter_transform(const uint8_t *src, uint8_t *dst,
139 int src_stride, int dst_stride,150 int src_stride, int dst_stride,
140 int width, int height, const float *matrix,151 int width, int height, const float *matrix,
@@ -173,8 +184,11 @@ void avfilter_transform(const uint8_t *src, uint8_t *dst, · 32 unmodified lines
173 def = src[(int)y_s * src_stride + (int)x_s];184 def = src[(int)y_s * src_stride + (int)x_s];
174 break;185 break;
175 case FILL_MIRROR:186 case FILL_MIRROR:
176 y_s = (y_s < 0) ? -y_s : (y_s >= height) ? (height + height - y_s) : y_s;187 x_s = mirror(x_s, width-1);
177 x_s = (x_s < 0) ? -x_s : (x_s >= width) ? (width + width - x_s) : x_s;188 y_s = mirror(y_s, height-1);
189
190 av_assert2(x_s >= 0 && y_s >= 0);
191 av_assert2(x_s < width && y_s < height);
178 def = src[(int)y_s * src_stride + (int)x_s];192 def = src[(int)y_s * src_stride + (int)x_s];
179 }193 }
180 194

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t