Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix potential cash in mythtranscode.

Fixes #10084
  • Loading branch information...
commit e89d6a9f7ed98cb60e32f0a0cfea674f573bb670 1 parent cb01f30
@jyavenard jyavenard authored
Showing with 27 additions and 14 deletions.
  1. +27 −14 mythtv/programs/mythtranscode/transcode.cpp
View
41 mythtv/programs/mythtranscode/transcode.cpp
@@ -45,14 +45,14 @@ class AudioReencodeBuffer : public AudioOutput
audiobuffer = new unsigned char[bufsize];
ab_count = 0;
- memset(ab_len, 0, sizeof(ab_len));
- memset(ab_offset, 0, sizeof(ab_offset));
- memset(ab_time, 0, sizeof(ab_time));
+ ab_size = 128;
+ ab = new AudioBuffer[ab_size];
}
~AudioReencodeBuffer()
{
delete [] audiobuffer;
+ delete [] ab;
}
// reconfigure sound out for new params
@@ -92,8 +92,16 @@ class AudioReencodeBuffer : public AudioOutput
audiobuffer = tmpbuf;
}
- ab_len[ab_count] = frames * bytes_per_frame;
- ab_offset[ab_count] = audiobuffer_len;
+ if (ab_count >= ab_size)
+ {
+ AudioBuffer *tmp = new AudioBuffer[ab_size + 128];
+ memcpy(tmp, ab, sizeof(AudioBuffer) * ab_size);
+ delete[] ab;
+ ab = tmp;
+ ab_size += 128;
+ }
+ ab[ab_count].len = frames * bytes_per_frame;
+ ab[ab_count].offset = audiobuffer_len;
memcpy(audiobuffer + audiobuffer_len, buffer,
frames * bytes_per_frame);
@@ -102,7 +110,7 @@ class AudioReencodeBuffer : public AudioOutput
// last_audiotime is at the end of the sample
last_audiotime = timecode + frames * 1000 / eff_audiorate;
- ab_time[ab_count] = last_audiotime;
+ ab[ab_count].time = last_audiotime;
ab_count++;
return true;
@@ -204,10 +212,15 @@ class AudioReencodeBuffer : public AudioOutput
virtual int readOutputData(unsigned char*, int ){ return 0; }
int bufsize;
- int ab_count;
- int ab_len[128];
- int ab_offset[128];
- long long ab_time[128];
+ uint ab_count;
+ struct AudioBuffer
+ {
+ int len;
+ int offset;
+ long long time;
+ };
+ AudioBuffer *ab;
+ uint ab_size;
unsigned char *audiobuffer;
int audiobuffer_len, channels, bits, bytes_per_frame, eff_audiorate;
long long last_audiotime;
@@ -1072,12 +1085,12 @@ int Transcode::TranscodeFile(
audioframesize = arb->audiobuffer_len;
if (arb->ab_count)
{
- for (int loop = 0; loop < arb->ab_count; loop++)
+ for (uint loop = 0; loop < arb->ab_count; loop++)
{
- nvr->SetOption("audioframesize", arb->ab_len[loop]);
- nvr->WriteAudio(arb->audiobuffer + arb->ab_offset[loop],
+ nvr->SetOption("audioframesize", arb->ab[loop].len);
+ nvr->WriteAudio(arb->audiobuffer + arb->ab[loop].offset,
audioFrame++,
- arb->ab_time[loop] - timecodeOffset);
+ arb->ab[loop].time - timecodeOffset);
if (nvr->IsErrored())
{
VERBOSE(VB_IMPORTANT, "Transcode: Encountered "
Please sign in to comment.
Something went wrong with that request. Please try again.