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] MULTI VLC decoding boost
Date: Fri, 15 Sep 2023 00:05:58 +0200
Message-ID: <CAPYw7P6DZGcfi6rEPJat9ZT5rDOgiJEU0Ok6h_-qSNiOL0rD6A@mail.gmail.com> (raw)
In-Reply-To: <20230914220134.GT8640@pb2>

On Fri, Sep 15, 2023 at 12:01 AM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> On Mon, Aug 28, 2023 at 07:36:17PM +0200, Paul B Mahol wrote:
> > Patches attached.
> >
> > Thanks for kurosu for pointing unmerged branches.
> >
> > The UNCACHED_PATH for x86_32 is broken with this for 2 codecs it touches.
> > Fix is trivial, to be fixed later.
> [...]
>
> > +int ff_init_vlc_multi_from_lengths(VLC *vlc, VLC_MULTI *multi, int
> nb_bits, int nb_elems,
> > +                                int nb_codes, const int8_t *lens, int
> lens_wrap,
> > +                                   const void *symbols, int
> symbols_wrap, int symbols_size,
> > +                                   int offset, int flags, void *logctx)
> > +{
> > +    VLCcode localbuf[LOCALBUF_ELEMS], *buf = localbuf;
> > +    uint64_t code;
> > +    int ret, j, len_max = FFMIN(32, 3 * nb_bits);
> > +
> > +    ret = vlc_common_init(vlc, nb_bits, nb_codes, &buf, flags);
> > +    if (ret < 0)
> > +        return ret;
> > +
> > +    multi->table = av_malloc(sizeof(*multi->table) << nb_bits);
> > +    if (!multi->table)
> > +        return AVERROR(ENOMEM);
> > +
> > +    j = code = 0;
> > +    for (int i = 0; i < nb_codes; i++, lens += lens_wrap) {
> > +        int len = *lens;
> > +        if (len > 0) {
> > +            unsigned sym;
> > +
> > +            buf[j].bits = len;
> > +            if (symbols)
> > +                GET_DATA(sym, symbols, i, symbols_wrap, symbols_size)
> > +            else
> > +                sym = i;
> > +            buf[j].symbol = sym + offset;
> > +            buf[j++].code = code;
> > +        } else if (len <  0) {
> > +            len = -len;
> > +        } else
> > +            continue;
> > +        if (len > len_max || code & ((1U << (32 - len)) - 1)) {
> > +            av_log(logctx, AV_LOG_ERROR, "Invalid VLC (length %u)\n",
> len);
> > +            goto fail;
> > +        }
> > +        code += 1U << (32 - len);
> > +        if (code > UINT32_MAX + 1ULL) {
> > +            av_log(logctx, AV_LOG_ERROR, "Overdetermined VLC tree\n");
> > +            goto fail;
> > +        }
> > +    }
> > +    ret = vlc_common_end(vlc, nb_bits, j, buf, flags, localbuf);
> > +    if (ret < 0)
> > +        goto fail;
> > +    return vlc_multi_gen(multi->table, vlc, nb_elems, j, nb_bits, buf,
> logctx);
> > +fail:
> > +    if (buf != localbuf)
> > +        av_free(buf);
> > +    return AVERROR_INVALIDDATA;
> > +}
>
> this is copy and pasted from
>
> int ff_vlc_init_from_lengths(VLC *vlc, int nb_bits, int nb_codes,
>
> leading to code duplication, it would be better if you could
> factor the duplication out
>
> thx
>

-1


>
> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> "You are 36 times more likely to die in a bathtub than at the hands of a
> terrorist. Also, you are 2.5 times more likely to become a president and
> 2 times more likely to become an astronaut, than to die in a terrorist
> attack." -- Thoughty2
>
> _______________________________________________
> 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-14 22:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-28 17:36 Paul B Mahol
2023-09-04 16:08 ` Paul B Mahol
2023-09-14 22:01 ` Michael Niedermayer
2023-09-14 22:05   ` Paul B Mahol [this message]
2023-10-22 18:01 ` Michael Niedermayer

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=CAPYw7P6DZGcfi6rEPJat9ZT5rDOgiJEU0Ok6h_-qSNiOL0rD6A@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