Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Paul B Mahol <onemda@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mjpegdec: add support for frame threading
Date: Thu, 7 Sep 2023 19:28:08 +0200
Message-ID: <CAPYw7P4ki5y_CHa6KYBGi0=pvMravW-4dvBtVpeiEd=90c5cog@mail.gmail.com> (raw)
In-Reply-To: <CAPYw7P4ppCkviHOF6ROhCMSVzwLaN4gOfG_A+CxokrDAib7kNA@mail.gmail.com>

On Thu, Sep 7, 2023 at 7:17 PM Paul B Mahol <onemda@gmail.com> wrote:

>
>
> On Tue, Dec 6, 2022 at 12:02 AM Timo Rothenpieler <timo@rothenpieler.org>
> wrote:
>
>> On 05.12.2022 15:15, Andreas Rheinhardt wrote:
>> > Timo Rothenpieler:
>> >> In my tests, this lead to a notable speed increase with the amount
>> >> of threads used. Decoding a 720p sample gave the following results:
>> >>
>> >> 1 Thread: 1428 FPS
>> >> 2 Threads: 2501 FPS
>> >> 8 Threads: 7575 FPS
>> >> Automatic: 11326 FPS (On a 16 Core/32 Threads system)
>> >> ---
>> >>   libavcodec/jpeglsdec.c |  2 +-
>> >>   libavcodec/mjpegdec.c  | 13 +++++++------
>> >>   libavcodec/sp5xdec.c   |  4 ++--
>> >>   3 files changed, 10 insertions(+), 9 deletions(-)
>> >>
>>
>
> I made almost same patch, can you apply this one?
> Thanks.
>

Actually, on better look, this one is more complicated, and does not apply
anymore.
So ignore my 'request'.


