annotate libmpcodecs/vd_dshow.c @ 10863:c2ec0a961019

This file does not need to be translated.
author diego
date Sat, 13 Sep 2003 15:22:06 +0000
parents 321763255480
children f34a7cf4265a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
1 #include <stdio.h>
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
2 #include <stdlib.h>
5003
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
3 #include <stdarg.h>
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
4
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
5 #include "config.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
6 #ifdef USE_DIRECTSHOW
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
7
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
8 #include "mp_msg.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
9 #include "help_mp.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
10
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
11 #include "vd_internal.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
12
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
13 #include "loader/dshow/DS_VideoDecoder.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
14
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
15 static vd_info_t info = {
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
16 "DirectShow video codecs",
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
17 "dshow",
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
18 "A'rpi",
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
19 "based on http://avifile.sf.net",
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
20 "win32 codecs"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
21 };
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
22
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
23 LIBVD_EXTERN(dshow)
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
24
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
25 // to set/get/query special features/parameters
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
26 static int control(sh_video_t *sh,int cmd,void* arg,...){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
27 switch(cmd){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
28 case VDCTRL_QUERY_MAX_PP_LEVEL:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
29 return 4;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
30 case VDCTRL_SET_PP_LEVEL:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
31 if(!sh->context) return CONTROL_ERROR;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
32 DS_VideoDecoder_SetValue(sh->context,"Quality",*((int*)arg));
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
33 return CONTROL_OK;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
34
5003
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
35 case VDCTRL_SET_EQUALIZER: {
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
36 va_list ap;
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
37 int value;
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
38 va_start(ap, arg);
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
39 value=va_arg(ap, int);
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
40 va_end(ap);
6802
c04345113340 eq range mapping -100..100 => 0..100
arpi
parents: 6525
diff changeset
41 if(DS_VideoDecoder_SetValue(sh->context,arg,50+value/2)==0)
5003
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
42 return CONTROL_OK;
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
43 return CONTROL_FALSE;
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
44 }
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
45
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
46 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
47 return CONTROL_UNKNOWN;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
48 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
49
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
50 // init driver
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
51 static int init(sh_video_t *sh){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
52 unsigned int out_fmt;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
53 if(!(sh->context=DS_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
54 mp_msg(MSGT_DECVIDEO,MSGL_ERR,MSGTR_MissingDLLcodec,sh->codec->dll);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
55 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"Maybe you forget to upgrade your win32 codecs?? It's time to download the new\n");
8504
321763255480 corrected w32codec address (noticed by Peter Nelson on mplayer-users)
alex
parents: 7180
diff changeset
56 mp_msg(MSGT_DECVIDEO,MSGL_HINT,"package from: ftp://mplayerhq.hu/MPlayer/releases/w32codec.tar.bz2!\n");
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
57 return 0;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
58 }
5124
3dcbf67c0de0 handle error from mpcodecs_config_vo()
arpi
parents: 5003
diff changeset
59 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2)) return 0;
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
60 out_fmt=sh->codec->outfmt[sh->outfmtidx];
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
61 switch(out_fmt){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
62 case IMGFMT_YUY2:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
63 case IMGFMT_UYVY:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
64 DS_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
65 case IMGFMT_YV12:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
66 case IMGFMT_I420:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
67 case IMGFMT_IYUV:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
68 DS_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 5124
diff changeset
69 case IMGFMT_YVU9:
0a7be46617d8 yvu9 and if09 support
alex
parents: 5124
diff changeset
70 DS_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
71 default:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
72 DS_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
73 }
5003
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
74 DS_SetAttr_DivX("Quality",divx_quality);
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
75 DS_VideoDecoder_StartInternal(sh->context);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
76 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DShow video codec init OK!\n");
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
77 return 1;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
78 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
79
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
80 // uninit driver
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
81 static void uninit(sh_video_t *sh){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
82 DS_VideoDecoder_Destroy(sh->context);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
83 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
84
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
85 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
86
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
87 // decode a frame
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
88 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
89 mp_image_t* mpi;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
90 if(len<=0) return NULL; // skipped frame
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
91
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
92 if(flags&3){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
93 // framedrop:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
94 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
95 return NULL;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
96 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
97
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
98 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0 /*MP_IMGFLAG_ACCEPT_STRIDE*/,
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
99 sh->disp_w, sh->disp_h);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
100
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
101 if(!mpi){ // temporary!
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
102 printf("couldn't allocate image for cinepak codec\n");
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
103 return NULL;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
104 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
105
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
106 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, mpi->planes[0]);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
107
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
108 return mpi;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
109 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
110
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
111 #endif