3K/UHD 5D2 Raw development and Other Digic IV Cams

Started by reddeercity, April 06, 2017, 12:22:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

names_are_hard

Quote from: theBilalFakhouridm-spy-experiments, io_trace and io_trace_full branches

Thanks for explaining, but since I don't have those branches, I'm out until someone gives me a build they want tested :)

reddeercity

Quote from: names_are_hard on April 22, 2024, 12:57:29 AM...... I'm out until someone gives me a build they want tested :)
I what everyone to test  :D
Sorry just Lazy today , I'm still getting my head back in to Magic Lantern Mode ,
Lots of rabbit holes to fall in to  ;D

Ok here we go , i did both 1.1.3. ver firm & 1.2.3 firm . Didn't know which is the most used
I/O_Trace_Full_5D3.123
I/O_Trace_Full_5D3.113

Mainly startup , anything to expose the Cf controller routines/regs . But i'm still thinking
i may still need to go in to Qemu from other I/O Traces I've seen seems to miss the regs changing.
but that was D4 cams i think. I don't have a 5d3 cam so i can't test of couse but i've build other I/O trace builds for 7d , 550d , etc. ... with out any issue so i expect it should work.
Post the Logs here or same where i can download & or Read Thanks !   

reddeercity

A old experiment from a 2-3 years ago , the video hi-speed frame rate are small h264.mp4 around 25-30Mb in size .
Proof that is can go beyond 48fps , but not in standard HD size at least for the 1st one  1600x832 & the other 12080x720 HD .
i can clean up the 1600x832 @ 62.5fps(i can drop it to 60fps for stability) also i should be able to clean up that
1280x720 also @ 70.086fps with some work (not the easiest to do but can be)
The question I ask is, is this useful ? Or just a novelty say i can do xxfps
by the way the highest i can achieved is 72fps @ 720 , i've had more but i smaller frame size
i think 86fps or around there @ a little more then SD Rez (800x600 i think) then it crashed.
I never came back to it but i though if there a interest i can pursue it futher.  :)     


1600x832-62.5fps-M02-2327.mov




5D2_1280x722-70.086-fps-M05-2305.mov

names_are_hard

Thanks.  I can only test 5d3 in qemu - is that still useful for you?  Can test both fw versions.

I'd be interested in getting high fps working, especially on newer cams.  These have a much higher base clock for the sensor, so possibly they can sample faster?  84MHz on 200D, compared to 24 or 32 on old cams.  Some of the new cams have 120fps native, which ones are capable but not enabled?  How far can we push this with raw video?  Fun to find out.

The only old cam I have is 70D, so if you have working code for high fps there, that would be ideal.  If not, a good write up so I can attempt to copy the approach would be great :)

I have a question about all these branches.  Do you like this approach?  Is it a good thing somehow, that the code is scattered across multiple branches, rather than in one place?  I don't even know which branches I'm supposed to use, there are so many.  In the repo I maintain I've merged many branches, so there is no need to switch.  Would you prefer that?

theBilalFakhouri

Quote from: reddeercity on April 17, 2024, 05:48:40 AMSo i need to find a 5D3 setup log or any logs with CF card on the 5D3 to know the reg set
but in the mean time i'll search some more on the forum , i'm sure i saw some , just cant remember where.  :)

BTW, CF clock speed config (UDMA modes) and related registers were found years ago, check:
https://www.magiclantern.fm/forum/index.php?topic=12862.msg206011#msg206011

Also there a is test was done by waza57 on 5D2 in the past, he claimed that he got 30% write speed improvement on 5D2, but during his experiment he ended up with a corrupted file system for the CF card:
https://www.magiclantern.fm/forum/index.php?topic=12862.msg206061#msg206061

reddeercity

