-
Notifications
You must be signed in to change notification settings - Fork 5
/
encode_common.cpp
52 lines (50 loc) · 1.51 KB
/
encode_common.cpp
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
//
// Copyright (C) Tammo Hinrichs 2021. All rights reserved.
// Licensed under the MIT License. See LICENSE.md file for full license information
//
#include "encode.h"
FormatInfo GetFormatInfo(IEncode::BufferFormat fmt, uint sizeX, uint sizeY)
{
FormatInfo info = {};
switch (fmt)
{
case IEncode::BufferFormat::BGRA8:
info.pitch = 4 * sizeX;
info.lines = sizeY;
info.amp = 255.0f;
break;
case IEncode::BufferFormat::NV12:
info.pitch = sizeX;
info.lines = sizeY + sizeY / 2;
info.amp = 255.0f;
info.ymin = info.uvmin = 16.f / 255.f;
info.ymax = 235.f / 255.f;
info.uvmax = 240.f / 255.f;
break;
case IEncode::BufferFormat::YUV444_8:
info.pitch = sizeX;
info.lines = 3 * sizeY;
info.amp = 255.0f;
info.ymin = info.uvmin = 16.f / 255.f;
info.ymax = 235.f / 255.f;
info.uvmax = 240.f / 255.f;
break;
case IEncode::BufferFormat::YUV420_16:
info.pitch = 2 * sizeX;
info.lines = sizeY + sizeY / 2;
info.amp = 65535.0f;
info.ymin = info.uvmin = 64.f / 1023.f;
info.ymax = 940.f / 1023.f;
info.uvmax = 960.f / 1023.f;
break;
case IEncode::BufferFormat::YUV444_16:
info.pitch = 2 * sizeX;
info.lines = 3 * sizeY;
info.amp = 65535.0f;
info.ymin = info.uvmin = 64.f / 1023.f;
info.ymax = 940.f / 1023.f;
info.uvmax = 960.f / 1023.f;
break;
}
return info;
}