[FFmpeg-devel] [PATCH 2/2] hevcdec: move SEI message parsing into a separate header

James Almer jamrial at gmail.com
Sun Apr 30 18:33:15 EEST 2017


It doesn't depend on hevcdec anymore.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/hevc_sei.c |  54 ++++++----------------
 libavcodec/hevc_sei.h | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++
 libavcodec/hevcdec.h  |  66 +-------------------------
 3 files changed, 140 insertions(+), 105 deletions(-)
 create mode 100644 libavcodec/hevc_sei.h

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index 1dc0674f81..1789d4fd4f 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -23,35 +23,8 @@
  */
 
 #include "golomb.h"
-#include "hevcdec.h"
-
-enum HEVC_SEI_TYPE {
-    SEI_TYPE_BUFFERING_PERIOD                     = 0,
-    SEI_TYPE_PICTURE_TIMING                       = 1,
-    SEI_TYPE_PAN_SCAN_RECT                        = 2,
-    SEI_TYPE_FILLER_PAYLOAD                       = 3,
-    SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35       = 4,
-    SEI_TYPE_USER_DATA_UNREGISTERED               = 5,
-    SEI_TYPE_RECOVERY_POINT                       = 6,
-    SEI_TYPE_SCENE_INFO                           = 9,
-    SEI_TYPE_FULL_FRAME_SNAPSHOT                  = 15,
-    SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
-    SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
-    SEI_TYPE_FILM_GRAIN_CHARACTERISTICS           = 19,
-    SEI_TYPE_POST_FILTER_HINT                     = 22,
-    SEI_TYPE_TONE_MAPPING_INFO                    = 23,
-    SEI_TYPE_FRAME_PACKING                        = 45,
-    SEI_TYPE_DISPLAY_ORIENTATION                  = 47,
-    SEI_TYPE_SOP_DESCRIPTION                      = 128,
-    SEI_TYPE_ACTIVE_PARAMETER_SETS                = 129,
-    SEI_TYPE_DECODING_UNIT_INFO                   = 130,
-    SEI_TYPE_TEMPORAL_LEVEL0_INDEX                = 131,
-    SEI_TYPE_DECODED_PICTURE_HASH                 = 132,
-    SEI_TYPE_SCALABLE_NESTING                     = 133,
-    SEI_TYPE_REGION_REFRESH_INFO                  = 134,
-    SEI_TYPE_MASTERING_DISPLAY_INFO               = 137,
-    SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO             = 144,
-};
+#include "hevc_ps.h"
+#include "hevc_sei.h"
 
 static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, GetBitContext *gb,
                                                void *logctx)
@@ -157,8 +130,8 @@ static int decode_nal_sei_display_orientation(HEVCSEIDisplayOrientation *s, GetB
     return 0;
 }
 
-static int decode_pic_timing(HEVCSEIContext *s, GetBitContext *gb, void *logctx,
-                             const HEVCParamSets *ps)
+static int decode_pic_timing(HEVCSEIContext *s, GetBitContext *gb,
+                             void *logctx, const HEVCParamSets *ps)
 {
     HEVCSEIPictureTiming *h = &s->picture_timing;
     HEVCSPS *sps;
@@ -267,7 +240,8 @@ static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEIContext *s,
     return 0;
 }
 
