00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef MXFLIB__VBI_H
00030 #define MXFLIB__VBI_H
00031
00032
00033
00034 namespace mxflib
00035 {
00036 }
00037
00038
00039 namespace mxflib
00040 {
00042 enum VBIWrappingType
00043 {
00044 VBIFrame = 1,
00045 VBIField1 = 2,
00046 VBIField2 = 3,
00047 VBIProgressive = 4
00048 };
00049
00051 enum VBISampleCoding
00052 {
00053 Y1Bit = 1,
00054 C1Bit = 2,
00055 YC1Bit = 3,
00056 Y8Bit = 4,
00057 C8Bit = 5,
00058 YC8Bit = 6,
00059 Y10Bit = 7,
00060 C10Bit = 8,
00061 YC10Bit = 9
00062 };
00063
00065 class VBILine : public RefCount<VBILine>
00066 {
00067 protected:
00068 DataChunk Data;
00069 int LineNumber;
00070 VBIWrappingType WrappingType;
00071 VBISampleCoding SampleCoding;
00072 UInt16 SampleCount;
00073
00074 public:
00076 VBILine(int LineNumber, VBIWrappingType Wrapping, VBISampleCoding Coding)
00077 : LineNumber(LineNumber), WrappingType(Wrapping), SampleCoding(Coding) {};
00078
00080 VBILine(int Field, int LineNumber, VBIWrappingType Wrapping, VBISampleCoding Coding)
00081 : WrappingType(Wrapping), SampleCoding(Coding)
00082 {
00083 if(Field == 2) this->LineNumber = 0x4000 + LineNumber;
00084 else this->LineNumber = LineNumber;
00085 };
00086
00088
00089 VBILine(int LineNumber, VBIWrappingType Wrapping, VBISampleCoding Coding, UInt16 SampleCount, DataChunkPtr &LineData)
00090 : LineNumber(LineNumber), WrappingType(Wrapping), SampleCoding(Coding), SampleCount(SampleCount)
00091 {
00092
00093 Data.TakeBuffer(LineData, true);
00094 }
00095
00097
00098 VBILine(int Field, int LineNumber, VBIWrappingType Wrapping, VBISampleCoding Coding, UInt16 SampleCount, DataChunkPtr &LineData)
00099 : LineNumber(LineNumber), WrappingType(Wrapping), SampleCoding(Coding), SampleCount(SampleCount)
00100 {
00101 if(Field == 2) this->LineNumber = 0x4000 + LineNumber;
00102 else this->LineNumber = LineNumber;
00103
00104
00105 Data.TakeBuffer(LineData, true);
00106 }
00107
00109
00110 void SetData(UInt16 SampleCount, DataChunkPtr &LineData)
00111 {
00112
00113 Data.TakeBuffer(LineData, true);
00114
00115 this->SampleCount = SampleCount;
00116 }
00117
00119 size_t GetDataSize(void) { return static_cast<size_t>(Data.Size); }
00120
00122 size_t GetFullDataSize(void) { return static_cast<size_t>(Data.Size) + 6; }
00123
00125
00127 void WriteData(UInt8 *Buffer);
00128 };
00129
00130
00131
00132 typedef SmartPtr<VBILine> VBILinePtr;
00133
00134
00135 typedef std::map<int, VBILinePtr> VBILineMap;
00136
00137
00139 class VBISource : public EssenceSource
00140 {
00141 protected:
00142 EssenceSourceParent MasterSource;
00143
00144 VBILineMap Lines;
00145
00146 DataChunkList BufferedData;
00147
00148 size_t BufferOffset;
00149
00150 Position CurrentPosition;
00151
00152 public:
00153
00154 VBISource(EssenceSource *Master) : MasterSource(Master), BufferOffset(0), CurrentPosition(0) {};
00155
00157 virtual ~VBISource() {};
00158
00159
00160 void AddLine(int LineNumber, VBIWrappingType Wrapping, VBISampleCoding Coding, UInt16 SampleCount, DataChunkPtr &LineData);
00161
00162
00163 void AddLine(int Field, int LineNumber, VBIWrappingType Wrapping, VBISampleCoding Coding, UInt16 SampleCount, DataChunkPtr &LineData)
00164 {
00165 if(Field == 2) LineNumber += 0x4000;
00166 AddLine(LineNumber, Wrapping, Coding, SampleCount, LineData);
00167 }
00168
00170
00171 virtual size_t GetEssenceDataSize(void);
00172
00174
00184 virtual DataChunkPtr GetEssenceData(size_t Size = 0, size_t MaxSize = 0);
00185
00187
00193 virtual bool EndOfItem(void) { return (BufferOffset == 0); }
00194
00196
00198 virtual bool EndOfData(void)
00199 {
00200 if(!MasterSource) return true;
00201 return MasterSource->EndOfData();
00202 }
00203
00205 virtual UInt8 GetGCEssenceType(void) { return 0x17; }
00206
00208 virtual UInt8 GetGCElementType(void) { return 0x01; }
00209
00211
00214 virtual Rational GetEditRate(void)
00215 {
00216 if(!MasterSource) return Rational(1,1);
00217 return MasterSource->GetEditRate();
00218 }
00219
00221
00225 virtual Position GetCurrentPosition(void)
00226 {
00227 return CurrentPosition;
00228 }
00229
00231 virtual int GetBERSize(void) { return 4; }
00232
00234 virtual bool IsPictureEssence(void) { return false; }
00235
00237 virtual bool IsSoundEssence(void) { return false; }
00238
00240 virtual bool IsDataEssence(void) { return true; }
00241
00243 virtual bool IsCompoundEssence(void) { return false; }
00244
00246
00269 virtual Int32 RelativeWriteOrder(void)
00270 {
00271
00272 return -1;
00273 }
00274
00276
00278 virtual int RelativeWriteOrderType(void)
00279 {
00280
00281 return 0x05;
00282 }
00283
00284 protected:
00286 DataChunkPtr BuildChunk(void);
00287 };
00288 }
00289
00290 #endif // MXFLIB__VBI_H