54 const uint8_t *buf_ptr,
int buf_size)
66 const uint8_t *buf_ptr,
int buf_size)
68 unsigned bitmask_size, mb_count;
75 bitmask_size = (mb_count + 7) >> 3;
76 if (bitmask_size > buf_size - 12) {
78 "MXM bitmask is not complete\n");
88 "MXM bitmask memory allocation error\n");
96 "Completion bitmask memory allocation error\n");
103 memcpy(s->
mxm_bitmask, buf_ptr + 12, bitmask_size);
107 uint8_t completion_check = 0xFF;
108 for (i = 0; i < bitmask_size; ++i) {
119 const uint8_t *buf_ptr,
int buf_size)
125 if (len > 14 && len <= buf_size && !strncmp(buf_ptr + 2,
"MXM", 3)) {
139 "Picture dimensions stored in SOF and MXM mismatch\n");
143 if (reference_ptr->
data[0]) {
149 "Dimensions of current and reference picture mismatch\n");
159 void *
data,
int *got_frame,
163 int buf_size = avpkt->
size;
166 const uint8_t *buf_end, *buf_ptr;
167 const uint8_t *unescaped_buf_ptr;
168 int unescaped_buf_size;
173 buf_end = buf + buf_size;
176 while (buf_ptr < buf_end) {
178 &unescaped_buf_ptr, &unescaped_buf_size);
184 if (start_code >=
APP0 && start_code <=
APP15) {
188 switch (start_code) {
199 "quantization table decode error\n");
207 "huffman table decode error\n");
222 "SOF data decode error\n");
227 "Interlaced mode not supported in MxPEG\n");
235 "Can not process SOS without SOF data, skipping\n");
241 "First picture has no SOF, skipping\n");
246 "Non-key frame has no MXM, skipping\n");
268 if (!reference_ptr->
data[0] &&
308 return buf_ptr -
buf;
320 for (i = 0; i < 2; ++i)
uint8_t * completion_bitmask
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_cold int init(AVCodecContext *avctx)
int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static int mxpeg_check_dimensions(MXpegDecodeContext *s, MJpegDecodeContext *jpg, AVFrame *reference_ptr)
int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
MJPEG encoder and decoder.
static int mxpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * name
Name of the codec implementation.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static int get_bits_count(const GetBitContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int mxpeg_decode_mxm(MXpegDecodeContext *s, const uint8_t *buf_ptr, int buf_size)
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
enum AVPictureType pict_type
Picture type of the frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static av_cold int mxpeg_decode_init(AVCodecContext *avctx)
main external API structure.
static void close(AVCodecParserContext *s)
#define AV_EF_EXPLODE
abort decoding on minor error detection
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static void skip_bits(GetBitContext *s, int n)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static const uint8_t start_code[]
static int mxpeg_decode_com(MXpegDecodeContext *s, const uint8_t *buf_ptr, int buf_size)
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, const AVFrame *reference)
common internal api header.
static av_cold int mxpeg_decode_end(AVCodecContext *avctx)
static int mxpeg_decode_app(MXpegDecodeContext *s, const uint8_t *buf_ptr, int buf_size)
int got_picture
we found a SOF and picture is valid, too.
int key_frame
1 -> keyframe, 0-> not
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int ff_mjpeg_find_marker(MJpegDecodeContext *s, const uint8_t **buf_ptr, const uint8_t *buf_end, const uint8_t **unescaped_buf_ptr, int *unescaped_buf_size)
This structure stores compressed data.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...