summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Melanson <mike@multimedia.cx>2004-06-10 04:46:18 +0000
committerMike Melanson <mike@multimedia.cx>2004-06-10 04:46:18 +0000
commit7d61144f3cc52f58978c165ae023fb610aaab9e1 (patch)
treeca1c98013fc12236dd99cbcba7949b72c3dea193
parent5c21abe208938b0dbff4a4fea60b715bb58b9c36 (diff)
downloadxine-lib-7d61144f3cc52f58978c165ae023fb610aaab9e1.tar.gz
xine-lib-7d61144f3cc52f58978c165ae023fb610aaab9e1.tar.bz2
hook up ffmpeg's FLAC decoder
CVS patchset: 6664 CVS date: 2004/06/10 04:46:18
-rw-r--r--src/libffmpeg/audio_decoder.c6
-rw-r--r--src/libffmpeg/libavcodec/Makefile.am1
-rw-r--r--src/libffmpeg/libavcodec/flac.c24
-rw-r--r--src/libffmpeg/xine_decoder.c3
4 files changed, 29 insertions, 5 deletions
diff --git a/src/libffmpeg/audio_decoder.c b/src/libffmpeg/audio_decoder.c
index 01af6e137..7400617b0 100644
--- a/src/libffmpeg/audio_decoder.c
+++ b/src/libffmpeg/audio_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: audio_decoder.c,v 1.10 2004/06/06 16:13:30 jstembridge Exp $
+ * $Id: audio_decoder.c,v 1.11 2004/06/10 04:46:18 tmmm Exp $
*
* xine audio decoder plugin using ffmpeg
*
@@ -98,7 +98,8 @@ static const ff_codec_t ff_audio_lookup[] = {
{BUF_AUDIO_MAC3, CODEC_ID_MACE3, "MACE 3:1 (ffmpeg)"},
{BUF_AUDIO_MAC6, CODEC_ID_MACE6, "MACE 6:1 (ffmpeg)"},
{BUF_AUDIO_XAN_DPCM, CODEC_ID_XAN_DPCM, "Origin Xan DPCM (ffmpeg)"},
- {BUF_AUDIO_VMD, CODEC_ID_VMDAUDIO, "Sierra VMD Audio (ffmpeg)"} };
+ {BUF_AUDIO_VMD, CODEC_ID_VMDAUDIO, "Sierra VMD Audio (ffmpeg)"},
+ {BUF_AUDIO_FLAC, CODEC_ID_FLAC, "FLAC (ffmpeg)"} };
static void ff_audio_ensure_buffer_size(ff_audio_decoder_t *this, int size) {
@@ -428,6 +429,7 @@ static uint32_t supported_audio_types[] = {
BUF_AUDIO_VMD,
BUF_AUDIO_EA_ADPCM,
BUF_AUDIO_SMJPEG_IMA,
+ BUF_AUDIO_FLAC,
/* BUF_AUDIO_MPEG, */
0
};
diff --git a/src/libffmpeg/libavcodec/Makefile.am b/src/libffmpeg/libavcodec/Makefile.am
index 78752e5fe..f097127cb 100644
--- a/src/libffmpeg/libavcodec/Makefile.am
+++ b/src/libffmpeg/libavcodec/Makefile.am
@@ -29,6 +29,7 @@ libavcodec_la_SOURCES = \
error_resilience.c \
eval.c \
faandct.c \
+ flac.c \
flicvideo.c \
fft.c \
golomb.c \
diff --git a/src/libffmpeg/libavcodec/flac.c b/src/libffmpeg/libavcodec/flac.c
index 7e92fa59e..382082627 100644
--- a/src/libffmpeg/libavcodec/flac.c
+++ b/src/libffmpeg/libavcodec/flac.c
@@ -21,6 +21,14 @@
* @file flac.c
* FLAC (Free Lossless Audio Codec) decoder
* @author Alex Beregszaszi
+ *
+ * For more information on the FLAC format, visit:
+ * http://flac.sourceforge.net/
+ *
+ * This decoder can be used in 1 of 2 ways: Either raw FLAC data can be fed
+ * through, starting from the initial 'fLaC' signature; or by passing the
+ * 34-byte streaminfo structure through avctx->extradata[_size] followed
+ * by data starting with the 0xFFF8 marker.
*/
#include <limits.h>
@@ -33,6 +41,7 @@
#define MAX_CHANNELS 8
#define MAX_BLOCKSIZE 65535
+#define FLAC_STREAMINFO_SIZE 34
enum decorrelation_type {
INDEPENDENT,
@@ -144,8 +153,21 @@ static int get_crc8(const uint8_t *buf, int count){
return crc;
}
+static void metadata_streaminfo(FLACContext *s);
+static void dump_headers(FLACContext *s);
+
static int flac_decode_init(AVCodecContext * avctx)
{
+ FLACContext *s = avctx->priv_data;
+ s->avctx = avctx;
+
+ /* initialize based on the demuxer-supplied streamdata header */
+ if (avctx->extradata_size == FLAC_STREAMINFO_SIZE) {
+ init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
+ metadata_streaminfo(s);
+ dump_headers(s);
+ }
+
return 0;
}
@@ -546,8 +568,6 @@ static int flac_decode_frame(AVCodecContext *avctx,
int tmp = 0, i, j = 0, input_buf_size;
int16_t *samples = data, *left, *right;
- s->avctx = avctx;
-
if(s->max_framesize == 0){
s->max_framesize= 8192; // should hopefully be enough for the first header
s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
diff --git a/src/libffmpeg/xine_decoder.c b/src/libffmpeg/xine_decoder.c
index 3bb5a46b4..9071c118e 100644
--- a/src/libffmpeg/xine_decoder.c
+++ b/src/libffmpeg/xine_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.159 2004/03/14 21:24:21 tmmm Exp $
+ * $Id: xine_decoder.c,v 1.160 2004/06/10 04:46:18 tmmm Exp $
*
* xine decoder plugin using ffmpeg
*
@@ -114,6 +114,7 @@ void avcodec_register_all(void)
register_avcodec(&vcr1_decoder);
register_avcodec(&flv_decoder);
register_avcodec(&qtrle_decoder);
+ register_avcodec(&flac_decoder);
}
void init_once_routine(void) {