Fastvideo JPEG vs NVIDIA nvJPEG on RTX 4090: encoding, decoding and restart markers

Updated:

This article compares two JPEG codecs on one RTX 4090 GPU: Fastvideo JPEG from the Fastvideo SDK and the nvJPEG library from the CUDA Toolkit. Both use the same quantization tables, so the compressed images are practically the same, and the comparison is about speed. At encoding the Fastvideo codec is 30–39 % faster on 2K, 4K and 8K frames in one thread. At decoding the gap is far larger: the Fastvideo decoder is 9.7 times faster than the nvJPEG decoder on a 2K frame, 28 times faster on 4K and 35 times faster on 8K. The main reason is restart markers. The Fastvideo encoder inserts them during compression, and the Fastvideo decoder later uses them to decode the image on the GPU in parallel; the markers add only 2.1–2.9 % to the file size. nvJPEG does not insert markers and cannot use them. The choice of encoder therefore sets not only the encoding speed but also the decoding speed, and decoding is where it matters most.

Chart: JPEG encoding and decoding speed in fps on an RTX 4090, Fastvideo JPEG vs nvJPEG on 2K, 4K and 8K frames
Encoding and decoding at quality 90, 4:4:4, without copying to the GPU and back. At encoding the two codecs differ by percent, at decoding by a factor of ten and more.

Key results

RTX 4090, Fastvideo SDK 0.23.1.0 and nvJPEG 13.2.1.68. Speed is given in frames per second (fps). The conditions are the standard ones for this article (section 2) unless an item says otherwise.

Encoding and decoding speedOne thread, without copying to the GPU and back, quality 90, 8 bits per channel, 4:4:4 (no chroma subsampling)
Test
frame
Fastvideo
encoder
nvJPEG
encoder
Fastvideo
decoder
nvJPEG
decoder
2K, 1920×10805595 fps4313 fps1862 fps191 fps
4K, 3840×21602805 fps2014 fps1640 fps59.1 fps
8K, 7680×4320715 fps541 fps515 fps14.9 fps
12K, 11520×6480335 fps248 fps221 fps6.05 fps
16K, 15360×8640191 fps137 fps118 fps3.43 fps
  • Encoding: the Fastvideo encoder is 30–39 % faster than the nvJPEG encoder.
  • Decoding: the Fastvideo decoder is 9.7–37 times faster than the nvJPEG decoder.
  • Restart markers: the Fastvideo encoder inserts them into every compressed frame, nvJPEG does not. The markers add 2.1–2.9 % to the file size.
  • When this decoding speed is available: on images with restart markers, that is, compressed by the Fastvideo encoder or prepared with jpegtran.
  • Large frames, 12K and 16K: the Fastvideo encoder is 35 and 39 % faster than the nvJPEG encoder, the Fastvideo decoder is 37 and 34 times faster than the nvJPEG decoder. The Fastvideo codec reaches its full performance already on an 8K frame. Section 5.
  • Decoding in multithreaded mode, with copying to the GPU and back: with each codec at its best settings, the Fastvideo decoder is 3.0–3.3 times faster.
  • GPU energy at encoding: 1.1–1.3 times less with the Fastvideo codec than with nvJPEG.

The test scripts, our harness for nvJPEG, the summaries and the logs of every measurement are on GitHub: github.com/fastvideo/jpeg-benchmark.

1. JPEG restart markers: what they are and why decoding speed depends on them

Most of the time in the JPEG algorithm goes not into the discrete cosine transform or quantization but into entropy coding and decoding.

How JPEG is built. Everything below is defined in the JPEG standard, ITU-T T.81, also published as ISO/IEC 10918-1. These terms are needed to see how the codecs work; clause numbers of the standard are given in brackets.

How data after a restart marker is coded. A DC coefficient in JPEG is coded as the difference from the DC coefficient of the previous block of the same component. After every restart marker the DC prediction starts again from zero. The compressed data before a marker is padded with 1-bits to a whole byte (clause B.1.1.5), so the marker starts on a byte boundary. A segment can therefore be decoded without knowing anything about the previous ones: everything it needs is in the segment itself and in the file header.

How markers are found. A marker starts with the byte FF. To keep such a byte from appearing inside compressed data by chance, the encoder inserts a zero byte 00 after every FF in the compressed data; this is called byte stuffing (clause 3.1.14). So FF followed by a byte from D0 to D7 in compressed data is always a restart marker, and all markers can be found by a plain byte scan, without decoding anything. A decoder can first find the start of every segment and then decode all segments at once. The standard names this use of markers directly: parallel encoding or decoding (clause 4.9).

The restart intervals of the Fastvideo encoder are fixed. The restart interval used to be an encoder parameter; now it is a set of constants, one for each subsampling type, and it cannot be set or changed. The values are given in the Fastvideo SDK manual. They are a trade-off between encoding and decoding speed. The decoder is fastest with a restart interval of 1, that is, with a marker after every MCU, but then the encoder would have to insert far more markers, it would run slower, and the file would grow by 21–29 % instead of 2.1–2.9 % (section 1.1). In every case a segment holds 30–32 data units.

Restart intervals of the Fastvideo encoderFrom the Fastvideo SDK manual; for 4:4:4, 4:2:2 and 4:2:0 checked against the headers of files written by the encoder; data units per segment are the restart interval times the data units per MCU
MCU,
pixels
Data units
per MCU
Interval,
MCUs
Data units
per segment
4:4:48×831030
4:2:216×84832
4:2:016×166530
Grayscale8×813232

About 4:2:2. 4:2:2 subsampling halves the chrominance components horizontally and keeps them at full vertical resolution: an area of 16×16 pixels has 4 luminance blocks and 2 blocks of each chrominance component. The standard allows two ways to write this in the header: sampling factors 2×1 for luminance and 1×1 for chrominance, giving a 16×8-pixel MCU of 4 data units, or 2×2 and 1×2, giving a 16×16-pixel MCU of 8 data units. The table shows the first way, the more common one, and it is what the Fastvideo encoder writes: we compressed a 4K frame with 4:2:2 subsampling and read the file header, which has factors 2×1 for luminance and 1×1 for chrominance, a 16×8-pixel MCU and a restart interval of 8 MCUs. The header is read by the script jpeg-sof-01.py from the repository (section 13).

