Author Topic: ProcessTwoInTwoOutLosslessPath  (Read 61524 times)


festr

  • New to the forum
  • *
  • Posts: 30
Re: ProcessTwoInTwoOutLosslessPath
« Reply #151 on: April 26, 2017, 03:14:10 PM »
thank you! It works including vertical stripes removing.

Alex - is vertical stripes removing possible inside the camera before it is even compressed? Or the vertical stripes has to be always corrected out of the camera?

DeafEyeJedi

  • Hero Member
  • *****
  • Posts: 2939
  • 5D3 / M1 / 7D / 70D / SL1
Re: ProcessTwoInTwoOutLosslessPath
« Reply #152 on: April 26, 2017, 05:50:38 PM »
can you please try this patch?
https://pastebin.com/Ggm0nkw4

Wonderful stuff and Thanks @g3gg0!
5D3.113 • 5D3.123 • EOSM.203 • 7D.203 • 70D.112 • 100D.101


Greg

  • Hero Member
  • *****
  • Posts: 550
Re: ProcessTwoInTwoOutLosslessPath
« Reply #154 on: May 05, 2017, 11:49:43 PM »
It works with FRSP but the image is not decoded.

Code: [Select]
if (is_camera("500D", "1.1.1"))
{
    /* uses TwoInTwoOutJpegPath, but functions are mostly compatible */
    TTL_SetArgs     = (void *) 0xFF1AD47C;
    TTL_Prepare     = (void *) 0xFF252748;
    TTL_RegisterCBR = (void *) 0xFF2517D0;
    TTL_Start       = (void *) 0xFF2527B8;
    TTL_Stop        = (void *) 0xFF2527F0;
    TTL_Finish      = (void *) 0xFF252828;

    TTL_ResLock     = (void *) MEM(0x39D0);
}

500D edmac RD1 default configuration :
Code: [Select]
struct edmac_info RD1_info = {
    .xa     = 1648 * 14/8,
    .xb     = 1616 * 14/8,
    .yb     = 3208 - 1,
    .xn     = 2,
    .off1a  = 4832 * 14/8 - 1648 * 14/8,
    .off1b  = 4832 * 14/8 - 1616 * 14/8,
    .off2b  = 0xe623490,
};

struct edmac_info RD1_info = {
    .xa     = slice1 * 14/8,
    .xb     = slice3 * 14/8,
    .yb     = height + 4 - 1,
    .xn     = 2,
    .off1a  = width * 14/8 - slice1 * 14/8,
    .off1b  = width * 14/8 - slice3 * 14/8,
    .off2b  = (((width * 14/8) * (height + 4 - 1) + 56) * -1 & 0xFFFFFFE),  //digic 3/4
};

7D edmac RD1 default configuration :
Code: [Select]
struct edmac_info RD1_info = {
    .xa     = 1760 * 14/8,
    .xb     = 1920 * 14/8,
    .yb     = 3520 - 1,
    .xn     = 2,
    .off1a  = 5360 * 14/8 - 1760 * 14/8,
    .off1b  = 5360 * 14/8 - 1920 * 14/8,
    .off2b  = 0xe08556c,
};

Comparison of configuration 500D vs 7D - https://www.diffnow.com/?report=92yqa

Current interpretation - http://s24.postimg.org/uu3knpc0z/ttj-config3.png/

Greg

  • Hero Member
  • *****
  • Posts: 550
Re: ProcessTwoInTwoOutLosslessPath
« Reply #155 on: May 07, 2017, 06:06:58 PM »
It works with live view (not decoded) but we have a problem.

When I take a silent simple picture (LV) it will wait with processing until I get out of LV (just go to play mode).

Conflict with live view reslock :
Code: [Select]
0x5000d,
0x5000f,
0x5001a,
0x80000,
0x130006,
0x130008,
0x130012,
0x130014,
0x130018,
0x13001c,

Some notes :
Code: [Select]
int slice1 = (width + 80 + 32) / 3;
int slice2 = (width + 80 + 32) / 3;
int slice3 = (width + 80 + 32) / 3 - 32;

int sliceerr = slice1 + slice2 + slice3 - width;
   
if (sliceerr != 80)
{
    printf("ERROR slice size margin %d\n", sliceerr);
    return -2;
}

