Mercurial > mplayer.hg
annotate libmpcodecs/ad_libdv.c @ 18673:02e837b23337
Do not require iconv program with --charset=noconv
author | reimar |
---|---|
date | Sat, 10 Jun 2006 20:11:38 +0000 |
parents | bcd805923554 |
children | a1807995e2ab |
rev | line source |
---|---|
6927 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <sys/types.h> | |
5 #include <unistd.h> | |
6 #include <math.h> | |
7 | |
8 #include "config.h" | |
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:
7180
diff
changeset
|
9 #include "mp_msg.h" |
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:
7180
diff
changeset
|
10 #include "help_mp.h" |
6927 | 11 |
12 #ifdef HAVE_LIBDV095 | |
13 | |
14 #include "img_format.h" | |
15 | |
16 #include <libdv/dv.h> | |
17 #include <libdv/dv_types.h> | |
18 | |
19 #include "stream.h" | |
20 #include "demuxer.h" | |
21 #include "stheader.h" | |
22 | |
23 #include "ad_internal.h" | |
24 | |
25 static ad_info_t info = | |
26 { | |
27 "Raw DV Audio Decoder", | |
28 "libdv", | |
29 "Alexander Neundorf <neundorf@kde.org>", | |
30 "http://libdv.sf.net", | |
31 "" | |
32 }; | |
33 | |
34 LIBAD_EXTERN(libdv) | |
35 | |
36 // defined in vd_libdv.c: | |
37 dv_decoder_t* init_global_rawdv_decoder(); | |
38 | |
39 static int preinit(sh_audio_t *sh_audio) | |
40 { | |
41 sh_audio->audio_out_minsize=4*DV_AUDIO_MAX_SAMPLES*2; | |
42 return 1; | |
43 } | |
44 | |
45 static int16_t *audioBuffers[4]={NULL,NULL,NULL,NULL}; | |
46 | |
47 static int init(sh_audio_t *sh) | |
48 { | |
49 int i; | |
50 WAVEFORMATEX *h=sh->wf; | |
51 | |
52 if(!h) return 0; | |
53 | |
54 sh->i_bps=h->nAvgBytesPerSec; | |
55 sh->channels=h->nChannels; | |
56 sh->samplerate=h->nSamplesPerSec; | |
57 sh->samplesize=(h->wBitsPerSample+7)/8; | |
58 | |
59 sh->context=init_global_rawdv_decoder(); | |
60 | |
61 for (i=0; i < 4; i++) | |
62 audioBuffers[i] = malloc(2*DV_AUDIO_MAX_SAMPLES); | |
63 | |
64 return 1; | |
65 } | |
66 | |
67 static void uninit(sh_audio_t *sh_audio) | |
68 { | |
69 int i; | |
70 for (i=0; i < 4; i++) | |
71 free(audioBuffers[i]); | |
72 } | |
73 | |
74 static int control(sh_audio_t *sh,int cmd,void* arg, ...) | |
75 { | |
76 // TODO!!! | |
77 return CONTROL_UNKNOWN; | |
78 } | |
79 | |
80 static int decode_audio(sh_audio_t *audio, unsigned char *buf, int minlen, int maxlen) | |
81 { | |
82 int len=0; | |
83 dv_decoder_t* decoder=audio->context; //global_rawdv_decoder; | |
84 unsigned char* dv_audio_frame=NULL; | |
85 int xx=ds_get_packet(audio->ds,&dv_audio_frame); | |
86 if(xx<=0 || !dv_audio_frame) return 0; // EOF? | |
87 | |
88 dv_parse_header(decoder, dv_audio_frame); | |
89 | |
90 if(xx!=decoder->frame_size) | |
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:
7180
diff
changeset
|
91 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_MPCODECS_AudioFramesizeDiffers, |
6927 | 92 xx, decoder->frame_size); |
93 | |
94 if (dv_decode_full_audio(decoder, dv_audio_frame,(int16_t**) audioBuffers)) | |
95 { | |
96 /* Interleave the audio into a single buffer */ | |
97 int i=0; | |
98 int16_t *bufP=(int16_t*)buf; | |
99 | |
100 // printf("samples=%d/%d chans=%d mem=%d \n",decoder->audio->samples_this_frame,DV_AUDIO_MAX_SAMPLES, | |
101 // decoder->audio->num_channels, decoder->audio->samples_this_frame*decoder->audio->num_channels*2); | |
102 | |
103 // return (44100/30)*4; | |
104 | |
105 for (i=0; i < decoder->audio->samples_this_frame; i++) | |
106 { | |
107 int ch; | |
108 for (ch=0; ch < decoder->audio->num_channels; ch++) | |
109 bufP[len++] = audioBuffers[ch][i]; | |
110 } | |
111 } | |
112 return len*2; | |
113 } | |
114 | |
115 #endif | |
116 |