Skip to content

Commit b049465

Browse files
committed
JXL: Parse Exif and XMP
1 parent 1fadaed commit b049465

File tree

3 files changed

+93
-5
lines changed

3 files changed

+93
-5
lines changed

Source/MediaInfo/Multiple/File_Mpeg4.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,20 @@ private :
7676

7777
//Elements
7878
void bloc();
79+
void brob();
7980
void cdat();
81+
void Exif();
8082
void cdt2() {cdat();}
8183
void free();
8284
void ftyp();
85+
void hrgm();
8386
void idat();
8487
void idsc();
8588
void jp2c();
8689
void jp2h();
8790
void jp2h_colr();
8891
void jp2h_ihdr();
92+
void JXL_();
8993
void jp2h_ricc() {jp2h_colr(); }
9094
void mdat();
9195
void mdat_xxxx();
@@ -416,6 +420,7 @@ private :
416420
void skip();
417421
void sidx();
418422
void wide();
423+
void xml_();
419424

420425
//Helpers
421426
Ztring Language_Get(int16u Language);

Source/MediaInfo/Multiple/File_Mpeg4_Elements.cpp

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,10 @@ std::string File_Mpeg4_sv3d_Mesh_index_type(int8u Value)
703703
namespace Elements
704704
{
705705
const int64u bloc=0x626C6F63;
706+
const int64u brob=0x62726F62;
706707
const int64u cdat=0x63646174;
707708
const int64u cdt2=0x63647432;
709+
const int64u Exif=0x45786966;
708710
const int64u free=0x66726565;
709711
const int64u ftyp=0x66747970;
710712
const int64u ftyp_qt=0x71742020;
@@ -715,13 +717,15 @@ namespace Elements
715717
const int64u ftyp_dash=0x64617368;
716718
const int64u ftyp_isom=0x69736F6D;
717719
const int64u ftyp_caqv=0x63617176;
720+
const int64u hrgm=0x6872676D;
718721
const int64u idat=0x69646174;
719722
const int64u idsc=0x69647363;
720723
const int64u jp2c=0x6A703263;
721724
const int64u jp2h=0x6A703268;
722725
const int64u jp2h_colr=0x636F6C72;
723726
const int64u jp2h_ihdr=0x69686472;
724727
const int64u jp2h_ricc=0x72696363;
728+
const int64u JXL_=0x4A584C20;
725729
const int64u mdat=0x6D646174;
726730
const int64u meta=0x6D657461;
727731
const int64u meta_grpl=0x6772706C;
@@ -1086,6 +1090,7 @@ namespace Elements
10861090
const int64u skip=0x736B6970;
10871091
const int64u sidx=0x73696478;
10881092
const int64u wide=0x77696465;
1093+
const int64u xml_=0x786D6C20;
10891094
}
10901095

10911096
//---------------------------------------------------------------------------
@@ -1124,10 +1129,13 @@ void File_Mpeg4::Data_Parse()
11241129
//Parsing
11251130
DATA_BEGIN
11261131
ATOM(bloc)
1132+
ATOM(brob)
11271133
ATOM(cdat)
11281134
ATOM(cdt2)
1135+
ATOM(Exif)
11291136
LIST_SKIP(free)
11301137
ATOM(ftyp)
1138+
ATOM(hrgm)
11311139
ATOM(idat)
11321140
ATOM(idsc)
11331141
ATOM(jp2c)
@@ -1137,6 +1145,7 @@ void File_Mpeg4::Data_Parse()
11371145
ATOM(jp2h_ihdr)
11381146
ATOM(jp2h_ricc)
11391147
ATOM_END
1148+
ATOM(JXL_)
11401149
LIST(mdat)
11411150
ATOM_DEFAULT_ALONE(mdat_xxxx)
11421151
LIST(meta)
@@ -1586,6 +1595,7 @@ void File_Mpeg4::Data_Parse()
15861595
LIST_SKIP(skip)
15871596
ATOM(sidx)
15881597
LIST_SKIP(wide)
1598+
ATOM(xml_)
15891599
DATA_END
15901600
}
15911601

@@ -1707,6 +1717,18 @@ void File_Mpeg4::bloc()
17071717
Skip_XX(512, "Reserved");
17081718
}
17091719

1720+
//-------------------------------------------------------------------------
1721+
void File_Mpeg4::brob()
1722+
{
1723+
Element_Name("Brotli-compressed box");
1724+
1725+
int32u type;
1726+
Get_C4(type, "payload box type");
1727+
Element_Info1(Ztring::ToZtring_From_CC4(type));
1728+
1729+
Skip_XX(Element_Size - 4, "compressed data");
1730+
}
1731+
17101732
//---------------------------------------------------------------------------
17111733
void File_Mpeg4::cdat()
17121734
{
@@ -1745,6 +1767,29 @@ void File_Mpeg4::cdat()
17451767
}
17461768
}
17471769

