comparison utils.c @ 55:6064342168f4 libavcodec

picture utils
author glantau
date Sat, 11 Aug 2001 19:04:31 +0000
parents 08265a63313e
children 79be2c581c01
comparison
equal deleted inserted replaced
54:764f2eaf711e 55:6064342168f4
172 p = p->next; 172 p = p->next;
173 } 173 }
174 return NULL; 174 return NULL;
175 } 175 }
176 176
177 const char *pix_fmt_str[] = {
178 "yuv420p",
179 "yuv422",
180 "rgb24",
181 "bgr24",
182 "yuv422p",
183 "yuv444p",
184 };
185
177 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) 186 void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
178 { 187 {
179 const char *codec_name; 188 const char *codec_name;
180 AVCodec *p; 189 AVCodec *p;
181 char buf1[32]; 190 char buf1[32];
206 switch(enc->codec_type) { 215 switch(enc->codec_type) {
207 case CODEC_TYPE_VIDEO: 216 case CODEC_TYPE_VIDEO:
208 snprintf(buf, buf_size, 217 snprintf(buf, buf_size,
209 "Video: %s%s", 218 "Video: %s%s",
210 codec_name, enc->flags & CODEC_FLAG_HQ ? " (hq)" : ""); 219 codec_name, enc->flags & CODEC_FLAG_HQ ? " (hq)" : "");
220 if (enc->codec_id == CODEC_ID_RAWVIDEO) {
221 snprintf(buf + strlen(buf), buf_size - strlen(buf),
222 ", %s",
223 pix_fmt_str[enc->pix_fmt]);
224 }
211 if (enc->width) { 225 if (enc->width) {
212 snprintf(buf + strlen(buf), buf_size - strlen(buf), 226 snprintf(buf + strlen(buf), buf_size - strlen(buf),
213 ", %dx%d, %0.2f fps", 227 ", %dx%d, %0.2f fps",
214 enc->width, enc->height, 228 enc->width, enc->height,
215 (float)enc->frame_rate / FRAME_RATE_BASE); 229 (float)enc->frame_rate / FRAME_RATE_BASE);
232 if (enc->bit_rate != 0) { 246 if (enc->bit_rate != 0) {
233 snprintf(buf + strlen(buf), buf_size - strlen(buf), 247 snprintf(buf + strlen(buf), buf_size - strlen(buf),
234 ", %d kb/s", enc->bit_rate / 1000); 248 ", %d kb/s", enc->bit_rate / 1000);
235 } 249 }
236 } 250 }
251
252 /* Picture field are filled with 'ptr' addresses */
253 void avpicture_fill(AVPicture *picture, UINT8 *ptr,
254 int pix_fmt, int width, int height)
255 {
256 int size;
257
258 size = width * height;
259 switch(pix_fmt) {
260 case PIX_FMT_YUV420P:
261 picture->data[0] = ptr;
262 picture->data[1] = picture->data[0] + size;
263 picture->data[2] = picture->data[1] + size / 4;
264 picture->linesize[0] = width;
265 picture->linesize[1] = width / 2;
266 picture->linesize[2] = width / 2;
267 break;
268 case PIX_FMT_YUV422P:
269 picture->data[0] = ptr;
270 picture->data[1] = picture->data[0] + size;
271 picture->data[2] = picture->data[1] + size / 2;
272 picture->linesize[0] = width;
273 picture->linesize[1] = width / 2;
274 picture->linesize[2] = width / 2;
275 break;
276 case PIX_FMT_YUV444P:
277 picture->data[0] = ptr;
278 picture->data[1] = picture->data[0] + size;
279 picture->data[2] = picture->data[1] + size;
280 picture->linesize[0] = width;
281 picture->linesize[1] = width;
282 picture->linesize[2] = width;
283 break;
284 case PIX_FMT_RGB24:
285 case PIX_FMT_BGR24:
286 picture->data[0] = ptr;
287 picture->data[1] = NULL;
288 picture->data[2] = NULL;
289 picture->linesize[0] = width * 3;
290 break;
291 case PIX_FMT_YUV422:
292 picture->data[0] = ptr;
293 picture->data[1] = NULL;
294 picture->data[2] = NULL;
295 picture->linesize[0] = width * 2;
296 break;
297 default:
298 picture->data[0] = NULL;
299 picture->data[1] = NULL;
300 picture->data[2] = NULL;
301 break;
302 }
303 }
304
305 int avpicture_get_size(int pix_fmt, int width, int height)
306 {
307 int size;
308
309 size = width * height;
310 switch(pix_fmt) {
311 case PIX_FMT_YUV420P:
312 size = (size * 3) / 2;
313 break;
314 case PIX_FMT_YUV422P:
315 size = (size * 2);
316 break;
317 case PIX_FMT_YUV444P:
318 size = (size * 3);
319 break;
320 case PIX_FMT_RGB24:
321 case PIX_FMT_BGR24:
322 size = (size * 3);
323 break;
324 case PIX_FMT_YUV422:
325 size = (size * 2);
326 break;
327 default:
328 size = -1;
329 break;
330 }
331 return size;
332 }
333
237 334
238 /* must be called before any other functions */ 335 /* must be called before any other functions */
239 void avcodec_init(void) 336 void avcodec_init(void)
240 { 337 {
241 dsputil_init(); 338 dsputil_init();