Skip to content

Commit

Permalink
fix AC3 stream detection for libavcodec V58
Browse files Browse the repository at this point in the history
  • Loading branch information
kfb77 committed Apr 5, 2020
1 parent 735459b commit fdfe80d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions command/decoder_new.cpp
Expand Up @@ -373,16 +373,18 @@ bool cDecoder::GetFrameInfo(MarkAdContext *maContext) {
}

if (isAudioStream()) {
if (isAudioAC3Frame()) {
if (isAudioAC3Stream()) {
#if LIBAVCODEC_VERSION_INT >= ((57<<16)+(107<<8)+100)
if (maContext->Audio.Info.Channels != avctx->streams[avpkt.stream_index]->codecpar->channels) {
dsyslog("cDecoder::GetFrameInfo(): audio channels changed from %i to %i at frame (%li)", maContext->Audio.Info.Channels,
dsyslog("cDecoder::GetFrameInfo(): audio channels of stream %i changed from %i to %i at frame (%li)", avpkt.stream_index,
maContext->Audio.Info.Channels,
avctx->streams[avpkt.stream_index]->codecpar->channels,
framenumber);
maContext->Audio.Info.Channels = avctx->streams[avpkt.stream_index]->codecpar->channels;
#else
if (maContext->Audio.Info.Channels != avctx->streams[avpkt.stream_index]->codec->channels) {
dsyslog("cDecoder::GetFrameInfo(): audio channels changed from %i to %i at frame (%li)", maContext->Audio.Info.Channels,
dsyslog("cDecoder::GetFrameInfo(): audio channels of stream %i changed from %i to %i at frame (%li)", avpkt.stream_index,
maContext->Audio.Info.Channels,
avctx->streams[avpkt.stream_index]->codec->channels,
framenumber);
maContext->Audio.Info.Channels = avctx->streams[avpkt.stream_index]->codec->channels;
Expand Down Expand Up @@ -414,10 +416,12 @@ bool cDecoder::isAudioStream() {
return false;
}

bool cDecoder::isAudioAC3Frame() {
bool cDecoder::isAudioAC3Stream() {
if (!avctx) return false;
#define AUDIOFORMATAC3 8
#if LIBAVCODEC_VERSION_INT >= ((57<<16)+(107<<8)+100)
#if LIBAVCODEC_VERSION_INT >= ((58<<16)+(35<<8)+100)
if (avctx->streams[avpkt.stream_index]->codecpar->codec_id == AV_CODEC_ID_AC3 ) return true;
#elif LIBAVCODEC_VERSION_INT >= ((57<<16)+(107<<8)+100)
if (avctx->streams[avpkt.stream_index]->codecpar->format == AUDIOFORMATAC3) return true;
#else
if (avctx->streams[avpkt.stream_index]->codec->sample_fmt == AUDIOFORMATAC3) return true;
Expand Down
2 changes: 1 addition & 1 deletion command/decoder_new.h
Expand Up @@ -29,7 +29,7 @@ class cDecoder
bool isVideoStream();
bool isVideoIFrame();
bool isAudioStream();
bool isAudioAC3Frame();
bool isAudioAC3Stream();
long int GetFrameNumber();
long int GetIFrameCount();
bool isInterlacedVideo();
Expand Down
2 changes: 1 addition & 1 deletion command/markad-standalone.cpp
Expand Up @@ -1794,7 +1794,7 @@ void cMarkAdStandalone::ProcessFrame(cDecoder *ptr_cDecoder)
if (lastiframe>chkSTOP) CheckStop();
}
}
if(ptr_cDecoder->isAudioAC3Frame()) {
if(ptr_cDecoder->isAudioAC3Stream()) {
MarkAdMark *amark=audio->Process(lastiframe,iframe);
if (amark) AddMark(amark);
}
Expand Down

0 comments on commit fdfe80d

Please sign in to comment.