2001-02-24 20:28:24 +00:00
|
|
|
/*
|
|
|
|
* video_out_pgm.c, pgm interface
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Hacked into mpeg2dec by
|
|
|
|
*
|
|
|
|
* Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
|
|
|
|
*
|
|
|
|
* 15 & 16 bpp support added by Franck Sicard <Franck.Sicard@solsoft.fr>
|
|
|
|
*
|
|
|
|
* Xv image suuport by Gerd Knorr <kraxel@goldbach.in-berlin.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2002-02-17 08:24:43 +00:00
|
|
|
#include <errno.h>
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "video_out.h"
|
|
|
|
#include "video_out_internal.h"
|
|
|
|
|
2002-11-11 15:22:10 +00:00
|
|
|
static vo_info_t info =
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
"PGM file",
|
|
|
|
"pgm",
|
|
|
|
"walken",
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2002-11-11 15:22:10 +00:00
|
|
|
LIBVO_EXTERN (pgm)
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
static int image_width;
|
|
|
|
static int image_height;
|
|
|
|
static char header[1024];
|
2001-04-17 21:00:46 +00:00
|
|
|
static int framenum = 0;
|
|
|
|
|
|
|
|
static uint8_t *image=NULL;
|
|
|
|
|
|
|
|
char vo_pgm_filename[24];
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
static uint32_t
|
2002-08-28 21:32:32 +00:00
|
|
|
config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
image_height = height;
|
|
|
|
image_width = width;
|
2001-04-17 21:00:46 +00:00
|
|
|
image=malloc(width*height*3/2);
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-06-11 12:34:46 +00:00
|
|
|
snprintf (header, 1024, "P5\n\n%d %d\n255\n", width, height*3/2);
|
2001-02-24 20:28:24 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-08-13 11:33:34 +00:00
|
|
|
static void draw_osd(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
static void flip_page (void)
|
|
|
|
{
|
2001-04-17 21:00:46 +00:00
|
|
|
FILE * f;
|
2001-02-24 20:28:24 +00:00
|
|
|
|
2001-06-11 12:34:46 +00:00
|
|
|
snprintf (vo_pgm_filename, 24, "%08d.pgm", framenum++);
|
2001-04-17 21:00:46 +00:00
|
|
|
|
|
|
|
f = fopen (vo_pgm_filename, "wb"); if (f == NULL) return;
|
|
|
|
fwrite (header, strlen (header), 1, f);
|
|
|
|
fwrite (image, image_width, image_height*3/2, f);
|
|
|
|
fclose (f);
|
|
|
|
|
|
|
|
return;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2001-04-17 21:00:46 +00:00
|
|
|
static uint32_t draw_slice(uint8_t *srcimg[], int stride[], int w,int h,int x,int y)
|
2001-02-24 20:28:24 +00:00
|
|
|
{
|
|
|
|
int i;
|
2001-04-17 21:00:46 +00:00
|
|
|
// copy Y:
|
|
|
|
uint8_t *dst=image+image_width*y+x;
|
|
|
|
uint8_t *src=srcimg[0];
|
|
|
|
for(i=0;i<h;i++){
|
|
|
|
memcpy(dst,src,w);
|
|
|
|
src+=stride[0];
|
|
|
|
dst+=image_width;
|
|
|
|
}
|
|
|
|
{
|
|
|
|
// copy U+V:
|
|
|
|
uint8_t *src1=srcimg[1];
|
|
|
|
uint8_t *src2=srcimg[2];
|
|
|
|
uint8_t *dst=image+image_width*image_height+image_width*(y/2)+(x/2);
|
|
|
|
for(i=0;i<h/2;i++){
|
|
|
|
memcpy(dst,src1,w/2);
|
|
|
|
memcpy(dst+image_width/2,src2,w/2);
|
|
|
|
src1+=stride[1];
|
|
|
|
src2+=stride[2];
|
|
|
|
dst+=image_width;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
2001-04-17 21:00:46 +00:00
|
|
|
}
|
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-04-17 21:00:46 +00:00
|
|
|
|
2001-02-24 20:28:24 +00:00
|
|
|
static uint32_t draw_frame(uint8_t * src[])
|
|
|
|
{
|
2001-04-17 21:00:46 +00:00
|
|
|
return 0;
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
query_format(uint32_t format)
|
|
|
|
{
|
2001-04-17 21:00:46 +00:00
|
|
|
if(format==IMGFMT_YV12) return 1;
|
2001-02-27 01:12:05 +00:00
|
|
|
// switch(format){
|
|
|
|
// case IMGFMT_YV12:
|
2001-02-24 20:28:24 +00:00
|
|
|
// case IMGFMT_RGB|24:
|
|
|
|
// case IMGFMT_BGR|24:
|
2001-02-27 01:12:05 +00:00
|
|
|
// return 1;
|
|
|
|
// }
|
2001-02-24 20:28:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
uninit(void)
|
|
|
|
{
|
2001-04-17 21:00:46 +00:00
|
|
|
if(image){ free(image);image=NULL;}
|
2001-02-24 20:28:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-03 21:46:39 +00:00
|
|
|
static void check_events(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-01-26 16:01:26 +00:00
|
|
|
static uint32_t preinit(const char *arg)
|
|
|
|
{
|
2002-02-17 08:24:43 +00:00
|
|
|
if(arg)
|
|
|
|
{
|
|
|
|
printf("vo_pgm: Unknown subdevice: %s\n",arg);
|
|
|
|
return ENOSYS;
|
|
|
|
}
|
|
|
|
return 0;
|
2002-01-26 16:01:26 +00:00
|
|
|
}
|
2001-03-03 21:46:39 +00:00
|
|
|
|
2002-02-09 01:21:48 +00:00
|
|
|
static uint32_t control(uint32_t request, void *data, ...)
|
2002-01-26 16:01:26 +00:00
|
|
|
{
|
2002-02-09 00:47:26 +00:00
|
|
|
switch (request) {
|
|
|
|
case VOCTRL_QUERY_FORMAT:
|
|
|
|
return query_format(*((uint32_t*)data));
|
|
|
|
}
|
|
|
|
return VO_NOTIMPL;
|
2002-01-26 16:01:26 +00:00
|
|
|
}
|