annotate libvo/vo_odivx.c @ 6604:62ce54563e56

Hopefully the end of the RealPlayer codecs saga.. Explained where to put things and which configure options to use in case something goes wrong.
author diego
date Sat, 29 Jun 2002 16:27:48 +0000
parents 32e1f5042f65
children eca7dbad0166
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>
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
8 #include <errno.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 LIBVO_EXTERN(odivx)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <sys/ioctl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <unistd.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #include <fcntl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 #include <sys/mman.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 #include "../encore/encore.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22
354
7de9e48c83a5 memcpy() moved mmx.h -> fastmemcpy.h
arpi_esp
parents: 350
diff changeset
23 #include "fastmemcpy.h"
350
601822cc8c52 applied MMX2 memcpy() patch by Nick Kurshev
arpi_esp
parents: 80
diff changeset
24
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 static vo_info_t vo_info =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 "OpenDivX AVI File writer",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 "odivx",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 "Arpad Gereoffy <arpi@esp-team.scene.hu>",
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 static uint8_t *image=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 static int image_width=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 static int image_height=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 static unsigned int image_format=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 static char *buffer=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 static int frameno=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 extern char* encode_name;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 extern char* encode_index_name;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 //static uint32_t draw_slice(uint8_t *src[], uint32_t slice_num)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 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
45 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 uint8_t *s;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 uint8_t *d;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 int dstride=image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 // copy Y
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 d=image+dstride*y+x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 s=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 memcpy(d,s,w);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 s+=stride[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 d+=dstride;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 w/=2;h/=2;x/=2;y/=2; dstride/=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 // copy U
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 d=image+image_width*image_height + dstride*y+x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 s=src[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 memcpy(d,s,w);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 s+=stride[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 d+=dstride;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 // copy V
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 d=image+image_width*image_height +image_width*image_height/4 + dstride*y+x;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 s=src[2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 memcpy(d,s,w);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 s+=stride[2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 d+=dstride;
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 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 draw_frame(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 uint8_t *d=image;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 switch(image_format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 case IMGFMT_YV12:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 // copy Y
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 memcpy(d,src[0],image_width*image_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 // copy U
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 d+=image_width*image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 memcpy(d,src[1],image_width*image_height/4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 // copy V
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 d+=image_width*image_height/4;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 memcpy(d,src[2],image_width*image_height/4);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 break;
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
99 case IMGFMT_YUY2: {
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
100 uint8_t *dY=image;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
101 uint8_t *dU=image+image_width*image_height;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
102 uint8_t *dV=dU+image_width*image_height/4;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
103 uint8_t *s=src[0];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
104 int y;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
105 for(y=0;y<image_height;y+=2){
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
106 uint8_t *e=s+image_width*2;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
107 while(s<e){
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
108 *dY++=s[0];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
109 *dU++=s[1];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
110 *dY++=s[2];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
111 *dV++=s[3];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
112 s+=4;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
113 }
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
114 e=s+image_width*2;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
115 while(s<e){
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
116 *dY++=s[0];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
117 *dY++=s[2];
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
118 s+=4;
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
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
122 // case IMGFMT_BGR|24:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
123 // memcpy(d,src[0],image_width*image_height*2);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
124 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 }
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
126 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 typedef unsigned int DWORD;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 typedef struct
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135 DWORD ckid;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 DWORD dwFlags;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137 DWORD dwChunkOffset; // Position of chunk
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 DWORD dwChunkLength; // Length of chunk
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 } AVIINDEXENTRY;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140
1502
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 612
diff changeset
141 static void draw_osd(void)
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 612
diff changeset
142 {
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 612
diff changeset
143 }
ccb1f3ddb29a atlka@pg.gda.pl:
atlka
parents: 612
diff changeset
144
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 flip_page(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 // we are rady to encode this frame
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 ENC_FRAME enc_frame;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 ENC_RESULT enc_result;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 if(++frameno<10) return;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
155 enc_frame.image=image;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 enc_frame.bitstream=buffer;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 enc_frame.length=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 encore(0x123,0,&enc_frame,&enc_result);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
612
77e0094f0cce some warnings killed
szabii
parents: 354
diff changeset
160 printf("coded length: %ld \n",enc_frame.length);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 if(encode_name){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 AVIINDEXENTRY i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 FILE *file;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 i.ckid=('c'<<24)|('d'<<16)|('0'<<8)|'0'; // "00dc"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 i.dwFlags=enc_result.isKeyFrame?0x10:0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 i.dwChunkLength=enc_frame.length;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 // Write AVI chunk:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 if((file=fopen(encode_name,"ab"))){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 unsigned char zerobyte=0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 i.dwChunkOffset=ftell(file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 fwrite(&i.ckid,4,1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 fwrite(&enc_frame.length,4,1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 fwrite(buffer,enc_frame.length,1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 if(enc_frame.length&1) fwrite(&zerobyte,1,1,file); // padding
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 // Write AVI index:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 if(encode_index_name && (file=fopen(encode_index_name,"ab"))){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 fwrite(&i,sizeof(i),1,file);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 fclose(file);
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 case IMGFMT_YV12:
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
193 case IMGFMT_YUY2:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
194 // case IMGFMT_BGR|24:
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 extern int encode_bitrate;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 static uint32_t
4433
df8e0f71cc3c new info for tuning
nick
parents: 4352
diff changeset
203 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format,const vo_tune_info_t *info)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 uint32_t frame_size;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 ENC_PARAM enc_param;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 // file = fopen("encoded.odvx","wb");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 // if(!file) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 case IMGFMT_YV12:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 frame_size=width*height+width*height/2;
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
214 // enc_param.flip=2; // 0=RGB 1=flippedRGB 2=planarYUV format
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 break;
80
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
216 case IMGFMT_YUY2:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
217 // case IMGFMT_BGR|24:
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
218 // enc_param.flip=0; // 0=RGB 1=flippedRGB 2=planarYUV format
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
219 // frame_size=width*height*2;
74064c2929a1 updated to opendivx 0.48
arpi_esp
parents: 31
diff changeset
220 frame_size=width*height+width*height/2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 break;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 default: return -1; // invalid format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 enc_param.x_dim=width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 enc_param.y_dim=height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 image_width=width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 image_height=height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 image_format=format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 image=malloc(frame_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 //clear the buffer
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 memset(image,0x80,frame_size);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 // buffer for encoded video data:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 buffer=malloc(0x100000);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 if(!buffer) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 // encoding parameters:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 enc_param.framerate=25.0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 enc_param.bitrate=encode_bitrate?encode_bitrate:780000;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 enc_param.rc_period=300;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 enc_param.max_quantizer=15;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 enc_param.min_quantizer=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 enc_param.search_range=128;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 // init codec:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 encore(0x123,ENC_OPT_INIT,&enc_param,NULL);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 static const vo_info_t*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 get_info(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 return &vo_info;
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 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 uninit(void)
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
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
265 static void check_events(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
266 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
267 }
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
268
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
269 static uint32_t preinit(const char *arg)
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
270 {
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
271 if(arg)
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
272 {
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
273 printf("vo_odivx: Unknown subdevice: %s\n",arg);
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
274 return ENOSYS;
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
275 }
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4596
diff changeset
276 return 0;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
277 }
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
278
4596
c35d7ce151b3 10000hl to Holm... control MUST BE static...
arpi
parents: 4592
diff changeset
279 static uint32_t control(uint32_t request, void *data, ...)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
280 {
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
281 switch (request) {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
282 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
283 return query_format(*((uint32_t*)data));
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
284 }
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4433
diff changeset
285 return VO_NOTIMPL;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 1502
diff changeset
286 }