blob: 842f7a87a795ed819104be00011c1c5e2c02e530 (
plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/* $Id: AviMuxer.h,v 1.10 2003/09/30 14:38:15 titer Exp $
This file is part of the HandBrake source code.
Homepage: <http://beos.titer.org/handbrake/>.
It may be used under the terms of the GNU General Public License. */
#ifndef HB_AVI_MUXER_H
#define HB_AVI_MUXER_H
#include "Common.h"
#include "Fifo.h"
#include "Thread.h"
/* Misc structures used in AVI headers */
#define BITMAP_INFO_SIZE 52
typedef struct BitmapInfo
{
uint32_t FourCC;
uint32_t BytesCount;
uint32_t Size;
uint32_t Width;
uint32_t Height;
uint16_t Planes;
uint16_t BitCount;
uint32_t Compression;
uint32_t SizeImage;
uint32_t XPelsPerMeter;
uint32_t YPelsPerMeter;
uint32_t ClrUsed;
uint32_t ClrImportant;
uint8_t Blue;
uint8_t Green;
uint8_t Red;
uint8_t Reserved;
} BitmapInfo;
#define WAVE_FORMAT_EX_SIZE 38
typedef struct WaveFormatEx
{
uint32_t FourCC;
uint32_t BytesCount;
uint16_t FormatTag;
uint16_t Channels;
uint32_t SamplesPerSec;
uint32_t AvgBytesPerSec;
uint16_t BlockAlign;
uint16_t BitsPerSample;
uint16_t Size;
/* mp3 specific */
uint16_t Id;
uint32_t Flags;
uint16_t BlockSize;
uint16_t FramesPerBlock;
uint16_t CodecDelay;
} WaveFormatEx;
#define AVI_STREAM_HEADER_SIZE 64
typedef struct AviStreamHeader
{
uint32_t FourCC;
uint32_t BytesCount;
uint32_t Type;
uint32_t Handler;
uint32_t Flags;
uint16_t Priority;
uint16_t Language;
uint32_t InitialFrames;
uint32_t Scale;
uint32_t Rate;
uint32_t Start;
uint32_t Length;
uint32_t SuggestedBufferSize;
uint32_t Quality;
uint32_t SampleSize;
int16_t Left;
int16_t Top;
int16_t Right;
int16_t Bottom;
} AviStreamHeader;
#define AVI_MAIN_HEADER_SIZE 64
typedef struct AviMainHeader
{
uint32_t FourCC;
uint32_t BytesCount;
uint32_t MicroSecPerFrame;
uint32_t MaxBytesPerSec;
uint32_t PaddingGranularity;
uint32_t Flags;
uint32_t TotalFrames;
uint32_t InitialFrames;
uint32_t Streams;
uint32_t SuggestedBufferSize;
uint32_t Width;
uint32_t Height;
uint32_t Reserved[4];
} AviMainHeader;
class HBAviIndex : public HBBuffer
{
public:
HBAviIndex( uint32_t size );
void WriteInt32( uint32_t val );
};
class HBAviMuxer : public HBThread
{
public:
HBAviMuxer( HBManager * manager,
HBTitle * title, HBAudio * audio1,
HBAudio * audio2,
char * fileName );
private:
void DoWork();
bool AddVideoChunk();
bool AddAudioChunk( int track );
void UpdateMainHeader();
HBManager * fManager;
HBTitle * fTitle;
HBAudio * fAudio1;
HBAudio * fAudio2;
char * fFileName;
FILE * fFile;
HBBuffer * fVideoBuffer;
HBBuffer * fAudio1Buffer;
HBBuffer * fAudio2Buffer;
/* The main header */
AviMainHeader fMainHeader;
/* The video track */
AviStreamHeader fVideoStreamHeader;
BitmapInfo fVideoStreamFormat;
/* The audio tracks */
AviStreamHeader fAudio1StreamHeader;
WaveFormatEx fAudio1StreamFormat;
AviStreamHeader fAudio2StreamHeader;
WaveFormatEx fAudio2StreamFormat;
uint32_t fRiffBytesCount;
uint32_t fHdrlBytesCount;
uint32_t fMoviBytesCount;
HBAviIndex * fIndex;
};
#endif
|