>
>
>> >> diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
>> >> index 2e6d018ea6..c0642e8e30 100644
>> >> --- a/libavcodec/jpeglsdec.c
>> >> +++ b/libavcodec/jpeglsdec.c
>> >> @@ -559,7 +559,7 @@ const FFCodec ff_jpegls_decoder = {
>> >>       .init           = ff_mjpeg_decode_init,
>> >>       .close          = ff_mjpeg_decode_end,
>> >>       FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame),
>> >> -    .p.capabilities = AV_CODEC_CAP_DR1,
>> >> +    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
>> >>       .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP |
>> >>                         FF_CODEC_CAP_SETS_PKT_DTS,
>> >>   };
>> >> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
>> >> index 9b7465abe7..d30d722398 100644
>> >> --- a/libavcodec/mjpegdec.c
>> >> +++ b/libavcodec/mjpegdec.c
>> >> @@ -54,6 +54,7 @@
>> >>   #include "exif.h"
>> >>   #include "bytestream.h"
>> >>   #include "tiff_common.h"
>> >> +#include "thread.h"
>> >>
>> >>
>> >>   static int init_default_huffman_tables(MJpegDecodeContext *s)
>> >> @@ -713,7 +714,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
>> >>                   s->avctx->pix_fmt,
>> >>                   AV_PIX_FMT_NONE,
>> >>               };
>> >> -            s->hwaccel_pix_fmt = ff_get_format(s->avctx, pix_fmts);
>> >> +            s->hwaccel_pix_fmt = ff_thread_get_format(s->avctx,
>> pix_fmts);
>> >>               if (s->hwaccel_pix_fmt < 0)
>> >>                   return AVERROR(EINVAL);
>> >>
>> >> @@ -729,7 +730,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
>> >>           }
>> >>
>> >>           av_frame_unref(s->picture_ptr);
>> >> -        if (ff_get_buffer(s->avctx, s->picture_ptr,
>> AV_GET_BUFFER_FLAG_REF) < 0)
>> >> +        if (ff_thread_get_buffer(s->avctx, s->picture_ptr,
>> AV_GET_BUFFER_FLAG_REF) < 0)
>> >>               return -1;
>> >>           s->picture_ptr->pict_type = AV_PICTURE_TYPE_I;
>> >>           s->picture_ptr->key_frame = 1;
>> >> @@ -2388,7 +2389,7 @@ static int mjpeg_get_packet(AVCodecContext
>> *avctx)
>> >>       int ret;
>> >>
>> >>       av_packet_unref(s->pkt);
>> >> -    ret = ff_decode_get_packet(avctx, s->pkt);
>> >> +    ret = ff_thread_decode_get_packet(avctx, s->pkt);
>> >>       if (ret < 0)
>> >>           return ret;
>> >>
>> >> @@ -3020,7 +3021,7 @@ const FFCodec ff_mjpeg_decoder = {
>> >>       .close          = ff_mjpeg_decode_end,
>> >>       FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame),
>> >>       .flush          = decode_flush,
>> >> -    .p.capabilities = AV_CODEC_CAP_DR1,
>> >> +    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
>> >>       .p.max_lowres   = 3,
>> >>       .p.priv_class   = &mjpegdec_class,
>> >>       .p.profiles     = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles),
>> >> @@ -3050,7 +3051,7 @@ const FFCodec ff_thp_decoder = {
>> >>       .close          = ff_mjpeg_decode_end,
>> >>       FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame),
>> >>       .flush          = decode_flush,
>> >> -    .p.capabilities = AV_CODEC_CAP_DR1,
>> >> +    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
>> >>       .p.max_lowres   = 3,
>> >>       .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP |
>> >>                         FF_CODEC_CAP_SETS_PKT_DTS,
>> >> @@ -3068,7 +3069,7 @@ const FFCodec ff_smvjpeg_decoder = {
>> >>       .close          = ff_mjpeg_decode_end,
>> >>       FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame),
>> >>       .flush          = decode_flush,
>> >> -    .p.capabilities = AV_CODEC_CAP_DR1,
>> >> +    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
>> >>       .caps_internal  = FF_CODEC_CAP_EXPORTS_CROPPING |
>> >>                         FF_CODEC_CAP_SETS_PKT_DTS |
>> FF_CODEC_CAP_INIT_CLEANUP,
>> >>   };
>> >> diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c
>> >> index 394448c5a9..8b08dc672a 100644
>> >> --- a/libavcodec/sp5xdec.c
>> >> +++ b/libavcodec/sp5xdec.c
>> >> @@ -101,7 +101,7 @@ const FFCodec ff_sp5x_decoder = {
>> >>       .init           = ff_mjpeg_decode_init,
>> >>       .close          = ff_mjpeg_decode_end,
>> >>       FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame),
>> >> -    .p.capabilities = AV_CODEC_CAP_DR1,
>> >> +    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
>> >>       .p.max_lowres   = 3,
>> >>       .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP |
>> >>                         FF_CODEC_CAP_SETS_PKT_DTS,
>> >> @@ -118,7 +118,7 @@ const FFCodec ff_amv_decoder = {
>> >>       .close          = ff_mjpeg_decode_end,
>> >>       FF_CODEC_RECEIVE_FRAME_CB(ff_mjpeg_receive_frame),
>> >>       .p.max_lowres   = 3,
>> >> -    .p.capabilities = AV_CODEC_CAP_DR1,
>> >> +    .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
>> >>       .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP |
>> >>                         FF_CODEC_CAP_SETS_PKT_DTS,
>> >>   };
>> >
>> > Can you test the sample that Michael mentioned here:
>> >
>> https://patchwork.ffmpeg.org/project/ffmpeg/patch/AS8PR01MB7944E105BE990A5D01EF89208FEF9@AS8PR01MB7944.eurprd01.prod.exchangelabs.com/
>> ?
>> > (I never got around to analyzing this, but if I am not mistaken, it
>> > shows that this decoder is not a simple one-in, one-out decoder, so that
>> > making it multithreaded will be more complicated than just adding the
>> > flag and using ff_thread_get_buffer/format.)
>>
>> Assuming this is the right file:
>> https://trac.ffmpeg.org/attachment/ticket/1915/not_interleaved.avi
>>
>> It does not decode for me at all, with or without this patch applied:
>>
>> > [mjpeg @ 0x562e81877c80] No JPEG data found in image
>> > Error while decoding stream #0:0: Invalid data found when processing
>> input
>>
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>>
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2023-09-07 17:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 13:39 [FFmpeg-devel] [PATCH 1/2] avcodec/thread: add support for frame threading receive_frame based decoders Timo Rothenpieler
2022-12-05 13:39 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mjpegdec: add support for frame threading Timo Rothenpieler
2022-12-05 14:15   ` Andreas Rheinhardt
2022-12-05 14:28     ` Paul B Mahol
2022-12-05 23:02     ` Timo Rothenpieler
2023-09-07 17:17       ` Paul B Mahol
2023-09-07 17:28         ` Paul B Mahol [this message]
2022-12-06 14:37 ` [FFmpeg-devel] [PATCH 1/2] avcodec/thread: add support for frame threading receive_frame based decoders Anton Khirnov
2022-12-06 14:39   ` Timo Rothenpieler
2022-12-06 14:43     ` Anton Khirnov
2022-12-06 15:08       ` Timo Rothenpieler
2022-12-06 16:00         ` Anton Khirnov
2022-12-07 11:43 [FFmpeg-devel] [PATCH 1/2] lavc: convert frame threading to the receive_frame() pattern Timo Rothenpieler
2022-12-07 11:43 ` [FFmpeg-devel] [PATCH 2/2] avcodec/mjpegdec: add support for frame threading Timo Rothenpieler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPYw7P4ki5y_CHa6KYBGi0=pvMravW-4dvBtVpeiEd=90c5cog@mail.gmail.com' \
    --to=onemda@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git