Permalink
Browse files

Fix some warnings and static analyzer complaints

- Adjust some error checks/remove some useless ones
- Rename some functions to comply to static analyzer naming conventions

git-svn-id: https://svn.perian.org/trunk@1483 621663c8-3916-0410-8f58-edc14a8543d5
  • Loading branch information...
astrange
astrange committed Dec 19, 2011
1 parent 78dc3b0 commit 96cd438a373fc0aecebfa12a7e8182aae62c2305
View
@@ -257,6 +257,8 @@ ComponentResult ReadESDSDescExt(Handle descExt, UInt8 **buffer, int *size)
UInt8 *esds = (UInt8 *) *descExt;
int tag, len;
// FIXME use safe bytestream reading here
*size = 0;
esds += 4; // version + flags
@@ -343,7 +345,7 @@ static int findNameInList(CFStringRef loadingApp, const CFStringRef *names, int
return 0;
}
static CFDictionaryRef getMyProcessInformation()
static CFDictionaryRef copyMyProcessInformation()
{
ProcessSerialNumber myProcess;
GetCurrentProcess(&myProcess);
@@ -353,7 +355,7 @@ static CFDictionaryRef getMyProcessInformation()
return processInformation;
}
static CFStringRef getProcessName(CFDictionaryRef processInformation)
static CFStringRef copyProcessName(CFDictionaryRef processInformation)
{
CFStringRef path = CFDictionaryGetValue(processInformation, kCFBundleExecutableKey);
CFRange entireRange = CFRangeMake(0, CFStringGetLength(path)), basename;
@@ -369,13 +371,13 @@ static CFStringRef getProcessName(CFDictionaryRef processInformation)
static int isApplicationNameInList(CFStringRef prefOverride, const CFStringRef *defaultList, unsigned int defaultListCount)
{
CFDictionaryRef processInformation = getMyProcessInformation();
CFDictionaryRef processInformation = copyMyProcessInformation();
if (!processInformation)
return FALSE;
CFArrayRef list = CopyPreferencesValueTyped(prefOverride, CFArrayGetTypeID());
CFStringRef myProcessName = getProcessName(processInformation);
CFStringRef myProcessName = copyProcessName(processInformation);
int ret;
if (list) {
View
@@ -128,17 +128,21 @@ void CompressAudioCodec::Initialize(const AudioStreamBasicDescription* inInputFo
while((component = FindNextComponent(component, &desc)) != NULL)
{
ComponentResult err = OpenAComponent(component, &actualUnit);
AudioStreamBasicDescription input = mInputFormat ;
if (err)
continue;
AudioStreamBasicDescription input = mInputFormat;
input.mFormatID = original;
err = AudioCodecInitialize(actualUnit, &input, inOutputFormat, innerCookie, innerCookieSize);
if(err == noErr)
break;
}
if (!actualUnit)
CODEC_THROW(kAudioCodecUnsupportedFormatError);
}
else if(actualUnit != NULL)
{
OSType original = originalStreamFourCC(mInputFormat.mFormatID);
AudioStreamBasicDescription input = mInputFormat ;
AudioStreamBasicDescription input = mInputFormat;
input.mFormatID = original;
AudioCodecInitialize(actualUnit, &input, inOutputFormat, innerCookie, innerCookieSize);
}
View
@@ -68,7 +68,7 @@ ComponentResult CompressCodecOpen(CompressCodecGlobals glob, ComponentInstance s
ComponentResult err;
glob = (CompressCodecGlobals)NewPtrClear(sizeof(CompressCodecGlobalRecord));
if(err = MemError()) goto bail;
if((err = MemError())) goto bail;
SetComponentInstanceStorage(self, (Handle)glob);
glob->self = self;
@@ -36,7 +36,8 @@ FFissionCodec::FFissionCodec(AudioComponentInstance inInstance) : ACBaseCodec(in
{
FFInitFFmpeg();
avContext = avcodec_alloc_context();
// FIXME avcodec_alloc_context3
avContext = avcodec_alloc_context2(AVMEDIA_TYPE_AUDIO);
avCodec = NULL;
}
@@ -394,7 +394,7 @@ void FFissionDecoder::OpenAVCodec()
if (magicCookie)
SetupExtradata();
if (avcodec_open(avContext, avCodec)) {
if (avcodec_open2(avContext, avCodec, NULL)) {
Codecprintf(NULL, "error opening audio avcodec\n");
avCodec = NULL;
CODEC_THROW(kAudioCodecUnsupportedFormatError);
@@ -500,18 +500,15 @@ int produceDTSPassthroughPackets(Byte *outputBuffer, int *outBufUsed, uint8_t *p
uint32_t mrk = AV_RB16(packet) << 16 | AV_RB16(packet + 2);
unsigned int frameSize = 0;
unsigned int blockCount = 0;
bool repackage = 0;
switch (mrk) {
case DCA_MARKER_RAW_BE:
blockCount = (AV_RB16(packet + 4) >> 2) & 0x7f;
frameSize = (AV_RB16(packet + 4) & 0x3) << 12 | (AV_RB16(packet + 6) >> 4) & 0xfff;
repackage = 1;
frameSize = (AV_RB16(packet + 4) & 0x3) << 12 | ((AV_RB16(packet + 6) >> 4) & 0xfff);
break;
case DCA_MARKER_RAW_LE:
blockCount = (AV_RL16(packet + 4) >> 2) & 0x7f;
frameSize = (AV_RL16(packet + 4) & 0x3) << 12 | (AV_RL16(packet + 6) >> 4) & 0xfff;
repackage = 1;
frameSize = (AV_RL16(packet + 4) & 0x3) << 12 | ((AV_RL16(packet + 6) >> 4) & 0xfff);
break;
case DCA_MARKER_14B_BE:
case DCA_MARKER_14B_LE:
@@ -674,6 +671,7 @@ UInt32 FFissionDecoder::ProduceOutputPackets(void* outOutputData,
av_init_packet(&pkt);
pkt.data = packet;
pkt.size = packetSize;
// FIXME avcodec_decode_audio4
len = avcodec_decode_audio3(avContext, (int16_t *)outputBuffer, &outBufUsed, &pkt);
}
View
@@ -292,7 +292,7 @@ static enum PixelFormat FindPixFmtFromVideo(AVCodec *codec, AVCodecContext *avct
tmpContext.extradata = avctx->extradata;
tmpContext.extradata_size = avctx->extradata_size;
avcodec_open(&tmpContext, codec);
avcodec_open2(&tmpContext, codec, NULL);
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = (UInt8*)data;
@@ -403,7 +403,7 @@ pascal ComponentResult FFusionCodecOpen(FFusionGlobals glob, ComponentInstance s
glob = (FFusionGlobals)NewPtrClear(sizeof(FFusionGlobalsRecord));
if (err = MemError())
if ((err = MemError()))
{
Codecprintf(NULL, "Unable to allocate globals! Exiting.\n");
}
@@ -758,7 +758,7 @@ pascal ComponentResult FFusionCodecPreflight(FFusionGlobals glob, CodecDecompres
// Finally we open the avcodec
if (avcodec_open(glob->avContext, glob->avCodec))
if (avcodec_open2(glob->avContext, glob->avCodec, NULL))
{
Codecprintf(glob->fileLog, "Error opening avcodec!\n");
View
@@ -352,7 +352,7 @@ ComponentResult MatroskaImport::Idle(long inFlags, long *outFlags)
// Only add samples every 20 idles when paused
// or if we're playing and only have 5 seconds away from the end of
// what's already been added
if (currentIdleTime == lastIdleTime && idlesSinceLastAdd > 20 ||
if ((currentIdleTime == lastIdleTime && idlesSinceLastAdd > 20) ||
maxLoadedTime < currentIdleTime + 5*movieTimeScale)
{
idlesSinceLastAdd = 0;
View
@@ -95,7 +95,7 @@ class MatroskaTrack {
// adds the all the frames in the block group to the sample table if it exists,
// the media otherwise. If this track type is subtitle, also inserts it into the track.
void AddBlock(KaxInternalBlock &block, uint32 duration, short flags);
void AddBlock(KaxInternalBlock &block, uint32 frameDuration, short flags);
// this adds all the samples added through AddBlock() to the track that aren't already
// added, e.g. from a previous call to AddSamplesToTrack()
@@ -246,7 +246,7 @@ class MatroskaImport {
// this is called recursively to add only the leaves on the chapter tree to
// chapter track, since QT doesn't support chapter nesting.
void AddChapterAtom(KaxChapterAtom *atom, Track chapterTrack);
void AddChapterAtom(KaxChapterAtom *atom);
// assumes cluster has been read already, and cycles through the contained blocks and
// adds the frames to the media/sample table, and to the track if addToTrack is true
View
@@ -605,7 +605,6 @@ ComponentResult MatroskaImport::AddAudioTrack(KaxTrackEntry &kaxTrack, MatroskaT
if (err) {
Codecprintf(NULL, "AudioFormatGetProperty failed (error %lx / format %lx)\n", err, asbd.mFormatID);
err = noErr;
}
// see ff_private.c initialize_audio_map
@@ -846,7 +845,7 @@ ComponentResult MatroskaImport::ReadChapters(KaxChapters &chapterEntries)
KaxChapterAtom *chapterAtom = FindChild<KaxChapterAtom>(edition);
while (chapterAtom && chapterAtom->GetSize() > 0) {
AddChapterAtom(chapterAtom, chapterTrack);
AddChapterAtom(chapterAtom);
chapterAtom = &GetNextChild<KaxChapterAtom>(edition, *chapterAtom);
}
@@ -856,7 +855,7 @@ ComponentResult MatroskaImport::ReadChapters(KaxChapters &chapterEntries)
return noErr;
}
void MatroskaImport::AddChapterAtom(KaxChapterAtom *atom, Track chapterTrack)
void MatroskaImport::AddChapterAtom(KaxChapterAtom *atom)
{
KaxChapterAtom *subChapter = FindChild<KaxChapterAtom>(*atom);
bool addThisChapter = true;
@@ -867,7 +866,7 @@ void MatroskaImport::AddChapterAtom(KaxChapterAtom *atom, Track chapterTrack)
KaxChapterFlagHidden &hideChapter = GetChild<KaxChapterFlagHidden>(*subChapter);
if (!uint8_t(hideChapter)) {
AddChapterAtom(subChapter, chapterTrack);
AddChapterAtom(subChapter);
addThisChapter = false;
}
subChapter = &GetNextChild(*atom, *subChapter);
@@ -936,8 +935,9 @@ ComponentResult MatroskaImport::ReadAttachments(KaxAttachments &attachments)
KaxFileData & fileData = GetChild<KaxFileData>(*attachedFile);
FourCharCode key = 'covr'; //iTunes cover art tag
QTMetaDataRef movieMetaData;
OSStatus err = QTCopyMovieMetaData(theMovie, &movieMetaData);
QTCopyMovieMetaData(theMovie, &movieMetaData);
OSErr err;
err = QTMetaDataAddItem(movieMetaData,
kQTMetaDataStorageFormatiTunes, kQTMetaDataKeyFormatiTunesShortForm,
(UInt8 *)&key, sizeof(key),
@@ -1040,9 +1040,9 @@ void MatroskaImport::ImportCluster(KaxCluster &cluster, bool addToTrack)
if (block) {
block->SetParent(cluster);
for (int i = 0; i < tracks.size(); i++) {
if (tracks[i].number == block->TrackNum()) {
tracks[i].AddBlock(*block, duration, flags);
for (int j = 0; j < tracks.size(); j++) {
if (tracks[j].number == block->TrackNum()) {
tracks[j].AddBlock(*block, duration, flags);
break;
}
}
@@ -1198,12 +1198,12 @@ void MatroskaTrack::ParseFirstBlock(KaxInternalBlock &block)
if (err == noErr) {
DisposeHandle((Handle) desc);
desc = (SampleDescriptionHandle) sndDesc;
err = QTSampleTableAddSampleDescription(sampleTable, desc, 0, &qtSampleDesc);
QTSampleTableAddSampleDescription(sampleTable, desc, 0, &qtSampleDesc);
}
}
}
void MatroskaTrack::AddBlock(KaxInternalBlock &block, uint32 duration, short flags)
void MatroskaTrack::AddBlock(KaxInternalBlock &block, uint32 frameDuration, short flags)
{
if (!seenFirstBlock) {
ParseFirstBlock(block);
@@ -1264,8 +1264,8 @@ void MatroskaTrack::AddBlock(KaxInternalBlock &block, uint32 duration, short fla
MatroskaFrame newFrame;
newFrame.pts = block.GlobalTimecode() / timecodeScale;
newFrame.dts = newFrame.pts;
if (duration > 0)
newFrame.duration = duration;
if (frameDuration > 0)
newFrame.duration = frameDuration;
else
newFrame.duration = defaultDuration;
newFrame.offset = block.GetDataPosition(i);
@@ -1291,7 +1291,7 @@ void MatroskaTrack::AddBlock(KaxInternalBlock &block, uint32 duration, short fla
void MatroskaTrack::AddFrame(MatroskaFrame &frame)
{
ComponentResult err = noErr;
TimeValue sampleTime;
TimeValue sampleTime = 0;
TimeValue64 displayOffset = frame.pts - frame.dts;
if (desc == NULL) return;
@@ -2423,7 +2423,7 @@
SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_STYLE = debugging;
WARNING_CFLAGS = "-Wimplicit";
WARNING_CFLAGS = "-Werror=implicit";
};
name = Development;
};
@@ -2462,7 +2462,7 @@
SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = YES;
STRIP_STYLE = debugging;
WARNING_CFLAGS = "-Wimplicit";
WARNING_CFLAGS = "-Werror=implicit";
};
name = Deployment;
};
@@ -2627,7 +2627,7 @@
SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
STRIP_STYLE = debugging;
WARNING_CFLAGS = "-Wimplicit";
WARNING_CFLAGS = "-Werror=implicit";
};
name = "Deployment+Debug";
};
@@ -66,21 +66,21 @@ -(void)finalize
[super finalize];
}
static CGColorRef MakeCGColorFromRGBA(SubRGBAColor c, CGColorSpaceRef cspace)
static CGColorRef CreateCGColorFromRGBA(SubRGBAColor c, CGColorSpaceRef cspace)
{
const float components[] = {c.red, c.green, c.blue, c.alpha};
return CGColorCreate(cspace, components);
}
static CGColorRef MakeCGColorFromRGBOpaque(SubRGBAColor c, CGColorSpaceRef cspace)
static CGColorRef CreateCGColorFromRGBOpaque(SubRGBAColor c, CGColorSpaceRef cspace)
{
SubRGBAColor c2 = c;
c2.alpha = 1;
return MakeCGColorFromRGBA(c2, cspace);
return CreateCGColorFromRGBA(c2, cspace);
}
static CGColorRef CloneCGColorWithAlpha(CGColorRef c, float alpha)
static CGColorRef CopyCGColorWithAlpha(CGColorRef c, float alpha)
{
CGColorRef new = CGColorCreateCopyWithAlpha(c, alpha);
CGColorRelease(c);
@@ -92,11 +92,11 @@ -(SubATSUISpanEx*)initWithStyle:(ATSUStyle)style_ subStyle:(SubStyle*)sstyle col
if (self = [super init]) {
ATSUCreateAndCopyStyle(style_, &style);
primaryColor = MakeCGColorFromRGBOpaque(sstyle->primaryColor, cs);
primaryColor = CreateCGColorFromRGBOpaque(sstyle->primaryColor, cs);
primaryAlpha = sstyle->primaryColor.alpha;
outlineColor = MakeCGColorFromRGBOpaque(sstyle->outlineColor, cs);
outlineColor = CreateCGColorFromRGBOpaque(sstyle->outlineColor, cs);
outlineAlpha = sstyle->outlineColor.alpha;
shadowColor = MakeCGColorFromRGBA(sstyle->shadowColor, cs);
shadowColor = CreateCGColorFromRGBA(sstyle->shadowColor, cs);
outlineRadius = sstyle->outlineRadius;
shadowDist = sstyle->shadowDist;
scaleX = sstyle->scaleX / 100.;
@@ -423,7 +423,7 @@ -(void)spanChangedTag:(SubSSATagName)tag span:(SubRenderSpan*)span div:(SubRende
#define fv() fval = *(float*)p;
#define sv() sval = *(NSString**)p;
#define fixv() fv(); fixval = FloatToFixed(fval);
#define colorv() color = MakeCGColorFromRGBA(SubParseSSAColor(*(int*)p), srgbCSpace);
#define colorv() color = CreateCGColorFromRGBA(SubParseSSAColor(*(int*)p), srgbCSpace);
switch (tag) {
case tag_b:
@@ -477,7 +477,7 @@ -(void)spanChangedTag:(SubSSATagName)tag span:(SubRenderSpan*)span div:(SubRende
if (!isFirstSpan) div->render_complexity |= renderMultipleParts;
{
SubRGBAColor rgba = SubParseSSAColor(*(int*)p);
spanEx->outlineColor = MakeCGColorFromRGBOpaque(rgba, srgbCSpace);
spanEx->outlineColor = CreateCGColorFromRGBOpaque(rgba, srgbCSpace);
spanEx->outlineAlpha = rgba.alpha;
}
break;
@@ -521,14 +521,14 @@ -(void)spanChangedTag:(SubSSATagName)tag span:(SubRenderSpan*)span div:(SubRende
case tag_4a:
iv();
if (!isFirstSpan) div->render_complexity |= renderMultipleParts | renderManualShadows;
spanEx->shadowColor = CloneCGColorWithAlpha(spanEx->shadowColor, (255-ival)/255.);
spanEx->shadowColor = CopyCGColorWithAlpha(spanEx->shadowColor, (255-ival)/255.);
break;
case tag_alpha:
iv();
fval = (255-ival)/255.;
if (!isFirstSpan) div->render_complexity |= renderMultipleParts | renderManualShadows;
spanEx->primaryAlpha = spanEx->outlineAlpha = fval;
spanEx->shadowColor = CloneCGColorWithAlpha(spanEx->shadowColor, fval);
spanEx->shadowColor = CopyCGColorWithAlpha(spanEx->shadowColor, fval);
break;
case tag_r:
sv();
View
@@ -48,8 +48,10 @@ __BEGIN_DECLS
unsigned last_begin_time, last_end_time;
unsigned num_lines_input;
}
@property (assign) BOOL finished;
-(void)addLine:(SubLine *)sline;
-(void)setFinished:(BOOL)finished;
-(SubLine*)getSerializedPacket;
-(BOOL)isEmpty;
@end
Oops, something went wrong.

0 comments on commit 96cd438

Please sign in to comment.