-
Notifications
You must be signed in to change notification settings - Fork 0
/
avbin_stream_info.c
37 lines (30 loc) · 1.12 KB
/
avbin_stream_info.c
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
#include <mex.h>
#include "avbin.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
AVbinFile *file;
int32_t index;
AVbinStreamInfo info;
AVbinResult result;
const char *fieldNames[] = {"type", "width", "height"};
mxArray *infoStruct;
if (nrhs != 2)
{
mexErrMsgIdAndTxt("avbin:usage", "Usage: info = avbin_stream_info(file, index)");
return;
}
file = (AVbinFile *)*((uint64_t *)mxGetData(prhs[0]));
index = mxGetScalar(prhs[1]);
info.structure_size = sizeof(info);
result = avbin_stream_info(file, index, &info);
if (result == AVBIN_RESULT_ERROR)
{
mexErrMsgIdAndTxt("avbin:failed", "An error occurred");
return;
}
infoStruct = mxCreateStructMatrix(1, 1, sizeof(fieldNames) / sizeof(fieldNames[0]), fieldNames);
mxSetField(infoStruct, 0, "type", mxCreateDoubleScalar(info.type));
mxSetField(infoStruct, 0, "width", mxCreateDoubleScalar(info.video.width));
mxSetField(infoStruct, 0, "height", mxCreateDoubleScalar(info.video.height));
plhs[0] = infoStruct;
}