Skip to content

Commit

Permalink
Remove pointless packet resend code
Browse files Browse the repository at this point in the history
  • Loading branch information
myrsloik committed Mar 28, 2024
1 parent 48b7729 commit 4a3f9c5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
12 changes: 5 additions & 7 deletions src/audiosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/audiosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::string> &LAVFOpts, double DrcScale);
Expand Down
7 changes: 3 additions & 4 deletions src/videosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/videosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, std::string> &LAVFOpts);
Expand Down

0 comments on commit 4a3f9c5

Please sign in to comment.