diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 8b03f61a22b5a27425c6d4111b00b2ec78e9894a..44b874d4f817d2fe8f2b79e8b627c910cbc09526 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1581,6 +1581,9 @@ static void decode_data_free(void *opaque, uint8_t *data)
     if (fdd->post_process_opaque_free)
         fdd->post_process_opaque_free(fdd->post_process_opaque);
 
+    if (fdd->hwaccel_priv_free)
+        fdd->hwaccel_priv_free(fdd->hwaccel_priv);
+
     av_freep(&fdd);
 }
 
diff --git a/libavcodec/decode.h b/libavcodec/decode.h
index 51947b9ec08ca986396175f5ed06df73867dcf7f..03fc783bba308f0e65413166fd44a29c0dfbb98c 100644
--- a/libavcodec/decode.h
+++ b/libavcodec/decode.h
@@ -44,6 +44,12 @@ typedef struct FrameDecodeData {
     int (*post_process)(void *logctx, AVFrame *frame);
     void *post_process_opaque;
     void (*post_process_opaque_free)(void *opaque);
+
+    /**
+     * Per-frame private data for hwaccels.
+     */
+    void *hwaccel_priv;
+    void (*hwaccel_priv_free)(void *priv);
 } FrameDecodeData;
 
 /**