annotate libvo/vo_jpeg.c @ 5871:c03422eaaadf

A little fix with hw video parameters setting
author albeu
date Sat, 27 Apr 2002 21:03:59 +0000
parents b17666766389
children 82cfd2a85519
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"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
20
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
21 #include "../postproc/swscale.h"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
22 #include "../postproc/rgb2rgb.h"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
23
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
24 LIBVO_EXTERN (jpeg)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
25
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
26 static vo_info_t vo_info=
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
27 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
28 "JPEG file",
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
29 "jpeg",
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
30 "Zoltan Ponekker (pontscho@makacs.poliod.hu)",
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
31 ""
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
32 };
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
33
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
34 #define RGB 0
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
35 #define BGR 1
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
36
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
37 extern int verbose;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
38 static int image_width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
39 static int image_height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
40 static int image_format;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
41 static uint8_t *image_data=NULL;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
42 static unsigned int scale_srcW=0, scale_srcH=0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
43
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
44 int jpeg_baseline = 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
45 int jpeg_progressive_mode = 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
46 int jpeg_optimize = 100;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
47 int jpeg_smooth = 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
48 int jpeg_quality = 75;
5659
b17666766389 fix ".". thanksz pl.
pontscho
parents: 5649
diff changeset
49 char * jpeg_outdir = ".";
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
50
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
51 #define bpp 24
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
52
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
53 static int cspace=RGB;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
54 static int framenum=0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
55
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
56 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
57 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
58 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
59 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
60
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
61 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,const vo_tune_info_t *info)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
62 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
63 if ( fullscreen&0x04 && ( width != d_width || height != d_height )&&( ( format == IMGFMT_YV12 ) ) )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
64 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
65 // software scaling
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
66 image_width=(d_width + 7) & ~7;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
67 image_height=d_height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
68 scale_srcW=width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
69 scale_srcH=height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
70 SwScale_Init();
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
71 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
72 else
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
73 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
74 image_height=height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
75 image_width=width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
76 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
77
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
78 image_format=format;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
79 switch(format)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
80 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
81 case IMGFMT_BGR32:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
82 cspace=BGR;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
83 image_data=malloc( image_width * image_height * 3 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
84 break;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
85 case IMGFMT_BGR24:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
86 cspace=BGR;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
87 image_data=malloc( image_width * image_height * 3 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
88 break;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
89 case IMGFMT_RGB24:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
90 cspace=RGB;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
91 break;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
92 case IMGFMT_IYUV:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
93 case IMGFMT_I420:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
94 case IMGFMT_YV12:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
95 cspace=BGR;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
96 yuv2rgb_init( bpp,MODE_BGR );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
97 image_data=malloc( image_width * image_height * 3 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
98 break;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
99 default:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
100 return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
101 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
102
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
103 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
104 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
105
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
106 static const vo_info_t*
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
107 get_info(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
108 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
109 return &vo_info;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
110 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
111
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
112 static uint32_t jpeg_write( uint8_t * name,uint8_t * buffer )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
113 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
114 FILE * o;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
115 struct jpeg_compress_struct cinfo;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
116 struct jpeg_error_mgr jerr;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
117 JSAMPROW row_pointer[1];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
118 int row_stride;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
119
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
120 if ( !buffer ) return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
121 if ( (o=fopen( name,"wb" )) == NULL ) return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
122
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
123 cinfo.err=jpeg_std_error(&jerr);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
124 jpeg_create_compress(&cinfo);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
125 jpeg_stdio_dest( &cinfo,o );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
126
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
127 jpeg_set_quality( &cinfo,jpeg_quality,jpeg_baseline );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
128
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
129 cinfo.image_width=image_width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
130 cinfo.image_height=image_height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
131 cinfo.input_components=bpp / 8;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
132 cinfo.in_color_space=JCS_RGB;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
133 cinfo.optimize_coding=jpeg_optimize;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
134 cinfo.smoothing_factor=jpeg_smooth;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
135
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
136 jpeg_set_defaults( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
137 if ( jpeg_progressive_mode ) jpeg_simple_progression( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
138 jpeg_start_compress( &cinfo,TRUE );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
139
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
140 row_stride = image_width * ( bpp / 8 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
141 while ( cinfo.next_scanline < cinfo.image_height )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
142 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
143 row_pointer[0]=&buffer[ cinfo.next_scanline * row_stride ];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
144 (void)jpeg_write_scanlines( &cinfo,row_pointer,1 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
145 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
146
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
147 jpeg_finish_compress( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
148 fclose( o );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
149 jpeg_destroy_compress( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
150
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
151 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
152 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
153
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
154 static uint32_t draw_frame(uint8_t * src[])
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
155 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
156 char buf[256];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
157
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
158 snprintf (buf, 256, "%s/%08d.jpg", jpeg_outdir, ++framenum);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
159
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
160 if ( image_format == IMGFMT_BGR32 )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
161 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
162 rgb32to24( src[0],image_data,image_width * image_height * 4 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
163 rgb24tobgr24( image_data,image_data,image_width * image_height * 3 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
164 src[0]=image_data;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
165 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
166 if ( image_format == IMGFMT_BGR24 )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
167 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
168 rgb24tobgr24( src[0],image_data,image_width * image_height * 3 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
169 src[0]=image_data;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
170 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
171 return jpeg_write( buf,src[0] );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
172 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
173
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
174 static void draw_osd(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
175 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
176 vo_draw_text(image_width, image_height, draw_alpha);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
177 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
178
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
179 static void flip_page (void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
180 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
181 char buf[256];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
182
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
183 if((image_format == IMGFMT_YV12) || (image_format == IMGFMT_IYUV) || (image_format == IMGFMT_I420))
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
184 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
185 snprintf (buf, 256, "%s/%08d.jpg", jpeg_outdir, ++framenum);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
186 jpeg_write( buf,image_data );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
187 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
188 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
189
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
190 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
191 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
192 // hack: swap planes for I420 ;) -- alex
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
193 if ((image_format == IMGFMT_IYUV) || (image_format == IMGFMT_I420))
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
194 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
195 uint8_t *src_i420[3];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
196
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
197 src_i420[0]=src[0];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
198 src_i420[1]=src[2];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
199 src_i420[2]=src[1];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
200 src=src_i420;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
201 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
202
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
203 if (scale_srcW)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
204 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
205 uint8_t *dst[3]={image_data, NULL, NULL};
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
206 SwScale_YV12slice(src,stride,y,h,
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
207 dst, image_width*((bpp+7)/8), bpp,
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
208 scale_srcW, scale_srcH, image_width, image_height);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
209 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
210 else
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
211 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
212 uint8_t *dst=image_data + (image_width * y + x) * (bpp/8);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
213 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
214 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
215 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
216 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
217
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
218 static uint32_t query_format(uint32_t format)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
219 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
220 switch( format )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
221 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
222 case IMGFMT_IYUV:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
223 case IMGFMT_I420:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
224 case IMGFMT_YV12:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
225 case IMGFMT_RGB|24:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
226 case IMGFMT_BGR|24:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
227 case IMGFMT_BGR|32:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
228 return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
229 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
230 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
231 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
232
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
233 static void uninit(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
234 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
235 if ( image_data )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
236 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
237 free( image_data );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
238 image_data=NULL;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
239 }
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 void check_events(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
243 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
244 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
245
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
246 static uint32_t preinit(const char *arg)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
247 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
248 if(arg)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
249 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
250 printf("JPEG Unknown subdevice: %s\n",arg);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
251 return ENOSYS;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
252 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
253 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
254 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
255
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
256 static uint32_t control(uint32_t request, void *data, ...)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
257 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
258 switch (request)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
259 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
260 case VOCTRL_QUERY_FORMAT:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
261 return query_format(*((uint32_t*)data));
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
262 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
263 return VO_NOTIMPL;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
264 }