[FFmpeg-devel] Access to previous packet in muxer

Michael Niedermayer michaelni
Tue Sep 7 20:36:46 CEST 2010


On Fri, Aug 27, 2010 at 09:08:30AM +0200, Tobias Bindhammer wrote:
> >> 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 :-)

dont forget av_dup_packet()

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100907/14dd40c1/attachment.pgp>



More information about the ffmpeg-devel mailing list