File: display_matrix.cpp

package info (click to toggle)
ffms2 2.40%2Bgit20211209-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 904 kB
  • sloc: cpp: 6,690; ansic: 384; makefile: 152; perl: 85; sh: 22
file content (102 lines) | stat: -rw-r--r-- 2,318 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <cfloat>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>

#include <ffms.h>
#include <gtest/gtest.h>

#include "tests.h"

namespace {

class DisplayMatrixTest : public ::testing::Test {
protected:
    virtual void SetUp();
    virtual void TearDown();
    bool DoIndexing(std::string);

    FFMS_Indexer* indexer;
    FFMS_Index* index;
    int video_track_idx;
    FFMS_VideoSource* video_source;
    const FFMS_VideoProperties* VP;

    FFMS_ErrorInfo E;
    char ErrorMsg[1024];

    std::string SamplesDir;
};

void DisplayMatrixTest::SetUp() {
    indexer = nullptr;
    index = nullptr;
    video_track_idx = -1;
    video_source = nullptr;
    VP = nullptr;
    E.Buffer = ErrorMsg;
    E.BufferSize = sizeof(ErrorMsg);
    SamplesDir = STRINGIFY(SAMPLES_DIR);

    FFMS_Init(0,0);
}

void DisplayMatrixTest::TearDown() {
    FFMS_DestroyIndex(index);
    FFMS_DestroyVideoSource(video_source);
    FFMS_Deinit();
}

bool DisplayMatrixTest::DoIndexing(std::string file_name) {
    indexer = FFMS_CreateIndexer(file_name.c_str(), &E);
    NULL_CHECK(indexer);
    FFMS_TrackTypeIndexSettings(indexer, FFMS_TYPE_VIDEO, 1, 0);

    index = FFMS_DoIndexing2(indexer, 0, &E);
    NULL_CHECK(index);

    video_track_idx = FFMS_GetFirstTrackOfType(index, FFMS_TYPE_VIDEO, &E);
    EXPECT_GE(0, video_track_idx);

    video_source = FFMS_CreateVideoSource(file_name.c_str(), video_track_idx, index, 1, FFMS_SEEK_NORMAL, &E);
    NULL_CHECK(video_source);

    VP = FFMS_GetVideoProperties(video_source); // Can't fail

    return true;
}

TEST_F(DisplayMatrixTest, HFlip270) {
    std::string FilePath = SamplesDir + "/qrvideo_hflip_90.mov";

    ASSERT_TRUE(DoIndexing(FilePath));

    ASSERT_EQ(VP->Flip, 1);
    ASSERT_EQ(VP->Rotation, 90);
}

TEST_F(DisplayMatrixTest, HFlip90) {
    std::string FilePath = SamplesDir + "/qrvideo_hflip_270.mov";

    ASSERT_TRUE(DoIndexing(FilePath));

    ASSERT_EQ(VP->Flip, 1);
    ASSERT_EQ(VP->Rotation, 270);
}

TEST_F(DisplayMatrixTest, VFlip180) {
    std::string FilePath = SamplesDir + "/qrvideo_vflip.mov";

    ASSERT_TRUE(DoIndexing(FilePath));

    ASSERT_EQ(VP->Flip, 1);
    ASSERT_EQ(VP->Rotation, 180);
}

} //namespace

int main(int argc, char **argv) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}