Skip to content

Commit 4fa2ae9

Browse files
committed
WIP AVI playback
1 parent bd89a2d commit 4fa2ae9

File tree

16 files changed

+734
-210
lines changed

16 files changed

+734
-210
lines changed

DumpAVIHeaders/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ static void Main(string[] args) {
387387
return;
388388
}
389389

390-
using (var br = new BinaryReader(new FileStream(args[0], FileMode.Open))) {
390+
using (var br = new BinaryReader(new FileStream(args[0], FileMode.Open, FileAccess.Read))) {
391391
uint RIFF = StringToFourCC("RIFF");
392392

393393
do {

MLDX12VideoCapture/MLAVICommon.h

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#pragma once
2+
3+
#include <stdint.h>
4+
#include <string>
5+
6+
enum MLAviImageFormat {
7+
MLIF_YUV422v210,
8+
};
9+
10+
enum MLFOURCC {
11+
MLFOURCC_RIFF = 0x46464952,
12+
MLFOURCC_AVI = 0x20495641,
13+
MLFOURCC_LIST = 0x5453494c,
14+
MLFOURCC_avih = 0x68697661,
15+
MLFOURCC_strh = 0x68727473,
16+
MLFOURCC_strf = 0x66727473,
17+
MLFOURCC_vids = 0x73646976,
18+
MLFOURCC_v210 = 0x30313276,
19+
MLFOURCC_AVIX = 0x58495641,
20+
MLFOURCC_movi = 0x69766f6d,
21+
MLFOURCC_00db = 0x62643030,
22+
MLFOURCC_00dc = 0x63643030,
23+
};
24+
25+
struct MLAviMainHeader {
26+
uint32_t fcc;
27+
uint32_t cb;
28+
uint32_t dwMicroSecPerFrame;
29+
uint32_t dwMaxBytesPersec;
30+
uint32_t dwPaddingGranularity;
31+
uint32_t dwFlags;
32+
33+
uint32_t dwTotalFrames;
34+
uint32_t dwInitialFrames;
35+
uint32_t dwStreams;
36+
uint32_t dwSuggestedBufferSize;
37+
uint32_t dwWidth;
38+
39+
uint32_t dwHeight;
40+
uint32_t dwReserved0;
41+
uint32_t dwReserved1;
42+
uint32_t dwReserved2;
43+
uint32_t dwReserved3;
44+
};
45+
46+
struct MLAviStreamHeader {
47+
uint32_t fcc;
48+
uint32_t cb;
49+
uint32_t fccType;
50+
uint32_t fccHandler;
51+
uint32_t dwFlags;
52+
uint16_t wPriority;
53+
uint16_t wLanguage;
54+
55+
uint32_t dwInitialFrames;
56+
uint32_t dwScale;
57+
uint32_t dwRate;
58+
uint32_t dwStart;
59+
uint32_t dwLength;
60+
61+
uint32_t dwSuggestedBufferSize;
62+
uint32_t dwQuality;
63+
uint32_t dwSampleSize;
64+
short left;
65+
short top;
66+
67+
short right;
68+
short bottom;
69+
};
70+
71+
struct MLBitmapInfoHeader {
72+
uint32_t biSize;
73+
int biWidth;
74+
int biHeight;
75+
short biPlanes;
76+
short biBitCount;
77+
78+
uint32_t biCompression;
79+
uint32_t biSizeImage;
80+
int biXPelsPerMeter;
81+
int biYPelsPerMeter;
82+
uint32_t biClrUsed;
83+
84+
uint32_t biClrImportant;
85+
};
86+
87+
struct MLRiffHeader {
88+
uint32_t riff;
89+
uint32_t bytes;
90+
uint32_t type;
91+
};
92+
93+
struct MLListHeader {
94+
uint32_t LIST;
95+
uint32_t bytes;
96+
uint32_t type;
97+
};
98+
99+
struct MLStreamDataHeader {
100+
uint32_t fcc;
101+
uint32_t bytes;
102+
};
103+
104+
uint32_t MLStringToFourCC(const char *s);
105+
106+
const std::string MLFourCCtoString(uint32_t fourcc);

MLDX12VideoCapture/MLAviCommon.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "MLAVICommon.h"
2+
#include <string.h>
3+
4+
uint32_t MLStringToFourCC(const char *s)
5+
{
6+
uint32_t fcc = 0;
7+
int count = (int)strlen(s);
8+
if (4 < count) {
9+
count = 4;
10+
}
11+
12+
for (int i = 0; i < count; ++i) {
13+
fcc |= (((unsigned char)s[i]) << i * 8);
14+
}
15+
16+
for (int i = count; i < 4; ++i) {
17+
fcc |= (((unsigned char)' ') << i * 8);
18+
}
19+
20+
return fcc;
21+
}
22+
23+
const std::string
24+
MLFourCCtoString(uint32_t fourcc)
25+
{
26+
char s[5];
27+
memset(s, 0, sizeof s);
28+
s[0] = (fourcc >> 0) & 0xff;
29+
s[1] = (fourcc >> 8) & 0xff;
30+
s[2] = (fourcc >> 16) & 0xff;
31+
s[3] = (fourcc >> 24) & 0xff;
32+
33+
return std::string(s);
34+
}

0 commit comments

Comments
 (0)