June 2024
Version 1.1
Blackmagic IP10
A codec for the transmission of 12G-SDI over 10G Ethernet
Introduction Description
There are a great number of different video codecs Blackmagic IP10 encodes each source data sample with
available, but occasionally a particular set of requirements a smaller (but fixed size) encoded symbol. Each encoded
emerge that are not well catered to by an existing codec. symbol has the capacity to represent some source data
The niche of very slight compression (such as 10:8) at very samples without loss (lossless compression) but some
high data rates (such as 1 gigasample/ second) achieved
source data values must be represented with a loss (lossy
with a very small hardware size (such as a few hundred
compression). Blackmagic IP10 does this by using the
FPGA LUTs) is one such set of requirements.
first bit of an encoded symbol as a flag. If the flag is a ‘1’
PNG, T81 lossless JPEG and T87 JPEG-LS are all examples then the symbol is lossy, but if it is ‘0’ then the symbol
of codecs that provide light compression with a moderate is lossless. The remaining bits of the encoded symbol
hardware size (in thousands of FPGA LUTs). All three provide a number that enumerates which lossless or lossy
use a pixel prediction algorithm, where a given pixel is
value is encoded.
transmitted as the difference of the pixel from a neighboring
pixel (or a value derived from a combination of multiple This is best described with a simplified example. Although
neighboring pixels). Blackmagic IP10 is intended to be used for compression
cases such as 10:8, for brevity Blackmagic IP10 4:3 will be
These codecs utilise variable length codes (VLC). Variable
shown. 4:3 takes a 4 bit data sample and compresses it
length codes achieve data compression by using different
code lengths; short codes for frequently transmitted to a 3 bit encoded symbol using a fixed bitrate: each 4 bit
differences and longer codes for infrequently transmitted data sample is transmitted as a 3 bit encoded symbol.
differences. Unfortunately the use of variable length Each 3 bit encoded symbol is able to encode 8 values:
codes necessitates the use of data buffers such as FIFOs 4 lossy values and 4 lossless.
which is a disadvantage as they consume more hardware
resources and thus increase the hardware cost.
Simplified Diagram
Scope Lossless
Transform
Unpacker
Lossy Inverse
Transform
Pixel
Component
Packer
Transport
Context Adaptive Mixed Lossy and Lossless Code Word Lossy Lossless Inverse
Transform Transform
codec (Blackmagic IP10) is a new codec that dispenses
with the need for VLC data buffers by using an absolutely
Decoder Context Calc.
Constant Bit Rate (ACBR) algorithm, resulting in an
extremely minimal hardware cost. Each source data sample Determine
Store of
Determine
Store of
Lossless Range Lossless Range
Last Context Last Context
is encoded with a fixed size encoded symbol that is smaller (High/Low) (High/Low)
than the data sample.
Pixel
In one embodiment data in a 10 bit video system is Component
compressed by 20%. In this embodiment each and every
10 bit sample is encoded and transmitted as an 8 bit Blackmagic IP10 4:3 uses 5 separate code tables. Each
channel symbol (and decoded back to 10 bits at the code table includes 4 lossless values and 4 lossy values,
receiver). As every encoded symbol has a fixed size (8 but the location of the lossless values varies across the
bits) there is no need for any VLC data buffers. 5 tables. The convention used across all Blackmagic IP10
Some content is highly compressible, but some content not codecs is that the numbers of Blackmagic IP10 tables is
so much. Blackmagic IP10 provides lossless compression one more than the number of lossy values encodable by
when it’s possible but switches to low loss compression a Blackmagic IP10 symbol:
when it isn’t. IP10 provides a strictly bounded error range
when it does switch to lossy compression. number of tables = number of lossy symbols + 1
2
Detailed Diagram
System
Y0 Cb Y1 Cr Y0 Cb Y1 Cr
10 8 8 10
Encoder Decoder
10 8 8 10
Unpacker
Encoder 32 32 Decoder
Packer
Transport
10 8 8 10
Encoder Decoder
10 8 8 10
Encoder Decoder
Encoder
10 8
Pixel Component Lossless Transform 8 Encoded Symbol
10 8
Lossy Transform
Decoder
Determine Lossless Store Of Last
Range (High/Low) Context
Decoder
8 10
Encoded Symbol Lossy Inverse Transform 10 Pixel Component
8 10
Lossless Inverse Transform
Context Calc
Determine Lossless Store Of Last
Range (High/Low) Context
IP10 4:3 Code Diagram
A Blackmagic IP10 4:3 symbol is able to encode 4 lossy Blackmagic IP10 4:3 table 0: Used when previous pixel was 0, 1, 2 or 3
values, so Blackmagic IP10 4:3 has 4+1 = 5 tables.
The naming convention used for Blackmagic IP10 tables
is that tables are numbered 0 to Tmax where Tmax equals Blackmagic IP10 4:3 table 1: Used when previous pixel was 4, 5 or 6
the number of lossy symbols.
Tmax = number of lossy symbols
Blackmagic IP10 4:3 table 2: Used when previous pixel was 7, 8 or 9
Table “N” has N lossy symbols located at the bottom of the
encoding range, followed by all of the lossless symbols,
followed by the remaining lossy symbols.
Blackmagic IP10 4:3 table 3: Used when previous pixel was 10, 11 or 12
For instance Blackmagic IP10 4:3 table 3 has 3 lossy symbol
at the bottom of the range, then the 4 lossless symbols,
then the remaining 1 lossy symbol. This can be seen in
Blackmagic IP10 4:3 table 4: Used when previous pixel was 13, 14 or 15
the following diagram:
3
Context Adaptive
Blackmagic IP10 is context adaptive and different encoding A related question is which is the first pixel? The answer
tables are used in different contexts. The encoder and is that Blackmagic IP10 can be applied to a row of pixels,
decoder jointly and unanimously decide which code table or to an entire frame, or even to multiple frames. The
to use by rigid convention. The encoder does not transmit only requirement is that encoder and decoder need to
a message saying which table to use, instead the encoder be maintained in perfect lockstep plus they always need
and decoder work in lockstep and “just know” which table to agree about when a new Blackmagic IP10 sequence
to use according to the previously transmitted sample. starts and how many samples it contains.
The rigid convention used is defined in the reference
source code as: The convention officially chosen by Blackmagic
Design is to synchronise at the start of each
// Use the decoded sample to select the next row of pixels, so the previous sample values
table to use referenced by Y1, Y2, U1 and V1 are all 0x200.
s32 NextTable(Blackmagic
_IP10 *cfg, s32 sample)
{
if (sample < cfg->lowest_table_thresh)
return 0;
else if (sample >= cfg->highest_table_
thresh)
return cfg->lossy_codes;
else
Benefits
return (sample - cfg->lowest_
Blackmagic IP10 has a number of beneficial characteristics:
table_thresh + cfg->lossy_rounding) /
cfg->lossy_code_width;
} Inherent Perceptual Masking
Blackmagic IP10 has the nice feature that it inherently
provides perceptual masking; in almost all real world
images lossy mode is only used in pixels that are part
First and Previous of sharp edges. This means that encoding errors are
restricted to areas of sharp edges, and are almost entirely
Sample Convention masked by those edges.
With the goal of simplifying the hardware requirements Idempotence
for IP10, the previous sample used as reference when
Blackmagic IP10 has the nice property of idempotence,
determining the encoded value for the new sample is
which means that losses may be incurred when initially
actually as follows:
performing Blackmagic IP10 encoding, but repeated
Ynew uses Ynew-2 encoding incurs no further losses.
Unew uses Unew-1
Applicability
Vnew uses Vnew-1
The reason for this is due to the structure of 4:2:2 video
Blackmagic IP10 can be applied to any digital data that
with 2 samples of Y sent with 1 sample of U and 1 sample
consists of a sequence of fixed size samples that need
of V components.
to be stored or transmitted with mild compression. That
As each sample is encoded relative to the previous sample, includes one dimensional digital data like a sound sample
the question arises: “how is the first sample (and second) or two dimensional digital data like a bitmap image.
encoded?” The answer is that both encoder and decoder
must be initialised before transmission begins, and that
at initialisation each selects the middle table:
initial table = (number of tables) / 2
4
Real World Blackmagic IP10
Blackmagic Lossy
IP10 Source Encoded Compression Lossless Lossy symbol Worst
Flavour Domain sample bits symbol bits ratio symbols symbols width error
10:8 Professional video 10 8 10:8 128 128 7 ±3
24:11 Audio 24 11 24:11 1024 1024 16383 ±8191
4:3 (Example) 4 3 4:3 4 4 3 ±1
Quality of Blackmagic IP10 10:8
It’s mathematically lossless across smooth gradients and
10:8
slightly lossy (but still visually lossless) on edges. It does
not introduce color banding when you push color grading. Clip Y-PSNR U-PSNR V-PSNR
The amount of loss is shown in the following table:
WeddingPortrait 72.72 dB — 110.81 dB
CarCoast 66.62 dB 73.86 dB 84.54 dB
WeddingPortrait Original WeddingPortrait exaggerated losses at 10:8 (max error +/- 3)
CarCoast Original CarCoast exaggerated losses at 10:8 (max error +/- 3)
5
Blackmagic IP10
Transport over SMPTE-2110
Payload and Packet Format
The payload structure IP10 uses is the same used by NOTE: This transport scheme is subject to
SMPTE 2110:20-2022 to transfer raw video streams. change as we progress this technology through
the standards bodies.
When IP10 10:8 coding scheme is used, the payload of the
10 bit color component matches exactly the payload of a
raw video stream with 8 bit color component, where each
single 8 bit color coded component is mapped exactly to Example of SDP
the equivalent 8 bit raw color component position.
v=0
Eg. the starting color coding used is 10 bit YCbCr 422, the
o=- 4134320319 2 IN IP4 10.0.0.166
IP10 10:8 will use the same coding scheme used by the s=ATEM 1
SMPTE 2110:20-2022 8 bit YCbCr. t=0 0
m=video 16388 RTP/AVP 96
You can determine if the payload is transporting raw or c=IN IP4 239.255.194.87/255
IP10 coded data by using the information provided by the a=source-filter:incl IN IP4 239.255.194.87
SDP (Session Description Protocol). 10.0.0.166
a=rtpmap:96 vnd.blackmagic-design.ip10/90000
a=fmtp:96 sampling=YCbCr-4:2:2; depth=10;
Session Description Protocol width=3840; height=2160; exactframerate=60;
colorimetry=BT709; SSN=ST2110-22:2022;
To conform with SMPTE 2110:22:2022, Blackmagic design
TP=2110TPN;scheme=10:8;
defines the media subtype as “vnd.blackmagicdesign. a=ts-refclk:ptp=IEEE1588-2008:7C-2E-0D-FF-FE-
ip10” (depending on IETF and IANA registration) and this 1B-09-D3:127
subtype shall be used when defining the rtpmap attribute. a=mediaclk:direct=0
a=ssrc:3945940506
For a video SDP IP10, a rtpmap attribute looks like: cname:540D63C6B9F747C5A344921131A30532
a=rtpmap:96 vnd.blackmagicdesign.ip10/90000
Where the payload type is set to 96, the encoding name
is set to vnd.blackmagicdesign.ip10 and the clock rate
is set to 90000Hz as per SMPTE 2110:22-2022 standard.
The format attribute definition is almost the same used by
SMPTE 2110:20-2022 raw video transport but re-adjusted
to comply with with the following key differences:
PM Packing mode can be omitted (and it is
assumed to be set to PM=2110GPM)
SSN SMPTE Standard Number shall be set to
ST2110-22:2022
TP Traffic shaping shall be set to TP=2110TPN
Scheme A new attribute introduced by Blackmagic
Design defines the scheme used, eg 10:8.
This is optional and can be omitted. If not
present, 10:8 scheme is assumed
6
Reference Software
A reference software implementation of Blackmagic IP10
is provided in ANSI C to precisely define the codec:
/*------------------------------------------------------------------------------
*
* Copyright (c) 2023 Blackmagic Design Pty Ltd
* 180 Bank Street, South Melbourne,
* Victoria 3205, Australia
*
* Source code and information contained herein are
* proprietary to Blackmagic Design Pty Ltd
*
*----------------------------------------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
typedef signed char s8;
typedef unsigned char u8;
typedef signed short s16;
typedef unsigned short u16;
typedef signed int s32;
typedef unsigned int u32;
typedef signed long long s64;
typedef unsigned long long u64;
typedef struct
{
u32 sample_states;
u32 coded_states;
u32 lossy_code_width;
u32 lossy_rounding;
u32 lossless_codes;
u32 lossy_codes;
u32 code_tables;
u32 default_table;
u32 lowest_table_thresh;
u32 highest_table_thresh;
u32 lossy_flag;
} BMIP10_Cfg;
// Calculate constants needed by the specified flavour of BMD IP compression
void SetupBMIP10(BMIP10_Cfg *cfg, u32 sample_bits, u32 coded_bits)
{
cfg->sample_states = 1 << sample_bits;
cfg->coded_states = 1 << coded_bits;
cfg->lossy_code_width = (1 << (sample_bits - coded_bits + 1)) - 1;
cfg->lossy_rounding = cfg->lossy_code_width / 2;
cfg->lossless_codes = cfg->coded_states / 2;
cfg->lossy_codes = cfg->coded_states / 2;
cfg->code_tables = 1 + cfg->coded_states / 2;
cfg->default_table = cfg->code_tables / 2;
cfg->lowest_table_thresh = cfg->lossless_codes / 2;
cfg->highest_table_thresh = cfg->sample_states - (cfg->lossless_codes / 2);
cfg->lossy_flag = (1 << coded_bits) / 2;
}
// Use the decoded sample to select the next table to use
s32 NextTable(BMIP10_Cfg *cfg, s32 sample)
{
if (sample < cfg->lowest_table_thresh)
return 0;
else if (sample >= cfg->highest_table_thresh)
return cfg->lossy_codes;
else
return (sample - cfg->lowest_table_thresh + cfg->lossy_rounding) / cfg->lossy_code_width;
}
7
// For a given sample and code table calculate the code word
s32 EncodeSample(BMIP10_Cfg *cfg, s32 table, s32 sample)
{
s32 lossless_low = table * cfg->lossy_code_width;
s32 lossless_high = lossless_low + cfg->lossless_codes;
if (sample >= lossless_low && sample < lossless_high)
return sample - lossless_low;
else if (sample < lossless_low)
return cfg->lossy_flag | (sample / cfg->lossy_code_width);
else
return cfg->lossy_flag | ((sample - lossless_high) / cfg->lossy_code_width + table);
}
// For a given code word and code table decode the sample
s32 DecodeSample(BMIP10_Cfg *cfg, s32 table, s32 code_word)
{
s32 index = code_word & ~cfg->lossy_flag;
if (code_word & cfg->lossy_flag)
if (index < table)
return index * cfg->lossy_code_width + cfg->lossy_rounding;
else
return index * cfg->lossy_code_width + cfg->lossy_rounding + cfg->lossless_codes;
else
return table * cfg->lossy_code_width + index;
}
// BMD IP10 encode a sequence of samples
void EncodeSequence
(
BMIP10_Cfg *cfg,
s16 *sampin,
s16 *codeout,
s32 samples
)
{
s32 i;
s32 code_word;
s32 decoded;
s32 table;
s32 table_old;
table = cfg->default_table;
printf(“Encoder started. Table initialised to %3d\n”, table);
for (i = 0; i < samples; ++i)
{
code_word = EncodeSample(cfg, table, *sampin++);
*codeout++ = code_word;
decoded = DecodeSample(cfg, table, code_word);
printf(“Used table %3d “, table);
table_old = table;
table = NextTable(cfg, decoded);
printf(“to encode sample %4d to codeword %3d. Decoder will decode %4d so “, sampin[-1],
codeout[-1], decoded);
if (table_old == table)
printf(“sticking with”);
else
printf(“changing to “);
printf(“ table %3d\n”, table);
}
}
// BMD IP10 encode a sequence of samples
void DecodeSequence
(
BMIP10_Cfg *cfg,
s16 *codein,
s16 *sampout,
s32 samples
)
{
s32 i;
s32 decoded;
s32 table;
8
s32 table_old;
table = cfg->default_table;
printf(“Decoder started. Table initialised to %3d\n”, table);
for (i = 0; i < samples; ++i)
{
decoded = DecodeSample(cfg, table, *codein++);
*sampout++ = decoded;
printf(“Used table %3d “, table);
table_old = table;
table = NextTable(cfg, decoded);
printf(“to decode codeword %3d to sample %4d so “, codein[-1], sampout[-1]);
if (table_old == table)
printf(“sticking with”);
else
printf(“changing to “);
printf(“ table %3d\n”, table);
}
}
int main(int argc, char *argv[])
{
s16 source[16] = {1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987};
s16 ethernet[16];
s16 decoded[16];
BMIP10_Cfg c;
SetupBMIP10(&c, 10, 8);
EncodeSequence(&c, source, ethernet, 16);
DecodeSequence(&c, ethernet, decoded, 16);
return 0;
}
Prior Art
There is prior art for an Absolutely Constant Bit Rate
(ACBR) codec. Steve Hayes, 1985:
“Amiga® ROM Kernel Reference Manual: Devices”
3rd edition, ISBN 0-201-56775-X
p428 Appendix A: IFF:Interchange File Format
Amiga “8SVX” IFF 8-Bit Sampled Voice file format
with optional Fibonacci Delta coded audio samples.
Each 8 bit audio sample is encoded as a 4 bit symbol.
https://web.archive.org/web/20091121223006/http://
amigan.1emu.net/reg/8SVX.txt
http://amigadev.elowar.com/read/ADCD_2.1/Devices_
Manual_guide/node02D6.html
“Adaptive Quantization With a One-Word Memory”
by N. S. Jayant, First published: September 1973
https://ieeexplore.ieee.org/document/6770731
www.blackmagicdesign.com