... | ... |
@@ -196,13 +196,13 @@ static av_cold int ape_decode_init(AVCodecContext *avctx) |
196 | 196 |
s->bps = avctx->bits_per_coded_sample; |
197 | 197 |
switch (s->bps) { |
198 | 198 |
case 8: |
199 |
- avctx->sample_fmt = AV_SAMPLE_FMT_U8; |
|
199 |
+ avctx->sample_fmt = AV_SAMPLE_FMT_U8P; |
|
200 | 200 |
break; |
201 | 201 |
case 16: |
202 |
- avctx->sample_fmt = AV_SAMPLE_FMT_S16; |
|
202 |
+ avctx->sample_fmt = AV_SAMPLE_FMT_S16P; |
|
203 | 203 |
break; |
204 | 204 |
case 24: |
205 |
- avctx->sample_fmt = AV_SAMPLE_FMT_S32; |
|
205 |
+ avctx->sample_fmt = AV_SAMPLE_FMT_S32P; |
|
206 | 206 |
break; |
207 | 207 |
default: |
208 | 208 |
av_log_ask_for_sample(avctx, "Unsupported bits per coded sample %d\n", |
... | ... |
@@ -830,7 +830,7 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, |
830 | 830 |
uint8_t *sample8; |
831 | 831 |
int16_t *sample16; |
832 | 832 |
int32_t *sample24; |
833 |
- int i, ret; |
|
833 |
+ int i, ch, ret; |
|
834 | 834 |
int blockstodecode; |
835 | 835 |
int bytes_used = 0; |
836 | 836 |
|
... | ... |
@@ -930,27 +930,24 @@ static int ape_decode_frame(AVCodecContext *avctx, void *data, |
930 | 930 |
|
931 | 931 |
switch (s->bps) { |
932 | 932 |
case 8: |
933 |
- sample8 = (uint8_t *)s->frame.data[0]; |
|
934 |
- for (i = 0; i < blockstodecode; i++) { |
|
935 |
- *sample8++ = (s->decoded[0][i] + 0x80) & 0xff; |
|
936 |
- if (s->channels == 2) |
|
937 |
- *sample8++ = (s->decoded[1][i] + 0x80) & 0xff; |
|
933 |
+ for (ch = 0; ch < s->channels; ch++) { |
|
934 |
+ sample8 = (uint8_t *)s->frame.data[ch]; |
|
935 |
+ for (i = 0; i < blockstodecode; i++) |
|
936 |
+ *sample8++ = (s->decoded[ch][i] + 0x80) & 0xff; |
|
938 | 937 |
} |
939 | 938 |
break; |
940 | 939 |
case 16: |
941 |
- sample16 = (int16_t *)s->frame.data[0]; |
|
942 |
- for (i = 0; i < blockstodecode; i++) { |
|
943 |
- *sample16++ = s->decoded[0][i]; |
|
944 |
- if (s->channels == 2) |
|
945 |
- *sample16++ = s->decoded[1][i]; |
|
940 |
+ for (ch = 0; ch < s->channels; ch++) { |
|
941 |
+ sample16 = (int16_t *)s->frame.data[ch]; |
|
942 |
+ for (i = 0; i < blockstodecode; i++) |
|
943 |
+ *sample16++ = s->decoded[ch][i]; |
|
946 | 944 |
} |
947 | 945 |
break; |
948 | 946 |
case 24: |
949 |
- sample24 = (int32_t *)s->frame.data[0]; |
|
950 |
- for (i = 0; i < blockstodecode; i++) { |
|
951 |
- *sample24++ = s->decoded[0][i] << 8; |
|
952 |
- if (s->channels == 2) |
|
953 |
- *sample24++ = s->decoded[1][i] << 8; |
|
947 |
+ for (ch = 0; ch < s->channels; ch++) { |
|
948 |
+ sample24 = (int32_t *)s->frame.data[ch]; |
|
949 |
+ for (i = 0; i < blockstodecode; i++) |
|
950 |
+ *sample24++ = s->decoded[ch][i] << 8; |
|
954 | 951 |
} |
955 | 952 |
break; |
956 | 953 |
} |
... | ... |
@@ -995,5 +992,9 @@ AVCodec ff_ape_decoder = { |
995 | 995 |
.capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1, |
996 | 996 |
.flush = ape_flush, |
997 | 997 |
.long_name = NULL_IF_CONFIG_SMALL("Monkey's Audio"), |
998 |
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P, |
|
999 |
+ AV_SAMPLE_FMT_S16P, |
|
1000 |
+ AV_SAMPLE_FMT_S32P, |
|
1001 |
+ AV_SAMPLE_FMT_NONE }, |
|
998 | 1002 |
.priv_class = &ape_decoder_class, |
999 | 1003 |
}; |