Mercurial > mplayer.hg
annotate libmpcodecs/ae_pcm.c @ 33754:1909e4015a3c
Add missing #includes <stdarg.h> and <stdio.h>.
author | ib |
---|---|
date | Thu, 07 Jul 2011 15:09:58 +0000 |
parents | c08363dc5320 |
children |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29826
diff
changeset
|
18 |
15234 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 #include <inttypes.h> | |
15238 | 22 #include <unistd.h> |
15234 | 23 #include <string.h> |
15240 | 24 #include <sys/types.h> |
15234 | 25 #include "m_option.h" |
17012 | 26 #include "mp_msg.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
27 #include "libmpdemux/aviheader.h" |
17012 | 28 #include "libaf/af_format.h" |
25315
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
29 #include "libaf/reorder_ch.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
30 #include "libmpdemux/ms_hdr.h" |
22600
3c2b4a866c6a
Add explicit location for headers from the stream/ directory.
diego
parents:
21660
diff
changeset
|
31 #include "stream/stream.h" |
22601
ed8f90096c65
Add explicit location for headers from the libmpdemux/ directory.
diego
parents:
22600
diff
changeset
|
32 #include "libmpdemux/muxer.h" |
15234 | 33 #include "ae_pcm.h" |
34 | |
35 | |
36 static int bind_pcm(audio_encoder_t *encoder, muxer_stream_t *mux_a) | |
37 { | |
38 mux_a->h.dwScale=1; | |
39 mux_a->h.dwRate=encoder->params.sample_rate; | |
32105 | 40 mux_a->wf=malloc(sizeof(*mux_a->wf)); |
15234 | 41 mux_a->wf->wFormatTag=0x1; // PCM |
42 mux_a->wf->nChannels=encoder->params.channels; | |
43 mux_a->h.dwSampleSize=2*mux_a->wf->nChannels; | |
44 mux_a->wf->nBlockAlign=mux_a->h.dwSampleSize; | |
45 mux_a->wf->nSamplesPerSec=mux_a->h.dwRate; | |
46 mux_a->wf->nAvgBytesPerSec=mux_a->h.dwSampleSize*mux_a->wf->nSamplesPerSec; | |
47 mux_a->wf->wBitsPerSample=16; | |
48 mux_a->wf->cbSize=0; // FIXME for l3codeca.acm | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25315
diff
changeset
|
49 |
15234 | 50 encoder->input_format = (mux_a->wf->wBitsPerSample==8) ? AF_FORMAT_U8 : AF_FORMAT_S16_LE; |
51 encoder->min_buffer_size = 16384; | |
52 encoder->max_buffer_size = mux_a->wf->nAvgBytesPerSec; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25315
diff
changeset
|
53 |
15234 | 54 return 1; |
55 } | |
56 | |
57 static int encode_pcm(audio_encoder_t *encoder, uint8_t *dest, void *src, int nsamples, int max_size) | |
58 { | |
21531
a90aa203186c
Get rid of min/max macros from aviheader.h, they do not belong here.
reimar
parents:
17012
diff
changeset
|
59 max_size = FFMIN(nsamples, max_size); |
29826 | 60 if (encoder->params.channels == 5 || encoder->params.channels == 6 || |
61 encoder->params.channels == 8) { | |
25315
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
62 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
|
63 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
|
64 dest, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
65 encoder->params.channels, |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
66 max_size / 2, 2); |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
67 } |
dfa8a510c81c
Fix all current known multi-channel wrong order problems by adding
ulion
parents:
22601
diff
changeset
|
68 else |
15234 | 69 memcpy(dest, src, max_size); |
70 return max_size; | |
71 } | |
72 | |
15258 | 73 static int set_decoded_len(audio_encoder_t *encoder, int len) |
15234 | 74 { |
15258 | 75 return len; |
15234 | 76 } |
77 | |
78 static int close_pcm(audio_encoder_t *encoder) | |
79 { | |
80 return 1; | |
81 } | |
82 | |
83 static int get_frame_size(audio_encoder_t *encoder) | |
84 { | |
85 return 0; | |
86 } | |
87 | |
88 int mpae_init_pcm(audio_encoder_t *encoder) | |
89 { | |
90 encoder->params.samples_per_frame = encoder->params.sample_rate; | |
91 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
|
92 |
15234 | 93 encoder->decode_buffer_size = encoder->params.bitrate / 8; |
94 encoder->bind = bind_pcm; | |
95 encoder->get_frame_size = get_frame_size; | |
96 encoder->set_decoded_len = set_decoded_len; | |
97 encoder->encode = encode_pcm; | |
98 encoder->close = close_pcm; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
25315
diff
changeset
|
99 |
15234 | 100 return 1; |
101 } |