1770+
//---------------------------------------------------------------------------
1771+
void File_Mpeg4::Exif()
1772+
{
1773+
Element_Name("Exif box");
1774+
1775+
//Parsing
1776+
#if defined(MEDIAINFO_EXIF_YES)
1777+
File_Exif MI{};
1778+
MI.FromHeif = true;
1779+
Open_Buffer_Init(&MI);
1780+
Open_Buffer_Continue(&MI);
1781+
Open_Buffer_Finalize(&MI);
1782+
Merge(MI, Stream_General, 0, 0, false);
1783+
Merge(MI, Stream_Image, 0, 0, false);
1784+
size_t Count = MI.Count_Get(Stream_Image);
1785+
for (size_t i = 1; i < Count; ++i) {
1786+
Merge(MI, Stream_Image, i, StreamPos_Last + 1, false);
1787+
}
1788+
#else
1789+
Skip_UTF8(Element_Size - Element_Offset, "EXIF Tags");
1790+
#endif
1791+
}
1792+
17481793
//---------------------------------------------------------------------------
17491794
void File_Mpeg4::free()
17501795
{
@@ -1839,6 +1884,13 @@ void File_Mpeg4::ftyp()
18391884
FILLING_END();
18401885
}
18411886

1887+
//---------------------------------------------------------------------------
1888+
void File_Mpeg4::hrgm()
1889+
{
1890+
Element_Name("HDR Gain Map");
1891+
Skip_XX(Element_Size, "Data");
1892+
}
1893+
18421894
//---------------------------------------------------------------------------
18431895
void File_Mpeg4::idat()
18441896
{
@@ -2006,6 +2058,18 @@ void File_Mpeg4::jp2h_ihdr()
20062058
FILLING_END()
20072059
}
20082060

2061+
//---------------------------------------------------------------------------
2062+
void File_Mpeg4::JXL_()
2063+
{
2064+
Element_Name("JPEG XL Signature box");
2065+
int32u signature;
2066+
Get_B4(signature, "Signature");
2067+
FILLING_BEGIN_PRECISE()
2068+
if (signature == 0x0D0A870A)
2069+
Fill(Stream_General, 0, General_Format, "JPEG XL");
2070+
FILLING_END()
2071+
}
2072+
20092073
//---------------------------------------------------------------------------
20102074
void File_Mpeg4::mdat()
20112075
{
@@ -11319,6 +11383,25 @@ void File_Mpeg4::wide()
1131911383
Skip_XX(Element_Size, "Free");
1132011384
}
1132111385

11386+
//---------------------------------------------------------------------------
11387+
void File_Mpeg4::xml_()
11388+
{
11389+
Element_Name("XML box");
11390+
11391+
//Parsing
11392+
#if defined(MEDIAINFO_XMP_YES)
11393+
File_Xmp MI{};
11394+
Open_Buffer_Init(&MI);
11395+
auto Element_Offset_Sav = Element_Offset;
11396+
Open_Buffer_Continue(&MI);
11397+
Element_Offset = Element_Offset_Sav;
11398+
Open_Buffer_Finalize(&MI);
11399+
Element_Show(); //TODO: why is it needed?
11400+
Merge(MI, Stream_General, 0, 0, false);
11401+
#endif
11402+
Skip_UTF8(Element_Size - Element_Offset, "XMP metadata");
11403+
}
11404+
1132211405
//***************************************************************************
1132311406
// C++
1132411407
//***************************************************************************

Source/MediaInfo/Tag/File_Exif.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,15 +1994,15 @@ void File_Exif::FileHeader_Parse()
19941994

19951995
//HEIF
19961996
if (FromHeif) {
1997-
int32u Size;
1998-
Get_B4 (Size, "Exif header length");
1997+
int32u exif_tiff_header_offset;
1998+
Get_B4 (exif_tiff_header_offset, "exif_tiff_header_offset");
19991999
string Identifier;
2000-
Get_String(Size, Identifier, "Identifier");
2001-
if (!(Size == 0 || (Size == 6 && !strncmp(Identifier.c_str(), "Exif\0", 6)))) {
2000+
Get_String(exif_tiff_header_offset, Identifier, "Identifier");
2001+
if (!(exif_tiff_header_offset == 0 || (exif_tiff_header_offset == 6 && !strncmp(Identifier.c_str(), "Exif\0", 6)))) {
20022002
Reject();
20032003
return;
20042004
}
2005-
OffsetFromContainer = static_cast<int64s>(4) + Size;
2005+
OffsetFromContainer = static_cast<int64s>(4) + exif_tiff_header_offset;
20062006
}
20072007

20082008
//Exif Makernotes

0 commit comments

Comments
 (0)