This article measures 4:4:4 and 4:2:0. The Fastvideo encoder never uses a restart interval of 1, a marker after every MCU: the files with that interval in section 1.1 were made by another program.

At encoding, block boundaries are known in advance: the uncompressed image defines them. All quantized blocks are known before entropy coding starts, so each block can be coded separately and the coded blocks joined into one stream afterwards. Encoding therefore runs in parallel even without restart markers.

At decoding, the boundaries of coded blocks are unknown. Huffman codes have variable length, and where one code ends becomes known only after it has been parsed. A decoder cannot start in the middle or jump ahead: until the data has been read from the start, there is nothing to split it by. This is where restart markers come in: only they split the compressed data into segments that can be decoded independently. Think of a book without a table of contents or page numbers: to find the start of chapter ten, you have to read it from page one. Restart markers are bookmarks at the start of each chapter: they show at once where every chapter begins, and several people can read different chapters at the same time. Here the chapters are segments and the readers are GPU cores.

This is neither our invention nor an extension of the format. Restart markers have been in the JPEG standard from the start, and they were designed precisely so that segments can be decoded independently of each other. The feature has been in the standard for more than thirty years and is open to anyone who writes a codec.

Yet few codecs use it. The reason is where JPEG has run all this time. On a CPU, segments give little: a CPU has a handful of threads, not thousands, and the gain does not pay for a few percent of file size. So most encoders do not insert markers, and decoders do not use them, even though with markers a single frame would decode faster too. On a GPU it is the other way round: there are thousands of cores, and a lack of segments is exactly what keeps them idle.

The Fastvideo encoder always inserts restart markers, nvJPEG never does. Markers do not hurt compatibility: any program reads a file with markers, and a decoder that cannot use them simply skips them.

The test results agree: the nvJPEG encoder is fast on the GPU without markers, because an encoder does not need them. An encoder inserts markers not for itself but for whoever decodes the image. The profiler shows directly that nvJPEG runs entropy coding on the GPU: at encoding its ACKernel and DCKernel kernels run, which code the AC and DC coefficients, and they take almost half of all kernel time. The nvJPEG decoder has no entropy decoding kernel at all. Section 7 has the details.

1.1. The same image with and without markers: test results

Chart: decoding speed of the same JPEG image with markers, without markers and with one marker per MCU, Fastvideo JPEG and nvJPEG decoders, 2K, 4K and 8K frames
Three versions of one file: with markers as the Fastvideo encoder inserted them, without markers, and with a marker after every MCU. The markers are what makes the Fastvideo decoder fast; the nvJPEG decoder hardly depends on them.

To make the role of markers a test result rather than a guess, we measured it directly. An image compressed by the Fastvideo encoder was rewritten with jpegtran from libjpeg-turbo into two more versions: without markers and with a marker after every MCU. jpegtran does this losslessly: it does not recompress the image and does not change a single coefficient. It only redoes entropy coding, removing restart markers or inserting them at the required interval. After decoding, all three versions give byte-identical images. Both decoders processed all three versions in one thread, without copying to the GPU and back.

Where jpegtran comes from. It is one of the utilities of libjpeg, the free JPEG implementation released by the Independent JPEG Group, an independent group of developers led by Tom Lane. The first version of the library came out on October 7, 1991, and jpegtran appeared in version 6, in August 1995. The program transforms JPEG files that are already compressed, without loss: it works on the quantized coefficients and never decodes the image fully. This is how it rotates and crops images, converts a file between baseline and progressive JPEG, recomputes Huffman tables, and inserts or removes restart markers. jpegtran is also part of libjpeg-turbo, the fastest JPEG codec for the CPU; it is accelerated with SIMD instructions and has been developed since 2010. libjpeg-turbo is free and ships with most Linux distributions and in builds for Windows.

With markers the Fastvideo decoder is 19 times faster on a 2K frame, 53 times faster on 4K and 75 times faster on 8K: 1864 fps instead of 96, 1652 fps instead of 31 and 527 fps instead of 7. Without markers the stream is decoded sequentially, and the Fastvideo decoder has no advantage: on the same file nvJPEG gives 177, 55.9 and 14.8 fps. This is expected: as the Fastvideo SDK manual says, on a file without markers, and with a restart interval above 255, the Fastvideo decoder runs entropy decoding on the CPU, just like nvJPEG. The whole advantage of the Fastvideo decoder rests on markers.

More markers, faster decoding. With a marker after every MCU the Fastvideo decoder is another 77 % faster on a 2K frame and 23 % faster on 4K and 8K. The cost is size: the file is 21 % larger than without markers on a 2K frame and 29 % larger on 4K and 8K, while markers at the rate the Fastvideo encoder inserts them add 2.1 % and 2.9 %. The Fastvideo encoder itself does not put a marker after every MCU: that version of the file can only be made by another program, here jpegtran.

The nvJPEG decoder cannot use markers. It handles files with markers the same way as files without them and simply skips the markers: 174 and 177 fps on 2K, 52.7 and 55.9 fps on 4K, 14.5 and 14.8 fps on 8K. With a marker after every MCU it is 7–14 % slower: there are more markers, and it has to skip each of them.

Decoding the same image in three versionsOne thread, quality 90, 4:4:4, without copying to the GPU and back
Fastvideo,
fps
nvJPEG,
fps
Fastvideo,
ms
nvJPEG,
ms
2K, with markers18641740.5365.74
2K, no markers9617710.45.64
2K, one marker per MCU32961610.3036.21
4K, with markers165252.70.60519.0
4K, no markers3155.932.317.9
4K, one marker per MCU203549.20.49120.3
8K, with markers52714.51.9069.0
8K, no markers714.814367.8
8K, one marker per MCU65012.51.5479.7

The marker test is a separate series run on the same day, so the rows “with markers” differ from section 4 by no more than 2.3 %: 1864 against 1862 fps on a 2K frame, 527 against 515 fps on 8K.

In multithreaded mode, with copying to the GPU and back, almost everything also depends on markers. On images with markers the Fastvideo decoder gives 3800 fps on a 2K frame and 896 fps on 4K. That is 93 % and 87 % of the PCIe bandwidth, so here the speed is already limited by the bus. Without markers it gives 869 and 255 fps, 77 % and 72 % less: several threads decode different frames at once, but inside each frame decoding stays sequential. A marker after every MCU adds another 13 % and 3 %: there is little room left, since the bus is already nearly full. On an 8K frame it is 197 fps with markers and 46 without, 77 % less; here 8 threads run, because a frame of this size needs no more.

