diff --git a/src/audiosource.cpp b/src/audiosource.cpp index e93ab77..7015522 100644 --- a/src/audiosource.cpp +++ b/src/audiosource.cpp @@ -65,11 +65,10 @@ bool LWAudioDecoder::DecodeNextFrame(bool SkipOutput) { if (Ret == 0) { return true; } else if (Ret == AVERROR(EAGAIN)) { - if (ResendPacket || ReadPacket()) { + if (ReadPacket()) { int SendRet = avcodec_send_packet(CodecContext, Packet); - ResendPacket = (SendRet == AVERROR(EAGAIN)); - if (!ResendPacket) - av_packet_unref(Packet); + assert(SendRet != AVERROR(EAGAIN)); + av_packet_unref(Packet); } else { avcodec_send_packet(CodecContext, nullptr); } @@ -930,13 +929,12 @@ void BestAudioSource::ZeroFillEndPlanar(uint8_t *Data[], int64_t Start, int64_t } static void UnpackChannels(const uint8_t *Src, uint8_t *Dst[], size_t Length, size_t Channels, size_t BytesPerSample) { - const uint8_t *S = Src; for (size_t i = 0; i < Length; i++) { for (size_t c = 0; c < Channels; c++) { - memcpy(Dst[c], S + c * BytesPerSample, BytesPerSample); + memcpy(Dst[c], Src, BytesPerSample); Dst[c] += BytesPerSample; + Src += BytesPerSample; } - S += Channels * BytesPerSample; } } diff --git a/src/audiosource.h b/src/audiosource.h index 8699ae2..399eeee 100644 --- a/src/audiosource.h +++ b/src/audiosource.h @@ -67,7 +67,6 @@ struct LWAudioDecoder { int TrackNumber = -1; bool DecodeSuccess = true; AVPacket *Packet = nullptr; - bool ResendPacket = false; bool Seeked = false; void OpenFile(const std::string &SourceFile, int Track, bool VariableFormat, int Threads, const std::map &LAVFOpts, double DrcScale); diff --git a/src/videosource.cpp b/src/videosource.cpp index 89b83fe..09a8594 100644 --- a/src/videosource.cpp +++ b/src/videosource.cpp @@ -104,11 +104,10 @@ bool LWVideoDecoder::DecodeNextFrame(bool SkipOutput) { } return true; } else if (Ret == AVERROR(EAGAIN)) { - if (ResendPacket || ReadPacket()) { + if (ReadPacket()) { int SendRet = avcodec_send_packet(CodecContext, Packet); - ResendPacket = (SendRet == AVERROR(EAGAIN)); - if (!ResendPacket) - av_packet_unref(Packet); + assert(SendRet != AVERROR(EAGAIN)); + av_packet_unref(Packet); } else { avcodec_send_packet(CodecContext, nullptr); } diff --git a/src/videosource.h b/src/videosource.h index ebceaec..dddd053 100644 --- a/src/videosource.h +++ b/src/videosource.h @@ -107,7 +107,6 @@ struct LWVideoDecoder { bool HWMode = false; bool DecodeSuccess = true; AVPacket *Packet = nullptr; - bool ResendPacket = false; bool Seeked = false; void OpenFile(const std::string &SourceFile, const std::string &HWDeviceName, int ExtraHWFrames, int Track, bool VariableFormat, int Threads, const std::map &LAVFOpts);