AJA NTV2 SDK  17.6.0.1664
NTV2 SDK 17.6.0.1664
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 
245  virtual std::ostream & Print (std::ostream & inOutStream, const bool inIncludeActives = false) const;
246 
250  virtual ~CNTV2CaptionRenderer ();
251 
252 
253  // PRIVATE METHODS
254  private:
255  // Hidden constructors & assignment operators
262  explicit CNTV2CaptionRenderer ( const NTV2PixelFormat inPixelFormat,
263  const NTV2CCFont & inCCFont,
264  const NTV2FrameDimensions & inFrameDimensions);
265 
266  explicit inline CNTV2CaptionRenderer (const CNTV2CaptionRenderer & inRendererToCopy);
267 
268  virtual CNTV2CaptionRenderer & operator = (const CNTV2CaptionRenderer & inRendererToCopy);
269 
270  // Per-Attribute Preloaded Glyphs Rasters
271  virtual bool CreatePreloadedGlyphsRasterForAttribute (const NTV2Line21Attributes & inAttribs) const;
272  virtual bool HasPreloadedGlyphsRasterForAttribute (const NTV2Line21Attributes & inAttribs) const;
273  virtual const UByte * GetPreloadedGlyphsRasterForAttribute (const NTV2Line21Attributes & inAttribs) const;
274 
275 
276 #if !defined(NTV2_DEPRECATE_16_0) // Old APIs
277  static NTV2_DEPRECATED_f(CNTV2CaptionRendererPtr GetRenderer (const NTV2PixelFormat pf, const NTV2FrameDimensions fd, const bool autoOpen = true));
278  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));
279  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));
280  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));
281 #endif // !defined(NTV2_DEPRECATE_16_0)
282 
283  // PRIVATE CLASS METHODS
284  private:
294  static bool Create (CNTV2CaptionRendererPtr & outCache,
295  const NTV2FrameBufferFormat inPixelFormat,
296  const NTV2CCFont & inCCFont,
297  const NTV2FrameDimensions & inFrameDimensions);
298 
299  // INSTANCE DATA
300  private:
301  typedef std::map <ULWord, UByte *> AttribToBufferMap;
302  typedef AttribToBufferMap::iterator AttribToBufferMapIter;
303  typedef AttribToBufferMap::const_iterator AttribToBufferMapConstIter;
304 
305  const NTV2CCFont mCCFont;
306  NTV2PixelFormat mPixelFormat;
307  mutable AttribToBufferMap mpRasters;
308  UWord mHRasterPixelsPerGlyphDot;
309  UWord mVRasterLinesPerGlyphDot;
310  UWord mVCaptionRasterOrigin;
311  UWord mHCaptionRasterOrigin;
312  UWord mGlyphWidthInPixels;
313  UWord mGlyphWidthInBytes;
314  UWord mGlyphHeightInLines;
315  ULWord mBytesPerAttribute;
316  ULWord mTotalBytes;
317  NTV2FrameDimensions mFrameDimensions;
318 
319 }; // CNTV2CaptionRenderer
320 
321 AJAExport std::ostream & operator << (std::ostream & inOutStream, const CNTV2CaptionRendererPtr & inObjPtr);
322 AJAExport std::ostream & operator << (std::ostream & inOutStream, const CNTV2CaptionRenderer & inObj);
323 
324 #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.
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
Describes a user-space buffer on the host computer. I have an address and a length,...
Definition: ntv2publicinterface.h:6141
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
NTV2FrameSize
Describes the horizontal and vertical size dimensions of a raster, bitmap, frame or image.
Definition: ntv2publicinterface.h:5741
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