demux: mp4: avoid audio cuts on seek
[vlc.git] / modules / codec / jpeg2000.h
blobc1a528038a75e361708e5235b1678635121d82d7
1 /*****************************************************************************
2 * jpeg2000.h J2K definitions
3 *****************************************************************************
4 * Copyright (C) 2017 VideoLAN Authors
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.
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.
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
23 #define J2K_BOX_JP2C VLC_FOURCC('j','p','2','c')
25 enum j2k_profiles_e
27 J2K_PROFILE_SD = 0,
28 J2K_PROFILE_HD,
29 J2K_PROFILE_3G,
30 J2K_PROFILE_S3D_HD,
31 J2K_PROFILE_S3D_3G,
34 static inline bool j2k_is_valid_framerate( unsigned num, unsigned den )
36 const struct
38 const unsigned num;
39 const unsigned den;
40 } numdens[] = { /* table 2-99 */
41 { 24000, 1001 },
42 { 24, 1 },
43 { 25, 1 },
44 { 30000, 1001 },
45 { 30, 1 },
46 { 50, 1 },
47 { 60000, 1001 },
48 { 60, 1 },
50 for( size_t i=0; i<ARRAY_SIZE(numdens); i++ )
51 if( numdens[i].den == den && numdens[i].num == num )
52 return true;
53 return false;
56 static inline enum j2k_profiles_e j2k_get_profile( unsigned w, unsigned h,
57 unsigned num, unsigned den, bool p )
59 const uint64_t s = w *(uint64_t)h;
60 const uint64_t f = num / den;
61 if( s <= 720*576 && f < 50 )
62 return J2K_PROFILE_SD; /* VSF_TR-01_2013-04-15 */
63 else if( s <= 1280*720 && f < 60 && p )
64 return J2K_PROFILE_HD;
65 else if( s <= 1920*1080 && f < 60 && !p )
66 return J2K_PROFILE_HD;
67 else
68 return J2K_PROFILE_3G;
71 static const struct
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 },
83 enum j2k_color_specs_e
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,
95 static const struct
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 },
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 )
132 if( e > J2K_COLOR_SPEC_UNKNOWN && e <= J2K_COLOR_SPEC_SMPTE_2084 )
134 *primaries = j2k_color_specifications[e].primaries;
135 *transfer = j2k_color_specifications[e].transfer;
136 *space = j2k_color_specifications[e].space;
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 )
145 enum j2k_color_specs_e e;
146 for( e = J2K_COLOR_SPEC_UNKNOWN; e <= J2K_COLOR_SPEC_SMPTE_2084; e++ )
148 if( primaries == j2k_color_specifications[e].primaries &&
149 transfer == j2k_color_specifications[e].transfer &&
150 space == j2k_color_specifications[e].space )
152 return e;
155 return J2K_COLOR_SPEC_UNKNOWN;
158 #endif