summaryrefslogtreecommitdiff
path: root/libavcodec/hevc_sei.h
blob: 5645e4f5de6bc0405b65d6b9b115e13c8c2a5010 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * 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 <stdint.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 */