EngDrvOut(0xc0f08548, PACK32(slice3 - 2, height + 3));
EngDrvOut(0xc0f08554, PACK32(width + 16, height + 4));
EngDrvOut(0xc0f0858c, slice1 - 32);
EngDrvOut(0xc0f08594, slice1 - 2);
EngDrvOut(0xc0f0d014, PACK32(slice3, height + 3));
EngDrvOut(0xc0f0d018, slice3 + 11);
EngDrvOut(0xc0f0d01c, slice2);
EngDrvOut(0xc0f0d020, slice2 + 3);
EngDrvOut(0xc0f0d024, slice1);
EngDrvOut(0xc0f0d054, PACK32(slice3 + 7, height + 4));
EngDrvOut(0xc0f0d05c, slice2 - 9);
EngDrvOut(0xc0f0d080, PACK32(slice3 + 7, height - 1));
EngDrvOut(0xc0f0d088, slice2 - 9);
EngDrvOut(0xC0F13068, PACK32(width - 1, height - 1));
EngDrvOut(0xc0f12010, PACK32(slice1 - 33, height - 37));
EngDrvOut(0xc0f12014, PACK32(slice3 - 17, height - 37));
EngDrvOut(0xc0f1201c, PACK32((slice1 - 33) / 8, (height  - 37) / 8));
EngDrvOut(0xc0f12020, PACK32((slice3 - 17) / 8, (height  - 37) / 8));

struct edmac_info RD1_info = {
    .xa     = slice1 * 14/8,
    .xb     = slice3 * 14/8,
    .yb     = height + 4 - 1,
    .xn     = 2,
    .off1a  = width * 14/8 - slice1 * 14/8,
    .off1b  = width * 14/8 - slice3 * 14/8,
    .off2b  = (((width * 14/8) * (height + 4 - 1) + 56) * -1 & 0xFFFFFFE),  //digic 3/4
};

500D ML TTJ_Start :
Code: [Select]
*** StartEDmac(0x3, 0x0), from ff28f6e4
    addr c000064, ptr c000064, size
StartEDmac(^^)/=== (3)(0)(0xc000064) ===
[ENGIO](Addr:0xc0f04304, Data:0x20000001) EngDrvOut  //WR1
[ENGIO](Addr:0xc0f04300, Data:0x       1) EngDrvOut  //WR1
[ENGIO](Addr:0xc0f12000, Data:0x       1)[0]
[ENGIO](Addr:0xc0f13048, Data:0x       3)[1]
[ENGIO](Addr:0xc0f13060, Data:0x       0)[2]
[ENGIO](Addr:0xc0f13000, Data:0x       0) EngDrvOut
[ENGIO](Addr:0xc0f13048, Data:0x       3) EngDrvOut
[ENGIO](Addr:0xc0f1304c, Data:0x       0) EngDrvOut
[ENGIO](Addr:0xc0f13004, Data:0x       1) EngDrvOut
[ENGIO](Addr:0xc0f0d000, Data:0x       1)[0]         
[ENGIO](Addr:0xc0f08540, Data:0x       1)[1]         //RSHD_ENB
[ENGIO](Addr:0xc0f08070, Data:0x       1)[2]         //UNPACK24
*** StartEDmac(0xa, 0x2), from ff251bc0
    addr 8008484, ptr 8008484, size
StartEDmac(^^)/=== (10)(2)(0x8008484) ===
[ENGIO](Addr:0xc0f04a04, Data:0x60020000) EngDrvOut  //RD1
[ENGIO](Addr:0xc0f04a00, Data:0x       1) EngDrvOut  //RD1

lorenzo353

  • New to the forum
  • *
  • Posts: 4
Re: ProcessTwoInTwoOutLosslessPath
« Reply #156 on: May 09, 2017, 10:50:08 PM »
Hi Greg,

how do you find slice1, slice3, height and width values, compared to this table (extracted from CR2 files)
http://lclevy.free.fr/cr2/#app, Sensor information ?
https://github.com/lclevy/libcraw2/blob/master/docs/cr2_database.txt
and this poster:
https://github.com/lclevy/libcraw2/blob/master/docs/cr2_lossless.pdf

Kind regards,

Laurent

It works with FRSP but the image is not decoded.

500D edmac RD1 default configuration :
Code: [Select]
struct edmac_info RD1_info = {
    .xa     = 1648 * 14/8,
    .xb     = 1616 * 14/8,
    .yb     = 3208 - 1,
    .xn     = 2,
    .off1a  = 4832 * 14/8 - 1648 * 14/8,
    .off1b  = 4832 * 14/8 - 1616 * 14/8,
    .off2b  = 0xe623490,
};

