Mercurial > mplayer.hg
annotate libmpcodecs/ae_pcm.c @ 23965:8d4b1bda30f1
Fix detection of xan audio. -noidx or -forceidx still is necessary
to detect audio at all.
author | reimar |
---|---|
date | Wed, 01 Aug 2007 09:01:28 +0000 |
parents | ed8f90096c65 |
children | dfa8a510c81c |
rev | line source |
---|---|
15234 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <inttypes.h> | |
15238 | 4 #include <unistd.h> |
15234 | 5 #include <string.h> |
15240 | 6 #include <sys/types.h> |
15234 | 7 #include "m_option.h" |
17012 | 8 #include "mp_msg.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
9 #include "libmpdemux/aviheader.h" |
17012 | 10 #include "libaf/af_format.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
11 #include "libmpdemux/ms_hdr.h" |
22600
3c2b4a866c6a
Add explicit location for headers from the stream/ directory.
diego
parents:
21660
diff
changeset
|
12 #include "stream/stream.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
13 #include "libmpdemux/muxer.h" |
15234 | 14 #include "ae_pcm.h" |
15 | |
16 | |
17 static int bind_pcm(audio_encoder_t *encoder, muxer_stream_t *mux_a) | |
18 { | |
19 mux_a->h.dwScale=1; | |
20 mux_a->h.dwRate=encoder->params.sample_rate; | |
21 mux_a->wf=malloc(sizeof(WAVEFORMATEX)); | |
22 mux_a->wf->wFormatTag=0x1; // PCM | |
23 mux_a->wf->nChannels=encoder->params.channels; | |
24 mux_a->h.dwSampleSize=2*mux_a->wf->nChannels; | |
25 mux_a->wf->nBlockAlign=mux_a->h.dwSampleSize; | |
26 mux_a->wf->nSamplesPerSec=mux_a->h.dwRate; | |
27 mux_a->wf->nAvgBytesPerSec=mux_a->h.dwSampleSize*mux_a->wf->nSamplesPerSec; | |
28 mux_a->wf->wBitsPerSample=16; | |
29 mux_a->wf->cbSize=0; // FIXME for l3codeca.acm | |
30 | |
31 encoder->input_format = (mux_a->wf->wBitsPerSample==8) ? AF_FORMAT_U8 : AF_FORMAT_S16_LE; | |
32 encoder->min_buffer_size = 16384; | |
33 encoder->max_buffer_size = mux_a->wf->nAvgBytesPerSec; | |
34 | |
35 return 1; | |
36 } | |
37 | |
38 static int encode_pcm(audio_encoder_t *encoder, uint8_t *dest, void *src, int nsamples, int max_size) | |
39 { | |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
17012
diff
changeset
|
40 max_size = FFMIN(nsamples, max_size); |
15234 | 41 memcpy(dest, src, max_size); |
42 return max_size; | |
43 } | |
44 | |
15258 | 45 static int set_decoded_len(audio_encoder_t *encoder, int len) |
15234 | 46 { |
15258 | 47 return len; |
15234 | 48 } |
49 | |
50 static int close_pcm(audio_encoder_t *encoder) | |
51 { | |
52 return 1; | |
53 } | |
54 | |
55 static int get_frame_size(audio_encoder_t *encoder) | |
56 { | |
57 return 0; | |
58 } | |
59 | |
60 int mpae_init_pcm(audio_encoder_t *encoder) | |
61 { | |
62 encoder->params.samples_per_frame = encoder->params.sample_rate; | |
63 encoder->params.bitrate = encoder->params.sample_rate * encoder->params.channels * 2 * 8; | |
64 | |
65 encoder->decode_buffer_size = encoder->params.bitrate / 8; | |
66 encoder->bind = bind_pcm; | |
67 encoder->get_frame_size = get_frame_size; | |
68 encoder->set_decoded_len = set_decoded_len; | |
69 encoder->encode = encode_pcm; | |
70 encoder->close = close_pcm; | |
71 | |
72 return 1; | |
73 } | |
74 |