Mercurial > mplayer.hg
annotate libmpcodecs/ad_dmo.c @ 33737:71c29e8ec68f
Move string functions from interface.c to string.c.
Additionally, change char parameter of gstrchr() to const and
rename parameter size of gstrncmp() n.
The Win32 GUI now needs gstrdup() defined before its first usage.
author | ib |
---|---|
date | Thu, 07 Jul 2011 08:32:10 +0000 |
parents | 9986a61354e6 |
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 |
8326 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 #include <unistd.h> | |
22 | |
23 #include "config.h" | |
24 #include "mp_msg.h" | |
25 #include "help_mp.h" | |
26 | |
27 #include "ad_internal.h" | |
31986
9986a61354e6
Remove duplicated audio_output_channels extern variable declaration.
diego
parents:
30504
diff
changeset
|
28 #include "dec_audio.h" |
25315
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
23918
diff
changeset
|
29 #include "libaf/reorder_ch.h" |
8326 | 30 |
30504
cc27da5d7286
Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents:
30421
diff
changeset
|
31 static const ad_info_t info = |
8326 | 32 { |
8327 | 33 "Win32/DMO decoders", |
8326 | 34 "dmo", |
35 "A'rpi", | |
36 "avifile.sf.net", | |
37 "" | |
38 }; | |
39 | |
40 LIBAD_EXTERN(dmo) | |
41 | |
22577
a033e5519802
Include loader/ prefix in #include path everywhere.
diego
parents:
18765
diff
changeset
|
42 #include "loader/dmo/DMO_AudioDecoder.h" |
8326 | 43 |
44 static int init(sh_audio_t *sh) | |
45 { | |
46 return 1; | |
47 } | |
48 | |
49 static int preinit(sh_audio_t *sh_audio) | |
50 { | |
51 DMO_AudioDecoder* ds_adec; | |
52 int chans=(audio_output_channels==sh_audio->wf->nChannels) ? | |
53 audio_output_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1); | |
54 if(!(ds_adec=DMO_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf,chans))) | |
55 { | |
56 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll); | |
57 return 0; | |
58 } | |
59 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; | |
60 sh_audio->channels=chans; | |
61 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
13427
9d0b052c4f74
setting samplesize to 2 in decoders where neccessary.
reimar
parents:
8327
diff
changeset
|
62 sh_audio->samplesize=2; |
8326 | 63 sh_audio->audio_in_minsize=4*sh_audio->wf->nBlockAlign; |
64 if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; | |
65 sh_audio->audio_out_minsize=4*16384; | |
66 sh_audio->context = ds_adec; | |
67 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO audio codec init OK!\n"); | |
68 return 1; | |
69 } | |
70 | |
71 static void uninit(sh_audio_t *sh) | |
72 { | |
73 DMO_AudioDecoder* ds_adec = sh->context; | |
74 DMO_AudioDecoder_Destroy(ds_adec); | |
75 } | |
76 | |
77 static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...) | |
78 { | |
79 int skip; | |
80 switch(cmd) | |
81 { | |
82 case ADCTRL_SKIP_FRAME: | |
83 skip=sh_audio->wf->nBlockAlign; | |
84 if(skip<16){ | |
85 skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7); | |
86 if(skip<16) skip=16; | |
87 } | |
88 demux_read_data(sh_audio->ds,NULL,skip); | |
89 return CONTROL_TRUE; | |
90 } | |
91 return CONTROL_UNKNOWN; | |
92 } | |
93 | |
94 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) | |
95 { | |
96 DMO_AudioDecoder* ds_adec = sh_audio->context; | |
97 // int len=-1; | |
98 int size_in=0; | |
99 int size_out=0; | |
100 int srcsize=DMO_AudioDecoder_GetSrcSize(ds_adec, maxlen); | |
101 mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DMO says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen); | |
102 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! | |
103 if(sh_audio->a_in_buffer_len<srcsize){ | |
104 sh_audio->a_in_buffer_len+= | |
105 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len], | |
106 srcsize-sh_audio->a_in_buffer_len); | |
107 } | |
108 DMO_AudioDecoder_Convert(ds_adec, sh_audio->a_in_buffer,sh_audio->a_in_buffer_len, | |
109 buf,maxlen, &size_in,&size_out); | |
110 mp_dbg(MSGT_DECAUDIO,MSGL_DBG2,"DMO: audio %d -> %d converted (in_buf_len=%d of %d) %d\n",size_in,size_out,sh_audio->a_in_buffer_len,sh_audio->a_in_buffer_size,ds_tell_pts(sh_audio->ds)); | |
111 if(size_in>=sh_audio->a_in_buffer_len){ | |
112 sh_audio->a_in_buffer_len=0; | |
113 } else { | |
114 sh_audio->a_in_buffer_len-=size_in; | |
15552
7867e143a557
Use memmove instead of memcpy for overlapping areas.
reimar
parents:
13427
diff
changeset
|
115 memmove(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len); |
8326 | 116 } |
25315
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
23918
diff
changeset
|
117 if (size_out > 0 && sh_audio->channels >= 5) { |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
23918
diff
changeset
|
118 reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
23918
diff
changeset
|
119 AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
23918
diff
changeset
|
120 sh_audio->channels, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
23918
diff
changeset
|
121 size_out / sh_audio->samplesize, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
23918
diff
changeset
|
122 sh_audio->samplesize); |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
23918
diff
changeset
|
123 } |
8326 | 124 // len=size_out; |
125 return size_out; | |
126 } |