ProcessTwoInTwoOutLosslessPath

Started by a1ex, December 18, 2016, 09:06:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


festr

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

5D3.113 | 5D3.123 | EOSM.203 | 7D.203 | 70D.112 | 100D.101 | EOSM2.* | 50D.109

g3gg0

most credits go to martinhering, i just added the code he shared to mlv_dump.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

Greg

It works with FRSP but the image is not decoded.

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 :
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 :
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

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 :
0x5000d,
0x5000f,
0x5001a,
0x80000,
0x130006,
0x130008,
0x130012,
0x130014,
0x130018,
0x13001c,


Some notes :
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 :
*** 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

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

Quote from: Greg on May 05, 2017, 11:49:43 PM
It works with FRSP but the image is not decoded.

500D edmac RD1 default configuration :
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 :
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

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) :
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

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

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?


festr

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

Keep 2 cards and change them if needed.

festr


reddeercity

Found this today on my 5d2 rom.bin string

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

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

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

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

Quote from: dfort on April 13, 2017, 07:39:44 AM
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.

    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,
    };


    TTL_Args.WR1_Channel = 0x20;


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

dfort

Quote from: ErwinH on August 07, 2017, 01:17:23 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:

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?

ErwinH

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

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

@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:

...
    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:

    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.

DeafEyeJedi

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 | EOSM2.* | 50D.109

Teamsleepkid

You guys are awesome. Nice going ErwinH. And Dfort you got it man. Hats off to you guys :)
EOS M