MCPcopy Create free account
hub / github.com/cisco/openh264 / ReadFrame

Function ReadFrame

test/api/BaseDecoderTest.cpp:8–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "BaseDecoderTest.h"
7
8static bool ReadFrame (std::ifstream* file, BufferedData* buf) {
9 // start code of a frame is {0, 0, 0, 1}
10 int zeroCount = 0;
11 char b;
12
13 buf->Clear();
14 for (;;) {
15 file->read (&b, 1);
16 if (file->gcount() != 1) { // end of file
17 return true;
18 }
19 if (!buf->PushBack (b)) {
20 std::cout << "unable to allocate memory" << std::endl;
21 return false;
22 }
23
24 if (buf->Length() <= 4) {
25 continue;
26 }
27
28 if (zeroCount < 3) {
29 zeroCount = b != 0 ? 0 : zeroCount + 1;
30 } else {
31 if (b == 1) {
32 if (file->seekg (-4, file->cur).good()) {
33 if (-1 == buf->SetLength(buf->Length() - 4))
34 return false;
35 return true;
36 } else {
37 std::cout << "unable to seek file" << std::endl;
38 return false;
39 }
40 } else if (b == 0) {
41 zeroCount = 3;
42 } else {
43 zeroCount = 0;
44 }
45 }
46 }
47}
48
49BaseDecoderTest::BaseDecoderTest()
50 : decoder_ (NULL), decodeStatus_ (OpenFile) {}

Callers 2

DecodeFileMethod · 0.70
DecodeNextFrameMethod · 0.70

Calls 5

ClearMethod · 0.80
PushBackMethod · 0.80
LengthMethod · 0.80
SetLengthMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected