annotate libmpcodecs/vd_dmo.c @ 16795:e8148dd5691c

xscreensaver --> XScreenSaver
author diego
date Tue, 18 Oct 2005 19:58:33 +0000
parents f34a7cf4265a
children bcd805923554
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
1 #include <stdio.h>
cd02bf201f38 DMO support
arpi
parents:
diff changeset
2 #include <stdlib.h>
cd02bf201f38 DMO support
arpi
parents:
diff changeset
3 #include <stdarg.h>
cd02bf201f38 DMO support
arpi
parents:
diff changeset
4
cd02bf201f38 DMO support
arpi
parents:
diff changeset
5 #include "config.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
6 #ifdef USE_DIRECTSHOW
cd02bf201f38 DMO support
arpi
parents:
diff changeset
7
cd02bf201f38 DMO support
arpi
parents:
diff changeset
8 #include "mp_msg.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
9 #include "help_mp.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
10
cd02bf201f38 DMO support
arpi
parents:
diff changeset
11 #include "vd_internal.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
12
cd02bf201f38 DMO support
arpi
parents:
diff changeset
13 #include "loader/dmo/DMO_VideoDecoder.h"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
14
cd02bf201f38 DMO support
arpi
parents:
diff changeset
15 static vd_info_t info = {
cd02bf201f38 DMO support
arpi
parents:
diff changeset
16 "DMO video codecs",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
17 "dmo",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
18 "A'rpi",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
19 "based on http://avifile.sf.net",
cd02bf201f38 DMO support
arpi
parents:
diff changeset
20 "win32 codecs"
cd02bf201f38 DMO support
arpi
parents:
diff changeset
21 };
cd02bf201f38 DMO support
arpi
parents:
diff changeset
22
cd02bf201f38 DMO support
arpi
parents:
diff changeset
23 LIBVD_EXTERN(dmo)
cd02bf201f38 DMO support
arpi
parents:
diff changeset
24
cd02bf201f38 DMO support
arpi
parents:
diff changeset
25 // to set/get/query special features/parameters
cd02bf201f38 DMO support
arpi
parents:
diff changeset
26 static int control(sh_video_t *sh,int cmd,void* arg,...){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
27 return CONTROL_UNKNOWN;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
28 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
29
cd02bf201f38 DMO support
arpi
parents:
diff changeset
30 // init driver
cd02bf201f38 DMO support
arpi
parents:
diff changeset
31 static int init(sh_video_t *sh){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
32 unsigned int out_fmt;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
33 if(!(sh->context=DMO_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
34 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
12763
f34a7cf4265a Console message corrected and moved to help_mp-en.h.
diego
parents: 8504
diff changeset
35 mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
36 return 0;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
37 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
38 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
39 out_fmt=sh->codec->outfmt[sh->outfmtidx];
cd02bf201f38 DMO support
arpi
parents:
diff changeset
40 switch(out_fmt){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
41 case IMGFMT_YUY2:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
42 case IMGFMT_UYVY:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
43 DMO_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
cd02bf201f38 DMO support
arpi
parents:
diff changeset
44 case IMGFMT_YV12:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
45 case IMGFMT_I420:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
46 case IMGFMT_IYUV:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
47 DMO_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
cd02bf201f38 DMO support
arpi
parents:
diff changeset
48 case IMGFMT_YVU9:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
49 DMO_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
50 default:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
51 DMO_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
cd02bf201f38 DMO support
arpi
parents:
diff changeset
52 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
53 DMO_VideoDecoder_StartInternal(sh->context);
12763
f34a7cf4265a Console message corrected and moved to help_mp-en.h.
diego
parents: 8504
diff changeset
54 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DMOInitOK);
8295
cd02bf201f38 DMO support
arpi
parents:
diff changeset
55 return 1;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
56 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
57
cd02bf201f38 DMO support
arpi
parents:
diff changeset
58 // uninit driver
cd02bf201f38 DMO support
arpi
parents:
diff changeset
59 static void uninit(sh_video_t *sh){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
60 DMO_VideoDecoder_Destroy(sh->context);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
61 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
62
cd02bf201f38 DMO support
arpi
parents:
diff changeset
63 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
64
cd02bf201f38 DMO support
arpi
parents:
diff changeset
65 // decode a frame
cd02bf201f38 DMO support
arpi
parents:
diff changeset
66 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
67 mp_image_t* mpi;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
68 if(len<=0) return NULL; // skipped frame
cd02bf201f38 DMO support
arpi
parents:
diff changeset
69
cd02bf201f38 DMO support
arpi
parents:
diff changeset
70 if(flags&3){
cd02bf201f38 DMO support
arpi
parents:
diff changeset
71 // framedrop:
cd02bf201f38 DMO support
arpi
parents:
diff changeset
72 DMO_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
73 return NULL;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
74 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
75
cd02bf201f38 DMO support
arpi
parents:
diff changeset
76 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
cd02bf201f38 DMO support
arpi
parents:
diff changeset
77 sh->disp_w, sh->disp_h);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
78
cd02bf201f38 DMO support
arpi
parents:
diff changeset
79 if(!mpi){ // temporary!
cd02bf201f38 DMO support
arpi
parents:
diff changeset
80 printf("couldn't allocate image for cinepak codec\n");
cd02bf201f38 DMO support
arpi
parents:
diff changeset
81 return NULL;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
82 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
83
cd02bf201f38 DMO support
arpi
parents:
diff changeset
84 DMO_VideoDecoder_DecodeInternal(sh->context, data, len, 1, mpi->planes[0]);
cd02bf201f38 DMO support
arpi
parents:
diff changeset
85
cd02bf201f38 DMO support
arpi
parents:
diff changeset
86 return mpi;
cd02bf201f38 DMO support
arpi
parents:
diff changeset
87 }
cd02bf201f38 DMO support
arpi
parents:
diff changeset
88
cd02bf201f38 DMO support
arpi
parents:
diff changeset
89 #endif