-
Notifications
You must be signed in to change notification settings - Fork 80
/
components.cpp
41 lines (37 loc) · 1.52 KB
/
components.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
#include "nmos/components.h"
#include "cpprest/json_ops.h"
namespace nmos
{
web::json::value make_component(const nmos::component_name& name, unsigned int width, unsigned int height, unsigned int bit_depth)
{
return web::json::value_of({
{ U("name"), web::json::value::string(name.name) },
{ U("width"), width },
{ U("height"), height },
{ U("bit_depth"), bit_depth }
});
}
// deprecated, see overload with sdp::sampling in nmos/sdp_utils.h
web::json::value make_components(chroma_subsampling chroma_subsampling, unsigned int frame_width, unsigned int frame_height, unsigned int bit_depth)
{
using web::json::value;
using web::json::value_of;
switch (chroma_subsampling)
{
case RGB444:
return value_of({
make_component(component_names::R, frame_width, frame_height, bit_depth),
make_component(component_names::G, frame_width, frame_height, bit_depth),
make_component(component_names::B, frame_width, frame_height, bit_depth)
});
case YCbCr422:
return value_of({
make_component(component_names::Y, frame_width, frame_height, bit_depth),
make_component(component_names::Cb, frame_width / 2, frame_height, bit_depth),
make_component(component_names::Cr, frame_width / 2, frame_height, bit_depth)
});
default:
return web::json::value::null();
}
}
}