Hi, Apologies for not using git send-email for the remaining patches; it seems like git send-email has been broken by gmail; or does not like sending multiple patches in a single shot.
As these patches are trivial; I have attached the remainder instead to this email. Regards, Ganesh
From d0471edddbfde1bfda5bd6fce635522a8fbbcd6f Mon Sep 17 00:00:00 2001 From: Ganesh Ajjanagadde <gajjanaga...@gmail.com> Date: Fri, 28 Aug 2015 01:29:07 -0400 Subject: [PATCH 2/5] avfilter/vsrc_life: use the name 's' for the pointer to the private context Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> --- libavfilter/vsrc_life.c | 218 ++++++++++++++++++++++++------------------------ 1 file changed, 109 insertions(+), 109 deletions(-) diff --git a/libavfilter/vsrc_life.c b/libavfilter/vsrc_life.c index 314746d..720953f 100644 --- a/libavfilter/vsrc_life.c +++ b/libavfilter/vsrc_life.c @@ -144,15 +144,15 @@ error: #ifdef DEBUG static void show_life_grid(AVFilterContext *ctx) { - LifeContext *life = ctx->priv; + LifeContext *s = ctx->priv; int i, j; - char *line = av_malloc(life->w + 1); + char *line = av_malloc(s->w + 1); if (!line) return; - for (i = 0; i < life->h; i++) { - for (j = 0; j < life->w; j++) - line[j] = life->buf[life->buf_idx][i*life->w + j] == ALIVE_CELL ? '@' : ' '; + for (i = 0; i < s->h; i++) { + for (j = 0; j < s->w; j++) + line[j] = s->buf[s->buf_idx][i*s->w + j] == ALIVE_CELL ? '@' : ' '; line[j] = 0; av_log(ctx, AV_LOG_DEBUG, "%3d: %s\n", i, line); } @@ -162,19 +162,19 @@ static void show_life_grid(AVFilterContext *ctx) static int init_pattern_from_file(AVFilterContext *ctx) { - LifeContext *life = ctx->priv; + LifeContext *s = ctx->priv; char *p; int ret, i, i0, j, h = 0, w, max_w = 0; - if ((ret = av_file_map(life->filename, &life->file_buf, &life->file_bufsize, + if ((ret = av_file_map(s->filename, &s->file_buf, &s->file_bufsize, 0, ctx)) < 0) return ret; - av_freep(&life->filename); + av_freep(&s->filename); /* prescan file to get the number of lines and the maximum width */ w = 0; - for (i = 0; i < life->file_bufsize; i++) { - if (life->file_buf[i] == '\n') { + for (i = 0; i < s->file_bufsize; i++) { + if (s->file_buf[i] == '\n') { h++; max_w = FFMAX(w, max_w); w = 0; } else { w++; @@ -182,78 +182,78 @@ static int init_pattern_from_file(AVFilterContext *ctx) } av_log(ctx, AV_LOG_DEBUG, "h:%d max_w:%d\n", h, max_w); - if (life->w) { - if (max_w > life->w || h > life->h) { + if (s->w) { + if (max_w > s->w || h > s->h) { av_log(ctx, AV_LOG_ERROR, "The specified size is %dx%d which cannot contain the provided file size of %dx%d\n", - life->w, life->h, max_w, h); + s->w, s->h, max_w, h); return AVERROR(EINVAL); } } else { /* size was not specified, set it to size of the grid */ - life->w = max_w; - life->h = h; + s->w = max_w; + s->h = h; } - if (!(life->buf[0] = av_calloc(life->h * life->w, sizeof(*life->buf[0]))) || - !(life->buf[1] = av_calloc(life->h * life->w, sizeof(*life->buf[1])))) { - av_freep(&life->buf[0]); - av_freep(&life->buf[1]); + if (!(s->buf[0] = av_calloc(s->h * s->w, sizeof(*s->buf[0]))) || + !(s->buf[1] = av_calloc(s->h * s->w, sizeof(*s->buf[1])))) { + av_freep(&s->buf[0]); + av_freep(&s->buf[1]); return AVERROR(ENOMEM); } /* fill buf[0] */ - p = life->file_buf; - for (i0 = 0, i = (life->h - h)/2; i0 < h; i0++, i++) { - for (j = (life->w - max_w)/2;; j++) { + p = s->file_buf; + for (i0 = 0, i = (s->h - h)/2; i0 < h; i0++, i++) { + for (j = (s->w - max_w)/2;; j++) { av_log(ctx, AV_LOG_DEBUG, "%d:%d %c\n", i, j, *p == '\n' ? 'N' : *p); if (*p == '\n') { p++; break; } else - life->buf[0][i*life->w + j] = av_isgraph(*(p++)) ? ALIVE_CELL : 0; + s->buf[0][i*s->w + j] = av_isgraph(*(p++)) ? ALIVE_CELL : 0; } } - life->buf_idx = 0; + s->buf_idx = 0; return 0; } static av_cold int init(AVFilterContext *ctx) { - LifeContext *life = ctx->priv; + LifeContext *s = ctx->priv; int ret; - if (!life->w && !life->filename) - av_opt_set(life, "size", "320x240", 0); + if (!s->w && !s->filename) + av_opt_set(s, "size", "320x240", 0); - if ((ret = parse_rule(&life->born_rule, &life->stay_rule, life->rule_str, ctx)) < 0) + if ((ret = parse_rule(&s->born_rule, &s->stay_rule, s->rule_str, ctx)) < 0) return ret; - if (!life->mold && memcmp(life->mold_color, "\x00\x00\x00", 3)) + if (!s->mold && memcmp(s->mold_color, "\x00\x00\x00", 3)) av_log(ctx, AV_LOG_WARNING, "Mold color is set while mold isn't, ignoring the color.\n"); - if (!life->filename) { + if (!s->filename) { /* fill the grid randomly */ int i; - if (!(life->buf[0] = av_calloc(life->h * life->w, sizeof(*life->buf[0]))) || - !(life->buf[1] = av_calloc(life->h * life->w, sizeof(*life->buf[1])))) { - av_freep(&life->buf[0]); - av_freep(&life->buf[1]); + if (!(s->buf[0] = av_calloc(s->h * s->w, sizeof(*s->buf[0]))) || + !(s->buf[1] = av_calloc(s->h * s->w, sizeof(*s->buf[1])))) { + av_freep(&s->buf[0]); + av_freep(&s->buf[1]); return AVERROR(ENOMEM); } - if (life->random_seed == -1) - life->random_seed = av_get_random_seed(); + if (s->random_seed == -1) + s->random_seed = av_get_random_seed(); - av_lfg_init(&life->lfg, life->random_seed); + av_lfg_init(&s->lfg, s->random_seed); - for (i = 0; i < life->w * life->h; i++) { - double r = (double)av_lfg_get(&life->lfg) / UINT32_MAX; - if (r <= life->random_fill_ratio) - life->buf[0][i] = ALIVE_CELL; + for (i = 0; i < s->w * s->h; i++) { + double r = (double)av_lfg_get(&s->lfg) / UINT32_MAX; + if (r <= s->random_fill_ratio) + s->buf[0][i] = ALIVE_CELL; } - life->buf_idx = 0; + s->buf_idx = 0; } else { if ((ret = init_pattern_from_file(ctx)) < 0) return ret; @@ -261,77 +261,77 @@ static av_cold int init(AVFilterContext *ctx) av_log(ctx, AV_LOG_VERBOSE, "s:%dx%d r:%d/%d rule:%s stay_rule:%d born_rule:%d stitch:%d seed:%u\n", - life->w, life->h, life->frame_rate.num, life->frame_rate.den, - life->rule_str, life->stay_rule, life->born_rule, life->stitch, - life->random_seed); + s->w, s->h, s->frame_rate.num, s->frame_rate.den, + s->rule_str, s->stay_rule, s->born_rule, s->stitch, + s->random_seed); return 0; } static av_cold void uninit(AVFilterContext *ctx) { - LifeContext *life = ctx->priv; + LifeContext *s = ctx->priv; - av_file_unmap(life->file_buf, life->file_bufsize); - av_freep(&life->rule_str); - av_freep(&life->buf[0]); - av_freep(&life->buf[1]); + av_file_unmap(s->file_buf, s->file_bufsize); + av_freep(&s->rule_str); + av_freep(&s->buf[0]); + av_freep(&s->buf[1]); } static int config_props(AVFilterLink *outlink) { - LifeContext *life = outlink->src->priv; + LifeContext *s = outlink->src->priv; - outlink->w = life->w; - outlink->h = life->h; - outlink->time_base = av_inv_q(life->frame_rate); + outlink->w = s->w; + outlink->h = s->h; + outlink->time_base = av_inv_q(s->frame_rate); return 0; } static void evolve(AVFilterContext *ctx) { - LifeContext *life = ctx->priv; + LifeContext *s = ctx->priv; int i, j; - uint8_t *oldbuf = life->buf[ life->buf_idx]; - uint8_t *newbuf = life->buf[!life->buf_idx]; + uint8_t *oldbuf = s->buf[ s->buf_idx]; + uint8_t *newbuf = s->buf[!s->buf_idx]; enum { NW, N, NE, W, E, SW, S, SE }; /* evolve the grid */ - for (i = 0; i < life->h; i++) { - for (j = 0; j < life->w; j++) { + for (i = 0; i < s->h; i++) { + for (j = 0; j < s->w; j++) { int pos[8][2], n, alive, cell; - if (life->stitch) { - pos[NW][0] = (i-1) < 0 ? life->h-1 : i-1; pos[NW][1] = (j-1) < 0 ? life->w-1 : j-1; - pos[N ][0] = (i-1) < 0 ? life->h-1 : i-1; pos[N ][1] = j ; - pos[NE][0] = (i-1) < 0 ? life->h-1 : i-1; pos[NE][1] = (j+1) == life->w ? 0 : j+1; - pos[W ][0] = i ; pos[W ][1] = (j-1) < 0 ? life->w-1 : j-1; - pos[E ][0] = i ; pos[E ][1] = (j+1) == life->w ? 0 : j+1; - pos[SW][0] = (i+1) == life->h ? 0 : i+1; pos[SW][1] = (j-1) < 0 ? life->w-1 : j-1; - pos[S ][0] = (i+1) == life->h ? 0 : i+1; pos[S ][1] = j ; - pos[SE][0] = (i+1) == life->h ? 0 : i+1; pos[SE][1] = (j+1) == life->w ? 0 : j+1; + if (s->stitch) { + pos[NW][0] = (i-1) < 0 ? s->h-1 : i-1; pos[NW][1] = (j-1) < 0 ? s->w-1 : j-1; + pos[N ][0] = (i-1) < 0 ? s->h-1 : i-1; pos[N ][1] = j ; + pos[NE][0] = (i-1) < 0 ? s->h-1 : i-1; pos[NE][1] = (j+1) == s->w ? 0 : j+1; + pos[W ][0] = i ; pos[W ][1] = (j-1) < 0 ? s->w-1 : j-1; + pos[E ][0] = i ; pos[E ][1] = (j+1) == s->w ? 0 : j+1; + pos[SW][0] = (i+1) == s->h ? 0 : i+1; pos[SW][1] = (j-1) < 0 ? s->w-1 : j-1; + pos[S ][0] = (i+1) == s->h ? 0 : i+1; pos[S ][1] = j ; + pos[SE][0] = (i+1) == s->h ? 0 : i+1; pos[SE][1] = (j+1) == s->w ? 0 : j+1; } else { pos[NW][0] = (i-1) < 0 ? -1 : i-1; pos[NW][1] = (j-1) < 0 ? -1 : j-1; pos[N ][0] = (i-1) < 0 ? -1 : i-1; pos[N ][1] = j ; - pos[NE][0] = (i-1) < 0 ? -1 : i-1; pos[NE][1] = (j+1) == life->w ? -1 : j+1; + pos[NE][0] = (i-1) < 0 ? -1 : i-1; pos[NE][1] = (j+1) == s->w ? -1 : j+1; pos[W ][0] = i ; pos[W ][1] = (j-1) < 0 ? -1 : j-1; - pos[E ][0] = i ; pos[E ][1] = (j+1) == life->w ? -1 : j+1; - pos[SW][0] = (i+1) == life->h ? -1 : i+1; pos[SW][1] = (j-1) < 0 ? -1 : j-1; - pos[S ][0] = (i+1) == life->h ? -1 : i+1; pos[S ][1] = j ; - pos[SE][0] = (i+1) == life->h ? -1 : i+1; pos[SE][1] = (j+1) == life->w ? -1 : j+1; + pos[E ][0] = i ; pos[E ][1] = (j+1) == s->w ? -1 : j+1; + pos[SW][0] = (i+1) == s->h ? -1 : i+1; pos[SW][1] = (j-1) < 0 ? -1 : j-1; + pos[S ][0] = (i+1) == s->h ? -1 : i+1; pos[S ][1] = j ; + pos[SE][0] = (i+1) == s->h ? -1 : i+1; pos[SE][1] = (j+1) == s->w ? -1 : j+1; } /* compute the number of live neighbor cells */ - n = (pos[NW][0] == -1 || pos[NW][1] == -1 ? 0 : oldbuf[pos[NW][0]*life->w + pos[NW][1]] == ALIVE_CELL) + - (pos[N ][0] == -1 || pos[N ][1] == -1 ? 0 : oldbuf[pos[N ][0]*life->w + pos[N ][1]] == ALIVE_CELL) + - (pos[NE][0] == -1 || pos[NE][1] == -1 ? 0 : oldbuf[pos[NE][0]*life->w + pos[NE][1]] == ALIVE_CELL) + - (pos[W ][0] == -1 || pos[W ][1] == -1 ? 0 : oldbuf[pos[W ][0]*life->w + pos[W ][1]] == ALIVE_CELL) + - (pos[E ][0] == -1 || pos[E ][1] == -1 ? 0 : oldbuf[pos[E ][0]*life->w + pos[E ][1]] == ALIVE_CELL) + - (pos[SW][0] == -1 || pos[SW][1] == -1 ? 0 : oldbuf[pos[SW][0]*life->w + pos[SW][1]] == ALIVE_CELL) + - (pos[S ][0] == -1 || pos[S ][1] == -1 ? 0 : oldbuf[pos[S ][0]*life->w + pos[S ][1]] == ALIVE_CELL) + - (pos[SE][0] == -1 || pos[SE][1] == -1 ? 0 : oldbuf[pos[SE][0]*life->w + pos[SE][1]] == ALIVE_CELL); - cell = oldbuf[i*life->w + j]; - alive = 1<<n & (cell == ALIVE_CELL ? life->stay_rule : life->born_rule); + n = (pos[NW][0] == -1 || pos[NW][1] == -1 ? 0 : oldbuf[pos[NW][0]*s->w + pos[NW][1]] == ALIVE_CELL) + + (pos[N ][0] == -1 || pos[N ][1] == -1 ? 0 : oldbuf[pos[N ][0]*s->w + pos[N ][1]] == ALIVE_CELL) + + (pos[NE][0] == -1 || pos[NE][1] == -1 ? 0 : oldbuf[pos[NE][0]*s->w + pos[NE][1]] == ALIVE_CELL) + + (pos[W ][0] == -1 || pos[W ][1] == -1 ? 0 : oldbuf[pos[W ][0]*s->w + pos[W ][1]] == ALIVE_CELL) + + (pos[E ][0] == -1 || pos[E ][1] == -1 ? 0 : oldbuf[pos[E ][0]*s->w + pos[E ][1]] == ALIVE_CELL) + + (pos[SW][0] == -1 || pos[SW][1] == -1 ? 0 : oldbuf[pos[SW][0]*s->w + pos[SW][1]] == ALIVE_CELL) + + (pos[S ][0] == -1 || pos[S ][1] == -1 ? 0 : oldbuf[pos[S ][0]*s->w + pos[S ][1]] == ALIVE_CELL) + + (pos[SE][0] == -1 || pos[SE][1] == -1 ? 0 : oldbuf[pos[SE][0]*s->w + pos[SE][1]] == ALIVE_CELL); + cell = oldbuf[i*s->w + j]; + alive = 1<<n & (cell == ALIVE_CELL ? s->stay_rule : s->born_rule); if (alive) *newbuf = ALIVE_CELL; // new cell is alive else if (cell) *newbuf = cell - 1; // new cell is dead and in the process of mold else *newbuf = 0; // new cell is definitely dead @@ -340,22 +340,22 @@ static void evolve(AVFilterContext *ctx) } } - life->buf_idx = !life->buf_idx; + s->buf_idx = !s->buf_idx; } static void fill_picture_monoblack(AVFilterContext *ctx, AVFrame *picref) { - LifeContext *life = ctx->priv; - uint8_t *buf = life->buf[life->buf_idx]; + LifeContext *s = ctx->priv; + uint8_t *buf = s->buf[s->buf_idx]; int i, j, k; /* fill the output picture with the old grid buffer */ - for (i = 0; i < life->h; i++) { + for (i = 0; i < s->h; i++) { uint8_t byte = 0; uint8_t *p = picref->data[0] + i * picref->linesize[0]; - for (k = 0, j = 0; j < life->w; j++) { - byte |= (buf[i*life->w+j] == ALIVE_CELL)<<(7-k++); - if (k==8 || j == life->w-1) { + for (k = 0, j = 0; j < s->w; j++) { + byte |= (buf[i*s->w+j] == ALIVE_CELL)<<(7-k++); + if (k==8 || j == s->w-1) { k = 0; *p++ = byte; byte = 0; @@ -370,24 +370,24 @@ static void fill_picture_monoblack(AVFilterContext *ctx, AVFrame *picref) static void fill_picture_rgb(AVFilterContext *ctx, AVFrame *picref) { - LifeContext *life = ctx->priv; - uint8_t *buf = life->buf[life->buf_idx]; + LifeContext *s = ctx->priv; + uint8_t *buf = s->buf[s->buf_idx]; int i, j; /* fill the output picture with the old grid buffer */ - for (i = 0; i < life->h; i++) { + for (i = 0; i < s->h; i++) { uint8_t *p = picref->data[0] + i * picref->linesize[0]; - for (j = 0; j < life->w; j++) { - uint8_t v = buf[i*life->w + j]; - if (life->mold && v != ALIVE_CELL) { - const uint8_t *c1 = life-> mold_color; - const uint8_t *c2 = life->death_color; - int death_age = FFMIN((0xff - v) * life->mold, 0xff); + for (j = 0; j < s->w; j++) { + uint8_t v = buf[i*s->w + j]; + if (s->mold && v != ALIVE_CELL) { + const uint8_t *c1 = s-> mold_color; + const uint8_t *c2 = s->death_color; + int death_age = FFMIN((0xff - v) * s->mold, 0xff); *p++ = FAST_DIV255((c2[0] << 8) + ((int)c1[0] - (int)c2[0]) * death_age); *p++ = FAST_DIV255((c2[1] << 8) + ((int)c1[1] - (int)c2[1]) * death_age); *p++ = FAST_DIV255((c2[2] << 8) + ((int)c1[2] - (int)c2[2]) * death_age); } else { - const uint8_t *c = v == ALIVE_CELL ? life->life_color : life->death_color; + const uint8_t *c = v == ALIVE_CELL ? s->life_color : s->death_color; AV_WB24(p, c[0]<<16 | c[1]<<8 | c[2]); p += 3; } @@ -397,14 +397,14 @@ static void fill_picture_rgb(AVFilterContext *ctx, AVFrame *picref) static int request_frame(AVFilterLink *outlink) { - LifeContext *life = outlink->src->priv; - AVFrame *picref = ff_get_video_buffer(outlink, life->w, life->h); + LifeContext *s = outlink->src->priv; + AVFrame *picref = ff_get_video_buffer(outlink, s->w, s->h); if (!picref) return AVERROR(ENOMEM); picref->sample_aspect_ratio = (AVRational) {1, 1}; - picref->pts = life->pts++; + picref->pts = s->pts++; - life->draw(outlink->src, picref); + s->draw(outlink->src, picref); evolve(outlink->src); #ifdef DEBUG show_life_grid(outlink->src); @@ -414,17 +414,17 @@ static int request_frame(AVFilterLink *outlink) static int query_formats(AVFilterContext *ctx) { - LifeContext *life = ctx->priv; + LifeContext *s = ctx->priv; enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_NONE, AV_PIX_FMT_NONE }; AVFilterFormats *fmts_list; - if (life->mold || memcmp(life-> life_color, "\xff\xff\xff", 3) - || memcmp(life->death_color, "\x00\x00\x00", 3)) { + if (s->mold || memcmp(s-> life_color, "\xff\xff\xff", 3) + || memcmp(s->death_color, "\x00\x00\x00", 3)) { pix_fmts[0] = AV_PIX_FMT_RGB24; - life->draw = fill_picture_rgb; + s->draw = fill_picture_rgb; } else { pix_fmts[0] = AV_PIX_FMT_MONOBLACK; - life->draw = fill_picture_monoblack; + s->draw = fill_picture_monoblack; } fmts_list = ff_make_format_list(pix_fmts); -- 2.5.1
From 3c63840db1b7145599f62898766e7055b34abf06 Mon Sep 17 00:00:00 2001 From: Ganesh Ajjanagadde <gajjanaga...@gmail.com> Date: Fri, 28 Aug 2015 01:31:02 -0400 Subject: [PATCH 3/5] avfilter/vsrc_cellauto: use the name 's' for the pointer to the private context Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> --- libavfilter/vsrc_cellauto.c | 150 ++++++++++++++++++++++---------------------- 1 file changed, 75 insertions(+), 75 deletions(-) diff --git a/libavfilter/vsrc_cellauto.c b/libavfilter/vsrc_cellauto.c index 0638825..67bd167 100644 --- a/libavfilter/vsrc_cellauto.c +++ b/libavfilter/vsrc_cellauto.c @@ -86,55 +86,55 @@ AVFILTER_DEFINE_CLASS(cellauto); #ifdef DEBUG static void show_cellauto_row(AVFilterContext *ctx) { - CellAutoContext *cellauto = ctx->priv; + CellAutoContext *s = ctx->priv; int i; - uint8_t *row = cellauto->buf + cellauto->w * cellauto->buf_row_idx; - char *line = av_malloc(cellauto->w + 1); + uint8_t *row = s->buf + s->w * s->buf_row_idx; + char *line = av_malloc(s->w + 1); if (!line) return; - for (i = 0; i < cellauto->w; i++) + for (i = 0; i < s->w; i++) line[i] = row[i] ? '@' : ' '; line[i] = 0; - av_log(ctx, AV_LOG_DEBUG, "generation:%"PRId64" row:%s|\n", cellauto->generation, line); + av_log(ctx, AV_LOG_DEBUG, "generation:%"PRId64" row:%s|\n", s->generation, line); av_free(line); } #endif static int init_pattern_from_string(AVFilterContext *ctx) { - CellAutoContext *cellauto = ctx->priv; + CellAutoContext *s = ctx->priv; char *p; int i, w = 0; - w = strlen(cellauto->pattern); + w = strlen(s->pattern); av_log(ctx, AV_LOG_DEBUG, "w:%d\n", w); - if (cellauto->w) { - if (w > cellauto->w) { + if (s->w) { + if (w > s->w) { av_log(ctx, AV_LOG_ERROR, "The specified width is %d which cannot contain the provided string width of %d\n", - cellauto->w, w); + s->w, w); return AVERROR(EINVAL); } } else { /* width was not specified, set it to width of the provided row */ - cellauto->w = w; - cellauto->h = (double)cellauto->w * M_PHI; + s->w = w; + s->h = (double)s->w * M_PHI; } - cellauto->buf = av_mallocz_array(sizeof(uint8_t) * cellauto->w, cellauto->h); - if (!cellauto->buf) + s->buf = av_mallocz_array(sizeof(uint8_t) * s->w, s->h); + if (!s->buf) return AVERROR(ENOMEM); /* fill buf */ - p = cellauto->pattern; - for (i = (cellauto->w - w)/2;; i++) { + p = s->pattern; + for (i = (s->w - w)/2;; i++) { av_log(ctx, AV_LOG_DEBUG, "%d %c\n", i, *p == '\n' ? 'N' : *p); if (*p == '\n' || !*p) break; else - cellauto->buf[i] = !!av_isgraph(*(p++)); + s->buf[i] = !!av_isgraph(*(p++)); } return 0; @@ -142,165 +142,165 @@ static int init_pattern_from_string(AVFilterContext *ctx) static int init_pattern_from_file(AVFilterContext *ctx) { - CellAutoContext *cellauto = ctx->priv; + CellAutoContext *s = ctx->priv; int ret; - ret = av_file_map(cellauto->filename, - &cellauto->file_buf, &cellauto->file_bufsize, 0, ctx); + ret = av_file_map(s->filename, + &s->file_buf, &s->file_bufsize, 0, ctx); if (ret < 0) return ret; /* create a string based on the read file */ - cellauto->pattern = av_malloc(cellauto->file_bufsize + 1); - if (!cellauto->pattern) + s->pattern = av_malloc(s->file_bufsize + 1); + if (!s->pattern) return AVERROR(ENOMEM); - memcpy(cellauto->pattern, cellauto->file_buf, cellauto->file_bufsize); - cellauto->pattern[cellauto->file_bufsize] = 0; + memcpy(s->pattern, s->file_buf, s->file_bufsize); + s->pattern[s->file_bufsize] = 0; return init_pattern_from_string(ctx); } static av_cold int init(AVFilterContext *ctx) { - CellAutoContext *cellauto = ctx->priv; + CellAutoContext *s = ctx->priv; int ret; - if (!cellauto->w && !cellauto->filename && !cellauto->pattern) - av_opt_set(cellauto, "size", "320x518", 0); + if (!s->w && !s->filename && !s->pattern) + av_opt_set(s, "size", "320x518", 0); - if (cellauto->filename && cellauto->pattern) { + if (s->filename && s->pattern) { av_log(ctx, AV_LOG_ERROR, "Only one of the filename or pattern options can be used\n"); return AVERROR(EINVAL); } - if (cellauto->filename) { + if (s->filename) { if ((ret = init_pattern_from_file(ctx)) < 0) return ret; - } else if (cellauto->pattern) { + } else if (s->pattern) { if ((ret = init_pattern_from_string(ctx)) < 0) return ret; } else { /* fill the first row randomly */ int i; - cellauto->buf = av_mallocz_array(sizeof(uint8_t) * cellauto->w, cellauto->h); - if (!cellauto->buf) + s->buf = av_mallocz_array(sizeof(uint8_t) * s->w, s->h); + if (!s->buf) return AVERROR(ENOMEM); - if (cellauto->random_seed == -1) - cellauto->random_seed = av_get_random_seed(); + if (s->random_seed == -1) + s->random_seed = av_get_random_seed(); - av_lfg_init(&cellauto->lfg, cellauto->random_seed); + av_lfg_init(&s->lfg, s->random_seed); - for (i = 0; i < cellauto->w; i++) { - double r = (double)av_lfg_get(&cellauto->lfg) / UINT32_MAX; - if (r <= cellauto->random_fill_ratio) - cellauto->buf[i] = 1; + for (i = 0; i < s->w; i++) { + double r = (double)av_lfg_get(&s->lfg) / UINT32_MAX; + if (r <= s->random_fill_ratio) + s->buf[i] = 1; } } av_log(ctx, AV_LOG_VERBOSE, "s:%dx%d r:%d/%d rule:%d stitch:%d scroll:%d full:%d seed:%u\n", - cellauto->w, cellauto->h, cellauto->frame_rate.num, cellauto->frame_rate.den, - cellauto->rule, cellauto->stitch, cellauto->scroll, cellauto->start_full, - cellauto->random_seed); + s->w, s->h, s->frame_rate.num, s->frame_rate.den, + s->rule, s->stitch, s->scroll, s->start_full, + s->random_seed); return 0; } static av_cold void uninit(AVFilterContext *ctx) { - CellAutoContext *cellauto = ctx->priv; + CellAutoContext *s = ctx->priv; - av_file_unmap(cellauto->file_buf, cellauto->file_bufsize); - av_freep(&cellauto->buf); - av_freep(&cellauto->pattern); + av_file_unmap(s->file_buf, s->file_bufsize); + av_freep(&s->buf); + av_freep(&s->pattern); } static int config_props(AVFilterLink *outlink) { - CellAutoContext *cellauto = outlink->src->priv; + CellAutoContext *s = outlink->src->priv; - outlink->w = cellauto->w; - outlink->h = cellauto->h; - outlink->time_base = av_inv_q(cellauto->frame_rate); + outlink->w = s->w; + outlink->h = s->h; + outlink->time_base = av_inv_q(s->frame_rate); return 0; } static void evolve(AVFilterContext *ctx) { - CellAutoContext *cellauto = ctx->priv; + CellAutoContext *s = ctx->priv; int i, v, pos[3]; - uint8_t *row, *prev_row = cellauto->buf + cellauto->buf_row_idx * cellauto->w; + uint8_t *row, *prev_row = s->buf + s->buf_row_idx * s->w; enum { NW, N, NE }; - cellauto->buf_prev_row_idx = cellauto->buf_row_idx; - cellauto->buf_row_idx = cellauto->buf_row_idx == cellauto->h-1 ? 0 : cellauto->buf_row_idx+1; - row = cellauto->buf + cellauto->w * cellauto->buf_row_idx; + s->buf_prev_row_idx = s->buf_row_idx; + s->buf_row_idx = s->buf_row_idx == s->h-1 ? 0 : s->buf_row_idx+1; + row = s->buf + s->w * s->buf_row_idx; - for (i = 0; i < cellauto->w; i++) { - if (cellauto->stitch) { - pos[NW] = i-1 < 0 ? cellauto->w-1 : i-1; + for (i = 0; i < s->w; i++) { + if (s->stitch) { + pos[NW] = i-1 < 0 ? s->w-1 : i-1; pos[N] = i; - pos[NE] = i+1 == cellauto->w ? 0 : i+1; + pos[NE] = i+1 == s->w ? 0 : i+1; v = prev_row[pos[NW]]<<2 | prev_row[pos[N]]<<1 | prev_row[pos[NE]]; } else { v = 0; v|= i-1 >= 0 ? prev_row[i-1]<<2 : 0; v|= prev_row[i ]<<1 ; - v|= i+1 < cellauto->w ? prev_row[i+1] : 0; + v|= i+1 < s->w ? prev_row[i+1] : 0; } - row[i] = !!(cellauto->rule & (1<<v)); + row[i] = !!(s->rule & (1<<v)); ff_dlog(ctx, "i:%d context:%c%c%c -> cell:%d\n", i, v&4?'@':' ', v&2?'@':' ', v&1?'@':' ', row[i]); } - cellauto->generation++; + s->generation++; } static void fill_picture(AVFilterContext *ctx, AVFrame *picref) { - CellAutoContext *cellauto = ctx->priv; + CellAutoContext *s = ctx->priv; int i, j, k, row_idx = 0; uint8_t *p0 = picref->data[0]; - if (cellauto->scroll && cellauto->generation >= cellauto->h) + if (s->scroll && s->generation >= s->h) /* show on top the oldest row */ - row_idx = (cellauto->buf_row_idx + 1) % cellauto->h; + row_idx = (s->buf_row_idx + 1) % s->h; /* fill the output picture with the whole buffer */ - for (i = 0; i < cellauto->h; i++) { + for (i = 0; i < s->h; i++) { uint8_t byte = 0; - uint8_t *row = cellauto->buf + row_idx*cellauto->w; + uint8_t *row = s->buf + row_idx*s->w; uint8_t *p = p0; - for (k = 0, j = 0; j < cellauto->w; j++) { + for (k = 0, j = 0; j < s->w; j++) { byte |= row[j]<<(7-k++); - if (k==8 || j == cellauto->w-1) { + if (k==8 || j == s->w-1) { k = 0; *p++ = byte; byte = 0; } } - row_idx = (row_idx + 1) % cellauto->h; + row_idx = (row_idx + 1) % s->h; p0 += picref->linesize[0]; } } static int request_frame(AVFilterLink *outlink) { - CellAutoContext *cellauto = outlink->src->priv; - AVFrame *picref = ff_get_video_buffer(outlink, cellauto->w, cellauto->h); + CellAutoContext *s = outlink->src->priv; + AVFrame *picref = ff_get_video_buffer(outlink, s->w, s->h); if (!picref) return AVERROR(ENOMEM); picref->sample_aspect_ratio = (AVRational) {1, 1}; - if (cellauto->generation == 0 && cellauto->start_full) { + if (s->generation == 0 && s->start_full) { int i; - for (i = 0; i < cellauto->h-1; i++) + for (i = 0; i < s->h-1; i++) evolve(outlink->src); } fill_picture(outlink->src, picref); evolve(outlink->src); - picref->pts = cellauto->pts++; + picref->pts = s->pts++; #ifdef DEBUG show_cellauto_row(outlink->src); -- 2.5.1
From 6b9def854f6dd96398d1adbbcabb683c0016b86f Mon Sep 17 00:00:00 2001 From: Ganesh Ajjanagadde <gajjanaga...@gmail.com> Date: Fri, 28 Aug 2015 01:33:42 -0400 Subject: [PATCH 4/5] avfilter/vf_yadif: use the name 's' for the pointer to the private context Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> --- libavfilter/vf_yadif.c | 132 ++++++++++++++++++++++++------------------------- 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index 7451832..eacfee7 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -222,17 +222,17 @@ static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) static void filter(AVFilterContext *ctx, AVFrame *dstpic, int parity, int tff) { - YADIFContext *yadif = ctx->priv; + YADIFContext *s = ctx->priv; ThreadData td = { .frame = dstpic, .parity = parity, .tff = tff }; int i; - for (i = 0; i < yadif->csp->nb_components; i++) { + for (i = 0; i < s->csp->nb_components; i++) { int w = dstpic->width; int h = dstpic->height; if (i == 1 || i == 2) { - w = FF_CEIL_RSHIFT(w, yadif->csp->log2_chroma_w); - h = FF_CEIL_RSHIFT(h, yadif->csp->log2_chroma_h); + w = FF_CEIL_RSHIFT(w, s->csp->log2_chroma_w); + h = FF_CEIL_RSHIFT(h, s->csp->log2_chroma_h); } @@ -248,48 +248,48 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic, static int return_frame(AVFilterContext *ctx, int is_second) { - YADIFContext *yadif = ctx->priv; + YADIFContext *s = ctx->priv; AVFilterLink *link = ctx->outputs[0]; int tff, ret; - if (yadif->parity == -1) { - tff = yadif->cur->interlaced_frame ? - yadif->cur->top_field_first : 1; + if (s->parity == -1) { + tff = s->cur->interlaced_frame ? + s->cur->top_field_first : 1; } else { - tff = yadif->parity ^ 1; + tff = s->parity ^ 1; } if (is_second) { - yadif->out = ff_get_video_buffer(link, link->w, link->h); - if (!yadif->out) + s->out = ff_get_video_buffer(link, link->w, link->h); + if (!s->out) return AVERROR(ENOMEM); - av_frame_copy_props(yadif->out, yadif->cur); - yadif->out->interlaced_frame = 0; + av_frame_copy_props(s->out, s->cur); + s->out->interlaced_frame = 0; } - filter(ctx, yadif->out, tff ^ !is_second, tff); + filter(ctx, s->out, tff ^ !is_second, tff); if (is_second) { - int64_t cur_pts = yadif->cur->pts; - int64_t next_pts = yadif->next->pts; + int64_t cur_pts = s->cur->pts; + int64_t next_pts = s->next->pts; if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) { - yadif->out->pts = cur_pts + next_pts; + s->out->pts = cur_pts + next_pts; } else { - yadif->out->pts = AV_NOPTS_VALUE; + s->out->pts = AV_NOPTS_VALUE; } } - ret = ff_filter_frame(ctx->outputs[0], yadif->out); + ret = ff_filter_frame(ctx->outputs[0], s->out); - yadif->frame_pending = (yadif->mode&1) && !is_second; + s->frame_pending = (s->mode&1) && !is_second; return ret; } -static int checkstride(YADIFContext *yadif, const AVFrame *a, const AVFrame *b) +static int checkstride(YADIFContext *s, const AVFrame *a, const AVFrame *b) { int i; - for (i = 0; i < yadif->csp->nb_components; i++) + for (i = 0; i < s->csp->nb_components; i++) if (a->linesize[i] != b->linesize[i]) return 1; return 0; @@ -312,63 +312,63 @@ static void fixstride(AVFilterLink *link, AVFrame *f) static int filter_frame(AVFilterLink *link, AVFrame *frame) { AVFilterContext *ctx = link->dst; - YADIFContext *yadif = ctx->priv; + YADIFContext *s = ctx->priv; av_assert0(frame); - if (yadif->frame_pending) + if (s->frame_pending) return_frame(ctx, 1); - if (yadif->prev) - av_frame_free(&yadif->prev); - yadif->prev = yadif->cur; - yadif->cur = yadif->next; - yadif->next = frame; + if (s->prev) + av_frame_free(&s->prev); + s->prev = s->cur; + s->cur = s->next; + s->next = frame; - if (!yadif->cur && - !(yadif->cur = av_frame_clone(yadif->next))) + if (!s->cur && + !(s->cur = av_frame_clone(s->next))) return AVERROR(ENOMEM); - if (checkstride(yadif, yadif->next, yadif->cur)) { + if (checkstride(s, s->next, s->cur)) { av_log(ctx, AV_LOG_VERBOSE, "Reallocating frame due to differing stride\n"); - fixstride(link, yadif->next); + fixstride(link, s->next); } - if (checkstride(yadif, yadif->next, yadif->cur)) - fixstride(link, yadif->cur); - if (yadif->prev && checkstride(yadif, yadif->next, yadif->prev)) - fixstride(link, yadif->prev); - if (checkstride(yadif, yadif->next, yadif->cur) || (yadif->prev && checkstride(yadif, yadif->next, yadif->prev))) { + if (checkstride(s, s->next, s->cur)) + fixstride(link, s->cur); + if (s->prev && checkstride(s, s->next, s->prev)) + fixstride(link, s->prev); + if (checkstride(s, s->next, s->cur) || (s->prev && checkstride(s, s->next, s->prev))) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate frame\n"); return -1; } - if (!yadif->prev) + if (!s->prev) return 0; - if ((yadif->deint && !yadif->cur->interlaced_frame) || + if ((s->deint && !s->cur->interlaced_frame) || ctx->is_disabled || - (yadif->deint && !yadif->prev->interlaced_frame && yadif->prev->repeat_pict) || - (yadif->deint && !yadif->next->interlaced_frame && yadif->next->repeat_pict) + (s->deint && !s->prev->interlaced_frame && s->prev->repeat_pict) || + (s->deint && !s->next->interlaced_frame && s->next->repeat_pict) ) { - yadif->out = av_frame_clone(yadif->cur); - if (!yadif->out) + s->out = av_frame_clone(s->cur); + if (!s->out) return AVERROR(ENOMEM); - av_frame_free(&yadif->prev); - if (yadif->out->pts != AV_NOPTS_VALUE) - yadif->out->pts *= 2; - return ff_filter_frame(ctx->outputs[0], yadif->out); + av_frame_free(&s->prev); + if (s->out->pts != AV_NOPTS_VALUE) + s->out->pts *= 2; + return ff_filter_frame(ctx->outputs[0], s->out); } - yadif->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h); - if (!yadif->out) + s->out = ff_get_video_buffer(ctx->outputs[0], link->w, link->h); + if (!s->out) return AVERROR(ENOMEM); - av_frame_copy_props(yadif->out, yadif->cur); - yadif->out->interlaced_frame = 0; + av_frame_copy_props(s->out, s->cur); + s->out->interlaced_frame = 0; - if (yadif->out->pts != AV_NOPTS_VALUE) - yadif->out->pts *= 2; + if (s->out->pts != AV_NOPTS_VALUE) + s->out->pts *= 2; return return_frame(ctx, 0); } @@ -376,9 +376,9 @@ static int filter_frame(AVFilterLink *link, AVFrame *frame) static int request_frame(AVFilterLink *link) { AVFilterContext *ctx = link->src; - YADIFContext *yadif = ctx->priv; + YADIFContext *s = ctx->priv; - if (yadif->frame_pending) { + if (s->frame_pending) { return_frame(ctx, 1); return 0; } @@ -386,36 +386,36 @@ static int request_frame(AVFilterLink *link) do { int ret; - if (yadif->eof) + if (s->eof) return AVERROR_EOF; ret = ff_request_frame(link->src->inputs[0]); - if (ret == AVERROR_EOF && yadif->cur) { - AVFrame *next = av_frame_clone(yadif->next); + if (ret == AVERROR_EOF && s->cur) { + AVFrame *next = av_frame_clone(s->next); if (!next) return AVERROR(ENOMEM); - next->pts = yadif->next->pts * 2 - yadif->cur->pts; + next->pts = s->next->pts * 2 - s->cur->pts; filter_frame(link->src->inputs[0], next); - yadif->eof = 1; + s->eof = 1; } else if (ret < 0) { return ret; } - } while (!yadif->prev); + } while (!s->prev); return 0; } static av_cold void uninit(AVFilterContext *ctx) { - YADIFContext *yadif = ctx->priv; + YADIFContext *s = ctx->priv; - av_frame_free(&yadif->prev); - av_frame_free(&yadif->cur ); - av_frame_free(&yadif->next); + av_frame_free(&s->prev); + av_frame_free(&s->cur ); + av_frame_free(&s->next); } static int query_formats(AVFilterContext *ctx) -- 2.5.1
From d18e010a7852468adc26b8df2a8585eba37651f8 Mon Sep 17 00:00:00 2001 From: Ganesh Ajjanagadde <gajjanaga...@gmail.com> Date: Fri, 28 Aug 2015 01:37:48 -0400 Subject: [PATCH 5/5] avfilter/vf_xbr: use the name 's' for the pointer to the private context Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> --- libavfilter/vf_xbr.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavfilter/vf_xbr.c b/libavfilter/vf_xbr.c index 38c3b70..8586608 100644 --- a/libavfilter/vf_xbr.c +++ b/libavfilter/vf_xbr.c @@ -328,11 +328,11 @@ XBR_FUNC(4) static int config_output(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; - XBRContext *xbr = ctx->priv; + XBRContext *s = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; - outlink->w = inlink->w * xbr->n; - outlink->h = inlink->h * xbr->n; + outlink->w = inlink->w * s->n; + outlink->h = inlink->h * s->n; return 0; } @@ -352,7 +352,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; - XBRContext *xbr = ctx->priv; + XBRContext *s = ctx->priv; ThreadData td; AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); @@ -365,8 +365,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) td.in = in; td.out = out; - td.rgbtoyuv = xbr->rgbtoyuv; - ctx->internal->execute(ctx, xbr->func, &td, NULL, FFMIN(inlink->h, ctx->graph->nb_threads)); + td.rgbtoyuv = s->rgbtoyuv; + ctx->internal->execute(ctx, s->func, &td, NULL, FFMIN(inlink->h, ctx->graph->nb_threads)); out->width = outlink->w; out->height = outlink->h; @@ -377,7 +377,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) static int init(AVFilterContext *ctx) { - XBRContext *xbr = ctx->priv; + XBRContext *s = ctx->priv; static const xbrfunc_t xbrfuncs[] = {xbr2x, xbr3x, xbr4x}; uint32_t c; @@ -392,13 +392,13 @@ static int init(AVFilterContext *ctx) uint32_t y = (uint32_t)(( 299*rg + 1000*startg + 114*bg)/1000); c = bg + (rg<<16) + 0x010101 * startg; for (g = startg; g <= endg; g++) { - xbr->rgbtoyuv[c] = ((y++) << 16) + (u << 8) + v; + s->rgbtoyuv[c] = ((y++) << 16) + (u << 8) + v; c+= 0x010101; } } } - xbr->func = xbrfuncs[xbr->n - 2]; + s->func = xbrfuncs[s->n - 2]; return 0; } -- 2.5.1
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel