mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Only a single frame is supported.
This commit is contained in:
parent
07b426f2b5
commit
762959fbb4
41
codec.c
41
codec.c
@ -667,6 +667,7 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, const char *name,
|
|||||||
int codec_id)
|
int codec_id)
|
||||||
{
|
{
|
||||||
AVCodec *audio_codec;
|
AVCodec *audio_codec;
|
||||||
|
AVDictionary *av_dict;
|
||||||
|
|
||||||
if (name && (audio_codec = avcodec_find_decoder_by_name(name))) {
|
if (name && (audio_codec = avcodec_find_decoder_by_name(name))) {
|
||||||
Debug(3, "codec: audio decoder '%s' found\n", name);
|
Debug(3, "codec: audio decoder '%s' found\n", name);
|
||||||
@ -693,10 +694,15 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, const char *name,
|
|||||||
Fatal(_("codec: can't open audio codec\n"));
|
Fatal(_("codec: can't open audio codec\n"));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (avcodec_open2(audio_decoder->AudioCtx, audio_codec, NULL) < 0) {
|
av_dict = NULL;
|
||||||
|
//av_dict_set(&av_dict, "dmix_mode", "0", 0);
|
||||||
|
//av_dict_set(&av_dict, "ltrt_cmixlev", "1.414", 0);
|
||||||
|
//av_dict_set(&av_dict, "loro_cmixlev", "1.414", 0);
|
||||||
|
if (avcodec_open2(audio_decoder->AudioCtx, audio_codec, &av_dict) < 0) {
|
||||||
pthread_mutex_unlock(&CodecLockMutex);
|
pthread_mutex_unlock(&CodecLockMutex);
|
||||||
Fatal(_("codec: can't open audio codec\n"));
|
Fatal(_("codec: can't open audio codec\n"));
|
||||||
}
|
}
|
||||||
|
av_dict_free(&av_dict);
|
||||||
#endif
|
#endif
|
||||||
pthread_mutex_unlock(&CodecLockMutex);
|
pthread_mutex_unlock(&CodecLockMutex);
|
||||||
Debug(3, "codec: audio '%s'\n", audio_decoder->AudioCtx->codec_name);
|
Debug(3, "codec: audio '%s'\n", audio_decoder->AudioCtx->codec_name);
|
||||||
@ -1095,24 +1101,24 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
|
|||||||
{
|
{
|
||||||
int16_t buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 4 +
|
int16_t buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 4 +
|
||||||
FF_INPUT_BUFFER_PADDING_SIZE] __attribute__ ((aligned(16)));
|
FF_INPUT_BUFFER_PADDING_SIZE] __attribute__ ((aligned(16)));
|
||||||
|
int buf_sz;
|
||||||
|
int l;
|
||||||
AVCodecContext *audio_ctx;
|
AVCodecContext *audio_ctx;
|
||||||
int index;
|
|
||||||
|
|
||||||
audio_ctx = audio_decoder->AudioCtx;
|
audio_ctx = audio_decoder->AudioCtx;
|
||||||
index = 0;
|
|
||||||
while (avpkt->size > index) {
|
|
||||||
int l;
|
|
||||||
int buf_sz;
|
|
||||||
|
|
||||||
buf_sz = sizeof(buf);
|
buf_sz = sizeof(buf);
|
||||||
l = avcodec_decode_audio3(audio_ctx, buf, &buf_sz, (AVPacket *) avpkt);
|
l = avcodec_decode_audio3(audio_ctx, buf, &buf_sz, (AVPacket *) avpkt);
|
||||||
|
if (avpkt->size != l) {
|
||||||
if (l == AVERROR(EAGAIN)) {
|
if (l == AVERROR(EAGAIN)) {
|
||||||
Error(_("codec: latm\n"));
|
Error(_("codec: latm\n"));
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
if (l < 0) { // no audio frame could be decompressed
|
if (l < 0) { // no audio frame could be decompressed
|
||||||
Error(_("codec: error audio data at %d\n"), index);
|
Error(_("codec: error audio data\n"));
|
||||||
break;
|
return;
|
||||||
|
}
|
||||||
|
Error(_("codec: error more than one frame data\n"));
|
||||||
}
|
}
|
||||||
#ifdef notyetFF_API_OLD_DECODE_AUDIO
|
#ifdef notyetFF_API_OLD_DECODE_AUDIO
|
||||||
// FIXME: ffmpeg git comeing
|
// FIXME: ffmpeg git comeing
|
||||||
@ -1176,7 +1182,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
|
|||||||
// FIXME: handle errors
|
// FIXME: handle errors
|
||||||
audio_decoder->HwChannels = 0;
|
audio_decoder->HwChannels = 0;
|
||||||
audio_decoder->HwSampleRate = 0;
|
audio_decoder->HwSampleRate = 0;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1191,8 +1197,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
|
|||||||
|
|
||||||
// FIXME: libav-0.7.2 crash here
|
// FIXME: libav-0.7.2 crash here
|
||||||
outlen =
|
outlen =
|
||||||
audio_resample(audio_decoder->ReSample, outbuf, buf,
|
audio_resample(audio_decoder->ReSample, outbuf, buf, buf_sz);
|
||||||
buf_sz);
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (outlen != buf_sz) {
|
if (outlen != buf_sz) {
|
||||||
Debug(3, "codec/audio: possible fixed ffmpeg\n");
|
Debug(3, "codec/audio: possible fixed ffmpeg\n");
|
||||||
@ -1220,7 +1225,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
|
|||||||
if (buf_sz < avpkt->size + 8) {
|
if (buf_sz < avpkt->size + 8) {
|
||||||
Error(_
|
Error(_
|
||||||
("codec/audio: decoded data smaller than encoded\n"));
|
("codec/audio: decoded data smaller than encoded\n"));
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
// copy original data for output
|
// copy original data for output
|
||||||
// FIXME: not 100% sure, if endian is correct
|
// FIXME: not 100% sure, if endian is correct
|
||||||
@ -1229,8 +1234,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
|
|||||||
buf[2] = htole16(0x01 | (avpkt->data[5] & 0x07) << 8);
|
buf[2] = htole16(0x01 | (avpkt->data[5] & 0x07) << 8);
|
||||||
buf[3] = htole16(avpkt->size * 8);
|
buf[3] = htole16(avpkt->size * 8);
|
||||||
swab(avpkt->data, buf + 4, avpkt->size);
|
swab(avpkt->data, buf + 4, avpkt->size);
|
||||||
memset(buf + 4 + avpkt->size / 2, 0,
|
memset(buf + 4 + avpkt->size / 2, 0, buf_sz - 8 - avpkt->size);
|
||||||
buf_sz - 8 - avpkt->size);
|
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
//
|
//
|
||||||
@ -1288,13 +1292,6 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
|
|||||||
AudioEnqueue(buf, buf_sz);
|
AudioEnqueue(buf, buf_sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avpkt->size > l) {
|
|
||||||
Error(_("codec: error more than one frame data\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
index += l;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user