Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3800338
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:52:38+00:00 2026-05-19T13:52:38+00:00

I am using Delphi 2007 and working on some presentation software. The current module

  • 0

I am using Delphi 2007 and working on some presentation software. The current module I am working on is the transition filter for video. The transition code I am using (TPicShow’s PSEffects unit) requires and X and a Y value based on the dimensions of the frame and the progress of the transition. Here is the code

Type
TPercent = 0..100;
var
ATo  : TBitmap; //
Prog : Integer; //Progress of the transition

      if ATo.Width >= ATo.Height then
    begin
      X := MulDiv(ATo.Width, Prog, High(TPercent));
      Y := MulDiv(X, ATo.Height, ATo.Width);
    end
  else
    begin
      Y := MulDiv(ATo.Height, Prog, High(TPercent));
      X := MulDiv(Y, ATo.Width, ATo.Height);
    end;

I am trying to optimize this and saw that I could save the calculations that would be constant (until the dimensions of ATo change) and remove 2 division calculations each frame.

So it would be something like

{All of these are calculated when the dimensions of ATo Change}
WDP : real; // width divided by High(TPercent)
HDW : real; // Height divided by width
HDP : real; // Height divided by High(TPercent)
WDH : real; // Width divided by Height

  if ATo.Width >= ATo.Height then
    begin
      X := Trunc(WDP * Prog);
      Y := Trunc(HDW * X);
    end
  else
    begin
      Y := Trunc(HDP * Prog);
      X := Trunc(WDH * Y);
    end;

It sounds good but not having the actual code of MulDiv I cant be sure. If it simply does (very simplified)

MulDiv(a,b,c : Integer)
begin
  Round((A*B)/C);
end

Then I know my change will be more efficient, however if MulDiv does anything very cool with optimizing the function (Which I’d thing it might) then I’m not sure if my change would net me anything.

Would my change be more efficient?

EDIT: I have not yet implemented this, I’m just entertaining the notion.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:52:39+00:00Added an answer on May 19, 2026 at 1:52 pm

    I’d be very surprised if calls to MulDiv, which is implemented using integer operations, were inefficient and the source of your performance problems. Have you timed your program? Have you used a profiler to identify the hot spots in your app?

    Personally I think it is unlikely that a switch from integer to double precision floating point operations is likely to yield performance improvements.

    In any case, my guess would be that you have other code which you call after the code you have shown, which uses X and Y and which consumes orders of magnitude more CPU than this little snippet. You presumably don’t calculate X and Y and then discard them: what do you do with them?

    EDIT: The Wine implementation of MulDiv is presumably very close to the Windows one, and the guts of that is so:

    if ( ( (nMultiplicand <  0) && (nMultiplier <  0) ) ||
         ( (nMultiplicand >= 0) && (nMultiplier >= 0) ) )
      ret = (((LONGLONG)nMultiplicand * nMultiplier) + (nDivisor/2)) / nDivisor;
    else
      ret = (((LONGLONG)nMultiplicand * nMultiplier) - (nDivisor/2)) / nDivisor;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working in Delphi 2007. Net, where I can find an example of using
Using Delphi 2007 I can write the following code: interface TTestType = (ttTest1, ttTest2);
I'm using Delphi 2007, and I am looking for some newer looking glyphs to
I'm using Delphi 2007. How can I put a GIF/PNG image on a BitBtn
I have a Windows CGI created with Delphi 2007 using CGIExpert that I need
I have a rather large (freeware) project written with Delphi 2007 which is using
I`m using Delphi 2009 and want to operate some XML data. I heard that
I'm using Delphi and need to get the current Windows DNS server IP address
I'm using Delphi 2007 Pro. I have a runtime package that includes a number
Simple problem. I'm working on a Delphi 2007/WIN32 application which now uses MS Access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.