-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(*): refactored the encoder and decoder into classes
Signed-off-by: k4yt3x <[email protected]>
- Loading branch information
Showing
6 changed files
with
321 additions
and
350 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
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
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 |
---|---|---|
@@ -1,37 +1,43 @@ | ||
#ifndef ENCODER_H | ||
#define ENCODER_H | ||
|
||
#include <cstdint> | ||
#include <filesystem> | ||
|
||
extern "C" { | ||
#include <libavcodec/avcodec.h> | ||
#include <libavformat/avformat.h> | ||
#include <libavutil/opt.h> | ||
#include <libavutil/pixdesc.h> | ||
} | ||
|
||
#include "libvideo2x.h" | ||
|
||
int init_encoder( | ||
AVBufferRef *hw_ctx, | ||
std::filesystem::path out_fpath, | ||
AVFormatContext *ifmt_ctx, | ||
AVFormatContext **ofmt_ctx, | ||
AVCodecContext **enc_ctx, | ||
AVCodecContext *dec_ctx, | ||
EncoderConfig *encoder_config, | ||
int in_vstream_idx, | ||
int *out_vstream_idx, | ||
int **stream_map | ||
); | ||
|
||
int write_frame( | ||
AVFrame *frame, | ||
AVCodecContext *enc_ctx, | ||
AVFormatContext *ofmt_ctx, | ||
int out_vstream_idx, | ||
int64_t frame_idx | ||
); | ||
|
||
int flush_encoder(AVCodecContext *enc_ctx, AVFormatContext *ofmt_ctx, int out_vstream_idx); | ||
#include "libvideo2x/libvideo2x.h" | ||
|
||
class Encoder { | ||
public: | ||
Encoder(); | ||
~Encoder(); | ||
|
||
int init( | ||
AVBufferRef *hw_ctx, | ||
const std::filesystem::path &out_fpath, | ||
AVFormatContext *ifmt_ctx, | ||
AVCodecContext *dec_ctx, | ||
EncoderConfig *encoder_config, | ||
int in_vstream_idx | ||
); | ||
|
||
int write_frame(AVFrame *frame, int64_t frame_idx); | ||
int flush(); | ||
|
||
AVCodecContext *get_encoder_context() const; | ||
AVFormatContext *get_format_context() const; | ||
int *get_stream_map() const; | ||
int get_output_video_stream_index() const; | ||
|
||
private: | ||
AVFormatContext *ofmt_ctx_; | ||
AVCodecContext *enc_ctx_; | ||
int out_vstream_idx_; | ||
int *stream_map_; | ||
}; | ||
|
||
#endif // ENCODER_H |
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
Oops, something went wrong.