MCPcopy Create free account
hub / github.com/FFMS/ffms2 / CheckFrame

Function CheckFrame

test/tests.cpp:15–51  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include "tests.h"
14
15bool CheckFrame(const FFMS_Frame *Frame, const FFMS_FrameInfo *info, const TestFrameData *Data) {
16 EQ_CHECK(info->PTS, Data->PTS);
17 EQ_CHECK(!!info->KeyFrame, Data->Keyframe);
18 EQ_CHECK(!!Frame->KeyFrame, Data->Keyframe);
19 EQ_CHECK(Frame->EncodedWidth, Data->Width);
20 EQ_CHECK(Frame->EncodedHeight, Data->Height);
21
22 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get((AVPixelFormat) Frame->ConvertedPixelFormat);
23 NULL_CHECK(desc);
24
25 EXPECT_STREQ(desc->name, Data->PixelFormat);
26 if (!!strcmp(desc->name, Data->PixelFormat))
27 return false;
28
29 struct AVSHA *sha = av_sha_alloc();
30 NULL_CHECK(sha);
31
32 int ret = av_sha_init(sha, 256);
33 EQ_CHECK(ret, 0);
34
35 for (int i = 0; i < av_pix_fmt_count_planes((AVPixelFormat) Frame->ConvertedPixelFormat); i++) {
36 const int subh = i == 0 ? 0 : desc->log2_chroma_h;
37 const int subw = i == 0 ? 0 : desc->log2_chroma_w;
38 for (int y = 0; y < Frame->EncodedHeight >> subh; y++)
39 av_sha_update(sha, Frame->Data[i] + y * Frame->Linesize[i], Frame->EncodedWidth >> subw);
40 }
41
42 uint8_t digest[32];
43 av_sha_final(sha, &digest[0]);
44 av_free(sha);
45
46 bool ok;
47
48 EXPECT_TRUE((ok = !memcmp(&Data->SHA256[0], &digest[0], 32)));
49
50 return ok;
51}

Callers 1

TEST_PFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected