Use proper length specifiers in mp_msg calls, fixes the warnings:
[mplayer/greg.git] / libmpcodecs / ae_pcm.c
blob2fcc5e32e0bc15bc0b0f2e02c8f23c45d349cecf
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <inttypes.h>
4 #include <unistd.h>
5 #include <string.h>
6 #include <sys/types.h>
7 #include "m_option.h"
8 #include "mp_msg.h"
9 #include "libmpdemux/aviheader.h"
10 #include "libaf/af_format.h"
11 #include "libaf/reorder_ch.h"
12 #include "libmpdemux/ms_hdr.h"
13 #include "stream/stream.h"
14 #include "libmpdemux/muxer.h"
15 #include "ae_pcm.h"
18 static int bind_pcm(audio_encoder_t *encoder, muxer_stream_t *mux_a)
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
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;
36 return 1;
39 static int encode_pcm(audio_encoder_t *encoder, uint8_t *dest, void *src, int nsamples, int max_size)
41 max_size = FFMIN(nsamples, max_size);
42 if (encoder->params.channels == 6 || encoder->params.channels == 5) {
43 max_size -= max_size % (encoder->params.channels * 2);
44 reorder_channel_copy_nch(src, AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
45 dest, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT,
46 encoder->params.channels,
47 max_size / 2, 2);
49 else
50 memcpy(dest, src, max_size);
51 return max_size;
54 static int set_decoded_len(audio_encoder_t *encoder, int len)
56 return len;
59 static int close_pcm(audio_encoder_t *encoder)
61 return 1;
64 static int get_frame_size(audio_encoder_t *encoder)
66 return 0;
69 int mpae_init_pcm(audio_encoder_t *encoder)
71 encoder->params.samples_per_frame = encoder->params.sample_rate;
72 encoder->params.bitrate = encoder->params.sample_rate * encoder->params.channels * 2 * 8;
74 encoder->decode_buffer_size = encoder->params.bitrate / 8;
75 encoder->bind = bind_pcm;
76 encoder->get_frame_size = get_frame_size;
77 encoder->set_decoded_len = set_decoded_len;
78 encoder->encode = encode_pcm;
79 encoder->close = close_pcm;
81 return 1;