struct edmac_info RD1_info = {
    .xa     = slice1 * 14/8,
    .xb     = slice3 * 14/8,
    .yb     = height + 4 - 1,
    .xn     = 2,
    .off1a  = width * 14/8 - slice1 * 14/8,
    .off1b  = width * 14/8 - slice3 * 14/8,
    .off2b  = (((width * 14/8) * (height + 4 - 1) + 56) * -1 & 0xFFFFFFE),  //digic 3/4
};

7D edmac RD1 default configuration :
Code: [Select]
struct edmac_info RD1_info = {
    .xa     = 1760 * 14/8,
    .xb     = 1920 * 14/8,
    .yb     = 3520 - 1,
    .xn     = 2,
    .off1a  = 5360 * 14/8 - 1760 * 14/8,
    .off1b  = 5360 * 14/8 - 1920 * 14/8,
    .off2b  = 0xe08556c,
};

Comparison of configuration 500D vs 7D - https://www.diffnow.com/?report=92yqa

Current interpretation - http://s24.postimg.org/uu3knpc0z/ttj-config3.png/

Greg

  • Hero Member
  • *****
  • Posts: 550
Re: ProcessTwoInTwoOutLosslessPath
« Reply #157 on: May 10, 2017, 12:11:25 AM »
I found this in dm-spy log and my interpretation. Edmac configuration also explains this.
I needed this to configure the image processor to live view/video mode.

Looking at your link - http://lclevy.free.fr/cr2/#app
Look at EOS Kiss X3 (500D) :
Code: [Select]
sensor width = 4832
slices[0] = 2
slices[1] = 1616
slices[2] = 1600

1616*2 + 1600 = 4832

Of course, the sizes needed for decoding may be slightly different.

lorenzo353

  • New to the forum
  • *
  • Posts: 4
Re: ProcessTwoInTwoOutLosslessPath
« Reply #158 on: May 10, 2017, 09:52:25 PM »
thanks Greg,

I added a section in  my doc:
http://lclevy.free.fr/cr2/index.html#ml
to highlight Magic Lantern work and links with Canon Raw v2 format interpretation.

please let me know if you know other useful information to open this proprietary format...

Laurent

festr

  • New to the forum
  • *
  • Posts: 30
Re: ProcessTwoInTwoOutLosslessPath
« Reply #159 on: June 03, 2017, 11:57:38 AM »
will be possible in near future using lossless compression alongside with sound recording? Anyone working on it or there are too much work to be done?

Walter Schulz

  • Hero Member
  • *****
  • Posts: 5591

festr

  • New to the forum
  • *
  • Posts: 30
Re: ProcessTwoInTwoOutLosslessPath
« Reply #161 on: June 03, 2017, 01:47:30 PM »
Is it possible to have both old raw rec with the sound (old module) with the new one in the same build? In case I want to decide recording audio without the compression but most of the time will be no audio with compression.

Walter Schulz

  • Hero Member
  • *****
  • Posts: 5591
Re: ProcessTwoInTwoOutLosslessPath
« Reply #162 on: June 03, 2017, 01:54:52 PM »
Keep 2 cards and change them if needed.

festr

  • New to the forum
  • *
  • Posts: 30
Re: ProcessTwoInTwoOutLosslessPath
« Reply #163 on: June 05, 2017, 01:14:26 AM »
good idea!

reddeercity

  • Hero Member
  • *****
  • Posts: 1366
Re: ProcessTwoInTwoOutLosslessPath
« Reply #164 on: June 30, 2017, 07:39:41 AM »
Found this today on my 5d2 rom.bin string
Code: [Select]
3373. ff088c74 StartYuvToJpegPath(%d)
3374. ff088f34 sdfExecuteMem1ToRawPath(%d)
3375. ff088f54 RAW_OBWB
3376. ff088f60 ->FindObject RAW_OBWB
3377. ff088f7c SRAW_OBWB
3378. ff088f8c ->Unknown PictureSize(Mem1ToRaw)
3379. ff088fb0 sdfExecuteMem1ToRawPath(%d)
3380. ff088fcd (SemOK)
3381. ff088fd8 ProcessTwoInTwoOutJpegPath(R) Start(%d)
3382. ff089000 ProcessTwoInTwoOutJpegPath(R) End(%d)
3383. ff089028 ->FindObject SRAW_OBWB
3384. ff0892d4 sdfExecuteMem1ToJpegPath(%d)
3385. ff08930c ProcessTwoInTwoOutJpegPath(J) Start(%d)
3386. ff089334 ProcessTwoInTwoOutJpegPath(J) End(%d)
Not that I know how to use this yet but it looks like's it maybe possible to have lossless on 5d2 .

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10064
  • 5D Mark Free
