Mercurial > mplayer.hg
annotate libmpcodecs/ae_pcm.c @ 21555:ababf115f90d
Avoid deprecated _sleep, instead include windows.h and use Sleep just like
osdep/timer-win2.c does.
Patch by Zuxy Meng [zuxy meng (at) gmail com]
author | reimar |
---|---|
date | Sun, 10 Dec 2006 14:04:27 +0000 |
parents | a90aa203186c |
children | ca9da45d13e9 |
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" |
15234 | 9 #include "aviheader.h" |
17012 | 10 #include "libaf/af_format.h" |
15234 | 11 #include "ms_hdr.h" |
12 #include "muxer.h" | |
13 #include "ae_pcm.h" | |
14 | |
15 | |
16 static int bind_pcm(audio_encoder_t *encoder, muxer_stream_t *mux_a) | |
17 { | |
18 mux_a->h.dwScale=1; | |
19 mux_a->h.dwRate=encoder->params.sample_rate; | |
20 mux_a->wf=malloc(sizeof(WAVEFORMATEX)); | |
21 mux_a->wf->wFormatTag=0x1; // PCM | |
22 mux_a->wf->nChannels=encoder->params.channels; | |
23 mux_a->h.dwSampleSize=2*mux_a->wf->nChannels; | |
24 mux_a->wf->nBlockAlign=mux_a->h.dwSampleSize; | |
25 mux_a->wf->nSamplesPerSec=mux_a->h.dwRate; | |
26 mux_a->wf->nAvgBytesPerSec=mux_a->h.dwSampleSize*mux_a->wf->nSamplesPerSec; | |
27 mux_a->wf->wBitsPerSample=16; | |
28 mux_a->wf->cbSize=0; // FIXME for l3codeca.acm | |
29 | |
30 encoder->input_format = (mux_a->wf->wBitsPerSample==8) ? AF_FORMAT_U8 : AF_FORMAT_S16_LE; | |
31 encoder->min_buffer_size = 16384; | |
32 encoder->max_buffer_size = mux_a->wf->nAvgBytesPerSec; | |
33 | |
34 return 1; | |
35 } | |
36 | |
37 static int encode_pcm(audio_encoder_t *encoder, uint8_t *dest, void *src, int nsamples, int max_size) | |
38 { | |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
17012
diff
changeset
|
39 max_size = FFMIN(nsamples, max_size); |
15234 | 40 memcpy(dest, src, max_size); |
41 return max_size; | |
42 } | |
43 | |
15258 | 44 static int set_decoded_len(audio_encoder_t *encoder, int len) |
15234 | 45 { |
15258 | 46 return len; |
15234 | 47 } |
48 | |
49 static int close_pcm(audio_encoder_t *encoder) | |
50 { | |
51 return 1; | |
52 } | |
53 | |
54 static int get_frame_size(audio_encoder_t *encoder) | |
55 { | |
56 return 0; | |
57 } | |
58 | |
59 int mpae_init_pcm(audio_encoder_t *encoder) | |
60 { | |
61 encoder->params.samples_per_frame = encoder->params.sample_rate; | |
62 encoder->params.bitrate = encoder->params.sample_rate * encoder->params.channels * 2 * 8; | |
63 | |
64 encoder->decode_buffer_size = encoder->params.bitrate / 8; | |
65 encoder->bind = bind_pcm; | |
66 encoder->get_frame_size = get_frame_size; | |
67 encoder->set_decoded_len = set_decoded_len; | |
68 encoder->encode = encode_pcm; | |
69 encoder->close = close_pcm; | |
70 | |
71 return 1; | |
72 } | |
73 |