Motion-JPEG video decoder: wraps JPEGDecoder (https://github.com/Bodmer/JPEGDecoder) as a VideoDecoder, so it can be plugged directly into e.g. DemuxerAVI::setOutputVideo()/ DemuxerMP4::setOutputVideo() - the same role H264Decoder (CodecH264.h) and MPGDecoder (CodecMPG.h) play for their own codecs. Named "MJPEGDecoder" rather than reusing JPEGDecoder's own name to avoid shadowing that (global-namespace) class from within this one.
More...
#include <CodecJPEG.h>
Motion-JPEG video decoder: wraps JPEGDecoder (https://github.com/Bodmer/JPEGDecoder) as a VideoDecoder, so it can be plugged directly into e.g. DemuxerAVI::setOutputVideo()/ DemuxerMP4::setOutputVideo() - the same role H264Decoder (CodecH264.h) and MPGDecoder (CodecMPG.h) play for their own codecs. Named "MJPEGDecoder" rather than reusing JPEGDecoder's own name to avoid shadowing that (global-namespace) class from within this one.
write()/flush() implement the VideoOutput contract (see Video.h), but unlike H264Decoder/MPGDecoder - which decode incrementally as Annex-B/ PES bytes arrive, with no separate "frame complete" signal needed - a bare JPEG byte stream has no equivalent self-framing a demuxer can use to decode early. write() therefore just accumulates one JPEG image's bytes, and flush() (called by e.g. DemuxerAVI/DemuxerMP4 at each frame boundary) decodes the assembled image directly into a full-frame RGB565 buffer and writes it to the target configured via setOutput(), one write() call per decoded picture - same convention as H264Decoder/ MPGDecoder, so any VideoOutput (OutputTFT_eSPI, OutputTinyGPU, OutputOpenCV, ...) works unchanged regardless of which codec produced the picture.
- Author
- Phil Schatzmann
- Copyright
- GPLv3
◆ MJPEGDecoder() [1/3]
◆ MJPEGDecoder() [2/3]
◆ MJPEGDecoder() [3/3]
◆ begin()
Initializes the decoder (allocates its picture buffers, etc).
Implements VideoDecoder.
◆ decodeToFrameBuffer()
| void decodeToFrameBuffer |
( |
| ) |
|
|
inlineprotected |
Reads every MCU block JPEGDecoder produces for the image just handed to decodeArray() and copies it into frame_buffer, row by row (source rows are MCUWidth pixels wide even for a right/bottom edge block narrower/shorter than that - only its top-left corner holds valid pixels - so a straight linear copy would misalign those edge blocks).
◆ end()
◆ flush()
Decodes the assembled JPEG image and writes the resulting RGB565 frame to setOutput()'s target, then resets for the next frame - a no-op if write() hasn't accumulated anything since the last call.
Reimplemented from VideoOutput.
◆ setOutput() [1/2]
| void setOutput |
( |
Print & |
out | ) |
|
|
inlinevirtual |
Defines the target the decoded picture is written to, one write() call per decoded picture (RGB565 - the only format JPEGDecoder produces).
Implements VideoDecoder.
◆ setOutput() [2/2]
◆ setVideoFormat()
JPEGDecoder only ever produces RGB565 - any other value is logged and ignored.
Implements VideoDecoder.
◆ videoInfo()
Reports the dimensions of the most recently decoded picture - 0 before any picture has been decoded.
Implements VideoDecoder.
◆ write()
| size_t write |
( |
const uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineoverridevirtual |
Accumulates one JPEG image's bytes - may be called more than once per frame (e.g. from a demuxer that hands over payload in pieces). Decoding happens on flush(), not here.
Implements VideoOutput.
◆ writeToOutput()
| size_t writeToOutput |
( |
const uint8_t * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineprotected |
◆ frame_buffer
◆ height_
◆ img_vector
◆ jpeg_decoder
◆ p_out
◆ p_out_video
◆ pos
◆ start_ms
◆ width_
The documentation for this class was generated from the following file: