[FFmpeg-devel] [PATCH 1/2] lavf: add AVFMT_AVFRAME flag
george at nsup.org
Thu Dec 26 09:58:37 CET 2013
Le quintidi 5 nivôse, an CCXXII, Ramiro Polla a écrit :
> The problem with using plain AVFMT_RAWPICTURE is that the frame is
> unreferenced in FFmpeg while the muxer might still be using it.
The problem with using plain AVFMT_RAWPICTURE is that it is an exceptional
API. The application needs to add special case to handle it, or it will just
not work, or even worse, crash.
It can be seen, in your patch, in the fact that you need to change both lavf
and ffmpeg.c in the same commit.
Your proposal has exactly the same problem, with the additional issue that
it causes an incompatibility with the fork. Therefore, I believe it is not a
good idea as is.
I have, amongst other things, the project of adding an API to provide an
AVFrame to willing devices/muxers, but it needs to be clean and transparent.
My project is not yet finalized, and therefore you are welcome to take over
if you can achieve it faster or have a better solution. The current draft is
* Add a write_undecoded_frame() method to AVOutputFormat.
* Add a av_write_undecoded_frame() public function to exploit that method
directly (leaving out the av_interleaved_ variant for now, as it does not
matter much for devices).
* Inside write_packet() (the actual code at the core of
av_(interleaved_)write_frame()), if the output format has a
write_undecoded_frame() method but no write_packet() method, print a
warning (once) and turn back the packet into a frame, provided it is some
kind of raw format.
It requires more work than your version, although not so much I believe, but
it has the advantage of working also with the normal API, without special
case in the application, at the cost of two copies (one when the application
encodes the frame into a raw packet and a second when the library decodes
the frame). In most cases, two copies is not that bad, and in all cases they
are better than not working at all or crashing.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 836 bytes
Desc: Digital signature
More information about the ffmpeg-devel