Permalink
Browse files

Fix planar audio for nuv container.

Additionally, properly handle errors and potential issues should an AVPacket contains more than one audio frame

Fixes #11194
  • Loading branch information...
jyavenard committed Apr 28, 2013
1 parent 56bd4a2 commit 709a6f64b86128473c07d939bd29c44bf37b7625
Showing with 16 additions and 16 deletions.
  1. +15 −15 mythtv/libs/libmythtv/nuppeldecoder.cpp
  2. +1 −1 mythtv/libs/libmythtv/nuppeldecoder.h
@@ -22,6 +22,7 @@ using namespace std;
#include "mythlogging.h"
#include "myth_imgconvert.h"
#include "programinfo.h"
#include "audiooutpututil.h"
#include "minilzo.h"
@@ -56,7 +57,8 @@ NuppelDecoder::NuppelDecoder(MythPlayer *parent,
memset(&extradata, 0, sizeof(extendeddata));
memset(&tmppicture, 0, sizeof(AVPicture));
planes[0] = planes[1] = planes[2] = 0;
m_audioFrame = avcodec_alloc_frame();
m_audioSamples = (uint8_t *)av_mallocz(AVCODEC_MAX_AUDIO_FRAME_SIZE *
sizeof(int32_t));
// set parent class variables
positionMapType = MARK_KEYFRAME;
@@ -95,7 +97,7 @@ NuppelDecoder::~NuppelDecoder()
if (strm_buf)
delete [] strm_buf;
av_free(m_audioFrame);
av_free(m_audioSamples);
while (!StoredData.empty())
{
@@ -1273,25 +1275,23 @@ bool NuppelDecoder::GetFrame(DecodeType decodetype)
while (pkt.size > 0)
{
int got_frame = 0;
ret = avcodec_decode_audio4(mpa_audctx, m_audioFrame,
&got_frame, &pkt);
int data_size = 0;
if (got_frame && ret > 0)
ret = AudioOutputUtil::DecodeAudio(mpa_audctx, m_audioSamples,
data_size, &pkt);
if (ret < 0)
{
int data_size =
av_samples_get_buffer_size(NULL,
mpa_audctx->channels,
m_audioFrame->nb_samples,
mpa_audctx->sample_fmt,
1);
m_audio->AddAudioData(
(char *)m_audioFrame->extended_data[0],
data_size, frameheader.timecode, 0);
LOG(VB_GENERAL, LOG_ERR, LOC + "Unknown audio decoding error");
return false;
}
pkt.size -= ret;
pkt.data += ret;
if (data_size <= 0)
continue;
m_audio->AddAudioData((char *)m_audioSamples, data_size,
frameheader.timecode, 0);
}
}
else
@@ -110,7 +110,7 @@ class NuppelDecoder : public DecoderBase
AVCodec *mpa_audcodec;
AVCodecContext *mpa_audctx;
AVPicture tmppicture;
AVFrame *m_audioFrame;
uint8_t *m_audioSamples;
bool directrendering;

0 comments on commit 709a6f6

Please sign in to comment.