Skip to content

Commit

Permalink
Combine some more files
Browse files Browse the repository at this point in the history
Make all files lowercase
  • Loading branch information
myrsloik committed Mar 21, 2024
1 parent ba02ed2 commit 8c97f63
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 84 deletions.
3 changes: 1 addition & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ link_static = get_option('link_static')

sources = [
'src/audiosource.cpp',
'src/BSRational.cpp',
'src/BSShared.cpp',
'src/bsshared.cpp',
'src/vapoursynth.cpp',
'src/videosource.cpp'
]
Expand Down
6 changes: 2 additions & 4 deletions msvc/BestSource.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
<ClCompile Include="..\libp2p\p2p_api.cpp" />
<ClCompile Include="..\libp2p\v210.cpp" />
<ClCompile Include="..\src\audiosource.cpp" />
<ClCompile Include="..\src\BSRational.cpp" />
<ClCompile Include="..\src\BSShared.cpp" />
<ClCompile Include="..\src\bsshared.cpp" />
<ClCompile Include="..\src\vapoursynth.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
Expand All @@ -34,8 +33,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\audiosource.h" />
<ClInclude Include="..\src\BSRational.h" />
<ClInclude Include="..\src\BSShared.h" />
<ClInclude Include="..\src\bsshared.h" />
<ClInclude Include="..\src\version.h" />
<ClInclude Include="..\src\videosource.h" />
</ItemGroup>
Expand Down
10 changes: 2 additions & 8 deletions msvc/BestSource.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,24 @@
<ClCompile Include="..\libp2p\v210.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\BSRational.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\audiosource.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\BSShared.cpp">
<ClCompile Include="..\src\bsshared.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\videosource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\BSRational.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\audiosource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\version.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\src\BSShared.h">
<ClInclude Include="..\src\bsshared.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
Expand Down
35 changes: 0 additions & 35 deletions src/BSShared.cpp

This file was deleted.

27 changes: 0 additions & 27 deletions src/BSShared.h

This file was deleted.

13 changes: 12 additions & 1 deletion src/BSRational.cpp → src/bsshared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
// THE SOFTWARE.


#include "BSRational.h"
#include "bsshared.h"

extern "C" {
#include <libavutil/log.h>
#include <libavutil/rational.h>
}

Expand All @@ -33,3 +34,13 @@ BSRational::BSRational(const AVRational &r) {
double BSRational::ToDouble() const {
return Num / (double)Den;
}


int SetFFmpegLogLevel(int Level) {
av_log_set_level(Level);
return GetFFmpegLogLevel();
}

int GetFFmpegLogLevel() {
return av_log_get_level();
}
7 changes: 5 additions & 2 deletions src/BSRational.h → src/bsshared.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef BSRATIONAL_H
#define BSRATIONAL_H
#ifndef BSSHARED_H
#define BSSHARED_H

struct AVRational;

Expand All @@ -31,4 +31,7 @@ struct BSRational {
double ToDouble() const;
};

int SetFFmpegLogLevel(int Level);
int GetFFmpegLogLevel();

#endif
2 changes: 1 addition & 1 deletion src/vapoursynth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "videosource.h"
#include "audiosource.h"
#include "BSShared.h"
#include "bsshared.h"
#include "version.h"
#include <VapourSynth4.h>
#include <VSHelper4.h>
Expand Down
19 changes: 16 additions & 3 deletions src/videosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,16 +1320,19 @@ namespace std {

typedef std::unique_ptr<FILE> file_ptr_t;

static file_ptr_t OpenCacheFile(const std::string &CachePath, int Track, bool Write) {
std::string FullPath = CachePath + "." + std::to_string(Track) + ".bsindex";
static file_ptr_t OpenFile(const std::string &Filename, bool Write) {
#ifdef _WIN32
file_ptr_t F(_wfopen(Utf16FromUtf8(FullPath).c_str(), Write ? L"wb" : L"rb"));
file_ptr_t F(_wfopen(Utf16FromUtf8(Filename).c_str(), Write ? L"wb" : L"rb"));
#else
file_ptr_t F(fopen(FullPath.c_str(), Write ? "wb" : "rb"));
#endif
return F;
}

static file_ptr_t OpenCacheFile(const std::string &CachePath, int Track, bool Write) {
return OpenFile(CachePath + "." + std::to_string(Track) + ".bsindex", Write);
}

static void WriteInt(file_ptr_t &F, int Value) {
fwrite(&Value, 1, sizeof(Value), F.get());
}
Expand Down Expand Up @@ -1458,3 +1461,13 @@ bool BestVideoSource::ReadVideoTrackIndex(const std::string &CachePath, int Trac

return true;
}

bool BestVideoSource::WriteTimecodes(const std::string &TimecodeFile) const {
file_ptr_t F(OpenFile(TimecodeFile, true));
if (!F)
return false;

fprintf(F.get(), "# timecode format v2\n");
for (const auto &Iter : TrackIndex.Frames)
fprintf(F.get(), "%.02f\n", (Iter.PTS * VP.TimeBase.Num) / (double)VP.TimeBase.Den);
}
3 changes: 2 additions & 1 deletion src/videosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifndef VIDEOSOURCE_H
#define VIDEOSOURCE_H

#include "BSRational.h"
#include "bsshared.h"
#include <cstdint>
#include <stdexcept>
#include <list>
Expand Down Expand Up @@ -264,6 +264,7 @@ class BestVideoSource {
[[nodiscard]] BestVideoFrame *GetFrame(int64_t N, bool Linear = false);
[[nodiscard]] BestVideoFrame *GetFrameWithRFF(int64_t N, bool Linear = false);
[[nodiscard]] BestVideoFrame *GetFrameByTime(double Time, bool Linear = false);
bool WriteTimecodes(const std::string &TimecodeFile) const;
};

#endif

0 comments on commit 8c97f63

Please sign in to comment.