-
Notifications
You must be signed in to change notification settings - Fork 684
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <torchaudio/csrc/ffmpeg/decoder.h> | ||
|
||
namespace torchaudio { | ||
namespace ffmpeg { | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// Decoder | ||
//////////////////////////////////////////////////////////////////////////////// | ||
Decoder::Decoder(AVCodecParameters* pParam) : pCodecContext(pParam) {} | ||
|
||
int Decoder::process_packet(AVPacket* pPacket) { | ||
return avcodec_send_packet(pCodecContext, pPacket); | ||
} | ||
|
||
int Decoder::get_frame(AVFrame* pFrame) { | ||
return avcodec_receive_frame(pCodecContext, pFrame); | ||
} | ||
|
||
} // namespace ffmpeg | ||
} // namespace torchaudio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include <torchaudio/csrc/ffmpeg/ffmpeg.h> | ||
|
||
namespace torchaudio { | ||
namespace ffmpeg { | ||
|
||
class Decoder { | ||
AVCodecContextPtr pCodecContext; | ||
|
||
public: | ||
// Default constructable | ||
Decoder(AVCodecParameters* pParam); | ||
// Custom destructor to clean up the resources | ||
~Decoder() = default; | ||
// Non-copyable | ||
Decoder(const Decoder&) = delete; | ||
Decoder& operator=(const Decoder&) = delete; | ||
// Movable | ||
Decoder(Decoder&&) = default; | ||
Decoder& operator=(Decoder&&) = default; | ||
|
||
// Process incoming packet | ||
int process_packet(AVPacket* pPacket); | ||
// Fetch a decoded frame | ||
int get_frame(AVFrame* pFrame); | ||
}; | ||
|
||
} // namespace ffmpeg | ||
} // namespace torchaudio |