[FFmpeg-devel] Understanding lavfi's permissions system (was: lavfi/audio: fix size of copied samples.)

Michael Niedermayer michaelni at gmx.at
Fri Jul 27 03:09:27 CEST 2012


On Fri, Jul 27, 2012 at 12:39:41AM +0200, Nicolas George wrote:
> Le sextidi 6 thermidor, an CCXX, Michael Niedermayer a écrit :
> > I think we maybe have a different understaning of "my permissions" vs.
> > "the previous filters permissions"
> > 
> > if the previous filter holds a PRESERVE+WRITE (random example) ref
> > then this is kind of a exclusive locked write buffer. If now the
> > previous filter passes this to us it becomes our reference and our
> > lock. so rej_perms= PRESERVE would be quite odd.
> > 
> > maybe theres a problem with my view above but i dont see any ATM ...
> 
> Maybe stating it like that can work:
> 
> The permissions that a filter has on the buffer pointed by a reference are
> exactly the permissions it asked for: the value of min_perms if the buffer
> comes from an input, the second argument of ff_get_<type>_buffer if the
> buffer is just created. The perms field in the structure are only there to
> help lavfi keep track of when a copy is needed.

this is not how the API was or is supposed to work nor is it what
is implemented even with all the bugs that are there
and it causes issues as you yourself describe below
my question is still open, where is the problem with the permissions
as i interpret them ?


[...]
> there are not-so-corner cases that will not work, i.e. require a copy where,
> in fact, no copy was needed.
> 
> Take vf_fps, for example: it requires a reader's lock, otherwise, a drawtext
> after it used to draw a scrolling banner would leave a sludge¹. But a
> reader's lock, aka PRESERVE, can not be acquired on an existing buffer.
> 
> The core of the problem resides in the fact that the lock is in the
> reference, and so can only be acquired when no parallelism is possible, i.e.
> when the buffer is created. I do not think we can go around this without
> altering the API.

when a buffer with permissions X is requested one gets a buffer with X
or more permissions. Permissions should only be droped when theres
need to drop them. Code currently seem to drop more than needed


> 
> Regards,
> 
> -- 
>   Nicolas George
> 
> 
> 1: it does, test this:
> ./ffmpeg_g -re -f lavfi -i 'testsrc=r=1,fps=fps=25,drawtext=fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf:fontsize=20:fontcolor=red:text=Hello:x=10*t:y=100' -pix_fmt yuv420p -f sdl -

heres a patch to fix this

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index ac61942..e8a4187 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -827,8 +827,7 @@ AVFilter avfilter_vf_drawtext = {
                                           .end_frame        = end_frame,
                                           .config_props     = config_input,
                                           .min_perms        = AV_PERM_WRITE |
-                                                              AV_PERM_READ,
-                                          .rej_perms        = AV_PERM_PRESERVE },
+                                                              AV_PERM_READ},
                                         { .name = NULL}},
     .outputs   = (const AVFilterPad[]) {{ .name             = "default",
                                           .type             = AVMEDIA_TYPE_VIDEO, },
diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c
index 3fdac4f..a77532a 100644
--- a/libavfilter/vf_fps.c
+++ b/libavfilter/vf_fps.c
@@ -290,7 +290,8 @@ AVFilter avfilter_vf_fps = {
                                           .type            = AVMEDIA_TYPE_VIDEO,
                                           .start_frame     = null_start_frame,
                                           .draw_slice      = null_draw_slice,
-                                          .end_frame       = end_frame, },
+                                          .end_frame       = end_frame,
+                                          .min_perms       = AV_PERM_PRESERVE | AV_PERM_REUSE},
                                         { .name = NULL}},
     .outputs   = (const AVFilterPad[]) {{ .name            = "default",
                                           .type            = AVMEDIA_TYPE_VIDEO,

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120727/8a247ff1/attachment.asc>


More information about the ffmpeg-devel mailing list