MCPcopy Create free account
hub / github.com/AOMediaCodec/libavif / avifRWStreamWriteFullBox

Function avifRWStreamWriteFullBox

src/stream.c:397–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397avifResult avifRWStreamWriteFullBox(avifRWStream * stream, const char * type, size_t contentSize, int version, uint32_t flags, avifBoxMarker * marker)
398{
399 assert(stream->numUsedBitsInPartialByte == 0); // Byte alignment is required.
400 if (marker) {
401 *marker = stream->offset;
402 }
403 size_t headerSize = sizeof(uint32_t) + 4 /* size of type */;
404 if (version != -1) {
405 headerSize += 4;
406 }
407
408 AVIF_CHECKRES(makeRoom(stream, headerSize));
409 memset(stream->raw->data + stream->offset, 0, headerSize);
410 uint32_t noSize = avifHTONL((uint32_t)(headerSize + contentSize));
411 memcpy(stream->raw->data + stream->offset, &noSize, sizeof(uint32_t));
412 memcpy(stream->raw->data + stream->offset + 4, type, 4);
413 if (version != -1) {
414 stream->raw->data[stream->offset + 8] = (uint8_t)version;
415 stream->raw->data[stream->offset + 9] = (uint8_t)((flags >> 16) & 0xff);
416 stream->raw->data[stream->offset + 10] = (uint8_t)((flags >> 8) & 0xff);
417 stream->raw->data[stream->offset + 11] = (uint8_t)((flags >> 0) & 0xff);
418 }
419 stream->offset += headerSize;
420
421 return AVIF_RESULT_OK;
422}
423
424avifResult avifRWStreamWriteBox(avifRWStream * stream, const char * type, size_t contentSize, avifBoxMarker * marker)
425{

Callers 7

avifRWStreamWriteBoxFunction · 0.85
avifWriteAltrGroupFunction · 0.85
avifEncoderFinishFunction · 0.85
TESTFunction · 0.85

Calls 2

makeRoomFunction · 0.85
avifHTONLFunction · 0.85

Tested by 1

TESTFunction · 0.68