get_raw_image_addr() with alternate value ? - General Discussion and Assistance - CHDK Forum supplierdeeply

get_raw_image_addr() with alternate value ?

  • 5 Replies
  • 1637 Views
*

Offline Lebeau

  • ***
  • 187
get_raw_image_addr() with alternate value ?
« on: 28 / July / 2011, 22:43:12 »
Advertisements
I print get_raw_image_addr() value at each pass in raw.c and got alternate values as per:
=== pass number: 0, raw buffer:1f6b740
=== pass number: 1, raw buffer:8057c0
=== pass number: 2, raw buffer:1f6b740
=== pass number: 3, raw buffer:8057c0
=== pass number: 4, raw buffer:1f6b740
=== pass number: 5, raw buffer:8057c0

I have a A650is and get_alt_raw_image_addr() equal to get_raw_image_addr().

Some one has an explanation ?

*

Offline reyalp

  • ******
  • 12218
Re: get_raw_image_addr() with alternate value ?
« Reply #1 on: 29 / July / 2011, 00:26:50 »
Explanation:
Code: [Select]
char *hook_raw_image_addr()
{
 return (char*) (*(int*)0x5684 ? 0x11F6B740 : 0x108057C0);
 //  return (char*)0x108057C0;
}
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3138
    • Photos
Re: get_raw_image_addr() with alternate value ?
« Reply #2 on: 29 / July / 2011, 00:40:50 »
I print get_raw_image_addr() value at each pass in raw.c and got alternate values as per:
=== pass number: 0, raw buffer:1f6b740
=== pass number: 1, raw buffer:8057c0
=== pass number: 2, raw buffer:1f6b740
=== pass number: 3, raw buffer:8057c0
=== pass number: 4, raw buffer:1f6b740
=== pass number: 5, raw buffer:8057c0

I have a A650is and get_alt_raw_image_addr() equal to get_raw_image_addr().

Some one has an explanation ?

Edit: Updated function names to correct values.

Unless you provide an override function hook_alt_raw_image_addr() will return the same value as hook_raw_image_addr().

The reason for this is to allow the DNG performance optimisation I made for the G12/SX30 to be backward compatible with other cameras.

Prior to the G12/SX30 the DNG process was:
- get raw buffer address
- reverse bytes
- save buffer
- reverse bytes back

Since many cameras have two raw buffers we can skip the second call to reverse_bytes.
This is what hook_alt_raw_image_addr() is for - if implemented it returns the inactive buffer so the DNG process can be:
- get active and inactive buffer addresses
- reverse bytes from active buffer to inactive buffer
- save inactive buffer
- if active buffer == inactive buffer reverse bytes back

So if you have two buffers and you implement hook_alt_raw_image_addr() to return the inactive buffer (by reversing the logic of hook_raw_image_addr()) then the DNG save will skip the second reverse_bytes.

Phil.
« Last Edit: 29 / July / 2011, 08:01:33 by philmoz »
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

*

Offline Lebeau

  • ***
  • 187
Re: get_raw_image_addr() with alternate value ?
« Reply #3 on: 29 / July / 2011, 07:52:42 »
That was my interrogation !

I saw the conditional under "hook_raw_image_addr" and the reusability of mem space under "get_alt_raw_image_addr".

So, are these mem spaces ( raw buffer:1f6b740 and raw buffer:8057c0 ) usefull as alternate raw buffer ?

Means, if actual raw buffer (1f6b740) then alt raw buffer (8057c0) could be use to small-endianeese bytes before writing it ?

P.S.: currently, I skip unreverse and save the useless reversed jpg :(


*

Offline philmoz

  • *****
  • 3138
    • Photos
Re: get_raw_image_addr() with alternate value ?
« Reply #4 on: 29 / July / 2011, 08:04:20 »
That was my interrogation !

I saw the conditional under "hook_raw_image_addr" and the reusability of mem space under "get_alt_raw_image_addr".

So, are these mem spaces ( raw buffer:1f6b740 and raw buffer:8057c0 ) usefull as alternate raw buffer ?

Means, if actual raw buffer (1f6b740) then alt raw buffer (8057c0) could be use to small-endianeese bytes before writing it ?

P.S.: currently, I skip unreverse and save the useless reversed jpg :(

Sorry, had the wrong function names in the previous post (edited to correct function names).
hook_alt_raw_image_addr is the function you need to override to return the inactive buffer address.

To answer your question, yes this is what the G12/SX30 and any other camera that correctly implements hook_alt_raw_image_addr is doing. The active raw buffer is the one the current image is stored in, the inactive one is where the bytes are reversed into and is saved to the SD card. This way the JPEG comes out correct and you don't need to do the second call to reverse_bytes.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)

*

Offline Lebeau

  • ***
  • 187
Re: get_raw_image_addr() with alternate value ?
« Reply #5 on: 03 / August / 2011, 14:46:02 »
Well, on my A650is (100d), I just try :
Code: [Select]
char *hook_raw_image_addr()
{
 return ( char * ) ( * ( int * ) 0x5684 ? 0x11F6B740 : 0x108057C0 );
}

char *hook_alt_raw_image_addr()
{
 return ( char * ) ( * ( int * ) 0x5684 ? 0x108057C0 : 0x11F6B740 );
}

/* old function single buffer function
char *hook_raw_image_addr(){
 return ( char * ) ( * ( int * ) 0x5684 ? 0x11F6B740 : 0x108057C0 );
 //  return (char*)0x108057C0;
}
*/


in lib.c (a650/sub/100d)

AND IT WORKS !!

I'm happy :)

Then,  I use the alt raw mem area to store uncached DNG data before writing on card.

AND IT WORKS !!

I'm happy :)

« Last Edit: 03 / August / 2011, 14:47:34 by Lebeau »

 

Related Topics