Mercurial > mplayer.hg
annotate libmpcodecs/vd_dshow.c @ 34863:04cd132753bc
vf_ass: fix running out of images and crashing.
This would happen when running direct rendering with
MP_IMGTYPE_NUMBERED.
author | reimar |
---|---|
date | Mon, 21 May 2012 20:00:01 +0000 |
parents | 277ec491a8a7 |
children |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
18 |
4958 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
5003 | 21 #include <stdarg.h> |
4958 | 22 |
23 #include "config.h" | |
24 | |
25 #include "mp_msg.h" | |
26 #include "help_mp.h" | |
27 | |
28 #include "vd_internal.h" | |
31983 | 29 #include "dec_video.h" |
4958 | 30 |
31 #include "loader/dshow/DS_VideoDecoder.h" | |
32 | |
30504
cc27da5d7286
Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents:
30421
diff
changeset
|
33 static const vd_info_t info = { |
4958 | 34 "DirectShow video codecs", |
35 "dshow", | |
36 "A'rpi", | |
37 "based on http://avifile.sf.net", | |
38 "win32 codecs" | |
39 }; | |
40 | |
41 LIBVD_EXTERN(dshow) | |
42 | |
43 // to set/get/query special features/parameters | |
44 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
45 switch(cmd){ | |
46 case VDCTRL_QUERY_MAX_PP_LEVEL: | |
47 return 4; | |
48 case VDCTRL_SET_PP_LEVEL: | |
49 if(!sh->context) return CONTROL_ERROR; | |
50 DS_VideoDecoder_SetValue(sh->context,"Quality",*((int*)arg)); | |
51 return CONTROL_OK; | |
52 | |
5003 | 53 case VDCTRL_SET_EQUALIZER: { |
54 va_list ap; | |
55 int value; | |
56 va_start(ap, arg); | |
57 value=va_arg(ap, int); | |
58 va_end(ap); | |
6802 | 59 if(DS_VideoDecoder_SetValue(sh->context,arg,50+value/2)==0) |
5003 | 60 return CONTROL_OK; |
61 return CONTROL_FALSE; | |
62 } | |
63 | |
4958 | 64 } |
65 return CONTROL_UNKNOWN; | |
66 } | |
67 | |
68 // init driver | |
69 static int init(sh_video_t *sh){ | |
30782
1c38d10731ab
Partially revert r30645, the final output format is determined by
reimar
parents:
30605
diff
changeset
|
70 unsigned int out_fmt=sh->codec->outfmt[0]; |
15344 | 71 |
72 /* Hack for VSSH codec: new dll can't decode old files | |
73 * In my samples old files have no extradata, so use that info | |
74 * to decide what dll should be used (here and in vd_vfw). | |
75 */ | |
76 if (!strcmp(sh->codec->dll, "vsshdsd.dll") && (sh->bih->biSize == 40)) | |
77 return 0; | |
78 | |
4958 | 79 if(!(sh->context=DS_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){ |
80 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
|
81 mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage); |
4958 | 82 return 0; |
83 } | |
30603
c5d8b7640b7d
Call mpcodecs_config_vo with the proper image format for dmo and dshow codecs.
reimar
parents:
30504
diff
changeset
|
84 if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,out_fmt)) return 0; |
30782
1c38d10731ab
Partially revert r30645, the final output format is determined by
reimar
parents:
30605
diff
changeset
|
85 // mpcodecs_config_vo can change the format |
1c38d10731ab
Partially revert r30645, the final output format is determined by
reimar
parents:
30605
diff
changeset
|
86 out_fmt=sh->codec->outfmt[sh->outfmtidx]; |
4958 | 87 switch(out_fmt){ |
88 case IMGFMT_YUY2: | |
89 case IMGFMT_UYVY: | |
90 DS_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV | |
91 case IMGFMT_YV12: | |
92 case IMGFMT_I420: | |
93 case IMGFMT_IYUV: | |
94 DS_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV | |
6525 | 95 case IMGFMT_YVU9: |
96 DS_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break; | |
4958 | 97 default: |
98 DS_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR | |
99 } | |
5003 | 100 DS_SetAttr_DivX("Quality",divx_quality); |
4958 | 101 DS_VideoDecoder_StartInternal(sh->context); |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
31983
diff
changeset
|
102 mp_msg(MSGT_DECVIDEO, MSGL_V, "INFO: Win32/DShow video codec init OK.\n"); |
4958 | 103 return 1; |
104 } | |
105 | |
106 // uninit driver | |
107 static void uninit(sh_video_t *sh){ | |
108 DS_VideoDecoder_Destroy(sh->context); | |
109 } | |
110 | |
111 //mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, int w, int h); | |
112 | |
113 // decode a frame | |
114 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
115 mp_image_t* mpi; | |
116 if(len<=0) return NULL; // skipped frame | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18765
diff
changeset
|
117 |
4958 | 118 if(flags&3){ |
119 // framedrop: | |
120 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0); | |
121 return NULL; | |
122 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18765
diff
changeset
|
123 |
30604
bc87504d1d6a
DShow and DMO decoders need MP_IMGFLAG_COMMON_PLANE
reimar
parents:
30603
diff
changeset
|
124 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_COMMON_PLANE, |
4958 | 125 sh->disp_w, sh->disp_h); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18765
diff
changeset
|
126 |
4958 | 127 if(!mpi){ // temporary! |
18004
bcd805923554
Part2 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu with LOTS of modifications by me
reynaldo
parents:
15344
diff
changeset
|
128 mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec); |
4958 | 129 return NULL; |
130 } | |
131 | |
132 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, mpi->planes[0]); | |
133 | |
134 return mpi; | |
135 } |