| 325 | avcodec_encode_session_t(avcodec_encode_session_t &&other) noexcept = default; |
| 326 | |
| 327 | ~avcodec_encode_session_t() { |
| 328 | // Flush any remaining frames in the encoder |
| 329 | if (avcodec_send_frame(avcodec_ctx.get(), nullptr) == 0) { |
| 330 | packet_raw_avcodec pkt; |
| 331 | while (avcodec_receive_packet(avcodec_ctx.get(), pkt.av_packet) == 0); |
| 332 | } |
| 333 | |
| 334 | // Order matters here because the context relies on the hwdevice still being valid |
| 335 | avcodec_ctx.reset(); |
| 336 | device.reset(); |
| 337 | } |
| 338 | |
| 339 | // Ensure objects are destroyed in the correct order |
| 340 | avcodec_encode_session_t &operator=(avcodec_encode_session_t &&other) { |