annotate libmpcodecs/ve_raw.c @ 11966:b58fdd5d8e8d

remove raw nonsense and replace it by one ovc patch by John Earl <jwe21@cam.ac.uk>
author attila
date Tue, 17 Feb 2004 12:43:07 +0000
parents
children 656a1b45b309
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
1 #include <stdio.h>
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
2 #include <stdlib.h>
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
3 #include <string.h>
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
4
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
5 #include "../config.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
6 #include "../mp_msg.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
7
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
8 #include "codec-cfg.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
9 #include "stream.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
10 #include "demuxer.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
11 #include "stheader.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
12
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
13 #include "muxer.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
14
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
15 #include "img_format.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
16 #include "mp_image.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
17 #include "vf.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
18
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
19
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
20 //===========================================================================//
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
21
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
22 struct vf_priv_s {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
23 muxer_stream_t* mux;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
24 };
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
25 #define mux_v (vf->priv->mux)
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
26
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
27 static int set_format(struct vf_instance_s *vf, unsigned int fmt) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
28 mux_v->bih->biCompression = fmt;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
29
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
30 mux_v->bih->biPlanes = 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
31 if (IMGFMT_IS_RGB(fmt)) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
32 if (IMGFMT_RGB_DEPTH(fmt) < 8 && !(fmt&128))
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
33 mux_v->bih->biBitCount = IMGFMT_RGB_DEPTH(fmt);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
34 else
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
35 mux_v->bih->biBitCount = (IMGFMT_RGB_DEPTH(fmt)+7)&(~7);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
36 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
37 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
38 if (IMGFMT_IS_BGR(fmt)) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
39 if (IMGFMT_BGR_DEPTH(fmt) < 8 && !(fmt&128))
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
40 mux_v->bih->biBitCount = IMGFMT_BGR_DEPTH(fmt);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
41 else
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
42 mux_v->bih->biBitCount = (IMGFMT_BGR_DEPTH(fmt)+7)&(~7);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
43 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
44 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
45 switch (fmt) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
46 case IMGFMT_I420:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
47 case IMGFMT_IYUV:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
48 case IMGFMT_YV12:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
49 case IMGFMT_411P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
50 mux_v->bih->biPlanes = 3;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
51 mux_v->bih->biBitCount = 12;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
52 break;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
53 case IMGFMT_444P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
54 mux_v->bih->biPlanes = 3;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
55 mux_v->bih->biBitCount = 24;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
56 break;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
57 case IMGFMT_422P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
58 mux_v->bih->biPlanes = 3;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
59 mux_v->bih->biBitCount = 16;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
60 break;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
61 case IMGFMT_IF09:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
62 mux_v->bih->biPlanes = 4;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
63 case IMGFMT_YVU9:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
64 mux_v->bih->biBitCount = 9;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
65 break;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
66 case IMGFMT_UYVY:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
67 case IMGFMT_YUY2:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
68 mux_v->bih->biBitCount = 16;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
69 break;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
70 default:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
71 printf("ve_raw: raw output with fourcc [%x] not supported!\n", fmt);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
72 mux_v->bih->biCompression = 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
73 return 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
74 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
75 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
76 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
77
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
78
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
79 static int config(struct vf_instance_s *vf,
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
80 int width, int height, int d_width, int d_height,
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
81 unsigned int flags, unsigned int outfmt)
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
82 {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
83 int ret;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
84 mux_v->bih->biWidth = width;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
85 mux_v->bih->biHeight = height;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
86 ret = set_format(vf, outfmt);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
87 if (!ret) return 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
88
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
89 mux_v->bih->biSizeImage = mux_v->bih->biWidth*mux_v->bih->biHeight*mux_v->bih->biBitCount/8;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
90 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
91 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
92
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
93 static int control(struct vf_instance_s *vf, int request, void *data) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
94 return CONTROL_UNKNOWN;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
95 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
96
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
97 static int query_format(struct vf_instance_s *vf, unsigned int fmt) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
98 if (IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt))
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
99 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
100 switch (fmt) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
101 case IMGFMT_I420:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
102 case IMGFMT_IYUV:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
103 case IMGFMT_YV12:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
104 case IMGFMT_411P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
105 case IMGFMT_444P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
106 case IMGFMT_422P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
107 case IMGFMT_UYVY:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
108 case IMGFMT_YUY2:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
109 case IMGFMT_YVU9:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
110 case IMGFMT_IF09:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
111 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
112 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
113
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
114 return 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
115 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
116
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
117 static int put_image(struct vf_instance_s *vf, mp_image_t *mpi) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
118 mux_v->buffer = mpi->planes[0];
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
119 muxer_write_chunk(mux_v, mpi->width*mpi->height*mux_v->bih->biBitCount/8, 0x10);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
120 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
121 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
122
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
123 //===========================================================================//
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
124
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
125 static int vf_open(vf_instance_t *vf, char* args){
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
126 vf->config = config;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
127 vf->control = control;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
128 vf->query_format = query_format;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
129 vf->put_image = put_image;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
130 vf->priv = malloc(sizeof(struct vf_priv_s));
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
131 memset(vf->priv, 0, sizeof(struct vf_priv_s));
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
132 vf->priv->mux = (muxer_stream_t*)args;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
133
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
134 mux_v->bih = malloc(sizeof(BITMAPINFOHEADER));
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
135 mux_v->bih->biSize = sizeof(BITMAPINFOHEADER);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
136 mux_v->bih->biWidth = 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
137 mux_v->bih->biHeight = 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
138
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
139 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
140 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
141
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
142 vf_info_t ve_info_raw = {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
143 "raw encoder",
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
144 "raw",
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
145 "jwe21@cam.ac.uk",
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
146 "Based on rawrgb",
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
147 vf_open
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
148 };
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
149
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
150 //===========================================================================//