@@ -1361,14 +1361,8 @@ void VideoDecoder::convertAudioAVFrameToFrameOutputOnCPU(
13611361 static_cast <AVSampleFormat>(avFrameStream.avFrame ->format );
13621362 AVSampleFormat desiredSampleFormat = AV_SAMPLE_FMT_FLTP;
13631363
1364- UniqueAVFrame convertedAVFrame;
1365- if (sourceSampleFormat != desiredSampleFormat) {
1366- convertedAVFrame = convertAudioAVFrameSampleFormat (
1367- avFrameStream.avFrame , sourceSampleFormat, desiredSampleFormat);
1368- }
1369- const UniqueAVFrame& avFrame = (sourceSampleFormat != desiredSampleFormat)
1370- ? convertedAVFrame
1371- : avFrameStream.avFrame ;
1364+ const UniqueAVFrame avFrame = convertAudioAVFrameSampleFormat (
1365+ avFrameStream.avFrame , sourceSampleFormat, desiredSampleFormat);
13721366
13731367 AVSampleFormat format = static_cast <AVSampleFormat>(avFrame->format );
13741368 TORCH_CHECK (
@@ -1395,11 +1389,13 @@ void VideoDecoder::convertAudioAVFrameToFrameOutputOnCPU(
13951389}
13961390
13971391UniqueAVFrame VideoDecoder::convertAudioAVFrameSampleFormat (
1398- const UniqueAVFrame& avFrame,
1392+ UniqueAVFrame& avFrame,
13991393 AVSampleFormat sourceSampleFormat,
1400- AVSampleFormat desiredSampleFormat
1394+ AVSampleFormat desiredSampleFormat) {
1395+ if (sourceSampleFormat == desiredSampleFormat) {
1396+ return std::move (avFrame);
1397+ }
14011398
1402- ) {
14031399 auto & streamInfo = streamInfos_[activeStreamIndex_];
14041400 const auto & streamMetadata =
14051401 containerMetadata_.allStreamMetadata [activeStreamIndex_];
0 commit comments