The Fastvideo decoder on the same three versions of the fileMultithreaded mode with copying to the GPU and back, quality 90, 4:4:4; 2K and 4K with 32 threads, 8K with 8 threads
With markers,
interval 10
No markersOne marker per MCU,
interval 1
2K, fps38008694297
4K, fps896255924
8K, fps19746212

The nvJPEG decoder is not shown in this part of the test: it was not tested on these files in multithreaded mode with copying.

How much restart markers add to the file sizeCompared with the same stream without markers, quality 90, 4:4:4
With markers,
interval 10
One marker per MCU,
interval 1
2K+ 2.1 %+ 21.2 %
4K+ 2.9 %+ 29.0 %
8K+ 2.9 %+ 29.0 %

This leads to the main point of the article. The Fastvideo JPEG decoder is fast because it works with images that contain markers: it processes the segments between them at the same time. Without markers there is nothing to decode in parallel, and the advantage disappears; this is now a measurement, not an argument. The nvJPEG decoder cannot use markers and processes the stream sequentially in any case.

So an encoder should not be chosen by compression speed alone. A compressed image will sooner or later be decoded: for processing, for display, as input to a neural network, when working with archives of compressed images. An encoder that inserts markers pays for them once, with a few percent of file size, and the gain comes every time the image is decoded. This holds only if the decoder can use the markers.

2. Test conditions

Test system. NVIDIA RTX 4090 GPU, driver 610.88, a CPU with 32 logical cores, Windows 11. Fastvideo JPEG comes from Fastvideo SDK 0.23.1.0 and was tested with the JpegSample application from the same package. nvJPEG comes from the CUDA Toolkit, library version 13.2.1.68, and was tested with our harness nvjpeg_bench: it calls the library directly, the way a developer would, and its source code is on GitHub together with the test scripts (section 13). Both codecs run on the CUDA cores: this card has no hardware JPEG unit, which was checked in three independent ways.

Images. Three frames: 2K, 1920×1080 pixels; 4K, 3840×2160; and 8K, 7680×4320. The 8K frame is four copies of the 4K frame joined two by two. Section 5 adds two more frames, 12K, 11520×6480, and 16K, 15360×8640, joined the same way, three by three and four by four; they are made by the script make-big-frames-02.py from the repository. Eight bits per channel, three channels, no chroma subsampling, that is, 4:4:4; only in section 4.1 are the same frames compressed with 4:2:0 subsampling. Quality 90, that is, the quality parameter q = 90. Baseline JPEG; no special modes were enabled in either codec.

What time was measured. In sections 1, 3, 4, 5 and 6, only the work of the codec on the GPU. The encoder gets an image that is already in GPU memory and leaves the compressed stream there; the decoder gets the compressed stream and leaves the finished image in GPU memory. Copying between host memory and GPU memory is not counted. In sections 8 and 9, and in the multithreaded part of the test in section 1.1, copying in both directions is included.

There are two measurements because they answer different questions. The uncompressed image is copied over PCIe in full, and on 2K and 4K frames the speed is limited by the bus bandwidth: at encoding with copying both codecs use 83–93 % of it. Such a measurement shows what the PCIe bus can do, not the codec. To judge the speed of encoding or decoding itself, copying time should be left out. To know the time of the whole task “take an image from host memory, compress it and return it”, copying time must be included. The two kinds of result must not be mixed in one table.

Threads. In sections 1, 3, 4, 5 and 6 the work runs in one thread (apart from the multithreaded part of the test in section 1.1), so the comparison does not depend on how each codec is parallelized from the outside. In sections 7, 8 and 9 each codec runs at its best settings, the ones that give it the highest speed; three settings were tried, from 8 to 32 threads.

Repeats. Every measurement was repeated three times, and the tables show the median. Before each repeat the script checked that no other program was using the card; during the speed and energy measurements it was never busy. In every measurement given in the article, the repeats differ by no more than 7 %. The 12K and 16K frames were measured in a separate series under a stricter procedure, described in section 5.

When. The tests in the article were run on September 25, 2026, the 12K and 16K frames (section 5) on September 29, 2026, on the same test system.

Do the codecs do the same work? The two codecs have the same base quantization tables, so at the same quality setting they give practically the same compressed images. The tables were checked on twelve pairs: 2K, 4K and 8K at quality 80, 85, 90 and 95. The quantization table is stored in the JPEG file itself, so anyone can repeat this check. At the same quality, PSNR differs by no more than 0.1 dB.

3. JPEG encoding speed on RTX 4090

In one thread the Fastvideo encoder is 30 % faster on a 2K frame, 39 % faster on 4K and 32 % faster on 8K. These results are also on the first chart of the article.

The comparison is not on equal terms, and not in favor of the Fastvideo encoder: it does extra work that nvJPEG does not do, namely inserting restart markers. It is not faster because it does less.

From 2K to 4K the amount of data grows four times, and the frame time of both encoders roughly doubles: 5595 fps against 2805 fps for Fastvideo, 4313 fps against 2014 fps for nvJPEG. From 4K to 8K the data grows four times again, and now the frame time grows almost as much, 3.9 times for Fastvideo and 3.7 times for nvJPEG. How the encoding time of a frame splits into stages was not measured here.

JPEG encoding speedOne thread, quality 90, 4:4:4, without copying to the GPU and back
Fastvideo,
fps
nvJPEG,
fps
Fastvideo,
ms
nvJPEG,
ms
Speedup
2K559543130.1790.232+ 30 %
4K280520140.3570.497+ 39 %
8K7155411.401.85+ 32 %

The time per frame in milliseconds is computed from frames per second. It is given so that the encoding time can be added to the time of other processing stages on the GPU.

The encoder itself is faster than the bus. To compare encoder speed with bus bandwidth, we express it in gigabytes per second of uncompressed data. In one thread the Fastvideo encoder processes: 2K, q = 90, 4:4:4, 35 GB/s; 4K, q = 90, 4:4:4, 70 GB/s; 8K, q = 90, 4:4:4, 71 GB/s; 8K, q = 90, 4:2:0, 96 GB/s (section 4.1). The PCIe bandwidth of this test system is 25.5 GB/s, so the encoder works 1.4–3.8 times faster than the bus can feed it images. This is why the speed with copying (section 8) shows what the bus can do, while the encoder’s own speed shows where the source image is already in GPU memory: in a camera processing pipeline, after decoding, after other processing stages on the GPU. Then only the compressed image goes over the bus, and it is several times smaller than the source.

