annotate libvo/vo_jpeg.c @ 12055:174ff71996aa

sync by danny <guru@digitalfantasy.it>
author diego
date Tue, 23 Mar 2004 04:24:52 +0000
parents 98791b90215a
children db49cdedb88d
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 /*
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
2 * vo_jpeg.c, JPEG Renderer for Mplayer
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
3 *
5649
764db6a6a851 upsz, 10l :)
pontscho
parents: 5648
diff changeset
4 * Copyright 2002 by Pontscho (pontscho@makacs.poliod.hu)
9989
98791b90215a Spring cleanup: supporting only RGB24 as input (native jpeg lib supports only that, maybe we could later add nativ YCbCr (YUV) support, but not swscale ones)
alex
parents: 9019
diff changeset
5 * 25/04/2003: Spring cleanup -- alex
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
6 *
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 #include <stdio.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
10 #include <stdlib.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
11 #include <string.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
12 #include <errno.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
13
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
14 #include <jpeglib.h>
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
15
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
16 #include "config.h"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
17 #include "video_out.h"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
18 #include "video_out_internal.h"
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
19
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7487
diff changeset
20 static vo_info_t info=
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
21 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
22 "JPEG file",
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
23 "jpeg",
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
24 "Zoltan Ponekker (pontscho@makacs.poliod.hu)",
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
25 ""
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
26 };
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
27
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7487
diff changeset
28 LIBVO_EXTERN (jpeg)
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7487
diff changeset
29
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
30 static int image_width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
31 static int image_height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
32
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
33 int jpeg_baseline = 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
34 int jpeg_progressive_mode = 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
35 int jpeg_optimize = 100;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
36 int jpeg_smooth = 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
37 int jpeg_quality = 75;
5659
b17666766389 fix ".". thanksz pl.
pontscho
parents: 5649
diff changeset
38 char * jpeg_outdir = ".";
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
39
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
40 static int framenum=0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
41
7124
eca7dbad0166 finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents: 6751
diff changeset
42 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
43 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
44 image_height=height;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
45 image_width=width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
46
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
47 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
48 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
49
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
50 static uint32_t jpeg_write( uint8_t * name,uint8_t * buffer )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
51 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
52 FILE * o;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
53 struct jpeg_compress_struct cinfo;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
54 struct jpeg_error_mgr jerr;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
55 JSAMPROW row_pointer[1];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
56 int row_stride;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
57
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
58 if ( !buffer ) return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
59 if ( (o=fopen( name,"wb" )) == NULL ) return 1;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
60
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
61 cinfo.err=jpeg_std_error(&jerr);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
62 jpeg_create_compress(&cinfo);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
63 jpeg_stdio_dest( &cinfo,o );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
64
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
65 cinfo.image_width=image_width;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
66 cinfo.image_height=image_height;
9989
98791b90215a Spring cleanup: supporting only RGB24 as input (native jpeg lib supports only that, maybe we could later add nativ YCbCr (YUV) support, but not swscale ones)
alex
parents: 9019
diff changeset
67 cinfo.input_components=3;
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
68 cinfo.in_color_space=JCS_RGB;
8267
1ac2523775ad patch from tonglijing <tong@intec.iscas.ac.cn>
pontscho
parents: 8148
diff changeset
69
1ac2523775ad patch from tonglijing <tong@intec.iscas.ac.cn>
pontscho
parents: 8148
diff changeset
70 jpeg_set_defaults( &cinfo );
1ac2523775ad patch from tonglijing <tong@intec.iscas.ac.cn>
pontscho
parents: 8148
diff changeset
71 jpeg_set_quality( &cinfo,jpeg_quality,jpeg_baseline );
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
72 cinfo.optimize_coding=jpeg_optimize;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
73 cinfo.smoothing_factor=jpeg_smooth;
8267
1ac2523775ad patch from tonglijing <tong@intec.iscas.ac.cn>
pontscho
parents: 8148
diff changeset
74
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
75 if ( jpeg_progressive_mode ) jpeg_simple_progression( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
76 jpeg_start_compress( &cinfo,TRUE );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
77
9989
98791b90215a Spring cleanup: supporting only RGB24 as input (native jpeg lib supports only that, maybe we could later add nativ YCbCr (YUV) support, but not swscale ones)
alex
parents: 9019
diff changeset
78 row_stride = image_width * 3;
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
79 while ( cinfo.next_scanline < cinfo.image_height )
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
80 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
81 row_pointer[0]=&buffer[ cinfo.next_scanline * row_stride ];
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
82 (void)jpeg_write_scanlines( &cinfo,row_pointer,1 );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
83 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
84
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
85 jpeg_finish_compress( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
86 fclose( o );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
87 jpeg_destroy_compress( &cinfo );
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
88
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
89 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
90 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
91
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
92 static uint32_t draw_frame(uint8_t * src[])
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
93 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
94 char buf[256];
6751
82cfd2a85519 fixing swscaler bug ;)
michael
parents: 5659
diff changeset
95 uint8_t *dst= src[0];
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
96
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
97 snprintf (buf, 256, "%s/%08d.jpg", jpeg_outdir, ++framenum);
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
98
9989
98791b90215a Spring cleanup: supporting only RGB24 as input (native jpeg lib supports only that, maybe we could later add nativ YCbCr (YUV) support, but not swscale ones)
alex
parents: 9019
diff changeset
99 return jpeg_write( buf,src[0] );
5648
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
100 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
101
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
102 static void draw_osd(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
103 {
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 void flip_page (void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
107 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
108 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
109
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
110 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
111 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
112 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
113 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
114
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
115 static uint32_t query_format(uint32_t format)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
116 {
9989
98791b90215a Spring cleanup: supporting only RGB24 as input (native jpeg lib supports only that, maybe we could later add nativ YCbCr (YUV) support, but not swscale ones)
alex
parents: 9019
diff changeset
117 if (format == IMGFMT_RGB24)
98791b90215a Spring cleanup: supporting only RGB24 as input (native jpeg lib supports only that, maybe we could later add nativ YCbCr (YUV) support, but not swscale ones)
alex
parents: 9019
diff changeset
118 return VFCAP_CSP_SUPPORTED|VFCAP_CSP_SUPPORTED_BY_HW;
98791b90215a Spring cleanup: supporting only RGB24 as input (native jpeg lib supports only that, maybe we could later add nativ YCbCr (YUV) support, but not swscale ones)
alex
parents: 9019
diff changeset
119
98791b90215a Spring cleanup: supporting only RGB24 as input (native jpeg lib supports only that, maybe we could later add nativ YCbCr (YUV) support, but not swscale ones)
alex
parents: 9019
diff changeset
120 return 0;
5648
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 static void uninit(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
124 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
125 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
126
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
127 static void check_events(void)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
128 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
129 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
130
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
131 static uint32_t preinit(const char *arg)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
132 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
133 return 0;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
134 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
135
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
136 static uint32_t control(uint32_t request, void *data, ...)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
137 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
138 switch (request)
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
139 {
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
140 case VOCTRL_QUERY_FORMAT:
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
141 return query_format(*((uint32_t*)data));
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
142 }
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
143 return VO_NOTIMPL;
c3ca8f05b3a9 add jpeg support for libvo
pontscho
parents:
diff changeset
144 }