History

avfilter/vf_v360: add padding to u/v/ker

Fixes use of uninitialized variables.

Paul B Mahol committed 7 years ago

Commit 558265d1 parent 29bde4b2 files · +15 −9Browse files

Unified · Split

2 files
  1. libavfilter/v360.h +1 −0
  2. libavfilter/vf_v360.c +14 −9
libavfilter/v360.h+1−0
@@ -110,6 +110,7 @@ typedef struct V360Context { · 109 unmodified lines
110110
111111 int planewidth[4], planeheight[4];
112112 int inplanewidth[4], inplaneheight[4];
113+ int uv_linesize[4];
113114 int nb_planes;
114115 int nb_allocated;
115116
libavfilter/vf_v360.c+14−9
@@ -222,6 +222,7 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo · 221 unmodified lines
222222 for (int plane = 0; plane < s->nb_planes; plane++) { \
223223 const int in_linesize = in->linesize[plane]; \
224224 const int out_linesize = out->linesize[plane]; \
225+ const int uv_linesize = s->uv_linesize[plane]; \
225226 const uint8_t *src = in->data[plane]; \
226227 uint8_t *dst = out->data[plane]; \
227228 const int width = s->planewidth[plane]; \
@@ -232,9 +233,9 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo · 4 unmodified lines
232233 \
233234 for (int y = slice_start; y < slice_end; y++) { \
234235 const unsigned map = s->map[plane]; \
235− const uint16_t *u = s->u[map] + y * width * ws * ws; \
236− const uint16_t *v = s->v[map] + y * width * ws * ws; \
237− const int16_t *ker = s->ker[map] + y * width * ws * ws; \
236+ const uint16_t *u = s->u[map] + y * uv_linesize * ws * ws; \
237+ const uint16_t *v = s->v[map] + y * uv_linesize * ws * ws; \
238+ const int16_t *ker = s->ker[map] + y * uv_linesize * ws * ws; \
238239 \
239240 s->remap_line(dst + y * out_linesize, width, src, in_linesize, u, v, ker); \
240241 } \
@@ -2035,12 +2036,12 @@ static inline void mirror(const float *modifier, float *vec) · 1794 unmodified lines
20352036
20362037 static int allocate_plane(V360Context *s, int sizeof_uv, int sizeof_ker, int p)
20372038 {
2038− s->u[p] = av_calloc(s->planewidth[p] * s->planeheight[p], sizeof_uv);
2039− s->v[p] = av_calloc(s->planewidth[p] * s->planeheight[p], sizeof_uv);
2039+ s->u[p] = av_calloc(s->uv_linesize[p] * s->planeheight[p], sizeof_uv);
2040+ s->v[p] = av_calloc(s->uv_linesize[p] * s->planeheight[p], sizeof_uv);
20402041 if (!s->u[p] || !s->v[p])
20412042 return AVERROR(ENOMEM);
20422043 if (sizeof_ker) {
2043− s->ker[p] = av_calloc(s->planewidth[p] * s->planeheight[p], sizeof_ker);
2044+ s->ker[p] = av_calloc(s->uv_linesize[p] * s->planeheight[p], sizeof_ker);
20442045 if (!s->ker[p])
20452046 return AVERROR(ENOMEM);
20462047 }
@@ -2266,6 +2267,9 @@ static int config_output(AVFilterLink *outlink) · 219 unmodified lines
22662267 s->planewidth[1] = s->planewidth[2] = FF_CEIL_RSHIFT(w, desc->log2_chroma_w);
22672268 s->planewidth[0] = s->planewidth[3] = w;
22682269
2270+ for (int i = 0; i < 4; i++)
2271+ s->uv_linesize[i] = FFALIGN(s->planewidth[i], 8);
2272+
22692273 outlink->h = h;
22702274 outlink->w = w;
22712275
@@ -2303,6 +2307,7 @@ static int config_output(AVFilterLink *outlink) · 31 unmodified lines
23032307 // Calculate remap data
23042308 for (p = 0; p < s->nb_allocated; p++) {
23052309 const int width = s->planewidth[p];
2310+ const int uv_linesize = s->uv_linesize[p];
23062311 const int height = s->planeheight[p];
23072312 const int in_width = s->inplanewidth[p];
23082313 const int in_height = s->inplaneheight[p];
@@ -2313,9 +2318,9 @@ static int config_output(AVFilterLink *outlink) · 4 unmodified lines
23132318
23142319 for (i = 0; i < width; i++) {
23152320 for (j = 0; j < height; j++) {
2316− uint16_t *u = s->u[p] + (j * width + i) * elements;
2317− uint16_t *v = s->v[p] + (j * width + i) * elements;
2318− int16_t *ker = s->ker[p] + (j * width + i) * elements;
2321+ uint16_t *u = s->u[p] + (j * uv_linesize + i) * elements;
2322+ uint16_t *v = s->v[p] + (j * uv_linesize + i) * elements;
2323+ int16_t *ker = s->ker[p] + (j * uv_linesize + i) * elements;
23192324
23202325 if (s->out_transpose)
23212326 out_transform(s, j, i, height, width, vec);

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