-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUtils.cpp
More file actions
36 lines (28 loc) · 857 Bytes
/
Copy pathUtils.cpp
File metadata and controls
36 lines (28 loc) · 857 Bytes
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
#include "Utils.hpp"
void SaveAvFrame(FFmpegFrame::Ptr frame, const char *filename)
{
FILE *fDump = fopen(filename, "ab");
auto frame_ptr = frame->get();
uint32_t pitchY = frame_ptr->linesize[0];
uint32_t pitchU = frame_ptr->linesize[1];
uint32_t pitchV = frame_ptr->linesize[2];
uint8_t *avY = frame_ptr->data[0];
uint8_t *avU = frame_ptr->data[1];
uint8_t *avV = frame_ptr->data[2];
for (int i = 0; i < frame_ptr->height; i++)
{
fwrite(avY, frame_ptr->width, 1, fDump);
avY += pitchY;
}
for (int i = 0; i < frame_ptr->height / 2; i++)
{
fwrite(avU, frame_ptr->width / 2, 1, fDump);
avU += pitchU;
}
for (int i = 0; i < frame_ptr->height / 2; i++)
{
fwrite(avV, frame_ptr->width / 2, 1, fDump);
avV += pitchV;
}
fclose(fDump);
}