annotate libvo/vo_odivx.c @ 325:b2fd5c172f80

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