[videodb] remove unused seasons table from episode_view
[xbmc.git] / xbmc / cores / VideoPlayer / DVDStreamInfo.cpp
blob08c1c6805d6de78a9f7dd4d55fe8cf7ead10b087
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #include "DVDStreamInfo.h"
11 #include "DVDDemuxers/DVDDemux.h"
12 #include "cores/VideoPlayer/Interface/DemuxCrypto.h"
14 #include <cstring>
16 CDVDStreamInfo::CDVDStreamInfo() : extradata{}
18 Clear();
20 CDVDStreamInfo::CDVDStreamInfo(const CDVDStreamInfo& right, bool withextradata) : extradata{}
22 Clear();
23 Assign(right, withextradata);
25 CDVDStreamInfo::CDVDStreamInfo(const CDemuxStream& right, bool withextradata) : extradata{}
27 Clear();
28 Assign(right, withextradata);
31 CDVDStreamInfo::~CDVDStreamInfo() = default;
33 void CDVDStreamInfo::Clear()
35 codec = AV_CODEC_ID_NONE;
36 type = STREAM_NONE;
37 uniqueId = -1;
38 source = STREAM_SOURCE_NONE;
39 codecOptions = 0;
40 codec_tag = 0;
41 flags = 0;
42 filename.clear();
43 dvd = false;
45 extradata = {};
47 cryptoSession = nullptr;
48 externalInterfaces = nullptr;
50 fpsscale = 0;
51 fpsrate = 0;
52 interlaced = false;
53 height = 0;
54 width = 0;
55 aspect = 0.0;
56 vfr = false;
57 stills = false;
58 level = 0;
59 profile = 0;
60 ptsinvalid = false;
61 forced_aspect = false;
62 bitsperpixel = 0;
63 hdrType = StreamHdrType::HDR_TYPE_NONE;
64 colorSpace = AVCOL_SPC_UNSPECIFIED;
65 colorRange = AVCOL_RANGE_UNSPECIFIED;
66 colorPrimaries = AVCOL_PRI_UNSPECIFIED;
67 colorTransferCharacteristic = AVCOL_TRC_UNSPECIFIED;
68 masteringMetadata = nullptr;
69 contentLightMetadata = nullptr;
70 stereo_mode.clear();
71 dovi = {};
73 channels = 0;
74 samplerate = 0;
75 blockalign = 0;
76 bitrate = 0;
77 bitspersample = 0;
78 channellayout = 0;
80 orientation = 0;
81 bitdepth = 0;
84 bool CDVDStreamInfo::Equal(const CDVDStreamInfo& right, int compare)
86 if (codec != right.codec || type != right.type ||
87 ((compare & COMPARE_ID) && uniqueId != right.uniqueId) ||
88 ((compare & COMPARE_ID) && demuxerId != right.demuxerId) || codec_tag != right.codec_tag ||
89 flags != right.flags)
90 return false;
92 if (compare & COMPARE_EXTRADATA && extradata != right.extradata)
94 return false;
97 // VIDEO
98 // clang-format off
99 if (fpsscale != right.fpsscale
100 || fpsrate != right.fpsrate
101 || interlaced != right.interlaced
102 || height != right.height
103 || width != right.width
104 || stills != right.stills
105 || level != right.level
106 || profile != right.profile
107 || ptsinvalid != right.ptsinvalid
108 || forced_aspect != right.forced_aspect
109 || bitsperpixel != right.bitsperpixel
110 || bitdepth != right.bitdepth
111 || vfr != right.vfr
112 || hdrType != right.hdrType
113 || colorSpace != right.colorSpace
114 || colorRange != right.colorRange
115 || colorPrimaries != right.colorPrimaries
116 || colorTransferCharacteristic != right.colorTransferCharacteristic
117 || stereo_mode != right.stereo_mode)
118 return false;
119 // clang-format on
121 if (masteringMetadata && right.masteringMetadata)
123 if (masteringMetadata->has_luminance != right.masteringMetadata->has_luminance
124 || masteringMetadata->has_primaries != right.masteringMetadata->has_primaries)
125 return false;
127 if (masteringMetadata->has_primaries)
129 for (unsigned int i(0); i < 3; ++i)
130 for (unsigned int j(0); j < 2; ++j)
131 if (av_cmp_q(masteringMetadata->display_primaries[i][j], right.masteringMetadata->display_primaries[i][j]))
132 return false;
133 for (unsigned int i(0); i < 2; ++i)
134 if (av_cmp_q(masteringMetadata->white_point[i], right.masteringMetadata->white_point[i]))
135 return false;
138 if (masteringMetadata->has_luminance)
140 if (av_cmp_q(masteringMetadata->min_luminance, right.masteringMetadata->min_luminance)
141 || av_cmp_q(masteringMetadata->max_luminance, right.masteringMetadata->max_luminance))
142 return false;
145 else if (masteringMetadata || right.masteringMetadata)
146 return false;
148 if (contentLightMetadata && right.contentLightMetadata)
150 if (contentLightMetadata->MaxCLL != right.contentLightMetadata->MaxCLL
151 || contentLightMetadata->MaxFALL != right.contentLightMetadata->MaxFALL)
152 return false;
154 else if (contentLightMetadata || right.contentLightMetadata)
155 return false;
157 if (0 != std::memcmp(&dovi, &right.dovi, sizeof(AVDOVIDecoderConfigurationRecord)))
158 return false;
160 // AUDIO
161 if( channels != right.channels
162 || samplerate != right.samplerate
163 || blockalign != right.blockalign
164 || bitrate != right.bitrate
165 || bitspersample != right.bitspersample
166 || channellayout != right.channellayout)
167 return false;
169 // SUBTITLE
171 // Crypto
172 if ((cryptoSession == nullptr) != (right.cryptoSession == nullptr))
173 return false;
175 if (cryptoSession && !(*cryptoSession == *right.cryptoSession))
176 return false;
178 return true;
181 bool CDVDStreamInfo::Equal(const CDemuxStream& right, bool withextradata)
183 CDVDStreamInfo info;
184 info.Assign(right, withextradata);
185 return Equal(info, withextradata ? COMPARE_ALL : COMPARE_ALL & ~COMPARE_EXTRADATA);
189 // ASSIGNMENT
190 void CDVDStreamInfo::Assign(const CDVDStreamInfo& right, bool withextradata)
192 codec = right.codec;
193 type = right.type;
194 uniqueId = right.uniqueId;
195 demuxerId = right.demuxerId;
196 source = right.source;
197 codec_tag = right.codec_tag;
198 flags = right.flags;
199 filename = right.filename;
200 dvd = right.dvd;
202 if (withextradata && right.extradata)
204 extradata = right.extradata;
206 else
208 extradata = {};
211 cryptoSession = right.cryptoSession;
212 externalInterfaces = right.externalInterfaces;
214 // VIDEO
215 fpsscale = right.fpsscale;
216 fpsrate = right.fpsrate;
217 interlaced = right.interlaced;
218 height = right.height;
219 width = right.width;
220 aspect = right.aspect;
221 stills = right.stills;
222 level = right.level;
223 profile = right.profile;
224 ptsinvalid = right.ptsinvalid;
225 forced_aspect = right.forced_aspect;
226 orientation = right.orientation;
227 bitsperpixel = right.bitsperpixel;
228 bitdepth = right.bitdepth;
229 vfr = right.vfr;
230 codecOptions = right.codecOptions;
231 hdrType = right.hdrType;
232 colorSpace = right.colorSpace;
233 colorRange = right.colorRange;
234 colorPrimaries = right.colorPrimaries;
235 colorTransferCharacteristic = right.colorTransferCharacteristic;
236 masteringMetadata = right.masteringMetadata;
237 contentLightMetadata = right.contentLightMetadata;
238 stereo_mode = right.stereo_mode;
239 dovi = right.dovi;
241 // AUDIO
242 channels = right.channels;
243 samplerate = right.samplerate;
244 blockalign = right.blockalign;
245 bitrate = right.bitrate;
246 bitspersample = right.bitspersample;
247 channellayout = right.channellayout;
249 // SUBTITLE
252 void CDVDStreamInfo::Assign(const CDemuxStream& right, bool withextradata)
254 Clear();
256 codec = right.codec;
257 type = right.type;
258 uniqueId = right.uniqueId;
259 demuxerId = right.demuxerId;
260 source = right.source;
261 codec_tag = right.codec_fourcc;
262 profile = right.profile;
263 level = right.level;
264 flags = right.flags;
266 if (withextradata && right.extraData)
268 extradata = right.extraData;
271 cryptoSession = right.cryptoSession;
272 externalInterfaces = right.externalInterfaces;
274 if (right.type == STREAM_AUDIO)
276 const CDemuxStreamAudio *stream = static_cast<const CDemuxStreamAudio*>(&right);
277 channels = stream->iChannels;
278 samplerate = stream->iSampleRate;
279 blockalign = stream->iBlockAlign;
280 bitrate = stream->iBitRate;
281 bitspersample = stream->iBitsPerSample;
282 channellayout = stream->iChannelLayout;
284 else if (right.type == STREAM_VIDEO)
286 const CDemuxStreamVideo *stream = static_cast<const CDemuxStreamVideo*>(&right);
287 fpsscale = stream->iFpsScale;
288 fpsrate = stream->iFpsRate;
289 interlaced = stream->interlaced;
290 height = stream->iHeight;
291 width = stream->iWidth;
292 aspect = stream->fAspect;
293 vfr = stream->bVFR;
294 ptsinvalid = stream->bPTSInvalid;
295 forced_aspect = stream->bForcedAspect;
296 orientation = stream->iOrientation;
297 bitsperpixel = stream->iBitsPerPixel;
298 bitdepth = stream->bitDepth;
299 hdrType = stream->hdr_type;
300 colorSpace = stream->colorSpace;
301 colorRange = stream->colorRange;
302 colorPrimaries = stream->colorPrimaries;
303 colorTransferCharacteristic = stream->colorTransferCharacteristic;
304 masteringMetadata = stream->masteringMetaData;
305 contentLightMetadata = stream->contentLightMetaData;
306 stereo_mode = stream->stereo_mode;
307 dovi = stream->dovi;
309 else if (right.type == STREAM_SUBTITLE)