[Libav-user] Multithread decode and scaler
Andrew Randrianasulu
randrianasulu at gmail.com
Thu Aug 25 07:03:08 EEST 2022
чт, 25 авг. 2022 г., 06:16 wolverin via Libav-user <libav-user at ffmpeg.org>:
> The only advice I can give you at this point is to examine how ffmpeg
> itself does and see how your program differs.
>
>
> But I do not know where to look in ffmpeg, the source text of it is very
> confusing and there are few examples
>
>
> ffmpeg -i some_file_with_mjpeg -f null -
>
> and at the same time:
>
> top
>
> and see how much CPU it uses. If it is >>100%, then multithreading is
> used. If not, then it probably is not possible easily.
>
>
> Thank you!
> I created a file
> ffmpeg -f v4l2 -input_format mjpeg -video_size 1920x1080 -i
> /dev/video0 -c:v copy test.mjpeg
>
> Then I executed your command and saw the CPU usage of 99-100%
> ffmpeg -i test.mjpeg -f null -
>
> 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?
>
Oh, really ..I thought mjpeg already multithreaded ...but it seems mpeg1/2
is, and not mjpeg ..
>From slightly outdated ffmpeg git copy:
grep THREADS libavcodec/mpeg12dec.c
#if HAVE_THREADS
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
if (HAVE_THREADS &&
if (HAVE_THREADS && (avctx->active_thread_type &
FF_THREAD_SLICE) &&
if (HAVE_THREADS &&
AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_SLICE_THREADS,
.update_thread_context =
ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context),
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
~/ffmpeg $ grep THREADS libavcodec/mjpegdec.c
{nothing}
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 ..:(
Random paper from google search:
https://www.researchgate.net/figure/Decoding-performance-of-parallel-M-JPEG-decoder-using-WRITE-algorithm_fig1_221141784
On the other hand mjpeg *encoder* in ffmpeg actually threaded :
~/ffmpeg $ grep THREADS libavcodec/mjpegenc.c
.p.capabilities = AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_FRAME_THREADS,
So, may be you can port ideas from encoder into decoder?
______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20220825/036b73b2/attachment.htm>
More information about the Libav-user
mailing list