| 1348 | } |
| 1349 | |
| 1350 | static 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 |
no test coverage detected