summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dxr3audiodecoder.c34
-rw-r--r--dxr3audiodecoder.h3
-rw-r--r--dxr3output-audio.c6
-rw-r--r--dxr3pesframe.h23
4 files changed, 44 insertions, 22 deletions
diff --git a/dxr3audiodecoder.c b/dxr3audiodecoder.c
index 11bd066..7892777 100644
--- a/dxr3audiodecoder.c
+++ b/dxr3audiodecoder.c
@@ -246,6 +246,40 @@ void cDxr3AudioDecoder::DecodeAc3Dts(const uint8_t* pPes, const uint8_t* buf,
}
}
+/**
+ * \brief decoded payload of frame
+ */
+void cDxr3AudioDecoder::decode(cDxr3PesFrame *frame)
+{
+ int len;
+ int out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+
+ const uint8_t *buf = frame->GetPayload();
+ int length = frame->GetPayloadLength();
+
+#if LIBAVCODEC_VERSION_INT < ((51<<16)+(29<<8)+0)
+ len = avcodec_decode_audio(
+#else
+ len = avcodec_decode_audio2(
+#endif
+ contextAudio, frame->decoded, &out_size, const_cast<uint8_t *>(buf), length);
+
+ if (len < 0) {
+ esyslog("[dxr3-decoder] failed to decode audio");
+ frame->decodedSize = 0;
+ return;
+ }
+
+ // can this happen?
+ if ((length - len) > 0) {
+ esyslog("[dxr3-decoder] TODO: more to decode");
+ }
+
+ frame->decodedSize = len;
+ frame->ctx.channels = contextAudio->channels;
+ frame->ctx.samplerate = contextAudio->sample_rate;
+}
+
// ==================================
//! checking routine
bool cDxr3AudioDecoder::HeadCheck(unsigned long head)
diff --git a/dxr3audiodecoder.h b/dxr3audiodecoder.h
index 4ef0706..d8c7c59 100644
--- a/dxr3audiodecoder.h
+++ b/dxr3audiodecoder.h
@@ -47,6 +47,9 @@ public:
void DecodeAc3Dts(const uint8_t* pPes, const uint8_t* buf, int length,
uint32_t pts, cDxr3SyncBuffer &aBuf);
+
+ void decode(cDxr3PesFrame *frame);
+
void Reset()
{
ac3dtsDecoder.Clear();
diff --git a/dxr3output-audio.c b/dxr3output-audio.c
index dd1e4ba..a7d6b10 100644
--- a/dxr3output-audio.c
+++ b/dxr3output-audio.c
@@ -128,14 +128,14 @@ void cDxr3AudioOutThread::PlayFrame(cFixedLengthFrame *frame)
void cDxr3AudioOutThread::PlayFrame(cDxr3PesFrame *frame)
{
// update audio context
- audioOutput->setup(frame->GetSampleContext());
+ audioOutput->setup(frame->ctx);
// volume changes
if (!cDxr3Interface::instance()->IsAudioModeAC3()) {
- audioOutput->changeVolume((short *)frame->GetDecoded(), (size_t)frame->GetDecodedSize());
+ audioOutput->changeVolume((short *)frame->decoded, (size_t)frame->decodedSize);
}
- audioOutput->write((uchar *)frame->GetDecoded(), frame->GetDecodedSize());
+ audioOutput->write((uchar *)frame->decoded, frame->decodedSize);
}
#undef SCR
diff --git a/dxr3pesframe.h b/dxr3pesframe.h
index b9aa664..bead78b 100644
--- a/dxr3pesframe.h
+++ b/dxr3pesframe.h
@@ -114,20 +114,10 @@ public:
return m_verticalSize;
}
- SampleContext GetSampleContext() const
- {
- return ctx;
- }
-
- uint32_t GetDecodedSize() const
- {
- return decodedSize;
- }
-
- const int16_t *GetDecoded()
- {
- return decoded;
- }
+ // needed for audio
+ uint32_t decodedSize;
+ int16_t *decoded;
+ SampleContext ctx;
private:
ePesDataType m_pesDataType;
@@ -143,11 +133,6 @@ private:
static uint32_t m_staticAspectRatio;
- // needed for audio
- uint32_t decodedSize;
- const int16_t *decoded;
- SampleContext ctx;
-
static const uint32_t MAX_PES_HEADER_SIZE;
};