|
1 diff --git a/media/libmkv/WebMElement.c b/media/libmkv/WebMElement.c |
|
2 --- a/media/libmkv/WebMElement.c |
|
3 +++ b/media/libmkv/WebMElement.c |
|
4 @@ -52,32 +52,39 @@ static UInt64 generateTrackID(unsigned i |
|
5 r = r << 32; |
|
6 r += rand(); |
|
7 // UInt64 rval = t ^ r; |
|
8 return t ^ r; |
|
9 } |
|
10 |
|
11 void writeVideoTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing, |
|
12 const char *codecId, unsigned int pixelWidth, unsigned int pixelHeight, |
|
13 + unsigned int displayWidth, unsigned int displayHeight, |
|
14 double frameRate) { |
|
15 EbmlLoc start; |
|
16 UInt64 trackID; |
|
17 Ebml_StartSubElement(glob, &start, TrackEntry); |
|
18 Ebml_SerializeUnsigned(glob, TrackNumber, trackNumber); |
|
19 trackID = generateTrackID(trackNumber); |
|
20 Ebml_SerializeUnsigned(glob, TrackUID, trackID); |
|
21 Ebml_SerializeString(glob, CodecName, "VP8"); // TODO shouldn't be fixed |
|
22 |
|
23 Ebml_SerializeUnsigned(glob, TrackType, 1); // video is always 1 |
|
24 Ebml_SerializeString(glob, CodecID, codecId); |
|
25 { |
|
26 EbmlLoc videoStart; |
|
27 Ebml_StartSubElement(glob, &videoStart, Video); |
|
28 Ebml_SerializeUnsigned(glob, PixelWidth, pixelWidth); |
|
29 Ebml_SerializeUnsigned(glob, PixelHeight, pixelHeight); |
|
30 + if (pixelWidth != displayWidth) { |
|
31 + Ebml_SerializeUnsigned(glob, DisplayWidth, displayWidth); |
|
32 + } |
|
33 + if (pixelHeight != displayHeight) { |
|
34 + Ebml_SerializeUnsigned(glob, DisplayHeight, displayHeight); |
|
35 + } |
|
36 Ebml_SerializeFloat(glob, FrameRate, frameRate); |
|
37 Ebml_EndSubElement(glob, &videoStart); // Video |
|
38 } |
|
39 Ebml_EndSubElement(glob, &start); // Track Entry |
|
40 } |
|
41 void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing, |
|
42 const char *codecId, double samplingFrequency, unsigned int channels, |
|
43 unsigned char *private, unsigned long privateSize) { |
|
44 diff --git a/media/libmkv/WebMElement.h b/media/libmkv/WebMElement.h |
|
45 --- a/media/libmkv/WebMElement.h |
|
46 +++ b/media/libmkv/WebMElement.h |
|
47 @@ -16,16 +16,17 @@ extern "C" { |
|
48 #include "EbmlWriter.h" |
|
49 |
|
50 // these are helper functions |
|
51 void writeHeader(EbmlGlobal *ebml); |
|
52 void writeSegmentInformation(EbmlGlobal *ebml, EbmlLoc *startInfo, unsigned long timeCodeScale, double duration); |
|
53 // this function is a helper only, it assumes a lot of defaults |
|
54 void writeVideoTrack(EbmlGlobal *ebml, unsigned int trackNumber, int flagLacing, |
|
55 const char *codecId, unsigned int pixelWidth, unsigned int pixelHeight, |
|
56 + unsigned int displayWidth, unsigned int displayHeight, |
|
57 double frameRate); |
|
58 void writeAudioTrack(EbmlGlobal *glob, unsigned int trackNumber, int flagLacing, |
|
59 const char *codecId, double samplingFrequency, unsigned int channels, |
|
60 unsigned char *private_, unsigned long privateSize); |
|
61 |
|
62 void writeSimpleBlock(EbmlGlobal *ebml, unsigned char trackNumber, short timeCode, |
|
63 int isKeyframe, unsigned char lacingFlag, int discardable, |
|
64 unsigned char *data, unsigned long dataLength); |