]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/apedec.c
add casts to silence gcc warnings
[ffmpeg] / libavcodec / apedec.c
index c4aa38f8fdeda5a26e96527e8cf0bb5dda89ebcd..9b8d707135a92c65c946d213b6779f1650b22753 100644 (file)
 #define ALT_BITSTREAM_READER_LE
 #include "avcodec.h"
 #include "dsputil.h"
-#include "bitstream.h"
+#include "get_bits.h"
 #include "bytestream.h"
 
 /**
- * @file apedec.c
+ * @file libavcodec/apedec.c
  * Monkey's Audio lossless audio decoder
  */
 
@@ -171,7 +171,7 @@ static av_cold int ape_decode_init(AVCodecContext * avctx)
         av_log(avctx, AV_LOG_ERROR, "Incorrect extradata\n");
         return -1;
     }
-    if (avctx->bits_per_sample != 16) {
+    if (avctx->bits_per_coded_sample != 16) {
         av_log(avctx, AV_LOG_ERROR, "Only 16-bit samples are supported\n");
         return -1;
     }
@@ -198,6 +198,8 @@ static av_cold int ape_decode_init(AVCodecContext * avctx)
     }
 
     dsputil_init(&s->dsp, avctx);
+    avctx->sample_fmt = SAMPLE_FMT_S16;
+    avctx->channel_layout = (avctx->channels==2) ? CH_LAYOUT_STEREO : CH_LAYOUT_MONO;
     return 0;
 }
 
@@ -246,6 +248,7 @@ static inline void range_dec_normalize(APEContext * ctx)
 
 /**
  * Calculate culmulative frequency for next symbol. Does NO update!
+ * @param ctx decoder context
  * @param tot_f is the total frequency or (code_value)1<<shift
  * @return the culmulative frequency
  */
@@ -258,6 +261,7 @@ static inline int range_decode_culfreq(APEContext * ctx, int tot_f)
 
 /**
  * Decode value with given size in bits
+ * @param ctx decoder context
  * @param shift number of bits to decode
  */
 static inline int range_decode_culshift(APEContext * ctx, int shift)
@@ -270,6 +274,7 @@ static inline int range_decode_culshift(APEContext * ctx, int shift)
 
 /**
  * Update decoding state
+ * @param ctx decoder context
  * @param sy_f the interval length (frequency of the symbol)
  * @param lt_f the lower end (frequency sum of < symbols)
  */
@@ -328,8 +333,9 @@ static const uint16_t counts_diff_3980[21] = {
 
 /**
  * Decode symbol
+ * @param ctx decoder context
  * @param counts probability range start position
- * @param count_diffs probability range widths
+ * @param counts_diff probability range widths
  */
 static inline int range_get_symbol(APEContext * ctx,
                                    const uint16_t counts[],
@@ -357,11 +363,10 @@ static inline int range_get_symbol(APEContext * ctx,
 
 static inline void update_rice(APERice *rice, int x)
 {
+    int lim = rice->k ? (1 << (rice->k + 4)) : 0;
     rice->ksum += ((x + 1) / 2) - ((rice->ksum + 16) >> 5);
 
-    if (rice->k == 0)
-        rice->k = 1;
-    else if (rice->ksum < (1 << (rice->k + 4)))
+    if (rice->ksum < lim)
         rice->k--;
     else if (rice->ksum >= (1 << (rice->k + 5)))
         rice->k++;
@@ -371,7 +376,7 @@ static inline int ape_decode_value(APEContext * ctx, APERice *rice)
 {
     int x, overflow;
 
-    if (ctx->fileversion < 3980) {
+    if (ctx->fileversion < 3990) {
         int tmpk;
 
         overflow = range_get_symbol(ctx, counts_3970, counts_diff_3970);
@@ -801,8 +806,10 @@ static void ape_unpack_stereo(APEContext * ctx, int count)
 
 static int ape_decode_frame(AVCodecContext * avctx,
                             void *data, int *data_size,
-                            const uint8_t * buf, int buf_size)
+                            AVPacket *avpkt)
 {
+    const uint8_t *buf = avpkt->data;
+    int buf_size = avpkt->size;
     APEContext *s = avctx->priv_data;
     int16_t *samples = data;
     int nblocks;