Revision 269b9847 libavfilter/avfilter.c

View differences:

libavfilter/avfilter.c
35 35
#define link_dpad(link)     link->dst-> input_pads[link->dstpad]
36 36
#define link_spad(link)     link->src->output_pads[link->srcpad]
37 37

  
38
/**
39
 * helper function to get a pointer to the structure telling the permissions
40
 * the filter has on the given picture, or to create the structure if it
41
 * does not yet exist.
42
 */
43
static AVFilterPicPerms *get_perms(AVFilterPic *pic, AVFilterContext *filter)
44
{
45
    AVFilterPicPerms *ret;
46

  
47
    for(ret = pic->perms; ret; ret = ret->next)
48
        if(ret->filter == filter)
49
            return ret;
50

  
51
    ret = av_malloc(sizeof(AVFilterPicPerms));
52
    ret->filter = filter;
53
    ret->perms  = 0;
54
    ret->next   = pic->perms;
55
    pic->perms  = ret;
56

  
57
    return ret;
58
}
59

  
60
int avfilter_get_pic_perms(AVFilterPicRef *pic, AVFilterContext *filter)
61
{
62
    return get_perms(pic->pic, filter)->perms;
63
}
64

  
65
void avfilter_add_pic_perms(AVFilterPicRef *pic, AVFilterContext *filter,
66
                            int perms)
38
AVFilterPicRef *avfilter_ref_pic(AVFilterPicRef *ref, int pmask)
67 39
{
68
    get_perms(pic->pic, filter)->perms |= perms;
69
}
70

  
71
AVFilterPicRef *avfilter_ref_pic(AVFilterPicRef *ref, AVFilterContext *filter,
72
                                 int pmask)
73
{
74
    AVFilterPicPerms *pic_perms;
75 40
    AVFilterPicRef *ret = av_malloc(sizeof(AVFilterPicRef));
76 41
    memcpy(ret, ref, sizeof(AVFilterPicRef));
77 42
    ret->perms &= pmask;
78 43
    ret->pic->refcount ++;
79

  
80
    if(filter) {
81
        pic_perms = get_perms(ref->pic, filter);
82
        pic_perms->perms |= ret->perms;
83
    }
84

  
85 44
    return ret;
86 45
}
87 46

  
88 47
void avfilter_unref_pic(AVFilterPicRef *ref)
89 48
{
90
    AVFilterPicPerms *perms;
91

  
92
    if(-- ref->pic->refcount == 0) {
93
        for(; ref->pic->perms; ref->pic->perms = perms) {
94
            perms = ref->pic->perms->next;
95
            av_free(ref->pic->perms);
96
        }
49
    if(-- ref->pic->refcount == 0)
97 50
        ref->pic->free(ref->pic);
98
    }
99 51
    av_free(ref);
100 52
}
101 53

  
......
208 160
 * forcing the source filter to do it? */
209 161
void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
210 162
{
211
    int perms = get_perms(picref->pic, link->dst)->perms;
212 163
    void (*start_frame)(AVFilterLink *, AVFilterPicRef *);
213 164

  
214 165
    start_frame = link_dpad(link).start_frame;
......
216 167
        start_frame = avfilter_default_start_frame;
217 168

  
218 169
    /* prepare to copy the picture if it has insufficient permissions */
219
    if((link_dpad(link).min_perms & perms) != link_dpad(link).min_perms ||
220
        link_dpad(link).rej_perms & perms) {
170
    if((link_dpad(link).min_perms & picref->perms) != link_dpad(link).min_perms ||
171
        link_dpad(link).rej_perms & picref->perms) {
221 172
        av_log(link->dst, AV_LOG_INFO,
222 173
                "frame copy needed (have perms %x, need %x, reject %x)\n",
223
                perms,
174
                picref->perms,
224 175
                link_dpad(link).min_perms, link_dpad(link).rej_perms);
225 176

  
226 177
        link->cur_pic = avfilter_default_get_video_buffer(link, link_dpad(link).min_perms);

Also available in: Unified diff