<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">чт, 25 авг. 2022 г., 06:16 wolverin via Libav-user <<a href="mailto:libav-user@ffmpeg.org" target="_blank" rel="noreferrer">libav-user@ffmpeg.org</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><blockquote style="border-left:1px solid #0857a6;margin:10px;padding:0 0 0 10px"><div id="m_1981439494117335302m_-6018068272671529005"><div><div><div id="m_1981439494117335302m_-6018068272671529005style_16611630120021814448_BODY">The only advice I can give you at this point is to examine how ffmpeg<br>itself does and see how your program differs.</div></div></div></div></blockquote></div><div> </div><div>But I do not know where to look in ffmpeg, the source text of it is very confusing and there are few examples</div><div> </div><div><blockquote style="border-left:1px solid #0857a6;margin:10px;padding:0 0 0 10px"><div><div><div><div>ffmpeg -i some_file_with_mjpeg -f null -<br><br>and at the same time:<br><br>top<br><br>and see how much CPU it uses. If it is >>100%, then multithreading is<br>used. If not, then it probably is not possible easily.</div></div></div></div></blockquote></div><div> </div><div>Thank you!</div><div>I created a file</div><div> ffmpeg -f v4l2 -input_format mjpeg -video_size 1920x1080 -i /dev/video0 -c:v copy test.mjpeg</div><div> </div><div>Then I executed your command and saw the CPU usage of 99-100%</div><div> ffmpeg -i test.mjpeg -f null -</div><div> </div><div>You said "it probably is not possible easily" but not impossible!? so I need to create my own thread queue for decoding or are there other solutions?</div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">Oh, really ..I thought mjpeg already multithreaded ...but it seems mpeg1/2 is, and not mjpeg ..</div><div dir="auto"><br></div><div dir="auto">From slightly outdated ffmpeg git copy:</div><div dir="auto"><br></div><div dir="auto">grep THREADS libavcodec/mpeg12dec.c</div><div dir="auto">#if HAVE_THREADS</div><div dir="auto"> if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))</div><div dir="auto"> if (HAVE_THREADS &&</div><div dir="auto"> if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE) &&</div><div dir="auto"> if (HAVE_THREADS &&</div><div dir="auto"> AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,</div><div dir="auto"> .update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context),</div><div dir="auto"> AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,</div><div dir="auto"> AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,</div><div dir="auto">~/ffmpeg $ grep THREADS libavcodec/mjpegdec.c</div><div dir="auto"><br></div><div dir="auto">{nothing}</div><div dir="auto"><br></div><div dir="auto">So ... I read somewhere at least IDCT stage of mjpeg can be parallelized, but before that we have Huffman decoding and this often not that much parallelizable ..:(</div><div dir="auto"><br></div><div dir="auto">Random paper from google search:</div><div dir="auto"><a href="https://www.researchgate.net/figure/Decoding-performance-of-parallel-M-JPEG-decoder-using-WRITE-algorithm_fig1_221141784">https://www.researchgate.net/figure/Decoding-performance-of-parallel-M-JPEG-decoder-using-WRITE-algorithm_fig1_221141784</a></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">On the other hand mjpeg *encoder* in ffmpeg actually threaded :</div><div dir="auto"><br></div><div dir="auto">~/ffmpeg $ grep THREADS libavcodec/mjpegenc.c</div><div dir="auto"> .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS,</div><div dir="auto"><br></div><div dir="auto"><br></div><div dir="auto">So, may be you can port ideas from encoder into decoder?</div><div dir="auto">______________________________________________</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" rel="noreferrer noreferrer" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="https://ffmpeg.org/mailman/listinfo/libav-user" rel="noreferrer noreferrer noreferrer" target="_blank">https://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br>
To unsubscribe, visit link above, or email<br>
<a href="mailto:libav-user-request@ffmpeg.org" rel="noreferrer noreferrer" target="_blank">libav-user-request@ffmpeg.org</a> with subject "unsubscribe".<br>
</blockquote></div></div></div>