[FFmpeg-devel] Google Summer of Code participation

Thilo Borgmann thilo.borgmann
Wed Apr 1 02:31:10 CEST 2009



Michael Niedermayer schrieb:
> 2. add a avcodec_decode_video2() that takes a AVPacket and update
> ffmpeg.c and ffplay.c (this was planned since a long time and is welcome)
>   
I looked at this today for some time. What you proposed can be done in a 
few minutes and in fact I've already implemented it in ffplay.c and 
libavcodec/utils.c.


But there are two issues.
First, the declaration of 'AVPacket*' as a parameter for the new 
avcodec_decode_video2() function requires the previous declaration of 
AVPacket itself. Found the declaration in libavformat/avformat.h.
Before the declaration of AVPacket, avformat.h includes avcodec.h, where 
avcodec_decode_video2() resides and because of that, AVPacket should 
have already been declared...
Here is the error output from the gcc:

gcc -DHAVE_AV_CONFIG_H -I. -I"/home/gandalf/tmp/ffmpeg/ffmpeg" 
-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -std=c99 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fomit-frame-pointer -g 
-Wdeclaration-after-statement -Wall -Wno-switch -Wdisabled-optimization 
-Wpointer-arith -Wredundant-decls -Wno-pointer-sign -Wcast-qual 
-Wwrite-strings -Wundef -O3 -fno-math-errno        -c -o 
libavdevice/alldevices.o libavdevice/alldevices.c
In file included from ./libavformat/avformat.h:47,
                 from libavdevice/alldevices.c:22:
./libavcodec/avcodec.h:3045: Fehler: expected declaration specifiers or 
?...? before ?AVPacket?


Ok, I could not solve this including problem this fast and I'm in need 
of some advise of how to make the struct AVPacket known in the 
avcodec.h. Because several possibilities may arise how to solve this for 
my decoder issue but this has to be done right not to break anything 
somewhere else (got the same error after moving the AVPacker declaration 
which made it work for alldevices.c but rearised in another .c-file).


The second issue seems more complex. It is easy to pass the packet down 
to the avcodec_decode_video2() function but this function has to pass it 
to the decode_frame function which it does by the use of a function 
pointer which resides in the AVCodec struct. Of course, this struct 
declares a avcodec_decode_frame() - style pointer for this wich have to 
be changed into a avcodec_decode_frame2() -style pointer parameterized 
by an AVPacket instead of a "uint8_t and int" combination.
In my eyes, this would require a new AVCodec2 struct, using the correct 
pointer type. But this would require the update of every codec. Which is 
not difficult, because it would be generic but a lot of files to change 
and test...

I got an idea to solve this problem with less work for now and would 
like to hear what you think about that. There could be an AVCodec2 
structure introduced which is defined by the CorePNG decoder (and as 
time comes by the others as well). A pointer to such a structure might 
reside next to the AVCodec* in the AVCodecContext structure. Thus, if 
the AVCodec2 pointer is not NULL, it's functions are used by the 
avcodec_decode_video function (and alike), else the 'old' AVCodec 
functions are used.
In my eyes, this might be the least deconstructing way to enable the 
pass of AVPacket's to the decoder functions (which as Michael says is 
wanted anyway) without having to change everything at once or using 
horrible if's just for the CorePNG decoder.

TB



More information about the ffmpeg-devel mailing list