Browse Source

use function and definitions from libavcodec/flac.h in oggparseflac.c

Originally committed as revision 16767 to svn://svn.ffmpeg.org/ffmpeg/trunk
tags/v0.5
Justin Ruggles 16 years ago
parent
commit
7fa9a0a256
1 changed files with 8 additions and 9 deletions
  1. +8
    -9
      libavformat/oggparseflac.c

+ 8
- 9
libavformat/oggparseflac.c View File

@@ -20,10 +20,11 @@


#include <stdlib.h> #include <stdlib.h>
#include "libavcodec/bitstream.h" #include "libavcodec/bitstream.h"
#include "libavcodec/flac.h"
#include "avformat.h" #include "avformat.h"
#include "oggdec.h" #include "oggdec.h"


#define FLAC_STREAMINFO_SIZE 0x22
#define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F


static int static int
flac_header (AVFormatContext * s, int idx) flac_header (AVFormatContext * s, int idx)
@@ -32,6 +33,7 @@ flac_header (AVFormatContext * s, int idx)
struct ogg_stream *os = ogg->streams + idx; struct ogg_stream *os = ogg->streams + idx;
AVStream *st = s->streams[idx]; AVStream *st = s->streams[idx];
GetBitContext gb; GetBitContext gb;
FLACStreaminfo si;
int mdt; int mdt;


if (os->buf[os->pstart] == 0xff) if (os->buf[os->pstart] == 0xff)
@@ -41,7 +43,8 @@ flac_header (AVFormatContext * s, int idx)
skip_bits1(&gb); /* metadata_last */ skip_bits1(&gb); /* metadata_last */
mdt = get_bits(&gb, 7); mdt = get_bits(&gb, 7);


if (mdt == 0x7f) {
if (mdt == OGG_FLAC_METADATA_TYPE_STREAMINFO) {
uint8_t *streaminfo_start = os->buf + os->pstart + 5 + 4 + 4 + 4;
skip_bits_long(&gb, 4*8); /* "FLAC" */ skip_bits_long(&gb, 4*8); /* "FLAC" */
if(get_bits(&gb, 8) != 1) /* unsupported major version */ if(get_bits(&gb, 8) != 1) /* unsupported major version */
return -1; return -1;
@@ -52,23 +55,19 @@ flac_header (AVFormatContext * s, int idx)
if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE) if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE)
return -1; return -1;


skip_bits_long(&gb, 16*2+24*2);

st->codec->sample_rate = get_bits_long(&gb, 20);
st->codec->channels = get_bits(&gb, 3) + 1;
ff_flac_parse_streaminfo(st->codec, &si, streaminfo_start);


st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_FLAC; st->codec->codec_id = CODEC_ID_FLAC;


st->codec->extradata = st->codec->extradata =
av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy (st->codec->extradata, os->buf + os->pstart + 5 + 4 + 4 + 4,
FLAC_STREAMINFO_SIZE);
memcpy(st->codec->extradata, streaminfo_start, FLAC_STREAMINFO_SIZE);
st->codec->extradata_size = FLAC_STREAMINFO_SIZE; st->codec->extradata_size = FLAC_STREAMINFO_SIZE;


st->time_base.num = 1; st->time_base.num = 1;
st->time_base.den = st->codec->sample_rate; st->time_base.den = st->codec->sample_rate;
} else if (mdt == 4) {
} else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4); vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4);
} }




Loading…
Cancel
Save