AJA NTV2 SDK  17.1.1.1245
NTV2 SDK 17.1.1.1245
HDMI Auxiliary Data

Starting in SDK 17.1, some of AJA’s devices with HDMI inputs support the capture of HDMI auxiliary data using AJA’s inserter/extractor firmware technology.

Note
Although HDMI Aux playback is documented here, the feature is not currently implemented. AJA plans to complete this feature in a future firmware and SDK release.

CONTENTS:


Custom Aux Packet Capture

The only way to capture any/all Auxiliary data packets is by way of the Aux Extractor firmware.

TIP: The “NTV2Watcher” tool’s Ancillary Data Inspector is useful for diagnosing issues with auxiliary data capture.

Auxiliary Packet Filtering

For devices that support HDMI Aux capture, each HDMI input has an “Aux Extractor” widget associated with it. Each of these widgets have a filter that can exclude unwanted packets based on their Packet Type. Each filter is configured using five 32-bit registers, each register accommodating four Packet Type values, resulting in the ability to filter (exclude) up to 20 different types of packets.

  • A non-zero byte value in a filter register will cause the Extractor to skip packets whose Packet Type matches that byte value.
  • A zero byte value is always ignored by the Extractor.
  • It is not an error to have the same Packet Type value in multiple byte positions in the filter registers.

By default, the HDMI input’s Aux extractor widget is configured when CNTV2Card::AutoCirculateInitForInput (or CNTV2Card::AncExtractInit) are called. By default, the extractor is configured to NOT filter any packets.

Disabling All Filtering

To disable all filtering of incoming auxiliary data packets, pass an empty NTV2DIDSet to CNTV2Card::AuxExtractSetPacketFilters.

CNTV2Card device;
. . .
device.AuxExtractSetPacketFilters(hdmiInput, NTV2DIDSet()); // Disable all filtering
Note
Changing packet filtering takes effect at the next captured frame.
Filtering Specific Packet Types

To exclude packets having specific HDMI Packet Types, build an NTV2DIDSet that contains the Packet Types you wish to exclude, then pass the set to CNTV2Card::AuxExtractSetPacketFilters.

Restoring Default Filtering

You can also reset the ANC filtering to the default filter set:

CNTV2Card device;
. . .
NTV2VideoFormat vfmt(device.GetInputVideoFormat(NTV2_INPUTSOURCE_HDMI1));
device.AuxExtractSetPacketFilters(hdmiInput, AuxExtractGetDefaultDIDs());

It’s a good practice to save the existing filter settings, change them to what’s needed for whatever processing is necessary, and then restore them afterward:

CNTV2Card device;
. . .
NTV2DIDSet savedDIDs;
device.AuxExtractGetPacketFilters(hdmiInput, savedDIDs); // Save current anc filter (so it can be restored later)
{
// Change the anc filter to include some audio packets...
NTV2DIDSet dids;
dids.insert(0x01); // Audio Clock Regeneration
dids.insert(0x02); // Audio Sample (L-PCM & IEC-61937 compressed)
dids.insert(0x84); // Audio InfoFrame
device.AuxExtractSetPacketFilters(hdmiInput, dids); // Set new anc filtering
// . . . do other processing . . .
}
device.AuxExtractSetPacketFilters(hdmiInput, savedDIDs); // Restore prior anc filtering

Auxiliary Data Space Limitations

Rarely does the auxiliary data transmitted with a field of video exceed 5KB (or 10KB for a frame of interlaced video) … but it’s possible. If your application must accommodate more than 72KB of auxiliary data, you’ll need to enlarge the driver’s auxiliary data region.

The NTV2 driver uses two virtual registers (kVRegAncField1Offset and kVRegAncField2Offset) to control where the Aux Extractors start writing extracted packet data into (current) frame memory. When the driver starts up, it’s configured to use 0x12000 bytes (~72k) of space per field at the very bottom of each 8MB/16MB/… frame on the device (depending on video format and pixel format).

