Changeset a11a00


Ignore:
Timestamp:
04/27/10 10:53:09 (3 years ago)
Author:
Dan Dennedy <dan@…>
Branches:
b1faa09f4dfcf63d19d2cb9fc598a583e1df1c33
Children:
649580
Parents:
4025fc
git-author:
Dan Dennedy <dan@…> (04/27/10 10:53:09)
git-committer:
Dan Dennedy <dan@…> (04/27/10 10:53:09)
Message:

Fix segfault in scale0tilt on insane widths (ticket:18).

Patch from Burkhard Plaum with indentation fix by me.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/filter/scale0tilt/scale0tilt.c

    rfb31c3 ra11a00  
    2424#include <string.h> 
    2525 
     26#define EPSILON 1e-6 
     27 
    2628typedef struct scale0tilt_instance { 
    2729        double cl, ct, cr, cb; 
     
    3234        gavl_video_frame_t* frame_src; 
    3335        gavl_video_frame_t* frame_dst; 
     36        int do_scale; 
    3437} scale0tilt_instance_t; 
    3538 
     
    3841        float dst_x, dst_y, dst_w, dst_h; 
    3942        float src_x, src_y, src_w, src_h; 
    40  
     43         
     44        inst->do_scale = 1; 
    4145        src_x = inst->w * inst->cl; 
    4246        src_y = inst->h * inst->ct; 
     
    4852        dst_w = inst->w * (1.0 - inst->cl - inst->cr) * inst->sx; 
    4953        dst_h = inst->h * (1.0 - inst->ct - inst->cb) * inst->sy; 
     54 
     55        if((dst_w < EPSILON) || (dst_h < EPSILON) ||  
     56           (src_w < EPSILON) || (src_h < EPSILON)) { 
     57                inst->do_scale = 0; 
     58                return; 
     59        } 
    5060 
    5161        if ( dst_x + dst_w > inst->w ) { 
     
    6979                dst_y = 0; 
    7080        } 
     81 
     82        if((dst_w < EPSILON) || (dst_h < EPSILON) || 
     83           (src_w < EPSILON) || (src_h < EPSILON)) { 
     84                inst->do_scale = 0; 
     85                return; 
     86        } 
     87 
    7188        gavl_video_options_t* options = gavl_video_scaler_get_options( inst->video_scaler ); 
    7289 
     
    7491        gavl_video_format_t format_dst; 
    7592 
    76         memset(&format_src, 0, sizeof(format_src)); 
    77         memset(&format_dst, 0, sizeof(format_dst)); 
     93        memset(&format_src, 0, sizeof(format_src)); 
     94        memset(&format_dst, 0, sizeof(format_dst)); 
    7895 
    7996        format_dst.frame_width  = inst->w; 
     
    275292                outframe[i] = 0; 
    276293        } 
    277         gavl_video_scaler_scale( inst->video_scaler, inst->frame_src, inst->frame_dst ); 
    278 } 
    279  
     294        if(inst->do_scale) 
     295                gavl_video_scaler_scale( inst->video_scaler, inst->frame_src, inst->frame_dst ); 
     296} 
     297 
Note: See TracChangeset for help on using the changeset viewer.