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

Function aomCodecEncodeFinish

src/codec_aom.c:1350–1387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1348}
1349
1350static avifBool aomCodecEncodeFinish(avifCodec * codec, avifCodecEncodeOutput * output)
1351{
1352 if (!codec->internal->encoderInitialized) {
1353 return AVIF_TRUE;
1354 }
1355 for (;;) {
1356 // flush encoder
1357 if (aom_codec_encode(&codec->internal->encoder, NULL, 0, 1, 0) != AOM_CODEC_OK) {
1358 aomDiagPrintf(codec->diag, "aom_codec_encode() with img=NULL", &codec->internal->encoder);
1359 return AVIF_FALSE;
1360 }
1361
1362 avifBool gotPacket = AVIF_FALSE;
1363 aom_codec_iter_t iter = NULL;
1364 for (;;) {
1365 const aom_codec_cx_pkt_t * pkt = aom_codec_get_cx_data(&codec->internal->encoder, &iter);
1366 if (pkt == NULL) {
1367 break;
1368 }
1369 if (pkt->kind == AOM_CODEC_CX_FRAME_PKT) {
1370 gotPacket = AVIF_TRUE;
1371 const avifResult result = avifCodecEncodeOutputAddSample(output,
1372 pkt->data.frame.buf,
1373 pkt->data.frame.sz,
1374 (pkt->data.frame.flags & AOM_FRAME_IS_KEY));
1375 if (result != AVIF_RESULT_OK) {
1376 avifDiagnosticsPrintf(codec->diag, "avifCodecEncodeOutputAddSample() failed: %s", avifResultToString(result));
1377 return AVIF_FALSE;
1378 }
1379 }
1380 }
1381
1382 if (!gotPacket) {
1383 break;
1384 }
1385 }
1386 return AVIF_TRUE;
1387}
1388
1389#endif // defined(AVIF_CODEC_AOM_ENCODE)
1390

Callers 1

aomCodecEncodeImageFunction · 0.85

Calls 4

aomDiagPrintfFunction · 0.85
avifDiagnosticsPrintfFunction · 0.85
avifResultToStringFunction · 0.85

Tested by

no test coverage detected