summaryrefslogtreecommitdiff
path: root/libavcodec/smacker.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-10 03:09:46 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-10 03:45:23 +0100
commitafc0a24d7d60f855676d8069011624d52361d7ed (patch)
tree5480e1c0a3f177805d9a2a85321117a94a2bf878 /libavcodec/smacker.c
parentdec354ba1dcc3c7858277d30c73dac030e2a441e (diff)
parentf1f6d3615f3f9a81f41905ea0c8116b4985870e4 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: avcodec: add support for planar signed 8-bit PCM. ra144enc: add sample_fmts list to ff_ra_144_encoder smackaud: use uint8_t* for 8-bit output buffer type smackaud: clip output samples smackaud: use sign_extend() for difference value instead of casting sipr: use a function pointer to select the decode_frame function sipr: set mode based on block_align instead of bit_rate sipr: do not needlessly set *data_size to 0 when returning an error ra288: fix formatting of LOCAL_ALIGNED_16 udp: Allow specifying the local IP address VC1: Add bottom field offset to block_index[] to avoid rewriting (+10L) vc1dec: move an if() block. vc1dec: use correct hybrid prediction threshold. vc1dec: Partial rewrite of vc1_pred_mv() vc1dec: take ME precision into account while scaling MV predictors. lavf: don't leak corrupted packets Conflicts: libavcodec/8svx.c libavcodec/ra288.c libavcodec/version.h libavformat/iff.c libavformat/udp.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/smacker.c')
-rw-r--r--libavcodec/smacker.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 04acaec21c..8345b7f8a0 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -33,6 +33,7 @@
#include "avcodec.h"
#include "libavutil/audioconvert.h"
+#include "mathops.h"
#define ALT_BITSTREAM_READER_LE
#include "get_bits.h"
@@ -580,7 +581,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
HuffContext h[4];
VLC vlc[4];
int16_t *samples = data;
- int8_t *samples8 = data;
+ uint8_t *samples8 = data;
int val;
int i, res;
int unp_size;
@@ -656,8 +657,8 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
else
res = 0;
val |= h[3].values[res] << 8;
- pred[1] += (int16_t)val;
- *samples++ = pred[1];
+ pred[1] += sign_extend(val, 16);
+ *samples++ = av_clip_int16(pred[1]);
} else {
if(vlc[0].table)
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
@@ -669,8 +670,8 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
else
res = 0;
val |= h[1].values[res] << 8;
- pred[0] += val;
- *samples++ = pred[0];
+ pred[0] += sign_extend(val, 16);
+ *samples++ = av_clip_int16(pred[0]);
}
}
} else { //8-bit data
@@ -684,15 +685,15 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
else
res = 0;
- pred[1] += (int8_t)h[1].values[res];
- *samples8++ = pred[1];
+ pred[1] += sign_extend(h[1].values[res], 8);
+ *samples8++ = av_clip_uint8(pred[1]);
} else {
if(vlc[0].table)
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
else
res = 0;
- pred[0] += (int8_t)h[0].values[res];
- *samples8++ = pred[0];
+ pred[0] += sign_extend(h[0].values[res], 8);
+ *samples8++ = av_clip_uint8(pred[0]);
}
}
}