Game Development Reference
In-Depth Information
2
VI
Real-Time JPEG Compression
Using DirectCompute
Stefan Petersson
Transporting frames within a DirectX application to a target destination is a
nontrivial task. For example, both low latency and available bandwidth are im-
portant factors when streaming image frames via a network connection. By using
the technique presented in this chapter, JPEG image data can be encoded in real
time. The resulting data may thereafter be streamed to a network destination,
saved as an image file, or appended to a movie sequence.
2.1
Introduction
Since the advent of DirectCompute, it is possible to execute more general algo-
rithms using Direct3D with full cross-vendor support. In this chapter a technique
is presented that uses DirectCompute to encode baseline JPEG images. The tech-
nique is implemented using C++ and Direct3D 11.0, which ease integration into
existing rendering systems. By using standard quantization and Huffman tables,
a majority of encoding steps can be computed in the GPU and encoded images
may be stored as still image JPEG files or appended to a motion-JPEG (MJPEG)
movie sequence file. This technique has advantages when source images are gen-
erated by the GPU, for example, taking a screenshot or recording gameplay video.
GPU encoding can outperform CPU encoding when modern hardware is used.
2.1.1 Baseline JPEG Encoding
JPEG is a digital image compression standard created by the Joint Photographic
Experts Group. The standard was accepted in 1992 and supports both lossless
and lossy compression modes. Lossy versions are frequently used in, for example,
digital cameras and web pages. The image compression method is used in multiple
data formats such as the JPEG file interchange format (JFIF) [Hamilton 92]. Files
with JFIF information are often referred to as “jpg-files.” This section describes
 
 
Search Nedrilad ::




Custom Search