mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
Merge commit '4753f802c00853859b7b4b8fdb79c35e082cb7f8'
* commit '4753f802c00853859b7b4b8fdb79c35e082cb7f8': vf_libopencv: use the name 's' for the pointer to the private context vf_hqdn3d: use the name 's' for the pointer to the private context vf_hflip: use the name 's' for the pointer to the private context vf_gradfun: use the name 's' for the pointer to the private context Conflicts: libavfilter/vf_gradfun.c libavfilter/vf_hflip.c libavfilter/vf_hqdn3d.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
commit
df003cbb56
@ -123,26 +123,26 @@ static void filter(GradFunContext *ctx, uint8_t *dst, const uint8_t *src, int wi
|
|||||||
|
|
||||||
static av_cold int init(AVFilterContext *ctx)
|
static av_cold int init(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
GradFunContext *gf = ctx->priv;
|
GradFunContext *s = ctx->priv;
|
||||||
|
|
||||||
gf->thresh = (1 << 15) / gf->strength;
|
s->thresh = (1 << 15) / s->strength;
|
||||||
gf->radius = av_clip((gf->radius + 1) & ~1, 4, 32);
|
s->radius = av_clip((s->radius + 1) & ~1, 4, 32);
|
||||||
|
|
||||||
gf->blur_line = ff_gradfun_blur_line_c;
|
s->blur_line = ff_gradfun_blur_line_c;
|
||||||
gf->filter_line = ff_gradfun_filter_line_c;
|
s->filter_line = ff_gradfun_filter_line_c;
|
||||||
|
|
||||||
if (ARCH_X86)
|
if (ARCH_X86)
|
||||||
ff_gradfun_init_x86(gf);
|
ff_gradfun_init_x86(s);
|
||||||
|
|
||||||
av_log(ctx, AV_LOG_VERBOSE, "threshold:%.2f radius:%d\n", gf->strength, gf->radius);
|
av_log(ctx, AV_LOG_VERBOSE, "threshold:%.2f radius:%d\n", s->strength, s->radius);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold void uninit(AVFilterContext *ctx)
|
static av_cold void uninit(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
GradFunContext *gf = ctx->priv;
|
GradFunContext *s = ctx->priv;
|
||||||
av_freep(&gf->buf);
|
av_freep(&s->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int query_formats(AVFilterContext *ctx)
|
static int query_formats(AVFilterContext *ctx)
|
||||||
@ -163,25 +163,25 @@ static int query_formats(AVFilterContext *ctx)
|
|||||||
|
|
||||||
static int config_input(AVFilterLink *inlink)
|
static int config_input(AVFilterLink *inlink)
|
||||||
{
|
{
|
||||||
GradFunContext *gf = inlink->dst->priv;
|
GradFunContext *s = inlink->dst->priv;
|
||||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
|
||||||
int hsub = desc->log2_chroma_w;
|
int hsub = desc->log2_chroma_w;
|
||||||
int vsub = desc->log2_chroma_h;
|
int vsub = desc->log2_chroma_h;
|
||||||
|
|
||||||
gf->buf = av_mallocz((FFALIGN(inlink->w, 16) * (gf->radius + 1) / 2 + 32) * sizeof(uint16_t));
|
s->buf = av_mallocz((FFALIGN(inlink->w, 16) * (s->radius + 1) / 2 + 32) * sizeof(uint16_t));
|
||||||
if (!gf->buf)
|
if (!s->buf)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
gf->chroma_w = FF_CEIL_RSHIFT(inlink->w, hsub);
|
s->chroma_w = FF_CEIL_RSHIFT(inlink->w, hsub);
|
||||||
gf->chroma_h = FF_CEIL_RSHIFT(inlink->h, vsub);
|
s->chroma_h = FF_CEIL_RSHIFT(inlink->h, vsub);
|
||||||
gf->chroma_r = av_clip(((((gf->radius >> hsub) + (gf->radius >> vsub)) / 2 ) + 1) & ~1, 4, 32);
|
s->chroma_r = av_clip(((((s->radius >> hsub) + (s->radius >> vsub)) / 2 ) + 1) & ~1, 4, 32);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
||||||
{
|
{
|
||||||
GradFunContext *gf = inlink->dst->priv;
|
GradFunContext *s = inlink->dst->priv;
|
||||||
AVFilterLink *outlink = inlink->dst->outputs[0];
|
AVFilterLink *outlink = inlink->dst->outputs[0];
|
||||||
AVFrame *out;
|
AVFrame *out;
|
||||||
int p, direct;
|
int p, direct;
|
||||||
@ -202,15 +202,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
for (p = 0; p < 4 && in->data[p]; p++) {
|
for (p = 0; p < 4 && in->data[p]; p++) {
|
||||||
int w = inlink->w;
|
int w = inlink->w;
|
||||||
int h = inlink->h;
|
int h = inlink->h;
|
||||||
int r = gf->radius;
|
int r = s->radius;
|
||||||
if (p) {
|
if (p) {
|
||||||
w = gf->chroma_w;
|
w = s->chroma_w;
|
||||||
h = gf->chroma_h;
|
h = s->chroma_h;
|
||||||
r = gf->chroma_r;
|
r = s->chroma_r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FFMIN(w, h) > 2 * r)
|
if (FFMIN(w, h) > 2 * r)
|
||||||
filter(gf, out->data[p], in->data[p], w, h, out->linesize[p], in->linesize[p], r);
|
filter(s, out->data[p], in->data[p], w, h, out->linesize[p], in->linesize[p], r);
|
||||||
else if (out->data[p] != in->data[p])
|
else if (out->data[p] != in->data[p])
|
||||||
av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p], w, h);
|
av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p], w, h);
|
||||||
}
|
}
|
||||||
|
@ -60,12 +60,12 @@ static int query_formats(AVFilterContext *ctx)
|
|||||||
|
|
||||||
static int config_props(AVFilterLink *inlink)
|
static int config_props(AVFilterLink *inlink)
|
||||||
{
|
{
|
||||||
FlipContext *flip = inlink->dst->priv;
|
FlipContext *s = inlink->dst->priv;
|
||||||
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
|
const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
|
||||||
|
|
||||||
av_image_fill_max_pixsteps(flip->max_step, NULL, pix_desc);
|
av_image_fill_max_pixsteps(s->max_step, NULL, pix_desc);
|
||||||
flip->hsub = pix_desc->log2_chroma_w;
|
s->hsub = pix_desc->log2_chroma_w;
|
||||||
flip->vsub = pix_desc->log2_chroma_h;
|
s->vsub = pix_desc->log2_chroma_h;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ static int config_props(AVFilterLink *inlink)
|
|||||||
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
||||||
{
|
{
|
||||||
AVFilterContext *ctx = inlink->dst;
|
AVFilterContext *ctx = inlink->dst;
|
||||||
FlipContext *flip = ctx->priv;
|
FlipContext *s = ctx->priv;
|
||||||
AVFilterLink *outlink = ctx->outputs[0];
|
AVFilterLink *outlink = ctx->outputs[0];
|
||||||
AVFrame *out;
|
AVFrame *out;
|
||||||
uint8_t *inrow, *outrow;
|
uint8_t *inrow, *outrow;
|
||||||
@ -91,9 +91,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
memcpy(out->data[1], in->data[1], AVPALETTE_SIZE);
|
memcpy(out->data[1], in->data[1], AVPALETTE_SIZE);
|
||||||
|
|
||||||
for (plane = 0; plane < 4 && in->data[plane]; plane++) {
|
for (plane = 0; plane < 4 && in->data[plane]; plane++) {
|
||||||
const int width = (plane == 1 || plane == 2) ? FF_CEIL_RSHIFT(inlink->w, flip->hsub) : inlink->w;
|
const int width = (plane == 1 || plane == 2) ? FF_CEIL_RSHIFT(inlink->w, s->hsub) : inlink->w;
|
||||||
const int height = (plane == 1 || plane == 2) ? FF_CEIL_RSHIFT(inlink->h, flip->vsub) : inlink->h;
|
const int height = (plane == 1 || plane == 2) ? FF_CEIL_RSHIFT(inlink->h, s->vsub) : inlink->h;
|
||||||
step = flip->max_step[plane];
|
step = s->max_step[plane];
|
||||||
|
|
||||||
outrow = out->data[plane];
|
outrow = out->data[plane];
|
||||||
inrow = in ->data[plane] + (width - 1) * step;
|
inrow = in ->data[plane] + (width - 1) * step;
|
||||||
|
@ -77,7 +77,7 @@ static void denoise_temporal(uint8_t *src, uint8_t *dst,
|
|||||||
}
|
}
|
||||||
|
|
||||||
av_always_inline
|
av_always_inline
|
||||||
static void denoise_spatial(HQDN3DContext *hqdn3d,
|
static void denoise_spatial(HQDN3DContext *s,
|
||||||
uint8_t *src, uint8_t *dst,
|
uint8_t *src, uint8_t *dst,
|
||||||
uint16_t *line_ant, uint16_t *frame_ant,
|
uint16_t *line_ant, uint16_t *frame_ant,
|
||||||
int w, int h, int sstride, int dstride,
|
int w, int h, int sstride, int dstride,
|
||||||
@ -103,8 +103,8 @@ static void denoise_spatial(HQDN3DContext *hqdn3d,
|
|||||||
src += sstride;
|
src += sstride;
|
||||||
dst += dstride;
|
dst += dstride;
|
||||||
frame_ant += w;
|
frame_ant += w;
|
||||||
if (hqdn3d->denoise_row[depth]) {
|
if (s->denoise_row[depth]) {
|
||||||
hqdn3d->denoise_row[depth](src, dst, line_ant, frame_ant, w, spatial, temporal);
|
s->denoise_row[depth](src, dst, line_ant, frame_ant, w, spatial, temporal);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pixel_ant = LOAD(0);
|
pixel_ant = LOAD(0);
|
||||||
@ -121,7 +121,7 @@ static void denoise_spatial(HQDN3DContext *hqdn3d,
|
|||||||
}
|
}
|
||||||
|
|
||||||
av_always_inline
|
av_always_inline
|
||||||
static void denoise_depth(HQDN3DContext *hqdn3d,
|
static void denoise_depth(HQDN3DContext *s,
|
||||||
uint8_t *src, uint8_t *dst,
|
uint8_t *src, uint8_t *dst,
|
||||||
uint16_t *line_ant, uint16_t **frame_ant_ptr,
|
uint16_t *line_ant, uint16_t **frame_ant_ptr,
|
||||||
int w, int h, int sstride, int dstride,
|
int w, int h, int sstride, int dstride,
|
||||||
@ -142,7 +142,7 @@ static void denoise_depth(HQDN3DContext *hqdn3d,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (spatial[0])
|
if (spatial[0])
|
||||||
denoise_spatial(hqdn3d, src, dst, line_ant, frame_ant,
|
denoise_spatial(s, src, dst, line_ant, frame_ant,
|
||||||
w, h, sstride, dstride, spatial, temporal, depth);
|
w, h, sstride, dstride, spatial, temporal, depth);
|
||||||
else
|
else
|
||||||
denoise_temporal(src, dst, frame_ant,
|
denoise_temporal(src, dst, frame_ant,
|
||||||
@ -150,7 +150,7 @@ static void denoise_depth(HQDN3DContext *hqdn3d,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define denoise(...) \
|
#define denoise(...) \
|
||||||
switch (hqdn3d->depth) {\
|
switch (s->depth) {\
|
||||||
case 8: denoise_depth(__VA_ARGS__, 8); break;\
|
case 8: denoise_depth(__VA_ARGS__, 8); break;\
|
||||||
case 9: denoise_depth(__VA_ARGS__, 9); break;\
|
case 9: denoise_depth(__VA_ARGS__, 9); break;\
|
||||||
case 10: denoise_depth(__VA_ARGS__, 10); break;\
|
case 10: denoise_depth(__VA_ARGS__, 10); break;\
|
||||||
@ -184,36 +184,36 @@ static int16_t *precalc_coefs(double dist25, int depth)
|
|||||||
|
|
||||||
static av_cold int init(AVFilterContext *ctx)
|
static av_cold int init(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
HQDN3DContext *hqdn3d = ctx->priv;
|
HQDN3DContext *s = ctx->priv;
|
||||||
|
|
||||||
if (!hqdn3d->strength[LUMA_SPATIAL])
|
if (!s->strength[LUMA_SPATIAL])
|
||||||
hqdn3d->strength[LUMA_SPATIAL] = PARAM1_DEFAULT;
|
s->strength[LUMA_SPATIAL] = PARAM1_DEFAULT;
|
||||||
if (!hqdn3d->strength[CHROMA_SPATIAL])
|
if (!s->strength[CHROMA_SPATIAL])
|
||||||
hqdn3d->strength[CHROMA_SPATIAL] = PARAM2_DEFAULT * hqdn3d->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
|
s->strength[CHROMA_SPATIAL] = PARAM2_DEFAULT * s->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
|
||||||
if (!hqdn3d->strength[LUMA_TMP])
|
if (!s->strength[LUMA_TMP])
|
||||||
hqdn3d->strength[LUMA_TMP] = PARAM3_DEFAULT * hqdn3d->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
|
s->strength[LUMA_TMP] = PARAM3_DEFAULT * s->strength[LUMA_SPATIAL] / PARAM1_DEFAULT;
|
||||||
if (!hqdn3d->strength[CHROMA_TMP])
|
if (!s->strength[CHROMA_TMP])
|
||||||
hqdn3d->strength[CHROMA_TMP] = hqdn3d->strength[LUMA_TMP] * hqdn3d->strength[CHROMA_SPATIAL] / hqdn3d->strength[LUMA_SPATIAL];
|
s->strength[CHROMA_TMP] = s->strength[LUMA_TMP] * s->strength[CHROMA_SPATIAL] / s->strength[LUMA_SPATIAL];
|
||||||
|
|
||||||
av_log(ctx, AV_LOG_VERBOSE, "ls:%f cs:%f lt:%f ct:%f\n",
|
av_log(ctx, AV_LOG_VERBOSE, "ls:%f cs:%f lt:%f ct:%f\n",
|
||||||
hqdn3d->strength[LUMA_SPATIAL], hqdn3d->strength[CHROMA_SPATIAL],
|
s->strength[LUMA_SPATIAL], s->strength[CHROMA_SPATIAL],
|
||||||
hqdn3d->strength[LUMA_TMP], hqdn3d->strength[CHROMA_TMP]);
|
s->strength[LUMA_TMP], s->strength[CHROMA_TMP]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold void uninit(AVFilterContext *ctx)
|
static av_cold void uninit(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
HQDN3DContext *hqdn3d = ctx->priv;
|
HQDN3DContext *s = ctx->priv;
|
||||||
|
|
||||||
av_freep(&hqdn3d->coefs[0]);
|
av_freep(&s->coefs[0]);
|
||||||
av_freep(&hqdn3d->coefs[1]);
|
av_freep(&s->coefs[1]);
|
||||||
av_freep(&hqdn3d->coefs[2]);
|
av_freep(&s->coefs[2]);
|
||||||
av_freep(&hqdn3d->coefs[3]);
|
av_freep(&s->coefs[3]);
|
||||||
av_freep(&hqdn3d->line);
|
av_freep(&s->line);
|
||||||
av_freep(&hqdn3d->frame_prev[0]);
|
av_freep(&s->frame_prev[0]);
|
||||||
av_freep(&hqdn3d->frame_prev[1]);
|
av_freep(&s->frame_prev[1]);
|
||||||
av_freep(&hqdn3d->frame_prev[2]);
|
av_freep(&s->frame_prev[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int query_formats(AVFilterContext *ctx)
|
static int query_formats(AVFilterContext *ctx)
|
||||||
@ -248,26 +248,26 @@ static int query_formats(AVFilterContext *ctx)
|
|||||||
|
|
||||||
static int config_input(AVFilterLink *inlink)
|
static int config_input(AVFilterLink *inlink)
|
||||||
{
|
{
|
||||||
HQDN3DContext *hqdn3d = inlink->dst->priv;
|
HQDN3DContext *s = inlink->dst->priv;
|
||||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
|
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
hqdn3d->hsub = desc->log2_chroma_w;
|
s->hsub = desc->log2_chroma_w;
|
||||||
hqdn3d->vsub = desc->log2_chroma_h;
|
s->vsub = desc->log2_chroma_h;
|
||||||
hqdn3d->depth = desc->comp[0].depth_minus1+1;
|
s->depth = desc->comp[0].depth_minus1+1;
|
||||||
|
|
||||||
hqdn3d->line = av_malloc(inlink->w * sizeof(*hqdn3d->line));
|
s->line = av_malloc(inlink->w * sizeof(*s->line));
|
||||||
if (!hqdn3d->line)
|
if (!s->line)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
hqdn3d->coefs[i] = precalc_coefs(hqdn3d->strength[i], hqdn3d->depth);
|
s->coefs[i] = precalc_coefs(s->strength[i], s->depth);
|
||||||
if (!hqdn3d->coefs[i])
|
if (!s->coefs[i])
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ARCH_X86)
|
if (ARCH_X86)
|
||||||
ff_hqdn3d_init_x86(hqdn3d);
|
ff_hqdn3d_init_x86(s);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -275,7 +275,7 @@ static int config_input(AVFilterLink *inlink)
|
|||||||
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
||||||
{
|
{
|
||||||
AVFilterContext *ctx = inlink->dst;
|
AVFilterContext *ctx = inlink->dst;
|
||||||
HQDN3DContext *hqdn3d = ctx->priv;
|
HQDN3DContext *s = ctx->priv;
|
||||||
AVFilterLink *outlink = ctx->outputs[0];
|
AVFilterLink *outlink = ctx->outputs[0];
|
||||||
|
|
||||||
AVFrame *out;
|
AVFrame *out;
|
||||||
@ -296,13 +296,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (c = 0; c < 3; c++) {
|
for (c = 0; c < 3; c++) {
|
||||||
denoise(hqdn3d, in->data[c], out->data[c],
|
denoise(s, in->data[c], out->data[c],
|
||||||
hqdn3d->line, &hqdn3d->frame_prev[c],
|
s->line, &s->frame_prev[c],
|
||||||
FF_CEIL_RSHIFT(in->width, (!!c * hqdn3d->hsub)),
|
FF_CEIL_RSHIFT(in->width, (!!c * s->hsub)),
|
||||||
FF_CEIL_RSHIFT(in->height, (!!c * hqdn3d->vsub)),
|
FF_CEIL_RSHIFT(in->height, (!!c * s->vsub)),
|
||||||
in->linesize[c], out->linesize[c],
|
in->linesize[c], out->linesize[c],
|
||||||
hqdn3d->coefs[c ? CHROMA_SPATIAL : LUMA_SPATIAL],
|
s->coefs[c ? CHROMA_SPATIAL : LUMA_SPATIAL],
|
||||||
hqdn3d->coefs[c ? CHROMA_TMP : LUMA_TMP]);
|
s->coefs[c ? CHROMA_TMP : LUMA_TMP]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->is_disabled) {
|
if (ctx->is_disabled) {
|
||||||
|
@ -86,8 +86,8 @@ typedef struct {
|
|||||||
|
|
||||||
static av_cold int smooth_init(AVFilterContext *ctx, const char *args)
|
static av_cold int smooth_init(AVFilterContext *ctx, const char *args)
|
||||||
{
|
{
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *s = ctx->priv;
|
||||||
SmoothContext *smooth = ocv->priv;
|
SmoothContext *smooth = s->priv;
|
||||||
char type_str[128] = "gaussian";
|
char type_str[128] = "gaussian";
|
||||||
|
|
||||||
smooth->param1 = 3;
|
smooth->param1 = 3;
|
||||||
@ -129,8 +129,8 @@ static av_cold int smooth_init(AVFilterContext *ctx, const char *args)
|
|||||||
|
|
||||||
static void smooth_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
|
static void smooth_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
|
||||||
{
|
{
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *s = ctx->priv;
|
||||||
SmoothContext *smooth = ocv->priv;
|
SmoothContext *smooth = s->priv;
|
||||||
cvSmooth(inimg, outimg, smooth->type, smooth->param1, smooth->param2, smooth->param3, smooth->param4);
|
cvSmooth(inimg, outimg, smooth->type, smooth->param1, smooth->param2, smooth->param3, smooth->param4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,8 +252,8 @@ typedef struct {
|
|||||||
|
|
||||||
static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
|
static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
|
||||||
{
|
{
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *s = ctx->priv;
|
||||||
DilateContext *dilate = ocv->priv;
|
DilateContext *dilate = s->priv;
|
||||||
char default_kernel_str[] = "3x3+0x0/rect";
|
char default_kernel_str[] = "3x3+0x0/rect";
|
||||||
char *kernel_str;
|
char *kernel_str;
|
||||||
const char *buf = args;
|
const char *buf = args;
|
||||||
@ -282,23 +282,23 @@ static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
|
|||||||
|
|
||||||
static av_cold void dilate_uninit(AVFilterContext *ctx)
|
static av_cold void dilate_uninit(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *s = ctx->priv;
|
||||||
DilateContext *dilate = ocv->priv;
|
DilateContext *dilate = s->priv;
|
||||||
|
|
||||||
cvReleaseStructuringElement(&dilate->kernel);
|
cvReleaseStructuringElement(&dilate->kernel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dilate_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
|
static void dilate_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
|
||||||
{
|
{
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *s = ctx->priv;
|
||||||
DilateContext *dilate = ocv->priv;
|
DilateContext *dilate = s->priv;
|
||||||
cvDilate(inimg, outimg, dilate->kernel, dilate->nb_iterations);
|
cvDilate(inimg, outimg, dilate->kernel, dilate->nb_iterations);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void erode_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
|
static void erode_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
|
||||||
{
|
{
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *s = ctx->priv;
|
||||||
DilateContext *dilate = ocv->priv;
|
DilateContext *dilate = s->priv;
|
||||||
cvErode(inimg, outimg, dilate->kernel, dilate->nb_iterations);
|
cvErode(inimg, outimg, dilate->kernel, dilate->nb_iterations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,43 +318,43 @@ static OCVFilterEntry ocv_filter_entries[] = {
|
|||||||
|
|
||||||
static av_cold int init(AVFilterContext *ctx)
|
static av_cold int init(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *s = ctx->priv;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!ocv->name) {
|
if (!s->name) {
|
||||||
av_log(ctx, AV_LOG_ERROR, "No libopencv filter name specified\n");
|
av_log(ctx, AV_LOG_ERROR, "No libopencv filter name specified\n");
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
for (i = 0; i < FF_ARRAY_ELEMS(ocv_filter_entries); i++) {
|
for (i = 0; i < FF_ARRAY_ELEMS(ocv_filter_entries); i++) {
|
||||||
OCVFilterEntry *entry = &ocv_filter_entries[i];
|
OCVFilterEntry *entry = &ocv_filter_entries[i];
|
||||||
if (!strcmp(ocv->name, entry->name)) {
|
if (!strcmp(s->name, entry->name)) {
|
||||||
ocv->init = entry->init;
|
s->init = entry->init;
|
||||||
ocv->uninit = entry->uninit;
|
s->uninit = entry->uninit;
|
||||||
ocv->end_frame_filter = entry->end_frame_filter;
|
s->end_frame_filter = entry->end_frame_filter;
|
||||||
|
|
||||||
if (!(ocv->priv = av_mallocz(entry->priv_size)))
|
if (!(s->priv = av_mallocz(entry->priv_size)))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
return ocv->init(ctx, ocv->params);
|
return s->init(ctx, s->params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
av_log(ctx, AV_LOG_ERROR, "No libopencv filter named '%s'\n", ocv->name);
|
av_log(ctx, AV_LOG_ERROR, "No libopencv filter named '%s'\n", s->name);
|
||||||
return AVERROR(EINVAL);
|
return AVERROR(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold void uninit(AVFilterContext *ctx)
|
static av_cold void uninit(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *s = ctx->priv;
|
||||||
|
|
||||||
if (ocv->uninit)
|
if (s->uninit)
|
||||||
ocv->uninit(ctx);
|
s->uninit(ctx);
|
||||||
av_free(ocv->priv);
|
av_free(s->priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
||||||
{
|
{
|
||||||
AVFilterContext *ctx = inlink->dst;
|
AVFilterContext *ctx = inlink->dst;
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *s = ctx->priv;
|
||||||
AVFilterLink *outlink= inlink->dst->outputs[0];
|
AVFilterLink *outlink= inlink->dst->outputs[0];
|
||||||
AVFrame *out;
|
AVFrame *out;
|
||||||
IplImage inimg, outimg;
|
IplImage inimg, outimg;
|
||||||
@ -368,7 +368,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
|
|||||||
|
|
||||||
fill_iplimage_from_frame(&inimg , in , inlink->format);
|
fill_iplimage_from_frame(&inimg , in , inlink->format);
|
||||||
fill_iplimage_from_frame(&outimg, out, inlink->format);
|
fill_iplimage_from_frame(&outimg, out, inlink->format);
|
||||||
ocv->end_frame_filter(ctx, &inimg, &outimg);
|
s->end_frame_filter(ctx, &inimg, &outimg);
|
||||||
fill_frame_from_iplimage(out, &outimg, inlink->format);
|
fill_frame_from_iplimage(out, &outimg, inlink->format);
|
||||||
|
|
||||||
av_frame_free(&in);
|
av_frame_free(&in);
|
||||||
|
Loading…
Reference in New Issue
Block a user