If you know the largest byte count you’ll encounter for each field, add some padding, then call CNTV2Card::AuxSetFrameBufferSize with those values.

Warning
Itʼs possible to reserve a very large auxiliary data space that actually runs into the video in the frame buffer.

To programmatically check if the Aux space intersects video in the frame buffer:

CNTV2Card device;
. . .
ULWord byteOffset(0), byteCount(0);
NTV2PixelFormat pixelFormat;
device.GetFrameBufferFormat(NTV2_CHANNEL1, pixelFormat);
const NTV2FormatDescriptor fd(vidFormat, pixelFormat);
device.GetAncRegionOffsetAndSize(byteOffset, byteCount, NTV2_AncRgn_All);
if (fd.GetTotalBytes() > byteOffset)
FAIL("HDMI Aux in video!");
Maximizing Auxiliary Data Capture Capacity
  1. Determine the largest raster your application is expected to handle.
  2. Determine the most “expensive” (in terms of memory) NTV2PixelFormat your application will need to use.
  3. Determine the “intrinsic” device frame buffer size that will be used for the video format and frame buffer format (8MB/16MB/etc.).
  4. Calculate the maximum available space for auxiliary data in the device frame buffer. This is the distance, in bytes, from just past the last line of the raster to the bottom of the device frame buffer.
  5. Call CNTV2Card::AuxSetFrameBufferSize, passing half the byte distance to each of the two parameters.

For example, 1080i video with a 10-bit YCbCr frame buffer format is easily handled by an 8MB device frame buffer. The 1920x1080 raster occupies the top 5,529,600 bytes of the device frame buffer, which leaves 2,859,008 bytes of space for auxiliary data. If a 16MB frame buffer is used (see CNTV2Card::SetFrameBufferSize), the maximum possible anc space jumps to 11,247,616 bytes — a LOT of space!

The Frame Buffer Inspector of “NTV2Watcher” readily illustrates how this works.

  1. Set it to the Raw view mode.
  2. Change the units used for the vertical ruler to Bytes From Top.
  3. Change the units used for the horizontal ruler to Bytes From Left Edge.
  4. Scroll down to the end of active video (EAV). This is where a noticeable boundary between illuminated and dimmed values indicate where changing pixel data ends. That offset – 0x00546000 – is the first safe (unchanging) byte of available HDMI auxiliary buffer space.
  5. Scroll down further until the data is displayed in a yellow color. That is the HDMI auxiliary data region.

HDMI Auxiliary Data Playout

To output HDMI Auxiliary data packets, use HDMI Aux Inserter firmware:

TIP: The “NTV2Watcher” tool’s Ancillary Data Inspector is useful for diagnosing issues with auxiliary data playout.


HDMI Aux Buffer Data Format

The data bytes in the auxiliary data buffer consist of zero or more packets. Each packet should have a fixed size of 32 bytes and match this format:

The packet bytes are:

  • Byte 0: HDMI Packet Type:
    • InfoFrame Packet:
      • 0x80: – General InfoFrame Packet (might be invalid)
      • 0x81: – Vendor-Specific InfoFrame
      • 0x82: – AVI InfoFrame
      • 0x83: – Source Product Descriptor InfoFrame
      • 0x84: – Audio InfoFrame
      • 0x85: – MPEG Source InfoFrame
    • Other Packet:
      • 0x01: – Audio Clock Regeneration (N/CTS)
      • 0x02: – Audio Sample (L-PCM & IEC-61937 compressed)
      • 0x03: – General Control
      • 0x04: – ACP Packet
      • 0x05: – ISRC1 Packet
      • 0x06: – ISRC2 Packet
      • 0x07: – One Bit Audio Sample Packet
      • 0x08: – DST Audio Packet
      • 0x09: – High Bitrate Audio Stream Packet (IEC-61937)
      • 0x0A: – Gamut Metadata Packet
  • Byte 1: Header Byte 1 (HB1)
  • Byte 2: Header Byte 2 (HB2)
    • For InfoFrames, the least-significant 5 bits of this byte contains the actual packet payload size, in bytes.
  • Byte 3:
    • For InfoFrames, this byte stores the packet checksum;
    • For all other packets, this is the first payload data byte.
  • Byte 4:
    • For InfoFrames, this byte stores the first payload data byte.
    • For all other packets, this is the 2nd payload data byte.
  • Bytes 5 … 31: Remaining payload data bytes
