Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly Language > Re: Fast way of...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 36 Topic 4980 of 5160
Post > Topic >>

Re: Fast way of splitting an image into bit planes ? (How would you re-write this code for speed up ?)

by "Skybuck Flying" <BloodyShame@[EMAIL PROTECTED] > Apr 28, 2008 at 08:43 PM

Hello,

I did a simple little test:

A four dimensional array is allocated:

The input/output is split into:

Color Component (R/G/B), Bit(0 to 7), Y, X

Then for compression this array is processed twice. (Read/Write)
Then for decompression this array is processed twice. (Read/Write)
( To mimic compression/decompression )

Playback for a 640x480 rgb file is just too slow.

Here is a code snippet:

// fields of object used:
  // components, bit, y, x
  mCompressWork : array of array of array of array of byte;
  mDeCompressWork : array of array of array of array of byte;

  mCompressInputWidth : integer;
  mCompressInputHeight : integer;

  mCompressInput : pointer;
  mCompressOutput : pointer;
  mCompressOutputSize : longword;

  mDeCompressOutputWidth : integer;
  mDeCompressOutputHeight : integer;

  mDeCompressInputSize : longword;
  mDeCompressInput : pointer;
  mDeCompressOutput : pointer;

// object methods:

// this will be called just once for the first frame and maybe once for
last 
frame for some reason
procedure TUniversalVideoCodec.CompressBegin;
begin
 // allocate stuff for compression
 SetLength( mCompressWork, 3, 8, mCompressInputHeight, 
mCompressInputWidth );
end;

// ok simple example, maybe later try splitting it up into components
{
procedure TUniversalVideoCodec.Compress;
var
 vX, vY : integer;
begin
 // compress stuff
 for vY := 0 to mCompressInputHeight-1 do
 begin
  for vX := 0 to mCompressInputWidth-1 do
  begin
   move( mCompressInput^, mCompressOutput^, 3 );
   longword(mCompressInput) := longword(mCompressInput) + 3;
   longword(mCompressOutput) := longword(mCompressOutput) + 3;
  end;
 end;

 mCompressOutputSize := mCompressInputWidth * mCompressInputHeight * 3;
end;
}

// more advanced example, split stuff up.
// will be called for each frame
procedure TUniversalVideoCodec.Compress;
var
 vX, vY : integer;
 vC, vP : longword;
begin
 // copy information to work array
 for vY := 0 to mCompressInputHeight-1 do
 begin
  for vX := 0 to mCompressInputWidth-1 do
  begin
   for vC := 0 to 2 do // component
   begin
    for vP := 0 to 7 do // bit
    begin
     mCompressWork[vC, vP, vY, vX] := ( byte( pointer( 
longword(mCompressInput) + vC )^ ) shr vP) and 1;
    end;
   end;

   longword(mCompressInput) := longword(mCompressInput) + 3;
  end;
 end;

 // copy information from work array to output
 for vY := 0 to mCompressInputHeight-1 do
 begin
  for vX := 0 to mCompressInputWidth-1 do
  begin
   for vC := 0 to 2 do // component
   begin
    byte( pointer( longword(mCompressOutput) + vC )^ ) := 0;
    for vP := 0 to 7 do // bit
    begin
     byte( pointer( longword(mCompressOutput) + vC )^ ) :=
     byte( pointer( longword(mCompressOutput) + vC )^ ) or 
(mCompressWork[vC, vP, vY, vX] shl vP);

    end;
   end;

   longword(mCompressOutput) := longword(mCompressOutput) + 3;
  end;
 end;

 mCompressOutputSize := mCompressInputWidth * mCompressInputHeight * 3;
end;

procedure TUniversalVideoCodec.CompressEnd;
begin
 // free stuff for compression
 mCompressWork := nil;
end;

// this will be called just once for the first frame and maybe once for
last 
frame for some reason
procedure TUniversalVideoCodec.DeCompressBegin;
begin
 // allocate stuff for decompression
 SetLength( mDeCompressWork, 3, 8, mDeCompressOutputHeight, 
mDeCompressOutputWidth );
end;

// simple example

{
procedure TUniversalVideoCodec.DeCompress;
var
 vX, vY : integer;
begin
 // decompress stuff
 for vY := 0 to mDeCompressOutputHeight-1 do
 begin
  for vX := 0 to mDeCompressOutputWidth-1 do
  begin
   move( mDeCompressInput^, mDeCompressOutput^, 3 );
   longword(mDeCompressInput) := longword(mDeCompressInput) + 3;
   longword(mDeCompressOutput) := longword(mDeCompressOutput) + 3;
  end;
 end;
end;
}

