annotate libvo/vo_jpeg.c @ 8969:a892e5f051e1

Adding support for more logical libaf configuration
author anders
date Fri, 17 Jan 2003 01:00:07 +0000
parents 1ac2523775ad
children 555d64fc02b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
1 #define DISP
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
2
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
3 /*
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
4 * vo_jpeg.c, JPEG Renderer for Mplayer
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
5 *
5649
764db6a6a851 upsz, 10l :)
pontscho
parents: 5648
diff changeset
6 * Copyright 2002 by Pontscho (pontscho@makacs.poliod.hu)
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
7 *
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
8 */
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
9
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
10 #include <stdio.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
11 #include <stdlib.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
12 #include <string.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
13 #include <errno.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
14
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
15 #include <jpeglib.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
16
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
17 #include "config.h"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
18 #include "video_out.h"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
19 #include "video_out_internal.h"
7472
c4434bdf6e51 tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents: 7124
diff changeset
20 #include "sub.h"
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
21
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
22 #include "../postproc/swscale.h"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
23 #include "../postproc/rgb2rgb.h"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
24
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7487
diff changeset
25 static vo_info_t info=
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
26 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
27 "JPEG file",
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
28 "jpeg",
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
29 "Zoltan Ponekker (pontscho@makacs.poliod.hu)",
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
30 ""
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
31 };
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
32
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7487
diff changeset
33 LIBVO_EXTERN (jpeg)
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7487
diff changeset
34
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
35 #define RGB 0
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
36 #define BGR 1
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
37
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
38 extern int verbose;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
39 static int image_width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
40 static int image_height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
41 static int image_format;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
42 static uint8_t *image_data=NULL;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
43 static unsigned int scale_srcW=0, scale_srcH=0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
44
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
45 int jpeg_baseline = 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
46 int jpeg_progressive_mode = 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
47 int jpeg_optimize = 100;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
48 int jpeg_smooth = 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
49 int jpeg_quality = 75;
5659
b17666766389 fix ".". thanksz pl.
pontscho
parents: 5649
diff changeset
50 char * jpeg_outdir = ".";
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
51
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
52 #define bpp 24
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
53
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
54 static int cspace=RGB;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
55 static int framenum=0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
56
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
57 static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
58 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
59 vo_draw_alpha_rgb24(w, h, src, srca, stride, image_data + 3 * (y0 * image_width + x0), 3 * image_width);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
60 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
61
7124
eca7dbad0166 finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents: 6751
diff changeset
62 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
63 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
64 if ( fullscreen&0x04 && ( width != d_width || height != d_height )&&( ( format == IMGFMT_YV12 ) ) )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
65 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
66 // software scaling
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
67 image_width=(d_width + 7) & ~7;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
68 image_height=d_height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
69 scale_srcW=width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
70 scale_srcH=height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
71 SwScale_Init();
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
72 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
73 else
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
74 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
75 image_height=height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
76 image_width=width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
77 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
78
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
79 image_format=format;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
80 switch(format)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
81 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
82 case IMGFMT_BGR32:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
83 cspace=BGR;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
84 image_data=malloc( image_width * image_height * 3 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
85 break;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
86 case IMGFMT_BGR24:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
87 cspace=BGR;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
88 image_data=malloc( image_width * image_height * 3 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
89 break;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
90 case IMGFMT_RGB24:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
91 cspace=RGB;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
92 break;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
93 case IMGFMT_IYUV:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
94 case IMGFMT_I420:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
95 case IMGFMT_YV12:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
96 cspace=BGR;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
97 yuv2rgb_init( bpp,MODE_BGR );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
98 image_data=malloc( image_width * image_height * 3 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
99 break;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
100 default:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
101 return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
102 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
103
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
104 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
105 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
106
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
107 static uint32_t jpeg_write( uint8_t * name,uint8_t * buffer )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
108 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
109 FILE * o;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
110 struct jpeg_compress_struct cinfo;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
111 struct jpeg_error_mgr jerr;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
112 JSAMPROW row_pointer[1];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
113 int row_stride;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
114
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
115 if ( !buffer ) return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
116 if ( (o=fopen( name,"wb" )) == NULL ) return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
117
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
118 cinfo.err=jpeg_std_error(&jerr);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
119 jpeg_create_compress(&cinfo);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
120 jpeg_stdio_dest( &cinfo,o );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
121
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
122
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
123 cinfo.image_width=image_width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
124 cinfo.image_height=image_height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
125 cinfo.input_components=bpp / 8;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
126 cinfo.in_color_space=JCS_RGB;
8267
1ac2523775ad patch from tonglijing <tong@intec.iscas.ac.cn>
pontscho
parents: 8148
diff changeset
127
1ac2523775ad patch from tonglijing <tong@intec.iscas.ac.cn>
pontscho
parents: 8148
diff changeset
128 jpeg_set_defaults( &cinfo );
1ac2523775ad patch from tonglijing <tong@intec.iscas.ac.cn>
pontscho
parents: 8148
diff changeset
129 jpeg_set_quality( &cinfo,jpeg_quality,jpeg_baseline );
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
130 cinfo.optimize_coding=jpeg_optimize;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
131 cinfo.smoothing_factor=jpeg_smooth;
8267
1ac2523775ad patch from tonglijing <tong@intec.iscas.ac.cn>
pontscho
parents: 8148
diff changeset
132
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
133 if ( jpeg_progressive_mode ) jpeg_simple_progression( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
134 jpeg_start_compress( &cinfo,TRUE );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
135
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
136 row_stride = image_width * ( bpp / 8 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
137 while ( cinfo.next_scanline < cinfo.image_height )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
138 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
139 row_pointer[0]=&buffer[ cinfo.next_scanline * row_stride ];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
140 (void)jpeg_write_scanlines( &cinfo,row_pointer,1 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
141 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
142
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
143 jpeg_finish_compress( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
144 fclose( o );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
145 jpeg_destroy_compress( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
146
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
147 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
148 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
149
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
150 static uint32_t draw_frame(uint8_t * src[])
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
151 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
152 char buf[256];
6751
82cfd2a85519 fixing swscaler bug ;)
michael
parents: 5659
diff changeset
153 uint8_t *dst= src[0];
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
154
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
155 snprintf (buf, 256, "%s/%08d.jpg", jpeg_outdir, ++framenum);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
156
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
157 if ( image_format == IMGFMT_BGR32 )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
158 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
159 rgb32to24( src[0],image_data,image_width * image_height * 4 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
160 rgb24tobgr24( image_data,image_data,image_width * image_height * 3 );
6751
82cfd2a85519 fixing swscaler bug ;)
michael
parents: 5659
diff changeset
161 dst=image_data;
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
162 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
163 if ( image_format == IMGFMT_BGR24 )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
164 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
165 rgb24tobgr24( src[0],image_data,image_width * image_height * 3 );
6751
82cfd2a85519 fixing swscaler bug ;)
michael
parents: 5659
diff changeset
166 dst=image_data;
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
167 }
6751
82cfd2a85519 fixing swscaler bug ;)
michael
parents: 5659
diff changeset
168 return jpeg_write( buf,dst );
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
169 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
170
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
171 static void draw_osd(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
172 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
173 vo_draw_text(image_width, image_height, draw_alpha);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
174 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
175
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
176 static void flip_page (void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
177 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
178 char buf[256];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
179
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
180 if((image_format == IMGFMT_YV12) || (image_format == IMGFMT_IYUV) || (image_format == IMGFMT_I420))
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
181 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
182 snprintf (buf, 256, "%s/%08d.jpg", jpeg_outdir, ++framenum);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
183 jpeg_write( buf,image_data );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
184 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
185 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
186
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
187 static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
188 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
189 if (scale_srcW)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
190 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
191 uint8_t *dst[3]={image_data, NULL, NULL};
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
192 SwScale_YV12slice(src,stride,y,h,
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
193 dst, image_width*((bpp+7)/8), bpp,
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
194 scale_srcW, scale_srcH, image_width, image_height);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
195 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
196 else
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
197 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
198 uint8_t *dst=image_data + (image_width * y + x) * (bpp/8);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
199 yuv2rgb(dst,src[0],src[1],src[2],w,h,image_width*(bpp/8),stride[0],stride[1]);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
200 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
201 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
202 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
203
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
204 static uint32_t query_format(uint32_t format)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
205 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
206 switch( format )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
207 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
208 case IMGFMT_IYUV:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
209 case IMGFMT_I420:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
210 case IMGFMT_YV12:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
211 case IMGFMT_RGB|24:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
212 case IMGFMT_BGR|24:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
213 case IMGFMT_BGR|32:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
214 return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
215 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
216 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
217 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
218
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
219 static void uninit(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
220 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
221 if ( image_data )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
222 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
223 free( image_data );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
224 image_data=NULL;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
225 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
226 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
227
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
228 static void check_events(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
229 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
230 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
231
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
232 static uint32_t preinit(const char *arg)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
233 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
234 if(arg)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
235 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
236 printf("JPEG Unknown subdevice: %s\n",arg);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
237 return ENOSYS;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
238 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
239 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
240 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
241
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
242 static uint32_t control(uint32_t request, void *data, ...)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
243 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
244 switch (request)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
245 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
246 case VOCTRL_QUERY_FORMAT:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
247 return query_format(*((uint32_t*)data));
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
248 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
249 return VO_NOTIMPL;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
250 }