annotate libmpcodecs/ae_pcm.c @ 15237:55d9619d75e5

replace Carbon.h by coreFoundation.h, fix build with x11 enable on mac osx with --enable-macosx-bundle enable
author nplourde
date Fri, 22 Apr 2005 12:45:29 +0000
parents e84a6ae9d51e
children 2cc48c37a7eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15234
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
1 #include <stdio.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
2 #include <stdlib.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
3 #include <inttypes.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
4 #include <string.h>
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
5 #include "m_option.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
6 #include "../mp_msg.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
7 #include "aviheader.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
8 #include "../libaf/af_format.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
9 #include "ms_hdr.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
10 #include "muxer.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
11 #include "ae_pcm.h"
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
12
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
13
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
14 static int bind_pcm(audio_encoder_t *encoder, muxer_stream_t *mux_a)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
15 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
16 mux_a->h.dwScale=1;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
17 mux_a->h.dwRate=encoder->params.sample_rate;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
18 mux_a->wf=malloc(sizeof(WAVEFORMATEX));
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
19 mux_a->wf->wFormatTag=0x1; // PCM
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
20 mux_a->wf->nChannels=encoder->params.channels;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
21 mux_a->h.dwSampleSize=2*mux_a->wf->nChannels;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
22 mux_a->wf->nBlockAlign=mux_a->h.dwSampleSize;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
23 mux_a->wf->nSamplesPerSec=mux_a->h.dwRate;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
24 mux_a->wf->nAvgBytesPerSec=mux_a->h.dwSampleSize*mux_a->wf->nSamplesPerSec;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
25 mux_a->wf->wBitsPerSample=16;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
26 mux_a->wf->cbSize=0; // FIXME for l3codeca.acm
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
27
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
28 encoder->input_format = (mux_a->wf->wBitsPerSample==8) ? AF_FORMAT_U8 : AF_FORMAT_S16_LE;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
29 encoder->min_buffer_size = 16384;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
30 encoder->max_buffer_size = mux_a->wf->nAvgBytesPerSec;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
31
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
32 return 1;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
33 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
34
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
35 static int encode_pcm(audio_encoder_t *encoder, uint8_t *dest, void *src, int nsamples, int max_size)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
36 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
37 max_size = min(nsamples, max_size);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
38 memcpy(dest, src, max_size);
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
39 return max_size;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
40 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
41
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
42 static void set_decoded_len(audio_encoder_t *encoder, int len)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
43 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
44 return;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
45 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
46
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
47 static int close_pcm(audio_encoder_t *encoder)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
48 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
49 return 1;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
50 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
51
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
52 static int get_frame_size(audio_encoder_t *encoder)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
53 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
54 return 0;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
55 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
56
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
57 int mpae_init_pcm(audio_encoder_t *encoder)
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
58 {
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
59 encoder->params.samples_per_frame = encoder->params.sample_rate;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
60 encoder->params.bitrate = encoder->params.sample_rate * encoder->params.channels * 2 * 8;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
61
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
62 encoder->decode_buffer_size = encoder->params.bitrate / 8;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
63 encoder->bind = bind_pcm;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
64 encoder->get_frame_size = get_frame_size;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
65 encoder->set_decoded_len = set_decoded_len;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
66 encoder->encode = encode_pcm;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
67 encoder->close = close_pcm;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
68
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
69 return 1;
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
70 }
e84a6ae9d51e audio encoding reworked
nicodvb
parents:
diff changeset
71