[Libav-user] draw_horiz_band and frame multi-thread question

Arnaud Carré arnaud.carre at gmail.com
Fri Nov 6 11:39:13 CET 2015


Hi Everyone,

I'm writing a h264 video player supporting very high res ( about 
16000*8000 pixels), running with DirectX11 / windows.

To minimize memory copy between AVFrame & GPU texture, I want to use the 
draw_horiz_band callback. It's not well documented. My first version is 
working when I force the H264 decoder to 1 thread ( 
m_pVideoCodecCtx->thread_count = 1; before avcodec_open2() )

My problem is when I activate multi-thread h264 decoding. 
draw_horiz_band is called from several threads in no special order. 
that's perfectly fine to me. My problem is that draw_horiz_band still to 
be called "after" the end of "avcodec_decode_video2(m_pVideoCodecCtx, 
m_pVideoFrame, &iFrameFinished, pPacket);"

Currently I'm doing this pseudo code:

(1)    lock directx texture
(2)   avcodec_decode_video2()    -> start to call draw_horiz_band in //
(3)   unlock directx texture
(4)   render texture to screen

Between (3) and (4) I still have some draw_horiz_band callback, which is 
bad because I already "unlock" the texture in (3).

I'm looking to kind of thread "fence" to be sure the frame is complete. 
a kind of "wait all threads have done the frame".

Anyone could help?

thanks in advance
Arnaud

NOTE: avcodec_decode_video2() is in a loop till "frame_finished", so 
when I go to (3) I know a complete frame is supposed to be ready
NOTE2: again, everything is perfectly working if I force decoding on one 
thread. But obviously I need multi-thread decoding speed


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the Libav-user mailing list