annotate libvo/vo_odivx.c @ 3426:ca4beb5dd3f7

g72x support
author arpi
date Mon, 10 Dec 2001 01:34:36 +0000
parents ccb1f3ddb29a
children ed5b85b713a3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * OpenDivX AVI file writer
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 LIBVO_EXTERN(odivx)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 #include <sys/ioctl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <unistd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <fcntl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #include <sys/mman.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 #include "../encore/encore.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21
354
7de9e48c83a5 memcpy() moved mmx.h -> fastmemcpy.h
arpi_esp
parents: 350
diff changeset
22 #include "fastmemcpy.h"
350
601822cc8c52 applied MMX2 memcpy() patch by Nick Kurshev
arpi_esp
parents: 80
diff changeset
23
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 static vo_info_t vo_info =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 "OpenDivX AVI File writer",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 "odivx",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 "Arpad Gereoffy <arpi@esp-team.scene.hu>",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 ""
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 static uint8_t *image=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 static int image_width=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 static int image_height=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 static unsigned int image_format=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 static char *buffer=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 static int frameno=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 extern char* encode_name;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 extern char* encode_index_name;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 //static uint32_t draw_slice(uint8_t *src[], uint32_t slice_num)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 uint8_t *s;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 uint8_t *d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 int dstride=image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 // copy Y
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 d=image+dstride*y+x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 s=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 memcpy(d,s,w);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 s+=stride[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 d+=dstride;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 w/=2;h/=2;x/=2;y/=2; dstride/=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 // copy U
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 d=image+image_width*image_height + dstride*y+x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 s=src[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 memcpy(d,s,w);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 s+=stride[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 d+=dstride;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 // copy V
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 d=image+image_width*image_height +image_width*image_height/4 + dstride*y+x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 s=src[2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 memcpy(d,s,w);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 s+=stride[2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 d+=dstride;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 draw_frame(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 uint8_t *d=image;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 switch(image_format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 case IMGFMT_YV12:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 // copy Y
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 memcpy(d,src[0],image_width*image_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 // copy U
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 d+=image_width*image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 memcpy(d,src[1],image_width*image_height/4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 // copy V
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 d+=image_width*image_height/4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 memcpy(d,src[2],image_width*image_height/4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 break;
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
98 case IMGFMT_YUY2: {
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
99 uint8_t *dY=image;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
100 uint8_t *dU=image+image_width*image_height;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
101 uint8_t *dV=dU+image_width*image_height/4;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
102 uint8_t *s=src[0];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
103 int y;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
104 for(y=0;y<image_height;y+=2){
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
105 uint8_t *e=s+image_width*2;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
106 while(s<e){
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
107 *dY++=s[0];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
108 *dU++=s[1];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
109 *dY++=s[2];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
110 *dV++=s[3];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
111 s+=4;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
112 }
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
113 e=s+image_width*2;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
114 while(s<e){
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
115 *dY++=s[0];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
116 *dY++=s[2];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
117 s+=4;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
118 }
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
119 }
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
120
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
121 // case IMGFMT_BGR|24:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
122 // memcpy(d,src[0],image_width*image_height*2);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 }
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
125 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 typedef unsigned int DWORD;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 typedef struct
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 DWORD ckid;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 DWORD dwFlags;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 DWORD dwChunkOffset; // Position of chunk
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 DWORD dwChunkLength; // Length of chunk
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 } AVIINDEXENTRY;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139
1502
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 612
diff changeset
140 static void draw_osd(void)
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 612
diff changeset
141 {
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 612
diff changeset
142 }
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 612
diff changeset
143
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 flip_page(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 // we are rady to encode this frame
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 ENC_FRAME enc_frame;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 ENC_RESULT enc_result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 if(++frameno<10) return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
154 enc_frame.image=image;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 enc_frame.bitstream=buffer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 enc_frame.length=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 encore(0x123,0,&enc_frame,&enc_result);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158
612
77e0094f0cce some warnings killed
szabii
parents: 354
diff changeset
159 printf("coded length: %ld \n",enc_frame.length);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 if(encode_name){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 AVIINDEXENTRY i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 FILE *file;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 i.ckid=('c'<<24)|('d'<<16)|('0'<<8)|'0'; // "00dc"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 i.dwFlags=enc_result.isKeyFrame?0x10:0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 i.dwChunkLength=enc_frame.length;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 // Write AVI chunk:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 if((file=fopen(encode_name,"ab"))){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 unsigned char zerobyte=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 i.dwChunkOffset=ftell(file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 fwrite(&i.ckid,4,1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 fwrite(&enc_frame.length,4,1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 fwrite(buffer,enc_frame.length,1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 if(enc_frame.length&1) fwrite(&zerobyte,1,1,file); // padding
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 fclose(file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 // Write AVI index:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 if(encode_index_name && (file=fopen(encode_index_name,"ab"))){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 fwrite(&i,sizeof(i),1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 fclose(file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 case IMGFMT_YV12:
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
192 case IMGFMT_YUY2:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
193 // case IMGFMT_BGR|24:
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 extern int encode_bitrate;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 uint32_t frame_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 ENC_PARAM enc_param;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 // file = fopen("encoded.odvx","wb");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 // if(!file) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 case IMGFMT_YV12:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 frame_size=width*height+width*height/2;
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
213 // enc_param.flip=2; // 0=RGB 1=flippedRGB 2=planarYUV format
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 break;
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
215 case IMGFMT_YUY2:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
216 // case IMGFMT_BGR|24:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
217 // enc_param.flip=0; // 0=RGB 1=flippedRGB 2=planarYUV format
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
218 // frame_size=width*height*2;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
219 frame_size=width*height+width*height/2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 default: return -1; // invalid format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 enc_param.x_dim=width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 enc_param.y_dim=height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 image_width=width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 image_height=height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 image_format=format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 image=malloc(frame_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 //clear the buffer
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 memset(image,0x80,frame_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 // buffer for encoded video data:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 buffer=malloc(0x100000);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 if(!buffer) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 // encoding parameters:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 enc_param.framerate=25.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 enc_param.bitrate=encode_bitrate?encode_bitrate:780000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 enc_param.rc_period=300;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 enc_param.max_quantizer=15;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 enc_param.min_quantizer=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 enc_param.search_range=128;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 // init codec:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 encore(0x123,ENC_OPT_INIT,&enc_param,NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 static const vo_info_t*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 get_info(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 return &vo_info;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
266 static void check_events(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
267 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
268 }
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
269
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
270