From: Paul B Mahol <onemda@gmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/mlp*: improvements Date: Wed, 25 Oct 2023 21:00:28 +0200 Message-ID: <CAPYw7P4yNtmnNmwm28eCtBs9UfSSdOdyQ+MAqnq-tViHiwOFMw@mail.gmail.com> (raw) In-Reply-To: <acf0602bbfda7a07ab387cd8cfd7c1e097a945b0.camel@haerdin.se> On Wed, Oct 25, 2023 at 8:39 PM Tomas Härdin <git@haerdin.se> wrote: > > > if (c) { > > e[0] = 1 << 14; > > e[1] = 0 << 14; > > e[2] = v[1]; > > e[3] = v[0]; > > } else { > > e[0] = v[0]; > > e[1] = v[1]; > > e[2] = 0 << 14; > > e[3] = 1 << 14; > > } > > > > if (invert2x2(e, d)) { > > sum = UINT64_MAX; > > goto next; > > } > > > > You can make use of the properties of e to simplify calculating the > inverse. The determinant is always v[0]<<14, so you can just do if > (!v[0]) continue; and skip the determinant check altogether. > Even for real 2x2 matrix case? (Once one of rows is not 1, 0) ? May added such cases later. > > > if (d[i] != av_clip_intp2(d[i], 15)) { > > d[i] < INT16_MIN || d[i] > INT16_MAX is more clear and probably faster > > > + lt = ((lm * e[0]) >> 14) + ((rm * e[1]) >> 14); > > + rt = ((lm * e[2]) >> 14) + ((rm * e[3]) >> 14); > > Result is implementation-defined. Use division by (1<<14). Also add > then divide. The intermediate result is 49 bits so fits easily in 64 > bits. > > You could also simplify this calculation by again making use of the > properties of e. > > > if (c) > > v += FFABS(rt); > > else > > v += FFABS(lt); > > sum += v; > > if (sum > best_sum) > > goto next; > > Seems like this reduces to solving a linear program. > > > if ((((lt * d[0]) >> 14) + ((rt * d[1]) >> 14)) > > != lm) { > > sum = UINT64_MAX; > > goto next; > > } > > > > if ((((lt * d[2]) >> 14) + ((rt * d[3]) >> 14)) > > != rm) { > > sum = UINT64_MAX; > > goto next; > > } > > Looks like a massive hack. I'd prefer to formally verify that the > arithmetic works out. Also again you can make use of the properties of > e, or inv(e) as it were. > > /Tomas > > _______________________________________________ > 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".
next prev parent reply other threads:[~2023-10-25 18:52 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-10-25 11:12 Paul B Mahol 2023-10-25 18:39 ` Tomas Härdin 2023-10-25 18:58 ` Paul B Mahol 2023-10-25 19:00 ` Paul B Mahol [this message] 2023-10-25 19:03 ` Tomas Härdin 2023-10-25 19:59 ` Paul B Mahol 2023-10-30 13:14 ` Tomas Härdin 2023-10-30 13:30 ` Paul B Mahol
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=CAPYw7P4yNtmnNmwm28eCtBs9UfSSdOdyQ+MAqnq-tViHiwOFMw@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