Revert braindead linked list of permissions

Commited in SoC by Bobby Bingham on 2007-08-17 22:44:03

Originally committed as revision 12010 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Vitor Sessak 2008-02-15 21:38:10 +00:00
parent a4af86c878
commit 269b9847ab
1 changed files with 5 additions and 54 deletions

View File

@ -35,67 +35,19 @@ static AVFilter **filters = NULL;
#define link_dpad(link) link->dst-> input_pads[link->dstpad] #define link_dpad(link) link->dst-> input_pads[link->dstpad]
#define link_spad(link) link->src->output_pads[link->srcpad] #define link_spad(link) link->src->output_pads[link->srcpad]
/** AVFilterPicRef *avfilter_ref_pic(AVFilterPicRef *ref, int pmask)
* helper function to get a pointer to the structure telling the permissions
* the filter has on the given picture, or to create the structure if it
* does not yet exist.
*/
static AVFilterPicPerms *get_perms(AVFilterPic *pic, AVFilterContext *filter)
{ {
AVFilterPicPerms *ret;
for(ret = pic->perms; ret; ret = ret->next)
if(ret->filter == filter)
return ret;
ret = av_malloc(sizeof(AVFilterPicPerms));
ret->filter = filter;
ret->perms = 0;
ret->next = pic->perms;
pic->perms = ret;
return ret;
}
int avfilter_get_pic_perms(AVFilterPicRef *pic, AVFilterContext *filter)
{
return get_perms(pic->pic, filter)->perms;
}
void avfilter_add_pic_perms(AVFilterPicRef *pic, AVFilterContext *filter,
int perms)
{
get_perms(pic->pic, filter)->perms |= perms;
}
AVFilterPicRef *avfilter_ref_pic(AVFilterPicRef *ref, AVFilterContext *filter,
int pmask)
{
AVFilterPicPerms *pic_perms;
AVFilterPicRef *ret = av_malloc(sizeof(AVFilterPicRef)); AVFilterPicRef *ret = av_malloc(sizeof(AVFilterPicRef));
memcpy(ret, ref, sizeof(AVFilterPicRef)); memcpy(ret, ref, sizeof(AVFilterPicRef));
ret->perms &= pmask; ret->perms &= pmask;
ret->pic->refcount ++; ret->pic->refcount ++;
if(filter) {
pic_perms = get_perms(ref->pic, filter);
pic_perms->perms |= ret->perms;
}
return ret; return ret;
} }
void avfilter_unref_pic(AVFilterPicRef *ref) void avfilter_unref_pic(AVFilterPicRef *ref)
{ {
AVFilterPicPerms *perms; if(-- ref->pic->refcount == 0)
if(-- ref->pic->refcount == 0) {
for(; ref->pic->perms; ref->pic->perms = perms) {
perms = ref->pic->perms->next;
av_free(ref->pic->perms);
}
ref->pic->free(ref->pic); ref->pic->free(ref->pic);
}
av_free(ref); av_free(ref);
} }
@ -208,7 +160,6 @@ int avfilter_request_frame(AVFilterLink *link)
* forcing the source filter to do it? */ * forcing the source filter to do it? */
void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref) void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
{ {
int perms = get_perms(picref->pic, link->dst)->perms;
void (*start_frame)(AVFilterLink *, AVFilterPicRef *); void (*start_frame)(AVFilterLink *, AVFilterPicRef *);
start_frame = link_dpad(link).start_frame; start_frame = link_dpad(link).start_frame;
@ -216,11 +167,11 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref)
start_frame = avfilter_default_start_frame; start_frame = avfilter_default_start_frame;
/* prepare to copy the picture if it has insufficient permissions */ /* prepare to copy the picture if it has insufficient permissions */
if((link_dpad(link).min_perms & perms) != link_dpad(link).min_perms || if((link_dpad(link).min_perms & picref->perms) != link_dpad(link).min_perms ||
link_dpad(link).rej_perms & perms) { link_dpad(link).rej_perms & picref->perms) {
av_log(link->dst, AV_LOG_INFO, av_log(link->dst, AV_LOG_INFO,
"frame copy needed (have perms %x, need %x, reject %x)\n", "frame copy needed (have perms %x, need %x, reject %x)\n",
perms, picref->perms,
link_dpad(link).min_perms, link_dpad(link).rej_perms); link_dpad(link).min_perms, link_dpad(link).rej_perms);
link->cur_pic = avfilter_default_get_video_buffer(link, link_dpad(link).min_perms); link->cur_pic = avfilter_default_get_video_buffer(link, link_dpad(link).min_perms);