| 995 | } |
| 996 | |
| 997 | static avifBool avmCodecEncodeFinish(avifCodec * codec, avifCodecEncodeOutput * output) |
| 998 | { |
| 999 | if (!codec->internal->encoderInitialized) { |
| 1000 | return AVIF_TRUE; |
| 1001 | } |
| 1002 | for (;;) { |
| 1003 | // flush encoder |
| 1004 | if (avm_codec_encode(&codec->internal->encoder, NULL, 0, 1, 0) != AVM_CODEC_OK) { |
| 1005 | avifDiagnosticsPrintf(codec->diag, |
| 1006 | "avm_codec_encode() with img=NULL failed: %s: %s", |
| 1007 | avm_codec_error(&codec->internal->encoder), |
| 1008 | avm_codec_error_detail(&codec->internal->encoder)); |
| 1009 | return AVIF_FALSE; |
| 1010 | } |
| 1011 | |
| 1012 | avifBool gotPacket = AVIF_FALSE; |
| 1013 | avm_codec_iter_t iter = NULL; |
| 1014 | for (;;) { |
| 1015 | const avm_codec_cx_pkt_t * pkt = avm_codec_get_cx_data(&codec->internal->encoder, &iter); |
| 1016 | if (pkt == NULL) { |
| 1017 | break; |
| 1018 | } |
| 1019 | if (pkt->kind == AVM_CODEC_CX_FRAME_PKT) { |
| 1020 | gotPacket = AVIF_TRUE; |
| 1021 | const avifResult result = avifCodecEncodeOutputAddSample(output, |
| 1022 | pkt->data.frame.buf, |
| 1023 | pkt->data.frame.sz, |
| 1024 | (pkt->data.frame.flags & AVM_FRAME_IS_KEY)); |
| 1025 | if (result != AVIF_RESULT_OK) { |
| 1026 | avifDiagnosticsPrintf(codec->diag, "avifCodecEncodeOutputAddSample() failed: %s", avifResultToString(result)); |
| 1027 | return AVIF_FALSE; |
| 1028 | } |
| 1029 | } |
| 1030 | } |
| 1031 | |
| 1032 | if (!gotPacket) { |
| 1033 | break; |
| 1034 | } |
| 1035 | } |
| 1036 | return AVIF_TRUE; |
| 1037 | } |
| 1038 | |
| 1039 | const char * avifCodecVersionAVM(void) |
| 1040 | { |
no test coverage detected