4. JPEG decoding speed on RTX 4090

Here, also in one thread, the difference is not in percent but in multiples, and it grows with image size: 9.7 times on 2K, 28 times on 4K and 35 times on 8K.

How to read this. What is compared is not two decoders on the same input but two encoder–decoder pairs, the way they work for a user: each decoder gets the image compressed by its own encoder. The Fastvideo frames contain restart markers, and the segments are decoded at once on thousands of cores. The nvJPEG frames have no markers, and decoding is sequential; the next section shows where. The test in section 1.1 shows that the difference is the markers: on a file without markers the Fastvideo decoder has no advantage.

This is also why frame time grows differently with resolution. From 2K to 4K the Fastvideo frame time grew by only 14 %, from 0.537 to 0.610 ms; the nvJPEG frame time grew 3.2 times, from 5.25 to 16.9 ms, following the growth of the data. That is how sequential decoding behaves. From 4K to 8K the Fastvideo frame time grew 3.2 times, to 1.94 ms, and the nvJPEG frame time 4.0 times, to 67.2 ms. How frame time grows further, on 12K and 16K frames, is in section 5.

JPEG decoding speedEach decoder works on the image from its own encoder; one thread, quality 90, 4:4:4, without copying to the GPU and back
Fastvideo,
fps
nvJPEG,
fps
Fastvideo,
ms
nvJPEG,
ms
Speedup
2K18621910.5375.259.7x
4K164059.10.61016.928x
8K51514.91.9467.235x

4.1. Chroma subsampling 4:2:0

With 4:2:0 subsampling each chrominance channel has four times fewer pixels, the total data is halved, and both encoders compress faster. At decoding the picture splits: the nvJPEG decoder speeds up by 55–64 %, while the Fastvideo decoder on 2K and 4K frames slows down by 17–25 % and speeds up by 25 % only on 8K. The gap between the decoders shrinks from 10 to 4.9 times on a 2K frame, from 29 to 15 times on 4K and from 38 to 29 times on 8K.

Next to this is an observation we have not yet checked separately. At 4:2:0 an MCU covers 16×16 pixels instead of 8×8, and the restart interval of the Fastvideo encoder is 5 MCUs instead of 10. So a frame has half as many segments: 1632 instead of 3240 on 2K, 6480 instead of 12,960 on 4K, 25,920 instead of 51,840 on 8K. It is not proven that this is what slows the Fastvideo decoder on 2K and 4K: it is a coincidence, not a measured cause. Nor does it explain everything: on 8K there are also half as many segments, yet there the Fastvideo decoder speeds up rather than slows down.

Encoding and decoding with 4:4:4 and 4:2:0 subsamplingOne thread, quality 90, separate series of measurements
4:4:4,
fps
4:2:0,
fps
Change
Fastvideo, encoding 2K53865508+ 2 %
Fastvideo, encoding 4K28063734+ 33 %
Fastvideo, encoding 8K716963+ 34 %
nvJPEG, encoding 2K41934471+ 7 %
nvJPEG, encoding 4K20142552+ 27 %
nvJPEG, encoding 8K541749+ 38 %
Fastvideo, decoding 2K18381379− 25 %
Fastvideo, decoding 4K16391363− 17 %
Fastvideo, decoding 8K527660+ 25 %
nvJPEG, decoding 2K181280+ 55 %
nvJPEG, decoding 4K55.689.2+ 60 %
nvJPEG, decoding 8K13.722.4+ 64 %

The 4:4:4 results were measured in the same series as 4:2:0, alternating with them, so they differ slightly from sections 3 and 4. The 8K rows were measured in a separate series on the same day.

5. Large frames: 12K and 16K

Images larger than 8K are common in many tasks: they come from high-resolution cameras, for example in aerial imaging, and from stitching many shots, in street panoramas, digital pathology, satellite imaging and microscopy. We checked what speed the codecs give on 12K and 16K frames.

How the frames are made. The same way as the 8K frame: from copies of the 4K frame placed side by side. The 12K frame is 11520×6480 pixels (75 MPix), nine copies, three by three; the 16K frame is 15360×8640 pixels (133 MPix), sixteen copies, four by four. The frames are made by the script make-big-frames-02.py from the repository (section 13): the frames themselves are 224 and 398 MB, and anyone can make them from the 4K frame in a few seconds. The conditions are the same as in sections 3, 4 and 4.1: q = 90, 4:4:4 and 4:2:0, one image at a time, without copying to the GPU and back. Each decoder works on the image from its own encoder.

Repeats. The 12K and 16K frames were measured in a separate series on the same test system. Each measurement was repeated at least three times, and throughout the run the script logged GPU load and power once a second. If during a repeat the GPU drew more than 20 % above the quietest repeat of the same measurement, another program was running on it: such a repeat was left out of the median and extra repeats were run. There were no such repeats. The tables show the median of the clean repeats; they differ by no more than 7.6 %.

The number of segments grows with frame size. The restart interval of the Fastvideo encoder is 10 MCUs at 4:4:4 and 5 at 4:2:0, so a frame splits into segments as follows:

Segments per frame with the Fastvideo encoderNumber of MCUs divided by the restart interval
Size,
MPix
4:4:44:2:0
8K frame3351,84025,920
12K frame75116,64058,320
16K frame133207,360103,680

nvJPEG files have no markers, and the whole frame is one segment: nvJPEG decodes a frame of any size sequentially, running entropy decoding on the CPU.

Markers allow decoding part of an image. Each segment starts with a marker and decodes independently of the others, and the restart interval sets how many MCUs it holds. So the segment number tells which area of the image it covers: with the Fastvideo encoder, on the frames of this section, it is a strip of 80×8 pixels at 4:4:4 and 80×16 at 4:2:0. In other words, markers split the image into small areas with known boundaries, in effect tiles, and they can be found by a plain byte scan. A decoder can then decode only the segments that fall into the part of the image it needs, for example the part now visible on screen, and leave the rest alone. For stitched images this can matter more than the speed of decoding the whole image: they are usually viewed part by part. A file without markers does not allow this: to reach the right place, everything before it in the stream has to be entropy decoded. The Fastvideo decoder has no such mode today and processes the whole image, but the format allows it, and the mode can be built for a task that needs it.

