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

Function avifCodecSpecificOptionsSet

src/avif.c:1120–1154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1118}
1119
1120avifResult avifCodecSpecificOptionsSet(avifCodecSpecificOptions * csOptions, const char * key, const char * value)
1121{
1122 // Check to see if a key must be replaced
1123 for (uint32_t i = 0; i < csOptions->count; ++i) {
1124 avifCodecSpecificOption * entry = &csOptions->entries[i];
1125 if (!strcmp(entry->key, key)) {
1126 if (value) {
1127 // Update the value
1128 avifFree(entry->value);
1129 entry->value = avifStrdup(value);
1130 AVIF_CHECKERR(entry->value, AVIF_RESULT_OUT_OF_MEMORY);
1131 } else {
1132 // Delete the value
1133 avifFree(entry->key);
1134 avifFree(entry->value);
1135 --csOptions->count;
1136 if (csOptions->count > 0) {
1137 memmove(&csOptions->entries[i], &csOptions->entries[i + 1], (csOptions->count - i) * (size_t)csOptions->elementSize);
1138 }
1139 }
1140 return AVIF_RESULT_OK;
1141 }
1142 }
1143
1144 if (value) {
1145 // Add a new key
1146 avifCodecSpecificOption * entry = (avifCodecSpecificOption *)avifArrayPush(csOptions);
1147 AVIF_CHECKERR(entry, AVIF_RESULT_OUT_OF_MEMORY);
1148 entry->key = avifStrdup(key);
1149 AVIF_CHECKERR(entry->key, AVIF_RESULT_OUT_OF_MEMORY);
1150 entry->value = avifStrdup(value);
1151 AVIF_CHECKERR(entry->value, AVIF_RESULT_OUT_OF_MEMORY);
1152 }
1153 return AVIF_RESULT_OK;
1154}
1155
1156// ---------------------------------------------------------------------------
1157// Codec availability and versions

Callers 1

Calls 3

avifFreeFunction · 0.85
avifArrayPushFunction · 0.85
avifStrdupFunction · 0.70

Tested by

no test coverage detected