annotate libmpcodecs/vd_dshow.c @ 31259:dc3954ca63ca

Remove explicit eof check for mp_read code, stream code handles this case better, e.g. properly supporting growing files.
author reimar
date Sat, 05 Jun 2010 16:12:36 +0000
parents 1c38d10731ab
children 33ff3fdad741
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
19 #include <stdio.h>
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
20 #include <stdlib.h>
5003
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
21 #include <stdarg.h>
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
22
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
23 #include "config.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
24
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
25 #include "mp_msg.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
26 #include "help_mp.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
27
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
28 #include "vd_internal.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
29
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
30 #include "loader/dshow/DS_VideoDecoder.h"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
31
30504
cc27da5d7286 Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents: 30421
diff changeset
32 static const vd_info_t info = {
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
33 "DirectShow video codecs",
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
34 "dshow",
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
35 "A'rpi",
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
36 "based on http://avifile.sf.net",
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
37 "win32 codecs"
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
38 };
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
39
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
40 LIBVD_EXTERN(dshow)
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
41
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
42 // to set/get/query special features/parameters
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
43 static int control(sh_video_t *sh,int cmd,void* arg,...){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
44 switch(cmd){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
45 case VDCTRL_QUERY_MAX_PP_LEVEL:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
46 return 4;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
47 case VDCTRL_SET_PP_LEVEL:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
48 if(!sh->context) return CONTROL_ERROR;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
49 DS_VideoDecoder_SetValue(sh->context,"Quality",*((int*)arg));
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
50 return CONTROL_OK;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
51
5003
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
52 case VDCTRL_SET_EQUALIZER: {
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
53 va_list ap;
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
54 int value;
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
55 va_start(ap, arg);
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
56 value=va_arg(ap, int);
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
57 va_end(ap);
6802
c04345113340 eq range mapping -100..100 => 0..100
arpi
parents: 6525
diff changeset
58 if(DS_VideoDecoder_SetValue(sh->context,arg,50+value/2)==0)
5003
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
59 return CONTROL_OK;
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
60 return CONTROL_FALSE;
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
61 }
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
62
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
63 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
64 return CONTROL_UNKNOWN;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
65 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
66
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
67 // init driver
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
68 static int init(sh_video_t *sh){
30782
1c38d10731ab Partially revert r30645, the final output format is determined by
reimar
parents: 30605
diff changeset
69 unsigned int out_fmt=sh->codec->outfmt[0];
15344
6a7adf41e4fe Support for new vssh dll, patch by adland
rtognimp
parents: 12763
diff changeset
70
6a7adf41e4fe Support for new vssh dll, patch by adland
rtognimp
parents: 12763
diff changeset
71 /* Hack for VSSH codec: new dll can't decode old files
6a7adf41e4fe Support for new vssh dll, patch by adland
rtognimp
parents: 12763
diff changeset
72 * In my samples old files have no extradata, so use that info
6a7adf41e4fe Support for new vssh dll, patch by adland
rtognimp
parents: 12763
diff changeset
73 * to decide what dll should be used (here and in vd_vfw).
6a7adf41e4fe Support for new vssh dll, patch by adland
rtognimp
parents: 12763
diff changeset
74 */
6a7adf41e4fe Support for new vssh dll, patch by adland
rtognimp
parents: 12763
diff changeset
75 if (!strcmp(sh->codec->dll, "vsshdsd.dll") && (sh->bih->biSize == 40))
6a7adf41e4fe Support for new vssh dll, patch by adland
rtognimp
parents: 12763
diff changeset
76 return 0;
6a7adf41e4fe Support for new vssh dll, patch by adland
rtognimp
parents: 12763
diff changeset
77
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
78 if(!(sh->context=DS_VideoDecoder_Open(sh->codec->dll,&sh->codec->guid, sh->bih, 0, 0))){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
79 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
80 mp_msg(MSGT_DECVIDEO,MSGL_HINT,MSGTR_DownloadCodecPackage);
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
81 return 0;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
82 }
30603
c5d8b7640b7d Call mpcodecs_config_vo with the proper image format for dmo and dshow codecs.
reimar
parents: 30504
diff changeset
83 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
84 // mpcodecs_config_vo can change the format
1c38d10731ab Partially revert r30645, the final output format is determined by
reimar
parents: 30605
diff changeset
85 out_fmt=sh->codec->outfmt[sh->outfmtidx];
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
86 switch(out_fmt){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
87 case IMGFMT_YUY2:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
88 case IMGFMT_UYVY:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
89 DS_VideoDecoder_SetDestFmt(sh->context,16,out_fmt);break; // packed YUV
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
90 case IMGFMT_YV12:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
91 case IMGFMT_I420:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
92 case IMGFMT_IYUV:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
93 DS_VideoDecoder_SetDestFmt(sh->context,12,out_fmt);break; // planar YUV
6525
0a7be46617d8 yvu9 and if09 support
alex
parents: 5124
diff changeset
94 case IMGFMT_YVU9:
0a7be46617d8 yvu9 and if09 support
alex
parents: 5124
diff changeset
95 DS_VideoDecoder_SetDestFmt(sh->context,9,out_fmt);break;
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
96 default:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
97 DS_VideoDecoder_SetDestFmt(sh->context,out_fmt&255,0); // RGB/BGR
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
98 }
5003
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4986
diff changeset
99 DS_SetAttr_DivX("Quality",divx_quality);
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
100 DS_VideoDecoder_StartInternal(sh->context);
12763
f34a7cf4265a Console message corrected and moved to help_mp-en.h.
diego
parents: 8504
diff changeset
101 mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_DShowInitOK);
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
102 return 1;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
103 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
104
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
105 // uninit driver
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
106 static void uninit(sh_video_t *sh){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
107 DS_VideoDecoder_Destroy(sh->context);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
108 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
109
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
110 //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
111
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
112 // decode a frame
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
113 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
114 mp_image_t* mpi;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
115 if(len<=0) return NULL; // skipped frame
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 18765
diff changeset
116
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
117 if(flags&3){
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
118 // framedrop:
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
119 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, 0);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
120 return NULL;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
121 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 18765
diff changeset
122
30604
bc87504d1d6a DShow and DMO decoders need MP_IMGFLAG_COMMON_PLANE
reimar
parents: 30603
diff changeset
123 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_COMMON_PLANE,
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
124 sh->disp_w, sh->disp_h);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 18765
diff changeset
125
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
126 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
127 mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_MPCODECS_CouldntAllocateImageForCinepakCodec);
4958
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
128 return NULL;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
129 }
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
130
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
131 DS_VideoDecoder_DecodeInternal(sh->context, data, len, 0, mpi->planes[0]);
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
132
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
133 return mpi;
ca6f6b35baf4 vd_dshow added
arpi
parents:
diff changeset
134 }