]> git.sesse.net Git - ffmpeg/commitdiff
stereo3d: Support view type for frame sequence type
authorVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 25 Sep 2017 13:09:21 +0000 (15:09 +0200)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Tue, 28 Nov 2017 19:56:51 +0000 (14:56 -0500)
Implement detection in h264 and hevc and insertion in framepack filter.

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>
doc/APIchanges
libavcodec/h264_sei.c
libavcodec/h264_sei.h
libavcodec/h264_slice.c
libavcodec/hevc_sei.c
libavcodec/hevc_sei.h
libavcodec/hevcdec.c
libavfilter/vf_framepack.c
libavutil/stereo3d.h
libavutil/version.h

index 9f3a1f2465810403531bb63f947886f7695d20bd..a7ecbcdaaed4054d8e425a649ce9e3e24f9a6594 100644 (file)
@@ -13,6 +13,9 @@ libavutil:     2017-03-23
 
 API changes, most recent first:
 
+2017-xx-xx - xxxxxxx - lavu 56.7.0 - stereo3d.h
+  Add view field to AVStereo3D structure and AVStereo3DView enum.
+
 2017-xx-xx - xxxxxxx - lavc 58.5.0 - avcodec.h
   Add avcodec_get_hw_frames_parameters().
 
index 03fca9017f9d1a1be573681c532d50b9e899f9da..da5d33c36c8de4962855a67b884d9e8e8f17f3eb 100644 (file)
@@ -314,10 +314,11 @@ static int decode_frame_packing_arrangement(H264SEIFramePacking *h,
         h->quincunx_subsampling           = get_bits1(gb);
         h->content_interpretation_type    = get_bits(gb, 6);
 
-        // the following skips: spatial_flipping_flag, frame0_flipped_flag,
-        // field_views_flag, current_frame_is_frame0_flag,
+        // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
+        skip_bits(gb, 3);
+        h->current_frame_is_frame0_flag = get_bits1(gb);
         // frame0_self_contained_flag, frame1_self_contained_flag
-        skip_bits(gb, 6);
+        skip_bits(gb, 2);
 
         if (!h->quincunx_subsampling && h->arrangement_type != 5)
             skip_bits(gb, 16);      // frame[01]_grid_position_[xy]
index f6ac6034daac1dad606db7158bf27c5c8c34c62c..c3a19dd8319891c6b50fd2969ae932be4a63faab 100644 (file)
@@ -108,6 +108,7 @@ typedef struct H264SEIFramePacking {
     int arrangement_type;
     int content_interpretation_type;
     int quincunx_subsampling;
+    int current_frame_is_frame0_flag;
 } H264SEIFramePacking;
 
 typedef struct H264SEIDisplayOrientation {
index 5dd01d836e95b3f83d3fbe928dd82a00bf8259fb..1b968ebd509b2db1f3fe770c31fe7012a63ae1b4 100644 (file)
@@ -1112,6 +1112,13 @@ static int h264_export_frame_props(H264Context *h)
 
         if (fp->content_interpretation_type == 2)
             stereo->flags = AV_STEREO3D_FLAG_INVERT;
+
+        if (fp->arrangement_type == 5) {
+            if (fp->current_frame_is_frame0_flag)
+                stereo->view = AV_STEREO3D_VIEW_LEFT;
+            else
+                stereo->view = AV_STEREO3D_VIEW_RIGHT;
+        }
     }
 
     if (h->sei.display_orientation.present &&
index 0a5d4440bf4fb13916b491a5333f8739402216c7..2bf170601d7ba2d5a85a1b11351585e46ae810ef 100644 (file)
@@ -57,10 +57,11 @@ static int decode_nal_sei_frame_packing_arrangement(HEVCSEIFramePacking *s, GetB
         s->quincunx_subsampling           = get_bits1(gb);
         s->content_interpretation_type    = get_bits(gb, 6);
 
-        // the following skips spatial_flipping_flag frame0_flipped_flag
-        // field_views_flag current_frame_is_frame0_flag
-        // frame0_self_contained_flag frame1_self_contained_flag
-        skip_bits(gb, 6);
+        // spatial_flipping_flag, frame0_flipped_flag, field_views_flag
+        skip_bits(gb, 3);
+        s->current_frame_is_frame0_flag = get_bits1(gb);
+        // frame0_self_contained_flag, frame1_self_contained_flag
+        skip_bits(gb, 2);
 
         if (!s->quincunx_subsampling && s->arrangement_type != 5)
             skip_bits(gb, 16);  // frame[01]_grid_position_[xy]
index e4aeac1fbe02e46c44e50eef789ad2a0f6d1ea7d..8d4f5df69f9dd086f9d3f751a80f06e37dd1876c 100644 (file)
@@ -67,6 +67,7 @@ typedef struct HEVCSEIFramePacking {
     int arrangement_type;
     int content_interpretation_type;
     int quincunx_subsampling;
+    int current_frame_is_frame0_flag;
 } HEVCSEIFramePacking;
 
 typedef struct HEVCSEIDisplayOrientation {
index a1619cf4bd944a82eeb7306f084577890ea86c26..f1d1c774977fb684e4c6d84958144db96483e5f3 100644 (file)
@@ -2397,6 +2397,13 @@ static int set_side_data(HEVCContext *s)
 
         if (s->sei.frame_packing.content_interpretation_type == 2)
             stereo->flags = AV_STEREO3D_FLAG_INVERT;
+
+        if (s->sei.frame_packing.arrangement_type == 5) {
+            if (s->sei.frame_packing.current_frame_is_frame0_flag)
+                stereo->view = AV_STEREO3D_VIEW_LEFT;
+            else
+                stereo->view = AV_STEREO3D_VIEW_RIGHT;
+        }
     }
 
     if (s->sei.display_orientation.present &&
index fd0c1897d55631f29af526b2c443a7dc8f56c168..64457b450144c65e631cd947b407819eb7ce623d 100644 (file)
@@ -310,6 +310,8 @@ static int request_frame(AVFilterLink *outlink)
             if (!stereo)
                 return AVERROR(ENOMEM);
             stereo->type = s->format;
+            stereo->view = i == LEFT ? AV_STEREO3D_VIEW_LEFT
+                                     : AV_STEREO3D_VIEW_RIGHT;
 
             // filter the frame and immediately relinquish its pointer
             ret = ff_filter_frame(outlink, s->input_views[i]);
index 0fa9f63a2ca63076924ecb3829cb8ab1167f3470..2d7cb8d4aad6c9a0793431a81d1f6721418629eb 100644 (file)
@@ -141,6 +141,25 @@ enum AVStereo3DType {
     AV_STEREO3D_COLUMNS,
 };
 
+/**
+ * List of possible view types.
+ */
+enum AVStereo3DView {
+    /**
+     * Frame contains two packed views.
+     */
+    AV_STEREO3D_VIEW_PACKED,
+
+    /**
+     * Frame contains only the left view.
+     */
+    AV_STEREO3D_VIEW_LEFT,
+
+    /**
+     * Frame contains only the right view.
+     */
+    AV_STEREO3D_VIEW_RIGHT,
+};
 
 /**
  * Inverted views, Right/Bottom represents the left view.
@@ -164,6 +183,11 @@ typedef struct AVStereo3D {
      * Additional information about the frame packing.
      */
     int flags;
+
+    /**
+     * Determines which views are packed.
+     */
+    enum AVStereo3DView view;
 } AVStereo3D;
 
 /**
index c258968b8e2f6fa079ab9201293145086fdcd1be..4a9fffef43303c84df9f568d1cdb3679ef11f6c0 100644 (file)
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 56
-#define LIBAVUTIL_VERSION_MINOR  6
+#define LIBAVUTIL_VERSION_MINOR  7
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \