<div dir="ltr">Dear all:<div> 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.</div>
<div> 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:</div><div> 1. av_read_frame(&packet);</div>
<div> 2. av_dup_packet(&packet);</div><div> 3. AVPacket *newPakcet = av_malloc(sizeof(AVPacket));</div><div> 4. *newPacket = packet;</div><div> 5. put_queue(packet);</div><div>
6. get_queue(&packet); (Another thread)</div><div> 7. avcodec_decode_video2(packet, &frame);</div><div> 8. show frame;</div><div> Is there any mistake I took on these codes? Thanks very much.</div>
<div><br></div><div>Sincerely</div><div><br></div></div>