Encoding and decoding of 8K, 12K and 16K framesOne thread, q = 90, 4:4:4, without copying to the GPU and back
Fastvideo,
fps
nvJPEG,
fps
Fastvideo,
GB/s
Speedup
Encoding 8K71554171+ 32 %
Encoding 12K33524875+ 35 %
Encoding 16K19113776+ 39 %
Decoding 8K51514.95135x
Decoding 12K2216.054937x
Decoding 16K1183.434734x

GB/s is uncompressed data per second: frames per second times the number of pixels times three bytes, as in section 8. The PCIe bandwidth of this test system is 25.5 GB/s.

Encoding. The Fastvideo encoder compresses a 12K frame at 335 fps and a 16K frame at 191 fps, that is, 75 and 76 GB/s against 71 GB/s on an 8K frame. With 4:2:0 subsampling it is 102 and 104 GB/s. That is 2.9–4.1 times the PCIe bandwidth. The Fastvideo encoder is 35 % faster than the nvJPEG encoder on a 12K frame and 39 % faster on 16K; on 8K the difference was 32 %.

Decoding. The Fastvideo decoder processes a 12K frame at 221 fps and a 16K frame at 118 fps, the nvJPEG decoder at 6.05 and 3.43 fps: the Fastvideo decoder is 37 times faster on a 12K frame and 34 times faster on 16K. For the Fastvideo decoder this is 49 and 47 GB/s against 51 GB/s on an 8K frame. The nvJPEG decoder spends 2.02 ms per megapixel on an 8K frame, and 2.21 and 2.20 ms on 12K and 16K.

Chroma subsampling 4:2:0. As in section 4.1, this adds to the main measurements: the same frames are compressed with 4:2:0 subsampling, and 4:4:4 is measured in the same series, alternating with it. With subsampling both encoders compress faster: the Fastvideo encoder by 36 and 37 %, the nvJPEG encoder by 45 and 49 %. The Fastvideo decoder speeds up by 33 and 40 %, as on an 8K frame and not as on 2K and 4K; the nvJPEG decoder by 65 % on both frames.

12K and 16K frames with 4:4:4 and 4:2:0 subsamplingOne thread, q = 90, separate series of measurements
4:4:4,
fps
4:2:0,
fps
Change
Fastvideo, encoding 12K335457+ 36 %
Fastvideo, encoding 16K191261+ 37 %
nvJPEG, encoding 12K248360+ 45 %
nvJPEG, encoding 16K137204+ 49 %
Fastvideo, decoding 12K221295+ 33 %
Fastvideo, decoding 16K118165+ 40 %
nvJPEG, decoding 12K6.0510.0+ 65 %
nvJPEG, decoding 16K3.435.67+ 65 %

Aerial imaging. Frames from aerial cameras are of the same order: 100 MPix and more (up to 254 MPix today). If the Fastvideo encoder compresses them after RAW-to-RGB conversion, the markers are already there, and the files need no special preparation. A 16K frame is 133 MPix: the Fastvideo encoder compresses it in 5.24 ms, the Fastvideo decoder processes it in 8.47 ms, and the nvJPEG decoder needs 292 ms for the same frame. We will cover JPEG in aerial imaging, with frames from real cameras, in a separate article.

What follows. On large frames the Fastvideo codec is faster at both encoding and decoding: on a 16K frame the encoder is 39 % faster and the decoder 34 times faster. The Fastvideo codec reaches its full performance already on an 8K frame, so there is no point in processing several large frames at the same time.

6. Where the nvJPEG decoder loses time

Chart: share of each stage in the total frame time of the nvJPEG decoder; stream parsing and entropy decoding on the CPU take 92 percent on a 2K frame, 93 percent on 4K and 91 percent on 8K
The hatched stage runs on the CPU. The GPU itself accounts for 0.7 to 1.9 % of the frame time.

The nvJPEG library splits decoding into three calls: the first runs on the CPU, the second transfers data to the GPU, the third runs on the GPU. Our harness for nvJPEG times each call separately and waits for the GPU to finish between calls, so it shows how the frame time splits between the stages. Stream parsing and entropy decoding run on the CPU, sequentially: they take 92 % of the time on a 2K frame, 93 % on 4K and 91 % on 8K. The GPU accounts for 0.7 to 1.9 %, so it is idle almost all of this time.

This is the cost of having no markers. There is nothing to split the compressed data by, so there is nothing to parallelize, and nvJPEG runs entropy decoding on the CPU, sequentially.

The nvJPEG decoder works like this. First the CPU parses the compressed data and runs entropy decoding. Then it transfers the result to the GPU. Everything else runs on the GPU: inverse quantization, the inverse discrete cosine transform and the conversion from YCbCr to RGB.

The profiler confirms this from the other side: the nvJPEG decoder runs only two kernels on the GPU, one for inverse quantization together with the inverse cosine transform, the other for the inverse color transform, and not a single entropy decoding kernel. Section 7 has the details.

Share of each stage in the total frame time of the nvJPEG decoderTime of each of the three nvJPEG decoder calls, measured by our harness, one thread, quality 90, 4:4:4
Runs on2K frame4K frame8K frame
stream parsing and entropy decodingCPU91.9 %93.3 %91.4 %
data transfer from the CPU to the GPUPCIe7.4 %5.8 %6.7 %
inverse quantization, inverse cosine transform, inverse color transformGPU0.7 %0.9 %1.9 %

6.1. nvJPEG batched mode: when entropy decoding moves to the GPU

Chart: nvJPEG decoding speed vs the number of frames in a batch, with a sharp rise between 32 and 64 frames
Batches of one to 128 frames, 2K frame, quality 90, 4:4:4. Up to 32 frames per batch the speed stays below 160 fps; between 32 and 64 it grows 2.7 times.

The nvJPEG library has its own way around this problem, batched mode: the decoder gets many frames in one call (the function nvjpegDecodeBatched). Only decoding has this mode; the encoder nvjpegEncodeImage always processes one frame per call.