Yup , i know but i think there incomplete alone with reg's for udma there's HP timers and
i think there need to be configured also . Just like crop_mode it's at least 6 reg's
just to make a basic preset etc. .... I believe qemu will expose them so i can see
how the routine works in 5D3 D5 cam not just the regs.
I don't expect the reg's in 5D3 to be the same 5D2 but there usually pretty close
that how i do most of work on crop record just find the corresponding
setting in 5D2,  it works most of the time. :)
I need to see this from the 5D3 log . 
[   CSMgrTask:ffbdb7d8 ] (22:06) GetFirstTuple: CISTPL_CONFIG
[   CSMgrTask:ffb8c454 ] (22:06) GetConfigurationTuple
[   CSMgrTask:ffb8bcb0 ] (22:01) RequestConfiguration: pLStorage=0x685504
[   CSMgrTask:ffb8bcc8 ] (22:01)                       ConfigBase=0x200, StatusReg=0
[   CSMgrTask:ffb8bce0 ] (22:01)                       PinRepReg=0, CopyReg=0
[   CSMgrTask:ffb8bcf8 ] (22:01)                       ConfigIndex=0x1, Present=0xf
[CFATA] at CSMgrTas:FFB8BD04:FFB8BD04 [0xC0628100] -> 0x0       : ???
[CFATA] at CSMgrTas:FFB8BD0C:FFB8BD04 [0xC0628100] <- 0x0       : ???
[CFATA] at CSMgrTas:FFB8BD18:FFB8BD18 [0xC0628100] <- 0x0       : ???
[CFATA] at CSMgrTas:FFB8BD24:FFB8BD24 [0xC0628100] -> 0x0       : ???
[CFATA] at CSMgrTas:FFB8BD2C:FFB8BD24 [0xC0628100] <- 0x2       : ???
[CFATA] at CSMgrTas:FFB8BD38:FFB8BD38 [0xC0628100] <- 0x2       : ???
[CFATA] at CSMgrTas:FFB8BD48:FFB8BD44 [0xC0628044] <- 0x0       : Interrupt related?
[CFATA] at CSMgrTas:FFB8BD5C:FFB8BD54 [0xC0620200] <- 0x41      : ???
[CFATA] at CSMgrTas:FFB8BD68:FFB8BD68 [0xC0620200] -> 0x0       : ???
[   CSMgrTask:ffb8bd80 ] (22:01) RequestConfiguration: Base = 200, Data = 0
[CFATA] at CSMgrTas:FFB8BD98:FFB8BD94 [0xC0620202] <- 0x0       : ???
[CFATA] at CSMgrTas:FFB8BDB0:FFB8BDAC [0xC0620204] <- 0x0       : ???
[CFATA] at CSMgrTas:FFB8BDC8:FFB8BDC4 [0xC0620206] <- 0x0       : ???
[   CSMgrTask:ffb8bde0 ] (22:01) RequestConfiguration: SUCCESS
If this approach fail to yield result i can still do the overclock CF Controller
with software in the hp_parm branch   , got the idea from a1ex in this post
https://www.magiclantern.fm/forum/index.php?msg=199697

I did early test with the information from a1ex on 5d3
https://www.magiclantern.fm/forum/index.php?msg=207128
But failed just like waza57 did but there again i just change one reg and that's not enough

reddeercity

Quote from: names_are_hard on April 22, 2024, 03:51:55 PMThanks.  I can only test 5d3 in qemu - is that still useful for you?  Can test both fw versions.

Yes please do both, if you can can you do a FA_Capture(Test-Image) that the log from the 5D2 i got that info on changing reg's

Quote from: names_are_hard on April 22, 2024, 03:51:55 PMI'd be interested in getting high fps working, especially on newer cams.  These have a much higher base clock for the sensor, so possibly they can sample faster?  84MHz on 200D, compared to 24 or 32 on old cams.  Some of the new cams have 120fps native, which ones are capable but not enabled?  How far can we push this with raw video?  Fun to find out.

The only old cam I have is 70D, so if you have working code for high fps there, that would be ideal.  If not, a good write up so I can attempt to copy the approach would be great :)