Note
During playback/output, before transferring the F1 (or F2 for interlace) aux buffer from the host, it’s a good practice to truncate (or zero) the buffer at (or past) the last packet written into the buffer.
During capture/input, after transferring the F1 (or F2 for interlace) aux buffer to the host, it’s a good practice to query the actual number of bytes written by the HDMI Aux Extractor, then truncate (or zero) the remainder of the host aux buffer with zeroes, to prevent parsing of stale/invalid aux packet data.

For Capture:

For Playout:

NTV2FormatDescriptor
Describes a video frame for a given video standard or format and pixel format, including the total nu...
Definition: ntv2formatdescriptor.h:41
NTV2FrameBufferFormat
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
Definition: ntv2enums.h:207
NTV2_CHANNEL1
@ NTV2_CHANNEL1
Specifies channel or Frame Store 1 (or the first item).
Definition: ntv2enums.h:1307
CNTV2Card::GetFrameBufferFormat
virtual bool GetFrameBufferFormat(NTV2Channel inChannel, NTV2FrameBufferFormat &outValue)
Returns the current frame buffer format for the given FrameStore on the AJA device.
Definition: ntv2register.cpp:1875
CNTV2Card::GetAncRegionOffsetAndSize
virtual bool GetAncRegionOffsetAndSize(ULWord &outByteOffset, ULWord &outByteCount, const NTV2AncillaryDataRegion inAncRegion=NTV2_AncRgn_All)
Answers with the offset and size of an ancillary data region within a device frame buffer.
Definition: ntv2dma.cpp:516
GetIndexForNTV2InputSource
ULWord GetIndexForNTV2InputSource(const NTV2InputSource inValue)
Definition: ntv2utils.cpp:5306
CNTV2Card::AuxExtractGetPacketFilters
virtual bool AuxExtractGetPacketFilters(const UWord inHDMIInput, NTV2DIDSet &outDIDs)
Answers with the HDMI packet types currently being excluded (filtered) by the HDMI input's Aux extrac...
Definition: ntv2aux.cpp:860
UWord
uint16_t UWord
Definition: ajatypes.h:251
CNTV2Card
I interrogate and control an AJA video/audio capture/playout device.
Definition: ntv2card.h:28
CNTV2Card::AuxExtractSetPacketFilters
virtual bool AuxExtractSetPacketFilters(const UWord inHDMIInput, const NTV2DIDSet &inDIDs)
Replaces the HDMI packet types to be excluded (filtered) by the given HDMI input's Aux extractor.
Definition: ntv2aux.cpp:886
NTV2_INPUTSOURCE_HDMI1
@ NTV2_INPUTSOURCE_HDMI1
Identifies the 1st HDMI video input.
Definition: ntv2enums.h:1224
CNTV2Card::GetInputVideoFormat
virtual NTV2VideoFormat GetInputVideoFormat(const NTV2InputSource inVideoSource=NTV2_INPUTSOURCE_SDI1, const bool inIsProgressive=(0))
Returns the video format of the signal that is present on the given input source.
Definition: ntv2register.cpp:3365
NTV2VideoFormat
enum _NTV2VideoFormat NTV2VideoFormat
Identifies a particular video format.
NTV2DIDSet
std::set< UByte > NTV2DIDSet
A set of distinct NTV2DID values.
Definition: ntv2publicinterface.h:76
NTV2_AncRgn_All
@ NTV2_AncRgn_All
Identifies "all" ancillary data regions.
Definition: ntv2enums.h:4153