Go to the documentation of this file.
56 for (
i = 0;
i < 2; ++
i)
72 if (!
s->picture[0] || !
s->picture[1])
75 s->jpg.picture_ptr =
s->picture[0];
80 const uint8_t *buf_ptr,
int buf_size)
92 const uint8_t *buf_ptr,
int buf_size)
94 unsigned bitmask_size, mb_count;
99 mb_count =
s->mb_width *
s->mb_height;
101 bitmask_size = (mb_count + 7) >> 3;
102 if (bitmask_size > buf_size - 12) {
104 "MXM bitmask is not complete\n");
108 if (
s->bitmask_size != bitmask_size) {
112 if (!
s->mxm_bitmask) {
114 "MXM bitmask memory allocation error\n");
120 if (!
s->completion_bitmask) {
122 "Completion bitmask memory allocation error\n");
126 s->bitmask_size = bitmask_size;
129 memcpy(
s->mxm_bitmask, buf_ptr + 12, bitmask_size);
130 s->got_mxm_bitmask = 1;
132 if (!
s->has_complete_frame) {
133 uint8_t completion_check = 0xFF;
134 for (
i = 0;
i < bitmask_size; ++
i) {
135 s->completion_bitmask[
i] |=
s->mxm_bitmask[
i];
136 completion_check &=
s->completion_bitmask[
i];
138 s->has_complete_frame = !(completion_check ^ 0xFF);
145 const uint8_t *buf_ptr,
int buf_size)
151 if (
len > 14 &&
len <= buf_size && !strncmp(buf_ptr + 2,
"MXM", 3)) {
162 if ((jpg->
width + 0x0F)>>4 !=
s->mb_width ||
163 (jpg->
height + 0x0F)>>4 !=
s->mb_height) {
165 "Picture dimensions stored in SOF and MXM mismatch\n");
169 if (reference_ptr->
data[0]) {
175 "Dimensions of current and reference picture mismatch\n");
187 const uint8_t *buf = avpkt->
data;
188 int buf_size = avpkt->
size;
191 const uint8_t *buf_end, *buf_ptr;
192 const uint8_t *unescaped_buf_ptr;
193 int unescaped_buf_size;
201 buf_end = buf + buf_size;
203 s->got_mxm_bitmask = 0;
204 s->got_sof_data = !!
s->got_sof_data;
205 while (buf_ptr < buf_end) {
207 &unescaped_buf_ptr, &unescaped_buf_size);
228 "quantization table decode error\n");
236 "huffman table decode error\n");
247 if (
s->got_sof_data > 1) {
249 "Multiple SOF in a frame\n");
255 "SOF data decode error\n");
261 "Interlaced mode not supported in MxPEG\n");
268 if (!
s->got_sof_data) {
270 "Can not process SOS without SOF data, skipping\n");
276 "First picture has no SOF, skipping\n");
279 if (!
s->got_mxm_bitmask){
281 "Non-key frame has no MXM, skipping\n");
297 if (
s->got_mxm_bitmask) {
298 AVFrame *reference_ptr =
s->picture[
s->picture_index ^ 1];
303 if (!reference_ptr->
data[0] &&
332 s->picture_index ^= 1;
335 if (!
s->has_complete_frame) {
336 if (!
s->got_mxm_bitmask)
337 s->has_complete_frame = 1;
343 return buf_ptr - buf;
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static int get_bits_count(const GetBitContext *s)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void skip_bits(GetBitContext *s, int n)
int ff_mjpeg_decode_dht(MJpegDecodeContext *s)
AVCodec p
The public AVCodec.
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
enum AVDiscard skip_frame
Skip decoding for selected frames.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
#define FF_CODEC_DECODE_CB(func)
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
static int mxpeg_decode_mxm(MXpegDecodeContext *s, const uint8_t *buf_ptr, int buf_size)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
#define CODEC_LONG_NAME(str)
@ AVDISCARD_ALL
discard all
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
@ AV_PICTURE_TYPE_I
Intra.
const FFCodec ff_mxpeg_decoder
enum AVPictureType pict_type
Picture type of the frame.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, int mb_bitmask_size, const AVFrame *reference)
static int mxpeg_decode_app(MXpegDecodeContext *s, const uint8_t *buf_ptr, int buf_size)
#define i(width, name, range_min, range_max)
static av_cold int mxpeg_decode_init(AVCodecContext *avctx)
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
const char * name
Name of the codec implementation.
static av_cold int mxpeg_decode_end(AVCodecContext *avctx)
static int mxpeg_check_dimensions(MXpegDecodeContext *s, MJpegDecodeContext *jpg, AVFrame *reference_ptr)
static int mxpeg_decode_frame(AVCodecContext *avctx, AVFrame *rframe, 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)
main external API structure.
int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
int got_picture
we found a SOF and picture is valid, too.
@ AV_PICTURE_TYPE_P
Predicted.
This structure stores compressed data.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int mxpeg_decode_com(MXpegDecodeContext *s, const uint8_t *buf_ptr, int buf_size)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
uint8_t * completion_bitmask