* \param src_len number of bytes in src
*/
static inline void decode_to16(int bps, int le, int us,
- uint8_t **src, short **samples, int src_len)
+ const uint8_t **src, short **samples, int src_len)
{
int usum = us ? -0x8000 : 0;
register int n = src_len / bps;
static int pcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- uint8_t *buf, int buf_size)
+ const uint8_t *buf, int buf_size)
{
PCMDecode *s = avctx->priv_data;
int c, n;
short *samples;
- uint8_t *src, *src2[MAX_CHANNELS];
+ const uint8_t *src, *src2[MAX_CHANNELS];
samples = data;
src = buf;
n= av_get_bits_per_sample(avctx->codec_id)/8;
- if((n && buf_size % n) || avctx->channels > MAX_CHANNELS){
+ if(n && buf_size % n){
av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n");
return -1;
}
+ if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){
+ av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n");
+ return -1;
+ }
buf_size= FFMIN(buf_size, *data_size/2);
*data_size=0;
#define PCM_CODEC(id, name) \
PCM_ENCODER(id,name) PCM_DECODER(id,name)
-PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
-PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
-PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
-PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
-PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
-PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
-PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
-PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
-PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
-PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
+PCM_CODEC (CODEC_ID_PCM_S32LE, pcm_s32le);
+PCM_CODEC (CODEC_ID_PCM_S32BE, pcm_s32be);
+PCM_CODEC (CODEC_ID_PCM_U32LE, pcm_u32le);
+PCM_CODEC (CODEC_ID_PCM_U32BE, pcm_u32be);
+PCM_CODEC (CODEC_ID_PCM_S24LE, pcm_s24le);
+PCM_CODEC (CODEC_ID_PCM_S24BE, pcm_s24be);
+PCM_CODEC (CODEC_ID_PCM_U24LE, pcm_u24le);
+PCM_CODEC (CODEC_ID_PCM_U24BE, pcm_u24be);
+PCM_CODEC (CODEC_ID_PCM_S24DAUD, pcm_s24daud);
+PCM_CODEC (CODEC_ID_PCM_S16LE, pcm_s16le);
PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, pcm_s16le_planar);
-PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
-PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
-PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
-PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
-PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
-PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
-PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
-PCM_CODEC(CODEC_ID_PCM_ZORK, pcm_zork);
+PCM_CODEC (CODEC_ID_PCM_S16BE, pcm_s16be);
+PCM_CODEC (CODEC_ID_PCM_U16LE, pcm_u16le);
+PCM_CODEC (CODEC_ID_PCM_U16BE, pcm_u16be);
+PCM_CODEC (CODEC_ID_PCM_S8, pcm_s8);
+PCM_CODEC (CODEC_ID_PCM_U8, pcm_u8);
+PCM_CODEC (CODEC_ID_PCM_ALAW, pcm_alaw);
+PCM_CODEC (CODEC_ID_PCM_MULAW, pcm_mulaw);
+PCM_CODEC (CODEC_ID_PCM_ZORK, pcm_zork);