Its was base off the Crop_Recording but instead of large frame size (4k,3k etc. ...) its reduce frame size (sometime vertical compression-> stretching 1.67 (ADTG12[100c])
not very difficult.
Here in this post i explain & post images how i got 1856x704 10bit @50p with regs
sumary of the reg i used , the post explaines it better. I can do i better write up on D4 crop_record in general with hi speed frame rate , there a few rabbit hole to watch or the cam will crash/lockup
i can't tell you how many time i though I broke i may cam  :'( , i would get so hot i couldn't handle in my hands (close to 75 degrees celsius  :o )   
Here is better post with cleaner image & more info on how its done
1856x704 50fps
cmos[1]   0xc00 -->0xbeD
c0f0713c  0x4f3 -->0x2d3 //liveview preview (vertial)//
c0f07150  0x523 -->0x3D3 //liveview preview (horizontal)//
c0f06008  0x23b023b --> 0x23bD237 //frame horizontal width//
c0f06088  0x4f40432 --> 0x2d4D432 //frame vertial height//
c0f06014  0x577  --> 0x34c //framerate timer "B" (i think)//
ADTG12[100c] 0x2 --> 0x4 //cmos pixel binning line (1.67:1 vertial compressing)


Quote from: names_are_hard on April 22, 2024, 03:51:55 PMI have a question about all these branches.  Do you like this approach?  Is it a good thing somehow, that the code is scattered across multiple branches, rather than in one place?  I don't even know which branches I'm supposed to use, there are so many.  In the repo I maintain I've merged many branches, so there is no need to switch.  Would you prefer that?
I have branches locally i need for D4 cams development , much of the info/code parts i use come from old branches (more then 5 years ago if not 10, e.g. Motion Jpeg video code etc. ....) so i'm not sure how to answer that . I'm not a true coder etc. ... i'm a old retired mechanic that pickup some coding skill here on Magic Lantern , After the 5D3 came out the deveolpment slowly stoped on D4 cam (5D2) so if i wanted the latest and exciting feature from 5D3 (mainly crop_record) or Dual ISO video etc. ...
I had to figure it out myself (and the fact that a1ex & other devloper had no time or not enough time to help everyone) , i fumbled my way thought it . As long i can see a sample of coding i can read it and duplicate but i can't write code from scratch , i have to fellow other examples i find & of course google is my friend in coding also.   

Walter Schulz

Quote from: reddeercity on April 22, 2024, 06:06:20 AMI what everyone to test  :D
[...]
Post the Logs here or same where i can download & or Read Thanks !   


Loaded 1.2.3 build onto CF card and started up. No log. Anything I missed?

reddeercity

Quote from: Walter Schulz on April 24, 2024, 10:10:27 AMLoaded 1.2.3 build onto CF card and started up. No log. Anything I missed?
Sorry forgot to give instruction
i/o logging instruction

QuoteTo run test , load ml io-trace-full build
exit liveview go to the debug menu activate the Logging feature
-- exit menu so there no liveview take a cr2 photo return to debug menu and hi-light logging again to save the log
For startup i think (i maybe wrong) but if you to Debug menu set logging and exit , shut down cam then restart , I think that should work , been a a few years since I've done this I'm a little rusty.
Try to take a picture and save it , to see if the I/O trace is working correctly  that my also so the CF routines not sure .Thanks for the help :)   

reddeercity

Looks like i found the data timing Regs(I think)one for these need to be set alone with the Reg
for udma 
 
[   CSMgrTask:ffbdbb3c ] (22:03) CF_GetAccessTiming : DatTim = 0, DatMod = 0
[CFATA] at CSMgrTas:FFB8A3D0:FFB8A3D0 [0xC06280A0] <- 0x4181410 : ???
[CFATA] at CSMgrTas:FFB8A3EC:FFB8A3EC [0xC06280A4] <- 0x4180804 : ???
[CFATA] at CSMgrTas:FFB8A4B0:FFB8A4B0 [0xC0628090] <- 0xC1C0004 : ???
[CFATA] at CSMgrTas:FFB8A4D0:FFB8A4D0 [0xC0628098] <- 0xC1C0004 : ???
[CFATA] at CSMgrTas:FFB8A4F0:FFB8A4F0 [0xC0628094] <- 0xC1C1004 : ???
[CFATA] at CSMgrTas:FFB8A580:FFB8A580 [0xC062809C] <- 0xC1C1004 : ???

I have a very  suspicion that these are the UDMA Reg that one need to set
I think 0xC0620207 could the one , untested of course, but make sense
because the 5D3 Offset is 0xC6xxx207 .

[CFATA] at CSMgrTas:FFB8BD98:FFB8BD94 [0xC0620202] <- 0x0       : ???
[CFATA] at CSMgrTas:FFB8BDB0:FFB8BDAC [0xC0620204] <- 0x0       : ???
[CFATA] at CSMgrTas:FFB8BDC8:FFB8BDC4 [0xC0620206] <- 0x0       : ???

More digging in to logs file be fore i test .

Walter Schulz


reddeercity


reddeercity

I been researching the CF card structure on how it communicates with the controller , is seem that
there a header (just like a Hard Drive) in that header is written configuration files & at what mode
it accesses , (e.g. mode 0-4) these mode are related to write/read speed & timing.
this is the CISTPL_CONFIGConfiguration Tuple is stored in the cf card header and is
determent mostly by the device in this case the 5d2 canon write the table for dryOS uses.
pLStorage=0x685504is the reg on the card as seen in the start up log I've posted , & the mode it run at
is in "ns" nano seconds , so in a nut shell that the timing for read/write plus in this mode theses
more then write & read i/o there wait times
here a list what going on
t0 -Cycle time (min)
t1 -Address Valid to -IORD/-IOWR setup(min) (Mode3= 180ns Mode4= 120ns)
t2 -IORD/-IOWR (min)(Mode3= 30ns Mode4= 25ns)
t2 -IORD/-IOWR (min) Register (8 bit)(Mode3= 80ns Mode4= 70ns)
t2i -IORD/-IOWR recovery time (min) (Mode3= 80ns Mode4= 70ns)
t3 -IOWR data setup (min) (Mode3= 30ns Mode4= 20ns)
t4 -IOWR data hold (min) (Mode3= 10ns Mode4= 10ns)
t5 -IORD data setup (min) (Mode3= 20ns Mode4= 20ns)
t6 -IORD data hold (min) (Mode3= 5ns Mode4= 5ns)
t6Z -IORD data tristate (max)(Mode3= 30ns Mode4= 30ns)
t7 Address valid to -IOCS16 assertion (max) (Mode3= n/a ns Mode4= n/a ns)
t8 Address valid to -IOCS16 released (max) (Mode3= n/a ns Mode4= n/a ns)
t9 -IORD/-IOWR to address valid hold (Mode3= 10ns Mode4= 10ns)
tRD Read Data Valid to IORDY active (min), if IORDY initially low after tA (Mode3= 0ns Mode4= 0ns)
tA IORDY Setup time (Mode3= 35ns Mode4= 35ns)
tB IORDY Pulse Width (max) (Mode3= 1250ns Mode4= 1250ns)
tC IORDY assertion to release (max)(Mode3= 5ns Mode4= 5ns)

the whole process can not take more then the total "I/O Pulse width" which is 1250ns
This where we/I can alter the timing band width for increased frequency ....... etc. ... more to come this
 
The above mode is for the CF card in "True IDE Mode" the cf card can run in 3 different configurations
 True IDE Mode,PC Card Memory Mode,PC Card I/O Mode(this is from specification 2.0 so there's more then likely the more mode in the newer spec.
So to find the block that has the configuration on the CF card was my next step , so i made a CF card image (like a ISO) and read it in HxD Hex editor , didn't find that block yet but found something interesting , appertainy  there more head timers involved then i thought .
I see 4 in total but we only use 2 so are we missing them ? or do we need them ?
this what i found
mv=1 res=0 crop=0 task=? pc=ff986cc4 addr=82d0 HEAD1 timer (start?).c0f0713c:     476 ISO=200 Tv=50 Av=56 lv=1 zoom=5 mv=1 res=0
crop=0 task=LiveViewMgr pc=ff8e1830 addr=8328 HEAD3 timer (ticks?).c0f07134:       4 ISO=200 Tv=50 Av=56 lv=1 zoom=5 mv=1 res=0
crop=0 task=LiveViewMgr pc=ff8e1830 addr=8330 HEAD3 timer (start?).c0f07150:     49c ISO=200 Tv=50 Av=56 lv=1 zoom=5 mv=1 res=0
crop=0 task=LiveViewMgr pc=ff8e1844 addr=8370 HEAD4 timer (ticks?).c0f15084:   10000 ISO=200 Tv=50 Av=56 lv=1 zoom=5 mv=1 res=0
Right now we use (this is crop mode)
c0f0713c (offset)475
c0f07150 (offset)49c
c0f07134
c0f15084
are not being modified , could be causing more overhead ? in write speed .
I've seem data from a1ex on 5d2 with 120Mb/s on CF card in a write test in a low level access
so there must be a lot of overhead going on.
There's 2 direction I'm looking at here reduce overhead (turn off unnecessary resources like "DFE face detection (must be part of the auto focus) e.g. and set it to UMDA7 (or over clock the cf bus)
If i can turn off some resources i can get 75-80Mb/s to go to at less 100Mb/s or 120Mb/s that the speed for UDMA 6 , UDMA 7 pushes that to 150Mb/s . The 5D3 is on a exfat which can access larger blocks of data so the 5D2 will never see UDMA 7 speeds without overclocking , fat32 will not allowed access speed in exfat file structure . Now that being said the theoretically fat32 is limited to 133Mb/s so 120Mb/s should be reachable

More to come ............   :) 
https://engineering.purdue.edu/ece477/Archive/2004/Spring/S04-Grp07/documentation/cfspc2_0_compact_flash.pdf
My sources of information

names_are_hard

Nice info, and good to hear you're still progressing :)  Doesn't make too much sense to me yet, but I'm sure it will be very useful next time I'm dealing with a CF cam.

An147

Quote from: reddeercity on April 22, 2024, 07:53:10 AMThe question I ask is, is this useful ? Or just a novelty say i can do xxfps

Hi. Yes, any 50/60 FPS mode will be useful even with 720p, because we can then upscale it using AI and sell on stocks.
I tried 48fps but it worked just a pair of times for me. So I often use regular RAW video with Dual ISO or crop_mod 5x 3.5K preset. Sometimes it even works with Dual ISO on low resolutions like about 1200 wide.

I'm using the latest experimental build I found here in topics, and it has an issue with DualISO - I have bad horizontal stripes pattern that ruins video quality in post. Also in the crop mode there is a slight patter like on a bath towel (little squares). For the latter I use AI to get rid of, but the Dual ISO bug is concerning.
Anyone else encountered this before?

With aggressive bad pixels fix it is clearly visible.




P.S. Lokks like image posting is not working, I'll leave screenshots URLs here:
https://prnt.sc/AYwQfZ1ls0_y
https://prnt.sc/-isFpfLHQvrg


Skinny

I'd say it will be really useful to get max FPS possible with h.264 (standard resolution) as well as 3x3 raw (16:9, 3:2, it doesn't need to be continuous)

3:2 h264 mode also would be great if possible, even if it is only 24 FPS

reddeercity

@An147 , dual iso is not as stable as its on 5D3 , anything over ISO 800(for low levels) & ISO 100 (for hi-light recovery) will give issue & beside that any ISO higher the 800 is digital push or pull not a true analog full clean ISO , even the 1/2 ISO changes e.g. ISO 150 or ISO 1200 (those are just pushed digitally) that being said , I only got good clean processing in MLVProducer
 https://www.magiclantern.fm/forum/index.php?msg=216415
https://sourceforge.net/projects/mlvproducer/files/mlvp.alpha.build3370.zip/download

Also remember there's aliasing & moiré still in 3X3 so dual ISO will magnify more.



reddeercity

Quote from: Skinny on June 07, 2024, 01:47:26 PMI'd say it will be really useful to get max FPS possible with h.264 (standard resolution) as well as 3x3 raw (16:9, 3:2, it doesn't need to be continuous)

