~ubuntu-branches/ubuntu/oneiric/faac/oneiric

« back to all changes in this revision

Viewing changes to common/mp4v2/mp4property.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2011-06-09 12:00:51 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110609120051-03a45t9zrp0xiu9k
Tags: 1.28-0ubuntu1
* New upstream release. Package based on Debian Multimedia team git.
  (LP: #395902)
* debian/copyright documents all applicable licenses. The package as a whole
  is not LGPL and will stay in multiverse. (LP: #374900)
* Back to using a bundled internal copy of libmp4v2 in the frontend. The
  external libmp4v2 will eventually be removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
150
150
                return;
151
151
        }
152
152
        Indent(pFile, indent);
153
 
        fprintf(pFile, "%s = %u (0x%02x)\n", 
154
 
                m_name, m_values[index], m_values[index]);
 
153
        if (index != 0) 
 
154
          fprintf(pFile, "%s[%u] = %u (0x%02x)\n", 
 
155
                  m_name, index, m_values[index], m_values[index]);
 
156
        else
 
157
          fprintf(pFile, "%s = %u (0x%02x)\n", 
 
158
                  m_name, m_values[index], m_values[index]);
 
159
        fflush(pFile);
155
160
}
156
161
 
157
162
void MP4Integer16Property::Dump(FILE* pFile, u_int8_t indent,
161
166
                return;
162
167
        }
163
168
        Indent(pFile, indent);
164
 
        fprintf(pFile, "%s = %u (0x%04x)\n", 
165
 
                m_name, m_values[index], m_values[index]);
 
169
        if (index != 0) 
 
170
          fprintf(pFile, "%s[%u] = %u (0x%04x)\n", 
 
171
                  m_name, index, m_values[index], m_values[index]);
 
172
        else
 
173
          fprintf(pFile, "%s = %u (0x%04x)\n", 
 
174
                  m_name, m_values[index], m_values[index]);
 
175
        fflush(pFile);
166
176
}
167
177
 
168
178
void MP4Integer24Property::Dump(FILE* pFile, u_int8_t indent,
172
182
                return;
173
183
        }
174
184
        Indent(pFile, indent);
175
 
        fprintf(pFile, "%s = %u (0x%06x)\n", 
176
 
                m_name, m_values[index], m_values[index]);
 
185
        if (index != 0) 
 
186
          fprintf(pFile, "%s[%u] = %u (0x%06x)\n", 
 
187
                  m_name, index, m_values[index], m_values[index]);
 
188
        else
 
189
          fprintf(pFile, "%s = %u (0x%06x)\n", 
 
190
                  m_name, m_values[index], m_values[index]);
 
191
        fflush(pFile);
177
192
}
178
193
 
179
194
void MP4Integer32Property::Dump(FILE* pFile, u_int8_t indent,
183
198
                return;
184
199
        }
185
200
        Indent(pFile, indent);
186
 
        fprintf(pFile, "%s = %u (0x%08x)\n", 
 
201
        if (index != 0) 
 
202
          fprintf(pFile, "%s[%u] = %u (0x%08x)\n", 
 
203
                  m_name, index, m_values[index], m_values[index]);
 
204
        else
 
205
          fprintf(pFile, "%s = %u (0x%08x)\n", 
187
206
                m_name, m_values[index], m_values[index]);
 
207
        fflush(pFile);
188
208
}
189
209
 
190
210
void MP4Integer64Property::Dump(FILE* pFile, u_int8_t indent,
194
214
                return;
195
215
        }
196
216
        Indent(pFile, indent);
197
 
        fprintf(pFile, 
198
 
                "%s = "U64" (0x%016"X64F")\n", 
199
 
                m_name, m_values[index], m_values[index]);
 
217
        if (index != 0) 
 
218
          fprintf(pFile, "%s[%u] = "U64" (0x%016"X64F")\n", 
 
219
                  m_name, index, m_values[index], m_values[index]);
 
220
        else
 
221
          fprintf(pFile, 
 
222
                  "%s = "U64" (0x%016"X64F")\n", 
 
223
                  m_name, m_values[index], m_values[index]);
 
224
        fflush(pFile);
200
225
}
201
226
 
202
227
// MP4BitfieldProperty
229
254
        if (hexWidth == 0 || (m_numBits % 4)) {
230
255
                hexWidth++;
231
256
        }
 
257
        if (index != 0) 
232
258
        fprintf(pFile, 
233
 
                "%s = "U64" (0x%0*"X64F") <%u bits>\n", 
234
 
                m_name, m_values[index], (int)hexWidth, m_values[index], m_numBits);
 
259
                "%s[%u] = "U64" (0x%0*"X64F") <%u bits>\n", 
 
260
                m_name, index, m_values[index], (int)hexWidth, m_values[index], m_numBits);
 
261
        else 
 
262
          fprintf(pFile, 
 
263
                  "%s = "U64" (0x%0*"X64F") <%u bits>\n", 
 
264
                  m_name, m_values[index], (int)hexWidth, m_values[index], m_numBits);
 
265
        fflush(pFile);
235
266
}
236
267
 
237
268
// MP4Float32Property
271
302
                return;
272
303
        }
273
304
        Indent(pFile, indent);
274
 
        fprintf(pFile, "%s = %f\n", 
275
 
                m_name, m_values[index]);
 
305
        if (index != 0) 
 
306
          fprintf(pFile, "%s[%u] = %f\n", 
 
307
                  m_name, index, m_values[index]);
 
308
        else
 
