annotate libvo/vo_odivx.c @ 1098:ed6ac3915d59

Should fix prob for gcc 2.96/3.0 users, please test.
author atmosfear
date Mon, 11 Jun 2001 16:13:30 +0000
parents 77e0094f0cce
children ccb1f3ddb29a
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 flip_page(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 // we are rady to encode this frame
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 ENC_FRAME enc_frame;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 ENC_RESULT enc_result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 if(++frameno<10) return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
150 enc_frame.image=image;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 enc_frame.bitstream=buffer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 enc_frame.length=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 encore(0x123,0,&enc_frame,&enc_result);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154
612
77e0094f0cce some warnings killed
szabii
parents: 354
diff changeset
155 printf("coded length: %ld \n",enc_frame.length);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 if(encode_name){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 AVIINDEXENTRY i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 FILE *file;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 i.ckid=('c'<<24)|('d'<<16)|('0'<<8)|'0'; // "00dc"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 i.dwFlags=enc_result.isKeyFrame?0x10:0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 i.dwChunkLength=enc_frame.length;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 // Write AVI chunk:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 if((file=fopen(encode_name,"ab"))){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 unsigned char zerobyte=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 i.dwChunkOffset=ftell(file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 fwrite(&i.ckid,4,1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 fwrite(&enc_frame.length,4,1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 fwrite(buffer,enc_frame.length,1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 if(enc_frame.length&1) fwrite(&zerobyte,1,1,file); // padding
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 fclose(file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 // Write AVI index:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 if(encode_index_name && (file=fopen(encode_index_name,"ab"))){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 fwrite(&i,sizeof(i),1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 fclose(file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180
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 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 case IMGFMT_YV12:
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
188 case IMGFMT_YUY2:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
189 // case IMGFMT_BGR|24:
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 extern int encode_bitrate;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 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
199 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 uint32_t frame_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 ENC_PARAM enc_param;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 // file = fopen("encoded.odvx","wb");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 // if(!file) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 case IMGFMT_YV12:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 frame_size=width*height+width*height/2;
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
209 // enc_param.flip=2; // 0=RGB 1=flippedRGB 2=planarYUV format
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 break;
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
211 case IMGFMT_YUY2:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
212 // case IMGFMT_BGR|24:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
213 // enc_param.flip=0; // 0=RGB 1=flippedRGB 2=planarYUV format
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
214 // frame_size=width*height*2;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
215 frame_size=width*height+width*height/2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 default: return -1; // invalid format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 enc_param.x_dim=width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 enc_param.y_dim=height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 image_width=width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 image_height=height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 image_format=format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 image=malloc(frame_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 //clear the buffer
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 memset(image,0x80,frame_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 // buffer for encoded video data:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 buffer=malloc(0x100000);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 if(!buffer) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 // encoding parameters:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 enc_param.framerate=25.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 enc_param.bitrate=encode_bitrate?encode_bitrate:780000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 enc_param.rc_period=300;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 enc_param.max_quantizer=15;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 enc_param.min_quantizer=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 enc_param.search_range=128;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 // init codec:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 encore(0x123,ENC_OPT_INIT,&enc_param,NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 static const vo_info_t*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 get_info(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 return &vo_info;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 uninit(void)
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
262 static void check_events(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
263 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
264 }
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
265
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
266