You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0KB

  1. #include "mov-internal.h"
  2. #include <assert.h>
  3. #include <stdlib.h>
  4. #include <errno.h>
  5. // https://aomediacodec.github.io/av1-isobmff
  6. // extra data: AV1CodecConfigurationRecord
  7. int mov_read_av1c(struct mov_t* mov, const struct mov_box_t* box)
  8. {
  9. struct mov_track_t* track = mov->track;
  10. struct mov_sample_entry_t* entry = track->stsd.current;
  11. if (entry->extra_data_size < box->size)
  12. {
  13. void* p = realloc(entry->extra_data, (size_t)box->size);
  14. if (NULL == p) return -ENOMEM;
  15. entry->extra_data = p;
  16. }
  17. mov_buffer_read(&mov->io, entry->extra_data, box->size);
  18. entry->extra_data_size = (int)box->size;
  19. return mov_buffer_error(&mov->io);
  20. }
  21. size_t mov_write_av1c(const struct mov_t* mov)
  22. {
  23. const struct mov_track_t* track = mov->track;
  24. const struct mov_sample_entry_t* entry = track->stsd.current;
  25. mov_buffer_w32(&mov->io, entry->extra_data_size + 8); /* size */
  26. mov_buffer_write(&mov->io, "av1C", 4);
  27. if (entry->extra_data_size > 0)
  28. mov_buffer_write(&mov->io, entry->extra_data, entry->extra_data_size);
  29. return entry->extra_data_size + 8;
  30. }