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

Method EncodeStream

test/api/BaseEncoderTest.cpp:87–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87void BaseEncoderTest::EncodeStream (InputStream* in, SEncParamExt* pEncParamExt, Callback* cbk) {
88
89 ASSERT_TRUE (NULL != pEncParamExt);
90
91 int rv = InitWithParam (encoder_, pEncParamExt);
92 ASSERT_TRUE (rv == cmResultSuccess);
93
94 // I420: 1(Y) + 1/4(U) + 1/4(V)
95 int frameSize = pEncParamExt->iPicWidth * pEncParamExt->iPicHeight * 3 / 2;
96
97 BufferedData buf;
98 buf.SetLength (frameSize);
99 ASSERT_TRUE (buf.Length() == (size_t)frameSize); //include memory fail (-1) case
100
101 SFrameBSInfo info;
102 memset (&info, 0, sizeof (SFrameBSInfo));
103
104 SSourcePicture pic;
105 memset (&pic, 0, sizeof (SSourcePicture));
106 pic.iPicWidth = pEncParamExt->iPicWidth;
107 pic.iPicHeight = pEncParamExt->iPicHeight;
108 pic.iColorFormat = videoFormatI420;
109 pic.iStride[0] = pic.iPicWidth;
110 pic.iStride[1] = pic.iStride[2] = pic.iPicWidth >> 1;
111 pic.pData[0] = buf.data();
112 pic.pData[1] = pic.pData[0] + pEncParamExt->iPicWidth * pEncParamExt->iPicHeight;
113 pic.pData[2] = pic.pData[1] + (pEncParamExt->iPicWidth * pEncParamExt->iPicHeight >> 2);
114 while (in->read (buf.data(), frameSize) == frameSize) {
115 rv = encoder_->EncodeFrame (&pic, &info);
116 ASSERT_TRUE (rv == cmResultSuccess);
117 if (info.eFrameType != videoFrameTypeSkip && cbk != NULL) {
118 cbk->onEncodeFrame (info);
119 }
120 }
121}
122
123void BaseEncoderTest::EncodeFile (const char* fileName, SEncParamExt* pEncParamExt, Callback* cbk) {
124 FileInputStream fileStream;

Callers

nothing calls this directly

Calls 7

InitWithParamFunction · 0.85
SetLengthMethod · 0.80
LengthMethod · 0.80
dataMethod · 0.80
readMethod · 0.45
EncodeFrameMethod · 0.45
onEncodeFrameMethod · 0.45

Tested by

no test coverage detected