Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 10 mois
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #include "mov-internal.h"
  2. #include <errno.h>
  3. #include <stdlib.h>
  4. #include <assert.h>
  5. // 8.7.4 Sample To Chunk Box (p57)
  6. /*
  7. aligned(8) class SampleToChunkBox extends FullBox('stsc', version = 0, 0) {
  8. unsigned int(32) entry_count;
  9. for (i=1; i <= entry_count; i++) {
  10. unsigned int(32) first_chunk;
  11. unsigned int(32) samples_per_chunk;
  12. unsigned int(32) sample_description_index;
  13. }
  14. }
  15. */
  16. int mov_read_stsc(struct mov_t* mov, const struct mov_box_t* box)
  17. {
  18. uint32_t i, entry_count;
  19. struct mov_stbl_t* stbl = &mov->track->stbl;
  20. mov_buffer_r8(&mov->io); /* version */
  21. mov_buffer_r24(&mov->io); /* flags */
  22. entry_count = mov_buffer_r32(&mov->io);
  23. assert(0 == stbl->stsc_count && NULL == stbl->stsc); // duplicated STSC atom
  24. if (stbl->stsc_count < entry_count)
  25. {
  26. void* p = realloc(stbl->stsc, sizeof(struct mov_stsc_t) * (entry_count + 1/*stco count*/));
  27. if (NULL == p) return -ENOMEM;
  28. stbl->stsc = (struct mov_stsc_t*)p;
  29. }
  30. stbl->stsc_count = entry_count;
  31. for (i = 0; i < entry_count; i++)
  32. {
  33. stbl->stsc[i].first_chunk = mov_buffer_r32(&mov->io);
  34. stbl->stsc[i].samples_per_chunk = mov_buffer_r32(&mov->io);
  35. stbl->stsc[i].sample_description_index = mov_buffer_r32(&mov->io);
  36. }
  37. (void)box;
  38. return mov_buffer_error(&mov->io);
  39. }
  40. size_t mov_write_stsc(const struct mov_t* mov)
  41. {
  42. uint64_t offset;
  43. uint64_t offset2;
  44. uint32_t size, i, entry;
  45. const struct mov_sample_t* chunk = NULL;
  46. const struct mov_sample_t* sample = NULL;
  47. const struct mov_track_t* track = mov->track;
  48. size = 12/* full box */ + 4/* entry count */;
  49. offset = mov_buffer_tell(&mov->io);
  50. mov_buffer_w32(&mov->io, 0); /* size */
  51. mov_buffer_write(&mov->io, "stsc", 4);
  52. mov_buffer_w32(&mov->io, 0); /* version & flags */
  53. mov_buffer_w32(&mov->io, 0); /* entry count */
  54. for (i = 0, entry = 0; i < track->sample_count; i++)
  55. {
  56. sample = &track->samples[i];
  57. if (0 == sample->first_chunk ||
  58. (chunk && chunk->samples_per_chunk == sample->samples_per_chunk
  59. && chunk->sample_description_index == sample->sample_description_index))
  60. continue;
  61. ++entry;
  62. chunk = sample;
  63. mov_buffer_w32(&mov->io, sample->first_chunk);
  64. mov_buffer_w32(&mov->io, sample->samples_per_chunk);
  65. mov_buffer_w32(&mov->io, sample->sample_description_index);
  66. }
  67. size += entry * 12/* entry size*/;
  68. offset2 = mov_buffer_tell(&mov->io);
  69. mov_buffer_seek(&mov->io, offset);
  70. mov_buffer_w32(&mov->io, size); /* size */
  71. mov_buffer_seek(&mov->io, offset + 12);
  72. mov_buffer_w32(&mov->io, entry); /* entry count */
  73. mov_buffer_seek(&mov->io, offset2);
  74. return size;
  75. }