aboutsummaryrefslogtreecommitdiffhomepage
path: root/libmpcodecs
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2012-08-12 15:30:21 +0200
committerGravatar wm4 <wm4@nowhere>2012-08-16 17:16:33 +0200
commitaebfbbf2bdda8e18beef90c16da97bd335f7d3b0 (patch)
treea7362bf3ef6f2d80a47b2e539a2ea4efe5e2e079 /libmpcodecs
parentc6b03ffef6250096373c4a81a489dae9fbff9087 (diff)
Remove win32/qt/xanim/real binary codecs loading
Remove the win32 loader - the win32 emulation layer, as well as the code for using DirectShow/DMO/VFW codecs. Remove loading of xanim, QuickTime, and RealMedia codecs. The win32 emulation layer is based on a very old version of wine. Apparently, wine code was copied and hacked until it was somehow able to load a limited collection of binary codecs. It poked around in the code segment of some known binary codecs to disable unsupported win32 API calls to make them work. Example from module.c: for (i=0;i<5;i++) RVA(0x19e842)[i]=0x90; // make_new_region ? for (i=0;i<28;i++) RVA(0x19e86d)[i]=0x90; // call__call_CreateCompatibleDC ? for (i=0;i<5;i++) RVA(0x19e898)[i]=0x90; // jmp_to_call_loadbitmap ? for (i=0;i<9;i++) RVA(0x19e8ac)[i]=0x90; // call__calls_OLE_shit ? for (i=0;i<106;i++) RVA(0x261b10)[i]=0x90; // disable threads Just to show how utterly insane this code is. You wouldn't want even your worst enemy to have to maintain this. In fact, it seems nobody made major changes to this code ever since it was committed. Most formats can be decoded by libavcodecs these days, and the loader couldn't be used on 64 bit platforms anyway. The same is (probably) true for the other binary codecs. General note about how support for win32 codecs could be added back: It's not possible to replace the win32 loader code by using wine as library, because modern wine can not be linked with native Linux programs for certain reasons. It would be possible to to move DirectShow video decoding into a separate process linked with wine, like the CoreAVC-for-Linux patches do. There is also the mplayer-ww fork, which uses the dshownative library to use DirectShow codecs on Windows.
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad.c19
-rw-r--r--libmpcodecs/ad_acm.c259
-rw-r--r--libmpcodecs/ad_dmo.c126
-rw-r--r--libmpcodecs/ad_dshow.c114
-rw-r--r--libmpcodecs/ad_qtaudio.c353
-rw-r--r--libmpcodecs/ad_realaud.c463
-rw-r--r--libmpcodecs/vd.c20
-rw-r--r--libmpcodecs/vd_dmo.c134
-rw-r--r--libmpcodecs/vd_dshow.c133
-rw-r--r--libmpcodecs/vd_qtvideo.c321
-rw-r--r--libmpcodecs/vd_realvid.c453
-rw-r--r--libmpcodecs/vd_vfw.c355
-rw-r--r--libmpcodecs/vd_vfwex.c4
-rw-r--r--libmpcodecs/vd_xanim.c854
14 files changed, 0 insertions, 3608 deletions
diff --git a/libmpcodecs/ad.c b/libmpcodecs/ad.c
index 2e67bd23af..d1e3c91430 100644
--- a/libmpcodecs/ad.c
+++ b/libmpcodecs/ad.c
@@ -40,15 +40,9 @@ extern const ad_functions_t mpcodecs_ad_pcm;
extern const ad_functions_t mpcodecs_ad_dvdpcm;
extern const ad_functions_t mpcodecs_ad_alaw;
extern const ad_functions_t mpcodecs_ad_imaadpcm;
-extern const ad_functions_t mpcodecs_ad_msadpcm;
-extern const ad_functions_t mpcodecs_ad_dshow;
-extern const ad_functions_t mpcodecs_ad_dmo;
-extern const ad_functions_t mpcodecs_ad_acm;
extern const ad_functions_t mpcodecs_ad_faad;
extern const ad_functions_t mpcodecs_ad_libmad;
-extern const ad_functions_t mpcodecs_ad_realaud;
extern const ad_functions_t mpcodecs_ad_libdv;
-extern const ad_functions_t mpcodecs_ad_qtaudio;
extern const ad_functions_t mpcodecs_ad_spdif;
extern const ad_functions_t mpcodecs_ad_libdca;
@@ -68,25 +62,12 @@ const ad_functions_t * const mpcodecs_ad_drivers[] =
&mpcodecs_ad_dvdpcm,
&mpcodecs_ad_alaw,
&mpcodecs_ad_imaadpcm,
- &mpcodecs_ad_msadpcm,
-#ifdef CONFIG_WIN32DLL
- &mpcodecs_ad_dshow,
- &mpcodecs_ad_dmo,
- &mpcodecs_ad_acm,
- &mpcodecs_ad_twin,
-#endif
-#ifdef CONFIG_QTX_CODECS
- &mpcodecs_ad_qtaudio,
-#endif
#ifdef CONFIG_FAAD
&mpcodecs_ad_faad,
#endif
#ifdef CONFIG_LIBMAD
&mpcodecs_ad_libmad,
#endif
-#ifdef CONFIG_REALCODECS
- &mpcodecs_ad_realaud,
-#endif
#ifdef CONFIG_LIBDV095
&mpcodecs_ad_libdv,
#endif
diff --git a/libmpcodecs/ad_acm.c b/libmpcodecs/ad_acm.c
deleted file mode 100644
index 1b1184a06a..0000000000
--- a/libmpcodecs/ad_acm.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "config.h"
-#include "mp_msg.h"
-#include "libmpdemux/aviprint.h"
-#include "loader/wineacm.h"
-
-#include "ad_internal.h"
-#include "osdep/timer.h"
-
-static const ad_info_t info =
-{
- "Win32/ACM decoders",
- "acm",
- "A'rpi",
- "A'rpi & Alex",
- ""
-};
-
-LIBAD_EXTERN(acm)
-
-typedef struct {
- WAVEFORMATEX *o_wf;
- HACMSTREAM handle;
-} acm_context_t;
-
-static int init(sh_audio_t *sh_audio)
-{
- int ret=decode_audio(sh_audio,sh_audio->a_buffer,4096,sh_audio->a_buffer_size);
- if(ret<0){
- mp_msg(MSGT_DECAUDIO,MSGL_INFO,"ACM decoding error: %d\n",ret);
- return 0;
- }
- sh_audio->a_buffer_len=ret;
- return 1;
-}
-
-static int preinit(sh_audio_t *sh_audio)
-{
- HRESULT ret;
- WAVEFORMATEX *in_fmt = sh_audio->wf;
- DWORD srcsize = 0;
- acm_context_t *priv;
-
- priv = malloc(sizeof(acm_context_t));
- if (!priv)
- return 0;
- sh_audio->context = priv;
-
- mp_msg(MSGT_WIN32, MSGL_V, "======= Win32 (ACM) AUDIO Codec init =======\n");
-
-// priv->handle = NULL;
-
- priv->o_wf = malloc(sizeof(*priv->o_wf));
- if (!priv->o_wf)
- {
- mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM audio codec (missing DLL file?).\n");
- return 0;
- }
-
- priv->o_wf->nChannels = in_fmt->nChannels;
- priv->o_wf->nSamplesPerSec = in_fmt->nSamplesPerSec;
- priv->o_wf->nAvgBytesPerSec = 2*in_fmt->nSamplesPerSec*in_fmt->nChannels;
- priv->o_wf->wFormatTag = WAVE_FORMAT_PCM;
- priv->o_wf->nBlockAlign = 2*in_fmt->nChannels;
- priv->o_wf->wBitsPerSample = 16;
-// priv->o_wf->wBitsPerSample = inf_fmt->wBitsPerSample;
- priv->o_wf->cbSize = 0;
-
- if ( mp_msg_test(MSGT_DECAUDIO,MSGL_V) )
- {
- mp_msg(MSGT_DECAUDIO, MSGL_V, "Input format:\n");
- print_wave_header(in_fmt, MSGL_V);
- mp_msg(MSGT_DECAUDIO, MSGL_V, "Output format:\n");
- print_wave_header(priv->o_wf, MSGL_V);
- }
-
- MSACM_RegisterDriver((const char *)sh_audio->codec->dll, in_fmt->wFormatTag, 0);
- ret = acmStreamOpen(&priv->handle, (HACMDRIVER)NULL, in_fmt,
- priv->o_wf, NULL, 0, 0, 0);
- if (ret)
- {
- if (ret == ACMERR_NOTPOSSIBLE)
- mp_msg(MSGT_WIN32, MSGL_ERR, "ACM_Decoder: Unappropriate audio format\n");
- else
- mp_msg(MSGT_WIN32, MSGL_ERR, "ACM_Decoder: acmStreamOpen error: %d\n",
- (int)ret);
- mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"Could not load/initialize Win32/ACM audio codec (missing DLL file?).\n");
- return 0;
- }
- mp_msg(MSGT_WIN32, MSGL_V, "Audio codec opened OK! ;-)\n");
-
- acmStreamSize(priv->handle, in_fmt->nBlockAlign, &srcsize, ACM_STREAMSIZEF_SOURCE);
- //if ( mp_msg_test(MSGT_DECAUDIO,MSGL_V) ) printf("Audio ACM output buffer min. size: %ld (reported by codec)\n", srcsize);
- srcsize *= 2;
- //if (srcsize < MAX_OUTBURST) srcsize = MAX_OUTBURST;
- if (!srcsize)
- {
- mp_msg(MSGT_WIN32, MSGL_WARN, "Warning! ACM codec reports srcsize=0\n");
- srcsize = 16384;
- }
- // limit srcsize to 4-16kb
- //while(srcsize && srcsize<4096) srcsize*=2;
- //while(srcsize>16384) srcsize/=2;
- sh_audio->audio_out_minsize=srcsize; // audio output min. size
- mp_msg(MSGT_WIN32,MSGL_V,"Audio ACM output buffer min. size: %ld\n",srcsize);
-
- acmStreamSize(priv->handle, srcsize, &srcsize, ACM_STREAMSIZEF_DESTINATION);
-// if(srcsize<in_fmt->nBlockAlign) srcsize=in_fmt->nBlockAlign;
-
- if (!srcsize)
- {
- mp_msg(MSGT_WIN32, MSGL_WARN, "Warning! ACM codec reports srcsize=0\n");
- srcsize = 2*in_fmt->nBlockAlign;
- }
-
- mp_msg(MSGT_WIN32,MSGL_V,"Audio ACM input buffer min. size: %ld\n",srcsize);
-
- sh_audio->audio_in_minsize=2*srcsize; // audio input min. size
-
- sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
- sh_audio->channels=priv->o_wf->nChannels;
- sh_audio->samplerate=priv->o_wf->nSamplesPerSec;
- sh_audio->samplesize=2;
-
- mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/ACM audio codec init OK!\n");
- return 1;
-}
-
-static void uninit(sh_audio_t *sh)
-{
- HRESULT ret;
- acm_context_t *priv = sh->context;
-
-retry:
- ret = acmStreamClose(priv->handle, 0);
-
- if (ret)
- switch(ret)
- {
- case ACMERR_BUSY:
- case ACMERR_CANCELED:
- mp_msg(MSGT_WIN32, MSGL_DBG2, "ACM_Decoder: stream busy, waiting..\n");
- usec_sleep(100000000);
- goto retry;
- case ACMERR_UNPREPARED:
- case ACMERR_NOTPOSSIBLE:
- return;
- default:
- mp_msg(MSGT_WIN32, MSGL_WARN, "ACM_Decoder: unknown error occurred: %ld\n", ret);
- return;
- }
-
- MSACM_UnregisterAllDrivers();
-
- free(priv->o_wf);
- free(priv);
-}
-
-static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...)
-{
- int skip;
- switch(cmd)
- {
- case ADCTRL_SKIP_FRAME:
- skip=sh_audio->wf->nBlockAlign;
- if(skip<16){
- skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7);
- if(skip<16) skip=16;
- }
- demux_read_data(sh_audio->ds,NULL,skip);
- return CONTROL_TRUE;
- }
- return CONTROL_UNKNOWN;
-}
-
-static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
-{
- ACMSTREAMHEADER ash;
- HRESULT hr;
- DWORD srcsize=0;
- DWORD len=minlen;
- acm_context_t *priv = sh_audio->context;
-
- acmStreamSize(priv->handle, len, &srcsize, ACM_STREAMSIZEF_DESTINATION);
- mp_msg(MSGT_WIN32,MSGL_DBG3,"acm says: srcsize=%ld (buffsize=%d) out_size=%ld\n",srcsize,sh_audio->a_in_buffer_size,len);
-
- if(srcsize<sh_audio->wf->nBlockAlign){
- srcsize=sh_audio->wf->nBlockAlign;
- acmStreamSize(priv->handle, srcsize, &len, ACM_STREAMSIZEF_SOURCE);
- if(len>maxlen) len=maxlen;
- }
-
-// if(srcsize==0) srcsize=((WAVEFORMATEX *)&sh_audio->o_wf_ext)->nBlockAlign;
- if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
- if(sh_audio->a_in_buffer_len<srcsize){
- sh_audio->a_in_buffer_len+=
- demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
- srcsize-sh_audio->a_in_buffer_len);
- }
- mp_msg(MSGT_WIN32,MSGL_DBG3,"acm convert %d -> %ld bytes\n",sh_audio->a_in_buffer_len,len);
- memset(&ash, 0, sizeof(ash));
- ash.cbStruct=sizeof(ash);
- ash.fdwStatus=0;
- ash.dwUser=0;
- ash.pbSrc=sh_audio->a_in_buffer;
- ash.cbSrcLength=sh_audio->a_in_buffer_len;
- ash.pbDst=buf;
- ash.cbDstLength=len;
- hr=acmStreamPrepareHeader(priv->handle,&ash,0);
- if(hr){
- mp_msg(MSGT_WIN32,MSGL_V,"ACM_Decoder: acmStreamPrepareHeader error %d\n",(int)hr);
- return -1;
- }
- hr=acmStreamConvert(priv->handle,&ash,0);
- if(hr){
- mp_msg(MSGT_WIN32,MSGL_DBG2,"ACM_Decoder: acmStreamConvert error %d\n",(int)hr);
- switch(hr)
- {
- case ACMERR_NOTPOSSIBLE:
- case ACMERR_UNPREPARED:
- mp_msg(MSGT_WIN32, MSGL_DBG2, "ACM_Decoder: acmStreamConvert error: probarly not initialized!\n");
- }
-// return -1;
- }
- mp_msg(MSGT_WIN32,MSGL_DBG2,"acm converted %ld -> %ld\n",ash.cbSrcLengthUsed,ash.cbDstLengthUsed);
- if(ash.cbSrcLengthUsed>=sh_audio->a_in_buffer_len){
- sh_audio->a_in_buffer_len=0;
- } else {
- sh_audio->a_in_buffer_len-=ash.cbSrcLengthUsed;
- memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[ash.cbSrcLengthUsed],sh_audio->a_in_buffer_len);
- }
- len=ash.cbDstLengthUsed;
- hr=acmStreamUnprepareHeader(priv->handle,&ash,0);
- if(hr){
- mp_msg(MSGT_WIN32,MSGL_V,"ACM_Decoder: acmStreamUnprepareHeader error %d\n",(int)hr);
- }
- return len;
-}
diff --git a/libmpcodecs/ad_dmo.c b/libmpcodecs/ad_dmo.c
deleted file mode 100644
index 714651a7e4..0000000000
--- a/libmpcodecs/ad_dmo.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "config.h"
-#include "options.h"
-#include "mp_msg.h"
-
-#include "ad_internal.h"
-#include "libaf/reorder_ch.h"
-
-static const ad_info_t info =
-{
- "Win32/DMO decoders",
- "dmo",
- "A'rpi",
- "avifile.sf.net",
- ""
-};
-
-LIBAD_EXTERN(dmo)
-
-#include "loader/dmo/DMO_AudioDecoder.h"
-
-static int init(sh_audio_t *sh)
-{
- return 1;
-}
-
-static int preinit(sh_audio_t *sh_audio)
-{
- struct MPOpts *opts = sh_audio->opts;
- DMO_AudioDecoder* ds_adec;
- int chans=(opts->audio_output_channels==sh_audio->wf->nChannels) ?
- opts->audio_output_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1);
- if(!(ds_adec=DMO_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf,chans)))
- {
- mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh_audio->codec->dll);
- return 0;
- }
- sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
- sh_audio->channels=chans;
- sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
- sh_audio->samplesize=2;
- sh_audio->audio_in_minsize=4*sh_audio->wf->nBlockAlign;
- if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192;
- sh_audio->audio_out_minsize=4*16384;
- sh_audio->context = ds_adec;
- mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO audio codec init OK!\n");
- return 1;
-}
-
-static void uninit(sh_audio_t *sh)
-{
- DMO_AudioDecoder* ds_adec = sh->context;
- DMO_AudioDecoder_Destroy(ds_adec);
-}
-
-static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...)
-{
- int skip;
- switch(cmd)
- {
- case ADCTRL_SKIP_FRAME:
- skip=sh_audio->wf->nBlockAlign;
- if(skip<16){
- skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7);
- if(skip<16) skip=16;
- }
- demux_read_data(sh_audio->ds,NULL,skip);
- return CONTROL_TRUE;
- }
- return CONTROL_UNKNOWN;
-}
-
-static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
-{
- DMO_AudioDecoder* ds_adec = sh_audio->context;
-// int len=-1;
- int size_in=0;
- int size_out=0;
- int srcsize=DMO_AudioDecoder_GetSrcSize(ds_adec, maxlen);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DMO says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen);
- if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
- if(sh_audio->a_in_buffer_len<srcsize){
- sh_audio->a_in_buffer_len+=
- demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
- srcsize-sh_audio->a_in_buffer_len);
- }
- DMO_AudioDecoder_Convert(ds_adec, sh_audio->a_in_buffer,sh_audio->a_in_buffer_len,
- buf,maxlen, &size_in,&size_out);
- mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"DMO: audio %d -> %d converted (in_buf_len=%d of %d) %d\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,ds_tell_pts(sh_audio->ds));
- if(size_in>=sh_audio->a_in_buffer_len){
- sh_audio->a_in_buffer_len=0;
- } else {
- sh_audio->a_in_buffer_len-=size_in;
- memmove(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len);
- }
- if (size_out > 0 && sh_audio->channels >= 5) {
- reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT,
- AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
- sh_audio->channels,
- size_out / sh_audio->samplesize,
- sh_audio->samplesize);
- }
-// len=size_out;
- return size_out;
-}
diff --git a/libmpcodecs/ad_dshow.c b/libmpcodecs/ad_dshow.c
deleted file mode 100644
index 8fb94660a4..0000000000
--- a/libmpcodecs/ad_dshow.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "config.h"
-#include "mp_msg.h"
-
-#include "ad_internal.h"
-
-static const ad_info_t info =
-{
- "Win32/DirectShow decoders",
- "dshow",
- "Nick Kurshev",
- "avifile.sf.net",
- ""
-};
-
-LIBAD_EXTERN(dshow)
-
-#include "loader/dshow/DS_AudioDecoder.h"
-
-static int init(sh_audio_t *sh)
-{
- return 1;
-}
-
-static int preinit(sh_audio_t *sh_audio)
-{
- DS_AudioDecoder* ds_adec;
- if(!(ds_adec=DS_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf)))
- {
- mp_tmsg(MSGT_DECAUDIO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh_audio->codec->dll);
- return 0;
- }
- sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec;
- sh_audio->channels=sh_audio->wf->nChannels;
- sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
- sh_audio->samplesize=2;
- sh_audio->audio_in_minsize=2*sh_audio->wf->nBlockAlign;
- if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192;
- sh_audio->audio_out_minsize=16384;
- sh_audio->context = ds_adec;
- mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow audio codec init OK!\n");
- return 1;
-}
-
-static void uninit(sh_audio_t *sh)
-{
- DS_AudioDecoder* ds_adec = sh->context;
- DS_AudioDecoder_Destroy(ds_adec);
-}
-
-static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...)
-{
- int skip;
- switch(cmd)
- {
- case ADCTRL_SKIP_FRAME:
- skip=sh_audio->wf->nBlockAlign;
- if(skip<16){
- skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7);
- if(skip<16) skip=16;
- }
- demux_read_data(sh_audio->ds,NULL,skip);
- return CONTROL_TRUE;
- }
- return CONTROL_UNKNOWN;
-}
-
-static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
-{
- DS_AudioDecoder* ds_adec = sh_audio->context;
-// int len=-1;
- int size_in=0;
- int size_out=0;
- int srcsize=DS_AudioDecoder_GetSrcSize(ds_adec, maxlen);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DShow says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen);
- if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!!
- if(sh_audio->a_in_buffer_len<srcsize){
- sh_audio->a_in_buffer_len+=
- demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len],
- srcsize-sh_audio->a_in_buffer_len);
- }
- DS_AudioDecoder_Convert(ds_adec, sh_audio->a_in_buffer,sh_audio->a_in_buffer_len,
- buf,maxlen, &size_in,&size_out);
- mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"DShow: audio %d -> %d converted (in_buf_len=%d of %d) %d\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,ds_tell_pts(sh_audio->ds));
- if(size_in>=sh_audio->a_in_buffer_len){
- sh_audio->a_in_buffer_len=0;
- } else {
- sh_audio->a_in_buffer_len-=size_in;
- memcpy(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len);
- }
-// len=size_out;
- return size_out;
-}
diff --git a/libmpcodecs/ad_qtaudio.c b/libmpcodecs/ad_qtaudio.c
deleted file mode 100644
index 1edd87cd17..0000000000
--- a/libmpcodecs/ad_qtaudio.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <inttypes.h>
-
-#include "config.h"
-#include "mp_msg.h"
-#include "mpbswap.h"
-#include "ad_internal.h"
-
-#ifdef CONFIG_QUICKTIME
-#include <QuickTime/QuickTimeComponents.h>
-#else
-#include "loader/ldt_keeper.h"
-#include "loader/wine/winbase.h"
-#include "loader/wine/windef.h"
-#endif
-
-static const ad_info_t info = {
- "QuickTime Audio Decoder",
- "qtaudio",
- "A'rpi",
- "Sascha Sommer",
- "uses win32 quicktime DLLs"
-};
-
-LIBAD_EXTERN(qtaudio)
-
-#ifndef CONFIG_QUICKTIME
-typedef struct OpaqueSoundConverter* SoundConverter;
-typedef unsigned long OSType;
-typedef unsigned long UnsignedFixed;
-typedef uint8_t Byte;
-typedef struct SoundComponentData {
- long flags;
- OSType format;
- short numChannels;
- short sampleSize;
- UnsignedFixed sampleRate;
- long sampleCount;
- Byte * buffer;
- long reserved;
-}SoundComponentData;
-
-typedef int (__cdecl* LPFUNC1)(long flag);
-typedef int (__cdecl* LPFUNC2)(const SoundComponentData *, const SoundComponentData *,SoundConverter *);
-typedef int (__cdecl* LPFUNC3)(SoundConverter sc);
-typedef int (__cdecl* LPFUNC4)(void);
-typedef int (__cdecl* LPFUNC5)(SoundConverter sc, OSType selector,void * infoPtr);
-typedef int (__cdecl* LPFUNC6)(SoundConverter sc,
- unsigned long inputBytesTarget,
- unsigned long *inputFrames,
- unsigned long *inputBytes,
- unsigned long *outputBytes );
-typedef int (__cdecl* LPFUNC7)(SoundConverter sc,
- const void *inputPtr,
- unsigned long inputFrames,
- void *outputPtr,
- unsigned long *outputFrames,
- unsigned long *outputBytes );
-typedef int (__cdecl* LPFUNC8)(SoundConverter sc,
- void *outputPtr,
- unsigned long *outputFrames,
- unsigned long *outputBytes);
-typedef int (__cdecl* LPFUNC9)(SoundConverter sc) ;
-
-static HINSTANCE qtime_qts; // handle to the preloaded quicktime.qts
-static HINSTANCE qtml_dll;
-static LPFUNC1 InitializeQTML;
-static LPFUNC2 SoundConverterOpen;
-static LPFUNC3 SoundConverterClose;
-static LPFUNC4 TerminateQTML;
-static LPFUNC5 SoundConverterSetInfo;
-static LPFUNC6 SoundConverterGetBufferSizes;
-static LPFUNC7 SoundConverterConvertBuffer;
-static LPFUNC8 SoundConverterEndConversion;
-static LPFUNC9 SoundConverterBeginConversion;
-
-#define siDecompressionParams 2002876005 // siDecompressionParams = FOUR_CHAR_CODE('wave')
-
-static int loader_init(void)
-{
-
-#ifdef WIN32_LOADER
- Setup_LDT_Keeper();
-#endif
- //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll
- qtime_qts = LoadLibraryA("QuickTime.qts");
- if( qtime_qts == (HMODULE)NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed loading QuickTime.qts\n" );
- return 1;
- }
- qtml_dll = LoadLibraryA("qtmlClient.dll");
- if( qtml_dll == (HMODULE)NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed loading qtmlClient.dll\n" );
- return 1;
- }
- InitializeQTML = (LPFUNC1)GetProcAddress(qtml_dll,"InitializeQTML");
- if ( InitializeQTML == NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed geting proc address InitializeQTML\n");
- return 1;
- }
- SoundConverterOpen = (LPFUNC2)GetProcAddress(qtml_dll,"SoundConverterOpen");
- if ( SoundConverterOpen == NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterOpen\n");
- return 1;
- }
- SoundConverterClose = (LPFUNC3)GetProcAddress(qtml_dll,"SoundConverterClose");
- if ( SoundConverterClose == NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterClose\n");
- return 1;
- }
- TerminateQTML = (LPFUNC4)GetProcAddress(qtml_dll,"TerminateQTML");
- if ( TerminateQTML == NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address TerminateQTML\n");
- return 1;
- }
- SoundConverterSetInfo = (LPFUNC5)GetProcAddress(qtml_dll,"SoundConverterSetInfo");
- if ( SoundConverterSetInfo == NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterSetInfo\n");
- return 1;
- }
- SoundConverterGetBufferSizes = (LPFUNC6)GetProcAddress(qtml_dll,"SoundConverterGetBufferSizes");
- if ( SoundConverterGetBufferSizes == NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterGetBufferSizes\n");
- return 1;
- }
- SoundConverterConvertBuffer = (LPFUNC7)GetProcAddress(qtml_dll,"SoundConverterConvertBuffer");
- if ( SoundConverterConvertBuffer == NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterConvertBuffer1\n");
- return 1;
- }
- SoundConverterEndConversion = (LPFUNC8)GetProcAddress(qtml_dll,"SoundConverterEndConversion");
- if ( SoundConverterEndConversion == NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterEndConversion\n");
- return 1;
- }
- SoundConverterBeginConversion = (LPFUNC9)GetProcAddress(qtml_dll,"SoundConverterBeginConversion");
- if ( SoundConverterBeginConversion == NULL )
- {
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"failed getting proc address SoundConverterBeginConversion\n");
- return 1;
- }
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"loader_init DONE???\n");
- return 0;
-}
-#endif /* #ifndef CONFIG_QUICKTIME */
-
-static SoundConverter myConverter = NULL;
-static SoundComponentData InputFormatInfo,OutputFormatInfo;
-
-static int InFrameSize;
-static int OutFrameSize;
-
-static int preinit(sh_audio_t *sh){
- int error;
- unsigned long FramesToGet=0; //how many frames the demuxer has to get
- unsigned long InputBufferSize=0; //size of the input buffer
- unsigned long OutputBufferSize=0; //size of the output buffer
- unsigned long WantedBufferSize=0; //the size you want your buffers to be
- void* codecdata = sh->codecdata;
-
- if (!sh->codecdata_len && sh->wf && sh->wf->cbSize){
- codecdata = sh->wf + 1;
- }
-
-#ifdef CONFIG_QUICKTIME
- EnterMovies();
-#else
- if(loader_init()) return 0; // failed to load DLL
-
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"loader_init DONE!\n");
-
- error = InitializeQTML(6+16);
- if(error){
- mp_msg(MSGT_DECAUDIO,MSGL_ERR,"InitializeQTML:%i\n",error);
- return 0;
- }
-#endif
-
- OutputFormatInfo.flags = InputFormatInfo.flags = 0;
- OutputFormatInfo.sampleCount = InputFormatInfo.sampleCount = 0;
- OutputFormatInfo.buffer = InputFormatInfo.buffer = NULL;
- OutputFormatInfo.reserved = InputFormatInfo.reserved = 0;
- OutputFormatInfo.numChannels = InputFormatInfo.numChannels = sh->wf->nChannels;
- InputFormatInfo.sampleSize = sh->wf->wBitsPerSample;
- OutputFormatInfo.sampleSize = 16;
- OutputFormatInfo.sampleRate = InputFormatInfo.sampleRate = sh->wf->nSamplesPerSec;
- InputFormatInfo.format = bswap_32(sh->format); //1363430706;///*1768775988;//*/1902406962;//qdm2//1768775988;//FOUR_CHAR_CODE('ima4');
- OutputFormatInfo.format = 1313820229;// FOUR_CHAR_CODE('NONE');
-
- error = SoundConverterOpen(&InputFormatInfo, &OutputFormatInfo, &myConverter);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterOpen:%i\n",error);
- if(error) return 0;
-
- if(codecdata){
- error = SoundConverterSetInfo(myConverter,siDecompressionParams,codecdata);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterSetInfo:%i\n",error);
-// if(error) return 0;
- }
-
- WantedBufferSize=OutputFormatInfo.numChannels*OutputFormatInfo.sampleRate*2;
- error = SoundConverterGetBufferSizes(myConverter,
- WantedBufferSize,&FramesToGet,&InputBufferSize,&OutputBufferSize);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterGetBufferSizes:%i\n",error);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"WantedBufferSize = %li\n",WantedBufferSize);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"InputBufferSize = %li\n",InputBufferSize);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"OutputBufferSize = %li\n",OutputBufferSize);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FramesToGet = %li\n",FramesToGet);
-
- InFrameSize=(InputBufferSize+FramesToGet-1)/FramesToGet;
- OutFrameSize=OutputBufferSize/FramesToGet;
-
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"FrameSize: %i -> %i\n",InFrameSize,OutFrameSize);
-
- error = SoundConverterBeginConversion(myConverter);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterBeginConversion:%i\n",error);
- if(error) return 0;
-
- sh->audio_out_minsize=OutputBufferSize;
- sh->audio_in_minsize=InputBufferSize;
-
- sh->channels=sh->wf->nChannels;
- sh->samplerate=sh->wf->nSamplesPerSec;
- sh->samplesize=2; //(sh->wf->wBitsPerSample+7)/8;
-
- sh->i_bps=sh->wf->nAvgBytesPerSec;
-//InputBufferSize*WantedBufferSize/OutputBufferSize;
-
- if(sh->format==0x3343414D){
- // MACE 3:1
- sh->ds->ss_div = 2*3; // 1 samples/packet
- sh->ds->ss_mul = sh->channels*2*1; // 1 bytes/packet
- } else
- if(sh->format==0x3643414D){
- // MACE 6:1
- sh->ds->ss_div = 2*6; // 1 samples/packet
- sh->ds->ss_mul = sh->channels*2*1; // 1 bytes/packet
- }
-
- return 1; // return values: 1=OK 0=ERROR
-}
-
-static int init(sh_audio_t *sh_audio){
-
- return 1; // return values: 1=OK 0=ERROR
-}
-
-static void uninit(sh_audio_t *sh){
- int error;
- unsigned long ConvertedFrames=0;
- unsigned long ConvertedBytes=0;
-
-#if defined(WIN32_LOADER) && !defined(CONFIG_QUICKTIME)
- Setup_FS_Segment();
-#endif
-
- error=SoundConverterEndConversion(myConverter,NULL,&ConvertedFrames,&ConvertedBytes);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterEndConversion:%i\n",error);
- error = SoundConverterClose(myConverter);
- mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"SoundConverterClose:%i\n",error);
-// error = TerminateQTML();
-// printf("TerminateQTML:%i\n",error);
-// FreeLibrary( qtml_dll );
-// qtml_dll = NULL;
-// FreeLibrary( qtime_qts );
-// qtime_qts = NULL;
-// printf("qt dll loader uninit done\n");
-#ifdef CONFIG_QUICKTIME
- ExitMovies();
-#endif
-}
-
-static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){
- unsigned long FramesToGet=0; //how many frames the demuxer has to get
- unsigned long InputBufferSize=0; //size of the input buffer
- unsigned long ConvertedFrames=0;
- unsigned long ConvertedBytes=0;
-
-#if defined(WIN32_LOADER) && !defined(CONFIG_QUICKTIME)
- Setup_FS_Segment();
-#endif
-
- FramesToGet=minlen/OutFrameSize;
- if(FramesToGet*OutFrameSize<minlen &&
- (FramesToGet+1)*OutFrameSize<=maxlen) ++FramesToGet;
- if(FramesToGet*InFrameSize>sh->a_in_buffer_size)
- FramesToGet=sh->a_in_buffer_size/InFrameSize;
-
- InputBufferSize=FramesToGet*InFrameSize;
-
-// printf("FramesToGet = %li (%li -> %li bytes)\n",FramesToGet,
-// InputBufferSize, FramesToGet*OutFrameSize);
-
- if(InputBufferSize>sh->a_in_buffer_len){
- int x=demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len],
- InputBufferSize-sh->a_in_buffer_len);
- if(x>0) sh->a_in_buffer_len+=x;
- if(InputBufferSize>sh->a_in_buffer_len)
- FramesToGet=sh->a_in_buffer_len/InFrameSize; // not enough data!
- }
-
-// printf("\nSoundConverterConvertBuffer(myConv=%p,inbuf=%p,frames=%d,outbuf=%p,&convframes=%p,&convbytes=%p)\n",
-// myConverter,sh->a_in_buffer,FramesToGet,buf,&ConvertedFrames,&ConvertedBytes);
- SoundConverterConvertBuffer(myConverter,sh->a_in_buffer,
- FramesToGet,buf,&ConvertedFrames,&ConvertedBytes);
-// printf("SoundConverterConvertBuffer:%i\n",error);
-// printf("ConvertedFrames = %li\n",ConvertedFrames);
-// printf("ConvertedBytes = %li\n",ConvertedBytes);
-
-// InputBufferSize=(ConvertedBytes/OutFrameSize)*InFrameSize; // FIXME!!
- InputBufferSize=FramesToGet*InFrameSize;
- sh->a_in_buffer_len-=InputBufferSize;
- if(sh->a_in_buffer_len<0) sh->a_in_buffer_len=0; // should not happen...
- else if(sh->a_in_buffer_len>0){
- memcpy(sh->a_in_buffer,&sh->a_in_buffer[InputBufferSize],sh->a_in_buffer_len);
- }
-
- return ConvertedBytes;
-}
-
-static int control(sh_audio_t *sh,int cmd,void* arg, ...){
- // various optional functions you MAY implement:
- return CONTROL_UNKNOWN;
-}
diff --git a/libmpcodecs/ad_realaud.c b/libmpcodecs/ad_realaud.c
deleted file mode 100644
index 3f221c61ef..0000000000
--- a/libmpcodecs/ad_realaud.c
+++ /dev/null
@@ -1,463 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "config.h"
-
-//#include <stddef.h>
-#ifdef HAVE_LIBDL
-#include <dlfcn.h>
-#endif
-#include "path.h"
-#include "libavutil/attributes.h"
-#include "ad_internal.h"
-#include "loader/wine/windef.h"
-
-static const ad_info_t info = {
- "RealAudio decoder",
- "realaud",
- "Alex Beregszaszi",
- "Florian Schneider, Arpad Gereoffy, Alex Beregszaszi, Donnie Smith",
- "binary real audio codecs"
-};
-
-LIBAD_EXTERN(realaud)
-
-void *__builtin_new(unsigned long size);
-void __builtin_delete(void *ize);
-
-void *__builtin_new(unsigned long size) {
- return malloc(size);
-}
-
-// required for cook's uninit:
-void __builtin_delete(void* ize) {
- free(ize);
-}
-
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-void *__ctype_b=NULL;
-#endif
-
-static unsigned long (*raCloseCodec)(void*);
-static unsigned long (*raDecode)(void*, char*,unsigned long,char*,unsigned int*,long);
-static unsigned long (*raFreeDecoder)(void*);
-//static unsigned long (*raGetNumberOfFlavors2)(void);
-static unsigned long (*raInitDecoder)(void*, void*);
-static unsigned long (*raOpenCodec)(void*);
-static unsigned long (*raOpenCodec2)(void*, void*);
-static unsigned long (*raSetFlavor)(void*,unsigned long);
-static void (*raSetDLLAccessPath)(char*);
-static void (*raSetPwd)(char*,char*);
-#ifdef CONFIG_WIN32DLL
-static unsigned long WINAPI (*wraCloseCodec)(void*);
-static unsigned long WINAPI (*wraDecode)(void*, char*,unsigned long,char*,unsigned int*,long);
-static unsigned long WINAPI (*wraFreeDecoder)(void*);
-static unsigned long WINAPI (*wraInitDecoder)(void*, void*);
-static unsigned long WINAPI (*wraOpenCodec)(void*);
-static unsigned long WINAPI (*wraOpenCodec2)(void*, void*);
-static unsigned long WINAPI (*wraSetFlavor)(void*,unsigned long);
-static void WINAPI (*wraSetDLLAccessPath)(char*);
-static void WINAPI (*wraSetPwd)(char*,char*);
-
-static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */
-#endif
-
-static void *rv_handle = NULL;
-
-#if 0
-typedef struct {
- int samplerate;
- short bits;
- short channels;
- int unk1;
- int unk2;
- int packetsize;
- int unk3;
- void* unk4;
-} ra_init_t ;
-#else
-
-/*
- Probably the linux .so-s were compiled with old GCC without setting
- packing, so it adds 2 bytes padding after the quality field.
- In windows it seems that there's no padding in it.
-
- -- alex
-*/
-
-/* linux dlls doesn't need packing */
-typedef struct /*__attribute__((__packed__))*/ {
- int samplerate;
- short bits;
- short channels;
- short quality;
- /* 2bytes padding here, by gcc */
- int bits_per_frame;
- int packetsize;
- int extradata_len;
- void* extradata;
-} ra_init_t;
-
-/* windows dlls need packed structs (no padding) */
-typedef struct __attribute__((__packed__)) {
- int samplerate;
- short bits;
- short channels;
- short quality;
- int bits_per_frame;
- int packetsize;
- int extradata_len;
- void* extradata;
-} wra_init_t;
-#endif
-
-#ifdef HAVE_LIBDL
-static int load_syms_linux(char *path)
-{
- void *handle;
-
- mp_msg(MSGT_DECVIDEO, MSGL_V, "opening shared obj '%s'\n", path);
- handle = dlopen(path, RTLD_LAZY);
- if (!handle)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error: %s\n", dlerror());
- return 0;
- }
-
- raCloseCodec = dlsym(handle, "RACloseCodec");
- raDecode = dlsym(handle, "RADecode");
- raFreeDecoder = dlsym(handle, "RAFreeDecoder");
- raOpenCodec = dlsym(handle, "RAOpenCodec");
- raOpenCodec2 = dlsym(handle, "RAOpenCodec2");
- raInitDecoder = dlsym(handle, "RAInitDecoder");
- raSetFlavor = dlsym(handle, "RASetFlavor");
- raSetDLLAccessPath = dlsym(handle, "SetDLLAccessPath");
- raSetPwd = dlsym(handle, "RASetPwd"); // optional, used by SIPR
-
- if (raCloseCodec && raDecode && raFreeDecoder &&
- (raOpenCodec||raOpenCodec2) && raSetFlavor &&
- /*raSetDLLAccessPath &&*/ raInitDecoder)
- {
- rv_handle = handle;
- return 1;
- }
-
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Cannot resolve symbols - incompatible dll: %s\n",path);
- dlclose(handle);
- return 0;
-}
-#endif
-
-#ifdef CONFIG_WIN32DLL
-
-#ifdef WIN32_LOADER
-#include "loader/ldt_keeper.h"
-#endif
-void* WINAPI LoadLibraryA(char* name);
-void* WINAPI GetProcAddress(void* handle,char *func);
-int WINAPI FreeLibrary(void *handle);
-
-static int load_syms_windows(char *path)
-{
- void *handle;
-
- mp_msg(MSGT_DECVIDEO, MSGL_V, "opening win32 dll '%s'\n", path);
-#ifdef WIN32_LOADER
- Setup_LDT_Keeper();
-#endif
- handle = LoadLibraryA(path);
- if (!handle)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Error loading dll\n");
- return 0;
- }
-
- wraCloseCodec = GetProcAddress(handle, "RACloseCodec");
- wraDecode = GetProcAddress(handle, "RADecode");
- wraFreeDecoder = GetProcAddress(handle, "RAFreeDecoder");
- wraOpenCodec = GetProcAddress(handle, "RAOpenCodec");
- wraOpenCodec2 = GetProcAddress(handle, "RAOpenCodec2");
- wraInitDecoder = GetProcAddress(handle, "RAInitDecoder");
- wraSetFlavor = GetProcAddress(handle, "RASetFlavor");
- wraSetDLLAccessPath = GetProcAddress(handle, "SetDLLAccessPath");
- wraSetPwd = GetProcAddress(handle, "RASetPwd"); // optional, used by SIPR
-
- if (wraCloseCodec && wraDecode && wraFreeDecoder &&
- (wraOpenCodec || wraOpenCodec2) && wraSetFlavor &&
- /*wraSetDLLAccessPath &&*/ wraInitDecoder)
- {
- rv_handle = handle;
- dll_type = 1;
- return 1;
- }
-
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Cannot resolve symbols - incompatible dll: %s\n",path);
- FreeLibrary(handle);
- return 0;
-
-}
-#endif
-
-
-static int preinit(sh_audio_t *sh){
- // let's check if the driver is available, return 0 if not.
- // (you should do that if you use external lib(s) which is optional)
- unsigned int result;
- char *path;
-
- path = malloc(strlen(codec_path) + strlen(sh->codec->dll) + 2);
- if (!path) return 0;
- sprintf(path, "%s/%s", codec_path, sh->codec->dll);
-
- /* first try to load linux dlls, if failed and we're supporting win32 dlls,
- then try to load the windows ones */
-
-#ifdef HAVE_LIBDL
- if (strstr(sh->codec->dll,".dll") || !load_syms_linux(path))
-#endif
-#ifdef CONFIG_WIN32DLL
- if (!load_syms_windows(sh->codec->dll))
-#endif
- {
- mp_tmsg(MSGT_DECVIDEO, MSGL_ERR, "ERROR: Could not open required DirectShow codec %s.\n", sh->codec->dll);
- mp_msg(MSGT_DECVIDEO, MSGL_HINT, "Read the RealAudio section of the DOCS!\n");
- free(path);
- return 0;
- }
-
-#ifdef CONFIG_WIN32DLL
- if((raSetDLLAccessPath && dll_type == 0) || (wraSetDLLAccessPath && dll_type == 1)){
-#else
- if(raSetDLLAccessPath){
-#endif
- // used by 'SIPR'
- path = realloc(path, strlen(codec_path) + 13);
- sprintf(path, "DT_Codecs=%s", codec_path);
- if(path[strlen(path)-1]!='/'){
- path[strlen(path)+1]=0;
- path[strlen(path)]='/';
- }
- path[strlen(path)+1]=0;
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- {
- int i;
- for (i=0; i < strlen(path); i++)
- if (path[i] == '/') path[i] = '\\';
- wraSetDLLAccessPath(path);
- }
- else
-#endif
- raSetDLLAccessPath(path);
- }
-
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1){
- if (wraOpenCodec2) {
- sprintf(path, "%s\\", codec_path);
- result = wraOpenCodec2(&sh->context, path);
- } else
- result=wraOpenCodec(&sh->context);
- } else
-#endif
- if (raOpenCodec2) {
- sprintf(path, "%s/", codec_path);
- result = raOpenCodec2(&sh->context, path);
- } else
- result=raOpenCodec(&sh->context);
- if(result){
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder open failed, error code: 0x%X\n",result);
- return 0;
- }
-// printf("opencodec ok (result: %x)\n", result);
- free(path); /* after this it isn't used anymore */
-
- sh->samplerate=sh->wf->nSamplesPerSec;
- sh->samplesize=sh->wf->wBitsPerSample/8;
- sh->channels=sh->wf->nChannels;
-
- {
- ra_init_t init_data={
- sh->wf->nSamplesPerSec,
- sh->wf->wBitsPerSample,
- sh->wf->nChannels,
- 100, // quality
- sh->wf->nBlockAlign, // subpacket size
- sh->wf->nBlockAlign, // coded frame size
- sh->wf->cbSize, // codec data length
- (char*)(sh->wf+1) // extras
- };
-#ifdef CONFIG_WIN32DLL
- wra_init_t winit_data={
- sh->wf->nSamplesPerSec,
- sh->wf->wBitsPerSample,
- sh->wf->nChannels,
- 100, // quality
- sh->wf->nBlockAlign, // subpacket size
- sh->wf->nBlockAlign, // coded frame size
- sh->wf->cbSize, // codec data length
- (char*)(sh->wf+1) // extras
- };
-#endif
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- result=wraInitDecoder(sh->context,&winit_data);
- else
-#endif
- result=raInitDecoder(sh->context,&init_data);
-
- if(result){
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder init failed, error code: 0x%X\n",result);
- return 0;
- }
-// printf("initdecoder ok (result: %x)\n", result);
- }
-
-#ifdef CONFIG_WIN32DLL
- if((raSetPwd && dll_type == 0) || (wraSetPwd && dll_type == 1)){
-#else
- if(raSetPwd){
-#endif
- // used by 'SIPR'
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- wraSetPwd(sh->context,"Ardubancel Quazanga");
- else
-#endif
- raSetPwd(sh->context,"Ardubancel Quazanga"); // set password... lol.
- }
-
- if (sh->format == mmioFOURCC('s','i','p','r')) {
- short flavor;
-
- if (sh->wf->nAvgBytesPerSec > 1531)
- flavor = 3;
- else if (sh->wf->nAvgBytesPerSec > 937)
- flavor = 1;
- else if (sh->wf->nAvgBytesPerSec > 719)
- flavor = 0;
- else
- flavor = 2;
- mp_msg(MSGT_DECAUDIO,MSGL_V,"Got sipr flavor %d from bitrate %d\n",flavor, sh->wf->nAvgBytesPerSec);
-
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- result=wraSetFlavor(sh->context,flavor);
- else
-#endif
- result=raSetFlavor(sh->context,flavor);
- if(result){
- mp_msg(MSGT_DECAUDIO,MSGL_WARN,"Decoder flavor setup failed, error code: 0x%X\n",result);
- return 0;
- }
- } // sipr flavor
-
- sh->i_bps=sh->wf->nAvgBytesPerSec;
-
- sh->audio_out_minsize=128000; // no idea how to get... :(
- sh->audio_in_minsize = sh->wf->nBlockAlign;
-
- return 1; // return values: 1=OK 0=ERROR
-}
-
-static int init(sh_audio_t *sh_audio){
- // initialize the decoder, set tables etc...
-
- // you can store HANDLE or private struct pointer at sh->context
- // you can access WAVEFORMATEX header at sh->wf
-
- // set sample format/rate parameters if you didn't do it in preinit() yet.
-
- return 1; // return values: 1=OK 0=ERROR
-}
-
-static void uninit(sh_audio_t *sh){
- // uninit the decoder etc...
- // again: you don't have to free() a_in_buffer here! it's done by the core.
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- {
- if (wraFreeDecoder) wraFreeDecoder(sh->context);
- if (wraCloseCodec) wraCloseCodec(sh->context);
- }
-#endif
-
- if (raFreeDecoder) raFreeDecoder(sh->context);
- if (raCloseCodec) raCloseCodec(sh->context);
-
-
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- {
- if (rv_handle) FreeLibrary(rv_handle);
- } else
-#endif
-// this dlclose() causes some memory corruption, and crashes soon (in caller):
-// if (rv_handle) dlclose(rv_handle);
- rv_handle = NULL;
-}
-
-static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){
- int result av_unused;
- int len=-1;
-
- if(sh->a_in_buffer_len<=0){
- // fill the buffer!
- if (sh->ds->eof)
- return 0;
- demux_read_data(sh->ds, sh->a_in_buffer, sh->wf->nBlockAlign);
- sh->a_in_buffer_size=
- sh->a_in_buffer_len=sh->wf->nBlockAlign;
- }
-
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- result=wraDecode(sh->context, sh->a_in_buffer+sh->a_in_buffer_size-sh->a_in_buffer_len, sh->wf->nBlockAlign,
- buf, &len, -1);
- else
-#endif
- result=raDecode(sh->context, sh->a_in_buffer+sh->a_in_buffer_size-sh->a_in_buffer_len, sh->wf->nBlockAlign,
- buf, &len, -1);
- sh->a_in_buffer_len-=sh->wf->nBlockAlign;
-
-// printf("radecode: %d bytes, res=0x%X \n",len,result);
-
- return len; // return value: number of _bytes_ written to output buffer,
- // or -1 for EOF (or uncorrectable error)
-}
-
-static int control(sh_audio_t *sh,int cmd,void* arg, ...){
- // various optional functions you MAY implement:
- switch(cmd){
- case ADCTRL_RESYNC_STREAM:
- // it is called once after seeking, to resync.
- // Note: sh_audio->a_in_buffer_len=0; is done _before_ this call!
- return CONTROL_TRUE;
- case ADCTRL_SKIP_FRAME:
- // it is called to skip (jump over) small amount (1/10 sec or 1 frame)
- // of audio data - used to sync audio to video after seeking
- // if you don't return CONTROL_TRUE, it will defaults to:
- // ds_fill_buffer(sh_audio->ds); // skip 1 demux packet
- return CONTROL_TRUE;
- }
- return CONTROL_UNKNOWN;
-}
diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c
index a9dbbf2fe6..9594cfba24 100644
--- a/libmpcodecs/vd.c
+++ b/libmpcodecs/vd.c
@@ -39,13 +39,8 @@
extern const vd_functions_t mpcodecs_vd_null;
extern const vd_functions_t mpcodecs_vd_ffmpeg;
-extern const vd_functions_t mpcodecs_vd_dshow;
-extern const vd_functions_t mpcodecs_vd_dmo;
-extern const vd_functions_t mpcodecs_vd_vfw;
-extern const vd_functions_t mpcodecs_vd_vfwex;
extern const vd_functions_t mpcodecs_vd_raw;
extern const vd_functions_t mpcodecs_vd_hmblck;
-extern const vd_functions_t mpcodecs_vd_xanim;
extern const vd_functions_t mpcodecs_vd_mpng;
extern const vd_functions_t mpcodecs_vd_ijpg;
extern const vd_functions_t mpcodecs_vd_mtga;
@@ -61,18 +56,9 @@ extern const vd_functions_t mpcodecs_vd_qtvideo;
const vd_functions_t * const mpcodecs_vd_drivers[] = {
&mpcodecs_vd_null,
&mpcodecs_vd_ffmpeg,
-#ifdef CONFIG_WIN32DLL
- &mpcodecs_vd_dshow,
- &mpcodecs_vd_dmo,
- &mpcodecs_vd_vfw,
- &mpcodecs_vd_vfwex,
-#endif
&mpcodecs_vd_lzo,
&mpcodecs_vd_raw,
&mpcodecs_vd_hmblck,
-#ifdef CONFIG_XANIM
- &mpcodecs_vd_xanim,
-#endif
#ifdef CONFIG_PNG
&mpcodecs_vd_mpng,
#endif
@@ -80,15 +66,9 @@ const vd_functions_t * const mpcodecs_vd_drivers[] = {
&mpcodecs_vd_ijpg,
#endif
&mpcodecs_vd_mtga,
-#ifdef CONFIG_REALCODECS
- &mpcodecs_vd_realvid,
-#endif
#ifdef CONFIG_LIBDV095
&mpcodecs_vd_libdv,
#endif
-#ifdef CONFIG_QTX_CODECS
- &mpcodecs_vd_qtvideo,
-#endif
/* Please do not add any new decoders here. If you want to implement a new
* decoder, add it to libavcodec, except for wrappers around external
* libraries and decoders requiring binary support. */
diff --git a/libmpcodecs/vd_dmo.c b/libmpcodecs/vd_dmo.c
deleted file mode 100644
index e300edd371..0000000000
--- a/libmpcodecs/vd_dmo.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "mp_msg.h"
-
-#include "vd_internal.h"
-
-#include "loader/dmo/DMO_VideoDecoder.h"
-
-static const vd_info_t info = {
- "DMO video codecs",
- "dmo",
- "A'rpi",
- "based on http://avifile.sf.net",
- "win32 codecs"
-};
-
-LIBVD_EXTERN(dmo)
-
-struct context {
- void *decoder;
- uint8_t *buffer;
- int stride;
-};
-
-// to set/get/query special features/parameters
-static int control(sh_video_t *sh,int cmd,void* arg,...){
- return CONTROL_UNKNOWN;
-}
-
-// init driver
-static int init(sh_video_t *sh){
- unsigned int out_fmt=sh->codec->outfmt[0];
- struct context *ctx;
- void *decoder;
- if(!(decoder=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
- mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll);
- mp_tmsg(MSGT_DECVIDEO,MSGL_HINT,"You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n");
- return 0;
- }
- if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,out_fmt)) return 0;
- // mpcodecs_config_vo can change the format
- out_fmt=sh->codec->outfmt[sh->outfmtidx];
- sh->context = ctx = calloc(1, sizeof(*ctx));
- ctx->decoder = decoder;
- switch(out_fmt){
- case IMGFMT_YUY2:
- case IMGFMT_UYVY:
- DMO_VideoDecoder_SetDestFmt(ctx->decoder,16,out_fmt);break; // packed YUV
- case IMGFMT_YV12:
- case IMGFMT_I420:
- case IMGFMT_IYUV:
- DMO_VideoDecoder_SetDestFmt(ctx->decoder,12,out_fmt);break; // planar YUV
- case IMGFMT_YVU9:
- DMO_VideoDecoder_SetDestFmt(ctx->decoder,9,out_fmt);break;
- case IMGFMT_RGB24:
- case IMGFMT_BGR24:
- if (sh->disp_w & 3)
- {
- ctx->stride = ((sh->disp_w * 3) + 3) & ~3;
- ctx->buffer = av_malloc(ctx->stride * sh->disp_h);
- }
- default:
- DMO_VideoDecoder_SetDestFmt(ctx->decoder,out_fmt&255,0); // RGB/BGR
- }
- DMO_VideoDecoder_StartInternal(ctx->decoder);
- mp_tmsg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO video codec init OK.\n");
- return 1;
-}
-
-// uninit driver
-static void uninit(sh_video_t *sh){
- struct context *ctx = sh->context;
- DMO_VideoDecoder_Destroy(ctx->decoder);
- av_free(ctx->buffer);
- free(ctx);
- sh->context = NULL;
-}
-
-//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
-
-// decode a frame
-static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
- struct context *ctx = sh->context;
- uint8_t *buffer = ctx->buffer;
- int type = ctx->buffer ? MP_IMGTYPE_EXPORT : MP_IMGTYPE_TEMP;
- mp_image_t* mpi;
- if(len<=0) return NULL; // skipped frame
-
- if(flags&3){
- // framedrop:
- DMO_VideoDecoder_DecodeInternal(ctx->decoder, data, len, 0, 0);
- return NULL;
- }
-
- mpi=mpcodecs_get_image(sh, type, MP_IMGFLAG_COMMON_PLANE,
- sh->disp_w, sh->disp_h);
- if (buffer) {
- mpi->planes[0] = buffer;
- mpi->stride[0] = ctx->stride;
- } else {
- buffer = mpi->planes[0];
- }
-
- if(!mpi){ // temporary!
- mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n");
- return NULL;
- }
-
- DMO_VideoDecoder_DecodeInternal(ctx->decoder, data, len, 1, buffer);
-
- return mpi;
-}
diff --git a/libmpcodecs/vd_dshow.c b/libmpcodecs/vd_dshow.c
deleted file mode 100644
index 7e8fe35ce0..0000000000
--- a/libmpcodecs/vd_dshow.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "config.h"
-
-#include "mp_msg.h"
-
-#include "vd_internal.h"
-
-#include "loader/dshow/DS_VideoDecoder.h"
-
-static const vd_info_t info = {
- "DirectShow video codecs",
- "dshow",
- "A'rpi",
- "based on http://avifile.sf.net",
- "win32 codecs"
-};
-
-LIBVD_EXTERN(dshow)
-
-// to set/get/query special features/parameters
-static int control(sh_video_t *sh,int cmd,void* arg,...){
- switch(cmd){
- case VDCTRL_QUERY_MAX_PP_LEVEL:
- return 4;
- case VDCTRL_SET_PP_LEVEL:
- if(!sh->context) return CONTROL_ERROR;
- DS_VideoDecoder_SetValue(sh->context,"Quality",*((int*)arg));
- return CONTROL_OK;
-
- case VDCTRL_SET_EQUALIZER: {
- va_list ap;
- int value;
- va_start(ap, arg);
- value=va_arg(ap, int);
- va_end(ap);
- if(DS_VideoDecoder_SetValue(sh->context,arg,50+value/2)==0)
- return CONTROL_OK;
- return CONTROL_FALSE;
- }
-
- }
- return CONTROL_UNKNOWN;
-}
-
-// init driver
-static int init(sh_video_t *sh){
- unsigned int out_fmt=sh->codec->outfmt[0];
-
- /* Hack for VSSH codec: new dll can't decode old files
- * In my samples old files have no extradata, so use that info
- * to decide what dll should be used (here and in vd_vfw).
- */
- if (!strcmp(sh->codec->dll, "vsshdsd.dll") && (sh->bih->biSize == 40))
- return 0;
-
- if(!(sh->context=DS_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
- mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll);
- mp_tmsg(MSGT_DECVIDEO,MSGL_HINT,"You need to upgrade/install the binary codecs package.\nGo to http://www.mplayerhq.hu/dload.html\n");
- return 0;
- }
- if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,out_fmt)) return 0;
- // mpcodecs_config_vo can change the format
- out_fmt=sh->codec->outfmt[sh->outfmtidx];
- switch(out_fmt){
- case IMGFMT_YUY2:
- case IMGFMT_UYVY:
- DS_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
- case IMGFMT_YV12:
- case IMGFMT_I420:
- case IMGFMT_IYUV:
- DS_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
- case IMGFMT_YVU9:
- DS_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
- default:
- DS_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
- }
- DS_SetAttr_DivX("Quality",divx_quality);
- DS_VideoDecoder_StartInternal(sh->context);
- mp_tmsg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK.\n");
- return 1;
-}
-
-// uninit driver
-static void uninit(sh_video_t *sh){
- DS_VideoDecoder_Destroy(sh->context);
-}
-
-//mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
-
-// decode a frame
-static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
- mp_image_t* mpi;
- if(len<=0) return NULL; // skipped frame
-
- if(flags&3){
- // framedrop:
- DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0);
- return NULL;
- }
-
- mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_COMMON_PLANE,
- sh->disp_w, sh->disp_h);
-
- if(!mpi){ // temporary!
- mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n");
- return NULL;
- }
-
- DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, mpi->planes[0]);
-
- return mpi;
-}
diff --git a/libmpcodecs/vd_qtvideo.c b/libmpcodecs/vd_qtvideo.c
deleted file mode 100644
index 5e37ca456e..0000000000
--- a/libmpcodecs/vd_qtvideo.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-
-#include "config.h"
-#include "mp_msg.h"
-#include "mpbswap.h"
-#include "vd_internal.h"
-
-#ifdef CONFIG_QUICKTIME
-#include <QuickTime/ImageCodec.h>
-#define dump_ImageDescription(x)
-#else
-#include "loader/ldt_keeper.h"
-#include "loader/qtx/qtxsdk/components.h"
-#include "loader/wine/winbase.h"
-#include "loader/wine/windef.h"
-#endif
-
-static const vd_info_t info = {
- "Quicktime Video decoder",
- "qtvideo",
- "A'rpi",
- "Sascha Sommer",
- "win32"
-};
-
-LIBVD_EXTERN(qtvideo)
-
-static mp_image_t* mpi;
-static Rect OutBufferRect; //the dimensions of our GWorld
-
-static GWorldPtr OutBufferGWorld = NULL;//a GWorld is some kind of description for a drawing environment
-static ImageDescriptionHandle framedescHandle;
-static ImageSequence imageSeq;
-
-#ifndef CONFIG_QUICKTIME
-static HINSTANCE qtime_qts; // handle to the preloaded quicktime.qts
-static HMODULE handler;
-static OSErr (*InitializeQTML)(long flags);
-static OSErr (*EnterMovies)(void);
-static void (*ExitMovies)(void);
-static OSErr (*DecompressSequenceBegin)(ImageSequence *seqID,
- ImageDescriptionHandle desc,
- CGrafPtr port,
- /*GDHandle*/void* gdh,
- const Rect *srcRect,
- MatrixRecordPtr matrix,
- short mode,
- RgnHandle mask,
- CodecFlags flags,
- CodecQ accuracy,
- DecompressorComponent codec);
-static OSErr (*DecompressSequenceFrameS)(ImageSequence seqID,
- Ptr data,
- long dataSize,
- CodecFlags inFlags,
- CodecFlags *outFlags,
- ICMCompletionProcRecordPtr asyncCompletionProc);
-static PixMapHandle (*GetGWorldPixMap)(GWorldPtr offscreenGWorld);
-static OSErr (*QTNewGWorldFromPtr)(GWorldPtr *gw,
- OSType pixelFormat,
- const Rect *boundsRect,
- CTabHandle cTable,
- /*GDHandle*/void* aGDevice, //unused anyway
- GWorldFlags flags,
- void *baseAddr,
- long rowBytes);
-static Handle (*NewHandleClear)(Size byteCount);
-static void (*DisposeHandle)(Handle h);
-static void (*DisposeGWorld)(GWorldPtr offscreenGWorld);
-static OSErr (*CDSequenceEnd)(ImageSequence seqID);
-#endif /* #ifndef CONFIG_QUICKTIME */
-
-// to set/get/query special features/parameters
-static int control(sh_video_t *sh,int cmd,void* arg,...){
- return CONTROL_UNKNOWN;
-}
-
-// init driver
-static int init(sh_video_t *sh){
- OSErr result = 1;
- int extradata_size = sh->bih ? sh->bih->biSize - sizeof(*sh->bih) : 0;
- void *extradata = sh->bih + 1;
-
- if (!sh->ImageDesc)
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"sh->ImageDesc not set, try -demuxer mov if this fails.\n");
-
-#ifndef CONFIG_QUICKTIME
-#ifdef WIN32_LOADER
- Setup_LDT_Keeper();
-#endif
-
- //preload quicktime.qts to avoid the problems caused by the hardcoded path inside the dll
- qtime_qts = LoadLibraryA("QuickTime.qts");
- if(!qtime_qts){
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load QuickTime.qts\n" );
- return 0;
- }
-
- handler = LoadLibraryA("qtmlClient.dll");
- if(!handler){
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"unable to load qtmlClient.dll\n");
- return 0;
- }
-
- InitializeQTML = (OSErr (*)(long))GetProcAddress(handler, "InitializeQTML");
- EnterMovies = (OSErr (*)(void))GetProcAddress(handler, "EnterMovies");
- ExitMovies = (void (*)(void))GetProcAddress(handler, "ExitMovies");
- DecompressSequenceBegin = (OSErr (*)(ImageSequence*,ImageDescriptionHandle,CGrafPtr,void *,const Rect *,MatrixRecordPtr,short,RgnHandle,CodecFlags,CodecQ,DecompressorComponent))GetProcAddress(handler, "DecompressSequenceBegin");
- DecompressSequenceFrameS = (OSErr (*)(ImageSequence,Ptr,long,CodecFlags,CodecFlags*,ICMCompletionProcRecordPtr))GetProcAddress(handler, "DecompressSequenceFrameS");
- GetGWorldPixMap = (PixMapHandle (*)(GWorldPtr))GetProcAddress(handler, "GetGWorldPixMap");
- QTNewGWorldFromPtr = (OSErr(*)(GWorldPtr *,OSType,const Rect *,CTabHandle,void*,GWorldFlags,void *,long))GetProcAddress(handler, "QTNewGWorldFromPtr");
- NewHandleClear = (Handle(*)(Size))GetProcAddress(handler, "NewHandleClear");
- DisposeHandle = (void (*)(Handle))GetProcAddress(handler, "DisposeHandle");
- DisposeGWorld = (void (*)(GWorldPtr))GetProcAddress(handler, "DisposeGWorld");
- CDSequenceEnd = (OSErr (*)(ImageSequence))GetProcAddress(handler, "CDSequenceEnd");
-
- if(!InitializeQTML || !EnterMovies || !DecompressSequenceBegin || !DecompressSequenceFrameS){
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"invalid qtmlClient.dll!\n");
- return 0;
- }
-
- result=InitializeQTML(kInitializeQTMLDisableDirectSound |
- kInitializeQTMLUseGDIFlag |
- kInitializeQTMLDisableDDClippers);
- mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"InitializeQTML returned %d\n",result);
-#endif /* CONFIG_QUICKTIME */
-
- result=EnterMovies();
- mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"EnterMovies returned %d\n",result);
-
- //make a yuy2 gworld
- OutBufferRect.top=0;
- OutBufferRect.left=0;
- OutBufferRect.right=sh->disp_w;
- OutBufferRect.bottom=sh->disp_h;
-
- //Fill the imagedescription for our SVQ3 frame
- //we can probably get this from Demuxer
- if (!sh->ImageDesc && extradata_size >= sizeof(ImageDescription) &&
- ((ImageDescription *)extradata)->idSize <= extradata_size)
- sh->ImageDesc = extradata;
- if (sh->ImageDesc) {
- mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize);
- framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize);
- memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize);
- } else {
- // assume extradata consists only of the atoms, build the other parts
- ImageDescription *idesc;
- int size = sizeof(*idesc) + extradata_size;
- mp_msg(MSGT_DECVIDEO, MSGL_V, "Generating a ImageDescription\n");
- framedescHandle=(ImageDescriptionHandle)NewHandleClear(size);
- idesc = *framedescHandle;
- memcpy(idesc + 1, extradata, extradata_size);
- idesc->idSize = size;
- idesc->width = sh->disp_w;
- idesc->height = sh->disp_h;
- }
- if (mp_msg_test(MSGT_DECVIDEO, MSGL_V))
- dump_ImageDescription(*framedescHandle);
-
- (**framedescHandle).cType = bswap_32(sh->format);
- sh->context = (void *)kYUVSPixelFormat;
- {
- int imgfmt = sh->codec->outfmt[sh->outfmtidx];
- int qt_imgfmt;
- switch(imgfmt)
- {
- case IMGFMT_YUY2:
- qt_imgfmt = kYUVSPixelFormat;
- break;
- case IMGFMT_YVU9:
- qt_imgfmt = 0x73797639; //kYVU9PixelFormat;
- break;
- case IMGFMT_YV12:
- qt_imgfmt = 0x79343230;
- break;
- case IMGFMT_UYVY:
- qt_imgfmt = k2vuyPixelFormat;
- break;
- case IMGFMT_YVYU:
- qt_imgfmt = kYVYU422PixelFormat;
- imgfmt = IMGFMT_YUY2;
- break;
- case IMGFMT_RGB16:
- qt_imgfmt = k16LE555PixelFormat;
- break;
- case IMGFMT_BGR24:
- qt_imgfmt = k24BGRPixelFormat;
- break;
- case IMGFMT_BGR32:
- qt_imgfmt = k32BGRAPixelFormat;
- break;
- case IMGFMT_RGB32:
- qt_imgfmt = k32RGBAPixelFormat;
- break;
- default:
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Unknown requested csp\n");
- return 0;
- }
- mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"imgfmt: %s qt_imgfmt: %.4s\n", vo_format_name(imgfmt), (char *)&qt_imgfmt);
- sh->context = (void *)qt_imgfmt;
- if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,imgfmt)) return 0;
- }
-
- mpi=mpcodecs_get_image(sh, MP_IMGTYPE_STATIC, MP_IMGFLAG_PRESERVE,
- sh->disp_w, sh->disp_h);
- if(!mpi) return 0;
-
- result = QTNewGWorldFromPtr(
- &OutBufferGWorld,
- (OSType)sh->context,
- &OutBufferRect, //we should benchmark if yvu9 is faster for svq3, too
- 0,
- 0,
- 0,
- mpi->planes[0],
- mpi->stride[0]);
- if (result) {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"QTNewGWorldFromPtr result=%d\n",result);
- return 0;
- }
-
- result = DecompressSequenceBegin(&imageSeq, framedescHandle, (CGrafPtr)OutBufferGWorld,
- NULL, NULL, NULL, srcCopy, NULL, 0,
- codecNormalQuality, 0);
- if(result) {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"DecompressSequenceBegin result=%d\n",result);
- return 0;
- }
-
- return 1;
-}
-
-// uninit driver
-static void uninit(sh_video_t *sh){
- if(OutBufferGWorld) {
- DisposeGWorld(OutBufferGWorld);
- OutBufferGWorld = NULL;
- }
- if(framedescHandle) {
- DisposeHandle((Handle)framedescHandle);
- framedescHandle = NULL;
- }
- if(imageSeq) {
- CDSequenceEnd(imageSeq);
- imageSeq = 0;
- }
- ExitMovies();
-}
-
-// decode a frame
-static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
- OSErr result = 1;
- CodecFlags ignore;
-
- if(len<=0) return NULL; // skipped frame
-
-#if defined(WIN32_LOADER) && !defined(CONFIG_QUICKTIME)
- Setup_FS_Segment();
-#endif
-
- result = DecompressSequenceFrameS(imageSeq, data, len, 0, &ignore, NULL);
- if(result) {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"DecompressSequenceFrameS result=0x%d\n",result);
- return NULL;
- }
-
-if((int)sh->context==0x73797639){ // Sorenson 16-bit YUV -> std YVU9
- int i;
-
- PixMap dstPixMap = **GetGWorldPixMap(OutBufferGWorld);
- short *src0=(short *)((char*)dstPixMap.baseAddr+0x20);
-
- for(i=0;i<mpi->h;i++){
- int x;
- unsigned char* dst=mpi->planes[0]+i*mpi->stride[0];
- unsigned short* src=src0+i*((mpi->w+15)&(~15));
- for(x=0;x<mpi->w;x++) dst[x]=src[x];
- }
- src0+=((mpi->w+15)&(~15))*((mpi->h+15)&(~15));
- for(i=0;i<mpi->h/4;i++){
- int x;
- unsigned char* dst=mpi->planes[1]+i*mpi->stride[1];
- unsigned short* src=src0+i*(((mpi->w+63)&(~63))/4);
- for(x=0;x<mpi->w/4;x++) dst[x]=src[x];
- src+=((mpi->w+63)&(~63))/4;
- }
- src0+=(((mpi->w+63)&(~63))/4)*(((mpi->h+63)&(~63))/4);
- for(i=0;i<mpi->h/4;i++){
- int x;
- unsigned char* dst=mpi->planes[2]+i*mpi->stride[2];
- unsigned short* src=src0+i*(((mpi->w+63)&(~63))/4);
- for(x=0;x<mpi->w/4;x++) dst[x]=src[x];
- src+=((mpi->w+63)&(~63))/4;
- }
-
-}
-
-
- return mpi;
-}
diff --git a/libmpcodecs/vd_realvid.c b/libmpcodecs/vd_realvid.c
deleted file mode 100644
index 08637b1407..0000000000
--- a/libmpcodecs/vd_realvid.c
+++ /dev/null
@@ -1,453 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <libavutil/intreadwrite.h>
-
-#include "config.h"
-
-#ifdef HAVE_LIBDL
-#include <dlfcn.h>
-#endif
-
-#include "mp_msg.h"
-#include "path.h"
-
-#include "vd_internal.h"
-#include "loader/wine/windef.h"
-
-static const vd_info_t info = {
- "RealVideo decoder",
- "realvid",
- "Alex Beregszaszi",
- "Florian Schneider, Arpad Gereoffy, Alex Beregszaszi, Donnie Smith",
- "binary real video codecs"
-};
-
-LIBVD_EXTERN(realvid)
-
-
-/*
- * Structures for data packets. These used to be tables of unsigned ints, but
- * that does not work on 64 bit platforms (e.g. Alpha). The entries that are
- * pointers get truncated. Pointers on 64 bit platforms are 8 byte longs.
- * So we have to use structures so the compiler will assign the proper space
- * for the pointer.
- */
-typedef struct cmsg_data_s {
- uint32_t data1;
- uint32_t data2;
- uint32_t* dimensions;
-} cmsg_data_t;
-
-typedef struct transform_in_s {
- uint32_t len;
- uint32_t unknown1;
- uint32_t chunks;
- uint32_t* extra;
- uint32_t unknown2;
- uint32_t timestamp;
-} transform_in_t;
-
-static unsigned long (*rvyuv_custom_message)(cmsg_data_t* ,void*);
-static unsigned long (*rvyuv_free)(void*);
-static unsigned long (*rvyuv_init)(void*, void*); // initdata,context
-static unsigned long (*rvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*);
-#ifdef CONFIG_WIN32DLL
-static unsigned long WINAPI (*wrvyuv_custom_message)(cmsg_data_t* ,void*);
-static unsigned long WINAPI (*wrvyuv_free)(void*);
-static unsigned long WINAPI (*wrvyuv_init)(void*, void*); // initdata,context
-static unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*);
-#endif
-
-static void *rv_handle=NULL;
-static int initialized=0;
-static uint8_t *buffer = NULL;
-static int bufsz = 0;
-#ifdef CONFIG_WIN32DLL
-static int dll_type = 0; /* 0 = unix dlopen, 1 = win32 dll */
-#endif
-
-void *__builtin_vec_new(unsigned long size);
-void __builtin_vec_delete(void *mem);
-void __pure_virtual(void);
-
-void *__builtin_vec_new(unsigned long size) {
- return malloc(size);
-}
-
-void __builtin_vec_delete(void *mem) {
- free(mem);
-}
-
-void __pure_virtual(void) {
- printf("FATAL: __pure_virtual() called!\n");
-// exit(1);
-}
-
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-void ___brk_addr(void) {exit(0);}
-char **__environ={NULL};
-#undef stderr
-FILE *stderr=NULL;
-#endif
-
-// to set/get/query special features/parameters
-static int control(sh_video_t *sh,int cmd,void* arg,...){
-// switch(cmd){
-// case VDCTRL_QUERY_MAX_PP_LEVEL:
-// return 9;
-// case VDCTRL_SET_PP_LEVEL:
-// vfw_set_postproc(sh,10*(*((int*)arg)));
-// return CONTROL_OK;
-// }
- return CONTROL_UNKNOWN;
-}
-
-/* exits program when failure */
-#ifdef HAVE_LIBDL
-static int load_syms_linux(char *path) {
- void *handle;
-
- mp_msg(MSGT_DECVIDEO,MSGL_V, "opening shared obj '%s'\n", path);
- handle = dlopen (path, RTLD_LAZY);
- if (!handle) {
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error: %s\n",dlerror());
- return 0;
- }
-
- rvyuv_custom_message = dlsym(handle, "RV20toYUV420CustomMessage");
- rvyuv_free = dlsym(handle, "RV20toYUV420Free");
- rvyuv_init = dlsym(handle, "RV20toYUV420Init");
- rvyuv_transform = dlsym(handle, "RV20toYUV420Transform");
-
- if(rvyuv_custom_message &&
- rvyuv_free &&
- rvyuv_init &&
- rvyuv_transform)
- {
- rv_handle = handle;
- return 1;
- }
-
- rvyuv_custom_message = dlsym(handle, "RV40toYUV420CustomMessage");
- rvyuv_free = dlsym(handle, "RV40toYUV420Free");
- rvyuv_init = dlsym(handle, "RV40toYUV420Init");
- rvyuv_transform = dlsym(handle, "RV40toYUV420Transform");
-
- if(rvyuv_custom_message &&
- rvyuv_free &&
- rvyuv_init &&
- rvyuv_transform)
- {
- rv_handle = handle;
- return 1;
- }
-
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n");
- dlclose(handle);
- return 0;
-}
-#endif
-
-#ifdef CONFIG_WIN32DLL
-
-#ifdef WIN32_LOADER
-#include "loader/ldt_keeper.h"
-#endif
-void* WINAPI LoadLibraryA(char* name);
-void* WINAPI GetProcAddress(void* handle,char* func);
-int WINAPI FreeLibrary(void *handle);
-
-#ifndef WIN32_LOADER
-void * WINAPI GetModuleHandleA(char *);
-static int patch_dll(uint8_t *patchpos, const uint8_t *oldcode,
- const uint8_t *newcode, int codesize) {
- void *handle = GetModuleHandleA("kernel32");
- int WINAPI (*VirtProt)(void *, unsigned, int, int *);
- int res = 0;
- int prot, tmp;
- VirtProt = GetProcAddress(handle, "VirtualProtect");
- // change permissions to PAGE_WRITECOPY
- if (!VirtProt ||
- !VirtProt(patchpos, codesize, 0x08, &prot)) {
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "VirtualProtect failed at %p\n", patchpos);
- return 0;
- }
- if (memcmp(patchpos, oldcode, codesize) == 0) {
- memcpy(patchpos, newcode, codesize);
- res = 1;
- }
- VirtProt(patchpos, codesize, prot, &tmp);
- return res;
-}
-#endif
-
-static int load_syms_windows(char *path) {
- void *handle;
-
- mp_msg(MSGT_DECVIDEO,MSGL_V, "opening win32 dll '%s'\n", path);
-#ifdef WIN32_LOADER
- Setup_LDT_Keeper();
-#endif
- handle = LoadLibraryA(path);
- mp_msg(MSGT_DECVIDEO,MSGL_V,"win32 real codec handle=%p \n",handle);
- if (!handle) {
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error loading dll\n");
- return 0;
- }
-
- wrvyuv_custom_message = GetProcAddress(handle, "RV20toYUV420CustomMessage");
- wrvyuv_free = GetProcAddress(handle, "RV20toYUV420Free");
- wrvyuv_init = GetProcAddress(handle, "RV20toYUV420Init");
- wrvyuv_transform = GetProcAddress(handle, "RV20toYUV420Transform");
-
- if(wrvyuv_custom_message &&
- wrvyuv_free &&
- wrvyuv_init &&
- wrvyuv_transform)
- {
- dll_type = 1;
- rv_handle = handle;
-#ifndef WIN32_LOADER
- {
- if (strstr(path, "drv43260.dll")) {
- int patched;
- // patch away multithreaded decoding, it causes crashes
- static const uint8_t oldcode[13] = {
- 0x83, 0xbb, 0xf8, 0x05, 0x00, 0x00, 0x01,
- 0x0f, 0x86, 0xd0, 0x00, 0x00, 0x00 };
- static const uint8_t newcode[13] = {
- 0x31, 0xc0,
- 0x89, 0x83, 0xf8, 0x05, 0x00, 0x00,
- 0xe9, 0xd0, 0x00, 0x00, 0x00 };
- patched = patch_dll(
- (char*)wrvyuv_transform + 0x634132fa - 0x634114d0,
- oldcode, newcode, sizeof(oldcode));
- if (!patched)
- mp_msg(MSGT_DECVIDEO, MSGL_WARN, "Could not patch Real codec, this might crash on multi-CPU systems\n");
- }
- }
-#endif
- return 1;
- }
-
- wrvyuv_custom_message = GetProcAddress(handle, "RV40toYUV420CustomMessage");
- wrvyuv_free = GetProcAddress(handle, "RV40toYUV420Free");
- wrvyuv_init = GetProcAddress(handle, "RV40toYUV420Init");
- wrvyuv_transform = GetProcAddress(handle, "RV40toYUV420Transform");
- if(wrvyuv_custom_message &&
- wrvyuv_free &&
- wrvyuv_init &&
- wrvyuv_transform) {
- dll_type = 1;
- rv_handle = handle;
- return 1;
- }
-
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error resolving symbols! (version incompatibility?)\n");
- FreeLibrary(handle);
- return 0; // error
-}
-#endif
-
-/* we need exact positions */
-struct rv_init_t {
- short unk1;
- short w;
- short h;
- short unk3;
- int unk2;
- int subformat;
- int unk5;
- int format;
-} rv_init_t;
-
-// init driver
-static int init(sh_video_t *sh){
- //unsigned int out_fmt;
- char *path;
- int result;
- // we export codec id and sub-id from demuxer in bitmapinfohdr:
- unsigned char* extrahdr=(unsigned char*)(sh->bih+1);
- unsigned int extrahdr_size = sh->bih->biSize - sizeof(*sh->bih);
- struct rv_init_t init_data;
-
- if(extrahdr_size < 8) {
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"realvideo: extradata too small (%u)\n", extrahdr_size);
- return 0;
- }
- init_data = (struct rv_init_t){11, sh->disp_w, sh->disp_h, 0, 0, AV_RB32(extrahdr), 1, AV_RB32(extrahdr + 4)}; // rv30
-
- mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo codec id: 0x%08X sub-id: 0x%08X\n",init_data.format,init_data.subformat);
-
- path = malloc(strlen(codec_path) + strlen(sh->codec->dll) + 2);
- if (!path) return 0;
- sprintf(path, "%s/%s", codec_path, sh->codec->dll);
-
- /* first try to load linux dlls, if failed and we're supporting win32 dlls,
- then try to load the windows ones */
-#ifdef HAVE_LIBDL
- if(strstr(sh->codec->dll,".dll") || !load_syms_linux(path))
-#endif
-#ifdef CONFIG_WIN32DLL
- if (!load_syms_windows(sh->codec->dll))
-#endif
- {
- mp_tmsg(MSGT_DECVIDEO,MSGL_ERR,"ERROR: Could not open required DirectShow codec %s.\n",sh->codec->dll);
- mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Read the RealVideo section of the DOCS!\n");
- free(path);
- return 0;
- }
- free(path);
- // only I420 supported
-// if((sh->format!=0x30335652) && !mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0;
- // init codec:
- sh->context=NULL;
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- result=(*wrvyuv_init)(&init_data, &sh->context);
- else
-#endif
- result=(*rvyuv_init)(&init_data, &sh->context);
- if (result){
- mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Couldn't open RealVideo codec, error code: 0x%X \n",result);
- return 0;
- }
- // setup rv30 codec (codec sub-type and image dimensions):
- if((sh->format<=0x30335652) && AV_RB32(extrahdr + 4)>=0x20200002){
- int i, cmsg_cnt;
- uint32_t cmsg24[16]={sh->disp_w,sh->disp_h};
- cmsg_data_t cmsg_data={0x24,1+(extrahdr[1]&7), &cmsg24[0]};
-
- mp_msg(MSGT_DECVIDEO,MSGL_V,"realvideo: using cmsg24 with %u elements.\n",extrahdr[1]&7);
- cmsg_cnt = (extrahdr[1]&7)*2;
- if (extrahdr_size-8 < cmsg_cnt) {
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,"realvideo: not enough extradata (%u) to make %u cmsg24 elements.\n",extrahdr_size-8,extrahdr[1]&7);
- cmsg_cnt = extrahdr_size-8;
- }
- for (i = 0; i < cmsg_cnt; i++)
- cmsg24[2+i] = extrahdr[8+i]*4;
- if (extrahdr_size-8 > cmsg_cnt)
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,"realvideo: %u bytes of unknown extradata remaining.\n",extrahdr_size-8-cmsg_cnt);
-
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- (*wrvyuv_custom_message)(&cmsg_data,sh->context);
- else
-#endif
- (*rvyuv_custom_message)(&cmsg_data,sh->context);
- }
- mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: RealVideo codec init OK!\n");
- return 1;
-}
-
-// uninit driver
-static void uninit(sh_video_t *sh){
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- {
- if (wrvyuv_free) wrvyuv_free(sh->context);
- } else
-#endif
- if(rvyuv_free) rvyuv_free(sh->context);
-
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- {
- if (rv_handle) FreeLibrary(rv_handle);
- } else
-#endif
-#ifdef HAVE_LIBDL
- if(rv_handle) dlclose(rv_handle);
-#endif
- rv_handle=NULL;
- initialized = 0;
- free(buffer);
- buffer = NULL;
- bufsz = 0;
-}
-
-// decode a frame
-static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
- mp_image_t* mpi;
- unsigned long result;
- uint8_t *buf = data;
- int chunks = *buf++;
- int extra_size = 8*(chunks+1);
- uint32_t data_size = len-1-extra_size;
- unsigned char* dp_data=buf+extra_size;
- uint32_t* extra=(uint32_t*)buf;
- int i;
-
- unsigned int transform_out[5];
- transform_in_t transform_in={
- data_size, // length of the packet (sub-packets appended)
- 0, // unknown, seems to be unused
- chunks, // number of sub-packets - 1
- extra, // table of sub-packet offsets
- 0, // unknown, seems to be unused
- 0, // timestamp (should be unneded)
- };
-
- if(len<=0 || flags&2) return NULL; // skipped frame || hardframedrop
-
- if (bufsz < sh->disp_w*sh->disp_h*3/2) {
- free(buffer);
- bufsz = sh->disp_w*sh->disp_h*3/2;
- buffer=malloc(bufsz);
- if (!buffer) return 0;
- }
-
- for (i=0; i<2*(chunks+1); i++)
- extra[i] = le2me_32(extra[i]);
-
-#ifdef CONFIG_WIN32DLL
- if (dll_type == 1)
- result=(*wrvyuv_transform)(dp_data, buffer, &transform_in,
- transform_out, sh->context);
- else
-#endif
- result=(*rvyuv_transform)(dp_data, buffer, &transform_in,
- transform_out, sh->context);
-
- if(!initialized){ // rv30 width/height now known
- sh->aspect=(float)sh->disp_w/(float)sh->disp_h;
- sh->disp_w=transform_out[3];
- sh->disp_h=transform_out[4];
- if (!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_I420)) return 0;
- initialized=1;
- }
- mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
- sh->disp_w, sh->disp_h);
- if(!mpi) return NULL;
- mpi->planes[0] = buffer;
- mpi->stride[0] = sh->disp_w;
- mpi->planes[1] = buffer + sh->disp_w*sh->disp_h;
- mpi->stride[1] = sh->disp_w / 2;
- mpi->planes[2] = buffer + sh->disp_w*sh->disp_h*5/4;
- mpi->stride[2] = sh->disp_w / 2;
-
- if(transform_out[0] &&
- (sh->disp_w != transform_out[3] || sh->disp_h != transform_out[4]))
- initialized = 0;
-
- return result ? NULL : mpi;
-}
diff --git a/libmpcodecs/vd_vfw.c b/libmpcodecs/vd_vfw.c
deleted file mode 100644
index 707589c869..0000000000
--- a/libmpcodecs/vd_vfw.c
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "config.h"
-#include "mp_msg.h"
-
-#include "vd_internal.h"
-#include "libmpdemux/aviprint.h"
-#include "loader/wine/driver.h"
-#include "loader/wine/vfw.h"
-
-static const vd_info_t info = {
-#ifdef BUILD_VFWEX
- "Win32/VfWex video codecs",
- "vfwex",
-#else
- "Win32/VfW video codecs",
- "vfw",
-#endif
- "A'rpi & Alex",
- "avifile.sf.net",
- "win32 codecs"
-};
-
-#ifdef BUILD_VFWEX
-LIBVD_EXTERN(vfwex)
-#else
-LIBVD_EXTERN(vfw)
-#endif
-
-typedef struct {
- BITMAPINFOHEADER *o_bih;
- HIC handle;
- unsigned char *palette;
-} vd_vfw_ctx;
-
-static int vfw_set_postproc(sh_video_t* sh, int quality)
-{
- vd_vfw_ctx *priv = sh->context;
- // Works only with opendivx/divx4 based DLL
- return ICSendMessage(priv->handle, ICM_USER+80, (long)(&quality), 0);
-}
-
-static void set_csp(BITMAPINFOHEADER *o_bih,unsigned int outfmt){
- int yuv = 0;
-
- switch (outfmt)
- {
- /* planar format */
- case IMGFMT_YV12:
- case IMGFMT_I420:
- case IMGFMT_IYUV:
- o_bih->biBitCount=12;
- yuv=1;
- break;
- case IMGFMT_YVU9:
- case IMGFMT_IF09:
- o_bih->biBitCount=9;
- yuv=1;
- break;
- /* packed format */
- case IMGFMT_YUY2:
- case IMGFMT_UYVY:
- case IMGFMT_YVYU:
- o_bih->biBitCount=16;
- yuv=1;
- break;
- /* rgb/bgr format */
- case IMGFMT_RGB8:
- case IMGFMT_BGR8:
- o_bih->biBitCount=8;
- break;
- case IMGFMT_RGB15:
- case IMGFMT_RGB16:
- case IMGFMT_BGR15:
- case IMGFMT_BGR16:
- o_bih->biBitCount=16;
- break;
- case IMGFMT_RGB24:
- case IMGFMT_BGR24:
- o_bih->biBitCount=24;
- break;
- case IMGFMT_RGB32:
- case IMGFMT_BGR32:
- o_bih->biBitCount=32;
- break;
- default:
- mp_msg(MSGT_WIN32,MSGL_ERR,"Unsupported image format: %s\n", vo_format_name(outfmt));
- return;
- }
-
- o_bih->biSizeImage = abs(o_bih->biWidth * o_bih->biHeight * (o_bih->biBitCount/8));
-
-// Note: we cannot rely on sh->outfmtidx here, it's undefined at this stage!!!
-// if (yuv && !(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK))
- if (yuv)
- o_bih->biCompression = outfmt;
- else
- o_bih->biCompression = 0;
-}
-
-// to set/get/query special features/parameters
-static int control(sh_video_t *sh,int cmd,void* arg,...){
- vd_vfw_ctx *priv = sh->context;
- switch(cmd){
- case VDCTRL_QUERY_MAX_PP_LEVEL:
- return 9;
- case VDCTRL_SET_PP_LEVEL:
- vfw_set_postproc(sh,10*(*((int*)arg)));
- return CONTROL_OK;
- // FIXME: make this optional...
- case VDCTRL_QUERY_FORMAT:
- {
- HRESULT ret;
- if(!(sh->codec->outflags[sh->outfmtidx]&CODECS_FLAG_QUERY))
- return CONTROL_UNKNOWN; // do not query!
- set_csp(priv->o_bih,*((int*)arg));
-#ifdef BUILD_VFWEX
- ret = ICDecompressQueryEx(priv->handle, sh->bih, priv->o_bih);
-#else
- ret = ICDecompressQuery(priv->handle, sh->bih, priv->o_bih);
-#endif
- if (ret)
- {
- mp_msg(MSGT_WIN32, MSGL_DBG2, "ICDecompressQuery failed:: Error %d\n", (int)ret);
- return CONTROL_FALSE;
- }
- return CONTROL_TRUE;
- }
- }
- return CONTROL_UNKNOWN;
-}
-
-// init driver
-static int init(sh_video_t *sh){
- HRESULT ret;
-// unsigned int outfmt=sh->codec->outfmt[sh->outfmtidx];
- int o_bih_len;
- vd_vfw_ctx *priv;
-
- /* Hack for VSSH codec: new dll can't decode old files
- * In my samples old files have no extradata, so use that info
- * to decide what dll should be used (here and in vd_dshow).
- */
- if (!strcmp(sh->codec->dll, "vssh264.dll") && (sh->bih->biSize > 40))
- return 0;
-
- priv = malloc(sizeof(vd_vfw_ctx));
- if (!priv)
- return 0;
- memset(priv, 0, sizeof(vd_vfw_ctx));
- sh->context = priv;
-
- mp_msg(MSGT_WIN32,MSGL_V,"======= Win32 (VFW) VIDEO Codec init =======\n");
-
-
-// win32_codec_name = sh->codec->dll;
-// sh->hic = ICOpen( 0x63646976, sh->bih->biCompression, ICMODE_FASTDECOMPRESS);
-// priv->handle = ICOpen( 0x63646976, sh->bih->biCompression, ICMODE_DECOMPRESS);
- priv->handle = ICOpen( (long)(sh->codec->dll), sh->bih->biCompression, ICMODE_DECOMPRESS);
- if(!priv->handle){
- mp_msg(MSGT_WIN32,MSGL_ERR,"ICOpen failed! unknown codec / wrong parameters?\n");
- return 0;
- }
-
-// sh->bih->biBitCount=32;
-
- o_bih_len = ICDecompressGetFormatSize(priv->handle, sh->bih);
-
- if(o_bih_len < sizeof(BITMAPINFOHEADER)){
- mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormatSize returned a bogus value: %d\n", o_bih_len);
- return 0;
- }
-
- priv->o_bih = malloc(o_bih_len);
- memset(priv->o_bih, 0, o_bih_len);
-
- mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormatSize ret: %d\n", o_bih_len);
-
- ret = ICDecompressGetFormat(priv->handle, sh->bih, priv->o_bih);
- if(ret < 0){
- mp_msg(MSGT_WIN32,MSGL_ERR,"ICDecompressGetFormat failed: Error %d\n", (int)ret);
- //for (i=0; i < o_bih_len; i++) mp_msg(MSGT_WIN32, MSGL_DBG2, "%02x ", priv->o_bih[i]);
- return 0;
- }
- mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetFormat OK\n");
-
-#if 0
- // workaround for pegasus MJPEG:
- if(!sh_video->o_bih.biWidth) sh_video->o_bih.biWidth=sh_video->bih->biWidth;
- if(!sh_video->o_bih.biHeight) sh_video->o_bih.biHeight=sh_video->bih->biHeight;
- if(!sh_video->o_bih.biPlanes) sh_video->o_bih.biPlanes=sh_video->bih->biPlanes;
-#endif
-
- // ok let libvo and vd core to handshake and decide the optimal csp:
- if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
-
- if (!(sh->codec->outflags[sh->outfmtidx]&CODECS_FLAG_FLIP)) {
- priv->o_bih->biHeight=-sh->bih->biHeight; // flip image!
- }
-
- // ok, let's set the choosen colorspace:
- set_csp(priv->o_bih,sh->codec->outfmt[sh->outfmtidx]);
-
- // fake it to RGB for broken DLLs (divx3)
- if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK)
- priv->o_bih->biCompression = 0;
-
- // sanity check:
-#ifdef BUILD_VFWEX
- ret = ICDecompressQueryEx(priv->handle, sh->bih, priv->o_bih);
-#else
- ret = ICDecompressQuery(priv->handle, sh->bih, priv->o_bih);
-#endif
- if (ret)
- {
- mp_msg(MSGT_WIN32,MSGL_WARN,"ICDecompressQuery failed: Error %d\n", (int)ret);
-// return 0;
- } else
- mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressQuery OK\n");
-
-#ifdef BUILD_VFWEX
- ret = ICDecompressBeginEx(priv->handle, sh->bih, priv->o_bih);
-#else
- ret = ICDecompressBegin(priv->handle, sh->bih, priv->o_bih);
-#endif
- if (ret)
- {
- mp_msg(MSGT_WIN32,MSGL_WARN,"ICDecompressBegin failed: Error %d\n", (int)ret);
-// return 0;
- }
-
- // for broken codecs set it again:
- if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_YUVHACK)
- set_csp(priv->o_bih,sh->codec->outfmt[sh->outfmtidx]);
-
- mp_msg(MSGT_WIN32, MSGL_V, "Input format:\n");
- if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_video_header(sh->bih,MSGL_V);
- mp_msg(MSGT_WIN32, MSGL_V, "Output format:\n");
- if( mp_msg_test(MSGT_HEADER,MSGL_V) ) print_video_header(priv->o_bih,MSGL_V);
-
- // set postprocessing level in xvid/divx4 .dll
- ICSendMessage(priv->handle, ICM_USER+80, (long)(&divx_quality), 0);
-
- // don't do this palette mess always, it makes div3 dll crashing...
- if(sh->codec->outfmt[sh->outfmtidx]==IMGFMT_BGR8){
- if(ICDecompressGetPalette(priv->handle, sh->bih, priv->o_bih)){
- priv->palette = (unsigned char*)(priv->o_bih+1);
- mp_msg(MSGT_WIN32,MSGL_V,"ICDecompressGetPalette OK\n");
- } else {
- if(sh->bih->biSize>=40+4*4)
- priv->palette = (unsigned char*)(sh->bih+1);
- }
- }
-
- mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32 video codec init OK!\n");
- return 1;
-}
-
-// uninit driver
-static void uninit(sh_video_t *sh){
- HRESULT ret;
- vd_vfw_ctx *priv = sh->context;
-
-#ifdef BUILD_VFWEX
- ret = ICDecompressEndEx(priv->handle);
-#else
- ret = ICDecompressEnd(priv->handle);
-#endif
- if (ret)
- {
- mp_msg(MSGT_WIN32, MSGL_WARN, "ICDecompressEnd failed: %ld\n", ret);
- return;
- }
-
- ret = ICClose(priv->handle);
- if (ret)
- {
- mp_msg(MSGT_WIN32, MSGL_WARN, "ICClose failed: %ld\n", ret);
- return;
- }
-
- free(priv->o_bih);
- free(priv);
-}
-
-// decode a frame
-static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
- vd_vfw_ctx *priv = sh->context;
- mp_image_t* mpi;
- HRESULT ret;
-
- if(len<=0) return NULL; // skipped frame
-
- mpi=mpcodecs_get_image(sh,
- (sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_STATIC) ?
- MP_IMGTYPE_STATIC : MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_WIDTH,
- sh->disp_w, sh->disp_h);
- if(!mpi){ // temporary!
- mp_tmsg(MSGT_DECVIDEO,MSGL_WARN,"[VD_DMO] Couldn't allocate image for cinepak codec.\n");
- return NULL;
- }
-
- // set stride: (trick discovered by Andreas Ackermann - thanx!)
- sh->bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);
- priv->o_bih->biWidth=mpi->width; //mpi->stride[0]/(mpi->bpp/8);
-
- sh->bih->biSizeImage = len;
-
-#ifdef BUILD_VFWEX
- ret = ICDecompressEx(priv->handle,
-#else
- ret = ICDecompress(priv->handle,
-#endif
- ( sh->ds->keyframe ? 0 : ICDECOMPRESS_NOTKEYFRAME ) |
- ( (flags&3) == 2 && !sh->ds->keyframe ?
- ICDECOMPRESS_HURRYUP|ICDECOMPRESS_PREROL : 0 ),
- sh->bih, data, priv->o_bih, (flags&3) ? 0 : mpi->planes[0]);
-
- if ((int)ret){
- mp_msg(MSGT_DECVIDEO,MSGL_WARN,"Error decompressing frame, err=%ld\n",ret);
- return NULL;
- }
-
- // export palette:
- if(mpi->imgfmt==IMGFMT_RGB8 || mpi->imgfmt==IMGFMT_BGR8){
- if (priv->palette)
- {
- mpi->planes[1] = priv->palette;
- mp_dbg(MSGT_DECVIDEO, MSGL_DBG2, "Found and copied palette\n");
- }
- else
- mpi->planes[1]=NULL;
- }
-
- return mpi;
-}
diff --git a/libmpcodecs/vd_vfwex.c b/libmpcodecs/vd_vfwex.c
deleted file mode 100644
index 630cbb0c5d..0000000000
--- a/libmpcodecs/vd_vfwex.c
+++ /dev/null
@@ -1,4 +0,0 @@
-
-#define BUILD_VFWEX 1
-
-#include "vd_vfw.c"
diff --git a/libmpcodecs/vd_xanim.c b/libmpcodecs/vd_xanim.c
deleted file mode 100644
index 58b79fecfc..0000000000
--- a/libmpcodecs/vd_xanim.c
+++ /dev/null
@@ -1,854 +0,0 @@
-/*
- * XAnim Video Codec DLL support
- *
- * It partly emulates the Xanim codebase.
- * You need the -rdynamic flag to use this with gcc.
- *
- * Copyright (C) 2001-2002 Alex Beregszaszi
- * Arpad Gereoffy <arpi@thot.banki.hu>
- *
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h> /* strerror */
-
-#include "config.h"
-#include "path.h"
-#include "mp_msg.h"
-
-#include "vd_internal.h"
-
-static const vd_info_t info = {
- "XAnim codecs",
- "xanim",
- "A'rpi & Alex",
- "Xanim (http://xanim.va.pubnix.com/)",
- "binary codec plugins"
-};
-
-LIBVD_EXTERN(xanim)
-
-#ifdef __FreeBSD__
-#include <unistd.h>
-#endif
-
-#include <dlfcn.h> /* dlsym, dlopen, dlclose */
-#include <stdarg.h> /* va_alist, va_start, va_end */
-#include <errno.h> /* strerror, errno */
-
-#include "mp_msg.h"
-#include "mpbswap.h"
-
-#include "osdep/timer.h"
-
-#if 0
-/* this should be removed */
-#ifndef RTLD_NOW
-#define RLTD_NOW 2
-#endif
-#ifndef RTLD_LAZY
-#define RLTD_LAZY 1
-#endif
-#ifndef RTLD_GLOBAL
-#define RLTD_GLOBAL 256
-#endif
-#endif
-
-struct XA_CODEC_HDR;
-struct XA_DEC_INFO;
-
-typedef long init_function(struct XA_CODEC_HDR *);
-typedef unsigned int decode_function(unsigned char *, unsigned char *,
- unsigned int, struct XA_DEC_INFO *);
-
-typedef struct
-{
- unsigned int what;
- unsigned int id;
- init_function *iq_func; /* init/query function */
- decode_function *dec_func; /* opt decode function */
-} XAVID_FUNC_HDR;
-
-#define XAVID_WHAT_NO_MORE 0x0000
-#define XAVID_AVI_QUERY 0x0001
-#define XAVID_QT_QUERY 0x0002
-#define XAVID_DEC_FUNC 0x0100
-
-#define XAVID_API_REV 0x0003
-
-typedef struct
-{
- unsigned int api_rev;
- char *desc;
- char *rev;
- char *copyright;
- char *mod_author;
- char *authors;
- unsigned int num_funcs;
- XAVID_FUNC_HDR *funcs;
-} XAVID_MOD_HDR;
-
-/* XA CODEC .. */
-typedef struct XA_CODEC_HDR
-{
- void *anim_hdr;
- unsigned int compression;
- unsigned int x, y;
- unsigned int depth;
- void *extra;
- unsigned int xapi_rev;
- decode_function *decoder;
- char *description;
- unsigned int avi_ctab_flag;
- unsigned int (*avi_read_ext)(void);
-} XA_CODEC_HDR;
-
-#define CODEC_SUPPORTED 1
-#define CODEC_UNKNOWN 0
-#define CODEC_UNSUPPORTED -1
-
-/* fuckin colormap structures for xanim */
-typedef struct
-{
- unsigned short red;
- unsigned short green;
- unsigned short blue;
- unsigned short gray;
-} ColorReg;
-
-typedef struct XA_ACTION_STRUCT
-{
- int type;
- int cmap_rev;
- unsigned char *data;
- struct XA_ACTION_STRUCT *next;
- struct XA_CHDR_STRUCT *chdr;
- ColorReg *h_cmap;
- unsigned int *map;
- struct XA_ACTION_STRUCT *next_same_chdr;
-} XA_ACTION;
-
-typedef struct XA_CHDR_STRUCT
-{
- unsigned int rev;
- ColorReg *cmap;
- unsigned int csize, coff;
- unsigned int *map;
- unsigned int msize, moff;
- struct XA_CHDR_STRUCT *next;
- XA_ACTION *acts;
- struct XA_CHDR_STRUCT *new_chdr;
-} XA_CHDR;
-
-typedef struct XA_DEC_INFO
-{
- unsigned int cmd;
- unsigned int skip_flag;
- unsigned int imagex, imagey; /* image buffer size */
- unsigned int imaged; /* image depth */
- XA_CHDR *chdr; /* color map header */
- unsigned int map_flag;
- unsigned int *map;
- unsigned int xs, ys;
- unsigned int xe, ye;
- unsigned int special;
- void *extra;
-} XA_DEC_INFO;
-
-typedef struct
-{
- unsigned int file_num;
- unsigned int anim_type;
- unsigned int imagex;
- unsigned int imagey;
- unsigned int imagec;
- unsigned int imaged;
-} XA_ANIM_HDR;
-
-typedef struct {
- XA_DEC_INFO *decinfo;
- void *file_handler;
- init_function *iq_func;
- decode_function *dec_func;
- mp_image_t *mpi;
-} vd_xanim_ctx;
-
-#if 0
-typedef char xaBYTE;
-typedef short xaSHORT;
-typedef int xaLONG;
-
-typedef unsigned char xaUBYTE;
-typedef unsigned short xaUSHORT;
-typedef unsigned int xaULONG;
-#endif
-
-#define xaFALSE 0
-#define xaTRUE 1
-
-#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
-
-#define XA_CLOSE_FUNCS 5
-int xa_close_funcs = 0;
-void *xa_close_func[XA_CLOSE_FUNCS];
-
-/* load, init and query */
-static int xacodec_load(sh_video_t *sh, char *filename)
-{
- vd_xanim_ctx *priv = sh->context;
- void *(*what_the)(void);
- char *error;
- XAVID_MOD_HDR *mod_hdr;
- XAVID_FUNC_HDR *func;
- int i;
-
-// priv->file_handler = dlopen(filename, RTLD_NOW|RTLD_GLOBAL);
- priv->file_handler = dlopen(filename, RTLD_LAZY);
- if (!priv->file_handler)
- {
- error = dlerror();
- if (error)
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: failed to dlopen %s while %s\n", filename, error);
- else
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: failed to dlopen %s\n", filename);
- return 0;
- }
-
- what_the = dlsym(priv->file_handler, "What_The");
- if ((error = dlerror()) != NULL)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: failed to init %s while %s\n", filename, error);
- dlclose(priv->file_handler);
- return 0;
- }
-
- mod_hdr = what_the();
- if (!mod_hdr)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: initializer function failed in %s\n", filename);
- dlclose(priv->file_handler);
- return 0;
- }
-
- mp_msg(MSGT_DECVIDEO, MSGL_V, "=== XAnim Codec ===\n");
- mp_msg(MSGT_DECVIDEO, MSGL_V, " Filename: %s (API revision: %x)\n", filename, mod_hdr->api_rev);
- mp_msg(MSGT_DECVIDEO, MSGL_V, " Codec: %s. Rev: %s\n", mod_hdr->desc, mod_hdr->rev);
- if (mod_hdr->copyright)
- mp_msg(MSGT_DECVIDEO, MSGL_V, " %s\n", mod_hdr->copyright);
- if (mod_hdr->mod_author)
- mp_msg(MSGT_DECVIDEO, MSGL_V, " Module Author(s): %s\n", mod_hdr->mod_author);
- if (mod_hdr->authors)
- mp_msg(MSGT_DECVIDEO, MSGL_V, " Codec Author(s): %s\n", mod_hdr->authors);
-
- if (mod_hdr->api_rev > XAVID_API_REV)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: not supported api revision (%d) in %s\n",
- mod_hdr->api_rev, filename);
- dlclose(priv->file_handler);
- return 0;
- }
-
- func = mod_hdr->funcs;
- if (!func)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: function table error in %s\n", filename);
- dlclose(priv->file_handler);
- return 0;
- }
-
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Exported functions by codec: [functable: %p entries: %d]\n",
- mod_hdr->funcs, mod_hdr->num_funcs);
- for (i = 0; i < (int)mod_hdr->num_funcs; i++)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, " %d: %d %d [iq:%p d:%p]\n",
- i, func[i].what, func[i].id, func[i].iq_func, func[i].dec_func);
- if (func[i].what & XAVID_AVI_QUERY)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, " %p: avi init/query func (id: %d)\n",
- func[i].iq_func, func[i].id);
- priv->iq_func = func[i].iq_func;
- }
- if (func[i].what & XAVID_QT_QUERY)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, " %p: qt init/query func (id: %d)\n",
- func[i].iq_func, func[i].id);
- priv->iq_func = func[i].iq_func;
- }
- if (func[i].what & XAVID_DEC_FUNC)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, " %p: decoder func (init/query: %p) (id: %d)\n",
- func[i].dec_func, func[i].iq_func, func[i].id);
- priv->dec_func = func[i].dec_func;
- }
- }
- return 1;
-}
-
-static int xacodec_query(sh_video_t *sh, XA_CODEC_HDR *codec_hdr)
-{
- vd_xanim_ctx *priv = sh->context;
- long ret;
-
-#if 0
- /* the brute one */
- if (priv->dec_func)
- {
- codec_hdr->decoder = priv->dec_func;
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "We got decoder's address at init! %p\n", codec_hdr->decoder);
- return 1;
- }
-#endif
-
- ret = priv->iq_func(codec_hdr);
- switch(ret)
- {
- case CODEC_SUPPORTED:
- priv->dec_func = codec_hdr->decoder;
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Codec is supported: found decoder for %s at %p\n",
- codec_hdr->description, codec_hdr->decoder);
- return 1;
- case CODEC_UNSUPPORTED:
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "Codec (%s) is unsupported by dll\n",
- codec_hdr->description);
- return 0;
- case CODEC_UNKNOWN:
- default:
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "Codec (%s) is unknown by dll\n",
- codec_hdr->description);
- return 0;
- }
-}
-
-/* These functions are required for loading XAnim binary libs.
- * Add forward declarations to avoid warnings with -Wmissing-prototypes. */
-void XA_Print(char *fmt, ...);
-void TheEnd1(char *err_mess);
-void XA_Add_Func_To_Free_Chain(XA_ANIM_HDR *anim_hdr, void (*function)(void));
-unsigned long XA_Time_Read(void);
-void XA_Gen_YUV_Tabs(XA_ANIM_HDR *anim_hdr);
-void JPG_Setup_Samp_Limit_Table(XA_ANIM_HDR *anim_hdr);
-void JPG_Alloc_MCU_Bufs(XA_ANIM_HDR *anim_hdr, unsigned int width,
- unsigned int height, unsigned int full_flag);
-void *YUV2x2_Blk_Func(unsigned int image_type, int blks,
- unsigned int dith_flag);
-void *YUV2x2_Map_Func(unsigned int image_type, unsigned int dith_type);
-void *XA_YUV1611_Func(unsigned int image_type);
-void *XA_YUV221111_Func(unsigned int image_type);
-
-void XA_Print(char *fmt, ...)
-{
- va_list vallist;
- char buf[1024];
-
- va_start(vallist, fmt);
- vsnprintf(buf, 1024, fmt, vallist);
- mp_msg(MSGT_XACODEC, MSGL_DBG2, "[xacodec] %s\n", buf);
- va_end(vallist);
-
- return;
-}
-
-/* 0 is no debug (needed by 3ivX) */
-long xa_debug = 0;
-
-void TheEnd1(char *err_mess)
-{
- XA_Print("error: %s - exiting\n", err_mess);
- /* we should exit here... */
-
- return;
-}
-
-void XA_Add_Func_To_Free_Chain(XA_ANIM_HDR *anim_hdr, void (*function)(void))
-{
-// XA_Print("XA_Add_Func_To_Free_Chain('anim_hdr: %08x', 'function: %08x')",
-// anim_hdr, function);
- xa_close_func[xa_close_funcs] = function;
- if (xa_close_funcs+1 < XA_CLOSE_FUNCS)
- xa_close_funcs++;
-
- return;
-}
-
-unsigned long XA_Time_Read(void)
-{
- return GetTimer(); //(GetRelativeTime());
-}
-
-static void XA_dummy(void)
-{
- XA_Print("dummy() called");
-}
-
-void XA_Gen_YUV_Tabs(XA_ANIM_HDR *anim_hdr)
-{
- XA_Print("XA_Gen_YUV_Tabs('anim_hdr: %08x')", anim_hdr);
- return;
-}
-
-void JPG_Setup_Samp_Limit_Table(XA_ANIM_HDR *anim_hdr)
-{
- XA_Print("JPG_Setup_Samp_Limit_Table('anim_hdr: %08x')", anim_hdr);
- return;
-}
-
-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);
- return;
-}
-
-/* --------------- 4x4 pixel YUV block fillers [CVID] ----------------- */
-
-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;
-
-#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;
-
-static void XA_2x2_OUT_1BLK_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
- unsigned int imagex, XA_2x2_Color *cmap2x2)
-{
- mp_image_t *mpi = (mp_image_t *)image_p;
-
-#if 0
- SET_4_YUV_PIXELS(mpi,x,y,cmap2x2)
-#else
- SET_4_YUV_PIXELS(mpi,x,y,cmap2x2)
- SET_4_YUV_PIXELS(mpi,x+2,y,cmap2x2)
- SET_4_YUV_PIXELS(mpi,x,y+2,cmap2x2)
- SET_4_YUV_PIXELS(mpi,x+2,y+2,cmap2x2)
-#endif
-
- return;
-}
-
-static void XA_2x2_OUT_4BLKS_Convert(unsigned char *image_p, unsigned int x, unsigned int y,
- unsigned int imagex, XA_2x2_Color *cm0, XA_2x2_Color *cm1, XA_2x2_Color *cm2,
- XA_2x2_Color *cm3)
-{
- mp_image_t *mpi = (mp_image_t *)image_p;
-
- SET_4_YUV_PIXELS(mpi,x,y,cm0)
- SET_4_YUV_PIXELS(mpi,x+2,y,cm1)
- SET_4_YUV_PIXELS(mpi,x,y+2,cm2)
- SET_4_YUV_PIXELS(mpi,x+2,y+2,cm3)
- return;
-}
-
-void *YUV2x2_Blk_Func(unsigned int image_type, int blks, unsigned int dith_flag)
-{
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "YUV2x2_Blk_Func(image_type=%d, blks=%d, dith_flag=%d)\n",
- image_type, blks, dith_flag);
- switch(blks){
- case 1:
- return (void*) XA_2x2_OUT_1BLK_Convert;
- case 4:
- return (void*) XA_2x2_OUT_4BLKS_Convert;
- }
-
- 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;
-}
-
-// Take Four Y's and UV and put them into a 2x2 Color structure.
-
-static 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)
-{
-
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "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;
- cmap2x2->clr0_1=Y1;
- cmap2x2->clr0_2=Y2;
- cmap2x2->clr0_3=Y3;
- cmap2x2->clr1_0=U;
- cmap2x2->clr1_1=V;
- return;
-}
-
-void *YUV2x2_Map_Func(unsigned int image_type, unsigned int dith_type)
-{
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "YUV2x2_Map_Func('image_type: %d', 'dith_type: %d')",
- image_type, dith_type);
- return (void*)XA_YUV_2x2_clr;
-}
-
-/* -------------------- whole YUV frame converters ------------------------- */
-
-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;
-
-YUVBufs jpg_YUVBufs;
-YUVTabs def_yuv_tabs;
-
-/* -------------- YUV 4x4 1x1 1x1 (4:1:0 aka YVU9) [Indeo 3,4,5] ------------------ */
-
-static void XA_YUV1611_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
- unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs,
- unsigned int map_flag, unsigned int *map, XA_CHDR *chdr)
-{
- sh_video_t *sh = (sh_video_t*)image_p;
- vd_xanim_ctx *priv = sh->context;
- mp_image_t *mpi;
- int y;
- int ystride=(yuv->y_w)?yuv->y_w:imagex;
- int uvstride=(yuv->uv_w)?yuv->uv_w:(imagex/4);
-
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "YUVTabs: %ld %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 );
-
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "XA_YUV1611_Convert('image: %p', 'imagex: %d', 'imagey: %d', 'i_x: %d', 'i_y: %d', 'yuv_bufs: %p', 'yuv_tabs: %p', 'map_flag: %d', 'map: %p', 'chdr: %p')",
- image_p, imagex, imagey, i_x, i_y, yuv, yuv_tabs, map_flag, map, chdr);
-
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "YUV: %p %p %p %p (%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);
-
- if(!yuv_tabs->YUV_Y_tab){
- // standard YVU9 - simply export it!
- mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,
- sh->disp_w, sh->disp_h);
- priv->mpi=mpi; if(!mpi) return; // ERROR!
- mpi->planes[0]=yuv->Ybuf;
- mpi->planes[1]=yuv->Ubuf;
- mpi->planes[2]=yuv->Vbuf;
- mpi->width=imagex;
- mpi->stride[0]=ystride; //i_x; // yuv->y_w
- mpi->stride[1]=mpi->stride[2]=uvstride; //i_x/4; // yuv->uv_w
- return;
- }
-
- // allocate TEMP buffer and convert the image:
- mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
- sh->disp_w, sh->disp_h);
- priv->mpi=mpi; if(!mpi) return; // ERROR!
-
- // convert the Y plane:
- for(y=0;y<(int)imagey;y++){
- unsigned int x;
- unsigned char* s=yuv->Ybuf+ystride*y;
- unsigned char* d=mpi->planes[0]+mpi->stride[0]*y;
- for(x=0;x<imagex;x++) d[x]=s[x]<<1;
- }
-
- imagex>>=2;
- imagey>>=2;
-
- // convert the U plane:
- for(y=0;y<(int)imagey;y++){
- unsigned int x;
- unsigned char* s=yuv->Ubuf+uvstride*y;
- unsigned char* d=mpi->planes[1]+mpi->stride[1]*y;
- for(x=0;x<imagex;x++) d[x]=s[x]<<1;
- }
-
- // convert the V plane:
- for(y=0;y<(int)imagey;y++){
- unsigned int x;
- unsigned char* s=yuv->Vbuf+uvstride*y;
- unsigned char* d=mpi->planes[2]+mpi->stride[2]*y;
- for(x=0;x<imagex;x++) d[x]=s[x]<<1;
- }
-}
-
-void *XA_YUV1611_Func(unsigned int image_type)
-{
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "XA_YUV1611_Func('image_type: %d')", image_type);
- return (void *)XA_YUV1611_Convert;
-}
-
-/* --------------- YUV 2x2 1x1 1x1 (4:2:0 aka YV12) [3ivX,H263] ------------ */
-
-static void XA_YUV221111_Convert(unsigned char *image_p, unsigned int imagex, unsigned int imagey,
- unsigned int i_x, unsigned int i_y, YUVBufs *yuv, YUVTabs *yuv_tabs, unsigned int map_flag,
- unsigned int *map, XA_CHDR *chdr)
-{
- sh_video_t *sh = (sh_video_t*)image_p;
- vd_xanim_ctx *priv = sh->context;
- mp_image_t *mpi;
- // note: 3ivX codec doesn't set y_w, uv_w, they are random junk :(
- int ystride=imagex; //(yuv->y_w)?yuv->y_w:imagex;
- int uvstride=imagex/2; //(yuv->uv_w)?yuv->uv_w:(imagex/2);
-
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "XA_YUV221111_Convert(%p %dx%d %d;%d [%dx%d] %p %p %d %p %p)\n",
- image_p,imagex,imagey,i_x,i_y, sh->disp_w, sh->disp_h,
- yuv,yuv_tabs,map_flag,map,chdr);
-
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG3, "YUV: %p %p %p %p (%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);
-
- // standard YV12 - simply export it!
- mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, sh->disp_w, sh->disp_h);
- priv->mpi=mpi; if(!mpi) return; // ERROR!
- mpi->planes[0]=yuv->Ybuf;
- mpi->planes[1]=yuv->Ubuf;
- mpi->planes[2]=yuv->Vbuf;
- mpi->width=imagex;
- mpi->stride[0]=ystride; //i_x; // yuv->y_w
- mpi->stride[1]=mpi->stride[2]=uvstride; //=i_x/4; // yuv->uv_w
-}
-
-void *XA_YUV221111_Func(unsigned int image_type)
-{
- mp_dbg(MSGT_DECVIDEO,MSGL_DBG2, "XA_YUV221111_Func('image_type: %d')\n",image_type);
- return (void *)XA_YUV221111_Convert;
-}
-
-/* *** EOF XANIM *** */
-
-// to set/get/query special features/parameters
-static int control(sh_video_t *sh,int cmd,void* arg,...){
- return CONTROL_UNKNOWN;
-}
-
-// init driver
-static int init(sh_video_t *sh)
-{
- vd_xanim_ctx *priv;
- char dll[1024];
- XA_CODEC_HDR codec_hdr;
- int i;
-
- priv = malloc(sizeof(vd_xanim_ctx));
- if (!priv)
- return 0;
- sh->context = priv;
- memset(priv, 0, sizeof(vd_xanim_ctx));
-
- if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12)) return 0;
-
- priv->iq_func = NULL;
- priv->dec_func = NULL;
-
- for (i=0; i < XA_CLOSE_FUNCS; i++)
- xa_close_func[i] = NULL;
-
- snprintf(dll, 1024, "%s/%s", codec_path, sh->codec->dll);
- if (xacodec_load(sh, dll) == 0)
- return 0;
-
- codec_hdr.xapi_rev = XAVID_API_REV;
- codec_hdr.anim_hdr = malloc(4096);
- codec_hdr.description = sh->codec->info;
- codec_hdr.compression = bswap_32(sh->bih->biCompression);
- codec_hdr.decoder = NULL;
- codec_hdr.x = sh->bih->biWidth; /* ->disp_w */
- codec_hdr.y = sh->bih->biHeight; /* ->disp_h */
- /* extra fields to store palette */
- codec_hdr.avi_ctab_flag = 0;
- codec_hdr.avi_read_ext = NULL;
- codec_hdr.extra = NULL;
-
- switch(sh->codec->outfmt[sh->outfmtidx])
- {
- case IMGFMT_BGR32:
- codec_hdr.depth = 32;
- break;
- case IMGFMT_BGR24:
- codec_hdr.depth = 24;
- break;
- case IMGFMT_IYUV:
- case IMGFMT_I420:
- case IMGFMT_YV12:
- codec_hdr.depth = 12;
- break;
- case IMGFMT_YVU9:
- codec_hdr.depth = 9;
- break;
- default:
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: not supported image out format (%s)\n",
- vo_format_name(sh->codec->outfmt[sh->outfmtidx]));
- return 0;
- }
- 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);
-
- if (xacodec_query(sh, &codec_hdr) == 0)
- return 0;
-
-// free(codec_hdr.anim_hdr);
-
- priv->decinfo = malloc(sizeof(XA_DEC_INFO));
- if (priv->decinfo == NULL)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_FATAL, "xacodec: memory allocation error: %s\n",
- strerror(errno));
- return 0;
- }
- priv->decinfo->cmd = 0;
- priv->decinfo->skip_flag = 0;
- priv->decinfo->imagex = priv->decinfo->xe = codec_hdr.x;
- priv->decinfo->imagey = priv->decinfo->ye = codec_hdr.y;
- priv->decinfo->imaged = codec_hdr.depth;
- priv->decinfo->chdr = NULL;
- priv->decinfo->map_flag = 0; /* xaFALSE */
- priv->decinfo->map = NULL;
- priv->decinfo->xs = priv->decinfo->ys = 0;
- priv->decinfo->special = 0;
- priv->decinfo->extra = codec_hdr.extra;
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "decinfo->extra, filled by codec: %p [%s]\n",
- &priv->decinfo->extra, (char *)priv->decinfo->extra);
-
- return 1;
-}
-
-// uninit driver
-static void uninit(sh_video_t *sh)
-{
- vd_xanim_ctx *priv = sh->context;
- int i;
- void (*close_func)(void);
-
- for (i=0; i < XA_CLOSE_FUNCS; i++)
- if (xa_close_func[i])
- {
- close_func = xa_close_func[i];
- close_func();
- }
- dlclose(priv->file_handler);
- free(priv->decinfo);
- free(priv);
-}
-
-// unsigned int (*dec_func)(unsigned char *image, unsigned char *delta,
-// unsigned int dsize, XA_DEC_INFO *dec_info);
-
-// decode a frame
-static mp_image_t* decode(sh_video_t *sh, void *data, int len, int flags)
-{
- vd_xanim_ctx *priv = sh->context;
- unsigned int ret;
-
- if (len <= 0)
- return NULL; // skipped frame
-
- priv->decinfo->skip_flag = (flags&3)?1:0;
-
- if(sh->codec->outflags[sh->outfmtidx] & CODECS_FLAG_STATIC){
- // allocate static buffer for cvid-like codecs:
- priv->mpi = mpcodecs_get_image(sh, MP_IMGTYPE_STATIC,
- MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_PREFER_ALIGNED_STRIDE,
- (sh->disp_w+3)&(~3), (sh->disp_h+3)&(~3));
- if (!priv->mpi) return NULL;
- ret = priv->dec_func((uint8_t*)priv->mpi, data, len, priv->decinfo);
- } else {
- // left the buffer allocation to the codecs, pass sh_video && priv
- priv->mpi=NULL;
- ret = priv->dec_func((uint8_t*)sh, data, len, priv->decinfo);
- }
-
- if (ret == ACT_DLTA_NORM)
- return priv->mpi;
-
- if (ret & ACT_DLTA_MAPD)
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "mapd\n");
-/*
- if (!(ret & ACT_DLT_MAPD))
- xacodec_driver->decinfo->map_flag = 0;
- else
- {
- xacodec_driver->decinfo->map_flag = 1;
- xacodec_driver->decinfo->map = ...
- }
-*/
-
- if (ret & ACT_DLTA_XOR)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "xor\n");
- return priv->mpi;
- }
-
- /* nothing changed */
- if (ret & ACT_DLTA_NOP)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "nop\n");
- return NULL;
- }
-
- /* frame dropped (also display latest frame) */
- if (ret & ACT_DLTA_DROP)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "drop\n");
- return NULL;
- }
-
- if (ret & ACT_DLTA_BAD)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "bad\n");
- return NULL;
- }
-
- /* used for double buffer */
- if (ret & ACT_DLTA_BODY)
- {
- mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "body\n");
- return NULL;
- }
-
- return priv->mpi;
-}