added flac to the codec table and the demuxer table.

audio format is now taken into account by the decoder when negociating the media output format.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31597 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2009-07-15 22:28:13 +00:00
parent fbe19a11f8
commit 6e94d29882
4 changed files with 31 additions and 2 deletions

View File

@ -330,12 +330,12 @@ AVCodecDecoder::_NegotiateAudioOutputFormat(media_format* inOutFormat)
media_multi_audio_format outputAudioFormat;
outputAudioFormat = media_raw_audio_format::wildcard;
outputAudioFormat.format = media_raw_audio_format::B_AUDIO_SHORT;
outputAudioFormat.byte_order = B_MEDIA_HOST_ENDIAN;
outputAudioFormat.frame_rate
= fInputFormat.u.encoded_audio.output.frame_rate;
outputAudioFormat.channel_count
= fInputFormat.u.encoded_audio.output.channel_count;
outputAudioFormat.format = fInputFormat.u.encoded_audio.output.format;
outputAudioFormat.buffer_size
= 1024 * fInputFormat.u.encoded_audio.output.channel_count;
inOutFormat->type = B_MEDIA_RAW_AUDIO;

View File

@ -46,6 +46,21 @@ extern "C" {
static const size_t kIOBufferSize = 64 * 1024;
// TODO: This could depend on the BMediaFile creation flags, IIRC,
// the allow to specify a buffering mode.
uint32
avformat_to_beos_format(SampleFormat format)
{
switch (format) {
case SAMPLE_FMT_U8: return media_raw_audio_format::B_AUDIO_UCHAR;
case SAMPLE_FMT_S16: return media_raw_audio_format::B_AUDIO_SHORT;
case SAMPLE_FMT_S32: return media_raw_audio_format::B_AUDIO_INT;
case SAMPLE_FMT_FLT: return media_raw_audio_format::B_AUDIO_FLOAT;
case SAMPLE_FMT_DBL: return media_raw_audio_format::B_AUDIO_DOUBLE;
default:
break;
}
return 0;
}
// #pragma mark - AVFormatReader::StreamCookie
@ -351,6 +366,10 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex)
description.family = B_WAV_FORMAT_FAMILY;
codecTag = 0x2000;
break;
case CODEC_ID_FLAC:
description.family = B_WAV_FORMAT_FAMILY;
codecTag = 'flac';
break;
default:
fprintf(stderr, "ffmpeg codecTag is null, codec_id "
"unknown 0x%x\n", codecContext->codec_id);
@ -427,6 +446,8 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex)
case B_MEDIA_RAW_AUDIO:
format->u.raw_audio.frame_rate = (float)codecContext->sample_rate;
format->u.raw_audio.channel_count = codecContext->channels;
format->u.encoded_audio.output.format
= avformat_to_beos_format(codecContext->sample_fmt);
format->u.raw_audio.buffer_size = 0;
// Read one packet and mark it for later re-use. (So our first
@ -448,6 +469,8 @@ AVFormatReader::StreamCookie::Init(int32 virtualIndex)
= (float)codecContext->sample_rate;
format->u.encoded_audio.output.channel_count
= codecContext->channels;
format->u.encoded_audio.output.format
= avformat_to_beos_format(codecContext->sample_fmt);
break;
case B_MEDIA_ENCODED_VIDEO:

View File

@ -61,6 +61,8 @@ const struct codec_table gCodecTable[] = {
{CODEC_ID_WMAV1, B_MEDIA_ENCODED_AUDIO, B_WAV_FORMAT_FAMILY, 0x160, "MS WMA v1"},
{CODEC_ID_WMAV2, B_MEDIA_ENCODED_AUDIO, B_WAV_FORMAT_FAMILY, 0x161, "MS WMA v2"},
{CODEC_ID_FLAC, B_MEDIA_ENCODED_AUDIO, B_WAV_FORMAT_FAMILY, 'flac', "FLAC"},
{CODEC_ID_CINEPAK, B_MEDIA_ENCODED_VIDEO, B_AVI_FORMAT_FAMILY, FOURCC('cvid'), "Cinepak Video"},
{CODEC_ID_CINEPAK, B_MEDIA_ENCODED_VIDEO, B_QUICKTIME_FORMAT_FAMILY, 'cvid', "Cinepak Video"},

View File

@ -70,9 +70,13 @@ static const DemuxerFormat gDemuxerTable[] = {
B_MPEG_FORMAT_FAMILY, B_MPEG_FORMAT_FAMILY
},
{
"dv", "DV Movie", "video/x-dv",
"dv", "DV Movie", "video/dv",
B_WAV_FORMAT_FAMILY, B_QUICKTIME_FORMAT_FAMILY
},
{
"flac", "FLAC", "audio/x-flac",
B_WAV_FORMAT_FAMILY, B_ANY_FORMAT_FAMILY
},
};