[FFmpeg-devel] Access to previous packet in muxer

Tobias Bindhammer tobias.bindhammer
Fri Aug 27 09:08:30 CEST 2010


>> is there any easy way to access the previous packet of AVPacket *pkt
>> inside the muxer's write_packet(), or do i need to clone it on my own
>> via the av_new_packet (and further functions) and hold it within my
>> muxer context?
> 
> please elaborate on what you are trying to do and why

i try to interleave contents of a current and a previous AVPacket in a
muxer. Therefore i am in need of the current and ahm, well, the previous
AVPacket :-)
The case i have is:
The encoder delivers a packet with a charset and 4 frames coresponding
to the charset, so i have:

AVPacket 1:
p1_charset_chunk1
p1_charset_chunk2
p1_charset_chunk3
p1_charset_chunk4
p1_frame1
p1_frame2
p1_frame3
p1_frame4

AVPacket 2:
p2_charset_chunk1
p2_charset_chunk2
p2_charset_chunk3
p2_charset_chunk4
p2_frame1
p2_frame2
p2_frame3
p2_frame4

now the muxer shall interleave all that like the following:

p2_charset_chunk1
p1_frame1

p2_charset_chunk2
p1_frame2

p2_charset_chunk3
p1_frame3

p2_charset_chunk4
p1_frame4
...

Thus when the resulting content is streamed to the decoding machine, it
can receive same sized blocks all way long. Without interleaving the
loading of frame1 would take way more time, compared to the other
frames, as the whole charset needs to be preloaded first. Alternatively
one could of course buffer 1 charset and 4 frames to RAM first before
displaying. But that would mean, copying all data from the NIC's buffer
to RAM first and then rereading it from RAM for decoding. That would be
too costly to achive a nice framerate.
In case of interleaving, loading of each frame takes exact the same
amount of cycles, and the frames can be decoded to their desired
locations directly when read from the NIC's buffer.
Hooray for very limited platforms :-)

At the moment i solve this, by having an AVPacket prev_pkt in my
MuxerContext, and i just copy contents of the current packet to this
prev_pkt after use. So i have all teh previoud data ready on the next
turn. But thought there might be an easier solution and hoped on things
like pkt->prev, but a look into avcodec.h destroyed my hope :-)

regards,

Toby

-- 
Dipl. Ing. Tobias Bindhammer
Institut f?r Verteilte Systeme
Oberer Eselsberg          Phone: + 49 731/502-4235
Universit?t Ulm           Fax  : + 49 731/502-4142
D-89069 Ulm               mailto:tobias.bindhammer at uni-ulm.de
http://www-vs.informatik.uni-ulm.de/~bindhammer/



More information about the ffmpeg-devel mailing list