static int query_formats(AVFilterContext *ctx)
{
AVFilterFormats *formats;
- enum PixelFormat pix_fmt;
+ enum AVPixelFormat pix_fmt;
int ret;
if (ctx->inputs[0]) {
formats = NULL;
- for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
+ for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
if ( sws_isSupportedInput(pix_fmt)
&& (ret = ff_add_format(&formats, pix_fmt)) < 0) {
ff_formats_unref(&formats);
}
if (ctx->outputs[0]) {
formats = NULL;
- for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
- if ( (sws_isSupportedOutput(pix_fmt) || pix_fmt == PIX_FMT_PAL8)
+ for (pix_fmt = 0; pix_fmt < AV_PIX_FMT_NB; pix_fmt++)
+ if ( (sws_isSupportedOutput(pix_fmt) || pix_fmt == AV_PIX_FMT_PAL8)
&& (ret = ff_add_format(&formats, pix_fmt)) < 0) {
ff_formats_unref(&formats);
return ret;
{
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = outlink->src->inputs[0];
- enum PixelFormat outfmt = outlink->format;
+ enum AVPixelFormat outfmt = outlink->format;
ScaleContext *scale = ctx->priv;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
int64_t w, h;
double var_values[VARS_NB], res;
char *expr;
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_A] = (double) 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;
+ (double) 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<<av_pix_fmt_descriptors[inlink->format].log2_chroma_w;
- var_values[VAR_VSUB] = 1<<av_pix_fmt_descriptors[inlink->format].log2_chroma_h;
+ var_values[VAR_HSUB] = 1 << desc->log2_chroma_w;
+ var_values[VAR_VSUB] = 1 << desc->log2_chroma_h;
/* evaluate width and height */
av_expr_parse_and_eval(&res, (expr = scale->w_expr),
/* TODO: make algorithm configurable */
- scale->input_is_pal = av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PAL ||
- av_pix_fmt_descriptors[inlink->format].flags & PIX_FMT_PSEUDOPAL;
- if (outfmt == PIX_FMT_PAL8) outfmt = PIX_FMT_BGR8;
- scale->output_is_pal = av_pix_fmt_descriptors[outfmt].flags & PIX_FMT_PAL ||
- av_pix_fmt_descriptors[outfmt].flags & PIX_FMT_PSEUDOPAL;
+ scale->input_is_pal = desc->flags & PIX_FMT_PAL ||
+ desc->flags & PIX_FMT_PSEUDOPAL;
+ if (outfmt == AV_PIX_FMT_PAL8) outfmt = AV_PIX_FMT_BGR8;
+ scale->output_is_pal = av_pix_fmt_desc_get(outfmt)->flags & PIX_FMT_PAL ||
+ av_pix_fmt_desc_get(outfmt)->flags & PIX_FMT_PSEUDOPAL;
if (scale->sws)
sws_freeContext(scale->sws);
outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d flags:0x%0x\n",
- inlink ->w, inlink ->h, av_pix_fmt_descriptors[ inlink->format].name,
+ inlink ->w, inlink ->h, av_get_pix_fmt_name( inlink->format),
inlink->sample_aspect_ratio.num, inlink->sample_aspect_ratio.den,
- outlink->w, outlink->h, av_pix_fmt_descriptors[outlink->format].name,
+ outlink->w, outlink->h, av_get_pix_fmt_name(outlink->format),
outlink->sample_aspect_ratio.num, outlink->sample_aspect_ratio.den,
scale->flags);
return 0;
ScaleContext *scale = link->dst->priv;
AVFilterLink *outlink = link->dst->outputs[0];
AVFilterBufferRef *outpicref, *for_next_filter;
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
int ret = 0;
if( picref->video->w != link->w
return ff_start_frame(outlink, outpicref);
}
- scale->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w;
- scale->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h;
+ scale->hsub = desc->log2_chroma_w;
+ scale->vsub = desc->log2_chroma_h;
outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h);
if (!outpicref)
outpicref->video->h = outlink->h;
if(scale->output_is_pal)
- ff_set_systematic_pal2((uint32_t*)outpicref->data[1], outlink->format == PIX_FMT_PAL8 ? PIX_FMT_BGR8 : outlink->format);
+ avpriv_set_systematic_pal2((uint32_t*)outpicref->data[1], outlink->format == AV_PIX_FMT_PAL8 ? AV_PIX_FMT_BGR8 : outlink->format);
av_reduce(&outpicref->video->sample_aspect_ratio.num, &outpicref->video->sample_aspect_ratio.den,
(int64_t)picref->video->sample_aspect_ratio.num * outlink->h * link->w,
return ret;
}
+static const AVFilterPad avfilter_vf_scale_inputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .start_frame = start_frame,
+ .draw_slice = draw_slice,
+ .min_perms = AV_PERM_READ,
+ },
+ { NULL }
+};
+
+static const AVFilterPad avfilter_vf_scale_outputs[] = {
+ {
+ .name = "default",
+ .type = AVMEDIA_TYPE_VIDEO,
+ .config_props = config_props,
+ },
+ { NULL }
+};
+
AVFilter avfilter_vf_scale = {
.name = "scale",
.description = NULL_IF_CONFIG_SMALL("Scale the input video to width:height size and/or convert the image format."),
.priv_size = sizeof(ScaleContext),
- .inputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO,
- .start_frame = start_frame,
- .draw_slice = draw_slice,
- .min_perms = AV_PERM_READ, },
- { .name = NULL}},
- .outputs = (const AVFilterPad[]) {{ .name = "default",
- .type = AVMEDIA_TYPE_VIDEO,
- .config_props = config_props, },
- { .name = NULL}},
+ .inputs = avfilter_vf_scale_inputs,
+ .outputs = avfilter_vf_scale_outputs,
};