annotate libmpcodecs/ve_qtvideo.c @ 10690:164fda5feaa6

Add P4 Northwood. (Roman Shiryaev <mih_val@mail.ru>; See <200308250434.38516.mih_val@mail.ru> in mplayer-users)
author ranma
date Mon, 25 Aug 2003 08:38:17 +0000
parents 97b30b4b722f
children 656a1b45b309
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
1 /*qt video encoder using win32 libs
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
2 released under gnu gpl
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
3 (C)Sascha Sommer */
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
4
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
5 #define MAX_IDSIZE 0x6F
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
6
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
7 #include <stdio.h>
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
8 #include <stdlib.h>
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
9 #include <string.h>
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
10
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
11 #include "../config.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
12 #include "../mp_msg.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
13 #include "../bswap.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
14
9435
97b30b4b722f cygwin win32 dll support
faust3
parents: 9217
diff changeset
15 #ifdef WIN32_LOADER
9217
420e2b2f8e5a compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 9014
diff changeset
16 #include "ldt_keeper.h"
420e2b2f8e5a compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 9014
diff changeset
17 #endif
420e2b2f8e5a compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 9014
diff changeset
18
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
19 #ifdef USE_QTX_CODECS
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
20 #include "../loader/qtx/qtxsdk/components.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
21 #include "wine/windef.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
22
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
23 #include "codec-cfg.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
24 #include "stream.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
25 #include "demuxer.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
26 #include "stheader.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
27
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8511
diff changeset
28 #include "muxer.h"
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
29
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
30 #include "img_format.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
31 #include "mp_image.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
32 #include "vf.h"
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
33
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
34 HMODULE WINAPI LoadLibraryA(LPCSTR);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
35 FARPROC WINAPI GetProcAddress(HMODULE,LPCSTR);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
36 int WINAPI FreeLibrary(HMODULE);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
37 static HMODULE handler;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
38
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
39 static OSErr (*FindCodec)(CodecType cType,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
40 CodecComponent specCodec,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
41 CompressorComponent * compressor,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
42 DecompressorComponent * decompressor);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
43 static OSErr (*InitializeQTML)(long flags);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
44 static PixMapHandle (*GetGWorldPixMap)(GWorldPtr offscreenGWorld);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
45 static OSErr (*QTNewGWorldFromPtr)(GWorldPtr *gw,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
46 OSType pixelFormat,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
47 const Rect *boundsRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
48 CTabHandle cTable,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
49 /*GDHandle*/void* aGDevice, /*unused anyway*/
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
50 GWorldFlags flags,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
51 void *baseAddr,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
52 long rowBytes);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
53 static OSErr (*NewHandleClear)(Size byteCount);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
54 static OSErr (*CompressSequenceBegin) (
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
55 ImageSequence *seqID,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
56 PixMapHandle src,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
57 PixMapHandle prev,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
58 const Rect *srcRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
59 const Rect *prevRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
60 short colorDepth,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
61 CodecType cType,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
62 CompressorComponent codec,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
63 CodecQ spatialQuality,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
64 CodecQ temporalQuality,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
65 long keyFrameRate,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
66 CTabHandle ctable,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
67 CodecFlags flags,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
68 ImageDescriptionHandle desc );
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
69
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
70 static OSErr (*CompressSequenceFrame) (
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
71 ImageSequence seqID,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
72 PixMapHandle src,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
73 const Rect *srcRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
74 CodecFlags flags,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
75 Ptr data,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
76 long *dataSize,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
77 UInt8 *similarity,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
78 ICMCompletionProcRecordPtr asyncCompletionProc );
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
79
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
80 static OSErr (*GetMaxCompressionSize)(PixMapHandle src,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
81 const Rect *srcRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
82 short colorDepth,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
83 CodecQ quality,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
84 CodecType cType,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
85 CompressorComponent codec,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
86 long *size );
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
87 static OSErr (*CDSequenceEnd)( ImageSequence seqID );
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
88 static Component (*FindNextComponent)(Component prev,ComponentDescription* desc);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
89 static long (*CountComponents)(ComponentDescription* desc);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
90 static OSErr (*GetComponentInfo)(Component prev,ComponentDescription* desc,Handle h1,Handle h2,Handle h3);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
91
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
92
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
93
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
94 //static int format=mmioFOURCC('S','V','Q','1');
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
95 static int format=mmioFOURCC('S','V','Q','3');
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
96
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
97
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
98
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
99 //static void *frame_in; //input frame
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
100 static void *frame_prev; //previous frame
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
101 static void *frame_comp; //compressed frame
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
102 static GWorldPtr frame_GWorld_in = NULL;//a GWorld is some kind of description for a drawing environment
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
103 static GWorldPtr frame_GWorld_prev = NULL;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
104 static Rect FrameRect;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
105
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
106 static CompressorComponent compressor;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
107 static DecompressorComponent decompressor;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
108 static ImageDescriptionHandle desc;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
109 static ImageSequence seq;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
110
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
111
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
112
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
113
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
114
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
115 struct vf_priv_s {
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8511
diff changeset
116 muxer_stream_t* mux;
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
117 //dv_encoder_t* enc;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
118
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
119 };
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
120 #define mux_v (vf->priv->mux)
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
121
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
122 //===========================================================================//
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
123
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
124 static int config(struct vf_instance_s* vf,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
125 int width, int height, int d_width, int d_height,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
126 unsigned int flags, unsigned int outfmt){
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
127 OSErr cres;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
128 ComponentDescription cdesc;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
129 mux_v->bih->biWidth=width;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
130 mux_v->bih->biHeight=height;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
131 mux_v->bih->biSizeImage=width*height*2;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
132
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
133
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
134
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
135 memset(&desc,0,sizeof(cdesc));
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
136 cdesc.componentType= (((unsigned char)'i')<<24)|
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
137 (((unsigned char)'m')<<16)|
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
138 (((unsigned char)'c')<<8)|
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
139 (((unsigned char)'o'));
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
140
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
141 cdesc.componentSubType=bswap_32(format);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
142 cdesc.componentManufacturer=0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
143 cdesc.componentFlags=0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
144 cdesc.componentFlagsMask=0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
145
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
146
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
147 printf("Count = %d\n",CountComponents(&cdesc));
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
148 compressor=FindNextComponent(NULL,&cdesc);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
149 if(!compressor){
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
150 printf("Cannot find requested component\n");
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
151 return(0);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
152 }
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
153 printf("Found it! ID = 0x%X\n",compressor);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
154
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
155 // cres= FindCodec (fourcc,anyCodec,&compressor,&decompressor );
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
156 // printf("FindCodec returned:%i compressor: 0x%X decompressor: 0x%X\n",cres&0xFFFF,compressor,decompressor);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
157
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
158 return 1;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
159 }
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
160
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
161 static int control(struct vf_instance_s* vf, int request, void* data){
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
162
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
163 return CONTROL_UNKNOWN;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
164 }
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
165
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
166 static int query_format(struct vf_instance_s* vf, unsigned int fmt){
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
167 if(fmt==IMGFMT_YUY2) return 3;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
168 return 0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
169 }
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
170
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
171 static int codec_inited = 0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
172
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
173 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
174
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
175 OSErr cres;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
176 long framesizemax;
8511
2b955a07fdcf set keyframe flag at encoding
arpi
parents: 8471
diff changeset
177 UInt8 similarity=0;
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
178 long compressedsize;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
179 int in_format=kYUVSPixelFormat;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
180 int width = mpi->width;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
181 int height = mpi->height;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
182 int stride = width*2;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
183 if(!codec_inited){
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
184 FrameRect.top=0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
185 FrameRect.left=0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
186 FrameRect.right=width;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
187 FrameRect.bottom=height;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
188 cres = QTNewGWorldFromPtr(
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
189 &frame_GWorld_in,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
190 in_format,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
191 &FrameRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
192 0,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
193 0,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
194 0,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
195 mpi->planes[0],
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
196 stride);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
197 printf("NewGWorldFromPtr returned:%i\n",cres&0xFFFF);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
198 //dunno what todo about this
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
199 frame_prev = malloc(stride * height);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
200 cres = QTNewGWorldFromPtr(
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
201 &frame_GWorld_prev,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
202 in_format,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
203 &FrameRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
204 0,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
205 0,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
206 0,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
207 frame_prev,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
208 stride);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
209 printf("height:%i width:%i stride:%i\n",height,width,stride);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
210 printf("NewGWorldFromPtr returned:%i\n",cres&0xFFFF);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
211 cres= GetMaxCompressionSize (
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
212 GetGWorldPixMap(frame_GWorld_in),
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
213 &FrameRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
214 24,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
215 codecNormalQuality,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
216 bswap_32(format),
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
217 compressor,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
218 &framesizemax );
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
219 printf("GetMaxCompressionSize returned:%i : MaxSize:%i\n",cres&0xFFFF,framesizemax);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
220 frame_comp=malloc(framesizemax);
8511
2b955a07fdcf set keyframe flag at encoding
arpi
parents: 8471
diff changeset
221
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
222 desc = (ImageDescriptionHandle)NewHandleClear(MAX_IDSIZE); //memory where the desc will be stored
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
223 (*desc)->idSize=MAX_IDSIZE;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
224
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
225 cres= CompressSequenceBegin (
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
226 &seq,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
227 GetGWorldPixMap( frame_GWorld_in),
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
228 GetGWorldPixMap( frame_GWorld_prev),
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
229 &FrameRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
230 &FrameRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
231 24, // color depth
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
232 bswap_32(format), // fourcc
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
233 compressor, // codec component
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
234 codecNormalQuality, //codecNormalQuality,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
235 codecMaxQuality, //codecNormalQuality,
8511
2b955a07fdcf set keyframe flag at encoding
arpi
parents: 8471
diff changeset
236 10*30, // keyframe rate
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
237 0,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
238 0,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
239 desc);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
240 printf("CompressSequenceBegin returned:%i\n",cres&0xFFFF);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
241 printf("Sequence ID:%i\n",seq);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
242
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
243 dump_ImageDescription(*desc);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
244 codec_inited++;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
245 }
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
246 cres = CompressSequenceFrame (
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
247 seq,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
248 GetGWorldPixMap(frame_GWorld_in),
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
249 &FrameRect,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
250 0,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
251 (char*)mux_v->buffer,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
252 &compressedsize,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
253 &similarity,
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
254 0);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
255
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
256 if(cres&0xFFFF)printf("CompressSequenceFrame returned:%i\n",cres&0xFFFF);
8511
2b955a07fdcf set keyframe flag at encoding
arpi
parents: 8471
diff changeset
257 #if 0
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
258 printf("Size %i->%i \n",stride*height,compressedsize);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
259 printf("Ratio: %i:1\n",(stride*height)/compressedsize);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
260 #endif
9014
c671e9adbe22 Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.
arpi
parents: 8733
diff changeset
261 muxer_write_chunk(mux_v, compressedsize , similarity?0:0x10);
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
262
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
263 if(((*desc)->idSize)>MAX_IDSIZE){
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
264 printf("FATAL! idSize=%d too big, increase MAX_IDSIZE in ve_qtvideo.c!\n",((*desc)->idSize));
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
265 } else {
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
266 // according to QT docs, imagedescription may be changed while encoding
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
267 // a frame (even its size may (and does!) change!)
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
268 memcpy(mux_v->bih+1,*desc,(*desc)->idSize);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
269 }
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
270
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
271 return 1;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
272 }
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
273
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
274 //===========================================================================//
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
275
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
276 static int vf_open(vf_instance_t *vf, char* args){
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
277 OSErr cres = 1;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
278 vf->config=config;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
279 vf->control=control;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
280 vf->query_format=query_format;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
281 vf->put_image=put_image;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
282 vf->priv=malloc(sizeof(struct vf_priv_s));
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
283 memset(vf->priv,0,sizeof(struct vf_priv_s));
8585
27da710563c2 the long-waited MUXER layer, and new MPEG-PS muxer
arpi
parents: 8511
diff changeset
284 vf->priv->mux=(muxer_stream_t*)args;
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
285
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
286 mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)+MAX_IDSIZE);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
287 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER)+MAX_IDSIZE;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
288 mux_v->bih->biWidth=0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
289 mux_v->bih->biHeight=0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
290 mux_v->bih->biCompression=format;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
291 mux_v->bih->biPlanes=1;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
292 mux_v->bih->biBitCount=24;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
293
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
294
9435
97b30b4b722f cygwin win32 dll support
faust3
parents: 9217
diff changeset
295 #ifdef WIN32_LOADER
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
296 Setup_LDT_Keeper();
9435
97b30b4b722f cygwin win32 dll support
faust3
parents: 9217
diff changeset
297 #endif
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
298 handler = LoadLibraryA("qtmlClient.dll");
8733
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
299 InitializeQTML = (OSErr (*)(long))GetProcAddress(handler, "InitializeQTML");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
300 GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
301 QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
302 NewHandleClear = (OSErr(*)(Size))GetProcAddress(handler, "NewHandleClear");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
303 FindCodec = (OSErr (*)(CodecType,CodecComponent,CompressorComponent *,DecompressorComponent *))GetProcAddress(handler,"FindCodec");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
304 CompressSequenceBegin = (OSErr(*)(ImageSequence *,PixMapHandle,PixMapHandle,const Rect *,const Rect *,short,CodecType,CompressorComponent,CodecQ,CodecQ,long,CTabHandle,CodecFlags,ImageDescriptionHandle))GetProcAddress(handler,"CompressSequenceBegin");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
305 CompressSequenceFrame = (OSErr(*)(ImageSequence,PixMapHandle,const Rect *,CodecFlags,Ptr,long *,UInt8 *,ICMCompletionProcRecordPtr))GetProcAddress(handler,"CompressSequenceFrame");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
306 GetMaxCompressionSize = (OSErr(*)(PixMapHandle,const Rect *,short,CodecQ,CodecType,CompressorComponent,long *))GetProcAddress(handler,"GetMaxCompressionSize");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
307 CDSequenceEnd = (OSErr (*)(ImageSequence))GetProcAddress(handler,"CDSequenceEnd");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
308 FindNextComponent = (Component (*)(Component,ComponentDescription*))GetProcAddress(handler, "FindNextComponent");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
309 CountComponents = (long (*)(ComponentDescription*))GetProcAddress(handler, "CountComponents");
478561617705 compiler warning fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 8585
diff changeset
310 GetComponentInfo = (OSErr (*)(Component,ComponentDescription*,Handle,Handle,Handle))GetProcAddress(handler, "GetComponentInfo");
8471
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
311 if(!InitializeQTML ||!CompressSequenceBegin){
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
312 printf("invalid qt DLL!\n");
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
313 return 0;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
314 }
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
315 //printf("%i,%i,%i\n",mmioFOURCC('S','V','Q','1'),'SVQ1',bswap_32(mmioFOURCC('S','V','Q','1')));
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
316 cres=InitializeQTML(6+16);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
317 printf("InitializeQTML returned %i\n",cres);
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
318 return 1;
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
319 }
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
320
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
321 vf_info_t ve_info_qtvideo = {
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
322 "Quicktime video encoder using win32 DLLs",
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
323 "qtvideo",
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
324 "Sascha Sommer",
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
325 "for internal use by mencoder",
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
326 vf_open
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
327 };
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
328
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
329 //===========================================================================//
0b7839c27be9 Sorenson 1/3 encoding just for fun :)
arpi
parents:
diff changeset
330 #endif