diff --git a/doc/APIchanges b/doc/APIchanges
index 34d788a706f8f8e491719d4ccffd9a4b73ab6eff..a251c4ca82a65ddec9417654c8b176caf8de00a0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,10 @@ libavutil:     2017-03-23
 
 API changes, most recent first:
 
+2017-04-30 - xxxxxxx - lavu 56.1.1 - hwcontext.h
+  av_hwframe_ctx_create_derived() now takes some AV_HWFRAME_MAP_* combination
+  as its flags argument (which was previously unused).
+
 2017-04-xx - xxxxxxx - lavu 56.1.0 - spherical.h
   Add av_spherical_projection_name() and av_spherical_from_name().
 
diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index a6d88421d8bb9406744d5f2b65d5e81e806f62e7..360b01205c286980c8b0f4a87599594e5ac2537f 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -455,6 +455,11 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
         // and map the frame immediately.
         AVFrame *src_frame;
 
+        frame->format = ctx->format;
+        frame->hw_frames_ctx = av_buffer_ref(hwframe_ref);
+        if (!frame->hw_frames_ctx)
+            return AVERROR(ENOMEM);
+
         src_frame = av_frame_alloc();
         if (!src_frame)
             return AVERROR(ENOMEM);
@@ -464,7 +469,8 @@ int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
         if (ret < 0)
             return ret;
 
-        ret = av_hwframe_map(frame, src_frame, 0);
+        ret = av_hwframe_map(frame, src_frame,
+                             ctx->internal->source_allocation_map_flags);
         if (ret) {
             av_log(ctx, AV_LOG_ERROR, "Failed to map frame into derived "
                    "frame context: %d.\n", ret);
@@ -816,6 +822,12 @@ int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx,
         goto fail;
     }
 
+    dst->internal->source_allocation_map_flags =
+        flags & (AV_HWFRAME_MAP_READ      |
+                 AV_HWFRAME_MAP_WRITE     |
+                 AV_HWFRAME_MAP_OVERWRITE |
+                 AV_HWFRAME_MAP_DIRECT);
+
     ret = AVERROR(ENOSYS);
     if (src->internal->hw_type->frames_derive_from)
         ret = src->internal->hw_type->frames_derive_from(dst, src, flags);
diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index 889e30365ee13604390c63218110bb4476c6ae2a..eaf40c46f16547bccea3667262df80fb0e714f19 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -564,7 +564,9 @@ int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags);
  *                           AVHWFramesContext on.
  * @param source_frame_ctx   A reference to an existing AVHWFramesContext
  *                           which will be mapped to the derived context.
- * @param flags  Currently unused; should be set to zero.
+ * @param flags  Some combination of AV_HWFRAME_MAP_* flags, defining the
+ *               mapping parameters to apply to frames which are allocated
+ *               in the derived device.
  * @return       Zero on success, negative AVERROR code on failure.
  */
 int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx,
diff --git a/libavutil/hwcontext_internal.h b/libavutil/hwcontext_internal.h
index 87b32e191e9f3dcc1d724260da3c808b258ad8eb..7cf6cb07c7145d24eb789c46ef72c9a500a7566e 100644
--- a/libavutil/hwcontext_internal.h
+++ b/libavutil/hwcontext_internal.h
@@ -121,6 +121,11 @@ struct AVHWFramesInternal {
      * context it was derived from.
      */
     AVBufferRef *source_frames;
+    /**
+     * Flags to apply to the mapping from the source to the derived
+     * frame context when trying to allocate in the derived context.
+     */
+    int source_allocation_map_flags;
 };
 
 typedef struct HWMapDescriptor {
diff --git a/libavutil/version.h b/libavutil/version.h
index fd72ff431d7fdb405b6f0477f17ee258fbc4d66c..7779755870ae29ab2813f4377bb3c48ae00258c6 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -55,7 +55,7 @@
 
 #define LIBAVUTIL_VERSION_MAJOR 56
 #define LIBAVUTIL_VERSION_MINOR  1
-#define LIBAVUTIL_VERSION_MICRO  0
+#define LIBAVUTIL_VERSION_MICRO  1
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
                                                LIBAVUTIL_VERSION_MINOR, \