Updated all decoders to the changed codec API (from meta_descriptions to
BMediaFormats based detection). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6248 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -82,6 +82,15 @@ mp3Decoder::~mp3Decoder()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
mp3Decoder::GetCodecInfo(media_codec_info &info)
|
||||
{
|
||||
strcpy(info.short_name, "mp3");
|
||||
strcpy(info.pretty_name, "MPEG 1/2.5 audio layer 1/2/3 decoder, based on mpeg123 mpglib");
|
||||
// ToDo: could alter the above string depending on the real format
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
mp3Decoder::Setup(media_format *ioEncodedFormat,
|
||||
const void *infoBuffer, int32 infoSize)
|
||||
@@ -334,18 +343,32 @@ mp3DecoderPlugin::NewDecoder()
|
||||
|
||||
|
||||
status_t
|
||||
mp3DecoderPlugin::RegisterPlugin()
|
||||
mp3DecoderPlugin::RegisterDecoder()
|
||||
{
|
||||
PublishDecoder("audiocodec/mpeg1layer1", "mp3", "MPEG 1 audio layer 1 decoder, based on mpeg123 mpglib");
|
||||
PublishDecoder("audiocodec/mpeg1layer2", "mp3", "MPEG 1 audio layer 2 decoder, based on mpeg123 mpglib");
|
||||
PublishDecoder("audiocodec/mpeg1layer3", "mp3", "MPEG 1 audio layer 3 decoder, based on mpeg123 mpglib");
|
||||
PublishDecoder("audiocodec/mpeg2layer1", "mp3", "MPEG 2 audio layer 1 decoder, based on mpeg123 mpglib");
|
||||
PublishDecoder("audiocodec/mpeg2layer2", "mp3", "MPEG 2 audio layer 2 decoder, based on mpeg123 mpglib");
|
||||
PublishDecoder("audiocodec/mpeg2layer3", "mp3", "MPEG 2 audio layer 3 decoder, based on mpeg123 mpglib");
|
||||
PublishDecoder("audiocodec/mpeg2.5layer1", "mp3", "MPEG 2.5 audio layer 1 decoder, based on mpeg123 mpglib");
|
||||
PublishDecoder("audiocodec/mpeg2.5layer2", "mp3", "MPEG 2.5 audio layer 2 decoder, based on mpeg123 mpglib");
|
||||
PublishDecoder("audiocodec/mpeg2.5layer3", "mp3", "MPEG 2.5 audio layer 3 decoder, based on mpeg123 mpglib");
|
||||
return B_OK;
|
||||
const mpeg_id ids[] = {
|
||||
B_MPEG_1_AUDIO_LAYER_1,
|
||||
B_MPEG_1_AUDIO_LAYER_2,
|
||||
B_MPEG_1_AUDIO_LAYER_3, // "MP3"
|
||||
B_MPEG_2_AUDIO_LAYER_1,
|
||||
B_MPEG_2_AUDIO_LAYER_2,
|
||||
B_MPEG_2_AUDIO_LAYER_3,
|
||||
B_MPEG_2_5_AUDIO_LAYER_1,
|
||||
B_MPEG_2_5_AUDIO_LAYER_2,
|
||||
B_MPEG_2_5_AUDIO_LAYER_3,
|
||||
};
|
||||
const size_t numIDs = sizeof(ids) / sizeof(mpeg_id);
|
||||
|
||||
media_format_description descriptions[numIDs];
|
||||
for (size_t i = 0; i < numIDs; i++) {
|
||||
descriptions[i].family = B_MPEG_FORMAT_FAMILY;
|
||||
descriptions[i].u.mpeg.id = ids[i];
|
||||
}
|
||||
|
||||
media_format format;
|
||||
format.type = B_MEDIA_ENCODED_AUDIO;
|
||||
format.u.encoded_audio = media_encoded_audio_format::wildcard;
|
||||
|
||||
return BMediaFormats().MakeFormatFor(descriptions, numIDs, &format);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ public:
|
||||
mp3Decoder();
|
||||
~mp3Decoder();
|
||||
|
||||
void GetCodecInfo(media_codec_info &codecInfo);
|
||||
|
||||
status_t Setup(media_format *ioEncodedFormat,
|
||||
const void *infoBuffer, int32 infoSize);
|
||||
|
||||
@@ -45,5 +47,5 @@ class mp3DecoderPlugin : public DecoderPlugin
|
||||
{
|
||||
public:
|
||||
Decoder * NewDecoder();
|
||||
status_t RegisterPlugin();
|
||||
status_t RegisterDecoder();
|
||||
};
|
||||
|
||||
@@ -22,10 +22,19 @@ MusePackPlugin::NewDecoder()
|
||||
}
|
||||
|
||||
status_t
|
||||
MusePackPlugin::RegisterPlugin()
|
||||
MusePackPlugin::RegisterDecoder()
|
||||
{
|
||||
PublishDecoder("audiocodec/musepack", "musepack", "musepack decoder");
|
||||
return B_OK;
|
||||
media_format_description description;
|
||||
description.family = B_MISC_FORMAT_FAMILY;
|
||||
description.u.misc.file_format = 'mpc ';
|
||||
description.u.misc.codec = 'MPC7';
|
||||
// 7 is the most recent stream version
|
||||
|
||||
media_format format;
|
||||
format.type = B_MEDIA_ENCODED_AUDIO;
|
||||
format.u.encoded_audio = media_encoded_audio_format::wildcard;
|
||||
|
||||
return BMediaFormats().MakeFormatFor(&description, 1, &format);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class MusePackPlugin : public ReaderPlugin, public DecoderPlugin {
|
||||
Reader *NewReader();
|
||||
|
||||
Decoder *NewDecoder();
|
||||
status_t RegisterPlugin();
|
||||
status_t RegisterDecoder();
|
||||
};
|
||||
|
||||
#endif /* MUSEPACK_PLUGIN_H */
|
||||
|
||||
@@ -21,6 +21,14 @@ MusePackDecoder::~MusePackDecoder()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MusePackDecoder::GetCodecInfo(media_codec_info &info)
|
||||
{
|
||||
strcpy(info.short_name, "musepack");
|
||||
strcpy(info.pretty_name, "MusePack audio codec based on mpcdec by Andree Buschmann");
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
MusePackDecoder::Setup(media_format *ioEncodedFormat, const void *infoBuffer, int32 infoSize)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,9 @@ class MusePackDecoder : public Decoder {
|
||||
public:
|
||||
MusePackDecoder();
|
||||
~MusePackDecoder();
|
||||
|
||||
|
||||
void GetCodecInfo(media_codec_info &info);
|
||||
|
||||
status_t Setup(media_format *ioEncodedFormat,
|
||||
const void *infoBuffer, int32 infoSize);
|
||||
|
||||
|
||||
@@ -41,11 +41,12 @@ MusePackReader::Sniff(int32 *_streamCount)
|
||||
int error = fInfo.ReadStreamInfo(file);
|
||||
if (error > B_OK) {
|
||||
// error came from engine
|
||||
printf("MusePack: ReadStreamInfo() engine error %d\n", error);
|
||||
printf("MusePackReader: ReadStreamInfo() engine error %d\n", error);
|
||||
return B_ERROR;
|
||||
} else if (error < B_OK)
|
||||
return error;
|
||||
|
||||
printf("MusePackReader: recognized MPC file\n");
|
||||
*_streamCount = 1;
|
||||
return B_OK;
|
||||
}
|
||||
@@ -87,10 +88,13 @@ MusePackReader::GetStreamInfo(void *cookie, int64 *_frameCount, bigtime_t *_dura
|
||||
|
||||
media_format_description description;
|
||||
description.family = B_MISC_FORMAT_FAMILY;
|
||||
description.u.misc.file_format = 'mpc ';
|
||||
description.u.misc.codec = 'MPC7';
|
||||
// ToDo: does this make any sense? BTW '7' is the most recent stream version...
|
||||
BMediaFormats formats;
|
||||
formats.GetFormatFor(description, format);
|
||||
// 7 is the most recent stream version
|
||||
|
||||
status_t status = BMediaFormats().GetFormatFor(description, format);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
// allocate and initialize internal decoder
|
||||
MPC_decoder *decoder = new MPC_decoder(static_cast<BPositionIO *>(Source()));
|
||||
|
||||
@@ -123,8 +123,9 @@ GetVorbisCodecStreamInfo(std::vector<ogg_packet> * packets,
|
||||
format->type = B_MEDIA_ENCODED_AUDIO;
|
||||
format->user_data_type = B_CODEC_TYPE_INFO;
|
||||
strncpy((char*)format->user_data, "vorb", 4);
|
||||
format->u.encoded_audio.encoding
|
||||
= (media_encoded_audio_format::audio_encoding)'vorb';
|
||||
// ToDo: that won't work any longer
|
||||
//format->u.encoded_audio.encoding
|
||||
// = (media_encoded_audio_format::audio_encoding)'vorb';
|
||||
if (info.bitrate_nominal > 0) {
|
||||
format->u.encoded_audio.bit_rate = info.bitrate_nominal;
|
||||
} else if (info.bitrate_upper > 0) {
|
||||
@@ -205,8 +206,9 @@ GetSpeexCodecStreamInfo(std::vector<ogg_packet> * packets,
|
||||
format->type = B_MEDIA_ENCODED_AUDIO;
|
||||
format->user_data_type = B_CODEC_TYPE_INFO;
|
||||
strncpy((char*)format->user_data,"Spee",4);
|
||||
format->u.encoded_audio.encoding
|
||||
= (media_encoded_audio_format::audio_encoding)'Spee';
|
||||
// ToDo: that won't work any longer
|
||||
//format->u.encoded_audio.encoding
|
||||
// = (media_encoded_audio_format::audio_encoding)'Spee';
|
||||
if (header->bitrate > 0) {
|
||||
format->u.encoded_audio.bit_rate = header->bitrate;
|
||||
} else {
|
||||
@@ -301,10 +303,11 @@ GetTobiasCodecStreamInfo(std::vector<ogg_packet> * packets,
|
||||
format->type = B_MEDIA_ENCODED_VIDEO;
|
||||
format->user_data_type = B_CODEC_TYPE_INFO;
|
||||
strncpy((char*)format->user_data,header->subtype,4);
|
||||
int32 encoding = header->subtype[0] << 24 | header->subtype[1] << 16
|
||||
| header->subtype[2] << 8 | header->subtype[3];
|
||||
format->u.encoded_video.encoding
|
||||
= (media_encoded_video_format::video_encoding)encoding;
|
||||
//int32 encoding = header->subtype[0] << 24 | header->subtype[1] << 16
|
||||
// | header->subtype[2] << 8 | header->subtype[3];
|
||||
// ToDo: that won't work any longer
|
||||
//format->u.encoded_video.encoding
|
||||
// = (media_encoded_video_format::video_encoding)encoding;
|
||||
format->u.encoded_video.frame_size
|
||||
= header->video.width * header->video.height;
|
||||
format->u.encoded_video.output.display.line_width = header->video.width;
|
||||
|
||||
@@ -20,6 +20,19 @@ AudioBufferSize(int32 channel_count, uint32 sample_format, float frame_rate, big
|
||||
return (sample_format & 0xf) * channel_count * (size_t)((frame_rate * buffer_duration) / 1000000.0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RawDecoder::GetCodecInfo(media_codec_info &info)
|
||||
{
|
||||
strcpy(info.short_name, "raw");
|
||||
|
||||
if (fInputFormat.IsAudio())
|
||||
strcpy(info.pretty_name, "Raw audio decoder");
|
||||
else
|
||||
strcpy(info.pretty_name, "Raw video decoder");
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
RawDecoder::Setup(media_format *ioEncodedFormat,
|
||||
const void *infoBuffer, int32 infoSize)
|
||||
@@ -471,11 +484,30 @@ RawDecoderPlugin::NewDecoder()
|
||||
}
|
||||
|
||||
status_t
|
||||
RawDecoderPlugin::RegisterPlugin()
|
||||
RawDecoderPlugin::RegisterDecoder()
|
||||
{
|
||||
PublishDecoder("audiocodec/raw", "raw", "RAW audio decoder");
|
||||
PublishDecoder("videocodec/raw", "raw", "RAW video decoder");
|
||||
return B_OK;
|
||||
BMediaFormats formats;
|
||||
media_format_description description;
|
||||
media_format format;
|
||||
|
||||
// audio decoder
|
||||
|
||||
description.family = B_MISC_FORMAT_FAMILY;
|
||||
description.u.beos.format = B_BEOS_FORMAT_RAW_AUDIO;
|
||||
format.type = B_MEDIA_ENCODED_AUDIO;
|
||||
format.u.encoded_audio = media_encoded_audio_format::wildcard;
|
||||
|
||||
status_t status = formats.MakeFormatFor(&description, 1, &format);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
// video decoder
|
||||
|
||||
description.u.beos.format = B_BEOS_FORMAT_RAW_VIDEO;
|
||||
format.type = B_MEDIA_ENCODED_VIDEO;
|
||||
format.u.encoded_video = media_encoded_video_format::wildcard;
|
||||
|
||||
return formats.MakeFormatFor(&description, 1, &format);
|
||||
}
|
||||
|
||||
MediaPlugin *instantiate_plugin()
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
class RawDecoder : public Decoder
|
||||
{
|
||||
public:
|
||||
void GetCodecInfo(media_codec_info &info);
|
||||
|
||||
status_t Setup(media_format *ioEncodedFormat,
|
||||
const void *infoBuffer, int32 infoSize);
|
||||
|
||||
@@ -43,5 +45,5 @@ class RawDecoderPlugin : public DecoderPlugin
|
||||
{
|
||||
public:
|
||||
Decoder * NewDecoder();
|
||||
status_t RegisterPlugin();
|
||||
status_t RegisterDecoder();
|
||||
};
|
||||
|
||||
@@ -42,6 +42,14 @@ speexDecoder::~speexDecoder()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
speexDecoder::GetCodecInfo(media_codec_info &info)
|
||||
{
|
||||
strcpy(info.short_name, "speex");
|
||||
strcpy(info.pretty_name, "speex decoder, based on libspeex");
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
speexDecoder::Setup(media_format *inputFormat,
|
||||
const void *infoBuffer, int32 infoSize)
|
||||
@@ -225,7 +233,7 @@ speexDecoder::Seek(uint32 seekTo,
|
||||
bigtime_t seekTime, bigtime_t *time)
|
||||
{
|
||||
TRACE("speexDecoder::Seek\n");
|
||||
int ignore = 0;
|
||||
// int ignore = 0;
|
||||
// speex_decoder_ctl(fDecoderState, SPEEX_RESET_STATE, &ignore);
|
||||
return B_OK;
|
||||
}
|
||||
@@ -309,10 +317,19 @@ speexDecoderPlugin::NewDecoder()
|
||||
|
||||
|
||||
status_t
|
||||
speexDecoderPlugin::RegisterPlugin()
|
||||
speexDecoderPlugin::RegisterDecoder()
|
||||
{
|
||||
PublishDecoder("audiocodec/speex", "speex", "speex decoder, based on libspeex");
|
||||
return B_OK;
|
||||
// ToDo: what about B_OGG_FORMAT_FAMILY?
|
||||
media_format_description description;
|
||||
description.family = B_MISC_FORMAT_FAMILY;
|
||||
description.u.misc.file_format = 'ogg ';
|
||||
description.u.misc.codec = 'spee';
|
||||
|
||||
media_format format;
|
||||
format.type = B_MEDIA_ENCODED_AUDIO;
|
||||
format.u.encoded_audio = media_encoded_audio_format::wildcard;
|
||||
|
||||
return BMediaFormats().MakeFormatFor(&description, 1, &format);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ class speexDecoder : public Decoder
|
||||
public:
|
||||
speexDecoder();
|
||||
~speexDecoder();
|
||||
|
||||
|
||||
void GetCodecInfo(media_codec_info &info);
|
||||
status_t Setup(media_format *inputFormat,
|
||||
const void *infoBuffer, int32 infoSize);
|
||||
|
||||
@@ -44,5 +45,5 @@ class speexDecoderPlugin : public DecoderPlugin
|
||||
{
|
||||
public:
|
||||
Decoder * NewDecoder();
|
||||
status_t RegisterPlugin();
|
||||
status_t RegisterDecoder();
|
||||
};
|
||||
|
||||
@@ -41,6 +41,14 @@ vorbisDecoder::~vorbisDecoder()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
vorbisDecoder::GetCodecInfo(media_codec_info &info)
|
||||
{
|
||||
strcpy(info.short_name, "vorbis");
|
||||
strcpy(info.pretty_name, "vorbis decoder, based on libvorbis");
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
vorbisDecoder::Setup(media_format *inputFormat,
|
||||
const void *infoBuffer, int32 infoSize)
|
||||
@@ -87,8 +95,9 @@ vorbisDecoder::Setup(media_format *inputFormat,
|
||||
|
||||
void vorbisDecoder::CopyInfoToEncodedFormat(media_format * format) {
|
||||
format->type = B_MEDIA_ENCODED_AUDIO;
|
||||
format->u.encoded_audio.encoding
|
||||
= (media_encoded_audio_format::audio_encoding)'vorb';
|
||||
// ToDo: this won't work any longer
|
||||
// format->u.encoded_audio.encoding
|
||||
// = (media_encoded_audio_format::audio_encoding)'vorb';
|
||||
if (fInfo.bitrate_nominal > 0) {
|
||||
format->u.encoded_audio.bit_rate = fInfo.bitrate_nominal;
|
||||
} else if (fInfo.bitrate_upper > 0) {
|
||||
@@ -224,10 +233,19 @@ vorbisDecoderPlugin::NewDecoder()
|
||||
|
||||
|
||||
status_t
|
||||
vorbisDecoderPlugin::RegisterPlugin()
|
||||
vorbisDecoderPlugin::RegisterDecoder()
|
||||
{
|
||||
PublishDecoder("audiocodec/vorbis", "vorbis", "vorbis decoder, based on libvorbis");
|
||||
return B_OK;
|
||||
media_format_description description;
|
||||
// ToDo: what about B_OGG_FORMAT_FAMILY?
|
||||
description.family = B_MISC_FORMAT_FAMILY;
|
||||
description.u.misc.file_format = 'ogg ';
|
||||
description.u.misc.codec = 'vorb';
|
||||
|
||||
media_format format;
|
||||
format.type = B_MEDIA_ENCODED_AUDIO;
|
||||
format.u.encoded_audio = media_encoded_audio_format::wildcard;
|
||||
|
||||
return BMediaFormats().MakeFormatFor(&description, 1, &format);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ public:
|
||||
vorbisDecoder();
|
||||
~vorbisDecoder();
|
||||
|
||||
void GetCodecInfo(media_codec_info &info);
|
||||
status_t Setup(media_format *inputFormat,
|
||||
const void *infoBuffer, int32 infoSize);
|
||||
|
||||
@@ -39,5 +40,5 @@ class vorbisDecoderPlugin : public DecoderPlugin
|
||||
{
|
||||
public:
|
||||
Decoder * NewDecoder();
|
||||
status_t RegisterPlugin();
|
||||
status_t RegisterDecoder();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user