Mercurial > mplayer.hg
annotate libmpcodecs/ad_dmo.c @ 20225:bdd028a5c834
cosmetics: indentation
author | kraymer |
---|---|
date | Sun, 15 Oct 2006 12:53:46 +0000 |
parents | 1ba0aff3ed0a |
children | a033e5519802 |
rev | line source |
---|---|
8326 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <unistd.h> | |
4 | |
5 #include "config.h" | |
6 #include "mp_msg.h" | |
7 #include "help_mp.h" | |
8 | |
9 #include "ad_internal.h" | |
10 | |
11 static ad_info_t info = | |
12 { | |
8327 | 13 "Win32/DMO decoders", |
8326 | 14 "dmo", |
15 "A'rpi", | |
16 "avifile.sf.net", | |
17 "" | |
18 }; | |
19 | |
20 LIBAD_EXTERN(dmo) | |
21 | |
22 #include "dmo/DMO_AudioDecoder.h" | |
23 | |
24 static int init(sh_audio_t *sh) | |
25 { | |
26 return 1; | |
27 } | |
28 | |
29 extern int audio_output_channels; | |
30 | |
31 static int preinit(sh_audio_t *sh_audio) | |
32 { | |
33 DMO_AudioDecoder* ds_adec; | |
34 int chans=(audio_output_channels==sh_audio->wf->nChannels) ? | |
35 audio_output_channels : (sh_audio->wf->nChannels>=2 ? 2 : 1); | |
36 if(!(ds_adec=DMO_AudioDecoder_Open(sh_audio->codec->dll,&sh_audio->codec->guid,sh_audio->wf,chans))) | |
37 { | |
38 mp_msg(MSGT_DECAUDIO,MSGL_ERR,MSGTR_MissingDLLcodec,sh_audio->codec->dll); | |
39 return 0; | |
40 } | |
41 sh_audio->i_bps=sh_audio->wf->nAvgBytesPerSec; | |
42 sh_audio->channels=chans; | |
43 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
13427
9d0b052c4f74
setting samplesize to 2 in decoders where neccessary.
reimar
parents:
8327
diff
changeset
|
44 sh_audio->samplesize=2; |
8326 | 45 sh_audio->audio_in_minsize=4*sh_audio->wf->nBlockAlign; |
46 if(sh_audio->audio_in_minsize<8192) sh_audio->audio_in_minsize=8192; | |
47 sh_audio->audio_out_minsize=4*16384; | |
48 sh_audio->context = ds_adec; | |
49 mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Win32/DMO audio codec init OK!\n"); | |
50 return 1; | |
51 } | |
52 | |
53 static void uninit(sh_audio_t *sh) | |
54 { | |
55 DMO_AudioDecoder* ds_adec = sh->context; | |
56 DMO_AudioDecoder_Destroy(ds_adec); | |
57 } | |
58 | |
59 static int control(sh_audio_t *sh_audio,int cmd,void* arg, ...) | |
60 { | |
61 int skip; | |
62 switch(cmd) | |
63 { | |
64 case ADCTRL_SKIP_FRAME: | |
65 skip=sh_audio->wf->nBlockAlign; | |
66 if(skip<16){ | |
67 skip=(sh_audio->wf->nAvgBytesPerSec/16)&(~7); | |
68 if(skip<16) skip=16; | |
69 } | |
70 demux_read_data(sh_audio->ds,NULL,skip); | |
71 return CONTROL_TRUE; | |
72 } | |
73 return CONTROL_UNKNOWN; | |
74 } | |
75 | |
76 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) | |
77 { | |
78 DMO_AudioDecoder* ds_adec = sh_audio->context; | |
79 // int len=-1; | |
80 int size_in=0; | |
81 int size_out=0; | |
82 int srcsize=DMO_AudioDecoder_GetSrcSize(ds_adec, maxlen); | |
83 mp_msg(MSGT_DECAUDIO,MSGL_DBG3,"DMO says: srcsize=%d (buffsize=%d) out_size=%d\n",srcsize,sh_audio->a_in_buffer_size,maxlen); | |
84 if(srcsize>sh_audio->a_in_buffer_size) srcsize=sh_audio->a_in_buffer_size; // !!!!!! | |
85 if(sh_audio->a_in_buffer_len<srcsize){ | |
86 sh_audio->a_in_buffer_len+= | |
87 demux_read_data(sh_audio->ds,&sh_audio->a_in_buffer[sh_audio->a_in_buffer_len], | |
88 srcsize-sh_audio->a_in_buffer_len); | |
89 } | |
90 DMO_AudioDecoder_Convert(ds_adec, sh_audio->a_in_buffer,sh_audio->a_in_buffer_len, | |
91 buf,maxlen, &size_in,&size_out); | |
92 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)); | |
93 if(size_in>=sh_audio->a_in_buffer_len){ | |
94 sh_audio->a_in_buffer_len=0; | |
95 } else { | |
96 sh_audio->a_in_buffer_len-=size_in; | |
15552
7867e143a557
Use memmove instead of memcpy for overlapping areas.
reimar
parents:
13427
diff
changeset
|
97 memmove(sh_audio->a_in_buffer,&sh_audio->a_in_buffer[size_in],sh_audio->a_in_buffer_len); |
8326 | 98 } |
99 // len=size_out; | |
100 return size_out; | |
101 } |