let asf config data through to decoders

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30460 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
David McPaul
2009-04-27 14:04:47 +00:00
parent 02359fde69
commit a0be875ae3
+23 -10
View File
@@ -16,6 +16,8 @@
#include "avcodecplugin.h" #include "avcodecplugin.h"
#define DO_PROFILING 0
#undef TRACE #undef TRACE
//#define TRACE_AV_CODEC //#define TRACE_AV_CODEC
#ifdef TRACE_AV_CODEC #ifdef TRACE_AV_CODEC
@@ -35,6 +37,9 @@ struct wave_format_ex {
// extra_data[extra_size] // extra_data[extra_size]
} _PACKED; } _PACKED;
static bigtime_t diff1 = 0, diff2 = 0;
static long prof_cnt = 0;
// uncommenting will make Decode() set the current thread priority to time // uncommenting will make Decode() set the current thread priority to time
// sharing, so it won't totally freeze if you busy-loop in there (to help debug // sharing, so it won't totally freeze if you busy-loop in there (to help debug
// with CD Manager) // with CD Manager)
@@ -82,6 +87,14 @@ avCodec::~avCodec()
{ {
TRACE("[%c] avCodec::~avCodec()\n", isAudio?('a'):('v')); TRACE("[%c] avCodec::~avCodec()\n", isAudio?('a'):('v'));
#ifdef DO_PROFILING
if (prof_cnt > 0) {
printf("[%c] profile: d1 = %lld, d2 = %lld (%Ld)\n",
isAudio?('a'):('v'), diff1/prof_cnt, diff2/prof_cnt,
fFrame);
}
#endif
if(fCodecInitDone) if(fCodecInitDone)
avcodec_close(ffc); avcodec_close(ffc);
@@ -173,8 +186,7 @@ avCodec::Setup(media_format *ioEncodedFormat, const void *infoBuffer,
} }
TRACE("avCodec: found decoder %s\n",fCodec->name); TRACE("avCodec: found decoder %s\n",fCodec->name);
if (gCodecTable[i].family == B_WAV_FORMAT_FAMILY) { if (gCodecTable[i].family == B_WAV_FORMAT_FAMILY && infoSize == sizeof(wave_format_ex)) {
TRACE("Additional MetaData required for WAV format. Should contain %ld has %ld\n",sizeof(wave_format_ex),infoSize);
const wave_format_ex *wfmt_data const wave_format_ex *wfmt_data
= (const wave_format_ex *)infoBuffer; = (const wave_format_ex *)infoBuffer;
size_t wfmt_size = infoSize; size_t wfmt_size = infoSize;
@@ -187,6 +199,7 @@ avCodec::Setup(media_format *ioEncodedFormat, const void *infoBuffer,
} }
} }
} else { } else {
fBlockAlign = ioEncodedFormat->u.encoded_audio.output.buffer_size;
TRACE("avCodec: extra data size %ld\n",infoSize); TRACE("avCodec: extra data size %ld\n",infoSize);
fExtraDataSize = infoSize; fExtraDataSize = infoSize;
if (fExtraDataSize) { if (fExtraDataSize) {
@@ -403,20 +416,20 @@ status_t
avCodec::Decode(void *out_buffer, int64 *out_frameCount, avCodec::Decode(void *out_buffer, int64 *out_frameCount,
media_header *mh, media_decode_info *info) media_header *mh, media_decode_info *info)
{ {
const void *data;
if (!fCodecInitDone) if (!fCodecInitDone)
return B_BAD_VALUE; return B_BAD_VALUE;
#ifdef DO_PROFILING #ifdef DO_PROFILING
bigtime_t prof_t1, prof_t2, prof_t3; bigtime_t prof_t1, prof_t2, prof_t3;
static bigtime_t diff1 = 0, diff2 = 0;
static long prof_cnt = 0;
#endif #endif
#ifdef UNREAL #ifdef UNREAL
set_thread_priority(find_thread(NULL), B_NORMAL_PRIORITY); set_thread_priority(find_thread(NULL), B_NORMAL_PRIORITY);
#endif #endif
// TRACE("[%c] avCodec::Decode()\n", isAudio?('a'):('v')); // TRACE("[%c] avCodec::Decode() for time %Ld\n", isAudio?('a'):('v'), fStartTime);
mh->start_time = fStartTime; mh->start_time = fStartTime;
@@ -490,11 +503,12 @@ avCodec::Decode(void *out_buffer, int64 *out_frameCount,
} }
fFrame += *out_frameCount; fFrame += *out_frameCount;
// TRACE("Played %Ld frames at time %Ld\n",*out_frameCount, mh->start_time);
} else { // Video } else { // Video
media_header chunk_mh; media_header chunk_mh;
status_t err; status_t err;
const void *data;
size_t size; size_t size;
err = GetNextChunk(&data, &size, &chunk_mh); err = GetNextChunk(&data, &size, &chunk_mh);
@@ -548,8 +562,8 @@ avCodec::Decode(void *out_buffer, int64 *out_frameCount,
#ifdef DO_PROFILING #ifdef DO_PROFILING
prof_t2 = system_time(); prof_t2 = system_time();
#endif #endif
TRACE("ONE FRAME OUT !! len=%d size=%ld (%s)\n", len, size, // TRACE("ONE FRAME OUT !! len=%d size=%ld (%s)\n", len, size,
pixfmt_to_string(ffc->pix_fmt)); // pixfmt_to_string(ffc->pix_fmt));
// Some decoders do not set pix_fmt until they have decoded 1 frame // Some decoders do not set pix_fmt until they have decoded 1 frame
if (conv_func == 0) { if (conv_func == 0) {
@@ -576,7 +590,7 @@ avCodec::Decode(void *out_buffer, int64 *out_frameCount,
diff2 += prof_t3 - prof_t2; diff2 += prof_t3 - prof_t2;
prof_cnt++; prof_cnt++;
if (!(fFrame % 10)) { if (!(fFrame % 10)) {
TRACE("[%c] profile: d1 = %lld, d2 = %lld (%ld)\n", TRACE("[%c] profile: d1 = %lld, d2 = %lld (%Ld)\n",
isAudio?('a'):('v'), diff1/prof_cnt, diff2/prof_cnt, isAudio?('a'):('v'), diff1/prof_cnt, diff2/prof_cnt,
fFrame); fFrame);
} }
@@ -586,7 +600,6 @@ avCodec::Decode(void *out_buffer, int64 *out_frameCount,
fStartTime = (bigtime_t) (1000000LL * fFrame / fOutputFrameRate); fStartTime = (bigtime_t) (1000000LL * fFrame / fOutputFrameRate);
// TRACE("END of avCodec::Decode()\n");
return B_OK; return B_OK;
} }