Re: ProcessTwoInTwoOutLosslessPath
« Reply #165 on: June 30, 2017, 10:02:11 AM »
First step: get a log that contains these strings. The startup-log builds should be fine to get started; to get more details in the log file, see episode #2 earlier in this thread.

You'll need to understand:
- how these things work in vanilla firmware (qemu with "-d io" is very useful for this)
- how to call them from your code (what functions to call, what parameters they take, what preconditions they might require - see previous messages)
- what parameters and/or registers to change and how, in order to modify resolution (see previous messages, in particular the ones from Greg)
- how to fix the conflicts with LiveView, in order to call it there (ResLock; unfortunately, this step was unsuccessful on 500D).

reddeercity

  • Hero Member
  • *****
  • Posts: 1366
Re: ProcessTwoInTwoOutLosslessPath
« Reply #166 on: July 01, 2017, 06:38:07 AM »
Ok --I'll do my best to port this to the 5d2 (swimming in the deep end now , hope there's life jacket near by  :P

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10064
  • 5D Mark Free
Re: ProcessTwoInTwoOutLosslessPath
« Reply #167 on: July 02, 2017, 09:05:57 AM »
I'd suggest to start with smaller goals - by 1 or 2 orders of magnitude :D

For example, look up "easy coding task" around the forum and pick one.

ErwinH

  • New to the forum
  • *
  • Posts: 10
Re: ProcessTwoInTwoOutLosslessPath
« Reply #168 on: August 07, 2017, 01:17:23 PM »
Good to verify some of the 700D addresses. Still can't save lossless full res DNG's but the warning messages and crashes are gone.

Had some fun trying to continue where dfort finished. After some searching, trying, failing and starting again I got the 700d taking full res silent pictures in Lossless DNG. Still in the default resolution, but at least it's a start.

Code: [Select]
    if (is_camera("700D", "1.1.4"))
    {
        /* ProcessTwoInTwoOutJpegath, 700D 1.1.4 */
        TTL_SetArgs     = (void *) 0xFF35F510;      /* fills TTJ_Args struct; PictureSize(Mem1ToRaw) */
        TTL_Prepare     = (void *) 0xFF424BA4;      /* called right after ProcessTwoInTwoOutJpegath(R) Start(%d); */
                                                    /* calls [TTJ] GetPathResources and sets up the encoder for RAW */
        TTL_RegisterCBR = (void *) 0xFF423B88;      /* RegisterTwoInTwoOutJpegPathCompleteCBR */
        TTL_SetFlags    = (void *) set_flags_700D;  /* this function is inline on 700D */
        TTL_Start       = (void *) 0xFF424C4C;      /* called next; starts the EDmac transfers */
        TTL_Stop        = (void *) 0xFF423DD4;      /* called right after sssStopMem1ToRawPath */
        TTL_Finish      = (void *) 0xFF424CBC;      /* called next; calls UnlockEngineResources and returns output size from JpCoreCompleteCBR */
    }

    uint32_t resources[] = {
        0x10002,                        /* read channel 0x8 */
        edmac_channel_to_index(0x20),   /* write channel 0x11 */
        0x20005,
        0x20016,
        0x30002,
        0x50034,
        0x5002d,
        0x50010,
        0x90001,
        0x90000,
        0xa0000,
        0x160000,
        0x260000,
        0x260001,
        0x260002,
        0x260003,
    };
Code: [Select]
    TTL_Args.WR1_Channel = 0x20;

Shooting simple silent photo's is hit or miss and in the wrong aspect ratio.

dfort

  • Hero Member
  • *****
  • Posts: 1747
Re: ProcessTwoInTwoOutLosslessPath
« Reply #169 on: August 12, 2017, 09:48:28 PM »
I got the 700d taking full res silent pictures in Lossless DNG.

Nice! Do you have something on bitbucket you could share?

I tried using your changes--note that you also need this:

