# JPEG Hardware Decode

**URL:** <https://forums.openmv.io/t/jpeg-hardware-decode/8811>\
**Category:** OpenMV Boards\
**Created:** [October 10, 2023, 6:54am UTC](https://forums.openmv.io/t/jpeg-hardware-decode/8811 "2023-10-10T06:54:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![yokonav](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yokonav](https://forums.openmv.io/u/yokonav)\
**Post date:** [October 10, 2023, 6:54am UTC](https://forums.openmv.io/t/jpeg-hardware-decode/8811/1 "2023-10-10T06:54:47Z")

</div>

I wanted to use JPEG hardware decoder on H7. It seems the support is there but is not enabled in the code:

> <https://github.com/openmv/openmv/blob/master/src/omv/imlib/jpegd.c#L57>

Also, it is not using DMA (HAL\_JPEG\_Decode\_DMA) that would be way much faster.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 10, 2023, 5:32pm UTC](https://forums.openmv.io/t/jpeg-hardware-decode/8811/2 "2023-10-10T17:32:11Z")

</div>

> <https://github.com/openmv/openmv/pull/1604>
>
> Per @kdarras asking us to fix jpeg support constantly I got on this and finished… the implementation of the hardware jpeg decoder using Ibrahim's code. All modes work. It can decode grayscale jpegs to binary/grayscale/rgb565. It can decode color 444/420/422 jpegs to binary/grayscale/rgb565. It uses DMA2D when it can. And it handles jpegs that aren't a multiple of 8x8, 16x8, 16x16 depending on the MCU size.
> 
> JPEG support issues should be closed now.

Need to get this updated per the PR comments and merged into the main code base. However, it’s not a priority right now.

---

<div class="post-metadata">

**Author:** ![yokonav](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yokonav](https://forums.openmv.io/u/yokonav)\
**Post date:** [October 16, 2023, 3:00pm UTC](https://forums.openmv.io/t/jpeg-hardware-decode/8811/3 "2023-10-16T15:00:02Z")

</div>

I can understand this is not on the priority list currently. I would like to know if it would work by enabling and building it locally, or if further steps are needed.

```auto
...
#if (OMV_HARDWARE_JPEG == 1)
/* Hardware JPEG decoder */
#include STM32_HAL_H
...

```

Also, how do you call the decoder function using an image object?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [October 16, 2023, 6:38pm UTC](https://forums.openmv.io/t/jpeg-hardware-decode/8811/4 "2023-10-16T18:38:17Z")

</div>

The PR I linked to works if you fix the merge errors with it.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [January 12, 2024, 8:56pm UTC](https://forums.openmv.io/t/jpeg-hardware-decode/8811/5 "2024-01-12T20:56:13Z")

</div>

@yokonav JPEG hardware decoding for the STM32 has been merged into main. You can download the latest development firmware release to run it.

We will extend the MJPEG class to support reading MJPEG files too for demoing video playback.

---

<div class="post-metadata">

**Author:** ![yokonav](https://avatars.discourse-cdn.com/v4/letter/y/87869e/32.png) [@yokonav](https://forums.openmv.io/u/yokonav)\
**Post date:** [January 16, 2024, 1:40am UTC](https://forums.openmv.io/t/jpeg-hardware-decode/8811/6 "2024-01-16T01:40:24Z")

</div>

Thanks @kwagyeman, will try out soon!

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [January 16, 2024, 1:51am UTC](https://forums.openmv.io/t/jpeg-hardware-decode/8811/7 "2024-01-16T01:51:19Z")

</div>

[Fun with AVI Files - OpenMV Products - OpenMV Forums](https://forums.openmv.io/t/fun-with-avi-files/9105)
