diff options
Diffstat (limited to 'libavfilter/vf_pad.c')
-rw-r--r-- | libavfilter/vf_pad.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 9ba91ed..1634f78 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -2,20 +2,20 @@ * Copyright (c) 2008 vmrsss * Copyright (c) 2009 Stefano Sabatini * - * This file is part of Libav. + * This file is part of FFmpeg. * - * Libav is free software; you can redistribute it and/or + * FFmpeg is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * - * Libav is distributed in the hope that it will be useful, + * FFmpeg is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with Libav; if not, write to the Free Software + * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -35,10 +35,7 @@ #include "libavutil/mathematics.h" #include "drawutils.h" -static const char *var_names[] = { - "PI", - "PHI", - "E", +static const char * const var_names[] = { "in_w", "iw", "in_h", "ih", "out_w", "ow", @@ -46,15 +43,14 @@ static const char *var_names[] = { "x", "y", "a", + "sar", + "dar", "hsub", "vsub", NULL }; enum var_name { - VAR_PI, - VAR_PHI, - VAR_E, VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, @@ -62,6 +58,8 @@ enum var_name { VAR_X, VAR_Y, VAR_A, + VAR_SAR, + VAR_DAR, VAR_HSUB, VAR_VSUB, VARS_NB @@ -84,7 +82,7 @@ static int query_formats(AVFilterContext *ctx) PIX_FMT_NONE }; - avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + avfilter_set_common_pixel_formats(ctx, avfilter_make_format_list(pix_fmts)); return 0; } @@ -116,7 +114,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) av_strlcpy(pad->y_expr, "0" , sizeof(pad->h_expr)); if (args) - sscanf(args, "%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255s", + sscanf(args, "%255[^:]:%255[^:]:%255[^:]:%255[^:]:%127s", pad->w_expr, pad->h_expr, pad->x_expr, pad->y_expr, color_string); if (av_parse_color(pad->color, color_string, -1, ctx) < 0) @@ -149,14 +147,14 @@ static int config_input(AVFilterLink *inlink) pad->hsub = pix_desc->log2_chroma_w; pad->vsub = pix_desc->log2_chroma_h; - var_values[VAR_PI] = M_PI; - var_values[VAR_PHI] = M_PHI; - var_values[VAR_E] = M_E; var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w; var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; var_values[VAR_A] = (float) inlink->w / inlink->h; + var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? + (float) inlink->sample_aspect_ratio.num / inlink->sample_aspect_ratio.den : 1; + var_values[VAR_DAR] = var_values[VAR_A] * var_values[VAR_SAR]; var_values[VAR_HSUB] = 1<<pad->hsub; var_values[VAR_VSUB] = 1<<pad->vsub; @@ -253,9 +251,10 @@ static int config_output(AVFilterLink *outlink) static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int w, int h) { PadContext *pad = inlink->dst->priv; + int align = (perms&AV_PERM_ALIGN) ? AVFILTER_ALIGN : 1; AVFilterBufferRef *picref = avfilter_get_video_buffer(inlink->dst->outputs[0], perms, - w + (pad->w - pad->in_w), + w + (pad->w - pad->in_w) + 4*align, h + (pad->h - pad->in_h)); int plane; @@ -266,7 +265,7 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int int hsub = (plane == 1 || plane == 2) ? pad->hsub : 0; int vsub = (plane == 1 || plane == 2) ? pad->vsub : 0; - picref->data[plane] += (pad->x >> hsub) * pad->line_step[plane] + + picref->data[plane] += FFALIGN(pad->x >> hsub, align) * pad->line_step[plane] + (pad->y >> vsub) * picref->linesize[plane]; } @@ -413,7 +412,7 @@ AVFilter avfilter_vf_pad = { .uninit = uninit, .query_formats = query_formats, - .inputs = (AVFilterPad[]) {{ .name = "default", + .inputs = (const AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_input, .get_video_buffer = get_video_buffer, @@ -422,7 +421,7 @@ AVFilter avfilter_vf_pad = { .end_frame = end_frame, }, { .name = NULL}}, - .outputs = (AVFilterPad[]) {{ .name = "default", + .outputs = (const AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_output, }, { .name = NULL}}, |