With 50 frames per batch or fewer, entropy decoding still runs on the CPU, and the batch gives almost nothing: a single frame decodes at 138 fps (a separate measurement through the batch function; the plain call in section 4 gives 191 fps), a batch of 32 frames at 155 fps. With more than 50 frames per batch, nvJPEG moves entropy decoding to the GPU. Inside one frame there is still nothing to split the stream by, but the frames of a batch are independent of each other, and the GPU decodes them at the same time, each on its own cores. The speed jumps: 422 fps with a batch of 64 frames and 742 fps with 128 frames.

The number 50 is not our estimate: it is stated in the library documentation, in its header file nvjpeg.h, and the test results agree: the jump in speed falls exactly between 32 and 64 frames.

That entropy decoding moves to the GPU here is not a guess: with a batch of 128 frames the profiler trace shows the kernel decodeDcHuffman, which is absent with a batch of 32, and it takes 95 % of all kernel time (section 7).

This is the best result nvJPEG shows at decoding, and it is still far below the 1862 fps of the Fastvideo decoder on a single image. Batched mode also costs latency: 128 frames have to be collected first. So batched mode suits tasks that need the highest speed and do not care about latency. The main such use is loading JPEG images for neural network training: this is what NVIDIA DALI is built for, a library that prepares training data and decodes JPEG through nvJPEG. Another example is processing ready archives and large image sets, where the frames are already on disk.

nvJPEG decoding in batched mode2K frame, quality 90, 4:4:4
Frames
per batch
13264128
Frames per second138155422742
Where entropy decoding runsCPUCPUGPUGPU

7. What the GPU actually does: Nsight Systems profile

All the measurements above were taken with the system clock. The clock tells how long the whole job took, but not what the GPU was busy with during that time. The profiler shows this: it records every kernel launch and every copy with nanosecond precision. The measurements below were taken with Nsight Systems on the same test system, on a 2K frame, with each codec at its best settings; neither codec was changed for this.

There are three quantities. Kernel time per frame: how long the GPU actually computed, without copying and without waiting. Compute share: the share of time when at least one kernel was running on the GPU. Idle share: the share of time when the GPU did nothing at all, neither computing nor copying.

GPU work at decoding2K frame, quality 90, 4:4:4, each codec at its best settings
Kernel time
per frame, ms
Compute
share
Idle share
Fastvideo JPEG, 32 threads0.43359 %6.6 %
nvJPEG, 8 threads with 2 images each0.0273.1 %2.5 %

In GPU compute time the difference is 16 times. This is not speed but the amount of work each codec gives the GPU. The Fastvideo decoder runs the whole algorithm on the GPU, entropy decoding included; nvJPEG runs only inverse quantization, the inverse cosine transform and the inverse color transform there.

nvJPEG has almost no idle time, 2.5 %. The GPU is not standing still: nearly all the remaining time it is copying. While one thread waits for the CPU, another transfers data to the GPU or fetches a finished image. The GPU computes 3 % of the time.

Kernel names show what the GPU computes. The profiler records the name of every kernel, and here the names speak for themselves.

Kernels that take most of the time2K frame, quality 90, 4:4:4
Kernels and their share of kernel time
Fastvideo, decodingHuffmanDecodeKernel 71 %, RleDecodeKernel 12 %, InverseDCTColorKernel 5.1 %
nvJPEG, decodingdctQuantInvJpegKernelMultiChannel 74 %, ycbcr_to_format_kernel_roi 26 %, and nothing else
Fastvideo, encodingRleBalancedKernel 30 %, DCT444Kernel 19 %, applyImageProcessingColor_8 17 %, HuffmanAndStuffingKernel 17 %
nvJPEG, encodingACKernel 37 %, format_to_ycbcr_kernel 15 %, forwardDct32x8Kernel 13 %, DCKernel 10 %

The nvJPEG decoder has two kernels in the list, and both belong to what comes after entropy decoding. There is no entropy decoding in the profiler trace because it does not happen on the GPU. The very first kernel of the Fastvideo decoder is HuffmanDecodeKernel, and it takes almost three quarters of the compute time.

The encoders look different, and this confirms what section 1 says. At encoding nvJPEG runs ACKernel and DCKernel, which code the AC and DC coefficients, that is, the entropy stage itself. It runs on the GPU and needs no markers: at encoding block boundaries are known in advance. The Fastvideo encoder, like its decoder, runs the entropy stage on the GPU: the kernels RleBalancedKernel and HuffmanAndStuffingKernel do run-length coding and Huffman coding, and they take almost half of the kernel time.

7.1. nvJPEG batched mode under the profiler

Section 6.1 shows that the speed jumps between a batch of 32 frames and a batch of 128. The profiler shows what the jump consists of.

nvJPEG batched mode under the profiler2K frame, quality 90, 4:4:4
Batch of 32 framesBatch of 128 frames
Kernel time per frame, ms0.1221.08
Compute share2.0 %79 %
Idle share76 %1.4 %
Entropy decoding kernelnonedecodeDcHuffman,
95 % of kernel time

With a batch of 32 frames the GPU is idle three quarters of the time: it waits for the CPU to parse the compressed data. With a batch of 128 frames entropy decoding has moved to the GPU, there is almost no idle time, and kernel time per frame has grown almost nine times. The speedup comes not from the GPU computing faster but from the GPU getting work that can be split between its cores. With markers the cores share one frame; in batched mode they share 128 different frames.

What these measurements do not show. The profiler sees only the GPU: it does not show how much time the CPU spends and on what. In multithreaded mode the kernels of different threads run at the same time, so kernel time must not be summed with the frame time from sections 3 and 4: they are different quantities.

8. Speed with copying to the GPU and back

Chart: highest JPEG encoding and decoding speed on an RTX 4090 in multithreaded mode with copying to the GPU and back, Fastvideo JPEG vs nvJPEG on 2K, 4K and 8K frames
The highest speed each codec gives on an RTX 4090: best settings, with copying to the GPU and back. Encoding speed is limited by the PCIe bandwidth, so on 2K the codecs are level and on 4K and 8K nvJPEG is faster; at decoding the difference remains.

The second measurement: the image is in host memory, is copied to GPU memory, processed and copied back. The uncompressed image goes over PCIe in full; the compressed one too, but it is several times smaller. The bus bandwidth of this test system is 25.5 GB/s, as measured by the test applications themselves. Each codec runs at the best of three settings, from 8 to 32 threads.

