72#define CHECK_IDENT(strc) (len >= sizeof(strc) && !memcmp(gb->buffer, strc, sizeof(strc)))
78 if (bytestream2_get_be16(gb) != (0xFF00 |
SOI))
82 if (bytestream2_get_byte(gb) != 0xFF)
85 int marker = bytestream2_get_byte(gb);
87 marker = bytestream2_get_byte(gb);
89 if (marker ==
SOS || marker ==
TEM || (marker >=
RST0 && marker <=
EOI))
94 const int len = bytestream2_get_be16(gb) - 2;
128 const int pos =
s->initial->size;
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) {
175 s->images =
av_calloc(nb_images,
sizeof(*
s->images));
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);
192 const int fatal = !
offset || explode;
194 "unsupported format 0x%"PRIx32
"\n",
i,
205 if (
s->first_img >= 0) {
210 s->first_img =
s->nb_images;
239 "Duplicate MP Index IFD\n");
244 const int skip =
sizeof(
"MPF");
299 const int pos =
s->initial->size;
302 uint8_t marker =
s->initial->data[
ret];
303 if (marker != 0xFF) {
308 while (marker == 0xFF) {
311 marker =
s->initial->data[
ret];
314 if (marker ==
SOS || marker ==
TEM || (marker >=
RST0 && marker <=
EOI))
334 s->passthrough = file_size <=
s->file_start;
342 .start =
s->file_start,
343 .size =
s->passthrough ?
s->initial->size
344 : file_size -
s->file_start,
348 if (
s->first_img < 0) {
358 s->has_gain_map &&
s->nb_images == 2)
365 for (
int i = 0;
i <
s->nb_images;
i++) {
367 if (!
s->images[
i].st)
371 for (
int i = 0;
i <
s->nb_images;
i++) {
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");
413 for (
int i = 0;
i <
s->nb_images - 1;
i++) {
415 if (next->start <
img->start +
img->size) {
418 "Image %d overlaps image %d%s\n",
img->index, next->index,
419 explode ?
"" :
", truncating");
422 img->size = next->start -
img->start;
435 if (
s->cur_image >=
s->nb_images &&
s->loop && !
s->passthrough) {
440 if (
s->cur_image >=
s->nb_images) {
447 pkt->stream_index = 0;
463 "%"PRId64
"\n",
img->st->id,
img->start);
468 if (
pkt->size <
img->size) {
474 pkt->stream_index =
img->st->index;
485 if (
s->passthrough || timestamp < 0 || (!
s->loop && timestamp > 0))
509#define OFFSET(x) offsetof(MPFDemuxContext, x)
510#define DEC AV_OPT_FLAG_DECODING_PARAM
518 .class_name =
"jpeg_mpf demuxer",
525 .p.name =
"jpeg_mpf",
528 .p.extensions =
"mpo",
static AVFormatContext * ctx
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int64_t avio_size(AVIOContext *s)
Get the filesize.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
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)
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
#define EOI
End Of Image marker.
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
#define AV_EF_EXPLODE
abort decoding on minor error detection
#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...
#define FF_INFMT_FLAG_ID3V2_AUTO
Automatically parse ID3v2 metadata.
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.
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.
void av_exif_free(AVExifMetadata *ifd)
Frees all resources associated with the given EXIF metadata struct.
@ AV_EXIF_TIFF_HEADER
The TIFF header starts with 0x49492a00, or 0x4d4d002a.
static int read_header(FFV1Context *f, RangeCoder *c)
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
AVStreamGroup * avformat_stream_group_create(AVFormatContext *s, enum AVStreamGroupParamsType type, AVDictionary **options)
Add a new empty stream group to a media file.
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.
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.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
Shared definitions for JPEG Multi-Picture Format (CIPA DC-007).
static int mpf_type_is_child(enum MPFType type)
@ MPF_TYPE_LARGE_THUMBNAIL
static int mpf_read_header(AVFormatContext *ctx)
static int parse_mp_index(AVFormatContext *ctx, const uint8_t *data, int len, int64_t tiff_base)
static int mpf_probe(const AVProbeData *p)
static const AVClass mpf_class
static int mpf_read_packet(AVFormatContext *ctx, AVPacket *pkt)
#define CHECK_IDENT(strc)
static int cmp_image_start(const void *a, const void *b)
static const AVOption mpf_options[]
static int mpf_read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
static int mpf_read_close(AVFormatContext *ctx)
static int add_gain_map_group(AVFormatContext *ctx, const MPFDemuxImage *base, const MPFDemuxImage *gain)
static int parse_app2(AVFormatContext *ctx, int offset, int len)
static int grow_header(AVFormatContext *ctx, int size)
#define AV_ISO21496_IDENTIFIER
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
#define FFDIFFSIGN(x, y)
Comparator.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
MJPEG encoder and decoder.
Describe the class of an AVClass context structure.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
This structure contains the data a format has to probe a file.
Rational number (pair of numerator and denominator).
unsigned int el_index
Index of the enhancement layer stream in AVStreamGroup.
unsigned int nb_entries
Number of elements in AVStreamGroup.entries.
union AVStreamGroup::@313244315204024013007202273061153315146016101155 params
Group type-specific parameters.
struct AVStreamGroupLayeredVideo * layered_video
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int id
Format-specific stream ID.
AVRational avg_frame_rate
Average framerate.
AVRational r_frame_rate
Real base framerate of the stream.
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
enum AVStreamParseType need_parsing