Commit 909cfdc2 authored by Martijn van Beurden's avatar Martijn van Beurden Committed by Paul B Mahol

libavcodec/flacdec: Implement decoding of 32 bit-per-sample PCM

Add decoding of FLAC files coding for 32 bit-per-sample PCM to libavcodec.
parent eeb280f3
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "flacdata.h" #include "flacdata.h"
#include "flac_parse.h" #include "flac_parse.h"
static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 0 }; static const int8_t sample_size_table[] = { 0, 8, 12, 0, 16, 20, 24, 32 };
static const AVChannelLayout flac_channel_layouts[8] = { static const AVChannelLayout flac_channel_layouts[8] = {
AV_CHANNEL_LAYOUT_MONO, AV_CHANNEL_LAYOUT_MONO,
...@@ -82,7 +82,7 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb, ...@@ -82,7 +82,7 @@ int ff_flac_decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
/* bits per sample */ /* bits per sample */
bps_code = get_bits(gb, 3); bps_code = get_bits(gb, 3);
if (bps_code == 3 || bps_code == 7) { if (bps_code == 3) {
av_log(avctx, AV_LOG_ERROR + log_level_offset, av_log(avctx, AV_LOG_ERROR + log_level_offset,
"invalid sample size code (%d)\n", "invalid sample size code (%d)\n",
bps_code); bps_code);
......
This diff is collapsed.
...@@ -596,6 +596,18 @@ static inline int get_sbits_long(GetBitContext *s, int n) ...@@ -596,6 +596,18 @@ static inline int get_sbits_long(GetBitContext *s, int n)
return sign_extend(get_bits_long(s, n), n); return sign_extend(get_bits_long(s, n), n);
} }
/**
* Read 0-64 bits as a signed integer.
*/
static inline int64_t get_sbits64(GetBitContext *s, int n)
{
// sign_extend(x, 0) is undefined
if (!n)
return 0;
return sign_extend64(get_bits64(s, n), n);
}
/** /**
* Show 0-32 bits. * Show 0-32 bits.
*/ */
......
...@@ -138,6 +138,15 @@ static inline av_const int sign_extend(int val, unsigned bits) ...@@ -138,6 +138,15 @@ static inline av_const int sign_extend(int val, unsigned bits)
} }
#endif #endif
#ifndef sign_extend64
static inline av_const int64_t sign_extend64(int64_t val, unsigned bits)
{
unsigned shift = 8 * sizeof(int64_t) - bits;
union { uint64_t u; int64_t s; } v = { (uint64_t) val << shift };
return v.s >> shift;
}
#endif
#ifndef zero_extend #ifndef zero_extend
static inline av_const unsigned zero_extend(unsigned val, unsigned bits) static inline av_const unsigned zero_extend(unsigned val, unsigned bits)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment