annotate libmpcodecs/ve_raw.c @ 27264:6cead9d8eb8f

cosmetics: Rename LANGUAGES variable to msg_langs.
author diego
date Wed, 16 Jul 2008 15:51:15 +0000
parents 1ea1e076cd4c
children 067da68b5b16
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
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14878
diff changeset
5 #include "config.h"
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 14878
diff changeset
6 #include "mp_msg.h"
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17906
diff changeset
7 #include "help_mp.h"
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
8
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
9 #include "codec-cfg.h"
22600
3c2b4a866c6a Add explicit location for headers from the stream/ directory.
diego
parents: 21660
diff changeset
10 #include "stream/stream.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
11 #include "libmpdemux/demuxer.h"
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
12 #include "libmpdemux/stheader.h"
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
13
22600
3c2b4a866c6a Add explicit location for headers from the stream/ directory.
diego
parents: 21660
diff changeset
14 #include "stream/stream.h"
22601
ed8f90096c65 Add explicit location for headers from the libmpdemux/ directory.
diego
parents: 22600
diff changeset
15 #include "libmpdemux/muxer.h"
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
16
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
17 #include "img_format.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
18 #include "mp_image.h"
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
19 #include "vf.h"
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 //===========================================================================//
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
23
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
24 struct vf_priv_s {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
25 muxer_stream_t* 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 #define mux_v (vf->priv->mux)
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
28
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
29 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
30 mux_v->bih->biCompression = fmt;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
31
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
32 mux_v->bih->biPlanes = 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
33 if (IMGFMT_IS_RGB(fmt)) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
34 if (IMGFMT_RGB_DEPTH(fmt) < 8 && !(fmt&128))
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
35 mux_v->bih->biBitCount = IMGFMT_RGB_DEPTH(fmt);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
36 else
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
37 mux_v->bih->biBitCount = (IMGFMT_RGB_DEPTH(fmt)+7)&(~7);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
38 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
39 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
40 if (IMGFMT_IS_BGR(fmt)) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
41 if (IMGFMT_BGR_DEPTH(fmt) < 8 && !(fmt&128))
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
42 mux_v->bih->biBitCount = IMGFMT_BGR_DEPTH(fmt);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
43 else
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
44 mux_v->bih->biBitCount = (IMGFMT_BGR_DEPTH(fmt)+7)&(~7);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
45 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
46 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
47 switch (fmt) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
48 case IMGFMT_I420:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
49 case IMGFMT_IYUV:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
50 case IMGFMT_YV12:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
51 case IMGFMT_411P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
52 mux_v->bih->biPlanes = 3;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
53 mux_v->bih->biBitCount = 12;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
54 break;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
55 case IMGFMT_444P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
56 mux_v->bih->biPlanes = 3;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
57 mux_v->bih->biBitCount = 24;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
58 break;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
59 case IMGFMT_422P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
60 mux_v->bih->biPlanes = 3;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
61 mux_v->bih->biBitCount = 16;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
62 break;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
63 case IMGFMT_IF09:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
64 mux_v->bih->biPlanes = 4;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
65 case IMGFMT_YVU9:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
66 mux_v->bih->biBitCount = 9;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
67 break;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
68 case IMGFMT_UYVY:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
69 case IMGFMT_YUY2:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
70 mux_v->bih->biBitCount = 16;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
71 break;
22958
1ea1e076cd4c support format=y8 with -ovc raw
lorenm
parents: 22601
diff changeset
72 case IMGFMT_Y8:
1ea1e076cd4c support format=y8 with -ovc raw
lorenm
parents: 22601
diff changeset
73 mux_v->bih->biBitCount = 8;
1ea1e076cd4c support format=y8 with -ovc raw
lorenm
parents: 22601
diff changeset
74 break;
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
75 default:
18004
bcd805923554 Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents: 17906
diff changeset
76 mp_msg(MSGT_MENCODER, MSGL_INFO, MSGTR_MPCODECS_OutputWithFourccNotSupported, fmt);
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
77 mux_v->bih->biCompression = 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
78 return 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
79 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
80 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
81 }
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
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
84 static int config(struct vf_instance_s *vf,
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
85 int width, int height, int d_width, int d_height,
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
86 unsigned int flags, unsigned int outfmt)
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
87 {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
88 int ret;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
89 mux_v->bih->biWidth = width;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
90 mux_v->bih->biHeight = height;
12061
656a1b45b309 Use aspect from encoder for AVI vprp header
ranma
parents: 11966
diff changeset
91 mux_v->aspect = (float)d_width/d_height;
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
92 ret = set_format(vf, outfmt);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
93 if (!ret) return 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
94
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
95 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
96 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
97 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
98
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
99 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
100 return CONTROL_UNKNOWN;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
101 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
102
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
103 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
104 if (IMGFMT_IS_RGB(fmt) || IMGFMT_IS_BGR(fmt))
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
105 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
106 switch (fmt) {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
107 case IMGFMT_I420:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
108 case IMGFMT_IYUV:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
109 case IMGFMT_YV12:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
110 case IMGFMT_411P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
111 case IMGFMT_444P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
112 case IMGFMT_422P:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
113 case IMGFMT_UYVY:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
114 case IMGFMT_YUY2:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
115 case IMGFMT_YVU9:
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
116 case IMGFMT_IF09:
22958
1ea1e076cd4c support format=y8 with -ovc raw
lorenm
parents: 22601
diff changeset
117 case IMGFMT_Y8:
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
118 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
119 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
120
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
121 return 0;
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
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17487
diff changeset
124 static int put_image(struct vf_instance_s *vf, mp_image_t *mpi, double pts) {
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
125 mux_v->buffer = mpi->planes[0];
17906
20aca9baf5d8 passing pts through the filter layer (lets see if pts or cola comes out at the end)
michael
parents: 17487
diff changeset
126 muxer_write_chunk(mux_v, mpi->width*mpi->height*mux_v->bih->biBitCount/8, 0x10, pts, pts);
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
127 return 1;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
128 }
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
129
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
130 //===========================================================================//
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
131
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
132 static int vf_open(vf_instance_t *vf, char* args){
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
133 vf->config = config;
14878
5723c4b2a2ea fixes for encoding of multiple files
henry
parents: 14549
diff changeset
134 vf->default_caps = VFCAP_CONSTANT;
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
135 vf->control = control;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
136 vf->query_format = query_format;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
137 vf->put_image = put_image;
14303
ef29ceb5add1 Raw encoder does not support stride.
reimar
parents: 12061
diff changeset
138 vf->default_caps = 0;
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
139 vf->priv = malloc(sizeof(struct vf_priv_s));
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
140 memset(vf->priv, 0, sizeof(struct vf_priv_s));
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
141 vf->priv->mux = (muxer_stream_t*)args;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
142
14549
acf3241be19b Initialized BITMAPINFOHEADER to 0 to avoid problems, esp. windows has problems
reimar
parents: 14303
diff changeset
143 mux_v->bih = calloc(1, sizeof(BITMAPINFOHEADER));
11966
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
144 mux_v->bih->biSize = sizeof(BITMAPINFOHEADER);
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
145 mux_v->bih->biWidth = 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
146 mux_v->bih->biHeight = 0;
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
147
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
148 return 1;
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
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
151 vf_info_t ve_info_raw = {
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
152 "raw encoder",
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
153 "raw",
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
154 "jwe21@cam.ac.uk",
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
155 "Based on rawrgb",
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
156 vf_open
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
157 };
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
158
b58fdd5d8e8d remove raw nonsense and replace it by one ovc
attila
parents:
diff changeset
159 //===========================================================================//