-static int active_parameter_sets(HEVCSEIContext *s, GetBitContext *gb, void *logctx)
+static int active_parameter_sets(HEVCSEIContext *s, GetBitContext *gb,
+                                 void *logctx)
 {
     int num_sps_ids_minus1;
     int i;
@@ -302,29 +276,29 @@ static int decode_nal_sei_prefix(GetBitContext *gb, void *logctx, HEVCSEIContext
     switch (type) {
     case 256:  // Mismatched value from HM 8.1
         return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb, logctx);
-    case SEI_TYPE_FRAME_PACKING:
+    case HEVC_SEI_TYPE_FRAME_PACKING:
         return decode_nal_sei_frame_packing_arrangement(&s->frame_packing,
                                                         gb, logctx);
-    case SEI_TYPE_DISPLAY_ORIENTATION:
+    case HEVC_SEI_TYPE_DISPLAY_ORIENTATION:
         return decode_nal_sei_display_orientation(&s->display_orientation,
                                                   gb, logctx);
-    case SEI_TYPE_PICTURE_TIMING:
+    case HEVC_SEI_TYPE_PICTURE_TIMING:
         {
             int ret = decode_pic_timing(s, gb, logctx, ps);
             av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
             skip_bits(gb, 8 * size);
             return ret;
         }
-    case SEI_TYPE_MASTERING_DISPLAY_INFO:
+    case HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO:
         return decode_nal_sei_mastering_display_info(&s->mastering_display,
                                                      gb, logctx);
-    case SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
+    case HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO:
         return decode_nal_sei_content_light_info(&s->content_light, gb, logctx);
-    case SEI_TYPE_ACTIVE_PARAMETER_SETS:
+    case HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS:
         active_parameter_sets(s, gb, logctx);
         av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
         return 0;
-    case SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
+    case HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35:
         return decode_nal_sei_user_data_registered_itu_t_t35(s, gb, logctx, size);
     default:
         av_log(logctx, AV_LOG_DEBUG, "Skipped PREFIX SEI %d\n", type);
@@ -337,7 +311,7 @@ static int decode_nal_sei_suffix(GetBitContext *gb, void *logctx, HEVCSEIContext
                                  int type, int size)
 {
     switch (type) {
-    case SEI_TYPE_DECODED_PICTURE_HASH:
+    case HEVC_SEI_TYPE_DECODED_PICTURE_HASH:
         return decode_nal_sei_decoded_picture_hash(&s->picture_hash, gb, logctx);
     default:
         av_log(logctx, AV_LOG_DEBUG, "Skipped SUFFIX SEI %d\n", type);
diff --git a/libavcodec/hevc_sei.h b/libavcodec/hevc_sei.h
new file mode 100644
index 0000000000..2687f449bf
--- /dev/null
+++ b/libavcodec/hevc_sei.h
@@ -0,0 +1,125 @@
+/*
+ * HEVC Supplementary Enhancement Information messages
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_HEVC_SEI_H
+#define AVCODEC_HEVC_SEI_H
+
+#include "libavutil/md5.h"
+#include "get_bits.h"
+
+/**
+ * SEI message types
+ */
+typedef enum {
+    HEVC_SEI_TYPE_BUFFERING_PERIOD                     = 0,
+    HEVC_SEI_TYPE_PICTURE_TIMING                       = 1,
+    HEVC_SEI_TYPE_PAN_SCAN_RECT                        = 2,
+    HEVC_SEI_TYPE_FILLER_PAYLOAD                       = 3,
+    HEVC_SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35       = 4,
+    HEVC_SEI_TYPE_USER_DATA_UNREGISTERED               = 5,
+    HEVC_SEI_TYPE_RECOVERY_POINT                       = 6,
+    HEVC_SEI_TYPE_SCENE_INFO                           = 9,
+    HEVC_SEI_TYPE_FULL_FRAME_SNAPSHOT                  = 15,
+    HEVC_SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
+    HEVC_SEI_TYPE_PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
+    HEVC_SEI_TYPE_FILM_GRAIN_CHARACTERISTICS           = 19,
+    HEVC_SEI_TYPE_POST_FILTER_HINT                     = 22,
+    HEVC_SEI_TYPE_TONE_MAPPING_INFO                    = 23,
+    HEVC_SEI_TYPE_FRAME_PACKING                        = 45,
+    HEVC_SEI_TYPE_DISPLAY_ORIENTATION                  = 47,
+    HEVC_SEI_TYPE_SOP_DESCRIPTION                      = 128,
+    HEVC_SEI_TYPE_ACTIVE_PARAMETER_SETS                = 129,
+    HEVC_SEI_TYPE_DECODING_UNIT_INFO                   = 130,
+    HEVC_SEI_TYPE_TEMPORAL_LEVEL0_INDEX                = 131,
+    HEVC_SEI_TYPE_DECODED_PICTURE_HASH                 = 132,
+    HEVC_SEI_TYPE_SCALABLE_NESTING                     = 133,
+    HEVC_SEI_TYPE_REGION_REFRESH_INFO                  = 134,
+    HEVC_SEI_TYPE_MASTERING_DISPLAY_INFO               = 137,
+    HEVC_SEI_TYPE_CONTENT_LIGHT_LEVEL_INFO             = 144,
+} HEVC_SEI_Type;
+
+typedef struct HEVCSEIPictureHash {
+    struct AVMD5 *md5_ctx;
+    uint8_t       md5[3][16];
+    uint8_t is_md5;
+} HEVCSEIPictureHash;
+
+typedef struct HEVCSEIFramePacking {
+    int present;
+    int arrangement_type;
+    int content_interpretation_type;
+    int quincunx_subsampling;
+} HEVCSEIFramePacking;
+
+typedef struct HEVCSEIDisplayOrientation {
+    int present;
+    int anticlockwise_rotation;
+    int hflip, vflip;
+} HEVCSEIDisplayOrientation;
+
+typedef struct HEVCSEIPictureTiming {
+    int picture_struct;
+} HEVCSEIPictureTiming;
+
+typedef struct HEVCSEIA53Caption {
+    int a53_caption_size;
+    uint8_t *a53_caption;
+} HEVCSEIA53Caption;
+
+typedef struct HEVCSEIMasteringDisplay {
+    int present;
+    uint16_t display_primaries[3][2];
+    uint16_t white_point[2];
+    uint32_t max_luminance;
+    uint32_t min_luminance;
+} HEVCSEIMasteringDisplay;
+
+typedef struct HEVCSEIContentLight {
+    int present;
+    uint16_t max_content_light_level;
+    uint16_t max_pic_average_light_level;
+} HEVCSEIContentLight;
+
+typedef struct HEVCSEIContext {
+    HEVCSEIPictureHash picture_hash;
+    HEVCSEIFramePacking frame_packing;
+    HEVCSEIDisplayOrientation display_orientation;
+    HEVCSEIPictureTiming picture_timing;
+    HEVCSEIA53Caption a53_caption;
+    HEVCSEIMasteringDisplay mastering_display;
+    HEVCSEIContentLight content_light;
+    int active_seq_parameter_set_id;
+} HEVCSEIContext;
+
+struct HEVCParamSets;
+
+int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEIContext *s,
+                           const struct HEVCParamSets *ps, int type);
+
+/**
+ * Reset SEI values that are stored on the Context.
+ * e.g. Caption data that was extracted during NAL
+ * parsing.
+ *
+ * @param s HEVCContext.
+ */
+void ff_hevc_reset_sei(HEVCSEIContext *s);
+
+#endif /* AVCODEC_HEVC_SEI_H */
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index b8b8605134..cc7fc7e35f 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -35,6 +35,7 @@
 #include "h2645_parse.h"
 #include "hevc.h"
 #include "hevc_ps.h"
+#include "hevc_sei.h"
 #include "hevcdsp.h"
 #include "internal.h"
 #include "thread.h"
@@ -463,59 +464,6 @@ typedef struct HEVCLocalContext {
     int boundary_flags;
 } HEVCLocalContext;
 
-typedef struct HEVCSEIPictureHash {
-    struct AVMD5 *md5_ctx;
-    uint8_t       md5[3][16];
-    uint8_t is_md5;
-} HEVCSEIPictureHash;
-
-typedef struct HEVCSEIFramePacking {
-    int present;
-    int arrangement_type;
-    int content_interpretation_type;
-    int quincunx_subsampling;
-} HEVCSEIFramePacking;
-
-typedef struct HEVCSEIDisplayOrientation {
-    int present;
-    int anticlockwise_rotation;
-    int hflip, vflip;
-} HEVCSEIDisplayOrientation;
-
-typedef struct HEVCSEIPictureTiming {
-    int picture_struct;
-} HEVCSEIPictureTiming;
-
-typedef struct HEVCSEIA53Caption {
-    int a53_caption_size;
-    uint8_t *a53_caption;
-} HEVCSEIA53Caption;
-
-typedef struct HEVCSEIMasteringDisplay {
-    int present;
-    uint16_t display_primaries[3][2];
-    uint16_t white_point[2];
-    uint32_t max_luminance;
-    uint32_t min_luminance;
-} HEVCSEIMasteringDisplay;
-
-typedef struct HEVCSEIContentLight {
-    int present;
-    uint16_t max_content_light_level;
-    uint16_t max_pic_average_light_level;
-} HEVCSEIContentLight;
-
-typedef struct HEVCSEIContext {
-    HEVCSEIPictureHash picture_hash;
-    HEVCSEIFramePacking frame_packing;
-    HEVCSEIDisplayOrientation display_orientation;
-    HEVCSEIPictureTiming picture_timing;
-    HEVCSEIA53Caption a53_caption;
-    HEVCSEIMasteringDisplay mastering_display;
-    HEVCSEIContentLight content_light;
-    int active_seq_parameter_set_id;
-} HEVCSEIContext;
-
 typedef struct HEVCContext {
     const AVClass *c;  // needed by private avoptions
     AVCodecContext *avctx;
@@ -621,9 +569,6 @@ typedef struct HEVCContext {
     HEVCSEIContext sei;
 } HEVCContext;
 
-int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEIContext *s,
-                           const HEVCParamSets *ps, int type);
-
 /**
  * Mark all frames in DPB as unused for reference.
  */
@@ -727,15 +672,6 @@ void ff_hevc_hls_residual_coding(HEVCContext *s, int x0, int y0,
 
 void ff_hevc_hls_mvd_coding(HEVCContext *s, int x0, int y0, int log2_cb_size);
 
-/**
- * Reset SEI values that are stored on the Context.
- * e.g. Caption data that was extracted during NAL
- * parsing.
- *
- * @param s HEVCContext.
- */
-void ff_hevc_reset_sei(HEVCSEIContext *s);
-
 extern const uint8_t ff_hevc_qpel_extra_before[4];
 extern const uint8_t ff_hevc_qpel_extra_after[4];
 extern const uint8_t ff_hevc_qpel_extra[4];
-- 
2.12.1



More information about the ffmpeg-devel mailing list