Mercurial > mplayer.hg
annotate libmpcodecs/ae_pcm.c @ 29942:9b90e1052b32
Use a fallback to make sure the basic OpenGL functions are available instead of
initializing them which does not work well with reinitializations.
author | reimar |
---|---|
date | Wed, 09 Dec 2009 17:50:07 +0000 |
parents | 4eae69f3f4f4 |
children | bbb6ebec87a0 |
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" |
25315
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
11 #include "libaf/reorder_ch.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
12 #include "libmpdemux/ms_hdr.h" |
22600
3c2b4a866c6a
Add explicit location for headers from the stream/ directory.
diego
parents:
21660
diff
changeset
|
13 #include "stream/stream.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
14 #include "libmpdemux/muxer.h" |
15234 | 15 #include "ae_pcm.h" |
16 | |
17 | |
18 static int bind_pcm(audio_encoder_t *encoder, muxer_stream_t *mux_a) | |
19 { | |
20 mux_a->h.dwScale=1; | |
21 mux_a->h.dwRate=encoder->params.sample_rate; | |
22 mux_a->wf=malloc(sizeof(WAVEFORMATEX)); | |
23 mux_a->wf->wFormatTag=0x1; // PCM | |
24 mux_a->wf->nChannels=encoder->params.channels; | |
25 mux_a->h.dwSampleSize=2*mux_a->wf->nChannels; | |
26 mux_a->wf->nBlockAlign=mux_a->h.dwSampleSize; | |
27 mux_a->wf->nSamplesPerSec=mux_a->h.dwRate; | |
28 mux_a->wf->nAvgBytesPerSec=mux_a->h.dwSampleSize*mux_a->wf->nSamplesPerSec; | |
29 mux_a->wf->wBitsPerSample=16; | |
30 mux_a->wf->cbSize=0; // FIXME for l3codeca.acm | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25315
diff
changeset
|
31 |
15234 | 32 encoder->input_format = (mux_a->wf->wBitsPerSample==8) ? AF_FORMAT_U8 : AF_FORMAT_S16_LE; |
33 encoder->min_buffer_size = 16384; | |
34 encoder->max_buffer_size = mux_a->wf->nAvgBytesPerSec; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25315
diff
changeset
|
35 |
15234 | 36 return 1; |
37 } | |
38 | |
39 static int encode_pcm(audio_encoder_t *encoder, uint8_t *dest, void *src, int nsamples, int max_size) | |
40 { | |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
17012
diff
changeset
|
41 max_size = FFMIN(nsamples, max_size); |
29826 | 42 if (encoder->params.channels == 5 || encoder->params.channels == 6 || |
43 encoder->params.channels == 8) { | |
25315
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
44 max_size -= max_size % (encoder->params.channels * 2); |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
45 reorder_channel_copy_nch(src, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
46 dest, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
47 encoder->params.channels, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
48 max_size / 2, 2); |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
49 } |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
50 else |
15234 | 51 memcpy(dest, src, max_size); |
52 return max_size; | |
53 } | |
54 | |
15258 | 55 static int set_decoded_len(audio_encoder_t *encoder, int len) |
15234 | 56 { |
15258 | 57 return len; |
15234 | 58 } |
59 | |
60 static int close_pcm(audio_encoder_t *encoder) | |
61 { | |
62 return 1; | |
63 } | |
64 | |
65 static int get_frame_size(audio_encoder_t *encoder) | |
66 { | |
67 return 0; | |
68 } | |
69 | |
70 int mpae_init_pcm(audio_encoder_t *encoder) | |
71 { | |
72 encoder->params.samples_per_frame = encoder->params.sample_rate; | |
73 encoder->params.bitrate = encoder->params.sample_rate * encoder->params.channels * 2 * 8; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25315
diff
changeset
|
74 |
15234 | 75 encoder->decode_buffer_size = encoder->params.bitrate / 8; |
76 encoder->bind = bind_pcm; | |
77 encoder->get_frame_size = get_frame_size; | |
78 encoder->set_decoded_len = set_decoded_len; | |
79 encoder->encode = encode_pcm; | |
80 encoder->close = close_pcm; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25315
diff
changeset
|
81 |
15234 | 82 return 1; |
83 } | |
84 |