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/"
112#define XMP_GCONTAINER_MAX_LEN 1024
121 "number of dependents reached (%d).\n",
img->index,
base->index,
143 if (
base->index != 0) {
145 "be the primary image (stream 0), got stream %d\n",
152 "as %s for a different stream group.\n", sg->
index, gain->
index,
157 for (
int i = 0;
i <
base->nb_rev_deps;
i++) {
161 "specified as a gain map for stream %d.\n", sg->
index,
176 if (
ctx->nb_streams < 2)
183 for (
int i = 0;
i <
ctx->nb_streams;
i++) {
186 img->start =
img->end = -1;
188 img->ext_size[n] = -1;
197 for (
unsigned i = 0;
i <
ctx->nb_stream_groups;
i++) {
212 for (
int i = 0;
i <
ctx->nb_streams;
i++) {
235#define CHECK_IDENT(strc) (len >= sizeof(strc) && !memcmp(gb->buffer, strc, sizeof(strc)))
241 "APP2 segments\n",
img->index);
247 "short\n",
img->index);
264 if (
img->packet->size) {
272 bytestream2_get_be16(&gb) != (0xFF00 |
SOI))
281 if (bytestream2_get_byte(&gb) != 0xFF) {
287 int marker = bytestream2_get_byte(&gb);
288 if (marker ==
SOS || marker ==
TEM || (marker >=
RST0 && marker <=
EOI)) {
289 if (!
img->splice_pos)
294 int len = bytestream2_get_be16(&gb) - 2;
297 "0x%x\n",
img->index,
pos);
317 if (!
img->splice_pos)
328 if (!
img->splice_pos) {
336 "but is missing ISO 21496-1 metadata\n",
img->index);
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" \
363 " <rdf:li rdf:parseType=\"Resource\">\n" \
364 " <Container:Item\n" \
365 " Item:Semantic=\"Primary\"\n" \
366 " Item:Mime=\"image/jpeg\"/>\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" \
375 " </Container:Directory>\n" \
376 " </rdf:Description>\n" \
381 "XMP buffer too small for template and values");
388 for (
int i = 0;
i <
base->nb_rev_deps;
i++) {
390 gain =
base->rev_deps[
i];
398 "packet; omitting the GContainer directory, as a JPEG file may "
399 "only contain one.\n");
403 int ret = snprintf(
s->xmp_gcontainer,
sizeof(
s->xmp_gcontainer),
405 if (ret < 0 || ret >=
sizeof(
s->xmp_gcontainer))
440#define RELPOS(x) (avio_tell(pb) - base - tiff_base + (x))
446 const int nb_tags = 3;
462 const int64_t entry_size =
sizeof(
int32_t[3]) +
sizeof(int16_t[2]);
469 for (
int i = 0;
i <
ctx->nb_streams;
i++) {
474 if (
entry->nb_rev_deps)
511 sizeof(uint16_t[2]));
528 if (
ctx->nb_streams > 1) {
536 for (
int i = 0;
i <
img->nb_rev_deps;
i++) {
538 switch (rdep->
role) {
554 for (
int i = 0;
i <
ctx->nb_streams;
i++) {
574 for (
int i = 0;
i <
ctx->nb_streams;
i++) {
575 if (!
s->images[
i].packet->size) {
595 for (
int i = 0;
i <
ctx->nb_streams;
i++) {
598 if (
img->ext_size[j] > UINT16_MAX) {
600 "large (%"PRId64
" bytes)\n",
img->index, j,
img->ext_size[j]);
615 for (
int i = 0;
i <
ctx->nb_streams;
i++)
622 .p.name =
"jpeg_mpf",
624 .p.mime_type =
"image/jpeg",
625 .p.extensions =
"jpg,jpeg",
static double val(void *priv, double ch)
static AVFormatContext * ctx
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void avio_w8(AVIOContext *s, int b)
void avio_wb32(AVIOContext *s, unsigned int val)
void avio_wb16(AVIOContext *s, unsigned int val)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
int ffio_open_null_buf(AVIOContext **s)
Open a write-only fake memory stream.
int ffio_close_null_buf(AVIOContext *s)
Close a null buffer.
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)
static av_always_inline int bytestream2_tell(const GetByteContext *g)
#define i(width, name, range_min, range_max)
#define EOI
End Of Image marker.
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
int av_packet_ref(AVPacket *dst, const AVPacket *src)
Setup a new reference to the data described by a given packet.
const char * avformat_stream_group_name(enum AVStreamGroupParamsType type)
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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...
static int mpf_build_gcontainer_xmp(AVFormatContext *ctx)
static int mpf_write_packet(AVFormatContext *ctx, AVPacket *pkt)
static int mpf_write_trailer(AVFormatContext *ctx)
static int register_dep(AVFormatContext *ctx, MPFImage *img, MPFImage *base)
static int mpf_write(AVFormatContext *ctx, AVIOContext *pb)
static int mpf_write_index(AVFormatContext *ctx, AVIOContext *pb, int64_t base, MPFImage *img)
static int init_gain_map(AVFormatContext *ctx, const AVStreamGroup *sg)
static void mpf_write_xmp(AVFormatContext *ctx, AVIOContext *pb, MPFImage *img)
#define XMP_GCONTAINER_TEMPLATE
static const struct @351235250060104351276150033220250051201364246176 mpf_roles[MPF_ROLE_NB]
#define XMP_GCONTAINER_MAX_LEN
static void parse_app1(MPFImage *img, const GetByteContext *gb, int len)
static int mpf_write_extensions(AVFormatContext *ctx, AVIOContext *pb, int64_t base, MPFImage *img)
#define CHECK_IDENT(strc)
static int parse_app2(AVFormatContext *ctx, MPFImage *img, const GetByteContext *gb, int len)
static void update_offset(AVIOContext *pb, int64_t base, int64_t *offset)
static int mpf_init(AVFormatContext *ctx)
static void mpf_write_iso21496(AVIOContext *pb, MPFImage *src)
static void mpf_uninit(AVFormatContext *ctx)
Serialization of AVGainMapParams into the metadata blobs that image formats carry it in,...
#define FF_GAIN_MAP_XMP_IDENT
#define FF_GAIN_MAP_XMP_NAMESPACE
#define AV_ISO21496_IDENTIFIER
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
MJPEG encoder and decoder.
#define FF_OFMT_FLAG_ONLY_DEFAULT_CODECS
If this flag is set, then the only permitted audio/video/subtitle codec ids are AVOutputFormat....
#define FF_ARRAY_ELEMS(a)
This structure stores compressed data.
AVStreamGroupLayeredVideo is meant to define the relation between a base layer video stream and a sep...
unsigned int el_index
Index of the enhancement layer stream in AVStreamGroup.
union AVStreamGroup::@166361102046003066253145020066347265153020354020 params
Group type-specific parameters.
enum AVStreamGroupParamsType type
Group type.
unsigned int nb_streams
Number of elements in AVStreamGroup.streams.
unsigned int index
Group index in AVFormatContext.
AVStream ** streams
A list of streams in the group.
struct AVStreamGroupLayeredVideo * layered_video
int index
stream index in AVFormatContext
int64_t ext_size[MPF_EXT_NB]
char xmp_gcontainer[1024]