AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
ntv2captionrenderer.h
Go to the documentation of this file.
1 
7 #ifndef __NTV2_CAPTIONRENDERER__
8 #define __NTV2_CAPTIONRENDERER__
9 
10 #include "ajatypes.h"
11 #include "ntv2enums.h"
12 #include "ntv2caption608types.h"
13 #include "ntv2formatdescriptor.h"
14 #include "ccfont.h"
16 #ifdef MSWindows
17  #include "windows.h"
18  #include "stdio.h"
19 #else
20  #include <stdint.h>
21 #endif
22 
23 
30 
32 {
33  // CLASS METHODS
34  public:
42  static CNTV2CaptionRendererPtr GetRenderer (const NTV2FormatDesc & inFBDescriptor,
43  const bool inAutoOpen = true); // New in SDK 16.0
44 
48  static bool FlushGlyphCaches (void);
49 
61  static bool BurnChar ( const UByte inCharCode,
62  const NTV2Line21Attrs & inAttribs,
63  NTV2Buffer & inFB,
64  const NTV2FormatDesc & inFD,
65  const UWord inXPos,
66  const UWord inYPos); // New in SDK 16.0
67 
88  static bool BurnString (const std::string & inString,
89  const NTV2Line21Attrs & inAttribs,
90  NTV2Buffer & inFB,
91  const NTV2FormatDesc & inFBDescriptor,
92  const UWord inRowNum = 15,
93  const UWord inColumnNum = 1); // New in SDK 16.0
94 
110  static bool BurnStringAtXY (const std::string & inString,
111  const NTV2Line21Attrs & inAttribs,
112  NTV2Buffer & inFB,
113  const NTV2FormatDesc & inFBDescriptor,
114  const UWord inXPos,
115  const UWord inYPos);
116  // INSTANCE METHODS
117  public:
123  virtual bool Open (void);
124 
130  virtual bool Close (void);
131 
136  virtual inline bool IsOpen (void) const {return mGlyphHeightInLines && mGlyphWidthInBytes && mGlyphWidthInPixels;}
137 
142  virtual inline NTV2PixelFormat GetPixelFormat (void) const {return mPixelFormat;}
143 
147  virtual inline UWord GetGlyphWidthInBytes (void) const {return mGlyphWidthInBytes;}
148 
152  virtual inline UWord GetGlyphWidthInPixels (void) const {return mGlyphWidthInPixels;}
153 
157  virtual inline UWord GetGlyphHeightInLines (void) const {return mGlyphHeightInLines;}
158 
164  virtual inline UWord GlyphDotHeightToRasterLines (const UWord inVHeightInGlyphDots) const {return inVHeightInGlyphDots * mVRasterLinesPerGlyphDot;}
165 
171  virtual inline UWord GlyphDotWidthToRasterPixels (const UWord inHWidthInGlyphDots) const {return inHWidthInGlyphDots * mHRasterPixelsPerGlyphDot;}
172 
183  virtual bool GetCharacterRasterOrigin (const UWord in608CaptionRow, const UWord in608CaptionCol,
184  UWord & outVertLineOffset, UWord & outHorzPixelOffset) const;
185 
193  virtual const UByte * GetPreloadedGlyphsRasterAddress (const NTV2Line21Attrs & inAttrs) const;
194 
201  virtual bool GetGlyphsRaster (NTV2Buffer & outBuffer, const NTV2Line21Attrs & inAttrs) const; // New in SDK 16.0
202 
206  virtual NTV2FormatDescriptor GetFormatDescriptor (void) const; // New in SDK 16.0
207 
211  virtual inline ULWord GetPreloadedGlyphsRasterRowBytes (void) const {return ULWord(mGlyphWidthInBytes) * ULWord(mCCFont.GetGlyphCount());}
212 
216  virtual inline UWord GetPreloadedGlyphsRasterHeightInLines (void) const {return GetGlyphHeightInLines();}
217 
221  virtual inline UWord GetPreloadedGlyphsRasterWidthInPixels (void) const {return GetGlyphWidthInPixels() * mCCFont.GetGlyphCount();}
222 
226  virtual inline ULWord GetTotalBytes (void) const {return mBytesPerAttribute * GetNumActivePreloadedGlyphsRasters();}
227 
231  virtual inline ULWord GetNumActivePreloadedGlyphsRasters (void) const {return ULWord(mpRasters.size());}
232 
236  virtual ULWordSequence GetActivePreloadedGlyphsRastersAttributes (void) const;
237 
243  virtual std::ostream & Print (std::ostream & inOutStream, const bool inIncludeActives = false) const;
244 
248  virtual ~CNTV2CaptionRenderer ();
249 
250 
251  // PRIVATE METHODS
252  private:
253  // Hidden constructors & assignment operators
260  explicit CNTV2CaptionRenderer ( const NTV2PixelFormat inPixelFormat,
261  const NTV2CCFont & inCCFont,
262  const NTV2FrameDimensions & inFrameDimensions);
263 
264  explicit inline CNTV2CaptionRenderer (const CNTV2CaptionRenderer & inRendererToCopy);
265 
266  virtual CNTV2CaptionRenderer & operator = (const CNTV2CaptionRenderer & inRendererToCopy);
267 
268  // Per-Attribute Preloaded Glyphs Rasters
269  virtual bool CreatePreloadedGlyphsRasterForAttribute (const NTV2Line21Attributes & inAttribs) const;
270  virtual bool HasPreloadedGlyphsRasterForAttribute (const NTV2Line21Attributes & inAttribs) const;
271  virtual const UByte * GetPreloadedGlyphsRasterForAttribute (const NTV2Line21Attributes & inAttribs) const;
272 
273 
274 #if !defined(NTV2_DEPRECATE_16_0) // Old APIs
275  static NTV2_DEPRECATED_f(CNTV2CaptionRendererPtr GetRenderer (const NTV2PixelFormat pf, const NTV2FrameDimensions fd, const bool autoOpen = true));
276  static NTV2_DEPRECATED_f(bool BurnChar (const UByte charCode, const NTV2Line21Attrs & att, UByte* fb, const NTV2FrameDimensions fd, const NTV2PixelFormat pf, const UWord x, const UWord y, const UWord bpr));
277  static NTV2_DEPRECATED_f(bool BurnString (const std::string & st, const NTV2Line21Attrs& att, UByte* fb, const NTV2FrameDimensions fd, const NTV2PixelFormat pf, const UWord bpr, const UWord r = 15, const UWord c = 1));
278  static NTV2_DEPRECATED_f(bool BurnStringAtXY (const std::string & st, const NTV2Line21Attrs & att, UByte* fb, const NTV2FrameDimensions fd, const NTV2PixelFormat pf, const UWord bpr, const UWord x, const UWord y));
279 #endif // !defined(NTV2_DEPRECATE_16_0)
280 
281  // PRIVATE CLASS METHODS
282  private:
292  static bool Create (CNTV2CaptionRendererPtr & outCache,
293  const NTV2FrameBufferFormat inPixelFormat,
294  const NTV2CCFont & inCCFont,
295  const NTV2FrameDimensions & inFrameDimensions);
296 
297  // INSTANCE DATA
298  private:
299  typedef std::map <ULWord, UByte *> AttribToBufferMap;
300  typedef AttribToBufferMap::iterator AttribToBufferMapIter;
301  typedef AttribToBufferMap::const_iterator AttribToBufferMapConstIter;
302 
303  const NTV2CCFont mCCFont;
304  NTV2PixelFormat mPixelFormat;
305  mutable AttribToBufferMap mpRasters;
306  UWord mHRasterPixelsPerGlyphDot;
307  UWord mVRasterLinesPerGlyphDot;
308  UWord mVCaptionRasterOrigin;
309  UWord mHCaptionRasterOrigin;
310  UWord mGlyphWidthInPixels;
311  UWord mGlyphWidthInBytes;
312  UWord mGlyphHeightInLines;
313  ULWord mBytesPerAttribute;
314  ULWord mTotalBytes;
315  NTV2FrameDimensions mFrameDimensions;
316 
317 }; // CNTV2CaptionRenderer
318 
319 AJAExport std::ostream & operator << (std::ostream & inOutStream, const CNTV2CaptionRendererPtr & inObjPtr);
320 AJAExport std::ostream & operator << (std::ostream & inOutStream, const CNTV2CaptionRenderer & inObj);
321 
322 #endif // __NTV2_CAPTIONRENDERER__
CNTV2CaptionRenderer::GlyphDotHeightToRasterLines
virtual UWord GlyphDotHeightToRasterLines(const UWord inVHeightInGlyphDots) const
Returns the equivalent number of horizontal raster pixels that correspond to the given number of glyp...
Definition: ntv2captionrenderer.h:164
ntv2caption608types.h
Declares several data types used with 608/SD captioning.
NTV2FrameDimensions
Describes the horizontal and vertical size dimensions of a raster, bitmap, frame or image.
Definition: ntv2publicinterface.h:5659
NTV2CCFont
This is the font used when rendering CEA-608 captions into a frame buffer. I define a "dot" map havin...
Definition: ccfont.h:27
NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
NTV2Buffer
A generic user-space buffer object that has an address and a length. Used most often to share an arbi...
Definition: ntv2publicinterface.h:6022
AJARefPtr
I am a reference-counted pointer template class. I am intended to be a proxy for an underlying object...
Definition: ajarefptr.h:89
CNTV2CaptionRenderer::GetPreloadedGlyphsRasterRowBytes
virtual ULWord GetPreloadedGlyphsRasterRowBytes(void) const
Definition: ntv2captionrenderer.h:211
CNTV2CaptionRenderer::GetGlyphWidthInBytes
virtual UWord GetGlyphWidthInBytes(void) const
Definition: ntv2captionrenderer.h:147
CNTV2CaptionRenderer::GetPreloadedGlyphsRasterWidthInPixels
virtual UWord GetPreloadedGlyphsRasterWidthInPixels(void) const
Definition: ntv2captionrenderer.h:221
NTV2FrameBufferFormat
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
Definition: ntv2enums.h:210
ajatypes.h
Declares the most fundamental data types used by NTV2. Since Windows NT was the first principal devel...
ccfont.h
Declaration of NTV2CCFont.
ULWord
uint32_t ULWord
Definition: ajatypes.h:255
CNTV2CaptionRenderer::GetPixelFormat
virtual NTV2PixelFormat GetPixelFormat(void) const
Returns the frame buffer format that I'm currently "open" for.
Definition: ntv2captionrenderer.h:142
CNTV2CaptionRendererPtr
AJARefPtr< CNTV2CaptionRenderer > CNTV2CaptionRendererPtr
Definition: ntv2captionrenderer.h:28
UWord
uint16_t UWord
Definition: ajatypes.h:253
ntv2enums.h
Enumerations for controlling NTV2 devices.
CNTV2CaptionRenderer::IsOpen
virtual bool IsOpen(void) const
Answers true if I'm currently open.
Definition: ntv2captionrenderer.h:136
CNTV2CaptionRenderer::GetPreloadedGlyphsRasterHeightInLines
virtual UWord GetPreloadedGlyphsRasterHeightInLines(void) const
Definition: ntv2captionrenderer.h:216
ntv2formatdescriptor.h
Declares the NTV2FormatDescriptor class.
CNTV2CaptionRenderer::GlyphDotWidthToRasterPixels
virtual UWord GlyphDotWidthToRasterPixels(const UWord inHWidthInGlyphDots) const
Returns the equivalent number of horizontal raster pixels that correspond to the given number of glyp...
Definition: ntv2captionrenderer.h:171
CNTV2CaptionRenderer
Definition: ntv2captionrenderer.h:31
CNTV2CaptionRenderer::GetGlyphHeightInLines
virtual UWord GetGlyphHeightInLines(void) const
Definition: ntv2captionrenderer.h:157
NTV2_DEPRECATED_f
#define NTV2_DEPRECATED_f(__f__)
Definition: ajatypes.h:555
UByte
uint8_t UByte
Definition: ajatypes.h:250
ULWordSequence
std::vector< uint32_t > ULWordSequence
An ordered sequence of ULWord (uint32_t) values.
Definition: ntv2publicinterface.h:46
AJAExport
#define AJAExport
Definition: export.h:33
CNTV2CaptionRenderer::GetNumActivePreloadedGlyphsRasters
virtual ULWord GetNumActivePreloadedGlyphsRasters(void) const
Definition: ntv2captionrenderer.h:231
CNTV2CaptionRenderer::GetTotalBytes
virtual ULWord GetTotalBytes(void) const
Definition: ntv2captionrenderer.h:226
NTV2Line21Attributes
CEA-608 Character Attributes.
Definition: ntv2caption608types.h:357
ajarefptr.h
Defines the AJARefPtr template class.
operator<<
std::ostream & operator<<(std::ostream &inOutStream, const CNTV2CaptionRendererPtr &inObjPtr)
CNTV2CaptionRenderer::GetGlyphWidthInPixels
virtual UWord GetGlyphWidthInPixels(void) const
Definition: ntv2captionrenderer.h:152