CHDK_DE Vorschauversion  Trunk Rev. 5163
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
live_view.c-Dateireferenz
#include "camera_info.h"
#include "stdlib.h"
#include "conf.h"
#include "viewport.h"
#include "ptp_chdk.h"
#include "live_view.h"
+ Include-Abhängigkeitsdiagramm für live_view.c:

gehe zum Quellcode dieser Datei

Funktionen

int live_view_get_data (ptp_data *data, int flags)
 

Dokumentation der Funktionen

int live_view_get_data ( ptp_data data,
int  flags 
)

Definiert in Zeile 13 der Datei live_view.c.

13  {
14  int vp_size = 0,bm_size = 0,bmo_size = 0,pal_size = 0;
15  lv_data_header *lv;
19 
20  // determine if we will send palette so it can go in one send
21  if ( flags & LV_TFR_PALETTE ) // bitmap palette
22  {
23  // if no palette, will be set to zero
24  pal_size = vid_get_palette_size();
25  }
26 
27  // one contiguous buffer to allow a single send call
28  int buf_size = sizeof(lv_data_header) + sizeof(lv_framebuffer_desc)*3 + pal_size;
29  void *buf = malloc(buf_size);
30  if(!buf) {
31  return 0;
32  }
33  lv = buf;
34 
35  lv->vp_desc_start = sizeof(lv_data_header);
38 
39  vp = buf + lv->vp_desc_start;
40  bm = buf + lv->bm_desc_start;
41  bmo = buf + lv->bmo_desc_start;
42 
45 
47 
49  lv->palette_data_start = 0;
50 
52 
54 
57 
60 
61  // TODO returning margins from lib.c might be better
62  // can end up with negative if size and offset sources don't update at exactly the same time
65 
66 // TODO maybe should be function like viewport
67 #ifndef THUMB_FW
68  bm->fb_type = LV_FB_PAL8;
69 #else
70  bm->fb_type = LV_FB_YUV8B;
71 #endif
73 
74  bm->margin_left = 0;
75  bm->margin_top = 0;
76  bm->margin_right = 0;
77  bm->margin_bot = 0;
78 
81 
82 // type is always set to OPACITY8 even if camera doesn't have, we won't have a "none" define.
83  bmo->fb_type = LV_FB_OPACITY8;
84 // for pre-d6, all values set to 0
85 #ifndef THUMB_FW
86  bmo->buffer_width = 0;
87 
88  bmo->margin_left = 0;
89  bmo->margin_top = 0;
90  bmo->margin_right = 0;
91  bmo->margin_bot = 0;
92 
93  bmo->visible_width = 0;
94  bmo->visible_height = 0;
95 #else
96 // TODO for now assume opacity buffer is same size as bm
98 
99  bmo->margin_left = 0;
100  bmo->margin_top = 0;
101  bmo->margin_right = 0;
102  bmo->margin_bot = 0;
103 
106 #endif
107 
108  vp->data_start = 0;
109  bm->data_start = 0;
110  bmo->data_start = 0;
111 
112  int total_size = buf_size;
113 
114  void *vp_fb = vid_get_viewport_active_buffer();
115  // Add viewport details if requested, and not null
116  if ( flags & LV_TFR_VIEWPORT && vp_fb) // live buffer
117  {
118  vp->data_start = total_size;
119 #ifndef THUMB_FW
120  vp_size = (vp->buffer_width*vp->visible_height*6)/4;
121 #else
122  vp_size = (vp->buffer_width*vp->visible_height*4)/2;
123 #endif
124  total_size += vp_size;
125  // offset to start of actual data
127  }
128 
129  // Add bitmap details if requested
130  if ( flags & LV_TFR_BITMAP ) // bitmap buffer
131  {
132  bm->data_start = total_size;
133 #ifndef THUMB_FW
134  bm_size = bm->buffer_width*bm->visible_height;
135 #else
136  bm_size = (bm->buffer_width*bm->visible_height*4)/2;
137 #endif
138  total_size += bm_size;
139  }
140 
141  // Add bitmap opacity if thumb2 and request
142 #ifdef THUMB_FW
143  if ( flags & LV_TFR_BITMAP_OPACITY ) // bitmap opacity buffer
144  {
145  bmo->data_start = total_size;
146  bmo_size = bmo->buffer_width*bmo->visible_height;
147  total_size += bmo_size;
148  }
149 #endif
150 
151  // Add palette detals if requested and available
152  if ( pal_size ) // bitmap palette
153  {
154  lv->palette_data_start = buf_size - pal_size;
156  }
157 
158  // Send header structure (along with total size to be sent)
159  data->send_data(data->handle,(char*)buf,buf_size,total_size,0,0,0);
160 
161  // Send viewport data if requested
162  if ( vp_size )
163  {
164  data->send_data(data->handle,vp_fb,vp_size,0,0,0,0);
165  }
166 
167  // Send bitmap data if requested
168  if ( bm_size )
169  {
170  data->send_data(data->handle,vid_get_bitmap_active_buffer(),bm_size,0,0,0,0);
171  }
172 
173  // Send bitmap opacity data if requested
174 #ifdef THUMB_FW
175  if ( bmo_size )
176  {
177  data->send_data(data->handle,vid_get_opacity_active_buffer(),bmo_size,0,0,0,0);
178  }
179 #endif
180 
181  free(buf);
182  return total_size;
183 }