]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
vaapi improvements
authorUkn Unknown <4031821+uknunknown@users.noreply.github.com>
Wed, 18 Jun 2025 00:19:34 +0000 (17:19 -0700)
committerFlole <Flole998@users.noreply.github.com>
Thu, 21 Aug 2025 15:26:12 +0000 (17:26 +0200)
- remove all '=NULL' because are not required
- keep first call for vaapi_encode_close_context() and remove the second call

src/transcoding/transcode/context.c
src/transcoding/transcode/hwaccels/vaapi.c
src/transcoding/transcode/transcoder.c

index 09f935ed7459cbd71c566dccadfa50acb12cd5c8..6d939e8f034e434cb0299f65d7e406cce35006e6 100644 (file)
@@ -756,7 +756,6 @@ void
 tvh_context_destroy(TVHContext *self)
 {
     if (self) {
-        tvh_context_close(self, 0);
         TVHPKT_CLEAR(self->src_pkt);
         if (self->avfltgraph) {
             avfilter_graph_free(&self->avfltgraph); // frees filter contexts
index 9174b7e707f6c56dcccbd712a6ff570be613c8b6..15473773efa2b73aaa76a2ebb860fe08375fe260 100644 (file)
@@ -50,7 +50,6 @@ tvhva_context_destroy(TVHVAContext *self)
     if (self) {
         if (self->hw_device_ref) {
             av_buffer_unref(&self->hw_device_ref);
-            self->hw_device_ref = NULL;
         }
         free(self);
         self = NULL;
@@ -676,7 +675,6 @@ vaapi_decode_close_context(AVCodecContext *avctx)
 #if ENABLE_FFMPEG4_TRANSCODING
     if (avctx->hw_device_ctx) {
         av_buffer_unref(&avctx->hw_device_ctx);
-        avctx->hw_device_ctx = NULL;
     }
 #endif
     tvhva_context_destroy(ctx->hw_accel_ictx);
@@ -820,16 +818,17 @@ void
 vaapi_encode_close_context(AVCodecContext *avctx)
 {
     TVHContext *ctx = avctx->opaque;
-    av_buffer_unref(&ctx->hw_device_octx);
-    ctx->hw_device_octx = NULL;
+    // hw_device_octx is initialized for software decoding (line 764)
+    if (ctx->hw_device_octx) {
+        av_buffer_unref(&ctx->hw_device_octx);
+    }
 #if ENABLE_FFMPEG4_TRANSCODING
+    // avctx->hw_device_ctx is cleaned up only if ffmpeg exit with error and didn't perform the clean up
     if (avctx->hw_device_ctx) {
         av_buffer_unref(&avctx->hw_device_ctx);
-        avctx->hw_device_ctx = NULL;
     }
     if (avctx->hw_frames_ctx) {
         av_buffer_unref(&avctx->hw_frames_ctx);
-        avctx->hw_frames_ctx = NULL;
     }
 #endif
 }
index d3657681d93368ace26db98ffe6f0c2d947b37b1..52fe227c634e2de6215efd70d38ff9aac66bfc8d 100644 (file)
@@ -294,6 +294,7 @@ tvh_transcoder_stream(void *opaque, tvh_sm_t *msg)
             streaming_target_deliver2(self->output, msg);
             break;
         case SMT_STOP:
+            // this will trigger tvh_context_close_meth()
             tvh_transcoder_stop(self, 1);
             /* !!! FALLTHROUGH !!! */
         default: