Skip to content

Commit 5b39c8f

Browse files
committed
WIP
1 parent c3ac80a commit 5b39c8f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/torchcodec/_core/SingleStreamDecoder.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,12 +1402,12 @@ UniqueAVFrame SingleStreamDecoder::convertAudioAVFrameSampleFormatAndSampleRate(
14021402
auto& streamInfo = streamInfos_[activeStreamIndex_];
14031403

14041404
if (!streamInfo.swrContext) {
1405-
createSwrContext(
1406-
streamInfo,
1405+
streamInfo.swrContext.reset(createSwrContext(
1406+
streamInfo.codecContext,
14071407
sourceSampleFormat,
14081408
desiredSampleFormat,
14091409
sourceSampleRate,
1410-
desiredSampleRate);
1410+
desiredSampleRate));
14111411
}
14121412

14131413
UniqueAVFrame convertedAVFrame(av_frame_alloc());
@@ -1735,14 +1735,14 @@ void SingleStreamDecoder::createSwsContext(
17351735
streamInfo.swsContext.reset(swsContext);
17361736
}
17371737

1738-
void SingleStreamDecoder::createSwrContext(
1739-
StreamInfo& streamInfo,
1738+
SwrContext* SingleStreamDecoder::createSwrContext(
1739+
UniqueAVCodecContext& avCodecContext,
17401740
AVSampleFormat sourceSampleFormat,
17411741
AVSampleFormat desiredSampleFormat,
17421742
int sourceSampleRate,
17431743
int desiredSampleRate) {
17441744
auto swrContext = allocateSwrContext(
1745-
streamInfo.codecContext,
1745+
avCodecContext,
17461746
sourceSampleFormat,
17471747
desiredSampleFormat,
17481748
sourceSampleRate,
@@ -1756,7 +1756,8 @@ void SingleStreamDecoder::createSwrContext(
17561756
". If the error says 'Invalid argument', it's likely that you are using "
17571757
"a buggy FFmpeg version. FFmpeg4 is known to fail here in some "
17581758
"valid scenarios. Try to upgrade FFmpeg?");
1759-
streamInfo.swrContext.reset(swrContext);
1759+
// streamInfo.swrContext.reset(swrContext);
1760+
return swrContext;
17601761
}
17611762

17621763
// --------------------------------------------------------------------------

src/torchcodec/_core/SingleStreamDecoder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ class SingleStreamDecoder {
310310
const DecodedFrameContext& frameContext,
311311
const enum AVColorSpace colorspace);
312312

313-
void createSwrContext(
314-
StreamInfo& streamInfo,
313+
SwrContext* createSwrContext(
314+
UniqueAVCodecContext& avCodecContext,
315315
AVSampleFormat sourceSampleFormat,
316316
AVSampleFormat desiredSampleFormat,
317317
int sourceSampleRate,

0 commit comments

Comments
 (0)