309
          fprintf(pFile, "%s = %f\n", 
 
310
                  m_name, m_values[index]);
 
311
        fflush(pFile);
276
312
}
277
313
 
278
314
// MP4StringProperty
279
315
 
280
 
MP4StringProperty::MP4StringProperty(char* name, 
 
316
MP4StringProperty::MP4StringProperty(const char* name,
281
317
        bool useCountedFormat, bool useUnicode)
282
318
        : MP4Property(name)
283
319
{
369
405
                return;
370
406
        }
371
407
        Indent(pFile, indent);
 
408
        char indexd[32];
 
409
        if (index != 0) {
 
410
          snprintf(indexd, 32, "[%u]", index);
 
411
        } else indexd[0] = '\0';
 
412
 
372
413
        if (m_useUnicode) {
373
 
                fprintf(pFile, "%s = %ls\n", m_name, (wchar_t*)m_values[index]);
 
414
          fprintf(pFile, "%s%s = %ls\n", m_name, indexd, (wchar_t*)m_values[index]);
374
415
        } else {
375
 
                fprintf(pFile, "%s = %s\n", m_name, m_values[index]);
 
416
          fprintf(pFile, "%s%s = %s\n", m_name, indexd, m_values[index]);
376
417
        }
 
418
        fflush(pFile);
377
419
}
378
420
 
379
421
// MP4BytesProperty
380
422
 
381
 
MP4BytesProperty::MP4BytesProperty(char* name, u_int32_t valueSize,
 
423
MP4BytesProperty::MP4BytesProperty(const char* name, u_int32_t valueSize,
382
424
                                   u_int32_t defaultValueSize)
383
425
        : MP4Property(name)
384
426
{
418
460
        }
419
461
        if (m_fixedValueSize) {
420
462
                if (valueSize > m_fixedValueSize) {
421
 
                        throw new MP4Error("value size exceeds fixed value size",
422
 
                                "MP4BytesProperty::SetValue");
 
463
                        throw new MP4Error("%s.%s value size %d exceeds fixed value size %d",
 
464
                                           "MP4BytesProperty::SetValue",
 
465
                                           GetParentAtom()->GetType(),
 
466
                                           GetName(),
 
467
                                           valueSize, 
 
468
                                           m_fixedValueSize);
423
469
                }
424
470
                if (m_values[index] == NULL) {
425
471
                        m_values[index] = (u_int8_t*)MP4Calloc(m_fixedValueSize);
487
533
                return;
488
534
        }
489
535
        Indent(pFile, indent);
490
 
        fprintf(pFile, "%s = <%u bytes> ", m_name, m_valueSizes[index]);
 
536
        fputs(m_name, pFile);
 
537
        if (index != 0) fprintf(pFile, "[%u]", index);
 
538
        fprintf(pFile, " = <%u bytes> ", m_valueSizes[index]);
491
539
        for (u_int32_t i = 0; i < m_valueSizes[index]; i++) {
492
540
                if ((i % 16) == 0 && m_valueSizes[index] > 16) {
493
541
                        fprintf(pFile, "\n");
496
544
                fprintf(pFile, "%02x ", m_values[index][i]);
497
545
        }
498
546
        fprintf(pFile, "\n");
 
547
        fflush(pFile);
499
548
}
500
549
 
501
550
// MP4TableProperty
502
551
 
503
 
MP4TableProperty::MP4TableProperty(char* name, MP4Property* pCountProperty)
 
552
MP4TableProperty::MP4TableProperty(const char* name, MP4IntegerProperty* pCountProperty)
504
553
        : MP4Property(name) 
505
554
{
506
 
        ASSERT(pCountProperty->GetType() == Integer8Property
507
 
                || pCountProperty->GetType() == Integer32Property);
508
555
        m_pCountProperty = pCountProperty;
509
556
        m_pCountProperty->SetReadOnly();
510
557
}
629
676
 
630
677
        u_int32_t numEntries = GetCount();
631
678
 
632
 
        ASSERT(m_pProperties[0]->GetCount() == numEntries);
 
679
        if (m_pProperties[0]->GetCount() != numEntries) {
 
680
          fprintf(stderr, "%s %s \"%s\"table entries %u doesn't match count %u\n", 
 
681
                  GetParentAtom() != NULL ? GetParentAtom()->GetType() : "", 
 
682
                  GetName(), m_pProperties[0]->GetName(),
 
683
                  m_pProperties[0]->GetCount(), numEntries);
 
684
 
 
685
          ASSERT(m_pProperties[0]->GetCount() == numEntries);
 
686
        }
633
687
 
634
688
        for (u_int32_t i = 0; i < numEntries; i++) {
635
689
                WriteEntry(pFile, i);
671
725
 
672
726
// MP4DescriptorProperty
673
727
  
674
 
MP4DescriptorProperty::MP4DescriptorProperty(char* name, 
 
728
MP4DescriptorProperty::MP4DescriptorProperty(const char* name,
675
729
        u_int8_t tagsStart, u_int8_t tagsEnd, bool mandatory, bool onlyOne)
676
730
        : MP4Property(name) 
677
731
858
912
 
859
913
        if (m_name) {
860
914
                Indent(pFile, indent);
861
 
                fprintf(pFile, "%s\n", m_name);
 
915
                if (index != 0) 
 
916
                  fprintf(pFile, "%s[%u]\n", m_name, index);
 
917
                else
 
918
                  fprintf(pFile, "%s\n", m_name);
862
919
                indent++;
863
920
        }
864
921