| 1 |
/*****************************************************************************/ |
| 2 |
// Copyright 2006-2022 Adobe Systems Incorporated |
| 3 |
// All Rights Reserved. |
| 4 |
// |
| 5 |
// NOTICE: Adobe permits you to use, modify, and distribute this file in |
| 6 |
// accordance with the terms of the Adobe license agreement accompanying it. |
| 7 |
/*****************************************************************************/ |
| 8 |
|
| 9 |
/** \file |
| 10 |
* Basic support for Base Media File Format. |
| 11 |
*/ |
| 12 |
|
| 13 |
/*****************************************************************************/ |
| 14 |
|
| 15 |
#ifndef __dng_bmff__ |
| 16 |
#define __dng_bmff__ |
| 17 |
|
| 18 |
/*****************************************************************************/ |
| 19 |
|
| 20 |
#include "dng_classes.h" |
| 21 |
#include "dng_memory.h" |
| 22 |
#include "dng_string.h" |
| 23 |
#include "dng_types.h" |
| 24 |
|
| 25 |
#include <memory> |
| 26 |
#include <vector> |
| 27 |
|
| 28 |
/*****************************************************************************/ |
| 29 |
|
| 30 |
class dng_bmff_box |
| 31 |
{ |
| 32 |
|
| 33 |
public: |
| 34 |
|
| 35 |
// Byte length of box as stored in the file: |
| 36 |
// |
| 37 |
// 0 = last box |
| 38 |
// 1 = large box |
| 39 |
// other = actual byte length for a compact box |
| 40 |
|
| 41 |
uint32 fStoredLength = 0xFFFFFFFF; |
| 42 |
|
| 43 |
// Real byte length of box, if known. May be 0 if fStoredLength is 0, |
| 44 |
// denoting the last box. |
| 45 |
|
| 46 |
uint64 fRealLength = 0ULL; |
| 47 |
|
| 48 |
// Offset of box (specifically, offset to the first byte of the length |
| 49 |
// field) from the start of the file. |
| 50 |
|
| 51 |
uint64 fOffset = 0ULL; |
| 52 |
|
| 53 |
// 4-char box name. |
| 54 |
|
| 55 |
dng_string fName; |
| 56 |
|
| 57 |
// Box contents, excluding the 8-byte (compact or last box) or 16-byte |
| 58 |
// (large box) header. |
| 59 |
|
| 60 |
std::shared_ptr<dng_memory_block> fContent; |
| 61 |
|
| 62 |
}; |
| 63 |
|
| 64 |
/*****************************************************************************/ |
| 65 |
|
| 66 |
typedef std::shared_ptr<dng_bmff_box> dng_bmff_box_sptr; |
| 67 |
|
| 68 |
typedef std::vector<dng_bmff_box_sptr> dng_bmff_box_list; |
| 69 |
|
| 70 |
/*****************************************************************************/ |
| 71 |
|
| 72 |
class dng_bmff_io |
| 73 |
{ |
| 74 |
|
| 75 |
public: |
| 76 |
|
| 77 |
dng_bmff_box_list fBoxes; |
| 78 |
|
| 79 |
public: |
| 80 |
|
| 81 |
virtual ~dng_bmff_io (); |
| 82 |
|
| 83 |
void Read (dng_host &host, |
| 84 |
dng_stream &stream); |
| 85 |
|
| 86 |
void Write (dng_host &host, |
| 87 |
dng_stream &stream) const; |
| 88 |
|
| 89 |
void UpdateBigTables (dng_host &host, |
| 90 |
const dng_big_table_dictionary &newTables, |
| 91 |
bool deleteUnused); |
| 92 |
|
| 93 |
void Add (dng_bmff_box_sptr box) |
| 94 |
{ |
| 95 |
if (box) |
| 96 |
fBoxes.push_back (box); |
| 97 |
} |
| 98 |
|
| 99 |
protected: |
| 100 |
|
| 101 |
virtual bool ShouldReadBox (const dng_string & /* str */, |
| 102 |
uint64 /* length */) const |
| 103 |
{ |
| 104 |
return true; |
| 105 |
} |
| 106 |
|
| 107 |
}; |
| 108 |
|
| 109 |
/*****************************************************************************/ |
| 110 |
|
| 111 |
#endif // __dng_bmff__ |
| 112 |
|
| 113 |
/*****************************************************************************/ |