VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gvcapturebuffer.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file gvcapturebuffer.h
19 ///
20 
21 #ifndef GV_CAPTURE_BUFFER__H
22 #define GV_CAPTURE_BUFFER__H
23 
24 #include "gdef.h"
25 #include "grcolourspace.h"
26 #include "grimagedata.h"
27 #include "gassert.h"
28 #include <cstdlib>
29 
30 namespace Gv
31 {
32  class CaptureBuffer ;
33  class CaptureBufferFormat ;
34  class CaptureBufferScale ;
35  class CaptureBufferComponent ;
36  class CaptureBufferIterator ;
37 }
38 
39 /// \class Gv::CaptureBufferScale
40 /// A structure holding capture buffer dimensions. The dimensions are obtained
41 /// from a successful set-format ioctl.
42 ///
44 {
45 public:
47  ///< Default constructor.
48 
49  CaptureBufferScale( size_t buffersize_ , size_t linesize_ , size_t dx_ , size_t dy_ ) ;
50  ///< Constructor.
51 
52  bool is_simple( int dx , int dy ) const ;
53  ///< Returns true if this buffer scale matches the given image
54  ///< size using packed rgb with no end-of-line padding.
55 
56 public:
57  size_t m_buffersize ;
58  size_t m_linesize ;
59  size_t m_dx ;
60  size_t m_dy ;
61  size_t m_xy ;
62  size_t m_xy2 ;
63  size_t m_xy4 ;
64  size_t m_xy8 ;
65 } ;
66 
67 /// \class Gv::CaptureBuffer
68 /// A video-capture buffer class to hold image data, with overloaded constructors
69 /// for the various V4l i/o mechanisms. The buffer contents are straight from
70 /// the video device; the setFormat() must be used to tell the buffer what
71 /// format it contains. The accessor methods row() and copy()/copyTo() can then
72 /// be used to extract RGB pixels. The low-level pixelformat conversion is
73 /// performed by the Gv::CaptureBufferIterator class.
74 ///
76 {
77 public:
78  explicit CaptureBuffer( size_t length ) ;
79  ///< Constructor for a malloc()ed buffer suitable for "read()" i/o.
80 
81  CaptureBuffer( size_t length , void * p , int (*unmap)(void*,size_t) ) ;
82  ///< Constructor for a mmap-ed i/o.
83 
84  CaptureBuffer( size_t page_size , size_t buffer_size ) ;
85  ///< Constructor for a memalign()ed buffer suitable for "userptr" i/o.
86 
87  ~CaptureBuffer() ;
88  ///< Destructor.
89 
90  const unsigned char * begin() const ;
91  ///< Returns a pointer to start of the dword-aligned data buffer.
92 
93  unsigned char * begin() ;
94  ///< Non-const overload.
95 
96  const unsigned char * end() const ;
97  ///< Returns a pointer off the end of the raw data buffer.
98 
99  size_t size() const ;
100  ///< Returns the size of the buffer.
101 
102  CaptureBufferIterator row( int y ) const ;
103  ///< Returns a pixel iterator for the y'th row.
104 
105  void setFormat( const CaptureBufferFormat & , const CaptureBufferScale & ) ;
106  ///< Used by the Gv::Capture class to imbue the buffer with a particular
107  ///< format description and scale.
108 
109  void copyTo( Gr::ImageData & ) const ;
110  ///< Copies the image to a correctly-sized image data buffer.
111 
112  void copy( int dx , int dy , char * p_out , size_t out_size ) const ;
113  ///< Copies the image to an rgb output buffer.
114 
115  void copy( int dx , int dy , unsigned char * p_out , size_t out_size ) const ;
116  ///< Overload for unsigned char.
117 
118  size_t offset_imp( int c , int x , int y ) const ;
119  ///< Used by Gv::CaptureBufferIterator.
120 
121  size_t offset_imp( int c , int y ) const ;
122  ///< Used by Gv::CaptureBufferIterator.
123 
124  Gr::ColourSpace::triple<unsigned char> rgb_imp( size_t , size_t , size_t ) const ;
125  ///< Used by Gv::CaptureBufferIterator.
126 
127  unsigned char luma_imp( size_t , size_t , size_t ) const ;
128  ///< Used by Gv::CaptureBufferIterator.
129 
130 private:
131  CaptureBuffer( const CaptureBuffer & ) ;
132  void operator=( const CaptureBuffer & ) ;
133  unsigned int value( int c , size_t ) const ;
134  unsigned int value( int c , int x , int y ) const ;
135  unsigned char value8( int c , int x , int y ) const ;
136  unsigned char value8( int c , size_t ) const ;
137  void checkFormat() const ;
138  static size_t size4( size_t ) ;
139 
140 private:
141  const CaptureBufferFormat * m_format ;
142  CaptureBufferScale m_scale ;
143  mutable void * m_freeme ;
144  mutable void * m_start ;
145  size_t m_length ;
146  int (*m_unmap)(void*,size_t) ;
147 } ;
148 
149 /// \class Gv::CaptureBufferComponent
150 /// A descriptor for one colour component in a Gv::CaptureBufferFormat structure.
151 ///
153 {
154 public:
155  enum PlanarOffset { XY = 0x800 , XY2 = 0x400 , XY4 = 0x200 , XY8 = 0x100 } ;
156  enum Type { c_byte , c_word_le , c_word_be } ;
157 
159  ///< Default constructor for a simple step-three component.
160 
161  CaptureBufferComponent( size_t offset_ , unsigned short x_shift_ , unsigned short y_shift_ ,
162  size_t step_ , unsigned short depth_ = 8 , unsigned short shift_ = 0 , Type type_ = c_byte ,
163  short linesize_shift_ = 0 ) ;
164  ///< Constructor. The offset parameter is small fixed offset
165  ///< (eg. 0, 1 or 2) optionally combined with flags of
166  ///< XY/XY4/XY8 representing fractions of dy*linesize.
167 
168  unsigned int value( const unsigned char * p ) const ;
169  ///< Returns the value at p.
170 
171  unsigned char value8( const unsigned char * p ) const ;
172  ///< Returns the 0..255 value at p.
173 
174  size_t offset( int x , int y , const CaptureBufferScale & scale ) const ;
175  ///< Returns the buffer offset for the given pixel.
176 
177  size_t offset( int y , const CaptureBufferScale & scale ) const ;
178  ///< Returns the buffer offset for a start-of-row pixel.
179 
180  bool is_simple( size_t offset ) const ;
181  ///< Returns true if the component x_shift and y_shift are zero,
182  ///< the depth is eight, the shift is zero, the step is three,
183  ///< and the offset matches the parameter.
184 
185  unsigned short xshift() const ;
186  ///< Returns the x_shift.
187 
188  unsigned short yshift() const ;
189  ///< Returns the y_shift.
190 
191  size_t step() const ;
192  ///< Returns the step.
193 
194  unsigned short depth() const ;
195  ///< Returns the depth.
196 
197 private:
198  bool is_simple() const ;
199 
200 private:
201  size_t m_offset ; // fixed offset into the buffer, with symbolic high bits
202  unsigned short m_x_shift ; // right shift of x (for chroma sub-sampling)
203  unsigned short m_y_shift ; // right shift of y (for chroma sub-sampling)
204  size_t m_step ; // offset for each new pixel
205  unsigned short m_depth ; // number of bits, eg. 8
206  unsigned int m_mask ; // mask for 'depth' bits
207  unsigned short m_shift ; // right-shift to get the value
208  Type m_type ; // bytes-or-words enum
209  short m_linesize_shift ; // right shift of overall linesize (for planar formats)
210  bool m_simple ; // simple wrt. type/depth/shift
211 } ;
212 
213 /// \class Gv::CaptureBufferFormat
214 /// A descriptor for a v4l pixel format. The descriptor, together with a scale
215 /// structure, allow other classes to extract pixel values from a raw v4l buffer
216 /// that is laid out in the way described.
217 ///
219 {
220 public:
221  enum Type { rgb , yuv , grey } ; // colour components
222 
223  CaptureBufferFormat( unsigned int id_ = 0 , const char * name_ = "" , Type type_ = rgb ) ;
224  ///< Default constructor for an unusable, un-named rgb format.
225 
226  CaptureBufferFormat( unsigned int id_ , const char * name_ , Type type_ ,
228  ///< Constructor for a named format. Use a string literal for the name.
229 
230  bool is_grey() const ;
231  ///< Returns true if grey colour components.
232 
233  bool is_rgb() const ;
234  ///< Returns true if rgb colour components.
235 
236  bool is_yuv() const ;
237  ///< Returns true if yuv colour components.
238 
239  bool is_simple() const ;
240  ///< Returns true for a packed rgb format with 24 bits per pixel.
241 
242  const CaptureBufferComponent & component( int c ) const ;
243  ///< Returns the c'th colour component descriptor.
244  ///< Every format has exactly three components; grey formats
245  ///< have a zero depth for two of them.
246 
247  unsigned int id() const ;
248  ///< Returns the id.
249 
250  const char * name() const ;
251  ///< Returns the name.
252 
253  Type type() const ;
254  ///< Returns the type.
255 
256 private:
257  unsigned int m_id ;
258  const char * m_name ;
259  Type m_type ;
260  CaptureBufferComponent m_c[3] ;
261 } ;
262 
263 /// \class Gv::CaptureBufferIterator
264 /// A const iterator for a single row of Gv::CaptureBuffer pixels.
265 ///
267 {
268 public:
269  explicit CaptureBufferIterator( const CaptureBuffer & ,
270  size_t offset_0 , unsigned short x_shift_0 , size_t step_0 ,
271  size_t offset_1 , unsigned short x_shift_1 , size_t step_1 ,
272  size_t offset_2 , unsigned short x_shift_2 , size_t step_2 ) ;
273  ///< Constructor used CaptureBuffer::row().
274 
276  ///< Returns the three rgb values at the current position.
277 
279  ///< Same as rgb().
280 
281  unsigned char luma() const ;
282  ///< Returns the luma value at the current position.
283 
285  ///< Advances the iterator to the next pixel in the row.
286 
287  bool operator==( const CaptureBufferIterator & ) const ;
288  ///< Comparison operator.
289 
290  bool operator!=( const CaptureBufferIterator & ) const ;
291  ///< Comparison operator.
292 
293 private:
294  const CaptureBuffer & m_buffer ;
295  unsigned int m_x ;
296  size_t m_offset[3] ;
297  unsigned int m_x_shift_mask[3] ;
298  size_t m_step[3] ;
299 } ;
300 
301 
302 inline
304  m_buffersize(0U) ,
305  m_linesize(0U) ,
306  m_dy(0U) ,
307  m_xy(0U) ,
308  m_xy2(0U) ,
309  m_xy4(0U) ,
310  m_xy8(0U)
311 {
312 }
313 
314 inline
315 Gv::CaptureBufferScale::CaptureBufferScale( size_t buffersize_ , size_t linesize_ , size_t dx_ , size_t dy_ ) :
316  m_buffersize(buffersize_) ,
317  m_linesize(linesize_) ,
318  m_dx(dx_) ,
319  m_dy(dy_) ,
320  m_xy(dy_*linesize_) ,
321  m_xy2(m_xy/2U) ,
322  m_xy4(m_xy/4U) ,
323  m_xy8(m_xy/8U)
324 {
325  G_ASSERT( m_buffersize > m_linesize && m_dy != 0U ) ;
326 }
327 
328 inline
329 bool Gv::CaptureBufferScale::is_simple( int dx_in , int dy_in ) const
330 {
331  size_t dx = dx_in ;
332  size_t dy = dy_in ;
333  return m_dy == dy && m_linesize == (dx*3U) && m_buffersize == (dx*dy*3U) ;
334 }
335 
336 
337 inline
338 unsigned short Gv::CaptureBufferComponent::depth() const
339 {
340  return m_depth ;
341 }
342 
343 inline
345 {
346  return m_step ;
347 }
348 
349 inline
351 {
352  return m_x_shift ;
353 }
354 
355 inline
357 {
358  return m_y_shift ;
359 }
360 
361 inline
362 size_t Gv::CaptureBufferComponent::offset( int y , const CaptureBufferScale & scale ) const
363 {
364  const unsigned short offset_small = m_offset & 0xff ;
365  const size_t linesize = m_linesize_shift == 0 ? scale.m_linesize :
366  ( m_linesize_shift >= 1 ? (scale.m_linesize>>m_linesize_shift) : (scale.m_linesize<<-m_linesize_shift) ) ;
367  const size_t offset_line = (y>>m_y_shift) * linesize ;
368 
369  // (optimised (?) multiplication)
370  const bool add_xy = !!( m_offset & XY ) ;
371  const bool add_xy2 = !!( m_offset & XY2 ) ;
372  const bool add_xy4 = !!( m_offset & XY4 ) ;
373  const bool add_xy8 = !!( m_offset & XY8 ) ;
374  const size_t offset_plane =
375  (add_xy?scale.m_xy:0U) +
376  (add_xy2?scale.m_xy2:0U) +
377  (add_xy4?scale.m_xy4:0U) +
378  (add_xy8?scale.m_xy8:0U) ;
379 
380  return offset_small + offset_plane + offset_line ;
381 }
382 
383 inline
384 size_t Gv::CaptureBufferComponent::offset( int x , int y , const CaptureBufferScale & scale ) const
385 {
386  return offset(y,scale) + ((x>>m_x_shift)*m_step) ;
387 }
388 
389 inline
390 unsigned int Gv::CaptureBufferComponent::value( const unsigned char * p ) const
391 {
392  unsigned int v = *p ;
393  if( m_type != c_byte )
394  {
395  unsigned int v2 = p[1] ;
396  v = m_type == c_word_be ? ((v<<8)|v2) : ((v2<<8)|v) ;
397  }
398  return ( v >> m_shift ) & m_mask ;
399 }
400 
401 inline
402 unsigned char Gv::CaptureBufferComponent::value8( const unsigned char * p ) const
403 {
404  if( m_simple ) // wrt. depth/type/shift
405  return *p ;
406 
407  const unsigned int v = value(p) ;
408  if( m_depth == 8 )
409  return v ;
410  else if( m_depth < 8 )
411  return v << (8-m_depth) ;
412  else
413  return v >> (m_depth-8) ;
414 }
415 
416 inline
417 bool Gv::CaptureBufferComponent::is_simple() const
418 {
419  return m_simple && m_x_shift == 0 && m_y_shift == 0 && m_step == 3 ;
420 }
421 
422 inline
423 bool Gv::CaptureBufferComponent::is_simple( size_t offset ) const
424 {
425  return is_simple() && m_offset == offset ;
426 }
427 
428 
429 inline
430 const unsigned char * Gv::CaptureBuffer::begin() const
431 {
432  return reinterpret_cast<const unsigned char *>(m_start) ;
433 }
434 
435 inline
436 unsigned char * Gv::CaptureBuffer::begin()
437 {
438  return reinterpret_cast<unsigned char *>(m_start) ;
439 }
440 
441 inline
442 const unsigned char * Gv::CaptureBuffer::end() const
443 {
444  return begin() + size() ;
445 }
446 
447 inline
449 {
450  return m_length ;
451 }
452 
453 inline
454 size_t Gv::CaptureBuffer::size4( size_t n )
455 {
456  return n < 4U ? 0U : (n & ~size_t(3U)) ;
457 }
458 
459 inline
461 {
462  return CaptureBufferIterator( *this ,
463  offset_imp(0,y) , m_format->component(0).xshift() , m_format->component(0).step() ,
464  offset_imp(1,y) , m_format->component(1).xshift() , m_format->component(1).step() ,
465  offset_imp(2,y) , m_format->component(2).xshift() , m_format->component(2).step() ) ;
466 }
467 
468 inline
469 size_t Gv::CaptureBuffer::offset_imp( int c , int y ) const
470 {
471  return m_format->component(c).offset( y , m_scale ) ;
472 }
473 
474 inline
475 size_t Gv::CaptureBuffer::offset_imp( int c , int x , int y ) const
476 {
477  size_t result = m_format->component(c).offset( x , y , m_scale ) ;
478  G_ASSERT( result < size() ) ;
479  return result ;
480 }
481 
482 inline
483 unsigned int Gv::CaptureBuffer::value( int c , int x , int y ) const
484 {
485  return value( c , offset_imp(c,x,y) ) ;
486 }
487 
488 inline
489 unsigned int Gv::CaptureBuffer::value( int c , size_t offset ) const
490 {
491  return m_format->component(c).value( begin() + offset ) ;
492 }
493 
494 inline
495 unsigned char Gv::CaptureBuffer::value8( int c , int x , int y ) const
496 {
497  return value8( c , offset_imp(c,x,y) ) ;
498 }
499 
500 inline
501 unsigned char Gv::CaptureBuffer::value8( int c , size_t offset ) const
502 {
503  return m_format->component(c).value8( begin() + offset ) ;
504 }
505 
506 inline
507 unsigned char Gv::CaptureBuffer::luma_imp( size_t offset_0 , size_t offset_1 , size_t offset_2 ) const
508 {
509  G_ASSERT( m_format != nullptr ) ;
510  typedef Gr::ColourSpace::triple<unsigned char> triple_t ;
511  if( m_format->is_grey() || m_format->is_yuv() )
512  {
513  return value8( 0 , offset_0 ) ;
514  }
515  else
516  {
517  return Gr::ColourSpace::y_int( value8(0,offset_0) , value8(1,offset_1) , value8(2,offset_2) ) ;
518  }
519 }
520 
521 inline
522 Gr::ColourSpace::triple<unsigned char> Gv::CaptureBuffer::rgb_imp( size_t offset_0 , size_t offset_1 , size_t offset_2 ) const
523 {
524  G_ASSERT( m_format != nullptr ) ;
525  typedef Gr::ColourSpace::triple<unsigned char> triple_t ;
526  if( m_format->is_yuv() )
527  {
528  return Gr::ColourSpace::rgb_int( triple_t( value8(0,offset_0) , value8(1,offset_1) , value8(2,offset_2) ) ) ;
529  }
530  else if( m_format->is_rgb() )
531  {
532  return triple_t( value8(0,offset_0) , value8(1,offset_1) , value8(2,offset_2) ) ;
533  }
534  else // m_format->is_grey()
535  {
536  const unsigned char luma = value8( 0 , offset_0 ) ;
537  return triple_t( luma , luma , luma ) ;
538  }
539 }
540 
541 
542 inline
544  size_t offset_0 , unsigned short x_shift_0 , size_t step_0 ,
545  size_t offset_1 , unsigned short x_shift_1 , size_t step_1 ,
546  size_t offset_2 , unsigned short x_shift_2 , size_t step_2 ) :
547  m_buffer(buffer) ,
548  m_x(0U)
549 {
550  m_offset[0] = offset_0 ;
551  m_offset[1] = offset_1 ;
552  m_offset[2] = offset_2 ;
553  m_x_shift_mask[0] = ((1U<<x_shift_0)-1U) ;
554  m_x_shift_mask[1] = ((1U<<x_shift_1)-1U) ;
555  m_x_shift_mask[2] = ((1U<<x_shift_2)-1U) ;
556  m_step[0] = step_0 ;
557  m_step[1] = step_1 ;
558  m_step[2] = step_2 ;
559 }
560 
561 inline
563 {
564  return m_buffer.rgb_imp( m_offset[0] , m_offset[1] , m_offset[2] ) ;
565 }
566 
567 inline
569 {
570  return m_buffer.rgb_imp( m_offset[0] , m_offset[1] , m_offset[2] ) ;
571 }
572 
573 inline
574 unsigned char Gv::CaptureBufferIterator::luma() const
575 {
576  return m_buffer.luma_imp( m_offset[0] , m_offset[1] , m_offset[2] ) ;
577 }
578 
579 inline
581 {
582  m_x++ ;
583  if( (m_x & m_x_shift_mask[0]) == 0 ) m_offset[0] += m_step[0] ;
584  if( (m_x & m_x_shift_mask[1]) == 0 ) m_offset[1] += m_step[1] ;
585  if( (m_x & m_x_shift_mask[2]) == 0 ) m_offset[2] += m_step[2] ;
586  return *this ;
587 }
588 
589 inline
591 {
592  return m_x == other.m_x ;
593 }
594 
595 inline
597 {
598  return !(*this == other) ;
599 }
600 
601 
602 inline
604 {
605  return m_type == grey ;
606 }
607 
608 inline
610 {
611  return m_type == rgb ;
612 }
613 
614 inline
616 {
617  return m_type == yuv ;
618 }
619 
620 inline
622 {
623  G_ASSERT( c >= 0 && c < 3 ) ;
624  return m_c[c] ;
625 }
626 
627 inline
628 unsigned int Gv::CaptureBufferFormat::id() const
629 {
630  return m_id ;
631 }
632 
633 inline
634 const char * Gv::CaptureBufferFormat::name() const
635 {
636  return m_name ;
637 }
638 
639 inline
640 Gv::CaptureBufferFormat::Type Gv::CaptureBufferFormat::type() const
641 {
642  return m_type ;
643 }
644 
645 #endif
triple< unsigned char > rgb(triple< unsigned char > yuv) g__noexcept
A top-level function that calculates rgb from yuv with default implementation options.
bool operator!=(const CaptureBufferIterator &) const
Comparison operator.
A holder for image data, having eight bits per sample and one or three channels.
Definition: grimagedata.h:46
CaptureBufferIterator row(int y) const
Returns a pixel iterator for the y'th row.
Type type() const
Returns the type.
unsigned short xshift() const
Returns the x_shift.
triple< unsigned char > rgb_int(triple< unsigned char > yuv) g__noexcept
A fast conversion from yuv to rgb.
A const iterator for a single row of Gv::CaptureBuffer pixels.
bool is_grey() const
Returns true if grey colour components.
unsigned short yshift() const
Returns the y_shift.
unsigned char value8(const unsigned char *p) const
Returns the 0..255 value at p.
size_t offset(int x, int y, const CaptureBufferScale &scale) const
Returns the buffer offset for the given pixel.
const unsigned char * begin() const
Returns a pointer to start of the dword-aligned data buffer.
CaptureBufferFormat(unsigned int id_=0, const char *name_="", Type type_=rgb)
Default constructor for an unusable, un-named rgb format.
Gr::ColourSpace::triple< unsigned char > operator*() const
Same as rgb().
A descriptor for a v4l pixel format.
Gr::ColourSpace::triple< unsigned char > rgb() const
Returns the three rgb values at the current position.
size_t offset_imp(int c, int x, int y) const
Used by Gv::CaptureBufferIterator.
bool is_simple(size_t offset) const
Returns true if the component x_shift and y_shift are zero, the depth is eight, the shift is zero...
const unsigned char * end() const
Returns a pointer off the end of the raw data buffer.
bool is_rgb() const
Returns true if rgb colour components.
CaptureBuffer(size_t length)
Constructor for a malloc()ed buffer suitable for "read()" i/o.
unsigned int id() const
Returns the id.
void setFormat(const CaptureBufferFormat &, const CaptureBufferScale &)
Used by the Gv::Capture class to imbue the buffer with a particular format description and scale...
~CaptureBuffer()
Destructor.
unsigned int value(const unsigned char *p) const
Returns the value at p.
const CaptureBufferComponent & component(int c) const
Returns the c'th colour component descriptor.
bool operator==(const CaptureBufferIterator &) const
Comparison operator.
A video-capture buffer class to hold image data, with overloaded constructors for the various V4l i/o...
CaptureBufferComponent()
Default constructor for a simple step-three component.
A structure holding capture buffer dimensions.
bool is_yuv() const
Returns true if yuv colour components.
CaptureBufferIterator(const CaptureBuffer &, size_t offset_0, unsigned short x_shift_0, size_t step_0, size_t offset_1, unsigned short x_shift_1, size_t step_1, size_t offset_2, unsigned short x_shift_2, size_t step_2)
Constructor used CaptureBuffer::row().
Gr::ColourSpace::triple< unsigned char > rgb_imp(size_t, size_t, size_t) const
Used by Gv::CaptureBufferIterator.
unsigned char y_int(unsigned char r, unsigned char g, unsigned char b)
A fast conversion from rgb to y.
triple< unsigned char > yuv(triple< unsigned char > rgb) g__noexcept
A top-level function that calculates yuv from rgb with default implementation options.
unsigned char luma() const
Returns the luma value at the current position.
CaptureBufferIterator & operator++()
Advances the iterator to the next pixel in the row.
unsigned char luma_imp(size_t, size_t, size_t) const
Used by Gv::CaptureBufferIterator.
void copyTo(Gr::ImageData &) const
Copies the image to a correctly-sized image data buffer.
bool is_simple(int dx, int dy) const
Returns true if this buffer scale matches the given image size using packed rgb with no end-of-line p...
bool is_simple() const
Returns true for a packed rgb format with 24 bits per pixel.
unsigned short depth() const
Returns the depth.
void copy(int dx, int dy, char *p_out, size_t out_size) const
Copies the image to an rgb output buffer.
size_t step() const
Returns the step.
const char * name() const
Returns the name.
size_t size() const
Returns the size of the buffer.
CaptureBufferScale()
Default constructor.
A descriptor for one colour component in a Gv::CaptureBufferFormat structure.