Commits

a1ex  committed f9f107a

Yep, we have 14-bit RAW data in LiveView. DNG silent pics for 5D2/5D3.

  • Participants
  • Parent commits 785dfa0

Comments (9)

Files changed (8)

File platform/5D2.212/Makefile

 	vsync-lite.o \
 	battery.o \
 	afma.o \
+	chdk-dng.o \
 
 #include generic rules and definitions
 #TOP_DIR defined in upper Makefile

File platform/5D2.212/consts.h

 #define MALLOC_FREE_MEMORY (MEM(MALLOC_STRUCT + 24 + 4) - MEM(MALLOC_STRUCT + 24 + 8)) // "Total Size" - "Allocated Size"
 
 #define RAW_IMAGE_BUFFER ((void*)sdsf3_get_raw_image_buffer())
-//~ #define RAW_BLACK_LEVEL (1024+32)  // autodetected
 #define RAW_WHITE_LEVEL 15600
 #define RAW_SKIP_H 160 // to ignore the black border 
 #define RAW_SKIP_V 100
+#define RAW_LV_EDMAC 0xc0f04508
 
 //~ max volume supported for beeps
 #define ASIF_MAX_VOL 5

File platform/5D2.212/features.h

 #define FEATURE_RAW_HISTOGRAM
 #define FEATURE_RAW_ZEBRAS
 #define FEATURE_RAW_SPOTMETER
+
+#define FEATURE_SILENT_PIC_RAW

File platform/5D3.113/Makefile

 	ph_info_disp.o \
 	flexinfo.o \
 	afma.o \
+	chdk-dng.o \
 
 #include generic rules and definitions
 #TOP_DIR defined in upper Makefile

File platform/5D3.113/consts.h

 #define UNAVI_FEEDBACK_TIMER_ACTIVE (MEM(0x33300) != 0x17) // dec CancelUnaviFeedBackTimer
 
 #define RAW_IMAGE_BUFFER ((void*)sss_get_raw_image_buffer())
-// #define RAW_BLACK_LEVEL (2048+16) autodetected
 #define RAW_WHITE_LEVEL 16000
 #define RAW_SKIP_H 160 // to ignore the black border 
 #define RAW_SKIP_V 10
+#define RAW_LV_EDMAC 0xc0f26208
 
 //~ max volume supported for beeps
 #define ASIF_MAX_VOL 5

File platform/5D3.113/features.h

 #define FEATURE_RAW_ZEBRAS
 #define FEATURE_RAW_HISTOGRAM
 #define FEATURE_RAW_SPOTMETER
+
+#define FEATURE_SILENT_PIC_RAW

File src/chdk-dng.c

 /**
  * DNG saving routines ported from CHDK
  * Code stripped down a bit, since we don't care about GPS and advanced exif stuff (at least for now)
+ * 
+ * TODO: make it platform-independent and move it to modules.
  */
 
 #include "dryos.h"
     static int prev_folder_number = -1;
     
     char *extension = "422";
+#ifdef FEATURE_SILENT_PIC_RAW
+    extension = "DNG";
+#endif
     
 #ifdef FEATURE_SILENT_PIC_JPG
     if(silent_pic_jpeg)
 #endif
 }
 
+#ifdef FEATURE_SILENT_PIC_RAW
+static void
+silent_pic_take_raw()
+{
+    /* this enables a LiveView debug flag that gives us 14-bit RAW data. Cool! */
+    call("lv_save_raw", 1);
+    msleep(50);
+    
+    /* after filling one frame, disable the flag so we can dump the data without tearing */
+    call("lv_save_raw", 0);
+    msleep(50);
+
+    /* try to autodetect image size */
+    uint32_t lv_raw_size = MEMX(RAW_LV_EDMAC+8);
+    int lv_raw_pitch = lv_raw_size & 0xFFFF;
+    int lv_raw_width = lv_raw_pitch * 8 / 14;
+    //~ int lv_raw_height = (lv_raw_size >> 16) & 0xFFFF; // it's zero...
+    int lv_raw_height = lv_raw_width * 21/30; // dumb one-size-fits-all
+    uint32_t lv_raw_addr = MEMX(RAW_LV_EDMAC);
+
+    /* save it to card */
+    char* fn = silent_pic_get_name();
+    bmp_printf(FONT_MED, 0, 60, "Saving %d x %d...", lv_raw_width, lv_raw_height);
+    save_dng(fn, lv_raw_addr, lv_raw_width, lv_raw_height);
+    redraw();
+}
+
+#else // who needs 422 when we have raw?
+
 static void
 silent_pic_take_simple(int interactive)
 {
         while (get_halfshutter_pressed()) msleep(100);
     }
 }
+#endif
+
 #else // no silent pics, need some dummy stubs
 int silent_pic_preview(){ return 0; }
 #endif
     if (!silent_pic_enabled) return;
 
     if (!lv) force_liveview();
+    
+#ifdef FEATURE_SILENT_PIC_RAW
+    silent_pic_take_raw();
+#else
 
     switch(silent_pic_mode)
     {
     }
 
     silent_pic_matrix_running = 0;
+#endif
 }
 #endif
 
     },
     #endif
     #ifdef FEATURE_SILENT_PIC
+    #ifdef FEATURE_SILENT_PIC_RAW
+    {
+        .name = "Silent Picture",
+        .priv = &silent_pic_enabled,
+        .max  = 1,
+        .depends_on = DEP_LIVEVIEW,
+        .help  = "Take pics in LiveView without moving the shutter mechanism.",
+        .help2 = "File format: 14-bit DNG.",
+    },
+    #else // who needs 422 when we have raw?
     {
         .name = "Silent Picture",
         .priv = &silent_pic_enabled,
         },
     },
     #endif
+    #endif
     #ifdef FEATURE_MLU_HANDHELD
         #ifndef FEATURE_MLU
         #error This requires FEATURE_MLU.