use user_data for ogg_packet and pass raw data pointer through chunkBuffer
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9495 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
#ifndef _OGG_FORMATS_H
|
||||||
|
#define _OGG_FORMATS_H
|
||||||
|
|
||||||
|
//! for use in media_misc_description.file_format
|
||||||
|
const uint32 OGG_FILE_FORMAT = 'OggS';
|
||||||
|
|
||||||
|
//! for use in media_header.user_data_type
|
||||||
|
const uint32 OGG_PACKET_DATA_TYPE = 'OggP';
|
||||||
|
|
||||||
|
#endif _OGG_FORMATS_H
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "OggSpeexSeekable.h"
|
#include "OggSpeexSeekable.h"
|
||||||
#include "OggTobiasSeekable.h"
|
#include "OggTobiasSeekable.h"
|
||||||
#include "OggVorbisSeekable.h"
|
#include "OggVorbisSeekable.h"
|
||||||
|
#include "OggFormats.h"
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -247,7 +248,7 @@ OggSeekable::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
// get the format for the description
|
// get the format for the description
|
||||||
media_format_description description;
|
media_format_description description;
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
description.family = B_MISC_FORMAT_FAMILY;
|
||||||
description.u.misc.file_format = 'OggS';
|
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||||
description.u.misc.codec = four_bytes;
|
description.u.misc.codec = four_bytes;
|
||||||
BMediaFormats formats;
|
BMediaFormats formats;
|
||||||
result = formats.InitCheck();
|
result = formats.InitCheck();
|
||||||
@@ -448,21 +449,25 @@ OggSeekable::Seek(uint32 seekTo, int64 *frame, bigtime_t *time)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
OggSeekable::GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
OggSeekable::GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
||||||
media_header *mediaHeader)
|
media_header *mediaHeader)
|
||||||
{
|
{
|
||||||
|
ogg_packet packet;
|
||||||
BAutolock autolock(fPositionLock);
|
BAutolock autolock(fPositionLock);
|
||||||
status_t result = GetPacket(&fChunkPacket);
|
status_t result = GetPacket(&packet);
|
||||||
|
*chunkBuffer = packet.packet;
|
||||||
|
*chunkSize = packet.bytes;
|
||||||
|
packet.packet = NULL;
|
||||||
|
assert(sizeof(ogg_packet) <= sizeof(mediaHeader->user_data));
|
||||||
|
mediaHeader->user_data_type = OGG_PACKET_DATA_TYPE;
|
||||||
|
memcpy(mediaHeader->user_data, &packet, sizeof(ogg_packet));
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
TRACE("OggSeekable::GetNextChunk failed: GetPacket = %s\n", strerror(result));
|
TRACE("OggSeekable::GetNextChunk failed: GetPacket = %s\n", strerror(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
*chunkBuffer = &fChunkPacket;
|
if (packet.granulepos > 0) {
|
||||||
*chunkSize = sizeof(fChunkPacket);
|
fCurrentFrame = packet.granulepos - fFirstGranulepos;
|
||||||
if (fChunkPacket.granulepos > 0) {
|
|
||||||
fCurrentFrame = fChunkPacket.granulepos - fFirstGranulepos;
|
|
||||||
fCurrentTime = (bigtime_t)((fCurrentFrame * 1000000LL) / fFrameRate);
|
fCurrentTime = (bigtime_t)((fCurrentFrame * 1000000LL) / fFrameRate);
|
||||||
mediaHeader->start_time = fCurrentTime;
|
mediaHeader->start_time = fCurrentTime;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ protected:
|
|||||||
|
|
||||||
// subclass pull input function
|
// subclass pull input function
|
||||||
status_t GetPacket(ogg_packet * packet);
|
status_t GetPacket(ogg_packet * packet);
|
||||||
ogg_packet fChunkPacket;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int64 fCurrentFrame;
|
int64 fCurrentFrame;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <MediaFormats.h>
|
#include <MediaFormats.h>
|
||||||
#include <ogg/ogg.h>
|
#include <ogg/ogg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <OggFormats.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* speex descriptions/formats
|
* speex descriptions/formats
|
||||||
@@ -15,7 +16,7 @@ speex_description()
|
|||||||
{
|
{
|
||||||
media_format_description description;
|
media_format_description description;
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
description.family = B_MISC_FORMAT_FAMILY;
|
||||||
description.u.misc.file_format = 'OggS';
|
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||||
description.u.misc.codec = 'Spee';
|
description.u.misc.codec = 'Spee';
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,18 +179,3 @@ OggSpeexSeekable::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
|
||||||
OggSpeexSeekable::GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
|
||||||
media_header *mediaHeader)
|
|
||||||
{
|
|
||||||
status_t result = inherited::GetNextChunk(chunkBuffer, chunkSize, mediaHeader);
|
|
||||||
if (result != B_OK) {
|
|
||||||
TRACE("OggSpeexSeekable::GetNextChunk failed: GetNextChunk = %s\n", strerror(result));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
*chunkSize = ((ogg_packet*)*chunkBuffer)->bytes;
|
|
||||||
*chunkBuffer = ((ogg_packet*)*chunkBuffer)->packet;
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -16,8 +16,6 @@ public:
|
|||||||
|
|
||||||
virtual status_t GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
virtual status_t GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
||||||
media_format *format);
|
media_format *format);
|
||||||
virtual status_t GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
|
||||||
media_header *mediaHeader);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include "OggTheoraStream.h"
|
#include "OggTheoraStream.h"
|
||||||
#include "OggTobiasStream.h"
|
#include "OggTobiasStream.h"
|
||||||
#include "OggVorbisStream.h"
|
#include "OggVorbisStream.h"
|
||||||
|
#include "OggFormats.h"
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -107,7 +108,7 @@ OggStream::GetStreamInfo(int64 *frameCount, bigtime_t *duration,
|
|||||||
// get the format for the description
|
// get the format for the description
|
||||||
media_format_description description;
|
media_format_description description;
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
description.family = B_MISC_FORMAT_FAMILY;
|
||||||
description.u.misc.file_format = 'OggS';
|
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||||
description.u.misc.codec = four_bytes;
|
description.u.misc.codec = four_bytes;
|
||||||
BMediaFormats formats;
|
BMediaFormats formats;
|
||||||
result = formats.InitCheck();
|
result = formats.InitCheck();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <MediaFormats.h>
|
#include <MediaFormats.h>
|
||||||
#include <ogg/ogg.h>
|
#include <ogg/ogg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <OggFormats.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* theora descriptions/formats
|
* theora descriptions/formats
|
||||||
@@ -15,7 +16,7 @@ theora_description()
|
|||||||
{
|
{
|
||||||
media_format_description description;
|
media_format_description description;
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
description.family = B_MISC_FORMAT_FAMILY;
|
||||||
description.u.misc.file_format = 'OggS';
|
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||||
description.u.misc.codec = 'theo';
|
description.u.misc.codec = 'theo';
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <MediaFormats.h>
|
#include <MediaFormats.h>
|
||||||
#include <ogg/ogg.h>
|
#include <ogg/ogg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "OggFormats.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tobias descriptions/formats
|
* tobias descriptions/formats
|
||||||
@@ -47,7 +48,7 @@ tobias_text_description()
|
|||||||
{
|
{
|
||||||
media_format_description description;
|
media_format_description description;
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
description.family = B_MISC_FORMAT_FAMILY;
|
||||||
description.u.misc.file_format = 'OggS';
|
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||||
description.u.misc.codec = 'text';
|
description.u.misc.codec = 'text';
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,8 +266,6 @@ OggTobiasSeekable::GetNextChunk(void **chunkBuffer, int32 *chunkSize,
|
|||||||
TRACE("OggTobiasSeekable::GetNextChunk failed: GetNextChunk = %s\n", strerror(result));
|
TRACE("OggTobiasSeekable::GetNextChunk failed: GetNextChunk = %s\n", strerror(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
*chunkSize = ((ogg_packet*)*chunkBuffer)->bytes;
|
|
||||||
*chunkBuffer = ((ogg_packet*)*chunkBuffer)->packet;
|
|
||||||
bool keyframe = ((uint*)chunkBuffer)[0] & (1 << 3); // ??
|
bool keyframe = ((uint*)chunkBuffer)[0] & (1 << 3); // ??
|
||||||
if (fMediaFormat.type == B_MEDIA_ENCODED_VIDEO) {
|
if (fMediaFormat.type == B_MEDIA_ENCODED_VIDEO) {
|
||||||
mediaHeader->type = fMediaFormat.type;
|
mediaHeader->type = fMediaFormat.type;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <MediaFormats.h>
|
#include <MediaFormats.h>
|
||||||
#include <ogg/ogg.h>
|
#include <ogg/ogg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "OggFormats.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* vorbis descriptions/formats
|
* vorbis descriptions/formats
|
||||||
@@ -15,7 +16,7 @@ vorbis_description()
|
|||||||
{
|
{
|
||||||
media_format_description description;
|
media_format_description description;
|
||||||
description.family = B_MISC_FORMAT_FAMILY;
|
description.family = B_MISC_FORMAT_FAMILY;
|
||||||
description.u.misc.file_format = 'OggS';
|
description.u.misc.file_format = OGG_FILE_FORMAT;
|
||||||
description.u.misc.codec = 'vorb';
|
description.u.misc.codec = 'vorb';
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,13 +184,13 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
|||||||
status_t status = GetNextChunk(&chunkBuffer, &chunkSize, &mh);
|
status_t status = GetNextChunk(&chunkBuffer, &chunkSize, &mh);
|
||||||
if (status == B_LAST_BUFFER_ERROR) {
|
if (status == B_LAST_BUFFER_ERROR) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
TRACE("VorbisDecoder::Decode: GetNextChunk failed\n");
|
TRACE("VorbisDecoder::Decode: GetNextChunk failed\n");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
if (chunkSize != sizeof(ogg_packet)) {
|
if (mh.user_data_type != OGG_PACKET_DATA_TYPE) {
|
||||||
TRACE("VorbisDecoder::Decode: chunk not ogg_packet-sized\n");
|
TRACE("VorbisDecoder::Decode: chunk missing ogg_packet data");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
if (!synced) {
|
if (!synced) {
|
||||||
@@ -199,8 +199,9 @@ VorbisDecoder::Decode(void *buffer, int64 *frameCount,
|
|||||||
synced = true;
|
synced = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ogg_packet * packet = static_cast<ogg_packet*>(chunkBuffer);
|
ogg_packet * packet = reinterpret_cast<ogg_packet*>(mh.user_data);
|
||||||
if (vorbis_synthesis(&fBlock,packet)==0) {
|
packet->packet = static_cast<unsigned char *>(chunkBuffer);
|
||||||
|
if (vorbis_synthesis(&fBlock, packet)==0) {
|
||||||
vorbis_synthesis_blockin(&fDspState,&fBlock);
|
vorbis_synthesis_blockin(&fDspState,&fBlock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user