[FFmpeg-devel] [PATCH 11/20] avcodec/h264_sei, sei: Make H264_SEI_FpaType generic

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Jul 3 01:21:51 EEST 2022


Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/h2645_sei.h  |  2 +-
 libavcodec/h264_sei.c   | 14 +++++++-------
 libavcodec/h264_sei.h   | 13 -------------
 libavcodec/h264_slice.c | 16 ++++++++--------
 libavcodec/sei.h        | 17 +++++++++++++++++
 5 files changed, 33 insertions(+), 29 deletions(-)

diff --git a/libavcodec/h2645_sei.h b/libavcodec/h2645_sei.h
index 4600caab29..4713b89e1f 100644
--- a/libavcodec/h2645_sei.h
+++ b/libavcodec/h2645_sei.h
@@ -57,7 +57,7 @@ typedef struct H2645SEIFramePacking {
     int present;
     int arrangement_id;
     int arrangement_cancel_flag;  ///< is previous arrangement canceled, -1 if never received (currently H.264 only)
-    int arrangement_type;
+    SEIFpaType arrangement_type;
     int arrangement_repetition_period;
     int content_interpretation_type;
     int quincunx_sampling_flag;
diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
index f11f8371f6..668204959f 100644
--- a/libavcodec/h264_sei.c
+++ b/libavcodec/h264_sei.c
@@ -307,37 +307,37 @@ const char *ff_h264_sei_stereo_mode(const H2645SEIFramePacking *h)
 {
     if (h->arrangement_cancel_flag == 0) {
         switch (h->arrangement_type) {
-            case H264_SEI_FPA_TYPE_CHECKERBOARD:
+            case SEI_FPA_H264_TYPE_CHECKERBOARD:
                 if (h->content_interpretation_type == 2)
                     return "checkerboard_rl";
                 else
                     return "checkerboard_lr";
-            case H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN:
+            case SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN:
                 if (h->content_interpretation_type == 2)
                     return "col_interleaved_rl";
                 else
                     return "col_interleaved_lr";
-            case H264_SEI_FPA_TYPE_INTERLEAVE_ROW:
+            case SEI_FPA_H264_TYPE_INTERLEAVE_ROW:
                 if (h->content_interpretation_type == 2)
                     return "row_interleaved_rl";
                 else
                     return "row_interleaved_lr";
-            case H264_SEI_FPA_TYPE_SIDE_BY_SIDE:
+            case SEI_FPA_TYPE_SIDE_BY_SIDE:
                 if (h->content_interpretation_type == 2)
                     return "right_left";
                 else
                     return "left_right";
-            case H264_SEI_FPA_TYPE_TOP_BOTTOM:
+            case SEI_FPA_TYPE_TOP_BOTTOM:
                 if (h->content_interpretation_type == 2)
                     return "bottom_top";
                 else
                     return "top_bottom";
-            case H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
+            case SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
                 if (h->content_interpretation_type == 2)
                     return "block_rl";
                 else
                     return "block_lr";
-            case H264_SEI_FPA_TYPE_2D:
+            case SEI_FPA_H264_TYPE_2D:
             default:
                 return "mono";
         }
diff --git a/libavcodec/h264_sei.h b/libavcodec/h264_sei.h
index 003f427ac3..bb9275e569 100644
--- a/libavcodec/h264_sei.h
+++ b/libavcodec/h264_sei.h
@@ -40,19 +40,6 @@ typedef enum {
     H264_SEI_PIC_STRUCT_FRAME_TRIPLING    = 8  ///<  8: %frame tripling
 } H264_SEI_PicStructType;
 
-/**
- * frame_packing_arrangement types
- */
-typedef enum {
-    H264_SEI_FPA_TYPE_CHECKERBOARD        = 0,
-    H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN   = 1,
-    H264_SEI_FPA_TYPE_INTERLEAVE_ROW      = 2,
-    H264_SEI_FPA_TYPE_SIDE_BY_SIDE        = 3,
-    H264_SEI_FPA_TYPE_TOP_BOTTOM          = 4,
-    H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL = 5,
-    H264_SEI_FPA_TYPE_2D                  = 6,
-} H264_SEI_FpaType;
-
 typedef struct H264SEITimeCode {
     /* When not continuously receiving full timecodes, we have to reference
        the previous timecode received */
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 18b9ae5b09..cd9f9bfa27 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -1234,28 +1234,28 @@ static int h264_export_frame_props(H264Context *h)
         AVStereo3D *stereo = av_stereo3d_create_side_data(out);
         if (stereo) {
         switch (fp->arrangement_type) {
-        case H264_SEI_FPA_TYPE_CHECKERBOARD:
+        case SEI_FPA_H264_TYPE_CHECKERBOARD:
             stereo->type = AV_STEREO3D_CHECKERBOARD;
             break;
-        case H264_SEI_FPA_TYPE_INTERLEAVE_COLUMN:
+        case SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN:
             stereo->type = AV_STEREO3D_COLUMNS;
             break;
-        case H264_SEI_FPA_TYPE_INTERLEAVE_ROW:
+        case SEI_FPA_H264_TYPE_INTERLEAVE_ROW:
             stereo->type = AV_STEREO3D_LINES;
             break;
-        case H264_SEI_FPA_TYPE_SIDE_BY_SIDE:
+        case SEI_FPA_TYPE_SIDE_BY_SIDE:
             if (fp->quincunx_sampling_flag)
                 stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
             else
                 stereo->type = AV_STEREO3D_SIDEBYSIDE;
             break;
-        case H264_SEI_FPA_TYPE_TOP_BOTTOM:
+        case SEI_FPA_TYPE_TOP_BOTTOM:
             stereo->type = AV_STEREO3D_TOPBOTTOM;
             break;
-        case H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
+        case SEI_FPA_TYPE_INTERLEAVE_TEMPORAL:
             stereo->type = AV_STEREO3D_FRAMESEQUENCE;
             break;
-        case H264_SEI_FPA_TYPE_2D:
+        case SEI_FPA_H264_TYPE_2D:
             stereo->type = AV_STEREO3D_2D;
             break;
         }
@@ -1263,7 +1263,7 @@ static int h264_export_frame_props(H264Context *h)
         if (fp->content_interpretation_type == 2)
             stereo->flags = AV_STEREO3D_FLAG_INVERT;
 
-        if (fp->arrangement_type == H264_SEI_FPA_TYPE_INTERLEAVE_TEMPORAL) {
+        if (fp->arrangement_type == SEI_FPA_TYPE_INTERLEAVE_TEMPORAL) {
             if (fp->current_frame_is_frame0_flag)
                 stereo->view = AV_STEREO3D_VIEW_LEFT;
             else
diff --git a/libavcodec/sei.h b/libavcodec/sei.h
index f13c37c308..f96b7b647b 100644
--- a/libavcodec/sei.h
+++ b/libavcodec/sei.h
@@ -137,4 +137,21 @@ enum SEIType {
     SEI_TYPE_SAMPLE_ASPECT_RATIO_INFO                    = 204,
 };
 
+/**
+ * frame_packing_arrangement types. H.265 and H.274 use only 3..5
+ * with all the other values being reserved. H.264 uses a few more values
+ * that are prefixed with SEI_FPA_H264 in the enum below.
+ *
+ * The semantics of the common values are the same for all standards.
+ */
+typedef enum {
+    SEI_FPA_H264_TYPE_CHECKERBOARD        = 0,
+    SEI_FPA_H264_TYPE_INTERLEAVE_COLUMN   = 1,
+    SEI_FPA_H264_TYPE_INTERLEAVE_ROW      = 2,
+    SEI_FPA_TYPE_SIDE_BY_SIDE             = 3,
+    SEI_FPA_TYPE_TOP_BOTTOM               = 4,
+    SEI_FPA_TYPE_INTERLEAVE_TEMPORAL      = 5,
+    SEI_FPA_H264_TYPE_2D                  = 6,
+} SEIFpaType;
+
 #endif /* AVCODEC_SEI_H */
-- 
2.34.1



More information about the ffmpeg-devel mailing list