55 for (
i = 0;
i < 2; ++
i)
75 if (!
s->picture[0] || !
s->picture[1])
78 s->jpg.picture_ptr =
s->picture[0];
83 const uint8_t *buf_ptr,
int buf_size)
95 const uint8_t *buf_ptr,
int buf_size)
97 unsigned bitmask_size, mb_count;
102 mb_count =
s->mb_width *
s->mb_height;
104 bitmask_size = (mb_count + 7) >> 3;
105 if (bitmask_size > buf_size - 12) {
107 "MXM bitmask is not complete\n");
111 if (
s->bitmask_size != bitmask_size) {
115 if (!
s->mxm_bitmask) {
117 "MXM bitmask memory allocation error\n");
123 if (!
s->completion_bitmask) {
125 "Completion bitmask memory allocation error\n");
129 s->bitmask_size = bitmask_size;
132 memcpy(
s->mxm_bitmask, buf_ptr + 12, bitmask_size);
133 s->got_mxm_bitmask = 1;
135 if (!
s->has_complete_frame) {
136 uint8_t completion_check = 0xFF;
137 for (
i = 0;
i < bitmask_size; ++
i) {
138 s->completion_bitmask[
i] |=
s->mxm_bitmask[
i];
139 completion_check &=
s->completion_bitmask[
i];
141 s->has_complete_frame = !(completion_check ^ 0xFF);
148 const uint8_t *buf_ptr,
int buf_size)
154 if (
len > 14 &&
len <= buf_size && !strncmp(buf_ptr + 2,
"MXM", 3)) {
165 if ((jpg->
width + 0x0F)>>4 !=
s->mb_width ||
166 (jpg->
height + 0x0F)>>4 !=
s->mb_height) {
168 "Picture dimensions stored in SOF and MXM mismatch\n");
172 if (reference_ptr->
data[0]) {
178 "Dimensions of current and reference picture mismatch\n");
196 const uint8_t *buf = avpkt->
data;
197 int buf_size = avpkt->
size;
200 const uint8_t *buf_end, *buf_ptr;
208 buf_end = buf + buf_size;
210 s->got_mxm_bitmask = 0;
211 s->got_sof_data = !!
s->got_sof_data;
212 while (buf_ptr < buf_end) {
217 int bytes_left = buf_end - buf_ptr;
235 "quantization table decode error\n");
243 "huffman table decode error\n");
253 if (
s->got_sof_data > 1) {
255 "Multiple SOF in a frame\n");
261 "SOF data decode error\n");
267 "Interlaced mode not supported in MxPEG\n");
274 if (!
s->got_sof_data) {
276 "Can not process SOS without SOF data, skipping\n");
282 "First picture has no SOF, skipping\n");
285 if (!
s->got_mxm_bitmask){
287 "Non-key frame has no MXM, skipping\n");
303 if (
s->got_mxm_bitmask) {
304 AVFrame *reference_ptr =
s->picture[
s->picture_index ^ 1];
309 if (!reference_ptr->
data[0] &&
341 s->picture_index ^= 1;
344 if (!
s->has_complete_frame) {
345 if (!
s->got_mxm_bitmask)
346 s->has_complete_frame = 1;
352 return buf_ptr - buf;
const FFCodec ff_mxpeg_decoder
static av_cold void close(AVCodecParserContext *s)
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline int bytestream2_tell(const GetByteContext *g)
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define EOI
End Of Image marker.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_EF_EXPLODE
abort decoding on minor error detection
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
@ AVDISCARD_ALL
discard all
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
Memory handling functions.
MJPEG encoder and decoder.
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
int ff_mjpeg_decode_sos(MJpegDecodeContext *s)
int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
int ff_mjpeg_find_marker(const uint8_t **pbuf_ptr, const uint8_t *buf_end)
int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
static av_cold int mxpeg_decode_init(AVCodecContext *avctx)
static int mxpeg_check_dimensions(MXpegDecodeContext *s, MJpegDecodeContext *jpg, AVFrame *reference_ptr)
static int mxpeg_decode_com(MXpegDecodeContext *s, const uint8_t *buf_ptr, int buf_size)
static int mxpeg_decode_frame(AVCodecContext *avctx, AVFrame *rframe, int *got_frame, AVPacket *avpkt)
static int mxpeg_decode_mxm(MXpegDecodeContext *s, const uint8_t *buf_ptr, int buf_size)
static int mxpeg_decode_app(MXpegDecodeContext *s, const uint8_t *buf_ptr, int buf_size)
static av_cold int mxpeg_decode_end(AVCodecContext *avctx)
main external API structure.
int flags
AV_CODEC_FLAG_*.
enum AVDiscard skip_frame
Skip decoding for selected frames.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
const AVFrame * reference
const uint8_t * mb_bitmask
int got_picture
we found a SOF and picture is valid, too.
uint8_t * completion_bitmask