From 1f8ddde027f9da9dc32a7e33bd50c970c562946b Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Fri, 26 Sep 2025 09:54:56 +0900
Subject: Fix location of call to avcodec_close for old version of libavcodec

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 k9author/k9avidecode.cpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/k9author/k9avidecode.cpp b/k9author/k9avidecode.cpp
index 4b34608..e79cb14 100644
--- a/k9author/k9avidecode.cpp
+++ b/k9author/k9avidecode.cpp
@@ -290,13 +290,6 @@ void k9AviDecode::close() {
         // Free the YUV frame
         av_free(m_Frame);
 
-        // Close the video file
-#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 17, 0)
-        avformat_close_input(&m_FormatCtx);
-#else
-        av_close_input_file(m_FormatCtx);
-#endif
-
         // Close the codec
 #if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 33, 100)
         avcodec_free_context(&m_CodecCtx);
@@ -304,6 +297,13 @@ void k9AviDecode::close() {
         avcodec_close(m_CodecCtx);
 #endif
 
+        // Close the video file
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 17, 0)
+        avformat_close_input(&m_FormatCtx);
+#else
+        av_close_input_file(m_FormatCtx);
+#endif
+
         m_opened=false;
     }
 }
-- 
cgit v1.2.3

