From eb72b73e6ca48b109809fd39558e6e45b0ae4538 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 9 Dec 2024 17:58:03 -0800 Subject: [PATCH] FFmpeg: Move some error buffers around Since in one case, it probably wasn't combining them into one stack allocation, it probably blew up the stack allocation quite a bit. Signed-off-by: Christopher Snowhill --- Plugins/FFMPEG/FFMPEGContainer.m | 5 ++--- Plugins/FFMPEG/FFMPEGDecoder.m | 10 ++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Plugins/FFMPEG/FFMPEGContainer.m b/Plugins/FFMPEG/FFMPEGContainer.m index b4f68de70..d1a70084c 100644 --- a/Plugins/FFMPEG/FFMPEGContainer.m +++ b/Plugins/FFMPEG/FFMPEGContainer.m @@ -26,6 +26,8 @@ } + (NSArray *)urlsForContainerURL:(NSURL *)url { + char errDescr[4096]; + if([url fragment]) { // input url already has fragment defined - no need to expand further return [NSMutableArray arrayWithObject:url]; @@ -65,7 +67,6 @@ NSString *urlString = [url absoluteString]; if((errcode = avformat_open_input(&formatCtx, [urlString UTF8String], NULL, NULL)) < 0) { - char errDescr[4096]; av_strerror(errcode, errDescr, 4096); ALog(@"Error opening file, errcode = %d, error = %s", errcode, errDescr); return [NSArray array]; @@ -102,7 +103,6 @@ formatCtx->pb = ioCtx; if((errcode = avformat_open_input(&formatCtx, "", NULL, NULL)) < 0) { - char errDescr[4096]; av_strerror(errcode, errDescr, 4096); ALog(@"Error opening file, errcode = %d, error = %s", errcode, errDescr); avformat_close_input(&(formatCtx)); @@ -116,7 +116,6 @@ } if((errcode = avformat_find_stream_info(formatCtx, NULL)) < 0) { - char errDescr[4096]; av_strerror(errcode, errDescr, 4096); ALog(@"Can't find stream info, errcode = %d, error = %s", errcode, errDescr); avformat_close_input(&(formatCtx)); diff --git a/Plugins/FFMPEG/FFMPEGDecoder.m b/Plugins/FFMPEG/FFMPEGDecoder.m index efb433c30..ed231101e 100644 --- a/Plugins/FFMPEG/FFMPEGDecoder.m +++ b/Plugins/FFMPEG/FFMPEGDecoder.m @@ -82,6 +82,8 @@ static uint8_t reverse_bits[0x100]; } - (BOOL)open:(id)s { + char errDescr[4096]; + int errcode, i; AVStream *stream; @@ -119,7 +121,6 @@ static uint8_t reverse_bits[0x100]; NSString *urlString = [url absoluteString]; if((errcode = avformat_open_input(&formatCtx, [urlString UTF8String], NULL, NULL)) < 0) { - char errDescr[4096]; av_strerror(errcode, errDescr, 4096); ALog(@"Error opening file, errcode = %d, error = %s", errcode, errDescr); return NO; @@ -146,7 +147,6 @@ static uint8_t reverse_bits[0x100]; formatCtx->pb = ioCtx; if((errcode = avformat_open_input(&formatCtx, "", NULL, NULL)) < 0) { - char errDescr[4096]; av_strerror(errcode, errDescr, 4096); ALog(@"Error opening file, errcode = %d, error = %s", errcode, errDescr); return NO; @@ -154,7 +154,6 @@ static uint8_t reverse_bits[0x100]; } if((errcode = avformat_find_stream_info(formatCtx, NULL)) < 0) { - char errDescr[4096]; av_strerror(errcode, errDescr, 4096); ALog(@"Can't find stream info, errcode = %d, error = %s", errcode, errDescr); return NO; @@ -195,7 +194,6 @@ static uint8_t reverse_bits[0x100]; } if((errcode = avcodec_parameters_to_context(codecCtx, codecPar)) < 0) { - char errDescr[4096]; av_strerror(errcode, errDescr, 4096); ALog(@"Can't copy codec parameters to context, errcode = %d, error = %s", errcode, errDescr); return NO; @@ -266,7 +264,6 @@ static uint8_t reverse_bits[0x100]; } if(!rawDSD && (errcode = avcodec_open2(codecCtx, codec, &dict)) < 0) { - char errDescr[4096]; av_dict_free(&dict); av_strerror(errcode, errDescr, 4096); ALog(@"could not open codec, errcode = %d, error = %s", errcode, errDescr); @@ -704,6 +701,8 @@ static void setDictionary(NSMutableDictionary *dict, NSString *tag, NSString *va } - (AudioChunk *)readAudio { + char errDescr[4096]; + if(!seekedToStart) { [self seek:0]; } @@ -801,7 +800,6 @@ static void setDictionary(NSMutableDictionary *dict, NSString *tag, NSString *va readNextPacket = YES; continue; } else { - char errDescr[4096]; av_strerror(errcode, errDescr, 4096); ALog(@"Error receiving frame, errcode = %d, error = %s", errcode, errDescr); return 0;