]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_crop.c
Port MPlayer fixes for coverity issues in libmpcodecs.
[ffmpeg] / libavfilter / vf_crop.c
index 40970b12669d39c7be2efc481cb6b6b43b66257a..17b24c4c369ba963586270864714b953d630ee9b 100644 (file)
@@ -165,7 +165,7 @@ static int config_input(AVFilterLink *link)
 {
     AVFilterContext *ctx = link->dst;
     CropContext *crop = ctx->priv;
-    const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[link->format];
+    const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(link->format);
     int ret;
     const char *expr;
     double res;
@@ -186,8 +186,8 @@ static int config_input(AVFilterLink *link)
     crop->var_values[VAR_POS]   = NAN;
 
     av_image_fill_max_pixsteps(crop->max_step, NULL, pix_desc);
-    crop->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w;
-    crop->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h;
+    crop->hsub = pix_desc->log2_chroma_w;
+    crop->vsub = pix_desc->log2_chroma_h;
 
     if ((ret = av_expr_parse_and_eval(&res, (expr = crop->ow_expr),
                                       var_names, crop->var_values,
@@ -267,6 +267,7 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
     AVFilterContext *ctx = link->dst;
     CropContext *crop = ctx->priv;
     AVFilterBufferRef *ref2;
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
     int i;
 
     ref2 = avfilter_ref_buffer(picref, ~0);
@@ -300,8 +301,7 @@ static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
     ref2->data[0] += crop->y * ref2->linesize[0];
     ref2->data[0] += crop->x * crop->max_step[0];
 
-    if (!(av_pix_fmt_descriptors[link->format].flags & PIX_FMT_PAL ||
-          av_pix_fmt_descriptors[link->format].flags & PIX_FMT_PSEUDOPAL)) {
+    if (!(desc->flags & PIX_FMT_PAL || desc->flags & PIX_FMT_PSEUDOPAL)) {
         for (i = 1; i < 3; i ++) {
             if (ref2->data[i]) {
                 ref2->data[i] += (crop->y >> crop->vsub) * ref2->linesize[i];
@@ -345,6 +345,28 @@ static int end_frame(AVFilterLink *link)
     return ff_end_frame(link->dst->outputs[0]);
 }
 
+static const AVFilterPad avfilter_vf_crop_inputs[] = {
+    {
+        .name             = "default",
+        .type             = AVMEDIA_TYPE_VIDEO,
+        .start_frame      = start_frame,
+        .draw_slice       = draw_slice,
+        .end_frame        = end_frame,
+        .get_video_buffer = ff_null_get_video_buffer,
+        .config_props     = config_input,
+    },
+    { NULL }
+};
+
+static const AVFilterPad avfilter_vf_crop_outputs[] = {
+    {
+        .name         = "default",
+        .type         = AVMEDIA_TYPE_VIDEO,
+        .config_props = config_output,
+    },
+    { NULL }
+};
+
 AVFilter avfilter_vf_crop = {
     .name      = "crop",
     .description = NULL_IF_CONFIG_SMALL("Crop the input video to width:height:x:y."),
@@ -355,16 +377,6 @@ AVFilter avfilter_vf_crop = {
     .init          = init,
     .uninit        = uninit,
 
-    .inputs    = (const AVFilterPad[]) {{ .name             = "default",
-                                          .type             = AVMEDIA_TYPE_VIDEO,
-                                          .start_frame      = start_frame,
-                                          .draw_slice       = draw_slice,
-                                          .end_frame        = end_frame,
-                                          .get_video_buffer = ff_null_get_video_buffer,
-                                          .config_props     = config_input, },
-                                        { .name = NULL}},
-    .outputs   = (const AVFilterPad[]) {{ .name             = "default",
-                                          .type             = AVMEDIA_TYPE_VIDEO,
-                                          .config_props     = config_output, },
-                                        { .name = NULL}},
+    .inputs    = avfilter_vf_crop_inputs,
+    .outputs   = avfilter_vf_crop_outputs,
 };