FFmpeg
Loading...
Searching...
No Matches
jpegmpfdec.c
Go to the documentation of this file.
1/*
2 * JPEG Multi-Picture Format demuxer
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21/**
22 * @file
23 * Demuxer for the JPEG Multi-Picture Format file format.
24 */
25
26#include <stdlib.h>
27#include <string.h>
28
30#include "libavutil/gain_map.h"
31#include "libavutil/mem.h"
32#include "libavutil/opt.h"
33
35#include "libavcodec/exif.h"
36#include "libavcodec/mjpeg.h"
37
38#include "avformat.h"
39#include "demux.h"
40#include "jpegmpf.h"
41#include "internal.h"
42
43typedef struct MPFDemuxImage {
47
48 uint32_t type;
49 int index; /* of the corresponding MP Entry */
50 int child; /* is a dependent image */
52
53typedef struct MPFDemuxContext {
54 const AVClass *class;
56 int loop;
57
58 MPFDemuxImage *images; /* sorted by position in the file */
60
61 int cur_image; /* index of next image to return */
62 int64_t pts; /* number of times all images were returned */
63 int has_gain_map; /* the primary image carries ISO 21496-1 metadata */
64 int passthrough; /* not an MPF file */
65 int first_img; /* index of the first individual image */
66
67 /* image data parsed during mpf_read_header() */
71
72#define CHECK_IDENT(strc) (len >= sizeof(strc) && !memcmp(gb->buffer, strc, sizeof(strc)))
73
74static int mpf_probe(const AVProbeData *p)
75{
76 GetByteContext gbc, *gb = &gbc;
77 bytestream2_init(gb, p->buf, p->buf_size);
78 if (bytestream2_get_be16(gb) != (0xFF00 | SOI))
79 return 0;
80
81 while (bytestream2_get_bytes_left(gb) >= 4) {
82 if (bytestream2_get_byte(gb) != 0xFF)
83 return 0; /* not a JPEG marker */
84
85 int marker = bytestream2_get_byte(gb);
86 while (marker == 0xFF && bytestream2_get_bytes_left(gb) > 0) /* fill bytes */
87 marker = bytestream2_get_byte(gb);
88
89 if (marker == SOS || marker == TEM || (marker >= RST0 && marker <= EOI))
90 return 0; /* start of entropy coded data */
91 else if (marker == 0xFF || bytestream2_get_bytes_left(gb) < 2)
92 break; /* need more data */
93
94 const int len = bytestream2_get_be16(gb) - 2;
95 if (len < 0)
96 return 0;
98 break;
99
100 switch (marker) {
101 case APP2:
102 /* Marker segments unique to MPF files; the base image of a gain
103 * map file only carries the version fields of the ISO 21496-1
104 * metadata (two 16-bit integers); we don't want to false positive
105 * on standalone JPEGs that happen to contain gain map metadata */
106 if (CHECK_IDENT("MPF") ||
108 len == sizeof(AV_ISO21496_IDENTIFIER) + sizeof(uint16_t[2])))
109 return AVPROBE_SCORE_EXTENSION + 10;
110 break;
111 }
112
114 }
115
116 /* If we ran out of probe bytes, we don't know yet whether this is an
117 * MPF file or not, unless the extension is unique to MPF files */
118 if (av_match_ext(p->filename, "mpo"))
119 return AVPROBE_SCORE_EXTENSION + 5;
120
121 return AVERROR(EAGAIN);
122}
123
124/* returns the offset of the first byte read */
126{
127 MPFDemuxContext *s = ctx->priv_data;
128 const int pos = s->initial->size;
129 int ret = av_append_packet(ctx->pb, s->initial, size);
130 if (ret < 0)
131 return ret;
132 if (ret < size)
133 return AVERROR_INVALIDDATA;
134 return pos;
135}
136
137static int parse_mp_index(AVFormatContext *ctx, const uint8_t *data, int len,
138 int64_t tiff_base)
139{
140 MPFDemuxContext *s = ctx->priv_data;
141 AVExifMetadata ifd = { 0 };
142 AVExifEntry *num = NULL, *entries = NULL;
143 int ret;
144
145 if (len < 2)
146 return AVERROR_INVALIDDATA;
147 const int le = AV_RB16(data) == AV_RB16("II");
148
150 if (ret < 0)
151 return ret;
152
153 if ((ret = av_exif_get_entry(ctx, &ifd, MPF_TAG_NumberOfImages, 0, &num)) < 0 ||
154 (ret = av_exif_get_entry(ctx, &ifd, MPF_TAG_MPEntry, 0, &entries)) < 0)
155 goto fail;
156
157 if (!num || num->type != AV_TIFF_LONG || num->count != 1 ||
158 !entries || entries->type != AV_TIFF_UNDEFINED) {
159 av_log(ctx, AV_LOG_ERROR, "Missing or malformed MP Index IFD\n");
161 goto fail;
162 }
163
164 /* The spec asserts MPEntry count = 16 * NumberOfImages, but tolerate
165 * excess entries, e.g. left behind after deleting an image */
166 const int entry_size = sizeof(uint32_t[3]) + sizeof(uint16_t[2]);
167 const uint64_t nb_images = num->value.uint[0];
168 if (!nb_images || nb_images * entry_size > entries->count) {
169 av_log(ctx, AV_LOG_ERROR, "Invalid number of images: %"PRIu64"\n",
170 nb_images);
172 goto fail;
173 }
174
175 s->images = av_calloc(nb_images, sizeof(*s->images));
176 if (!s->images) {
177 ret = AVERROR(ENOMEM);
178 goto fail;
179 }
180
182 bytestream2_init(&gb, entries->value.ubytes, entries->count);
183
184 const int explode = ctx->error_recognition & AV_EF_EXPLODE;
185 for (int i = 0; i < nb_images; i++) {
186 const uint32_t attr = le ? bytestream2_get_le32u(&gb) : bytestream2_get_be32u(&gb);
187 const uint32_t size = le ? bytestream2_get_le32u(&gb) : bytestream2_get_be32u(&gb);
188 const uint32_t offset = le ? bytestream2_get_le32u(&gb) : bytestream2_get_be32u(&gb);
189 bytestream2_skipu(&gb, sizeof(uint16_t[2])); /* dependent images */
190
191 if ((attr & MPF_ATTR_FORMAT_MASK) != MPF_FORMAT_JPEG) {
192 const int fatal = !offset || explode;
193 av_log(ctx, fatal ? AV_LOG_ERROR : AV_LOG_WARNING, "Image %d: "
194 "unsupported format 0x%"PRIx32"\n", i,
195 attr & MPF_ATTR_FORMAT_MASK);
196 if (fatal) {
198 goto fail;
199 }
200 continue;
201 }
202
203 /* the First Individual Image is identified by an offset of 0 */
204 if (!offset) {
205 if (s->first_img >= 0) {
206 av_log(ctx, AV_LOG_ERROR, "Duplicate First Individual Image\n");
208 goto fail;
209 }
210 s->first_img = s->nb_images;
211 }
212
213 MPFDemuxImage *img = &s->images[s->nb_images++];
214 img->index = i;
215 img->start = offset ? tiff_base + offset : s->file_start;
216 img->size = size;
217 img->type = attr & MPF_ATTR_TYPE_MASK;
218 img->child = !!(attr & MPF_DEPENDENT_CHILD);
219 }
220
221 ret = 0;
222fail:
223 av_exif_free(&ifd);
224 return ret;
225}
226
228{
229 MPFDemuxContext *s = ctx->priv_data;
230 GetByteContext gbc, *gb = &gbc;
231 bytestream2_init(gb, s->initial->data + offset, len);
232
234 s->has_gain_map = 1;
235 } else if (CHECK_IDENT("MPF")) {
236 if (s->images) {
237 const int explode = ctx->error_recognition & AV_EF_EXPLODE;
239 "Duplicate MP Index IFD\n");
240 return explode ? AVERROR_INVALIDDATA : 0;
241 }
242
243 /* MP offsets are relative to the start of the TIFF header */
244 const int skip = sizeof("MPF");
245 return parse_mp_index(ctx, gb->buffer + skip, len - skip,
246 s->file_start + offset + skip);
247 }
248
249 return 0;
250}
251
252static int cmp_image_start(const void *a, const void *b)
253{
254 const MPFDemuxImage *ia = a, *ib = b;
255 if (ia->start != ib->start)
256 return FFDIFFSIGN(ia->start, ib->start);
257 return FFDIFFSIGN(ia->index, ib->index);
258}
259
261 const MPFDemuxImage *gain)
262{
263 if (gain == base) {
264 av_log(ctx, AV_LOG_ERROR, "The first image cannot be a gain map\n");
265 return AVERROR_INVALIDDATA;
266 }
267
269 if (!stg)
270 return AVERROR(ENOMEM);
271
272 int ret;
273 if ((ret = avformat_stream_group_add_stream(stg, base->st)) < 0 ||
274 (ret = avformat_stream_group_add_stream(stg, gain->st)) < 0)
275 return ret;
276
277 stg->params.layered_video->el_index = stg->nb_entries - 1;
278 return 0;
279}
280
282{
283 MPFDemuxContext *s = ctx->priv_data;
284 int ret;
285
286 s->first_img = -1;
287 s->initial = av_packet_alloc();
288 if (!s->initial)
289 return AVERROR(ENOMEM);
290
291 s->file_start = avio_tell(ctx->pb);
292 if ((ret = grow_header(ctx, 2)) < 0)
293 return ret;
294 if (AV_RB16(s->initial->data) != (0xFF00 | SOI))
295 return AVERROR_INVALIDDATA;
296
297 /* Walk the JPEG marker sections up until the start of entropy coded data */
298 for (;;) {
299 const int pos = s->initial->size;
300 if ((ret = grow_header(ctx, 1)) < 0)
301 return ret;
302 uint8_t marker = s->initial->data[ret];
303 if (marker != 0xFF) {
304 av_log(ctx, AV_LOG_ERROR, "Malformed JPEG marker at 0x%x\n", pos);
305 return AVERROR_INVALIDDATA;
306 }
307
308 while (marker == 0xFF) {
309 if ((ret = grow_header(ctx, 1)) < 0)
310 return ret;
311 marker = s->initial->data[ret];
312 }
313
314 if (marker == SOS || marker == TEM || (marker >= RST0 && marker <= EOI))
315 break; /* start of entropy coded data */
316
317 if ((ret = grow_header(ctx, 2)) < 0)
318 return ret;
319 const int len = AV_RB16(s->initial->data + ret) - 2;
320 if (len < 0) {
321 av_log(ctx, AV_LOG_ERROR, "Invalid marker segment at 0x%x\n", pos);
322 return AVERROR_INVALIDDATA;
323 }
324
325 if ((ret = grow_header(ctx, len)) < 0)
326 return ret;
327 if (marker == APP2 && (ret = parse_app2(ctx, ret, len)) < 0)
328 return ret;
329 }
330
331 if (!s->images) {
332 /* Not an MPF file, just return as-is to the underlying decoder */
333 const int64_t file_size = avio_size(ctx->pb);
334 s->passthrough = file_size <= s->file_start;
335 s->first_img = 0;
336 s->nb_images = 1;
337 s->images = av_malloc(sizeof(*s->images));
338 if (!s->images)
339 return AVERROR(ENOMEM);
340 s->images[0] = (MPFDemuxImage){
341 .type = MPF_TYPE_PRIMARY,
342 .start = s->file_start,
343 .size = s->passthrough ? s->initial->size
344 : file_size - s->file_start,
345 };
346 }
347
348 if (s->first_img < 0) {
349 av_log(ctx, AV_LOG_ERROR, "No MP Entry for the first image\n");
350 return AVERROR_INVALIDDATA;
351 }
352
353 /* Compatibility hack for libultrahdr, which produces invalid MPF files
354 * whose gain maps have no MP type. Needed to support a large number
355 * of JPEG Ultra HDR images in the wild */
356 const MPFDemuxImage *first = &s->images[s->first_img];
357 if (ctx->strict_std_compliance < FF_COMPLIANCE_STRICT &&
358 s->has_gain_map && s->nb_images == 2)
359 {
360 MPFDemuxImage *other = &s->images[1 - s->first_img];
361 if (other->type == MPF_TYPE_UNDEFINED)
362 other->type = MPF_TYPE_GAIN_MAP;
363 }
364
365 for (int i = 0; i < s->nb_images; i++) {
366 s->images[i].st = avformat_new_stream(ctx, NULL);
367 if (!s->images[i].st)
368 return AVERROR(ENOMEM);
369 }
370
371 for (int i = 0; i < s->nb_images; i++) {
372 MPFDemuxImage *img = &s->images[i];
373 AVStream *st = img->st;
374
375 st->id = img->index;
378 if (img == first)
380 if (img->child || mpf_type_is_child(img->type))
382 avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num);
383 st->avg_frame_rate = st->r_frame_rate = s->framerate;
384 if (s->passthrough) /* we don't know the image size */
386
387 switch (img->type & MPF_TYPE_INFO_MASK) {
389 ret = add_gain_map_group(ctx, first, img);
390 if (ret < 0)
391 return ret;
392 break;
395 case MPF_TYPE_PRIMARY:
397 /* no special handling */
398 break;
400 default:
402 "Image %d: unhandled MP type 0x%06"PRIx32", treating as an "
403 "%s image\n", img->index, img->type,
404 img->child ? "unspecified dependent" : "unrelated");
405 break;
406 }
407 }
408
409 /* Sort the images array by file offset for mpf_read_packet() */
410 qsort(s->images, s->nb_images, sizeof(*s->images), cmp_image_start);
411 s->first_img = 0; /* by construction */
412
413 for (int i = 0; i < s->nb_images - 1; i++) {
414 MPFDemuxImage *img = &s->images[i], *next = &s->images[i + 1];
415 if (next->start < img->start + img->size) {
416 const int explode = ctx->error_recognition & AV_EF_EXPLODE;
418 "Image %d overlaps image %d%s\n", img->index, next->index,
419 explode ? "" : ", truncating");
420 if (explode)
421 return AVERROR_INVALIDDATA;
422 img->size = next->start - img->start;
423 }
424 }
425
426 return 0;
427}
428
430{
431 MPFDemuxContext *s = ctx->priv_data;
432 AVIOContext *pb = ctx->pb;
433 int ret;
434
435 if (s->cur_image >= s->nb_images && s->loop && !s->passthrough) {
436 s->cur_image = 0;
437 s->pts++;
438 }
439
440 if (s->cur_image >= s->nb_images) {
441 if (!s->passthrough)
442 return AVERROR_EOF;
443
444 if ((ret = av_get_packet(pb, pkt, 4096)) < 0)
445 return ret;
446 pkt->flags &= ~AV_PKT_FLAG_CORRUPT; /* short read at EOF */
447 pkt->stream_index = 0;
448 return 0;
449 }
450
451 const MPFDemuxImage *img = &s->images[s->cur_image++];
452 if (img->size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
453 return AVERROR(ERANGE);
454
455 if (s->initial) {
456 av_packet_move_ref(pkt, s->initial);
457 av_packet_free(&s->initial);
458 av_shrink_packet(pkt, FFMIN(pkt->size, img->size));
459 } else {
460 int64_t pos = avio_seek(pb, img->start, SEEK_SET);
461 if (pos < 0) {
462 av_log(ctx, AV_LOG_ERROR, "Failed seeking to image %d at offset "
463 "%"PRId64"\n", img->st->id, img->start);
464 return pos;
465 }
466 }
467
468 if (pkt->size < img->size) {
469 ret = av_append_packet(pb, pkt, img->size - pkt->size);
471 return ret;
472 }
473
474 pkt->stream_index = img->st->index;
475 pkt->pts = pkt->dts = s->pts;
476 pkt->duration = 1;
477 pkt->flags |= AV_PKT_FLAG_KEY;
478 return 0;
479}
480
481static int mpf_read_seek(AVFormatContext *ctx, int stream_index,
482 int64_t timestamp, int flags)
483{
484 MPFDemuxContext *s = ctx->priv_data;
485 if (s->passthrough || timestamp < 0 || (!s->loop && timestamp > 0))
486 return -1;
487
488 /* Don't seek if the initial packet is still pending; since this would
489 * desynchronize the input stream otherwise */
490 if (!s->initial) {
491 int64_t pos = avio_seek(ctx->pb, s->images[0].start, SEEK_SET);
492 if (pos < 0)
493 return pos;
494 }
495
496 s->cur_image = 0;
497 s->pts = timestamp;
498 return 0;
499}
500
502{
503 MPFDemuxContext *s = ctx->priv_data;
504 av_freep(&s->images);
505 av_packet_free(&s->initial);
506 return 0;
507}
508
509#define OFFSET(x) offsetof(MPFDemuxContext, x)
510#define DEC AV_OPT_FLAG_DECODING_PARAM
511static const AVOption mpf_options[] = {
512 { "framerate", "set the video framerate", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, DEC },
513 { "loop", "loop over the images in the file", OFFSET(loop), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DEC },
514 { NULL },
515};
516
517static const AVClass mpf_class = {
518 .class_name = "jpeg_mpf demuxer",
519 .item_name = av_default_item_name,
520 .option = mpf_options,
521 .version = LIBAVUTIL_VERSION_INT,
522};
523
525 .p.name = "jpeg_mpf",
526 .p.long_name = NULL_IF_CONFIG_SMALL("JPEG Multi-Picture Format"),
527 .p.priv_class = &mpf_class,
528 .p.extensions = "mpo",
529 .priv_data_size = sizeof(MPFDemuxContext),
536};
const FFInputFormat ff_jpeg_mpf_demuxer
Definition jpegmpfdec.c:524
static AVFormatContext * ctx
void avpriv_set_pts_info(AVStream *st, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition avformat.c:865
Main libavformat public API header.
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size)
Read data and append it to the current content of the AVPacket.
Definition utils.c:114
@ AV_STREAM_GROUP_PARAMS_GAIN_MAP
Definition avformat.h:1165
#define AV_DISPOSITION_DEPENDENT
The stream is intended to be mixed with another stream before presentation.
Definition avformat.h:729
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition avformat.h:483
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size)
Allocate and read the payload of a packet and initialize its fields with default values.
Definition utils.c:98
#define AV_DISPOSITION_DEFAULT
The stream should be chosen by default among other streams of the same type, unless the user has expl...
Definition avformat.h:641
@ AVSTREAM_PARSE_FULL
full parsing and repack
Definition avformat.h:613
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition aviobuf.c:236
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition aviobuf.c:326
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:507
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static av_always_inline void bytestream2_skipu(GetByteContext *g, unsigned int size)
Definition bytestream.h:174
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
Definition bytestream.h:158
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition bytestream.h:137
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition bytestream.h:168
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define ib(width, name)
Definition cbs_h264.c:65
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
static int read_probe(const AVProbeData *p)
Definition cdg.c:30
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
#define EOI
End Of Image marker.
Definition cpia.c:43
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
Definition defs.h:59
#define AV_EF_EXPLODE
abort decoding on minor error detection
Definition defs.h:51
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
Definition demux.h:35
#define FF_INFMT_FLAG_ID3V2_AUTO
Automatically parse ID3v2 metadata.
Definition demux.h:45
static AVPacket * pkt
int av_exif_get_entry(void *logctx, AVExifMetadata *ifd, uint16_t id, int flags, AVExifEntry **value)
Get an entry with the tagged ID from the EXIF metadata struct.
Definition exif.c:1197
int av_exif_parse_buffer(void *logctx, const uint8_t *buf, size_t size, AVExifMetadata *ifd, enum AVExifHeaderMode header_mode)
Decodes the EXIF data provided in the buffer and writes it into the struct *ifd.
Definition exif.c:896
void av_exif_free(AVExifMetadata *ifd)
Frees all resources associated with the given EXIF metadata struct.
Definition exif.c:673
EXIF metadata parser.
@ AV_TIFF_LONG
Definition exif.h:45
@ AV_TIFF_UNDEFINED
Definition exif.h:48
@ AV_EXIF_TIFF_HEADER
The TIFF header starts with 0x49492a00, or 0x4d4d002a.
Definition exif.h:62
int ret
Definition ffplay.c:391
static int loop
Definition ffplay.c:367
static int read_header(FFV1Context *f, RangeCoder *c)
Definition ffv1dec.c:578
#define fail
Definition test.h:479
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition opt.h:314
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ AV_CODEC_ID_MJPEG
Definition codec_id.h:57
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
Definition packet.h:658
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition packet.h:657
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition packet.c:492
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
Definition packet.c:113
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition packet.c:63
AVStreamGroup * avformat_stream_group_create(AVFormatContext *s, enum AVStreamGroupParamsType type, AVDictionary **options)
Add a new empty stream group to a media file.
Definition options.c:474
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st)
Add an already allocated stream to a stream group.
Definition options.c:589
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
Definition format.c:41
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR_EOF
End of file.
Definition error.h:57
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
const char * av_default_item_name(void *ptr)
Return the context name.
Definition log.c:247
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
int a
#define b
Definition input.c:43
#define AV_RB16(p)
Shared definitions for JPEG Multi-Picture Format (CIPA DC-007).
static int mpf_type_is_child(enum MPFType type)
Definition jpegmpf.h:52
@ MPF_FORMAT_JPEG
Definition jpegmpf.h:36
@ MPF_ATTR_FORMAT_MASK
Definition jpegmpf.h:34
@ MPF_DEPENDENT_CHILD
Definition jpegmpf.h:32
@ MPF_ATTR_TYPE_MASK
Definition jpegmpf.h:35
@ MPF_TAG_NumberOfImages
Definition jpegmpf.h:67
@ MPF_TAG_MPEntry
Definition jpegmpf.h:68
@ MPF_TYPE_UNDEFINED
Definition jpegmpf.h:41
@ MPF_TYPE_PRIMARY
Definition jpegmpf.h:44
@ MPF_TYPE_MULTI_FRAME
Definition jpegmpf.h:43
@ MPF_TYPE_GAIN_MAP
Definition jpegmpf.h:46
@ MPF_TYPE_ORIGINAL
Definition jpegmpf.h:45
@ MPF_TYPE_LARGE_THUMBNAIL
Definition jpegmpf.h:42
@ MPF_TYPE_INFO_MASK
Definition jpegmpf.h:48
static int mpf_read_header(AVFormatContext *ctx)
Definition jpegmpfdec.c:281
static int parse_mp_index(AVFormatContext *ctx, const uint8_t *data, int len, int64_t tiff_base)
Definition jpegmpfdec.c:137
static int mpf_probe(const AVProbeData *p)
Definition jpegmpfdec.c:74
static const AVClass mpf_class
Definition jpegmpfdec.c:517
static int mpf_read_packet(AVFormatContext *ctx, AVPacket *pkt)
Definition jpegmpfdec.c:429
#define CHECK_IDENT(strc)
Definition jpegmpfdec.c:72
static int cmp_image_start(const void *a, const void *b)
Definition jpegmpfdec.c:252
static const AVOption mpf_options[]
Definition jpegmpfdec.c:511
static int mpf_read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition jpegmpfdec.c:481
static int mpf_read_close(AVFormatContext *ctx)
Definition jpegmpfdec.c:501
static int add_gain_map_group(AVFormatContext *ctx, const MPFDemuxImage *base, const MPFDemuxImage *gain)
Definition jpegmpfdec.c:260
static int parse_app2(AVFormatContext *ctx, int offset, int len)
Definition jpegmpfdec.c:227
#define OFFSET(x)
Definition jpegmpfdec.c:509
static int grow_header(AVFormatContext *ctx, int size)
Definition jpegmpfdec.c:125
unsigned offset
Definition libaomenc.c:763
static av_always_inline FFStream * ffstream(AVStream *st)
Definition internal.h:384
#define AV_ISO21496_IDENTIFIER
Definition gain_map.h:28
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
static av_cold int read_close(AVFormatContext *ctx)
Definition libcdio.c:143
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
Definition libcdio.c:151
#define DEC
Definition librsvgdec.c:149
#define FFMIN(a, b)
Definition macros.h:49
#define FFDIFFSIGN(x, y)
Comparator.
Definition macros.h:45
void * av_calloc(size_t nmemb, size_t size)
Definition mem.c:370
Memory handling functions.
MJPEG encoder and decoder.
@ RST0
Definition mjpeg.h:61
@ APP2
Definition mjpeg.h:81
@ SOS
Definition mjpeg.h:72
@ TEM
Definition mjpeg.h:113
@ SOI
Definition mjpeg.h:70
const char data[16]
Definition mxf.c:149
#define av_malloc(s)
Definition ops_static.c:52
AVOptions.
unsigned int pos
Definition spdifenc.c:431
Describe the class of an AVClass context structure.
Definition log.h:76
enum AVMediaType codec_type
General type of the encoded data.
Definition codec_par.h:53
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition codec_par.h:57
Format I/O context.
Definition avformat.h:1401
Bytestream IO Context.
Definition avio.h:160
AVOption.
Definition opt.h:428
This structure stores compressed data.
Definition packet.h:587
This structure contains the data a format has to probe a file.
Definition avformat.h:473
Rational number (pair of numerator and denominator).
Definition rational.h:58
unsigned int el_index
Index of the enhancement layer stream in AVStreamGroup.
Definition avformat.h:1113
unsigned int nb_entries
Number of elements in AVStreamGroup.entries.
Definition avformat.h:1286
union AVStreamGroup::@313244315204024013007202273061153315146016101155 params
Group type-specific parameters.
struct AVStreamGroupLayeredVideo * layered_video
Definition avformat.h:1221
Stream structure.
Definition avformat.h:768
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition avformat.h:791
int id
Format-specific stream ID.
Definition avformat.h:780
AVRational avg_frame_rate
Average framerate.
Definition avformat.h:857
AVRational r_frame_rate
Real base framerate of the stream.
Definition avformat.h:902
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
Definition avformat.h:837
enum AVStreamParseType need_parsing
Definition internal.h:340
const uint8_t * buffer
Definition bytestream.h:34
AVPacket * initial
Definition jpegmpfdec.c:68
AVRational framerate
Definition jpegmpfdec.c:55
MPFDemuxImage * images
Definition jpegmpfdec.c:58
int64_t file_start
Definition jpegmpfdec.c:69
AVStream * st
Definition jpegmpfdec.c:44
int64_t size
Definition jpegmpfdec.c:46
uint32_t type
Definition jpegmpfdec.c:48
int64_t start
Definition jpegmpfdec.c:45
#define av_freep(p)
#define av_log(a,...)
float framerate
Definition av1_levels.c:29
int num
Definition error.c:23
int size
#define img
int len
uint8_t base
Definition vp3data.h:128