summaryrefslogtreecommitdiffstats
path: root/libavcodec/dpcm.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-11-02 14:15:28 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-11-02 14:20:33 +0100
commit6788350281c418f0f395a8279eee82f7abe7c63b (patch)
tree69cd76f699eff929f5b13f76b42eabc7f25f9355 /libavcodec/dpcm.c
parent00aa7fa786e41b5fc8404732453869aa3c14e33a (diff)
parent50a65e7a540ce6747f81d6dbf6a602ad35be77ff (diff)
downloadffmpeg-streaming-6788350281c418f0f395a8279eee82f7abe7c63b.zip
ffmpeg-streaming-6788350281c418f0f395a8279eee82f7abe7c63b.tar.gz
Merge commit '50a65e7a540ce6747f81d6dbf6a602ad35be77ff'
* commit '50a65e7a540ce6747f81d6dbf6a602ad35be77ff': (24 commits) vmdaudio: set channel layout twinvq: validate sample rate code twinvq: set channel layout twinvq: validate that channels is not <= 0 truespeech: set channel layout sipr: set channel layout shorten: validate that the channel count in the header is not <= 0 ra288dec: set channel layout ra144dec: set channel layout qdm2: remove unneeded checks for channel count qdm2: make sure channels is not <= 0 and set channel layout qcelpdec: set channel layout nellymoserdec: set channels to 1 libopencore-amr: set channel layout for amr-nb or if not set by the user libilbc: set channel layout dpcm: use AVCodecContext.channels instead of keeping a private copy imc: set channels to 1 instead of validating it gsmdec: always set channel layout and sample rate at initialization libgsmdec: always set channel layout and sample rate at initialization g726dec: do not validate sample rate ... Conflicts: libavcodec/dpcm.c libavcodec/qdm2.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dpcm.c')
-rw-r--r--libavcodec/dpcm.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c
index a7c9bb1..1875a55 100644
--- a/libavcodec/dpcm.c
+++ b/libavcodec/dpcm.c
@@ -44,7 +44,6 @@
typedef struct DPCMContext {
AVFrame frame;
- int channels;
int16_t roq_square_array[256];
int sample[2]; ///< previous sample (for SOL_DPCM)
const int8_t *sol_table; ///< delta table for SOL_DPCM
@@ -123,7 +122,6 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- s->channels = avctx->channels;
s->sample[0] = s->sample[1] = 0;
switch(avctx->codec->id) {
@@ -179,7 +177,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
int out = 0, ret;
int predictor[2];
int ch = 0;
- int stereo = s->channels - 1;
+ int stereo = avctx->channels - 1;
int16_t *output_samples, *samples_end;
GetByteContext gb;
@@ -193,10 +191,10 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
out = buf_size - 8;
break;
case AV_CODEC_ID_INTERPLAY_DPCM:
- out = buf_size - 6 - s->channels;
+ out = buf_size - 6 - avctx->channels;
break;
case AV_CODEC_ID_XAN_DPCM:
- out = buf_size - 2 * s->channels;
+ out = buf_size - 2 * avctx->channels;
break;
case AV_CODEC_ID_SOL_DPCM:
if (avctx->codec_tag != 3)
@@ -209,12 +207,12 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
- if (out % s->channels) {
+ if (out % avctx->channels) {
av_log(avctx, AV_LOG_WARNING, "channels have differing number of samples\n");
}
/* get output buffer */
- s->frame.nb_samples = (out + s->channels - 1) / s->channels;
+ s->frame.nb_samples = (out + avctx->channels - 1) / avctx->channels;
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
@@ -248,7 +246,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
case AV_CODEC_ID_INTERPLAY_DPCM:
bytestream2_skipu(&gb, 6); /* skip over the stream mask and stream length */
- for (ch = 0; ch < s->channels; ch++) {
+ for (ch = 0; ch < avctx->channels; ch++) {
predictor[ch] = sign_extend(bytestream2_get_le16u(&gb), 16);
*output_samples++ = predictor[ch];
}
@@ -268,7 +266,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
{
int shift[2] = { 4, 4 };
- for (ch = 0; ch < s->channels; ch++)
+ for (ch = 0; ch < avctx->channels; ch++)
predictor[ch] = sign_extend(bytestream2_get_le16u(&gb), 16);
ch = 0;
OpenPOWER on IntegriCloud