libmtp  1.1.18
chdk_live_view.h
1 #ifndef __LIVE_VIEW_H
2 #define __LIVE_VIEW_H
3 
4 // Note: used in modules and platform independent code.
5 // Do not add platform dependent stuff in here (#ifdef/#endif compile options or camera dependent values)
6 
7 /*
8 Protocol notes:
9 - Unless otherwise specified, all structure values are packed in camera native (little
10  endian) byte order
11 - Frame buffer and palette data are in native camera formats
12  Some documentation may be found at http://chdk.wikia.com/wiki/Frame_buffers
13 - The frame buffer descriptions returned may not be correct depending on the
14  camera model and various camera settings (shooting mode, digital zoom, aspect ratio)
15  This may result in partial images, garbage in the "valid" area or incorrect position
16 - In some cases, the requested data may not be available. If this happens, the framebuffer
17  or palette data offset will be zero.
18 - The frame buffer descriptions are returned regardless of whether the data is available
19 - New enum values (e.g. aspect ratio, framebuffer type, palette type) may be added in minor
20  versions.
21 */
22 // Live View protocol version
23 #define LIVE_VIEW_VERSION_MAJOR 2 // increase only with backwards incompatible changes (and reset minor)
24 #define LIVE_VIEW_VERSION_MINOR 2 // increase with extensions of functionality
25 
26 /*
27 protocol version history
28 < 2.0 - development versions
29 2.0 - initial release, chdk 1.1
30 2.1 - added palette type 4 - 16 entry VUYA, 2 bit alpha
31 2.2 - in development digic 6 support. Added LV_ASPECT_3_2, LV_FB_YUV8B and LV_FB_YUV8C formats
32 */
33 
34 
35 // Control flags for determining which data block to transfer
36 #define LV_TFR_VIEWPORT 0x01
37 #define LV_TFR_BITMAP 0x04
38 #define LV_TFR_PALETTE 0x08
39 #define LV_TFR_BITMAP_OPACITY 0x10
40 
41 enum lv_aspect_rato {
42  LV_ASPECT_4_3,
43  LV_ASPECT_16_9,
44  // below added in 2.2
45  LV_ASPECT_3_2,
46 };
47 
48 /*
49 Framebuffer types
50 additional values will be added if new data formats appear
51 */
52 enum lv_fb_type {
53  LV_FB_YUV8, // 8 bit per element UYVYYY, used for live view
54  LV_FB_PAL8, // 8 bit paletted, used for bitmap overlay. Note palette data and type sent separately
55  // below added in 2.2
56  LV_FB_YUV8B,// 8 bit per element UYVY, used for live view and overlay on Digic 6
57  LV_FB_YUV8C,// 8 bit per element UYVY, used for alternate Digic 6 live view
58  LV_FB_OPACITY8,// 8 bit opacity / alpha buffer
59 };
60 
61 /*
62 framebuffer data description
63 NOTE YUV pixels widths are based on the number of Y elements
64 */
65 typedef struct {
66  int fb_type; // framebuffer type - note future versions might use different structures depending on type
67  int data_start; // offset of data from start of live view header
68  /*
69  buffer width in pixels
70  data size is always buffer_width*visible_height*(buffer bpp based on type)
71  */
72  int buffer_width;
73  /*
74  visible size in pixels
75  describes data within the buffer which contains image data to be displayed
76  any offsets within buffer data are added before sending, so the top left
77  pixel is always the first first byte of data.
78  width must always be <= buffer_width
79  if buffer_width is > width, the additional data should be skipped
80  visible_height also defines the number of data rows
81  */
82  int visible_width;
83  int visible_height;
84 
85  /*
86  margins
87  pixels offsets needed to replicate display position on cameras screen
88  not used for any buffer offsets
89  */
90  int margin_left;
91  int margin_top;
92 
93  int margin_right;
94  int margin_bot;
96 
97 typedef struct {
98  // live view sub-protocol version
99  int version_major;
100  int version_minor;
101  int lcd_aspect_ratio; // physical aspect ratio of LCD
102  int palette_type;
103  int palette_data_start;
104  // framebuffer descriptions are given as offsets, to allow expanding the structures in minor protocol changes
105  int vp_desc_start;
106  int bm_desc_start;
107  int bmo_desc_start; // added in protocol 2.2
109 
110 #endif // __LIVE_VIEW_H
Definition: chdk_live_view.h:97
Definition: chdk_live_view.h:65