From 87cd9f8490224acdb6d07817fd5ba39fa6f8e85a Mon Sep 17 00:00:00 2001 From: Pekka Helenius Date: Thu, 23 May 2019 00:12:48 +0300 Subject: [PATCH] Add magiclantern-tools --- Readme.md | 14 +++ .../01-patch_tcc_makefile-fix.patch | 15 +++ .../02_patch_cr2hdr-source_add-dryrun.patch | 71 ++++++++++++ .../03_patch_add_baseline-exif.patch | 11 ++ .../04_patch_cr2hdr_disable-strings.patch | 32 ++++++ ...tch_modules-makefile_disable-strings.patch | 11 ++ magiclantern-tools/Makefile.user | 1 + magiclantern-tools/PKGBUILD | 103 ++++++++++++++++++ 8 files changed, 258 insertions(+) create mode 100644 magiclantern-tools/01-patch_tcc_makefile-fix.patch create mode 100644 magiclantern-tools/02_patch_cr2hdr-source_add-dryrun.patch create mode 100644 magiclantern-tools/03_patch_add_baseline-exif.patch create mode 100644 magiclantern-tools/04_patch_cr2hdr_disable-strings.patch create mode 100644 magiclantern-tools/05_patch_modules-makefile_disable-strings.patch create mode 100644 magiclantern-tools/Makefile.user create mode 100644 magiclantern-tools/PKGBUILD diff --git a/Readme.md b/Readme.md index 87d0938..187d656 100644 --- a/Readme.md +++ b/Readme.md @@ -181,6 +181,20 @@ Usage: once you've inserted a SD card into your computer, use 'ml-bootablecard' **FORMAT:** Arch Linux PKGBUILD script + custom source files. +## [magiclantern-tools](magiclantern-tools) + +Linux-compatible Magic Lantern image processing tools for pictures taken with Canon DSLR's with Magic Lantern firmware. + +Tools: `cr2hdr` (for dual ISO images), `mlvdump` (mlv files) + +### Highlights + +- Additional dry-run feature added to `cr2hdr` (`--dry-run`). Combine with Linux shell scripts, i.e. 1) to check whether images have been taken with dual ISO setting (without actually processing dual ISO images), and do further analysis for these images 2) to distinguish normal CR2 images from dual ISO ones, 3) etc. + +- Adds `baseline` information to EXIF metadata + +**FORMAT:** Arch Linux PKGBUILD script + patch files. + ## [mlvdump](mlvdump) Magic Lantern Raw file conversion tool for MLV files. Extract individual DNG frames from MLV files. diff --git a/magiclantern-tools/01-patch_tcc_makefile-fix.patch b/magiclantern-tools/01-patch_tcc_makefile-fix.patch new file mode 100644 index 0000000..991d19f --- /dev/null +++ b/magiclantern-tools/01-patch_tcc_makefile-fix.patch @@ -0,0 +1,15 @@ +--- a/magic-lantern/tcc/Makefile ++++ b/magic-lantern/tcc/Makefile +@@ -137,6 +137,12 @@ + TCCLIBS+=$(LIBTCC1_CROSS) + endif + ++#Very bad workaround for solving compilation issues ++CC=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-gcc-4.8.3 ++LD=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-ld ++READELF=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-readelf ++OBJCOPY=../gcc-arm-none-eabi-4_8-2013q4/bin/arm-none-eabi-objcopy ++ + #all: $(PROGS) $(TCCLIBS) $(TCCDOCS) + + all: libtccx.o diff --git a/magiclantern-tools/02_patch_cr2hdr-source_add-dryrun.patch b/magiclantern-tools/02_patch_cr2hdr-source_add-dryrun.patch new file mode 100644 index 0000000..aca90fe --- /dev/null +++ b/magiclantern-tools/02_patch_cr2hdr-source_add-dryrun.patch @@ -0,0 +1,71 @@ +--- a/magic-lantern/modules/dual_iso/cr2hdr.c ++++ b/magic-lantern/modules/dual_iso/cr2hdr.c +@@ -60,6 +60,7 @@ + + /** Command-line interface */ + ++int process_method = 0; + int interp_method = 0; /* 0:amaze-edge, 1:mean23 */ + int chroma_smooth_method = 2; + int fix_pink_dots = 0; +@@ -98,7 +99,13 @@ + + void check_shortcuts() + { +- if (shortcut_fast) ++ if (process_method == 1) ++ { ++ interp_method = 2; ++ chroma_smooth_method = 1; ++ gray_wb = 5; ++ } ++ else if (shortcut_fast) + { + interp_method = 1; + chroma_smooth_method = 0; +@@ -129,6 +136,13 @@ + + struct cmd_group options[] = { + { ++ "Processing methods", (struct cmd_option[]) { ++ { &process_method, 0, "--process", "Process Dual ISO compatible file (default)" }, ++ { &process_method, 1, "--dry-run", "Only check file for Dual ISO presence" }, ++ OPTION_EOL ++ }, ++ }, ++ { + "Shortcuts", (struct cmd_option []) { + { &shortcut_fast, 1, "--fast", "disable most postprocessing steps (fast, but low quality)\n" + " (--mean23, --no-cs, --no-fullres, --no-alias-map, --no-stripe-fix, --no-bad-pix)" }, +@@ -870,12 +884,12 @@ + whites[num_files] = raw_info.white_level; + num_files++; + } +- else ++ else if (process_method != 1) + { + printf("ISO blending didn't work\n"); + } + } +- else ++ else if (process_method != 1) + { + printf("Doesn't look like interlaced ISO\n"); + } +@@ -2206,7 +2220,15 @@ + double corr_ev = 0; + int white_darkened = white_bright; + int ok = match_exposures(&corr_ev, &white_darkened); +- if (!ok) goto err; ++ if (!ok) ++ { ++ goto err; ++ } ++ else if (ok && process_method == 1) ++ { ++ printf("Interlaced ISO detected\n"); /*. File: %s\n", filename);*/ ++ return 0; ++ } + + /* run a second black subtract pass, to fix whatever our funky processing may do to blacks */ + black_subtract_simple(raw_info.active_area.x1, raw_info.active_area.y1); diff --git a/magiclantern-tools/03_patch_add_baseline-exif.patch b/magiclantern-tools/03_patch_add_baseline-exif.patch new file mode 100644 index 0000000..73221d9 --- /dev/null +++ b/magiclantern-tools/03_patch_add_baseline-exif.patch @@ -0,0 +1,11 @@ +--- a/magic-lantern/modules/dual_iso/exiftool-bridge.c ++++ a/magic-lantern/modules/dual_iso/exiftool-bridge.c +@@ -10,7 +10,7 @@ + { + char exif_cmd[1000]; + printf("%-16s: copying EXIF from %s\n", dest, source); +- snprintf(exif_cmd, sizeof(exif_cmd), "exiftool -tagsFromFile \"%s\" -all:all \"-xmp:subject=Dual-ISO\" \"-UniqueCameraModel + +pkgname=magiclantern-tools +pkgver=1 +pkgrel=1 +pkgdesc="Magic Lantern Linux-compatible image processing tools for pictures taken with Canon DSLR's with Magic Lantern firmware." +arch=('any') +url='https://bitbucket.org/hudson/magic-lantern' +license=("GPL") +depends=('perl-image-exiftool' 'dcraw') +optdepends=('octave') +makedepends=('mercurial') + +#REQUIRED BY MODULES +#Use these dependencies only if you try compile more modules. They rely partially on rst2html5 package. +#makedepends=('rst2html5' 'python-docutils') + +arm_compiler=gcc-arm-none-eabi-4_8-2013q4 +source=( + "https://launchpad.net/gcc-arm-embedded/4.8/4.8-2013-q4-major/+download/$arm_compiler-20131204-linux.tar.bz2" + "Makefile.user" + "01-patch_tcc_makefile-fix.patch" + "02_patch_cr2hdr-source_add-dryrun.patch" + "03_patch_add_baseline-exif.patch" + "04_patch_cr2hdr_disable-strings.patch" + "05_patch_modules-makefile_disable-strings.patch" +) +md5sums=('4869e6a6e1dc11ea0835e8b8213bb194' + '035e3049e5f3205680566ffc6c6e9023' + 'd2f975ad4896c3b82a5076bd396ceec6' + '2a921d40e65004bb0f9f4d274b83ff04' + '317c4ce8317182a98700b57b285ef184' + 'd2e57664cbc7310521eee4b0b13a3f41' + '25281350b6a5a9f40a1b40933f0de829') + +prepare() { + cd "$srcdir"/ + + ##### + #Download Magic Lantern latest source files + msg2 "Downloading Magic Lantern source code" + hg clone -r unified https://bitbucket.org/hudson/magic-lantern + ##### + + #This is an ugly hack, I know. Make sure you update the patch file if you change ARM compiler + patch -Np1 -i "$srcdir"/01-patch_tcc_makefile-fix.patch + + #Implement Dry Run feature in CR2HDR + patch -Np1 -i "$srcdir"/02_patch_cr2hdr-source_add-dryrun.patch + + #Write Baseline Exposure values to EXIF tags: + patch -Np1 -i "$srcdir"/03_patch_add_baseline-exif.patch + + #All modules have python issues (outdated code?) so they don't compile. The problem is related to version etc. strings. Just disable them and compile the code. Only used for cr2hdr (as we need it, not other modules) + patch -Np1 -i "$srcdir"/04_patch_cr2hdr_disable-strings.patch + patch -Np1 -i "$srcdir"/05_patch_modules-makefile_disable-strings.patch + + #Custom compilation settings for Magic Lantern (Mainly ARM compiler path redefinition) + ln -fs "$srcdir"/Makefile.user "$srcdir"/magic-lantern/Makefile.user + + #Link downloaded ARM compiler files to Magic Lantern directory + ln -fs "$srcdir"/$arm_compiler "$srcdir"/magic-lantern/$arm_compiler +} + +build() { + cd ${srcdir} + export PATH=$PATH:${PWD}/${arm_compiler}/bin + + cd "$srcdir"/magic-lantern #/modules/dual_iso + +####################################### +# FIRMWARE - MODULES FAIL TO BUILD DUE TO PYTHON ISSUES + + ##make 5D3 #5D Mark 3 - Both firmwares - DOESN'T INCLUDE MODULES YET + ##make 5D3.113 #5D Mark 3 - Firmware 1.1.3 - DOESN'T INCLUDE MODULES YET + + #make 5D3.123 #5D Mark 3 - Firmware 1.2.3 - DOESN'T INCLUDE MODULES YET + #mkdir -p "$startdir"/5dmark3_firmware_123/ + #cp "$srcdir"/magic-lantern/platform/5D3.123/{autoexec.bin,ML-SETUP.FIR} "$startdir"/5dmark3_firmware_123/ #magiclantern.bin,version.bin + +####################################### +# MODULES + + #make all_modules #All modules - FAIL TO BUILD DUE TO PYTHON ISSUES + +#CR2HDR application for host computer + cd "$srcdir"/magic-lantern/modules/dual_iso + make cr2hdr + cd .. + +#MLV_DUMP application for host computer + cd "$srcdir"/magic-lantern/modules/mlv_rec + make mlv_dump + cd .. + +} + +package() +{ +mkdir -p "$pkgdir"/usr/bin +cp "$srcdir"/magic-lantern/modules/dual_iso/cr2hdr "$pkgdir"/usr/bin +cp "$srcdir"/magic-lantern/modules/mlv_rec/mlv_dump "$pkgdir"/usr/bin/mlvdump +}