Permalink
Browse files

Updated mythmusic to work following FFmpeg resync

Decoded audio is now planar so we can't just copy the decoded data. Simplify the code to use one of the audio utility routine.
  • Loading branch information...
jyavenard committed Dec 13, 2012
1 parent 61167e5 commit c4c473f5bf847af87bccb7733d24ca7571c8ad7a
@@ -27,6 +27,7 @@
#include <mythconfig.h>
#include <mythcontext.h>
#include <audiooutput.h>
#include <audiooutpututil.h>
#include <mythlogging.h>
using namespace std;
@@ -307,8 +308,8 @@ bool avfDecoder::initialize()
// decode 8 bks worth of samples each time we need more
decodeBytes = bks << 3;
output_buf = (char *)av_malloc(decodeBytes +
AVCODEC_MAX_AUDIO_FRAME_SIZE * 2);
output_buf = (uint8_t *)av_malloc(decodeBytes +
AVCODEC_MAX_AUDIO_FRAME_SIZE * 2);
output_at = 0;
inited = true;
@@ -368,7 +369,6 @@ void avfDecoder::run()
}
AVPacket pkt, tmp_pkt;
AVFrame *frame = avcodec_alloc_frame();
int data_size, dec_len;
uint fill, total;
// account for possible frame expansion in aobase (upmix, float conv)
@@ -419,29 +419,18 @@ void avfDecoder::run()
while (tmp_pkt.size > 0 && !finish &&
!user_stop && seekTime <= 0.0)
{
// Decode the stream to the output codec
int got_frame = 0;
data_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
dec_len = avcodec_decode_audio4(m_audioDec, frame,
&got_frame, &tmp_pkt);
if (dec_len < 0 || !got_frame)
int ret;
ret = AudioOutputUtil::DecodeAudio(m_audioDec,
output_buf + output_at,
data_size,
&tmp_pkt);
if (ret < 0)
break;
data_size =
av_samples_get_buffer_size(NULL,
m_audioDec->channels,
frame->nb_samples,
m_audioDec->sample_fmt,
1);
// Copy the data to the output buffer
memcpy((char *)(output_buf + output_at),
frame->extended_data[0], data_size);
// Increment the output pointer and count
output_at += data_size;
tmp_pkt.size -= dec_len;
tmp_pkt.data += dec_len;
tmp_pkt.size -= ret;
tmp_pkt.data += ret;
}
av_free_packet(&pkt);
@@ -492,8 +481,6 @@ void avfDecoder::run()
dispatch(e);
}
av_free(frame);
deinit();
RunEpilog();
}
@@ -33,7 +33,7 @@ class avfDecoder : public Decoder
bool inited, user_stop;
int stat;
char *output_buf;
uint8_t *output_buf;
ulong output_at;
unsigned int bks, bksFrames, decodeBytes;
@@ -257,7 +257,7 @@ bool CdDecoder::initialize()
if (output())
{
const AudioSettings settings(FORMAT_S16, m_chan,
CODEC_ID_PCM_S16LE, m_freq, false /* AC3/DTS passthru */);
AV_CODEC_ID_PCM_S16LE, m_freq, false /* AC3/DTS passthru */);
output()->Reconfigure(settings);
output()->SetSourceBitrate(m_freq * m_chan * 16);
}
@@ -10,6 +10,7 @@ LIBS += -lmythservicecontracts-$$LIBVERSION
LIBS += -lmythavcodec
LIBS += -lmythavutil
LIBS += -lmythavformat
LIBS += -lmythswresample
# On Windows, libs are stored with the binaries:
mingw:LIBS += -L$${SYSROOT}$${PREFIX}/bin
@@ -13,6 +13,7 @@ LIBS += -L../../external/FFmpeg/libavutil
LIBS += -L../../external/FFmpeg/libavcodec
LIBS += -L../../external/FFmpeg/libavformat
LIBS += -L../../external/FFmpeg/libswscale
LIBS += -L../../external/FFmpeg/libswresample
LIBS += -L../../libs/libmythbase
LIBS += -L../../libs/libmythui
LIBS += -L../../libs/libmythupnp
@@ -24,6 +25,7 @@ LIBS += -lmythswscale
LIBS += -lmythavformat
LIBS += -lmythavcodec
LIBS += -lmythavutil
LIBS += -lmythswresample
LIBS += -lmythtv-$$LIBVERSION
LIBS += -lmythupnp-$$LIBVERSION
LIBS += -lmythbase-$$LIBVERSION
@@ -48,6 +50,7 @@ POST_TARGETDEPS += ../../external/FFmpeg/libavutil/$$avLibName(avutil)
POST_TARGETDEPS += ../../external/FFmpeg/libavcodec/$$avLibName(avcodec)
POST_TARGETDEPS += ../../external/FFmpeg/libavformat/$$avLibName(avformat)
POST_TARGETDEPS += ../../external/FFmpeg/libswscale/$$avLibName(swscale)
POST_TARGETDEPS += ../../external/FFmpeg/libswresample/$$avLibName(swresample)
POST_TARGETDEPS += ../../libs/libmythupnp/libmythupnp-$${MYTH_SHLIB_EXT}
POST_TARGETDEPS += ../../libs/libmythbase/libmythbase-$${MYTH_SHLIB_EXT}
POST_TARGETDEPS += ../../libs/libmythservicecontracts/libmythservicecontracts-$${MYTH_SHLIB_EXT}

0 comments on commit c4c473f

Please sign in to comment.