Code: [Select]
static void set_flags_700D()
{
    EngDrvOut(0xC0F37010, (shamem_read(0xC0F37010) & 0xFFE3FFFF) | 0xC0000);
    EngDrvOut(0xC0F3704C, (shamem_read(0xC0F3704C) & 0xFFFFFFC0) | 0x20);
    EngDrvOut(0xC0F37074, (shamem_read(0xC0F37074) & 0xFFC0FFFF) | 0x180000);
    EngDrvOut(0xC0F37078, (shamem_read(0xC0F37078) & 0xFFC0FFFF) | 0x180000);
}

Branching off the compressed_raw branch and adding your changes it does build and I was able to shoot silent stills with the Lossless DNG setting but they were not compressed. How did you do it?
EOSM.202 EOSM.203 EOSM2.103 700D.115 5D3.*

ErwinH

  • New to the forum
  • *
  • Posts: 10
Re: ProcessTwoInTwoOutLosslessPath
« Reply #170 on: August 13, 2017, 07:35:35 PM »
I tool the crop_rec_4k branche, took out the 5D3 specific boothacks and that runs like a charm.

I need some help with the raw buffers (for the mlv_lite) but I'll share my code with you tomorrow.

Warning, I did encounter a null pointer error during recording when the card couldn't keep up and the scan_a5a5 routines warns about a null pointer bug all the time...

ErwinH

  • New to the forum
  • *
  • Posts: 10
Re: ProcessTwoInTwoOutLosslessPath
« Reply #171 on: August 14, 2017, 09:53:06 AM »
dfort: https://bitbucket.org/ehoutsma/magic-lantern/src/?at=crop_rec_4k_700d

Just took 2 pictures, one in DNG and one in Lossless DNG (both with the lenscap on), Lossless DNG was 1.4MB, the normal DNG 2.3MB.

I haven't disabled the null pointer warning ;)


dfort

  • Hero Member
  • *****
  • Posts: 1747
Re: ProcessTwoInTwoOutLosslessPath
« Reply #172 on: August 15, 2017, 01:18:07 AM »
@ErwinH

That null pointer warning makes for a wild and crazy ride:



I wasn't able to get a compressed Full Resoution Silent Picture DNG but it did work for Simple Silent:



The first few I shot came out blank and Adobe Camera Raw wouldn't open them but the next batch came out fine. That's to be expected with experiments like this. A while back I remember testing out the crop_rec_4k branch and finding out that FRSP was not working so it isn't surprising if these changes broke it.

Next test, compressed raw video with reduced bit-depth. Don't know if "mlv_dump -v" shows if the video is compressed and at what bit-depth it was recorded in but:

Code: [Select]
...
    Frames Video: 916
...
    Res:  1736x976
...
     Camera Name:   'Canon EOS REBEL T5i'
...

Holy Smokes! First test was 38 seconds of raw video at that resolution with no corrupt frames. Subsequent tests were even better. Adjusting the aspect ratio to 1.85 and 2.35 (the standards in cinema) recording was continuous. This works both in mv1080 (1736x936 for 1.85 and 1736x736 for 2.35) and mv1080crop (1800x968 for 1.85 and 1800x760 for 2.35).

Going even more extreme, zoom mode:

Code: [Select]
    FPS         : 23.976000
...
    Frames Video: 173
...
    Res:  2520x1072

Congratulations!

Will the crop_rec module add anything to this? It should be possible to get more resolution options but it is very doubtful that recording 4K raw video on a 700D is possible unless you adjust the frame rate way down.
EOSM.202 EOSM.203 EOSM2.103 700D.115 5D3.*

DeafEyeJedi

  • Hero Member
  • *****
  • Posts: 2939
  • 5D3 / M1 / 7D / 70D / SL1
ProcessTwoInTwoOutLosslessPath
« Reply #173 on: August 15, 2017, 07:59:59 AM »
That's some sick work @dfort and thanks for sharing the source code @ErwinH! :D
5D3.113 • 5D3.123 • EOSM.203 • 7D.203 • 70D.112 • 100D.101

Teamsleepkid

  • Member
  • ***
  • Posts: 156
Re: ProcessTwoInTwoOutLosslessPath
« Reply #174 on: August 15, 2017, 08:23:05 AM »
You guys are awesome. Nice going ErwinH. And Dfort you got it man. Hats off to you guys :)
EOS M