Mercurial > mplayer.hg
annotate libmpcodecs/ve_nuv.c @ 14246:474a40917f73
CONF_TYPE_AFMT similar to CONF_TYPE_IMGFMT
author | alex |
---|---|
date | Mon, 27 Dec 2004 17:32:54 +0000 |
parents | 656a1b45b309 |
children | acf3241be19b |
rev | line source |
---|---|
9520
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
1 #include <stdio.h> |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
2 #include <stdlib.h> |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
3 #include <string.h> |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
4 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
5 #include "../config.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
6 #include "../mp_msg.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
7 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
8 #include "m_option.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
9 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
10 #include "codec-cfg.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
11 #include "stream.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
12 #include "demuxer.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
13 #include "stheader.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
14 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
15 #include "muxer.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
16 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
17 #include "img_format.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
18 #include "mp_image.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
19 #include "vf.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
20 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
21 #include "libmpdemux/nuppelvideo.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
22 #include "native/minilzo.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
23 #include "native/RTjpegN.h" |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
24 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
25 #define LZO_AL(size) (((size) + (sizeof(long) - 1)) / sizeof(long)) |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
26 #define LZO_IN_LEN (1024*1024L) |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
27 #define LZO_OUT_LEN (LZO_IN_LEN + LZO_IN_LEN / 64 + 16 + 3) |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
28 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
29 //===========================================================================// |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
30 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
31 struct vf_priv_s { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
32 int raw; // Do not use RTjpeg |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
33 int lzo; // Use lzo |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
34 unsigned int l,c,q; // Mjpeg param |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
35 muxer_stream_t* mux; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
36 uint8_t* buffer; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
37 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
38 int buf_size; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
39 int tbl_wrote; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
40 lzo_byte *zbuffer; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
41 long __LZO_MMODEL *zmem; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
42 }; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
43 #define mux_v (vf->priv->mux) |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
44 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
45 struct vf_priv_s nuv_priv_dflt = { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
46 0, // raw |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
47 1, // lzo |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
48 1,1, // l,c |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
49 255, // q |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
50 NULL, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
51 NULL, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
52 0,0, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
53 NULL,NULL |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
54 }; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
55 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
56 m_option_t nuvopts_conf[]={ |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
57 {"raw", &nuv_priv_dflt.raw, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
58 {"rtjpeg", &nuv_priv_dflt.raw, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
59 {"lzo", &nuv_priv_dflt.lzo, CONF_TYPE_FLAG, 0, 0, 1, NULL}, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
60 {"nolzo", &nuv_priv_dflt.lzo, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
61 {"q", &nuv_priv_dflt.q, CONF_TYPE_INT, M_OPT_RANGE,3,255, NULL}, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
62 {"l", &nuv_priv_dflt.l, CONF_TYPE_INT, M_OPT_RANGE,0,20, NULL}, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
63 {"c", &nuv_priv_dflt.c, CONF_TYPE_INT, M_OPT_RANGE,0,20, NULL}, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
64 {NULL, NULL, 0, 0, 0, 0, NULL} |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
65 }; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
66 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
67 //===========================================================================// |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
68 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
69 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
70 static int config(struct vf_instance_s* vf, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
71 int width, int height, int d_width, int d_height, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
72 unsigned int flags, unsigned int outfmt){ |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
73 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
74 // We need a buffer wich can holda header and a whole YV12 picture |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
75 // or a RTJpeg table |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
76 vf->priv->buf_size = width*height*3/2+FRAMEHEADERSIZE; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
77 if(vf->priv->buf_size < (int)(128*sizeof(long int) + FRAMEHEADERSIZE)) |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
78 vf->priv->buf_size = 128*sizeof(long int) + FRAMEHEADERSIZE; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
79 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
80 mux_v->bih->biWidth=width; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
81 mux_v->bih->biHeight=height; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
82 mux_v->bih->biSizeImage=mux_v->bih->biWidth*mux_v->bih->biHeight*(mux_v->bih->biBitCount/8); |
12061 | 83 mux_v->aspect = (float)d_width/d_height; |
9520
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
84 vf->priv->buffer = realloc(vf->priv->buffer,vf->priv->buf_size); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
85 vf->priv->tbl_wrote = 0; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
86 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
87 return 1; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
88 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
89 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
90 static int control(struct vf_instance_s* vf, int request, void* data){ |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
91 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
92 return CONTROL_UNKNOWN; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
93 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
94 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
95 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
96 if(fmt==IMGFMT_I420) return 3; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
97 return 0; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
98 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
99 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
100 static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){ |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
101 struct rtframeheader* ench = (struct rtframeheader*)vf->priv->buffer; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
102 uint8_t* data = vf->priv->buffer + FRAMEHEADERSIZE; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
103 uint8_t* zdata = vf->priv->zbuffer + FRAMEHEADERSIZE; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
104 int len = 0, zlen = 0,r; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
105 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
106 memset(vf->priv->buffer,0,FRAMEHEADERSIZE); // Reset the header |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
107 if(vf->priv->lzo) |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
108 memset(vf->priv->zbuffer,0,FRAMEHEADERSIZE); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
109 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
110 // This has to be don here otherwise tv with sound doesn't work |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
111 if(!vf->priv->tbl_wrote) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
112 RTjpeg_init_compress((long int*)data,mpi->width,mpi->height,vf->priv->q); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
113 RTjpeg_init_mcompress(); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
114 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
115 ench->frametype = 'D'; // compressor data |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
116 ench->comptype = 'R'; // compressor data for RTjpeg |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
117 ench->packetlength = 128*sizeof(long int); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
118 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
119 mux_v->buffer=vf->priv->buffer; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
120 muxer_write_chunk(mux_v,FRAMEHEADERSIZE + 128*sizeof(long int), 0x10); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
121 vf->priv->tbl_wrote = 1; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
122 memset(ench,0,FRAMEHEADERSIZE); // Reset the header |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
123 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
124 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
125 // Raw picture |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
126 if(vf->priv->raw) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
127 len = mpi->width*mpi->height*3/2; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
128 // Try lzo ??? |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
129 if(vf->priv->lzo) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
130 r = lzo1x_1_compress(mpi->planes[0],mpi->width*mpi->height*3/2, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
131 zdata,&zlen,vf->priv->zmem); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
132 if(r != LZO_E_OK) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
133 mp_msg(MSGT_VFILTER,MSGL_ERR,"LZO compress error\n"); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
134 zlen = 0; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
135 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
136 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
137 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
138 if(zlen <= 0 || zlen > len) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
139 memcpy(data,mpi->planes[0],len); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
140 ench->comptype = '0'; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
141 } else { // Use lzo only if it's littler |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
142 ench = (struct rtframeheader*)vf->priv->zbuffer; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
143 ench->comptype = '3'; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
144 len = zlen; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
145 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
146 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
147 } else { // RTjpeg compression |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
148 len = RTjpeg_mcompressYUV420(data,mpi->planes[0],vf->priv->l, |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
149 vf->priv->c); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
150 if(len <= 0) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
151 mp_msg(MSGT_VFILTER,MSGL_ERR,"RTjpeg_mcompressYUV420 error (%d)\n",len); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
152 return 0; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
153 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
154 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
155 if(vf->priv->lzo) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
156 r = lzo1x_1_compress(data,len,zdata,&zlen,vf->priv->zmem); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
157 if(r != LZO_E_OK) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
158 mp_msg(MSGT_VFILTER,MSGL_ERR,"LZO compress error\n"); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
159 zlen = 0; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
160 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
161 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
162 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
163 if(zlen <= 0 || zlen > len) |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
164 ench->comptype = '1'; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
165 else { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
166 ench = (struct rtframeheader*)vf->priv->zbuffer; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
167 ench->comptype = '2'; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
168 len = zlen; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
169 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
170 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
171 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
172 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
173 ench->frametype = 'V'; // video frame |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
174 ench->packetlength = len; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
175 mux_v->buffer=(void*)ench; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
176 muxer_write_chunk(mux_v, len + FRAMEHEADERSIZE, 0x10); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
177 return 1; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
178 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
179 |
9522 | 180 static void uninit(struct vf_instance_s* vf) { |
181 | |
182 if(vf->priv->buffer) | |
183 free(vf->priv->buffer); | |
184 if(vf->priv->zbuffer) | |
185 free(vf->priv->zbuffer); | |
186 if(vf->priv->zmem) | |
187 free(vf->priv->zmem); | |
188 | |
189 } | |
190 | |
9520
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
191 //===========================================================================// |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
192 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
193 static int vf_open(vf_instance_t *vf, char* args){ |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
194 vf->config=config; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
195 vf->control=control; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
196 vf->query_format=query_format; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
197 vf->put_image=put_image; |
9522 | 198 vf->uninit = uninit; |
9520
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
199 vf->priv=malloc(sizeof(struct vf_priv_s)); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
200 memcpy(vf->priv, &nuv_priv_dflt,sizeof(struct vf_priv_s)); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
201 vf->priv->mux=(muxer_stream_t*)args; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
202 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
203 mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
204 mux_v->bih->biSize=sizeof(BITMAPINFOHEADER); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
205 mux_v->bih->biWidth=0; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
206 mux_v->bih->biHeight=0; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
207 mux_v->bih->biPlanes=1; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
208 mux_v->bih->biBitCount=12; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
209 mux_v->bih->biCompression = mmioFOURCC('N','U','V','1'); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
210 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
211 if(vf->priv->lzo) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
212 if(lzo_init() != LZO_E_OK) { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
213 mp_msg(MSGT_VFILTER,MSGL_WARN,"LZO init failed: no lzo compression\n"); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
214 vf->priv->lzo = 0; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
215 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
216 vf->priv->zbuffer = (lzo_bytep)malloc(FRAMEHEADERSIZE + LZO_OUT_LEN); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
217 vf->priv->zmem = (long*)malloc(sizeof(long)*LZO_AL(LZO1X_1_MEM_COMPRESS)); |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
218 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
219 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
220 return 1; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
221 } |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
222 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
223 vf_info_t ve_info_nuv = { |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
224 "nuv encoder", |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
225 "nuv", |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
226 "Albeu", |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
227 "for internal use by mencoder", |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
228 vf_open |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
229 }; |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
230 |
2860f7c9d9ca
A new nuppel video encoder. Mainly for RT encoding on slow box.
albeu
parents:
diff
changeset
|
231 //===========================================================================// |