FFmpeg
Loading...
Searching...
No Matches
jpegmpfenc.c
Go to the documentation of this file.
1/*
2 * JPEG Multi-Picture Format muxer
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 * Muxes several JPEG images into a single JPEG Multi-Picture Format file.
24 */
25
26#include <stdio.h>
27#include <string.h>
28#include <stddef.h>
29
30#include "libavutil/avassert.h"
31#include "libavutil/avstring.h"
32#include "libavutil/gain_map.h"
33#include "libavutil/internal.h"
34#include "libavutil/mem.h"
35
37#include "libavcodec/exif.h"
38#include "libavcodec/gain_map.h"
39#include "libavcodec/mjpeg.h"
40
41#include "avformat.h"
42#include "avio_internal.h"
43#include "mux.h"
44
45/* Namespace URIs of the GContainer XMP extension */
46#define XMP_CONTAINER_NS "http://ns.google.com/photos/1.0/container/"
47#define XMP_ITEM_NS "http://ns.google.com/photos/1.0/container/item/"
48
49/* Individual Image Attribute bits, from CIPA DC-007 Figure 8 */
52 MPF_DEPENDENT_CHILD = 0x40000000,
53 MPF_FORMAT_JPEG = 0x00000000,
54};
55
56/* MP Index IFD tags, from CIPA DC-007 Table 3 */
62
69
70/* APP2 extension segments */
71typedef enum MPFExt {
72 MPF_EXT_XMP, /* GContainer directory, First Individual Image only */
73 MPF_EXT_INDEX, /* MP Index IFD, First Individual Image only */
74 MPF_EXT_ISO21496, /* ISO 21496-1 version fields (in the base image) */
76} MPFExt;
77
78static const struct {
79 const char *name;
80 uint32_t type; /* from CIPA DC-007 Table 4 */
82 [MPF_ROLE_PRIMARY] = { "primary image", 0x030000 },
83 [MPF_ROLE_GAIN_MAP] = { "gain map image", 0x050000 },
84};
85
86typedef struct MPFImage MPFImage;
87struct MPFImage {
89 int index;
91
92 /* Relative to the packet data (before splicing) */
93 int app2; /* offset to role-specific APP2 header */
94 int has_xmp; /* image already carries an XMP packet */
95 int has_hdrgm; /* .. containing Ultra HDR gain map metadata */
96 int splice_pos; /* where in `packet->data` to splice our segments */
97
98 /* Relative to the output file (after splicing) */
99 int64_t start, end; /* start and end of this image in the output stream */
100 int64_t ext_size[MPF_EXT_NB]; /* APP2 payload sizes */
101
102 /* Image dependency metadata */
104 MPFImage *rev_deps[2]; /* maximum 2 permissible by the spec */
106};
107
108typedef struct MPFMuxContext {
110
111 /* Holds the XMP GContainer; if needed */
112#define XMP_GCONTAINER_MAX_LEN 1024 /* see XMP_GCONTAINER_TEMPLATE */
113 char xmp_gcontainer[1024];
114 int xmp_len; /* or 0 */
116
118{
119 if (base->nb_rev_deps == FF_ARRAY_ELEMS(base->rev_deps)) {
120 av_log(ctx, AV_LOG_ERROR, "Stream %d cannot depend on %d, maximum "
121 "number of dependents reached (%d).\n", img->index, base->index,
122 (int) FF_ARRAY_ELEMS(base->rev_deps));
123 return AVERROR(EINVAL);
124 }
125
126 base->rev_deps[base->nb_rev_deps++] = img;
127 img->dep = base;
128 return 0;
129}
130
132{
133 MPFMuxContext *s = ctx->priv_data;
135 if (sg->nb_streams != 2 || lv->el_index >= sg->nb_streams)
136 return AVERROR(EINVAL);
137
138 const AVStream *bl = sg->streams[!lv->el_index];
139 const AVStream *el = sg->streams[lv->el_index];
140 MPFImage *base = &s->images[bl->index];
141 MPFImage *gain = &s->images[el->index];
142
143 if (base->index != 0) {
144 av_log(ctx, AV_LOG_ERROR, "Stream group %u: the gain map base layer must "
145 "be the primary image (stream 0), got stream %d\n",
146 sg->index, base->index);
147 return AVERROR(EINVAL);
148 }
149
150 if (gain->role != MPF_ROLE_UNKNOWN) {
151 av_log(ctx, AV_LOG_ERROR, "Stream group %u: stream %d already used "
152 "as %s for a different stream group.\n", sg->index, gain->index,
153 mpf_roles[gain->role].name);
154 return AVERROR(EINVAL);
155 }
156
157 for (int i = 0; i < base->nb_rev_deps; i++) {
158 const MPFImage *other = base->rev_deps[i];
159 if (other->role == MPF_ROLE_GAIN_MAP) {
160 av_log(ctx, AV_LOG_ERROR, "Stream group %u: stream %d already "
161 "specified as a gain map for stream %d.\n", sg->index,
162 other->index, base->index);
163 return AVERROR(EINVAL);
164 }
165 }
166
167 gain->role = MPF_ROLE_GAIN_MAP;
168 return register_dep(ctx, gain, base);
169}
170
172{
173 int ret;
174
175 MPFMuxContext *s = ctx->priv_data;
176 if (ctx->nb_streams < 2)
177 av_log(ctx, AV_LOG_WARNING, "Specified only a single stream (no-op)\n");
178
179 s->images = av_calloc(ctx->nb_streams, sizeof(*s->images));
180 if (!s->images)
181 return AVERROR(ENOMEM);
182
183 for (int i = 0; i < ctx->nb_streams; i++) {
184 MPFImage *img = &s->images[i];
185 img->index = i;
186 img->start = img->end = -1;
187 for (int n = 0; n < MPF_EXT_NB; n++)
188 img->ext_size[n] = -1;
189 img->packet = av_packet_alloc();
190 if (!img->packet)
191 return AVERROR(ENOMEM);
192 }
193
194 /* Classify streams by their role */
195 s->images[0].role = MPF_ROLE_PRIMARY;
196
197 for (unsigned i = 0; i < ctx->nb_stream_groups; i++) {
198 const AVStreamGroup *sg = ctx->stream_groups[i];
199 switch (sg->type) {
201 if ((ret = init_gain_map(ctx, sg)) < 0)
202 return ret;
203 break;
204
205 default:
206 av_log(ctx, AV_LOG_ERROR, "Stream group %u: unknown type '%s'\n", i,
208 return AVERROR(EINVAL);
209 }
210 }
211
212 for (int i = 0; i < ctx->nb_streams; i++) {
213 if (s->images[i].role == MPF_ROLE_UNKNOWN) {
214 av_log(ctx, AV_LOG_ERROR, "Missing stream group for stream %d.\n", i);
215 return AVERROR(EINVAL);
216 }
217 }
218
219 return 0;
220}
221
222static void parse_app1(MPFImage *img, const GetByteContext *gb, int len)
223{
224 if (len < sizeof(FF_GAIN_MAP_XMP_IDENT) ||
226 return; /* not an XMP packet; e.g. Exif */
227
228 img->has_xmp = 1;
229 img->has_hdrgm = !!av_strnstr(gb->buffer, FF_GAIN_MAP_XMP_NAMESPACE, len);
230}
231
233 const GetByteContext *gb, int len)
234{
235#define CHECK_IDENT(strc) (len >= sizeof(strc) && !memcmp(gb->buffer, strc, sizeof(strc)))
236 switch (img->role) {
239 if (img->app2) {
240 av_log(ctx, AV_LOG_ERROR, "Stream %d: multiple ISO 21496-1 "
241 "APP2 segments\n", img->index);
242 return AVERROR_INVALIDDATA;
243 }
244
245 if (len < sizeof(AV_ISO21496_IDENTIFIER) + sizeof(uint16_t[2])) {
246 av_log(ctx, AV_LOG_ERROR, "Stream %d: ISO 21496-1 payload too "
247 "short\n", img->index);
248 return AVERROR_INVALIDDATA;
249 }
250 img->app2 = bytestream2_tell(gb);
251 }
252 break;
253 }
254#undef CHECK_IDENT
255
256 return 0;
257}
258
260{
261 int ret;
262 MPFMuxContext *s = ctx->priv_data;
263 MPFImage *img = &s->images[pkt->stream_index];
264 if (img->packet->size) {
265 av_log(ctx, AV_LOG_ERROR, "Stream %d: expected a single JPEG image\n", img->index);
266 return AVERROR(EINVAL);
267 }
268
270 bytestream2_init(&gb, pkt->data, pkt->size);
271 if (bytestream2_get_bytes_left(&gb) < 2 ||
272 bytestream2_get_be16(&gb) != (0xFF00 | SOI))
273 {
274 av_log(ctx, AV_LOG_ERROR, "Stream %d: not a JPEG image (no SOI)\n", img->index);
275 return AVERROR_INVALIDDATA;
276 }
277
278 /* Walk the JPEG marker sections up until the start of entropy coded data */
279 while (bytestream2_get_bytes_left(&gb) >= 4) {
280 const int pos = bytestream2_tell(&gb);
281 if (bytestream2_get_byte(&gb) != 0xFF) {
282 av_log(ctx, AV_LOG_ERROR, "Stream %d: malformed JPEG marker at 0x%x\n",
283 img->index, pos);
284 return AVERROR_INVALIDDATA;
285 }
286
287 int marker = bytestream2_get_byte(&gb);
288 if (marker == SOS || marker == TEM || (marker >= RST0 && marker <= EOI)) {
289 if (!img->splice_pos)
290 img->splice_pos = pos;
291 break; /* start of entropy coded data */
292 }
293
294 int len = bytestream2_get_be16(&gb) - 2;
296 av_log(ctx, AV_LOG_ERROR, "Stream %d: truncated marker segment at "
297 "0x%x\n", img->index, pos);
298 return AVERROR_INVALIDDATA;
299 }
300
301 switch (marker) {
302 case APP0:
303 break; /* ignored */
304 case APP1:
305 parse_app1(img, &gb, len);
306 break; /* not spliced past */
307 case APP2:
308 ret = parse_app2(ctx, img, &gb, len);
309 if (ret < 0)
310 return ret;
312 default:
313 /**
314 * Splice position for the MPF metadata shall be the first segment
315 * position after any SOI, APP0 or APP1 (cf. CIPA DC-007)
316 */
317 if (!img->splice_pos)
318 img->splice_pos = pos;
319 break;
320 }
321
322 bytestream2_skip(&gb, len);
323 }
324
325 /* Verify completeness of all needed information */
326 switch (img->role) {
327 case MPF_ROLE_PRIMARY:
328 if (!img->splice_pos) {
329 av_log(ctx, AV_LOG_ERROR, "Stream %d: truncated JPEG data\n", img->index);
330 return AVERROR_INVALIDDATA;
331 }
332 break;
334 if (!img->app2) {
335 av_log(ctx, AV_LOG_ERROR, "Stream %d was declared as a gain map "
336 "but is missing ISO 21496-1 metadata\n", img->index);
337 return AVERROR_INVALIDDATA;
338 }
339 break;
340 }
341
342 return av_packet_ref(img->packet, pkt);
343}
344
346{
347 int64_t val = avio_tell(pb) - base;
348 av_assert0(val >= 0);
349 av_assert0(*offset < 0 || *offset == val);
350 *offset = val;
351}
352
353#define XMP_GCONTAINER_TEMPLATE \
354 "<x:xmpmeta xmlns:x=\"adobe:ns:meta/\" x:xmptk=\"Adobe XMP Core 5.1.2\">\n" \
355 " <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n" \
356 " <rdf:Description\n" \
357 " xmlns:Container=\"" XMP_CONTAINER_NS "\"\n" \
358 " xmlns:Item=\"" XMP_ITEM_NS "\"\n" \
359 " xmlns:hdrgm=\"" FF_GAIN_MAP_XMP_NAMESPACE "\"\n" \
360 " hdrgm:Version=\"1.0\">\n" \
361 " <Container:Directory>\n" \
362 " <rdf:Seq>\n" \
363 " <rdf:li rdf:parseType=\"Resource\">\n" \
364 " <Container:Item\n" \
365 " Item:Semantic=\"Primary\"\n" \
366 " Item:Mime=\"image/jpeg\"/>\n" \
367 " </rdf:li>\n" \
368 " <rdf:li rdf:parseType=\"Resource\">\n" \
369 " <Container:Item\n" \
370 " Item:Semantic=\"GainMap\"\n" \
371 " Item:Mime=\"image/jpeg\"\n" \
372 " Item:Length=\"%d\"/>\n" \
373 " </rdf:li>\n" \
374 " </rdf:Seq>\n" \
375 " </Container:Directory>\n" \
376 " </rdf:Description>\n" \
377 " </rdf:RDF>\n" \
378 "</x:xmpmeta>"
379
380static_assert(XMP_GCONTAINER_MAX_LEN > sizeof(XMP_GCONTAINER_TEMPLATE) + 10,
381 "XMP buffer too small for template and values");
382
384{
385 MPFMuxContext *s = ctx->priv_data;
386 const MPFImage *base = &s->images[0];
387 const MPFImage *gain = NULL;
388 for (int i = 0; i < base->nb_rev_deps; i++) {
389 if (base->rev_deps[i]->role == MPF_ROLE_GAIN_MAP)
390 gain = base->rev_deps[i];
391 }
392
393 if (!gain || !gain->has_hdrgm)
394 return 0;
395
396 if (base->has_xmp) {
397 av_log(ctx, AV_LOG_WARNING, "The primary image already carries an XMP "
398 "packet; omitting the GContainer directory, as a JPEG file may "
399 "only contain one.\n");
400 return 0;
401 }
402
403 int ret = snprintf(s->xmp_gcontainer, sizeof(s->xmp_gcontainer),
405 if (ret < 0 || ret >= sizeof(s->xmp_gcontainer))
406 return AVERROR_BUG;
407
408 s->xmp_len = ret;
409 return 0;
410}
411
413{
414 const MPFMuxContext *s = ctx->priv_data;
415
416 avio_w8(pb, 0xFF);
417 avio_w8(pb, APP1);
418
419 const int64_t start = avio_tell(pb);
420 avio_wb16(pb, img->ext_size[MPF_EXT_XMP]);
422 avio_write(pb, s->xmp_gcontainer, s->xmp_len);
423
424 update_offset(pb, start, &img->ext_size[MPF_EXT_XMP]);
425}
426
428 MPFImage *img)
429{
430 const MPFMuxContext *s = ctx->priv_data;
431
432 avio_w8(pb, 0xFF);
433 avio_w8(pb, APP2);
434 const int64_t app2_start = avio_tell(pb) - base;
435 avio_wb16(pb, img->ext_size[MPF_EXT_INDEX]);
436 avio_write(pb, "MPF\0", 4);
437
438 /* every offset below is relative to this byte */
439 int64_t tiff_base = avio_tell(pb) - base;
440#define RELPOS(x) (avio_tell(pb) - base - tiff_base + (x))
441
442 avio_write(pb, "MM\0*", 4); /* big endian */
443 avio_wb32(pb, RELPOS(4)); /* offset to first IFD */
444
445 /* First (and only) IFD */
446 const int nb_tags = 3; /* MPFVersion, NumberOfImages, MPEntry */
447 avio_wb16(pb, nb_tags); /* number of IFD tags */
448
449 /* MPFVersion tag */
452 avio_wb32(pb, 4); /* count */
453 avio_write(pb, "0100", 4);
454
455 /* NumberOfImages tag */
458 avio_wb32(pb, 1);
459 avio_wb32(pb, ctx->nb_streams);
460
461 /* MPEntry tag */
462 const int64_t entry_size = sizeof(int32_t[3]) + sizeof(int16_t[2]);
465 avio_wb32(pb, ctx->nb_streams * entry_size);
466 avio_wb32(pb, RELPOS(4 + 4)); /* offset to MPEntry data */
467 avio_wb32(pb, 0); /* no MP Attribute IFD, per DC-007 6.1.1.1 */
468
469 for (int i = 0; i < ctx->nb_streams; i++) {
470 const MPFImage *entry = &s->images[i];
471 int64_t size = entry->end - entry->start;
472 av_assert0(size <= UINT32_MAX); /* would overflow null buffer anyways */
473 uint32_t attr = MPF_FORMAT_JPEG | mpf_roles[entry->role].type;
474 if (entry->nb_rev_deps)
475 attr |= MPF_DEPENDENT_PARENT;
476 if (entry->dep)
477 attr |= MPF_DEPENDENT_CHILD;
478
479 avio_wb32(pb, attr);
480 avio_wb32(pb, size);
481
482 /* The data offset of the First Individual Image is always zero */
483 int64_t offset = i ? entry->start - tiff_base : 0;
484 av_assert0(offset <= UINT32_MAX);
485 avio_wb32(pb, offset);
486
487 /* Indices are 1-based; 0 means "no dependent image" */
488 for (int j = 0; j < FF_ARRAY_ELEMS(entry->rev_deps); j++) {
489 const MPFImage *rdep = entry->rev_deps[j];
490 avio_wb16(pb, rdep ? rdep->index + 1 : 0);
491 }
492 }
493#undef RELPOS
494
495 update_offset(pb, base + app2_start, &img->ext_size[MPF_EXT_INDEX]);
496 return 0;
497}
498
500{
501 avio_w8(pb, 0xFF);
502 avio_w8(pb, APP2);
503
504 const int64_t start = avio_tell(pb);
505 avio_wb16(pb, src->ext_size[MPF_EXT_ISO21496]);
506
507 /* The primary image contains a subset of the ISO 21496-1 struct, carrying
508 * just the version header (two 16-bit integers), but no payload */
510 avio_write(pb, src->packet->data + src->app2 + sizeof(AV_ISO21496_IDENTIFIER),
511 sizeof(uint16_t[2]));
512
513 update_offset(pb, start, &src->ext_size[MPF_EXT_ISO21496]);
514}
515
518{
519 MPFMuxContext *s = ctx->priv_data;
520 int ret;
521
522 switch (img->role) {
523 case MPF_ROLE_PRIMARY:
524 /* The GContainer directory goes ahead of the MP Extensions, so that
525 * the latter still directly follow the APP1 segments (DC-007 Fig. 1) */
526 if (s->xmp_len)
527 mpf_write_xmp(ctx, pb, img);
528 if (ctx->nb_streams > 1) {
529 ret = mpf_write_index(ctx, pb, base, img);
530 if (ret < 0)
531 return ret;
532 }
533 break;
534 }
535
536 for (int i = 0; i < img->nb_rev_deps; i++) {
537 MPFImage *rdep = img->rev_deps[i];
538 switch (rdep->role) {
540 mpf_write_iso21496(pb, rdep);
541 break;
542 }
543 }
544
545 return 0;
546}
547
549{
550 MPFMuxContext *s = ctx->priv_data;
551 const int64_t base = avio_tell(pb);
552 int ret;
553
554 for (int i = 0; i < ctx->nb_streams; i++) {
555 MPFImage *img = &s->images[i];
556 const AVPacket *pkt = img->packet;
557
558 update_offset(pb, base, &img->start);
559 avio_write(pb, pkt->data, img->splice_pos);
560 if ((ret = mpf_write_extensions(ctx, pb, base, img)) < 0)
561 return ret;
562 avio_write(pb, pkt->data + img->splice_pos, pkt->size - img->splice_pos);
563 update_offset(pb, base, &img->end);
564 }
565
566 return 0;
567}
568
570{
571 MPFMuxContext *s = ctx->priv_data;
572 int ret;
573
574 for (int i = 0; i < ctx->nb_streams; i++) {
575 if (!s->images[i].packet->size) {
576 av_log(ctx, AV_LOG_ERROR, "No image was supplied on stream %d\n", i);
577 return AVERROR(EINVAL);
578 }
579 }
580
581 if ((ret = mpf_build_gcontainer_xmp(ctx)) < 0)
582 return ret;
583
584 /* Write the whole file once to a null buffer to settle offsets/sizes */
585 AVIOContext *null;
586 if ((ret = ffio_open_null_buf(&null)) < 0)
587 return ret;
588 ret = mpf_write(ctx, null);
589 int size = ffio_close_null_buf(null);
590 if (ret < 0)
591 return ret;
592 else if (size < 0)
593 return size;
594
595 for (int i = 0; i < ctx->nb_streams; i++) {
596 MPFImage *img = &s->images[i];
597 for (int j = 0; j < MPF_EXT_NB; j++) {
598 if (img->ext_size[j] > UINT16_MAX) {
599 av_log(ctx, AV_LOG_ERROR, "Stream %d: APP2 segment %d is too "
600 "large (%"PRId64" bytes)\n", img->index, j, img->ext_size[j]);
601 return AVERROR(EINVAL);
602 }
603 }
604 }
605
606 return mpf_write(ctx, ctx->pb);
607}
608
610{
611 MPFMuxContext *s = ctx->priv_data;
612 if (!s->images)
613 return;
614
615 for (int i = 0; i < ctx->nb_streams; i++)
616 av_packet_free(&s->images[i].packet);
617
618 av_freep(&s->images);
619}
620
622 .p.name = "jpeg_mpf",
623 .p.long_name = NULL_IF_CONFIG_SMALL("JPEG Multi-Picture Format"),
624 .p.mime_type = "image/jpeg",
625 .p.extensions = "jpg,jpeg",
626 .priv_data_size = sizeof(MPFMuxContext),
628 .p.video_codec = AV_CODEC_ID_MJPEG,
629 .flags_internal = FF_OFMT_FLAG_ONLY_DEFAULT_CODECS,
630 .init = mpf_init,
631 .deinit = mpf_uninit,
632 .write_packet = mpf_write_packet,
633 .write_trailer = mpf_write_trailer,
634 .interleave_packet = ff_interleave_packet_passthrough,
635};
static double val(void *priv, double ch)
Definition aeval.c:77
const FFOutputFormat ff_jpeg_mpf_muxer
Definition jpegmpfenc.c:621
#define entry
static AVFormatContext * ctx
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
Main libavformat public API header.
#define AVFMT_NODIMENSIONS
Format does not need width/height.
Definition avformat.h:504
@ AV_STREAM_GROUP_PARAMS_GAIN_MAP
Definition avformat.h:1157
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition avformat.h:500
void avio_w8(AVIOContext *s, int b)
Definition aviobuf.c:184
void avio_wb32(AVIOContext *s, unsigned int val)
Definition aviobuf.c:368
void avio_wb16(AVIOContext *s, unsigned int val)
Definition aviobuf.c:446
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition avio.h:494
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition aviobuf.c:206
int ffio_open_null_buf(AVIOContext **s)
Open a write-only fake memory stream.
Definition aviobuf.c:1421
int ffio_close_null_buf(AVIOContext *s)
Close a null buffer.
Definition aviobuf.c:1431
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
static av_always_inline int bytestream2_tell(const GetByteContext *g)
Definition bytestream.h:192
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define NULL
Definition coverity.c:32
long long int64_t
Definition coverity.c:34
#define EOI
End Of Image marker.
Definition cpia.c:43
static AVPacket * pkt
EXIF metadata parser.
@ AV_TIFF_LONG
Definition exif.h:45
@ AV_TIFF_UNDEFINED
Definition exif.h:48
@ AV_CODEC_ID_MJPEG
Definition codec_id.h:57
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition packet.c:63
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
Definition packet.c:442
const char * avformat_stream_group_name(enum AVStreamGroupParamsType type)
Definition avformat.c:270
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition error.h:52
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
char * av_strnstr(const char *haystack, const char *needle, size_t hay_length)
Locate the first occurrence of the string needle in the string haystack where not more than hay_lengt...
Definition avstring.c:71
static int mpf_build_gcontainer_xmp(AVFormatContext *ctx)
Definition jpegmpfenc.c:383
static int mpf_write_packet(AVFormatContext *ctx, AVPacket *pkt)
Definition jpegmpfenc.c:259
static int mpf_write_trailer(AVFormatContext *ctx)
Definition jpegmpfenc.c:569
static int register_dep(AVFormatContext *ctx, MPFImage *img, MPFImage *base)
Definition jpegmpfenc.c:117
static int mpf_write(AVFormatContext *ctx, AVIOContext *pb)
Definition jpegmpfenc.c:548
static int mpf_write_index(AVFormatContext *ctx, AVIOContext *pb, int64_t base, MPFImage *img)
Definition jpegmpfenc.c:427
static int init_gain_map(AVFormatContext *ctx, const AVStreamGroup *sg)
Definition jpegmpfenc.c:131
static void mpf_write_xmp(AVFormatContext *ctx, AVIOContext *pb, MPFImage *img)
Definition jpegmpfenc.c:412
#define XMP_GCONTAINER_TEMPLATE
Definition jpegmpfenc.c:353
static const struct @351235250060104351276150033220250051201364246176 mpf_roles[MPF_ROLE_NB]
#define XMP_GCONTAINER_MAX_LEN
Definition jpegmpfenc.c:112
MPFExt
Definition jpegmpfenc.c:71
@ MPF_EXT_NB
Definition jpegmpfenc.c:75
@ MPF_EXT_ISO21496
Definition jpegmpfenc.c:74
@ MPF_EXT_XMP
Definition jpegmpfenc.c:72
@ MPF_EXT_INDEX
Definition jpegmpfenc.c:73
static void parse_app1(MPFImage *img, const GetByteContext *gb, int len)
Definition jpegmpfenc.c:222
static int mpf_write_extensions(AVFormatContext *ctx, AVIOContext *pb, int64_t base, MPFImage *img)
Definition jpegmpfenc.c:516
MPFAttribute
Definition jpegmpfenc.c:50
@ MPF_DEPENDENT_PARENT
Definition jpegmpfenc.c:51
@ MPF_FORMAT_JPEG
Definition jpegmpfenc.c:53
@ MPF_DEPENDENT_CHILD
Definition jpegmpfenc.c:52
#define CHECK_IDENT(strc)
static int parse_app2(AVFormatContext *ctx, MPFImage *img, const GetByteContext *gb, int len)
Definition jpegmpfenc.c:232
static void update_offset(AVIOContext *pb, int64_t base, int64_t *offset)
Definition jpegmpfenc.c:345
MPFRole
Definition jpegmpfenc.c:63
@ MPF_ROLE_GAIN_MAP
Definition jpegmpfenc.c:66
@ MPF_ROLE_UNKNOWN
Definition jpegmpfenc.c:64
@ MPF_ROLE_PRIMARY
Definition jpegmpfenc.c:65
@ MPF_ROLE_NB
Definition jpegmpfenc.c:67
MPFTag
Definition jpegmpfenc.c:57
@ MPF_TAG_MPFVersion
Definition jpegmpfenc.c:58
@ MPF_TAG_NumberOfImages
Definition jpegmpfenc.c:59
@ MPF_TAG_MPEntry
Definition jpegmpfenc.c:60
#define RELPOS(x)
static int mpf_init(AVFormatContext *ctx)
Definition jpegmpfenc.c:171
uint32_t type
Definition jpegmpfenc.c:80
static void mpf_write_iso21496(AVIOContext *pb, MPFImage *src)
Definition jpegmpfenc.c:499
static void mpf_uninit(AVFormatContext *ctx)
Definition jpegmpfenc.c:609
unsigned offset
Definition libaomenc.c:763
Serialization of AVGainMapParams into the metadata blobs that image formats carry it in,...
#define FF_GAIN_MAP_XMP_IDENT
Definition gain_map.h:37
#define FF_GAIN_MAP_XMP_NAMESPACE
Definition gain_map.h:38
int ff_interleave_packet_passthrough(AVFormatContext *s, AVPacket *pkt, int flush, int has_packet)
Interleave packets directly in the order in which they arrive without any sort of buffering.
Definition mux.c:1021
#define av_fallthrough
Definition attributes.h:67
#define AV_ISO21496_IDENTIFIER
Definition gain_map.h:28
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:97
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
@ APP1
Definition mjpeg.h:80
@ APP2
Definition mjpeg.h:81
@ SOS
Definition mjpeg.h:72
@ APP0
Definition mjpeg.h:79
@ TEM
Definition mjpeg.h:113
@ SOI
Definition mjpeg.h:70
#define FF_OFMT_FLAG_ONLY_DEFAULT_CODECS
If this flag is set, then the only permitted audio/video/subtitle codec ids are AVOutputFormat....
Definition mux.h:59
const char * name
Definition qsvenc.c:142
#define FF_ARRAY_ELEMS(a)
unsigned int pos
Definition spdifenc.c:431
Format I/O context.
Definition avformat.h:1337
Bytestream IO Context.
Definition avio.h:160
This structure stores compressed data.
Definition packet.h:580
int size
Definition packet.h:604
AVStreamGroupLayeredVideo is meant to define the relation between a base layer video stream and a sep...
Definition avformat.h:1096
unsigned int el_index
Index of the enhancement layer stream in AVStreamGroup.
Definition avformat.h:1105
union AVStreamGroup::@166361102046003066253145020066347265153020354020 params
Group type-specific parameters.
enum AVStreamGroupParamsType type
Group type.
Definition avformat.h:1190
unsigned int nb_streams
Number of elements in AVStreamGroup.streams.
Definition avformat.h:1225
unsigned int index
Group index in AVFormatContext.
Definition avformat.h:1174
AVStream ** streams
A list of streams in the group.
Definition avformat.h:1238
struct AVStreamGroupLayeredVideo * layered_video
Definition avformat.h:1199
Stream structure.
Definition avformat.h:768
int index
stream index in AVFormatContext
Definition avformat.h:774
const uint8_t * buffer
Definition bytestream.h:34
int index
Definition jpegmpfenc.c:89
AVPacket * packet
Definition jpegmpfenc.c:88
int64_t ext_size[MPF_EXT_NB]
Definition jpegmpfenc.c:100
MPFImage * rev_deps[2]
Definition jpegmpfenc.c:104
int splice_pos
Definition jpegmpfenc.c:96
int has_xmp
Definition jpegmpfenc.c:94
int has_hdrgm
Definition jpegmpfenc.c:95
int64_t end
Definition jpegmpfenc.c:99
MPFImage * dep
Definition jpegmpfenc.c:103
int nb_rev_deps
Definition jpegmpfenc.c:105
MPFRole role
Definition jpegmpfenc.c:90
int64_t start
Definition jpegmpfenc.c:99
MPFImage * images
Definition jpegmpfenc.c:109
char xmp_gcontainer[1024]
Definition jpegmpfenc.c:113
#define av_freep(p)
#define av_log(a,...)
#define src
Definition vp8dsp.c:248
int size
#define img
int len
uint8_t base
Definition vp3data.h:128