1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

The cutter now allocates its buffers on the heap to avoid problems on systems with limited stack space

This commit is contained in:
Klaus Schmidinger 2013-03-18 09:54:00 +01:00
parent b7f4536fe1
commit 5e805b5dfd
3 changed files with 26 additions and 5 deletions

View File

@ -2919,6 +2919,8 @@ Juergen Lock <vdr-l@jelal.kn-bremen.de>
in case, for instance, there is now a DVB-T device where there used to be a bonded in case, for instance, there is now a DVB-T device where there used to be a bonded
DVB-S device DVB-S device
for fixing a possible deadlock in handling the tuners of bonded devices for fixing a possible deadlock in handling the tuners of bonded devices
for suggesting to allocate the cutter's buffers on the heap to avoid problems on
systems with limited stack space
Sergiu Dotenco <sergiu.dotenco@googlemail.com> Sergiu Dotenco <sergiu.dotenco@googlemail.com>
for reporting a missing initialization in sDvbSpuRect for reporting a missing initialization in sDvbSpuRect

View File

@ -7767,3 +7767,5 @@ Video Disk Recorder Revision History
(thanks to Johann Friedrichs). (thanks to Johann Friedrichs).
- The "Resume" button in the main menu is now only active if the respective recording - The "Resume" button in the main menu is now only active if the respective recording
actually exists (reported by Johann Friedrichs). actually exists (reported by Johann Friedrichs).
- The cutter now allocates its buffers on the heap to avoid problems on systems with
limited stack space (suggested by Juergen Lock).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: cutter.c 2.24 2013/02/17 14:11:03 kls Exp $ * $Id: cutter.c 2.25 2013/03/18 09:40:49 kls Exp $
*/ */
#include "cutter.h" #include "cutter.h"
@ -362,11 +362,22 @@ bool cCuttingThread::SwitchFile(bool Force)
return true; return true;
} }
class cHeapBuffer {
private:
uchar *buffer;
public:
cHeapBuffer(int Size) { buffer = MALLOC(uchar, Size); }
~cHeapBuffer() { free(buffer); }
operator uchar * () { return buffer; }
};
bool cCuttingThread::FramesAreEqual(int Index1, int Index2) bool cCuttingThread::FramesAreEqual(int Index1, int Index2)
{ {
cHeapBuffer Buffer1(MAXFRAMESIZE);
cHeapBuffer Buffer2(MAXFRAMESIZE);
if (!Buffer1 || !Buffer2)
return false;
bool Independent; bool Independent;
uchar Buffer1[MAXFRAMESIZE];
uchar Buffer2[MAXFRAMESIZE];
int Length1; int Length1;
int Length2; int Length2;
if (LoadFrame(Index1, Buffer1, Independent, Length1) && LoadFrame(Index2, Buffer2, Independent, Length2)) { if (LoadFrame(Index1, Buffer1, Independent, Length1) && LoadFrame(Index2, Buffer2, Independent, Length2)) {
@ -386,12 +397,14 @@ bool cCuttingThread::FramesAreEqual(int Index1, int Index2)
void cCuttingThread::GetPendingPackets(uchar *Data, int &Length, int Index) void cCuttingThread::GetPendingPackets(uchar *Data, int &Length, int Index)
{ {
cHeapBuffer Buffer(MAXFRAMESIZE);
if (!Buffer)
return;
bool Processed[MAXPID] = { false }; bool Processed[MAXPID] = { false };
cPacketStorage PacketStorage; cPacketStorage PacketStorage;
int64_t LastPts = lastVidPts + delta;// adding one frame length to fully cover the very last frame int64_t LastPts = lastVidPts + delta;// adding one frame length to fully cover the very last frame
Processed[patPmtParser.Vpid()] = true; // we only want non-video packets Processed[patPmtParser.Vpid()] = true; // we only want non-video packets
for (int NumIndependentFrames = 0; NumIndependentFrames < 2; Index++) { for (int NumIndependentFrames = 0; NumIndependentFrames < 2; Index++) {
uchar Buffer[MAXFRAMESIZE];
bool Independent; bool Independent;
int len; int len;
if (LoadFrame(Index, Buffer, Independent, len)) { if (LoadFrame(Index, Buffer, Independent, len)) {
@ -534,8 +547,12 @@ bool cCuttingThread::ProcessSequence(int LastEndIndex, int BeginIndex, int EndIn
bool SeamlessBegin = LastEndIndex >= 0 && FramesAreEqual(LastEndIndex, BeginIndex); bool SeamlessBegin = LastEndIndex >= 0 && FramesAreEqual(LastEndIndex, BeginIndex);
bool SeamlessEnd = NextBeginIndex >= 0 && FramesAreEqual(EndIndex, NextBeginIndex); bool SeamlessEnd = NextBeginIndex >= 0 && FramesAreEqual(EndIndex, NextBeginIndex);
// Process all frames from BeginIndex (included) to EndIndex (excluded): // Process all frames from BeginIndex (included) to EndIndex (excluded):
cHeapBuffer Buffer(MAXFRAMESIZE);
if (!Buffer) {
error = "malloc";
return false;
}
for (int Index = BeginIndex; Running() && Index < EndIndex; Index++) { for (int Index = BeginIndex; Running() && Index < EndIndex; Index++) {
uchar Buffer[MAXFRAMESIZE];
bool Independent; bool Independent;
int Length; int Length;
if (LoadFrame(Index, Buffer, Independent, Length)) { if (LoadFrame(Index, Buffer, Independent, Length)) {