[FFmpeg-devel] [PATCH] lavfi/audio: fix size of copied samples.
nicolas.george at normalesup.org
Fri Jul 20 15:18:48 CEST 2012
Le duodi 2 thermidor, an CCXX, Michael Niedermayer a écrit :
> avfilter.h says:
> #define AV_PERM_WRITE 0x02 ///< can write to the buffer
> #define AV_PERM_PRESERVE 0x04 ///< nobody else can overwrite the buffer
> I interpret this as:
> 0 -> We are not allowed to write to the buffer and there is no
> gurantee that the buffer content stays as it is.
> AV_PERM_WRITE -> we can write to the buffer, so can other filters, we
> cannot assume that the buffer content stays unchanged
> AV_PERM_PRESERVE -> noone can write to the buffer, its content is
> guranteed to stay unchanged
> AV_PERM_WRITE|AV_PERM_PRESERVE -> we can write to the buffer but noone
> else is allowed to, so it wont change
> unless we change it.
> From this inerpretation i dont see why write implicates not preserve
That is not what I meant, sorry if I was not clear. What I mean is that the
semantic of PRESERVE is implemented by adding it to rej_perms always when
WRITE is requested. Let me take an example to make things more clear:
movie_dr=some_file , showinfo , drawtext=options , sink
movie_dr is a version of movie with direct-rendering implemented. The
buffers it uses must not be overwritten by others, because they may be
showinfo only reads the frame, it can operate on the frame from movie_dr
drawtext writes in the frame, it requires a copy. Since decisions are local,
the copy is between showinfo and drawtext.
What happens is:
movie_dr has READ|WRITE|PRESERVE.
It gives gives a new reference for the same buffer to showinfo; the
reference still has READ|WRITE|PRESERVE, showinfo only cares about READ.
showinfo gives a new reference to the same buffer to drawtext. But drawtext
has PRESERVE in rej_perms: lavfi makes a copy before sending it to drawtext.
In other words, PRESERVE on a reference means: someone wants to be the only
one tinkering with the contents of the buffer. If it's me (some filter),
fine. If it is someone else, and I intend to write (min_perms = WRITE), I
need a copy: thus rej_perms = PRESERVE.
There would have been other solutions to implement the same thing. For
example: in ff_start_frame / ff_filter_samples:
if ((dst->min_perms & AV_PERM_WRITE) &&
(ref->perms & AV_PERM_PRESERVE))
copy_needed = 1;
Or possibly: in movie_dr, remove WRITE before pushing to the output, no need
of PRESERVE at all (this one works for sources, not sure it would work for
filters without a lot of complexity).
I hope I was clear and accurate enough this time. This is how I understand
things. If no one finds mistakes, I will try to complete
doc/filter_design.txt with that.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the ffmpeg-devel