Why the highest speed is measured only with copying. In multithreaded mode JpegSample measures the whole processing time, with copying to GPU memory and back, and does not report the time of the codec itself. That is why the article has no multithreaded comparison without copying: it can be measured for nvJPEG but not for Fastvideo JPEG, and such a comparison would not be on equal terms.

At encoding with copying, both codecs are limited by the bus. On 2K and 4K frames they use 83–93 % of its bandwidth, and the difference between them is how fully each one loads the bus, not computing speed: on 2K the codecs are level, on 4K nvJPEG is 12 % faster because it uses 93 % of the bandwidth against 83 % for Fastvideo. No codec can work faster than data is copied over PCIe.

On an 8K frame the nvJPEG encoder is 22 % faster: 235 fps against 192. It uses 92 % of the bus bandwidth, Fastvideo 75 %. The best settings of Fastvideo on 8K are 8 threads with two frames each, and they do not load the bus fully; with more threads the speed on a frame of this size no longer grows.

At decoding, the bus bandwidth limits only Fastvideo. It uses 87–89 % of the bandwidth on 2K and 4K frames and 75 % on 8K; nvJPEG uses about a quarter. nvJPEG is limited by the work on the CPU, not by the bus, so the difference between the codecs shows in this measurement too.

Why the difference here is 3 times, and in sections 4 and 5 tens of times. There the codecs work in one thread and without copying: on an 8K frame the Fastvideo decoder processes 515 fps, the nvJPEG decoder 14.9 fps, 35 times less. Here both sides change. The Fastvideo decoder hits the bus: 193 fps, 75 % of its bandwidth. The nvJPEG decoder in eight threads runs entropy decoding of several frames at once on different CPU cores, with about six cores busy, and gives 65 fps instead of 14.9. The 35-times difference is the speed of the decoders themselves; the 3-times difference is the speed of the whole processing with copying over the bus on this PC.

Speed with copying to the GPU and backEach codec at its best settings, quality 90, 4:4:4; share of the bus bandwidth in brackets
Fastvideo,
fps
nvJPEG,
fps
Fastvideo,
GB/s (share)
nvJPEG,
GB/s (share)
Encoding 2K3497353221.8 (85 %)22.0 (86 %)
Encoding 4K84895121.1 (83 %)23.7 (93 %)
Encoding 8K19223519.1 (75 %)23.4 (92 %)
Decoding 2K3632116122.6 (89 %)7.2 (28 %)
Decoding 4K89526822.3 (87 %)6.7 (26 %)
Decoding 8K1936519.2 (75 %)6.5 (25 %)

Gigabytes per second in this table are uncompressed data per second: frames per second times the number of pixels times three bytes. The brackets give the share of the bus bandwidth the codec uses, computed from the measured 25.5 GB/s.

9. GPU energy per frame

Chart: GPU energy per frame at JPEG encoding on an RTX 4090, in joules, Fastvideo JPEG vs nvJPEG; Fastvideo uses 1.1 to 1.3 times less
Joules per frame at encoding from the GPU counter, quality 90, 4:4:4, best settings, with copying. Only the energy of the GPU is counted; this counter does not see the energy of the CPU.

Energy was measured under the same conditions as the speed in section 8: with copying to the GPU and back, and with each codec at its best settings. It was measured with the counter of the GPU itself. The counter covers all the energy the card draws: for computing, copying, memory and its own idle power. The application is run twice, on N and on 2N frames, and the energy per frame is the difference between the two counter readings divided by N: this removes the start-up cost of the application, which does not depend on the number of frames. Idle power stays in the result: the card draws it all the time processing runs, including while it waits for the CPU. At idle this card draws 45 to 76 W (in different measurements), with a limit of 450 W. A check by another method, the average power of the card times the frame time, gave the same results within 9 %.

The codecs are compared on energy only at encoding: for both Fastvideo and nvJPEG it runs entirely on the GPU, and the counter sees all the work. To encode one frame, the GPU with the Fastvideo codec uses 1.1–1.3 times less energy, even though with copying the encoding speeds are close, and on 4K and 8K nvJPEG is even faster: speed is limited by the bus bandwidth (section 8).

Why the nvJPEG decoder has a dash. This decoder spends most of the frame time on the CPU, parsing the compressed stream and running entropy decoding (section 6), while the GPU waits. For it the GPU counter shows mostly what the card draws while waiting for the CPU (92–96 W on average), not the work of the decoder, and it does not see the energy of the CPU at all. Such a result cannot be compared with that of the Fastvideo decoder, so the table has a dash. The Fastvideo decoder runs entirely on the GPU, entropy decoding included, because markers split the stream into segments. That is why its energy per frame is in the table.

GPU energy per frameFrom the GPU counter, best settings, with copying, quality 90, 4:4:4
Fastvideo,
J
nvJPEG,
J
Difference
Encoding 2K0.0440.0551.3x
Encoding 4K0.170.191.1x
Encoding 8K0.720.781.1x
Decoding 2K0.056——
Decoding 4K0.17——
Decoding 8K0.71——

10. What this means in practice

The measurements lead to a few rules, and all of them say the same thing: the decision is made at encoding, and the cost or the gain comes at decoding.

An encoder is not chosen by compression speed alone. In one thread the difference in encoding speed is 30–39 %, and the difference in decoding what this encoder compressed is 9.7 times on a 2K frame, 28 times on 4K and 35 times on 8K. An image is compressed once and decoded every time it is accessed.

Restart markers cost 2.1–2.9 % of file size. The time the encoder spends inserting them is already part of its speed, and the Fastvideo encoder is still faster than nvJPEG. They do not break compatibility: markers are part of the standard, and a program that cannot use them reads such a file as an ordinary one.

If frames come in batches and latency does not matter, nvJPEG has batched mode: from 64 frames per batch it runs entropy decoding on the GPU, and the speed rises to 742 fps.

If the task is to take an image from host memory, compress it and return it, the speed depends on the PCIe bandwidth, not on the codec: when compressing 2K and 4K frames both codecs use 83–93 % of the bus bandwidth. The encoder itself has a large margin: on an 8K frame, q = 90, 4:2:0, the Fastvideo encoder processes 96 GB/s, 3.8 times the bus bandwidth. The speed of the codec pays off where an image enters GPU memory once and goes through many processing stages, whose times add up.

10.1. Which images the Fastvideo decoder decodes fast