// more advanced example
// will be called for each frame.
procedure TUniversalVideoCodec.DeCompress;
var
 vX, vY : integer;
 vC, vP : longword;
begin
 // copy information to work array
 for vY := 0 to mDeCompressOutputHeight-1 do
 begin
  for vX := 0 to mDeCompressOutputWidth-1 do
  begin
   for vC := 0 to 2 do // component
   begin
    for vP := 0 to 7 do // bit
    begin
     mDeCompressWork[vC, vP, vY, vX] := ( byte( pointer( 
longword(mDeCompressInput) + vC )^ ) shr vP) and 1;
    end;
   end;

   longword(mDeCompressInput) := longword(mDeCompressInput) + 3;
  end;
 end;

 // copy information from work array to output
 for vY := 0 to mDeCompressOutputHeight-1 do
 begin
  for vX := 0 to mDeCompressOutputWidth-1 do
  begin
   for vC := 0 to 2 do // component
   begin
    byte( pointer( longword(mDeCompressOutput) + vC )^ ) := 0;
    for vP := 0 to 7 do // bit
    begin
     byte( pointer( longword(mDeCompressOutput) + vC )^ ) :=
     byte( pointer( longword(mDeCompressOutput) + vC )^ ) or 
(mDeCompressWork[vC, vP, vY, vX] shl vP);
    end;
   end;

   longword(mDeCompressOutput) := longword(mDeCompressOutput) + 3;
  end;
 end;
end;

// this will be called just once for the first frame and maybe once for
last 
frame for some reason
procedure TUniversalVideoCodec.DeCompressEnd;
begin
 // free stuff for decompression
 mDeCompressWork := nil;
end;

Maybe the code can somehow be re-written/modified for more speed ?

How ?

Bye,
  Skybuck.
 




 36 Posts in Topic:
Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-04-27 21:23:00 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-04-27 21:46:14 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-04-27 21:53:57 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-28 20:43:33 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 09:39:52 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 10:14:23 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 10:25:46 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 10:27:56 
Re: Fast way of splitting an image into bit planes ?
Ivan Levashew <octagra  2008-04-28 02:58:04 
Re: Fast way of splitting an image into bit planes ?
Robert Redelmeier <red  2008-04-27 21:35:35 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-04-28 09:07:10 
Re: Fast way of splitting an image into bit planes ?
Wolfgang Draxinger <wd  2008-04-28 11:12:18 
Re: Fast way of splitting an image into bit planes ? (How would
penang@[EMAIL PROTECTED]   2008-04-29 03:42:18 
Re: Fast way of splitting an image into bit planes ? (How would
"Ken Hagan" <  2008-04-29 12:46:09 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 13:56:42 
Re: Fast way of splitting an image into bit planes ? (How would
penang@[EMAIL PROTECTED]   2008-04-29 05:35:15 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 14:59:43 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 18:54:19 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 19:02:51 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 21:14:29 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-29 21:19:49 
Re: Fast way of splitting an image into bit planes ? (How would
"Skybuck Flying"  2008-04-30 11:19:55 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
"Skybuck Flying"  2008-04-30 17:20:12 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
"Skybuck Flying"  2008-04-30 17:39:30 
Re: Fast way of splitting an image into bit planes ?
Bo Schwarzstein <Bo.Sc  2008-05-01 03:54:28 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
pg <penang@[EMAIL PROT  2008-05-01 08:21:30 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
"Skybuck Flying"  2008-05-01 20:19:01 
Re: Fast way of splitting an image into bit planes ?
Terence <tbwright@[EMA  2008-05-01 16:06:03 
Re: Fast way of splitting an image into bit planes ?
pg <penang@[EMAIL PROT  2008-05-02 18:01:31 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
pg <penang@[EMAIL PROT  2008-05-02 18:03:40 
Re: Fast way of splitting an image into bit planes ? (Skybuck's
"Skybuck Flying"  2008-05-03 19:40:48 
Re: Fast way of splitting an image into bit planes ?
"windenntw@[EMAIL PR  2008-05-04 13:09:13 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-05-04 22:54:19 
Re: Fast way of splitting an image into bit planes ?
Nils <n.pipenbrinck@[E  2008-05-04 23:11:31 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-05-05 01:40:01 
Re: Fast way of splitting an image into bit planes ?
"Skybuck Flying"  2008-05-05 01:55:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 23:45:00 CDT 2008.