Debian Codegraph @

src/core/indexing.h

raw symbols SCIP
1 // Copyright (c) 2007-2017 Fredrik Mellbin
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20
21 #ifndef INDEXING_H
22 #define INDEXING_H
23
24 #include "utils.h"
25
26 #include <set>
27 #include <map>
28 #include <memory>
29 #include <atomic>
30
31 extern "C" {
32 #include <libavutil/avutil.h>
33 }
34
35 class Wave64Writer;
36 class ZipFile;
37
38 struct SharedAVContext {
39 AVCodecContext *CodecContext = nullptr;
40 AVCodecParserContext *Parser = nullptr;
41 int64_t CurrentSample = 0;
42 ~SharedAVContext();
43 };
44
45 struct FFMS_Index : public std::vector<FFMS_Track> {
46 FFMS_Index(FFMS_Index const&) = delete;
47 FFMS_Index& operator=(FFMS_Index const&) = delete;
48 void ReadIndex(ZipFile &zf, const char* IndexFile);
49 void WriteIndex(ZipFile &zf);
50 public:
51 static void CalculateFileSignature(const char *Filename, int64_t *Filesize, uint8_t Digest[20]);
52
53 int ErrorHandling;
54 int64_t Filesize;
55 uint8_t Digest[20];
56 std::map<std::string, std::string> LAVFOpts;
57
58 void Finalize(std::vector<SharedAVContext> const& video_contexts, const char *Format);
59 bool CompareFileSignature(const char *Filename);
60 void WriteIndexFile(const char *IndexFile);
61 uint8_t *WriteIndexBuffer(size_t *Size);
62
63 FFMS_Index(const char *IndexFile);
64 FFMS_Index(const uint8_t *Buffer, size_t Size);
65 FFMS_Index(int64_t Filesize, uint8_t Digest[20], int ErrorHandling, const std::map<std::string, std::string> &LAVFOpts);
66 };
67
68 struct FFMS_Indexer {
69 private:
70 std::map<int, FFMS_AudioProperties> LastAudioProperties;
71 FFMS_Indexer(FFMS_Indexer const&) = delete;
72 FFMS_Indexer& operator=(FFMS_Indexer const&) = delete;
73 AVFormatContext *FormatContext = nullptr;
74 std::set<int> IndexMask;
75 std::map<std::string, std::string> LAVFOpts;
76 int ErrorHandling = FFMS_IEH_CLEAR_TRACK;
77 TIndexCallback IC = nullptr;
78 void *ICPrivate = nullptr;
79 std::string SourceFile;
80 AVFrame *DecodeFrame = nullptr;
81
82 int64_t Filesize;
83 uint8_t Digest[20];
84
85 void ReadTS(const AVPacket *Packet, int64_t &TS, bool &UseDTS);
86 void CheckAudioProperties(int Track, AVCodecContext *Context);
87 uint32_t IndexAudioPacket(int Track, AVPacket *Packet, SharedAVContext &Context, FFMS_Index &TrackIndices);
88 void ParseVideoPacket(SharedAVContext &VideoContext, AVPacket *pkt, int *RepeatPict, int *FrameType, bool *Invisible, bool *SecondField, enum AVPictureStructure *LastPicStruct);
89 void Free();
90 public:
91 FFMS_Indexer(const char *Filename, const FFMS_KeyValuePair *DemuxerOptions, int NumOptions);
92 ~FFMS_Indexer();
93
94 void SetIndexTrack(int Track, bool Index);
95 void SetIndexTrackType(int TrackType, bool Index);
96 void SetErrorHandling(int ErrorHandling_);
97 void SetProgressCallback(TIndexCallback IC_, void *ICPrivate_);
98
99 FFMS_Index *DoIndexing();
100 int GetNumberOfTracks();
101 FFMS_TrackType GetTrackType(int Track);
102 const char *GetTrackCodec(int Track);
103 const char *GetFormatName();
104 };
105
106
107 #endif