annotate libmpcodecs/ad_dmo.c @ 16132:cd65644dae2d

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