/src/vlc/modules/codec/jpeg2000.h
Line | Count | Source |
1 | | /***************************************************************************** |
2 | | * jpeg2000.h J2K definitions |
3 | | ***************************************************************************** |
4 | | * Copyright (C) 2017 VideoLAN Authors |
5 | | * |
6 | | * This program is free software; you can redistribute it and/or modify it |
7 | | * under the terms of the GNU Lesser General Public License as published by |
8 | | * the Free Software Foundation; either version 2.1 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * This program is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU Lesser General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU Lesser General Public License |
17 | | * along with this program; if not, write to the Free Software Foundation, |
18 | | * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
19 | | *****************************************************************************/ |
20 | | #ifndef VLC_JPEG2000_H |
21 | | #define VLC_JPEG2000_H |
22 | | |
23 | | #define J2K_BOX_JP2C VLC_FOURCC('j','p','2','c') |
24 | | |
25 | | enum j2k_profiles_e |
26 | | { |
27 | | J2K_PROFILE_SD = 0, |
28 | | J2K_PROFILE_HD, |
29 | | J2K_PROFILE_3G, |
30 | | J2K_PROFILE_S3D_HD, |
31 | | J2K_PROFILE_S3D_3G, |
32 | | }; |
33 | | |
34 | | static inline bool j2k_is_valid_framerate( unsigned num, unsigned den ) |
35 | 0 | { |
36 | 0 | const struct |
37 | 0 | { |
38 | 0 | const unsigned num; |
39 | 0 | const unsigned den; |
40 | 0 | } numdens[] = { /* table 2-99 */ |
41 | 0 | { 24000, 1001 }, |
42 | 0 | { 24, 1 }, |
43 | 0 | { 25, 1 }, |
44 | 0 | { 30000, 1001 }, |
45 | 0 | { 30, 1 }, |
46 | 0 | { 50, 1 }, |
47 | 0 | { 60000, 1001 }, |
48 | 0 | { 60, 1 }, |
49 | 0 | }; |
50 | 0 | for( size_t i=0; i<ARRAY_SIZE(numdens); i++ ) |
51 | 0 | if( numdens[i].den == den && numdens[i].num == num ) |
52 | 0 | return true; |
53 | 0 | return false; |
54 | 0 | } Unexecuted instantiation: ts_psi.c:j2k_is_valid_framerate Unexecuted instantiation: tables.c:j2k_is_valid_framerate |
55 | | |
56 | | static inline enum j2k_profiles_e j2k_get_profile( unsigned w, unsigned h, |
57 | | unsigned num, unsigned den, bool p ) |
58 | 0 | { |
59 | 0 | const uint64_t s = w *(uint64_t)h; |
60 | 0 | const uint64_t f = num / den; |
61 | 0 | if( s <= 720*576 && f < 50 ) |
62 | 0 | return J2K_PROFILE_SD; /* VSF_TR-01_2013-04-15 */ |
63 | 0 | else if( s <= 1280*720 && f < 60 && p ) |
64 | 0 | return J2K_PROFILE_HD; |
65 | 0 | else if( s <= 1920*1080 && f < 60 && !p ) |
66 | 0 | return J2K_PROFILE_HD; |
67 | 0 | else |
68 | 0 | return J2K_PROFILE_3G; |
69 | 0 | } Unexecuted instantiation: ts_psi.c:j2k_get_profile Unexecuted instantiation: tables.c:j2k_get_profile |
70 | | |
71 | | static const struct |
72 | | { |
73 | | const uint16_t min; |
74 | | const uint16_t max; |
75 | | } j2k_profiles_rates[] = { |
76 | | [J2K_PROFILE_SD] = { 25, 200 }, |
77 | | [J2K_PROFILE_HD] = { 75, 200 }, |
78 | | [J2K_PROFILE_3G] = { 100, 400 }, |
79 | | [J2K_PROFILE_S3D_HD] = { 150, 200 }, |
80 | | [J2K_PROFILE_S3D_3G] = { 200, 400 }, |
81 | | }; |
82 | | |
83 | | enum j2k_color_specs_e |
84 | | { |
85 | | J2K_COLOR_SPEC_UNKNOWN = 0, |
86 | | J2K_COLOR_SPEC_SRGB, |
87 | | J2K_COLOR_SPEC_REC_601, |
88 | | J2K_COLOR_SPEC_REC_709, |
89 | | J2K_COLOR_SPEC_CIE_LUV, |
90 | | J2K_COLOR_SPEC_CIE_XYZ, |
91 | | J2K_COLOR_SPEC_REC_2020, |
92 | | J2K_COLOR_SPEC_SMPTE_2084, |
93 | | }; |
94 | | |
95 | | static const struct |
96 | | { |
97 | | video_color_primaries_t primaries; |
98 | | video_transfer_func_t transfer; |
99 | | video_color_space_t space; |
100 | | } j2k_color_specifications[] = { |
101 | | [J2K_COLOR_SPEC_UNKNOWN] = { COLOR_PRIMARIES_UNDEF, |
102 | | TRANSFER_FUNC_UNDEF, |
103 | | COLOR_SPACE_UNDEF }, |
104 | | [J2K_COLOR_SPEC_SRGB] = { COLOR_PRIMARIES_SRGB, |
105 | | TRANSFER_FUNC_SRGB, |
106 | | COLOR_SPACE_SRGB }, |
107 | | [J2K_COLOR_SPEC_REC_601] = { COLOR_PRIMARIES_BT601_625, |
108 | | TRANSFER_FUNC_SMPTE_170, |
109 | | COLOR_SPACE_BT601 }, |
110 | | [J2K_COLOR_SPEC_REC_709] = { COLOR_PRIMARIES_BT709, |
111 | | TRANSFER_FUNC_BT709, |
112 | | COLOR_SPACE_BT709 }, |
113 | | [J2K_COLOR_SPEC_CIE_LUV] = { COLOR_PRIMARIES_UNDEF, |
114 | | TRANSFER_FUNC_UNDEF, |
115 | | COLOR_SPACE_UNDEF }, |
116 | | [J2K_COLOR_SPEC_CIE_XYZ] = { COLOR_PRIMARIES_UNDEF, |
117 | | TRANSFER_FUNC_UNDEF, |
118 | | COLOR_SPACE_UNDEF }, |
119 | | [J2K_COLOR_SPEC_REC_2020] ={ COLOR_PRIMARIES_BT2020, |
120 | | TRANSFER_FUNC_BT2020, |
121 | | COLOR_SPACE_BT2020 }, |
122 | | [J2K_COLOR_SPEC_SMPTE_2084]={ COLOR_PRIMARIES_SMTPE_170, |
123 | | TRANSFER_FUNC_SMPTE_ST2084, |
124 | | COLOR_SPACE_BT2020 }, |
125 | | }; |
126 | | |
127 | | static inline void j2k_fill_color_profile( enum j2k_color_specs_e e, |
128 | | video_color_primaries_t *primaries, |
129 | | video_transfer_func_t *transfer, |
130 | | video_color_space_t *space ) |
131 | 0 | { |
132 | 0 | if( e > J2K_COLOR_SPEC_UNKNOWN && e <= J2K_COLOR_SPEC_SMPTE_2084 ) |
133 | 0 | { |
134 | 0 | *primaries = j2k_color_specifications[e].primaries; |
135 | 0 | *transfer = j2k_color_specifications[e].transfer; |
136 | 0 | *space = j2k_color_specifications[e].space; |
137 | 0 | } |
138 | 0 | } Unexecuted instantiation: ts_psi.c:j2k_fill_color_profile Unexecuted instantiation: tables.c:j2k_fill_color_profile |
139 | | |
140 | | static inline enum j2k_color_specs_e |
141 | | j2k_get_color_spec( video_color_primaries_t primaries, |
142 | | video_transfer_func_t transfer , |
143 | | video_color_space_t space ) |
144 | 0 | { |
145 | 0 | enum j2k_color_specs_e e; |
146 | 0 | for( e = J2K_COLOR_SPEC_UNKNOWN; e <= J2K_COLOR_SPEC_SMPTE_2084; e++ ) |
147 | 0 | { |
148 | 0 | if( primaries == j2k_color_specifications[e].primaries && |
149 | 0 | transfer == j2k_color_specifications[e].transfer && |
150 | 0 | space == j2k_color_specifications[e].space ) |
151 | 0 | { |
152 | 0 | return e; |
153 | 0 | } |
154 | 0 | } |
155 | 0 | return J2K_COLOR_SPEC_UNKNOWN; |
156 | 0 | } Unexecuted instantiation: ts_psi.c:j2k_get_color_spec Unexecuted instantiation: tables.c:j2k_get_color_spec |
157 | | |
158 | | #endif |