diff -NpuBr -Xexclude.txt main/Makefile sherpya/Makefile --- main/Makefile 2011-12-07 02:25:23.531250000 +0100 +++ sherpya/Makefile 2011-12-07 02:30:28.218750000 +0100 @@ -270,6 +270,7 @@ SRCS_COMMON-$(WIN32DLL) += libmpcodecs/ad_twin.c \ libmpcodecs/vd_dmo.c \ libmpcodecs/vd_dshow.c \ + libmpcodecs/vd_dsnative.c \ libmpcodecs/vd_vfw.c \ libmpcodecs/vd_vfwex.c \ libmpdemux/demux_avs.c \ diff -NpuBr -Xexclude.txt main/etc/codecs.conf sherpya/etc/codecs.conf --- main/etc/codecs.conf 2011-12-07 02:25:29.281250000 +0100 +++ sherpya/etc/codecs.conf 2011-12-07 02:30:28.234375000 +0100 @@ -3943,6 +3943,97 @@ videocodec null out BGR32,BGR24,BGR16,BGR15 ;============================================================================= +; DSNATIVE VIDEO CODECS +;============================================================================= + +videocodec dsncoreavc + info "CoreAVC Video Decoder" + status working + fourcc H264,h264 + fourcc X264,x264 + fourcc avc1 AVC1,AVC1 + fourcc davc,DAVC + fourcc VSSH + format 0x10000005 + driver dsnative + dll "CoreAVCDecoder.ax" + guid 0x09571a4b, 0xf1fe, 0x4c60, 0x97, 0x60, 0xde, 0x6d, 0x31, 0x0c, 0x7c, 0x31 + out YV12,IYUV,I420,YUY2 + +videocodec dsndivxh264 + info "DivX H.264 Decoder" + status working + fourcc H264,h264 + fourcc X264,x264 + fourcc avc1 AVC1,AVC1 + fourcc davc,DAVC + fourcc VSSH + format 0x10000005 + driver dsnative + dll "DivXDecH264.ax" + guid 0x6f513d27, 0x97c3, 0x453c, 0x87, 0xfe, 0xb2, 0x4a, 0xe5, 0x0b, 0x16, 0x01 + out YV12,IYUV,I420,YUY2 + +videocodec dsnffdshow + info "ffdshow Video Decoder" + status working + fourcc H264,h264 + fourcc X264,x264 + fourcc avc1 AVC1,AVC1 + fourcc davc,DAVC + fourcc VSSH + format 0x10000005 + fourcc DIVX,divx + fourcc DIV1,div1 divx + fourcc MP4S,mp4s ; ISO MPEG-4 Video V1 + fourcc M4S2,m4s2 + fourcc xvid,XVID,XviD,XVIX + fourcc DX50,dx50,BLZ0 DX50 + fourcc mp4v,MP4V + fourcc FVFW,fvfw + driver dsnative + dll "ffdshow.ax" + guid 0x04fe9017, 0xf873, 0x410e, 0x87, 0x1e, 0xab, 0x91, 0x66, 0x1a, 0x4e, 0xf7 + out YV12,IYUV,I420,YUY2 + +videocodec dsnffdshowdxva + info "ffdshow DXVA Video Decoder" + status buggy + fourcc H264,h264 + fourcc X264,x264 + fourcc avc1 AVC1,AVC1 + fourcc davc,DAVC + fourcc VSSH + format 0x10000005 + driver dsnative + dll "ffdshow.ax" + guid 0x0b0eff97, 0xc750, 0x462c, 0x94, 0x88, 0xb1, 0x0e, 0x7d, 0x87, 0xf1, 0xa6 + out YV12,IYUV,I420,YUY2 + +videocodec dsndiavc + info "DiAVC H.264 Decoder (DiAVC)" + status working + fourcc H264,h264 + fourcc X264,x264 + fourcc avc1 AVC1,AVC1 + fourcc davc,DAVC + fourcc VSSH + format 0x10000005 + driver dsnative + dll "diavc.ax" + guid 0x5dfa20a4, 0xc343, 0x45df, 0xa4, 0x6e, 0xec, 0x17, 0x11, 0xe4, 0xee, 0x32 + out YV12,IYUV,I420,YUY2,RGB32,UYVY + +videocodec dsncineformhd + info "CineForm HD" + status working + fourcc CFHD + driver dsnative + dll "CFDecode2.ax" + guid 0xad83011e, 0x01d1, 0x4623, 0x91, 0xfd, 0x6b, 0x75, 0xf1, 0x83, 0xc5, 0xa9 + out YUY2 + +;============================================================================= ; AUDIO CODECS ;============================================================================= diff -NpuBr -Xexclude.txt main/libmpcodecs/vd.c sherpya/libmpcodecs/vd.c --- main/libmpcodecs/vd.c 2011-03-27 06:57:56.062500000 +0200 +++ sherpya/libmpcodecs/vd.c 2011-12-07 02:30:28.234375000 +0100 @@ -40,6 +40,7 @@ extern const vd_functions_t mpcodecs_vd_ extern const vd_functions_t mpcodecs_vd_ffmpeg; extern const vd_functions_t mpcodecs_vd_theora; extern const vd_functions_t mpcodecs_vd_dshow; +extern const vd_functions_t mpcodecs_vd_dsnative; extern const vd_functions_t mpcodecs_vd_dmo; extern const vd_functions_t mpcodecs_vd_vfw; extern const vd_functions_t mpcodecs_vd_vfwex; @@ -73,6 +74,7 @@ const vd_functions_t * const mpcodecs_vd #endif #ifdef CONFIG_WIN32DLL &mpcodecs_vd_dshow, + &mpcodecs_vd_dsnative, &mpcodecs_vd_dmo, &mpcodecs_vd_vfw, &mpcodecs_vd_vfwex, diff -NpuBr -Xexclude.txt main/libmpcodecs/vd_dsnative.c sherpya/libmpcodecs/vd_dsnative.c --- main/libmpcodecs/vd_dsnative.c 1970-01-01 01:00:00.000000000 +0100 +++ sherpya/libmpcodecs/vd_dsnative.c 2011-12-07 02:30:28.250000000 +0100 @@ -0,0 +1,160 @@ +#include +#include +#include + +#include "config.h" +#include "mp_msg.h" +#include "help_mp.h" +#include "vd_internal.h" + +#include "loader/wine/winbase.h" + +#ifdef WIN32_LOADER +#include "loader/ldt_keeper.h" +#endif + +#define DSN_OK 0 +#define DSN_API_VERSION 4 + +typedef struct _DSVideoCodec DSVideoCodec; +typedef DSVideoCodec * (WINAPI *funcDSOpenVideoCodec)(const char *dll, const GUID guid, BITMAPINFOHEADER* bih, + unsigned int outfmt, float fps, const char *filename, int *err); +typedef void (WINAPI *funcDSCloseVideoCodec)(DSVideoCodec *codec); +typedef int (WINAPI *funcDSVideoDecode)(DSVideoCodec *vcodec, const BYTE *src, int size, double pts, + double *newpts, BYTE *pImage, int keyframe); +typedef int (WINAPI *funcDSVideoResync)(DSVideoCodec *codec, double pts); +typedef const char * (WINAPI *funcDSStrError)(int error); +typedef unsigned int (WINAPI *funcDSGetApiVersion)(void); + +static const vd_info_t info = { + "DirectShow video codecs (native win32)", + "dsnative", + "Gianluigi Tiesi", + "using dsnative external dll wrapper", + "win32 codecs" +}; + +static struct +{ + HMODULE hLib; + funcDSOpenVideoCodec DSOpenVideoCodec; + funcDSCloseVideoCodec DSCloseVideoCodec; + funcDSVideoDecode DSVideoDecode; + funcDSVideoResync DSVideoResync; + funcDSStrError DSStrError; + funcDSGetApiVersion DSGetApiVersion; + DSVideoCodec *codec; +#ifdef WIN32_LOADER + ldt_fs_t* ldt_fs; +#endif +} dsn; + +LIBVD_EXTERN(dsnative) + +static int control(sh_video_t *sh, int cmd, void *arg, ...) +{ + switch (cmd) + { + case VDCTRL_RESYNC_STREAM: + dsn.DSVideoResync(dsn.codec, sh->pts); + return CONTROL_TRUE; + default: + return CONTROL_UNKNOWN; + } +} + +static int init(sh_video_t *sh) +{ + int err; + char fname[MAX_PATH + 1] = ""; +#ifdef WIN32_LOADER + dsn.ldt_fs = Setup_LDT_Keeper(); +#endif + + memset(&dsn, 0, sizeof(dsn)); + dsn.hLib = LoadLibraryA("dsnative.dll"); + //dsn.hLib = LoadLibraryA("C:\\Work\\mplayer\\wip\\core\\dsnative\\Debug\\dsnative.dll"); + + if (!dsn.hLib) + { + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dsnative] Cannot find dsnative dll: %ld\n", GetLastError()); + return 0; + } + + dsn.DSOpenVideoCodec = (funcDSOpenVideoCodec) GetProcAddress(dsn.hLib, "DSOpenVideoCodec"); + dsn.DSCloseVideoCodec = (funcDSCloseVideoCodec) GetProcAddress(dsn.hLib, "DSCloseVideoCodec"); + dsn.DSVideoDecode = (funcDSVideoDecode) GetProcAddress(dsn.hLib, "DSVideoDecode"); + dsn.DSVideoResync = (funcDSVideoResync) GetProcAddress(dsn.hLib, "DSVideoResync"); + dsn.DSStrError = (funcDSStrError) GetProcAddress(dsn.hLib, "DSStrError"); + dsn.DSGetApiVersion = (funcDSGetApiVersion) GetProcAddress(dsn.hLib, "DSGetApiVersion"); + + if (!(dsn.DSOpenVideoCodec && dsn.DSCloseVideoCodec && dsn.DSVideoDecode && dsn.DSVideoResync && dsn.DSStrError && dsn.DSGetApiVersion)) + { + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dsnative] dsnative dll symbol mismatch\n"); + return 0; + } + + if (dsn.DSGetApiVersion() != DSN_API_VERSION) + { + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dsnative] Incompatible API version\n"); + return 0; + } + + if (sh->ds->demuxer->filename) + GetFullPathNameA(sh->ds->demuxer->filename, MAX_PATH, fname, NULL); + + if (!(dsn.codec = dsn.DSOpenVideoCodec(sh->codec->dll, sh->codec->guid, sh->bih, + sh->codec->outfmt[sh->outfmtidx], sh->fps, fname, &err))) + { + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dsnative] Codec init failed: %s\n", dsn.DSStrError(err)); + return 0; + } + + if (!mpcodecs_config_vo(sh, sh->disp_w, sh->disp_h, IMGFMT_YUY2)) + { + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dsnative] mpcodecs_config_vo() failed\n"); + return 0; + } + + mp_msg(MSGT_DECVIDEO, MSGL_V, "[dsnative]: Win32/DShow video codec init OK.\n"); + return 1; +} + +static void uninit(sh_video_t *sh) +{ + if (dsn.codec) dsn.DSCloseVideoCodec(dsn.codec); + if (dsn.hLib) FreeLibrary(dsn.hLib); +#ifdef WIN32_LOADER + Restore_LDT_Keeper(dsn.ldt_fs); +#endif +} + +// decode a frame +static mp_image_t* decode(sh_video_t *sh, void* data,int len, int flags) +{ + mp_image_t* mpi; + unsigned char *planes; + int err; + double newpts; + int keyframe; + + if (len <= 0) + return NULL; // skipped frame + + mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_COMMON_PLANE, sh->disp_w, sh->disp_h); + if (!mpi) return NULL; + + keyframe = sh->ds->flags & 1; + + if (!keyframe && (flags & 3)) + planes = NULL; + else + planes = mpi->planes[0]; + + err = dsn.DSVideoDecode(dsn.codec, data, len, sh->pts, &newpts, planes, keyframe); + if (err == DSN_OK) + sh->pts = newpts; + else + mp_msg(MSGT_DECVIDEO, MSGL_ERR, "[dsnative] Decoding failed: %s\n", dsn.DSStrError(err)); + return mpi; +}