The high decoding speed shown in this article is possible only on images with restart markers. There are two kinds of such images:

The very highest speed needs specially prepared images. With a marker after every MCU the Fastvideo decoder is faster still: 3296 fps on a 2K frame instead of 1864, 2035 fps on 4K instead of 1652 and 650 fps on 8K instead of 527 (section 1.1). The Fastvideo SDK manual calls a restart interval of 1 optimal for the decoder. The Fastvideo encoder does not make such files: its restart interval is 10 MCUs, not 1. Such files are prepared in advance with another program, for example jpegtran, at a cost in size: the file grows by 21–29 % compared with no markers.

Images without markers cannot be decoded this fast. Without restart markers the Fastvideo decoder runs entropy decoding on the CPU. nvJPEG does not insert markers either, and libjpeg-turbo inserts them only with a separate option, so many JPEG files that come from outside have none. Such images can only be decoded sequentially, and the Fastvideo decoder has no advantage on them (section 1.1). This is not a property of a particular library but of the compressed image: without markers there is no fast GPU decoding for it.

This gives two practical cases. If your own system compresses the images, it is enough to compress them with an encoder that inserts markers. If the images come from outside but the same file is decoded many times, in neural network training, when browsing an archive, in repeated processing, it makes sense to insert markers into it once, in advance. The insertion itself runs on the CPU, and its time cost was not measured here. If each outside file is decoded only once, there is no reason to insert markers in advance.

11. Conclusion

On an RTX 4090 in one thread the Fastvideo JPEG encoder compresses 2K, 4K and 8K images 30–39 % faster than the nvJPEG library. This is a noticeable difference, but not the main one. The main one is that it also inserts restart markers into the stream, which nvJPEG never does, and pays 2.1–2.9 % of file size for them.

At decoding the difference between the codecs is much larger: the Fastvideo decoder is 9.7 times faster than the nvJPEG decoder on a 2K frame, 28 times faster on 4K and 35 times faster on 8K (each decodes files from its own encoder, in one thread). The reason is restart markers. They split the compressed data into segments, and the GPU decodes them at the same time. Files from the Fastvideo encoder have markers, files from nvJPEG do not. The nvJPEG decoder runs entropy decoding on the CPU even when the file has markers; entropy decoding takes 91–93 % of its frame time. Even in batched mode, where nvJPEG runs entropy decoding on the GPU, it processes a 2K frame at best at 742 fps, 2.5 times slower than the Fastvideo decoder (1862 fps).

Large frames. On 12K and 16K frames the Fastvideo encoder is 35 and 39 % faster than the nvJPEG encoder, and the Fastvideo decoder is 37 times faster than the nvJPEG decoder on a 12K frame and 34 times faster on 16K (section 5). The Fastvideo codec reaches its full performance already on an 8K frame, so there is no point in processing several large frames at the same time.

With 4:2:0 subsampling the Fastvideo decoder is also faster than the nvJPEG decoder: 4.9 times on a 2K frame, 15 times on 4K and 29 times on 8K (section 4.1). In multithreaded mode with copying to the GPU and back the Fastvideo decoder is 3.0–3.3 times faster. The encoders in this mode are nearly level on a 2K frame, and on 4K and 8K the nvJPEG encoder is faster, by 12 and 22 % (section 8). At encoding the GPU with the Fastvideo codec uses 1.1–1.3 times less energy per frame. The decoders were not compared on energy: nvJPEG does most of its work on the CPU, and the GPU counter does not see the energy of the CPU.

What this means for choosing a codec. Compression speed alone is not enough: it also matters how many times the image will be decoded later. Decoding speed is decided at compression. If an image has restart markers, it can be decoded on the GPU in parallel and fast; if it has none, decoding will be sequential, whatever the decoder.

12. What these measurements do not cover

13. Code, data and further reading

Everything needed to reproduce the measurements is on GitHub: github.com/fastvideo/jpeg-benchmark. It has the test scripts, the source code of our harness for nvJPEG, the summaries and logs of all measurements of September 25 and 29, 2026, and a description of how to reproduce them on your own PC. JpegSample is not in the repository: it is part of the Fastvideo SDK.

Both implementations are available: the Fastvideo JPEG codec is part of the Fastvideo SDK together with JpegSample, and the nvJPEG library is part of the CUDA Toolkit, with the NVIDIA samples next to it. To check the speed on your own images, request the Fastvideo SDK, and we will send a build for Windows, Linux or ARM.

Rights to this material

The text of the article is licensed under CC BY-ND 4.0: you may republish it in full and quote it, including in commercial publications, with a link to the source; translations and adaptations need our written permission, which you can ask for through the form at the bottom of the page.

The measurement results and tables are licensed under CC BY 4.0: you may use them in your own materials, rearrange them and compute from them. If you change anything, say what.

Source reference in both cases: Fastvideo, https://www.fastcompression.com/blog/fastvideo-jpeg-vs-nvjpeg.htm, measurements of 2026-09-25 and 2026-09-29. Please give the test conditions next to the results: without them a result cannot be reproduced.

Neither license covers the images.

Fyodor Serzhenko, Fastvideo

About the author

Fyodor Serzhenko, PhD, is the founder and CEO of Fastvideo. He earned his PhD at the Moscow Institute of Physics and Technology (MIPT) in 1993. Since 2009 he has led the development of Fastvideo’s GPU-accelerated image codecs and ISP modules, including the Fastvideo SDK. Connect on LinkedIn.

Why you can trust these results

Fastvideo has built GPU-accelerated image processing software since 2009. Our codecs comply with the standards they implement — JPEG (ITU-T T.81 / ISO IEC 10918) and JPEG2000 (ITU-T T.800 / ISO IEC 15444) — and our tools are open source on GitHub. Every performance figure we publish is reproducible: see our benchmark methodology, download the Fastvideo SDK benchmark report (PDF), and measure it on your own GPU.

You Might Also Like

JPEG2000 codec test: Fastvideo JPEG2000 vs NVIDIA nvJPEG2000 on RTX 4090 Fastvideo JPEG2000 vs nvJPEG2000 on RTX 4090 Fastvideo SDK vs NVIDIA NPP for camera applications Fastvideo SDK vs NVIDIA NPP for camera applications Review of JPEG optimization techniques JPEG optimization techniques review

Contact Form

This form collects your name and email. See our Privacy Policy for how we handle your personal data.