[Libav-user] How To Duplicate AVPacket
chenxiemin at gmail.com
Thu Jun 26 02:46:59 CEST 2014
I want to split av_read_frame() and avcodec_decode_video2() in to
different thread so I need to put a queue behind them. av_read_frame() read
a packet then put the packet into queue, avcodec_decode_video2() read a
packet from the queue then decode.
But sometimes the decoded frames may contain rubbish, it's random. So I
think that AVPacket shares its data memory and overwrite by somebody before
I decode it. The following code like this:
3. AVPacket *newPakcet = av_malloc(sizeof(AVPacket));
4. *newPacket = packet;
6. get_queue(&packet); (Another thread)
7. avcodec_decode_video2(packet, &frame);
8. show frame;
Is there any mistake I took on these codes? Thanks very much.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user