3:2 h264 mode also would be great if possible, even if it is only 24 FPS
Raw i can do 60fps 3x3 1600x800 i do believe, h264 is around 40 fps i think, the think with H264
is it has a HD preset that is encodes to 1920x1080 , (you need to reduce resolution or a custom one)
That can't be change Yet (it could be with 422 Avi which the H264 gets it stream from) actually it start with the raw stream them goes to compressed 422 8bit .avi then H264 .
So the 40D (a D4 cam) has some success with avi compression (i have followed that development and hope to try and get it running on 5D2 someday ,
that's same compression as the canon 1DC 4k cinema cam.

2blackbar

Quote from: reddeercity on April 17, 2024, 05:59:25 AMI also found my address for lossless compressed raw in one of my Logs
this is good! I had the compression routine code wrong or should i say miss some parts
its different then the 5d3/D5 cams but not by much , it very similar in structure with more parts that all.
Now i'm not saying I've got it working,  i see the problem in the code so hopefully i can correct it. ;D
Any news on this? Would be very nice to have

reddeercity

Quote from: 2blackbar on July 02, 2024, 12:52:57 AMAny news on this? Would be very nice to have
nothing news worthy yet , lots of backend stuff basically I have to go line by line in the code.
could be a long time or a short time can't say right now. 

reddeercity

Made some headway on hi-speed 3x3 framerate (higher then 48fps that is)
I'm up 50.024 (stable, recordable) @ 1880x775 in 3x3 mode , I've got it up to 52.068 same resolution(not stable yet)
Finally I push to 54.01fps but then it lockup/froze needed a battery pull , I could have got it work but I didn't adjust
frame timer windows enough. If shrink the side width down from 1880 pixel to 1856 pixel & keep the vertical at 775 pixel
I should be able to reach 60fps. So that would be 1856x775 @ 60fps
This in 3x3 mode not 1.67 stretch(720p mode on D5 cams)  so cleaner image in 3x3

50.024 @ 1880x775 Stable


52.068fps @ 1880x775 recordable , but not stable yet


54.016fps @ 1880x775 (lockup/froze battery needed)


SebastianC

Quote from: reddeercity on July 02, 2024, 07:59:16 AMMade some headway on hi-speed 3x3 framerate (higher then 48fps that is)
I'm up 50.024 (stable, recordable) @ 1880x775 in 3x3 mode , I've got it up to 52.068 same resolution(not stable yet)
Finally I push to 54.01fps but then it lockup/froze needed a battery pull , I could have got it work but I didn't adjust
frame timer windows enough. If shrink the side width down from 1880 pixel to 1856 pixel & keep the vertical at 775 pixel
I should be able to reach 60fps. So that would be 1856x775 @ 60fps
This in 3x3 mode not 1.67 stretch(720p mode on D5 cams)  so cleaner image in 3x3

50.024 @ 1880x775 Stable


52.068fps @ 1880x775 recordable , but not stable yet


54.016fps @ 1880x775 (lockup/froze battery needed)




It was fantastic! Never thought 5D2 still have more power. I used basic 5D2 raw vision which is pretty nice! I excited to test new features!

reddeercity

Quote from: SebastianC on July 04, 2024, 11:35:58 AMIt was fantastic! Never thought 5D2 still have more power. I used basic 5D2 raw vision which is pretty nice! I excited to test new features!
it not a new feature , just expanding on the crop_record 48p high frame rate preset

reddeercity

I found something that i think may make the D4 cam user happy or at least the 5D2 & 50D users
A lone time ago , will at least in terms of camera reverse engineering .
back when there was branch "vxworks-dm-spy" mainly working off the 450d camera but other as well.
Developer "Ant123" wrote some code that is very useful to use and to other cams maybe D5 .
This code,  I've forgotten i had it been in my archives for 4-5 years , what is it you may ask ?
Its Mjpeg module , thou it was written for the 450d "Ant123" made a special built 5D2 build
I have the source code , but the problem is ( well it not big problems) i have get to work with the new
code base , it was written when we still use Raw 1st generation (###.raw) mainly and "MLV" was in 1st stages with mlv_lite. when there was only 14bit raw

So what are we talking about ? we should be able to record everything that RAW_record does
even crop_record special sizes , cause its base off the frame height, wide & frame rate
sames as raw recording modules does, so 3x1, 1x3 , hi-speed frame rate. not a preset HD like H264.mov
does.
Motion Jpeg is the file format which is 422 8bit color space in .AVI , really its the stream before H264 compression(4.2.0 color space) or the same as the HDMI stream (4.2.2 color space)
Its the same file format/codec as the canon 4k 1DC cine cam (they still demands have a very high used price)

https://bitbucket.org/Ant123/magic-lantern-450d/src/vxworks-dm-spy/modules/mj_rec/mj_rec.c
so here the code i found (its for the 450D but simular to my 5d2 code , you get the idea
I couldn't find the commit that i have d855737fc7cf
in the .hg_archival.txt file it show the last commit
repo: 4d0acc5c07929676956c3cb53c8173e198390d46
node: d855737fc7cf6c101b92bb6bea162bee7e4718f6
branch: vxworks-dm-spy
latesttag: ML-650D-Alpha1
latesttagdistance: 3757
changessincelatesttag: 6483
but i cannot found it on https://foss.heptapod.net/

this the README.rst
MJPEG video recorder
=========================

Records Motion JPEG AVI video.
In Live View mode press the shutter halfway to start recording.

Modes:

* Simple: press the shutter halfway to start recording.

:Author: Ant123
:License: GPL
:Summary: Records Motion JPEG AVI video.
here a bit of the code
struct AVIHeader
{
uint32_t dwMicroSecPerFrame;
uint32_t dwMaxBytesPerSec; //
uint32_t dwReserved1; // must be 0
uint32_t dwFlags; // 0 ?
uint32_t dwTotalFrames;
uint32_t dwInitialFrames; // here must be 0
uint32_t dwStreams; // number of streams
uint32_t dwSuggestedBufferSize;
uint32_t dwWidth; // width of frame
uint32_t dwHeight; // height of frame
uint32_t dwReserved[4]; // all must be 0
};

// size - 56
struct AVIStreamHeader
{
uint32_t fccType; // 'vids'
uint32_t fccHandler; // 'mjpg'
uint32_t dwFlags; // here 0
uint16_t wPriority; // here 0
uint16_t wLanguage; // here 0
uint32_t dwInitialFrames; // here 0
uint32_t dwScale; // dwMicroSecPerFrame
uint32_t dwRate; // 1000000
uint32_t dwStart; // here 0
uint32_t dwLength; // dwTotalFrames
uint32_t dwSuggestedBufferSize; //  size largest chunk in the stream
uint32_t dwQuality; // from 0 to 10000
uint32_t dwSampleSize; // here 0
struct // here all field zero
{
uint16_t left;
uint16_t top;
uint16_t right;
uint16_t bottom;
} rcFrame;
};

// size - 40
struct AVIStreamFormat
{
uint32_t biSize; // must be 40
int32_t  biWidth; // width of frame
int32_t  biHeight; // height of frame
uint16_t biPlanes; // here must be 1
uint16_t biBitCount; // here must be 24
uint32_t biCompression; // here 'MJPG' or 0x47504A4D
uint32_t biSizeImage; // size, in bytes, of the image (in D90_orig.avi 2764800)
int32_t  biXPelsPerMeter; // here 0
int32_t  biYPelsPerMeter; // here 0
uint32_t biClrUsed; // here 0
uint32_t biClrImportant; // here 0
};

struct AVIIndexChunk
{

so it has a avi writer , the hard part done :) 

First I'll do is start with 1st gen build and see if its successfully builds,
then i can try and implement in to the new code base.
   

reddeercity

Trying to compile the Mjpeg module , it almost compiled using my latest crop_rec 4k etc... code
has 2 error that stop it from compiling , not sure how to solve.
Will here what is says , its line 479:16 & 564:17 . I'll link the source after the errors i post

david@reddeercity:~/5D2-50D-Crop_Rec_4k_fix_raw.c_error_7-19-2020/magic-lantern_reddeercity_5d2-50d_4k-crop_rec/modules/mj_rec$ make zip
Using /usr/bin/arm-none-eabi-gcc (from PATH).
[ RM dir   ]   /home/david/5D2-50D-Crop_Rec_4k_fix_raw.c_error_7-19-2020/magic-lantern_reddeercity_5d2-50d_4k-crop_rec/modules/mj_rec/zip/
mkdir -p /home/david/5D2-50D-Crop_Rec_4k_fix_raw.c_error_7-19-2020/magic-lantern_reddeercity_5d2-50d_4k-crop_rec/modules/mj_rec/zip
[ MKDIR    ]   modules_install_dir
Updated HGVERSION
[ README   ]   module_strings.h
[ CC       ]   mj_rec.o
mj_rec.c: In function 'mjpegSetup':
mj_rec.c:367:58: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  rf->aviheader->dwMicroSecPerFrame = (uint32_t)(1000000.0/fps);
                                                          ^
mj_rec.c:372:49: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
  rf->avistreamheader->dwRate = (uint32_t)(1000.0*fps);
                                                 ^
mj_rec.c: In function 'mjpegCloseFile':
mj_rec.c:438:67: warning: mj_rec.c: In fcomparison between signed and unsigned integer expressions [-Wsign-compare]
   if (FIO_WriteFile(rf->fd, rf->index, *rf->pindex_real_size + 8) != *rf->pindex_real_size + 8)
                                                                   ^~
mj_rec.c: In function 'mjpeg_video_rec_task':
mj_rec.c:479:16: error: implicit declaration of function 'get_ms_clock_value' [-Werror=implicit-function-declaration]
   OldFioTime = get_ms_clock_value();
                ^~~~~~~~~~~~~~~~~~
mj_rec.c: In function 'process_frame':
mj_rec.c:535:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (max_frame_size < lvsize)
                      ^
unction 'mjpeg_frame_rdy':
mj_rec.c:560:8: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  lvbuf = MEM(0x8308);
        ^
mj_rec.c:564:17: error: implicit declaration of function 'get_us_clock_value' [-Werror=implicit-function-declaration]
  NewFrameTime = get_us_clock_value();
                 ^~~~~~~~~~~~~~~~~~
mj_rec.c: In function 'mj_rec_polling_cbr':
mj_rec.c:682:15: warning: unused variable 'filename' [-Wunused-variable]
         char* filename = mj_rec_get_name();
               ^~~~~~~~
mj_rec.c:712:35: warning: implicit conversion from 'float' to 'double' to match other operand of binary expression [-Wdouble-promotion]
   double fps = ((double)FrameCount*1000.0)/(double)(StopWriteTime - StartWriteTime);
                                   ^
mj_rec.c:725:13: warning: unused variable 'rf' [-Wunused-variable]
   RIFFFILE* rf = (RIFFFILE*)mjpeg;
             ^~
At top level:
mj_rec.c:47:21: warning: 'NewFioTime' defined but not used [-Wunused-variable]
 static int FioTime, NewFioTime, OldFioTime;
                     ^~~~~~~~~~
mj_rec.c:42:13: warning: 'mjpeg_dbg_buf' defined but not used [-Wunused-variable]
 static char mjpeg_dbg_buf[255];
             ^~~~~~~~~~~~~
cc1: some warnings being treated as errors
../../Makefile.filerules:31: recipe for target 'mj_rec.o' failed
make: *** [mj_rec.o] Error 1
david@reddeercity:~/5D2-50D-Crop_Rec_4k_fix_raw.c_error_7-19-2020/magic-lantern_reddeercity_5d2-50d_4k-crop_rec/modules/mj_rec$
rec
 

I know there some other warning here , could they be related to the errors that stop the compile ?
I do know enough about this code to understand fully , can anyone offer so advice ?

mj_rec.c: In function 'mjpeg_video_rec_task':
mj_rec.c:479:16: error: implicit declaration of function 'get_ms_clock_value' [-Werror=implicit-function-declaration]
   OldFioTime = get_ms_clock_value();
                ^~~~~~~~~~~~~~~~~~

mj_rec.c:564:17: error: implicit declaration of function 'get_us_clock_value' [-Werror=implicit-function-declaration]
  NewFrameTime = get_us_clock_value();
                 ^~~~~~~~~~~~~~~~~~
here the source
https://bitbucket.org/reddeercity/crop_rec_5d2_50d/downloads/mj_rec.c