2001-10-22 16:54:13 +00:00
|
|
|
/*
|
2001-10-22 23:17:14 +00:00
|
|
|
xacodec.c -- XAnim Video Codec DLL support
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
(C) 2001 Alex Beregszaszi <alex@naxine.org>
|
2001-10-22 23:17:14 +00:00
|
|
|
and Arpad Gereoffy <arpi@thot.banki.hu>
|
2001-10-22 16:54:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2001-10-22 17:49:17 +00:00
|
|
|
#include <stdlib.h>
|
2001-11-03 21:57:07 +00:00
|
|
|
#include <string.h> /* strerror */
|
2001-10-22 17:49:17 +00:00
|
|
|
|
2001-10-23 08:55:47 +00:00
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2001-10-22 16:54:13 +00:00
|
|
|
#include <dlfcn.h> /* dlsym, dlopen, dlclose */
|
|
|
|
#include <stdarg.h> /* va_alist, va_start, va_end */
|
|
|
|
#include <errno.h> /* strerror, errno */
|
|
|
|
|
2001-10-22 17:49:17 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-10-22 17:07:40 +00:00
|
|
|
#include "mp_msg.h"
|
2001-10-22 17:49:17 +00:00
|
|
|
#include "bswap.h"
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
#include "stream.h"
|
|
|
|
#include "demuxer.h"
|
|
|
|
#include "codec-cfg.h"
|
|
|
|
#include "stheader.h"
|
2001-10-22 17:49:17 +00:00
|
|
|
|
2001-10-22 16:54:13 +00:00
|
|
|
#include "libvo/img_format.h"
|
2001-11-03 21:57:07 +00:00
|
|
|
#include "linux/timer.h"
|
2001-10-22 16:54:13 +00:00
|
|
|
#include "xacodec.h"
|
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
#ifdef USE_XANIM
|
2001-10-26 13:39:15 +00:00
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
#if 0
|
2001-10-22 20:48:39 +00:00
|
|
|
typedef char xaBYTE;
|
|
|
|
typedef short xaSHORT;
|
|
|
|
typedef int xaLONG;
|
|
|
|
|
|
|
|
typedef unsigned char xaUBYTE;
|
|
|
|
typedef unsigned short xaUSHORT;
|
|
|
|
typedef unsigned int xaULONG;
|
2001-10-23 01:46:55 +00:00
|
|
|
#endif
|
2001-10-22 20:48:39 +00:00
|
|
|
|
|
|
|
#define xaFALSE 0
|
|
|
|
#define xaTRUE 1
|
|
|
|
|
2001-10-22 16:54:13 +00:00
|
|
|
#ifndef RTLD_NOW
|
|
|
|
#define RLTD_NOW 2
|
|
|
|
#endif
|
|
|
|
#ifndef RTLD_LAZY
|
|
|
|
#define RLTD_LAZY 1
|
|
|
|
#endif
|
|
|
|
#ifndef RTLD_GLOBAL
|
|
|
|
#define RLTD_GLOBAL 256
|
|
|
|
#endif
|
|
|
|
|
2001-10-22 21:03:25 +00:00
|
|
|
#define XA_CLOSE_FUNCS 5
|
|
|
|
int xa_close_func = 0;
|
|
|
|
|
2001-10-22 16:54:13 +00:00
|
|
|
typedef struct xacodec_driver
|
|
|
|
{
|
|
|
|
XA_DEC_INFO *decinfo;
|
|
|
|
void *file_handler;
|
|
|
|
long (*iq_func)(XA_CODEC_HDR *codec_hdr);
|
|
|
|
unsigned int (*dec_func)(unsigned char *image, unsigned char *delta,
|
|
|
|
unsigned int dsize, XA_DEC_INFO *dec_info);
|
2001-10-22 21:03:25 +00:00
|
|
|
void *close_func[XA_CLOSE_FUNCS];
|
2001-10-22 22:45:06 +00:00
|
|
|
xacodec_image_t image;
|
2001-10-22 16:54:13 +00:00
|
|
|
} xacodec_driver_t;
|
|
|
|
|
|
|
|
xacodec_driver_t *xacodec_driver = NULL;
|
|
|
|
|
|
|
|
/* Needed by XAnim DLLs */
|
2001-11-03 21:57:07 +00:00
|
|
|
void XA_Print(char *fmt, ...)
|
2001-10-22 16:54:13 +00:00
|
|
|
{
|
|
|
|
va_list vallist;
|
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
va_start(vallist, fmt);
|
|
|
|
vsnprintf(buf, 1024, fmt, vallist);
|
2001-10-22 18:52:10 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "[xacodec] %s\n", buf);
|
2001-10-22 16:54:13 +00:00
|
|
|
va_end(vallist);
|
2001-11-03 21:57:07 +00:00
|
|
|
|
|
|
|
return;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
|
2001-10-22 21:03:25 +00:00
|
|
|
/* 0 is no debug (needed by 3ivX) */
|
2001-10-22 23:17:14 +00:00
|
|
|
long xa_debug = 0;
|
2001-10-22 21:03:25 +00:00
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
void TheEnd1(char *err_mess)
|
2001-10-22 16:54:13 +00:00
|
|
|
{
|
|
|
|
XA_Print("error: %s - exiting\n", err_mess);
|
|
|
|
xacodec_exit();
|
2001-11-03 21:57:07 +00:00
|
|
|
|
|
|
|
return;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
2001-10-22 21:03:25 +00:00
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
void XA_Add_Func_To_Free_Chain(XA_ANIM_HDR *anim_hdr, void (*function)())
|
2001-10-22 21:03:25 +00:00
|
|
|
{
|
2001-10-22 23:17:14 +00:00
|
|
|
// XA_Print("XA_Add_Func_To_Free_Chain('anim_hdr: %08x', 'function: %08x')",
|
|
|
|
// anim_hdr, function);
|
2001-10-22 21:03:25 +00:00
|
|
|
xacodec_driver->close_func[xa_close_func] = function;
|
|
|
|
if (xa_close_func+1 < XA_CLOSE_FUNCS)
|
|
|
|
xa_close_func++;
|
2001-11-03 21:57:07 +00:00
|
|
|
|
|
|
|
return;
|
2001-10-22 21:03:25 +00:00
|
|
|
}
|
2001-10-22 16:54:13 +00:00
|
|
|
/* end of crap */
|
|
|
|
|
|
|
|
/* load, init and query */
|
|
|
|
int xacodec_init(char *filename, xacodec_driver_t *codec_driver)
|
|
|
|
{
|
|
|
|
void *(*what_the)();
|
|
|
|
char *error;
|
|
|
|
XAVID_MOD_HDR *mod_hdr;
|
|
|
|
XAVID_FUNC_HDR *func;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
codec_driver->file_handler = dlopen(filename, RTLD_NOW|RTLD_GLOBAL);
|
|
|
|
if (!codec_driver->file_handler)
|
|
|
|
{
|
|
|
|
error = dlerror();
|
|
|
|
if (error)
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: failed to dlopen %s while %s\n", filename, error);
|
2001-10-22 16:54:13 +00:00
|
|
|
else
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: failed to dlopen %s\n", filename);
|
2001-10-22 16:54:13 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
what_the = dlsym(codec_driver->file_handler, "What_The");
|
|
|
|
if ((error = dlerror()) != NULL)
|
|
|
|
{
|
2001-10-22 17:07:40 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: failed to init %s while %s\n", filename, error);
|
2001-10-22 16:54:13 +00:00
|
|
|
dlclose(codec_driver->file_handler);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
mod_hdr = what_the();
|
|
|
|
if (!mod_hdr)
|
|
|
|
{
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: initializer function failed in %s\n", filename);
|
2001-10-22 16:54:13 +00:00
|
|
|
dlclose(codec_driver->file_handler);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2001-10-22 17:07:40 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_INFO, "=== XAnim Codec ===\n");
|
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_INFO, " Filename: %s (API revision: %x)\n", filename, mod_hdr->api_rev);
|
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_INFO, " Codec: %s. Rev: %s\n", mod_hdr->desc, mod_hdr->rev);
|
2001-10-22 16:54:13 +00:00
|
|
|
if (mod_hdr->copyright)
|
2001-10-22 17:07:40 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_INFO, " %s\n", mod_hdr->copyright);
|
2001-10-22 16:54:13 +00:00
|
|
|
if (mod_hdr->mod_author)
|
2001-10-22 17:07:40 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_INFO, " Module Author(s): %s\n", mod_hdr->mod_author);
|
2001-10-22 16:54:13 +00:00
|
|
|
if (mod_hdr->authors)
|
2001-10-22 17:07:40 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_INFO, " Codec Author(s): %s\n", mod_hdr->authors);
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
if (mod_hdr->api_rev > XAVID_API_REV)
|
|
|
|
{
|
2001-10-23 12:02:45 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: not supported api revision (%d) in %s\n",
|
|
|
|
mod_hdr->api_rev, filename);
|
2001-10-22 16:54:13 +00:00
|
|
|
dlclose(codec_driver->file_handler);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
func = mod_hdr->funcs;
|
|
|
|
if (!func)
|
|
|
|
{
|
2001-10-22 17:07:40 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: function table error in %s\n", filename);
|
2001-10-22 16:54:13 +00:00
|
|
|
dlclose(codec_driver->file_handler);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Exported functions by codec: [functable: 0x%08x entries: %d]\n",
|
|
|
|
mod_hdr->funcs, mod_hdr->num_funcs);
|
2001-10-22 16:54:13 +00:00
|
|
|
for (i = 0; i < mod_hdr->num_funcs; i++)
|
|
|
|
{
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, " %d: %d %d [iq:0x%08x d:0x%08x]\n",
|
|
|
|
i, func[i].what, func[i].id, func[i].iq_func, func[i].dec_func);
|
2001-10-22 16:54:13 +00:00
|
|
|
if (func[i].what & XAVID_AVI_QUERY)
|
|
|
|
{
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, " 0x%08x: avi init/query func (id: %d)\n",
|
2001-10-22 16:54:13 +00:00
|
|
|
func[i].iq_func, func[i].id);
|
2001-11-03 21:57:07 +00:00
|
|
|
codec_driver->iq_func = (void *)func[i].iq_func;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
if (func[i].what & XAVID_QT_QUERY)
|
|
|
|
{
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, " 0x%08x: qt init/query func (id: %d)\n",
|
2001-10-22 16:54:13 +00:00
|
|
|
func[i].iq_func, func[i].id);
|
2001-10-23 02:11:27 +00:00
|
|
|
codec_driver->iq_func = (void *)func[i].iq_func;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
if (func[i].what & XAVID_DEC_FUNC)
|
|
|
|
{
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, " 0x%08x: decoder func (init/query: 0x%08x) (id: %d)\n",
|
2001-10-22 16:54:13 +00:00
|
|
|
func[i].dec_func, func[i].iq_func, func[i].id);
|
2001-10-23 02:11:27 +00:00
|
|
|
codec_driver->dec_func = (void *)func[i].dec_func;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int xacodec_query(xacodec_driver_t *codec_driver, XA_CODEC_HDR *codec_hdr)
|
|
|
|
{
|
|
|
|
long codec_ret;
|
|
|
|
|
2001-11-04 14:21:44 +00:00
|
|
|
#if 0
|
|
|
|
/* the brute one */
|
|
|
|
if (codec_driver->dec_func)
|
|
|
|
{
|
|
|
|
codec_hdr->decoder = codec_driver->dec_func;
|
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "We got decoder's address at init! %p\n", codec_hdr->decoder);
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
#endif
|
2001-10-22 16:54:13 +00:00
|
|
|
codec_ret = codec_driver->iq_func(codec_hdr);
|
|
|
|
switch(codec_ret)
|
|
|
|
{
|
|
|
|
case CODEC_SUPPORTED:
|
2001-10-23 02:11:27 +00:00
|
|
|
codec_driver->dec_func = (void *)codec_hdr->decoder;
|
2001-10-22 21:03:25 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Codec is supported: found decoder for %s at 0x%08x\n",
|
2001-10-22 16:54:13 +00:00
|
|
|
codec_hdr->description, codec_hdr->decoder);
|
|
|
|
return(1);
|
|
|
|
case CODEC_UNSUPPORTED:
|
2001-10-22 23:17:14 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "Codec (%s) is unsupported by driver\n",
|
|
|
|
codec_hdr->description);
|
2001-10-22 16:54:13 +00:00
|
|
|
return(0);
|
|
|
|
case CODEC_UNKNOWN:
|
|
|
|
default:
|
2001-10-22 23:17:14 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "Codec (%s) is unknown by driver\n",
|
|
|
|
codec_hdr->description);
|
2001-10-22 16:54:13 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char *xacodec_def_path = XACODEC_PATH;
|
|
|
|
|
|
|
|
int xacodec_init_video(sh_video_t *vidinfo, int out_format)
|
|
|
|
{
|
|
|
|
char dll[1024];
|
|
|
|
XA_CODEC_HDR codec_hdr;
|
2001-10-22 21:03:25 +00:00
|
|
|
int i;
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
xacodec_driver = realloc(xacodec_driver, sizeof(struct xacodec_driver));
|
|
|
|
if (xacodec_driver == NULL)
|
2001-10-23 12:02:45 +00:00
|
|
|
{
|
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: memory allocation error: %s\n",
|
|
|
|
strerror(errno));
|
2001-10-22 16:54:13 +00:00
|
|
|
return(0);
|
2001-10-23 12:02:45 +00:00
|
|
|
}
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
xacodec_driver->iq_func = NULL;
|
|
|
|
xacodec_driver->dec_func = NULL;
|
2001-10-22 21:03:25 +00:00
|
|
|
|
|
|
|
for (i=0; i < XA_CLOSE_FUNCS; i++)
|
|
|
|
xacodec_driver->close_func[i] = NULL;
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
snprintf(dll, 1024, "%s/%s", xacodec_def_path, vidinfo->codec->dll);
|
|
|
|
if (xacodec_init(dll, xacodec_driver) == 0)
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
codec_hdr.anim_hdr = malloc(4096);
|
|
|
|
codec_hdr.description = vidinfo->codec->info;
|
2001-11-04 14:21:44 +00:00
|
|
|
codec_hdr.compression = bswap_32(vidinfo->bih->biCompression);
|
2001-10-22 16:54:13 +00:00
|
|
|
codec_hdr.decoder = NULL;
|
|
|
|
codec_hdr.avi_ctab_flag = 0;
|
|
|
|
codec_hdr.avi_read_ext = NULL;
|
2001-11-04 14:21:44 +00:00
|
|
|
codec_hdr.xapi_rev = XAVID_API_REV;
|
2001-10-22 16:54:13 +00:00
|
|
|
codec_hdr.extra = NULL;
|
|
|
|
codec_hdr.x = vidinfo->disp_w;
|
|
|
|
codec_hdr.y = vidinfo->disp_h;
|
|
|
|
|
|
|
|
switch(out_format)
|
|
|
|
{
|
2001-11-03 21:57:07 +00:00
|
|
|
/* case IMGFMT_RGB8:
|
2001-10-22 16:54:13 +00:00
|
|
|
codec_hdr.depth = 8;
|
|
|
|
break;
|
|
|
|
case IMGFMT_RGB15:
|
|
|
|
codec_hdr.depth = 15;
|
|
|
|
break;
|
|
|
|
case IMGFMT_RGB16:
|
|
|
|
codec_hdr.depth = 16;
|
|
|
|
break;
|
|
|
|
case IMGFMT_RGB24:
|
|
|
|
codec_hdr.depth = 24;
|
|
|
|
break;
|
|
|
|
case IMGFMT_RGB32:
|
|
|
|
codec_hdr.depth = 32;
|
|
|
|
break;
|
|
|
|
case IMGFMT_BGR8:
|
|
|
|
codec_hdr.depth = 8;
|
|
|
|
break;
|
|
|
|
case IMGFMT_BGR15:
|
|
|
|
codec_hdr.depth = 15;
|
|
|
|
break;
|
|
|
|
case IMGFMT_BGR16:
|
|
|
|
codec_hdr.depth = 16;
|
|
|
|
break;
|
|
|
|
case IMGFMT_BGR24:
|
|
|
|
codec_hdr.depth = 24;
|
|
|
|
break;
|
|
|
|
case IMGFMT_BGR32:
|
|
|
|
codec_hdr.depth = 32;
|
2001-11-03 21:57:07 +00:00
|
|
|
break;*/
|
2001-10-22 21:31:42 +00:00
|
|
|
case IMGFMT_IYUV:
|
2001-10-22 21:03:25 +00:00
|
|
|
case IMGFMT_I420:
|
2001-10-22 21:31:42 +00:00
|
|
|
case IMGFMT_YV12:
|
|
|
|
codec_hdr.depth = 12;
|
2001-10-22 21:03:25 +00:00
|
|
|
break;
|
2001-10-22 16:54:13 +00:00
|
|
|
default:
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: not supported image out format (%s)\n",
|
2001-10-22 16:54:13 +00:00
|
|
|
vo_format_name(out_format));
|
|
|
|
return(0);
|
|
|
|
}
|
2001-11-03 21:57:07 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_INFO, "xacodec: querying for input %dx%d %dbit [fourcc: %4x] (%s)...\n",
|
|
|
|
codec_hdr.x, codec_hdr.y, codec_hdr.depth, codec_hdr.compression, codec_hdr.description);
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
if (xacodec_query(xacodec_driver, &codec_hdr) == 0)
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
// free(codec_hdr.anim_hdr);
|
|
|
|
|
|
|
|
xacodec_driver->decinfo = malloc(sizeof(XA_DEC_INFO));
|
2001-10-23 12:02:45 +00:00
|
|
|
if (xacodec_driver->decinfo == NULL)
|
|
|
|
{
|
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: memory allocation error: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return(0);
|
|
|
|
}
|
2001-10-22 16:54:13 +00:00
|
|
|
xacodec_driver->decinfo->cmd = 0;
|
|
|
|
xacodec_driver->decinfo->skip_flag = 0;
|
|
|
|
xacodec_driver->decinfo->imagex = xacodec_driver->decinfo->xe = codec_hdr.x;
|
|
|
|
xacodec_driver->decinfo->imagey = xacodec_driver->decinfo->ye = codec_hdr.y;
|
|
|
|
xacodec_driver->decinfo->imaged = codec_hdr.depth;
|
|
|
|
xacodec_driver->decinfo->chdr = NULL;
|
|
|
|
xacodec_driver->decinfo->map_flag = 0; /* xaFALSE */
|
|
|
|
xacodec_driver->decinfo->map = NULL;
|
|
|
|
xacodec_driver->decinfo->xs = xacodec_driver->decinfo->ys = 0;
|
|
|
|
xacodec_driver->decinfo->special = 0;
|
|
|
|
xacodec_driver->decinfo->extra = codec_hdr.extra;
|
2001-10-23 12:02:45 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "decinfo->extra, filled by codec: 0x%08x [%s]\n",
|
|
|
|
&xacodec_driver->decinfo->extra, xacodec_driver->decinfo->extra);
|
2001-10-22 16:54:13 +00:00
|
|
|
|
2001-10-22 18:52:10 +00:00
|
|
|
// vidinfo->our_out_buffer = malloc(codec_hdr.y * codec_hdr.x * ((codec_hdr.depth+7)/8));
|
2001-10-22 22:45:06 +00:00
|
|
|
// vidinfo->our_out_buffer = malloc(codec_hdr.y * codec_hdr.x * codec_hdr.depth);
|
2001-10-23 12:02:45 +00:00
|
|
|
xacodec_driver->image.out_fmt = out_format;
|
|
|
|
xacodec_driver->image.bpp = codec_hdr.depth;
|
|
|
|
xacodec_driver->image.width = codec_hdr.x;
|
|
|
|
xacodec_driver->image.height = codec_hdr.y;
|
|
|
|
xacodec_driver->image.mem = malloc(codec_hdr.y * codec_hdr.x * ((codec_hdr.depth+7)/8));
|
2001-10-22 16:54:13 +00:00
|
|
|
|
2001-10-22 23:17:14 +00:00
|
|
|
if (xacodec_driver->image.mem == NULL)
|
2001-10-22 16:54:13 +00:00
|
|
|
{
|
2001-10-23 12:02:45 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: memory allocation error: %s\n",
|
2001-10-22 16:54:13 +00:00
|
|
|
strerror(errno));
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
#define ACT_DLTA_NORM 0x00000000
|
|
|
|
#define ACT_DLTA_BODY 0x00000001
|
|
|
|
#define ACT_DLTA_XOR 0x00000002
|
|
|
|
#define ACT_DLTA_NOP 0x00000004
|
|
|
|
#define ACT_DLTA_MAPD 0x00000008
|
|
|
|
#define ACT_DLTA_DROP 0x00000010
|
|
|
|
#define ACT_DLTA_BAD 0x80000000
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
// unsigned int (*dec_func)(unsigned char *image, unsigned char *delta,
|
|
|
|
// unsigned int dsize, XA_DEC_INFO *dec_info);
|
|
|
|
|
2001-10-22 22:45:06 +00:00
|
|
|
xacodec_image_t* xacodec_decode_frame(uint8_t *frame, int frame_size, int skip_flag)
|
2001-10-22 16:54:13 +00:00
|
|
|
{
|
|
|
|
unsigned int ret;
|
2001-10-22 23:04:43 +00:00
|
|
|
xacodec_image_t *image=&xacodec_driver->image;
|
2001-10-22 22:45:06 +00:00
|
|
|
|
2001-10-23 01:46:55 +00:00
|
|
|
// ugyis kiirja a vegen h dropped vagy nem..
|
|
|
|
// if (skip_flag > 0)
|
|
|
|
// mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "frame will be dropped..\n");
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
xacodec_driver->decinfo->skip_flag = skip_flag;
|
|
|
|
|
2001-10-22 23:04:43 +00:00
|
|
|
image->planes[0]=image->mem;
|
|
|
|
image->stride[0]=image->width;
|
|
|
|
image->stride[1]=image->stride[2]=image->width/2;
|
|
|
|
switch(image->out_fmt){
|
|
|
|
case IMGFMT_YV12:
|
|
|
|
image->planes[2]=image->planes[0]+image->width*image->height;
|
|
|
|
image->planes[1]=image->planes[2]+image->width*image->height/4;
|
|
|
|
break;
|
|
|
|
case IMGFMT_I420:
|
|
|
|
case IMGFMT_IYUV:
|
|
|
|
image->planes[1]=image->planes[0]+image->width*image->height;
|
|
|
|
image->planes[2]=image->planes[1]+image->width*image->height/4;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-10-22 22:45:06 +00:00
|
|
|
// printf("frame: %08x (size: %d) - dest: %08x\n", frame, frame_size, dest);
|
2001-10-22 16:54:13 +00:00
|
|
|
|
2001-10-22 22:45:06 +00:00
|
|
|
ret = xacodec_driver->dec_func((uint8_t*)&xacodec_driver->image, frame, frame_size, xacodec_driver->decinfo);
|
2001-10-22 16:54:13 +00:00
|
|
|
|
2001-10-22 22:45:06 +00:00
|
|
|
// printf("ret: %lu : ", ret);
|
2001-10-22 16:54:13 +00:00
|
|
|
|
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
if (ret == ACT_DLTA_NORM)
|
2001-10-22 16:54:13 +00:00
|
|
|
{
|
2001-10-23 02:11:27 +00:00
|
|
|
// mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "norm\n");
|
2001-10-22 22:45:06 +00:00
|
|
|
return &xacodec_driver->image;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
if (ret & ACT_DLTA_MAPD)
|
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "mapd\n");
|
2001-10-22 16:54:13 +00:00
|
|
|
/*
|
|
|
|
if (!(ret & ACT_DLT_MAPD))
|
|
|
|
xacodec_driver->decinfo->map_flag = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
xacodec_driver->decinfo->map_flag = 1;
|
|
|
|
xacodec_driver->decinfo->map = ...
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
if (ret & ACT_DLTA_XOR)
|
|
|
|
{
|
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "xor\n");
|
|
|
|
return &xacodec_driver->image;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nothing changed */
|
|
|
|
if (ret & ACT_DLTA_NOP)
|
2001-10-22 16:54:13 +00:00
|
|
|
{
|
2001-10-22 23:17:14 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "nop\n");
|
2001-11-03 21:57:07 +00:00
|
|
|
return NULL;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
/* frame dropped (also display latest frame) */
|
|
|
|
if (ret & ACT_DLTA_DROP)
|
2001-10-22 16:54:13 +00:00
|
|
|
{
|
2001-10-22 23:17:14 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "drop\n");
|
2001-10-22 22:45:06 +00:00
|
|
|
return NULL;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
if (ret & ACT_DLTA_BAD)
|
2001-10-22 16:54:13 +00:00
|
|
|
{
|
2001-10-22 23:17:14 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "bad\n");
|
2001-10-22 22:45:06 +00:00
|
|
|
return NULL;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
|
2001-11-03 21:57:07 +00:00
|
|
|
/* used for double buffer */
|
|
|
|
if (ret & ACT_DLTA_BODY)
|
2001-10-22 16:54:13 +00:00
|
|
|
{
|
2001-10-22 23:17:14 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "body\n");
|
2001-10-22 22:45:06 +00:00
|
|
|
return NULL;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
|
2001-10-22 22:45:06 +00:00
|
|
|
return NULL;
|
2001-10-22 16:54:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int xacodec_exit()
|
|
|
|
{
|
2001-10-22 21:03:25 +00:00
|
|
|
int i;
|
|
|
|
void (*close_func)();
|
|
|
|
|
|
|
|
for (i=0; i < XA_CLOSE_FUNCS; i++)
|
|
|
|
if (xacodec_driver->close_func[i])
|
|
|
|
{
|
|
|
|
close_func = xacodec_driver->close_func[i];
|
|
|
|
close_func();
|
|
|
|
}
|
2001-10-22 16:54:13 +00:00
|
|
|
dlclose(xacodec_driver->file_handler);
|
|
|
|
if (xacodec_driver->decinfo != NULL)
|
|
|
|
free(xacodec_driver->decinfo);
|
2001-10-22 23:17:14 +00:00
|
|
|
free(xacodec_driver);
|
2001-10-22 16:54:13 +00:00
|
|
|
return(TRUE);
|
|
|
|
}
|
2001-10-22 17:07:40 +00:00
|
|
|
|
|
|
|
|
2001-10-23 02:11:27 +00:00
|
|
|
/* *** XANIM Conversions *** */
|
2001-10-22 17:07:40 +00:00
|
|
|
/* like loader/win32.c - mini XANIM library */
|
|
|
|
|
2001-10-22 21:03:25 +00:00
|
|
|
unsigned long XA_Time_Read()
|
|
|
|
{
|
2001-10-22 22:45:06 +00:00
|
|
|
return GetTimer(); //(GetRelativeTime());
|
2001-10-22 21:03:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void XA_dummy()
|
|
|
|
{
|
|
|
|
XA_Print("dummy() called");
|
|
|
|
}
|
|
|
|
|
2001-10-23 01:46:55 +00:00
|
|
|
void XA_Gen_YUV_Tabs(XA_ANIM_HDR *anim_hdr)
|
2001-10-22 23:42:19 +00:00
|
|
|
{
|
|
|
|
XA_Print("XA_Gen_YUV_Tabs('anim_hdr: %08x')", anim_hdr);
|
|
|
|
|
|
|
|
// XA_Print("anim type: %d - img[x: %d, y: %d, c: %d, d: %d]",
|
|
|
|
// anim_hdr->anim_type, anim_hdr->imagex, anim_hdr->imagey,
|
|
|
|
// anim_hdr->imagec, anim_hdr->imaged);
|
2001-10-23 01:46:55 +00:00
|
|
|
return;
|
2001-10-22 23:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JPG_Setup_Samp_Limit_Table(XA_ANIM_HDR *anim_hdr)
|
|
|
|
{
|
|
|
|
XA_Print("JPG_Setup_Samp_Limit_Table('anim_hdr: %08x')", anim_hdr);
|
|
|
|
// xa_byte_limit = jpg_samp_limit + (MAXJSAMPLE + 1);
|
2001-10-23 01:46:55 +00:00
|
|
|
return;
|
2001-10-22 23:42:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void JPG_Alloc_MCU_Bufs(XA_ANIM_HDR *anim_hdr, unsigned int width,
|
|
|
|
unsigned int height, unsigned int full_flag)
|
|
|
|
{
|
|
|
|
XA_Print("JPG_Alloc_MCU_Bufs('anim_hdr: %08x', 'width: %d', 'height: %d', 'full_flag: %d')",
|
|
|
|
anim_hdr, width, height, full_flag);
|
2001-10-23 01:46:55 +00:00
|
|
|
return;
|
2001-10-22 23:42:19 +00:00
|
|
|
}
|
|
|
|
|
2001-10-23 02:32:59 +00:00
|
|
|
/* --------------- 4x4 pixel YUV block fillers [CVID] ----------------- */
|
2001-10-22 23:42:19 +00:00
|
|
|
|
2001-10-22 17:07:40 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned char r0, g0, b0;
|
|
|
|
unsigned char r1, g1, b1;
|
|
|
|
unsigned char r2, g2, b2;
|
|
|
|
unsigned char r3, g3, b3;
|
|
|
|
unsigned int clr0_0, clr0_1, clr0_2, clr0_3;
|
|
|
|
unsigned int clr1_0, clr1_1, clr1_2, clr1_3;
|
|
|
|
unsigned int clr2_0, clr2_1, clr2_2, clr2_3;
|
|
|
|
unsigned int clr3_0, clr3_1, clr3_2, clr3_3;
|
|
|
|
} XA_2x2_Color;
|
|
|
|
|
2001-10-22 23:42:19 +00:00
|
|
|
#define SET_4_YUV_PIXELS(image,x,y,cmap2x2) \
|
|
|
|
image->planes[0][((x)+0)+((y)+0)*image->stride[0]]=cmap2x2->clr0_0;\
|
|
|
|
image->planes[0][((x)+1)+((y)+0)*image->stride[0]]=cmap2x2->clr0_1;\
|
|
|
|
image->planes[0][((x)+0)+((y)+1)*image->stride[0]]=cmap2x2->clr0_2;\
|
|
|
|
image->planes[0][((x)+1)+((y)+1)*image->stride[0]]=cmap2x2->clr0_3;\
|
|
|
|
image->planes[1][((x)>>1)+((y)>>1)*image->stride[1]]=cmap2x2->clr1_0;\
|
|
|
|
image->planes[2][((x)>>1)+((y)>>1)*image->stride[2]]=cmap2x2->clr1_1;
|
2001-10-22 17:07:40 +00:00
|
|
|
|
2001-10-23 02:32:59 +00:00
|
|
|
void XA_2x2_OUT_1BLK_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
|
2001-10-22 17:07:40 +00:00
|
|
|
unsigned int imagex, XA_2x2_Color *cmap2x2)
|
|
|
|
{
|
2001-10-22 23:04:43 +00:00
|
|
|
xacodec_image_t *image=(xacodec_image_t*)image_p;
|
2001-10-22 17:07:40 +00:00
|
|
|
|
2001-10-22 23:42:19 +00:00
|
|
|
#if 0
|
|
|
|
SET_4_YUV_PIXELS(image,x,y,cmap2x2)
|
|
|
|
#else
|
|
|
|
SET_4_YUV_PIXELS(image,x,y,cmap2x2)
|
|
|
|
SET_4_YUV_PIXELS(image,x+2,y,cmap2x2)
|
|
|
|
SET_4_YUV_PIXELS(image,x,y+2,cmap2x2)
|
|
|
|
SET_4_YUV_PIXELS(image,x+2,y+2,cmap2x2)
|
|
|
|
#endif
|
2001-10-23 01:46:55 +00:00
|
|
|
return;
|
2001-10-22 17:07:40 +00:00
|
|
|
}
|
|
|
|
|
2001-10-23 02:32:59 +00:00
|
|
|
void XA_2x2_OUT_4BLKS_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
|
2001-10-22 17:07:40 +00:00
|
|
|
unsigned int imagex, XA_2x2_Color *cm0, XA_2x2_Color *cm1, XA_2x2_Color *cm2,
|
|
|
|
XA_2x2_Color *cm3)
|
|
|
|
{
|
2001-10-22 23:42:19 +00:00
|
|
|
xacodec_image_t *image=(xacodec_image_t*)image_p;
|
2001-10-22 20:48:39 +00:00
|
|
|
|
2001-10-22 23:42:19 +00:00
|
|
|
SET_4_YUV_PIXELS(image,x,y,cm0)
|
|
|
|
SET_4_YUV_PIXELS(image,x+2,y,cm1)
|
|
|
|
SET_4_YUV_PIXELS(image,x,y+2,cm2)
|
|
|
|
SET_4_YUV_PIXELS(image,x+2,y+2,cm3)
|
2001-10-23 01:46:55 +00:00
|
|
|
return;
|
2001-10-22 20:48:39 +00:00
|
|
|
}
|
|
|
|
|
2001-10-22 17:07:40 +00:00
|
|
|
void *YUV2x2_Blk_Func(unsigned int image_type, int blks, unsigned int dith_flag)
|
|
|
|
{
|
2001-10-22 23:42:19 +00:00
|
|
|
switch(blks){
|
|
|
|
case 1:
|
2001-10-23 02:32:59 +00:00
|
|
|
return (void*) XA_2x2_OUT_1BLK_Convert;
|
2001-10-22 23:42:19 +00:00
|
|
|
case 4:
|
2001-10-23 02:32:59 +00:00
|
|
|
return (void*) XA_2x2_OUT_4BLKS_Convert;
|
2001-10-22 17:07:40 +00:00
|
|
|
}
|
|
|
|
|
2001-10-22 23:42:19 +00:00
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Unimplemented: YUV2x2_Blk_Func(image_type=%d blks=%d dith=%d)\n",image_type,blks,dith_flag);
|
|
|
|
return (void*) XA_dummy;
|
2001-10-22 17:07:40 +00:00
|
|
|
}
|
|
|
|
|
2001-10-22 23:42:19 +00:00
|
|
|
// Take Four Y's and UV and put them into a 2x2 Color structure.
|
2001-10-22 20:48:39 +00:00
|
|
|
|
2001-10-23 01:46:55 +00:00
|
|
|
void XA_YUV_2x2_clr(XA_2x2_Color *cmap2x2, unsigned int Y0, unsigned int Y1,
|
|
|
|
unsigned int Y2, unsigned int Y3, unsigned int U, unsigned int V,
|
|
|
|
unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
|
2001-10-22 23:42:19 +00:00
|
|
|
{
|
2001-10-22 20:48:39 +00:00
|
|
|
|
|
|
|
// printf("XA_YUV_2x2_clr(%p [%d,%d,%d,%d][%d][%d] %d %p %p)\n",
|
|
|
|
// cmap2x2,Y0,Y1,Y2,Y3,U,V,map_flag,map,chdr);
|
|
|
|
|
|
|
|
cmap2x2->clr0_0=Y0;
|
2001-10-22 23:42:19 +00:00
|
|
|
cmap2x2->clr0_1=Y1;
|
|
|
|
cmap2x2->clr0_2=Y2;
|
|
|
|
cmap2x2->clr0_3=Y3;
|
|
|
|
cmap2x2->clr1_0=U;
|
|
|
|
cmap2x2->clr1_1=V;
|
2001-10-23 01:46:55 +00:00
|
|
|
return;
|
2001-10-22 18:52:10 +00:00
|
|
|
}
|
|
|
|
|
2001-10-22 17:07:40 +00:00
|
|
|
void *YUV2x2_Map_Func(unsigned int image_type, unsigned int dith_type)
|
|
|
|
{
|
2001-10-22 20:48:39 +00:00
|
|
|
// XA_Print("YUV2x2_Map_Func('image_type: %d', 'dith_type: %d')",
|
|
|
|
// image_type, dith_type);
|
2001-10-23 02:11:27 +00:00
|
|
|
return((void*)XA_YUV_2x2_clr);
|
2001-10-22 17:07:40 +00:00
|
|
|
}
|
|
|
|
|
2001-10-23 02:32:59 +00:00
|
|
|
/* -------------------- whole YUV frame converters ------------------------- */
|
2001-10-22 17:07:40 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned char *Ybuf;
|
|
|
|
unsigned char *Ubuf;
|
|
|
|
unsigned char *Vbuf;
|
|
|
|
unsigned char *the_buf;
|
|
|
|
unsigned int the_buf_size;
|
|
|
|
unsigned short y_w, y_h;
|
|
|
|
unsigned short uv_w, uv_h;
|
|
|
|
} YUVBufs;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned long Uskip_mask;
|
|
|
|
long *YUV_Y_tab;
|
|
|
|
long *YUV_UB_tab;
|
|
|
|
long *YUV_VR_tab;
|
|
|
|
long *YUV_UG_tab;
|
|
|
|
long *YUV_VG_tab;
|
|
|
|
} YUVTabs;
|
|
|
|
|
2001-10-23 02:32:59 +00:00
|
|
|
YUVBufs jpg_YUVBufs;
|
|
|
|
YUVTabs def_yuv_tabs;
|
|
|
|
|
|
|
|
/* -------------- YUV 4x4 1x1 1x1 [Indeo 3,4,5] ------------------ */
|
|
|
|
|
2001-10-23 02:11:27 +00:00
|
|
|
void XA_YUV1611_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
|
2001-10-22 23:42:19 +00:00
|
|
|
unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs,
|
2001-10-22 17:07:40 +00:00
|
|
|
unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
|
|
|
|
{
|
2001-10-22 23:42:19 +00:00
|
|
|
xacodec_image_t *image=(xacodec_image_t*)image_p;
|
2001-10-23 00:12:46 +00:00
|
|
|
int y;
|
|
|
|
int uvstride;
|
2001-10-22 17:07:40 +00:00
|
|
|
|
2001-10-23 00:12:46 +00:00
|
|
|
#if 0
|
2001-10-23 01:14:13 +00:00
|
|
|
printf("YUVTabs: %d %p %p %p %p %p\n",yuv_tabs->Uskip_mask,
|
|
|
|
yuv_tabs->YUV_Y_tab,
|
|
|
|
yuv_tabs->YUV_UB_tab,
|
|
|
|
yuv_tabs->YUV_VR_tab,
|
|
|
|
yuv_tabs->YUV_UG_tab,
|
|
|
|
yuv_tabs->YUV_VG_tab );
|
|
|
|
|
2001-10-23 02:11:27 +00:00
|
|
|
XA_Print("XA_YUV1611_Convert('image: %08x', 'imagex: %d', 'imagey: %d', 'i_x: %d', 'i_y: %d', 'yuv_bufs: %08x', 'yuv_tabs: %08x', 'map_flag: %d', 'map: %08x', 'chdr: %08x')",
|
2001-10-22 23:42:19 +00:00
|
|
|
image, imagex, imagey, i_x, i_y, yuv, yuv_tabs, map_flag, map, chdr);
|
|
|
|
|
2001-10-23 00:12:46 +00:00
|
|
|
printf("YUV: %p %p %p %X (%d) %dx%d %dx%d\n",
|
|
|
|
yuv->Ybuf,yuv->Ubuf,yuv->Vbuf,yuv->the_buf,yuv->the_buf_size,
|
|
|
|
yuv->y_w,yuv->y_h,yuv->uv_w,yuv->uv_h);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// copy Y plane:
|
2001-10-23 01:14:13 +00:00
|
|
|
if(yuv_tabs->YUV_Y_tab){ // dirty hack to detect iv32:
|
|
|
|
for(y=0;y<imagey*imagex;y++)
|
|
|
|
image->planes[0][y]=yuv->Ybuf[y]<<1;
|
|
|
|
} else
|
|
|
|
memcpy(image->planes[0],yuv->Ybuf,imagex*imagey);
|
2001-10-23 00:12:46 +00:00
|
|
|
|
|
|
|
// scale U,V planes by 2:
|
|
|
|
imagex>>=2;
|
|
|
|
imagey>>=2;
|
|
|
|
|
|
|
|
uvstride=(yuv->uv_w)?yuv->uv_w:imagex;
|
|
|
|
|
|
|
|
for(y=0;y<imagey;y++){
|
|
|
|
unsigned char *su=yuv->Ubuf+uvstride*y;
|
|
|
|
unsigned char *sv=yuv->Vbuf+uvstride*y;
|
|
|
|
unsigned int strideu=image->stride[1];
|
|
|
|
unsigned int stridev=image->stride[2];
|
|
|
|
unsigned char *du=image->planes[1]+2*y*strideu;
|
|
|
|
unsigned char *dv=image->planes[2]+2*y*stridev;
|
|
|
|
int x;
|
2001-10-23 01:14:13 +00:00
|
|
|
if(yuv_tabs->YUV_Y_tab){ // dirty hack to detect iv32:
|
|
|
|
for(x=0;x<imagex;x++){
|
|
|
|
du[2*x]=du[2*x+1]=du[2*x+strideu]=du[2*x+strideu+1]=su[x]*2;
|
|
|
|
dv[2*x]=dv[2*x+1]=dv[2*x+stridev]=dv[2*x+stridev+1]=sv[x]*2;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for(x=0;x<imagex;x++){
|
|
|
|
du[2*x]=du[2*x+1]=du[2*x+strideu]=du[2*x+strideu+1]=su[x];
|
|
|
|
dv[2*x]=dv[2*x+1]=dv[2*x+stridev]=dv[2*x+stridev+1]=sv[x];
|
|
|
|
}
|
2001-10-23 00:12:46 +00:00
|
|
|
}
|
|
|
|
}
|
2001-10-23 01:46:55 +00:00
|
|
|
return;
|
2001-10-22 17:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *XA_YUV1611_Func(unsigned int image_type)
|
|
|
|
{
|
2001-10-23 02:11:27 +00:00
|
|
|
// XA_Print("XA_YUV1611_Func('image_type: %d')", image_type);
|
|
|
|
return((void *)XA_YUV1611_Convert);
|
2001-10-22 17:07:40 +00:00
|
|
|
}
|
|
|
|
|
2001-10-23 02:32:59 +00:00
|
|
|
/* -------------- YUV 4x1 1x1 1x1 (4:1:1 ?) [???] ------------------ */
|
2001-10-23 00:12:46 +00:00
|
|
|
|
2001-10-23 02:11:27 +00:00
|
|
|
void XA_YUV411111_Convert(unsigned char *image, unsigned int imagex, unsigned int imagey,
|
2001-10-22 17:07:40 +00:00
|
|
|
unsigned int i_x, unsigned int i_y, YUVBufs *yuv_bufs, YUVTabs *yuv_tabs,
|
|
|
|
unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
|
|
|
|
{
|
2001-10-23 02:11:27 +00:00
|
|
|
XA_Print("XA_YUV411111_Convert('image: %d', 'imagex: %d', 'imagey: %d', 'i_x: %d', 'i_y: %d', 'yuv_bufs: %08x', 'yuv_tabs: %08x', 'map_flag: %d', 'map: %08x', 'chdr: %08x')",
|
2001-10-22 17:07:40 +00:00
|
|
|
image, imagex, imagey, i_x, i_y, yuv_bufs, yuv_tabs, map_flag, map, chdr);
|
2001-10-23 01:46:55 +00:00
|
|
|
return;
|
2001-10-22 17:07:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *XA_YUV411111_Func(unsigned int image_type)
|
|
|
|
{
|
2001-10-23 02:11:27 +00:00
|
|
|
// XA_Print("XA_YUV411111_Func('image_type: %d')", image_type);
|
|
|
|
return((void*)XA_YUV411111_Convert);
|
2001-10-22 17:07:40 +00:00
|
|
|
}
|
|
|
|
|
2001-10-23 02:32:59 +00:00
|
|
|
/* --------------- YUV 2x2 1x1 1x1 (4:2:0 aka YV12) [3ivX,H263] ------------ */
|
2001-10-22 23:42:19 +00:00
|
|
|
|
2001-10-23 02:11:27 +00:00
|
|
|
void XA_YUV221111_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
|
2001-10-23 01:46:55 +00:00
|
|
|
unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs, unsigned int map_flag,
|
|
|
|
unsigned int *map, XA_CHDR *chdr)
|
2001-10-22 21:31:42 +00:00
|
|
|
{
|
2001-10-22 22:45:06 +00:00
|
|
|
xacodec_image_t *image=(xacodec_image_t*)image_p;
|
|
|
|
|
|
|
|
#if 0
|
2001-10-23 02:11:27 +00:00
|
|
|
printf("XA_YUV221111_Convert(%p %dx%d %d;%d [%dx%d] %p %p %d %p %p)\n",
|
2001-10-22 22:45:06 +00:00
|
|
|
image,imagex,imagey,i_x,i_y, image->width,image->height,
|
|
|
|
yuv,yuv_tabs,map_flag,map,chdr);
|
2001-10-22 21:31:42 +00:00
|
|
|
|
|
|
|
printf("YUV: %p %p %p %X (%X) %Xx%X %Xx%X\n",
|
|
|
|
yuv->Ybuf,yuv->Ubuf,yuv->Vbuf,yuv->the_buf,yuv->the_buf_size,
|
|
|
|
yuv->y_w,yuv->y_h,yuv->uv_w,yuv->uv_h);
|
2001-10-22 22:45:06 +00:00
|
|
|
#endif
|
|
|
|
|
2001-10-23 01:55:49 +00:00
|
|
|
if(i_x==image->width && i_y==image->height){
|
2001-10-22 22:45:06 +00:00
|
|
|
// printf("Direct render!!!\n");
|
|
|
|
image->planes[0]=yuv->Ybuf;
|
|
|
|
if(image->out_fmt==IMGFMT_YV12){
|
|
|
|
image->planes[1]=yuv->Ubuf;
|
|
|
|
image->planes[2]=yuv->Vbuf;
|
|
|
|
} else {
|
|
|
|
image->planes[1]=yuv->Vbuf;
|
|
|
|
image->planes[2]=yuv->Ubuf;
|
|
|
|
}
|
2001-10-23 01:55:49 +00:00
|
|
|
image->stride[0]=i_x; // yuv->y_w
|
|
|
|
image->stride[1]=image->stride[2]=i_x/2; // yuv->uv_w
|
2001-10-22 22:45:06 +00:00
|
|
|
} else {
|
2001-10-23 01:55:49 +00:00
|
|
|
int y;
|
|
|
|
for(y=0;y<i_y;y++)
|
|
|
|
memcpy(image->planes[0]+y*image->stride[0],yuv->Ybuf+y*i_x,i_x);
|
|
|
|
i_x>>=1; i_y>>=1;
|
|
|
|
for(y=0;y<i_y;y++){
|
|
|
|
memcpy(image->planes[1]+y*image->stride[1],yuv->Ubuf+y*i_x,i_x);
|
|
|
|
memcpy(image->planes[2]+y*image->stride[2],yuv->Vbuf+y*i_x,i_x);
|
|
|
|
}
|
2001-10-22 22:45:06 +00:00
|
|
|
}
|
2001-10-23 01:46:55 +00:00
|
|
|
return;
|
2001-10-22 21:31:42 +00:00
|
|
|
}
|
|
|
|
|
2001-10-22 21:03:25 +00:00
|
|
|
void *XA_YUV221111_Func(unsigned int image_type)
|
|
|
|
{
|
2001-10-23 02:11:27 +00:00
|
|
|
// XA_Print("XA_YUV221111_Func('image_type: %d')", image_type);
|
|
|
|
return((void *)XA_YUV221111_Convert);
|
2001-10-22 21:03:25 +00:00
|
|
|
}
|
2001-10-22 17:07:40 +00:00
|
|
|
|
2001-10-23 02:11:27 +00:00
|
|
|
/* *** EOF XANIM *** */
|
2001-11-03 21:57:07 +00:00
|
|
|
#endif
|