mirror of
https://github.com/k4yt3x/video2x.git
synced 2025-01-28 21:38:41 +00:00
fix(encoder): re-add PTS calculation after processing for interpolators
Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
parent
9d4b21b4c1
commit
7d10fa2814
@ -63,7 +63,7 @@ class Encoder {
|
|||||||
int in_vstream_idx
|
int in_vstream_idx
|
||||||
);
|
);
|
||||||
|
|
||||||
int write_frame(AVFrame* frame);
|
int write_frame(AVFrame* frame, int64_t frame_idx);
|
||||||
int flush();
|
int flush();
|
||||||
|
|
||||||
AVCodecContext* get_encoder_context() const;
|
AVCodecContext* get_encoder_context() const;
|
||||||
|
@ -267,13 +267,16 @@ int Encoder::init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
|
[[gnu::target_clones("arch=x86-64-v4", "arch=x86-64-v3", "default")]]
|
||||||
int Encoder::write_frame(AVFrame* frame) {
|
int Encoder::write_frame(AVFrame* frame, int64_t frame_idx) {
|
||||||
AVFrame* converted_frame = nullptr;
|
AVFrame* converted_frame = nullptr;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
// Let the encoder decide the frame type
|
// Let the encoder decide the frame type
|
||||||
frame->pict_type = AV_PICTURE_TYPE_NONE;
|
frame->pict_type = AV_PICTURE_TYPE_NONE;
|
||||||
|
|
||||||
|
// Calculate this frame's presentation timestamp (PTS)
|
||||||
|
frame->pts = av_rescale_q(frame_idx, av_inv_q(enc_ctx_->framerate), enc_ctx_->time_base);
|
||||||
|
|
||||||
// Convert the frame to the encoder's pixel format if needed
|
// Convert the frame to the encoder's pixel format if needed
|
||||||
if (frame->format != enc_ctx_->pix_fmt) {
|
if (frame->format != enc_ctx_->pix_fmt) {
|
||||||
converted_frame = conversions::convert_avframe_pix_fmt(frame, enc_ctx_->pix_fmt);
|
converted_frame = conversions::convert_avframe_pix_fmt(frame, enc_ctx_->pix_fmt);
|
||||||
|
@ -314,7 +314,7 @@ int VideoProcessor::write_frame(AVFrame* frame, encoder::Encoder& encoder) {
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (!benchmark_) {
|
if (!benchmark_) {
|
||||||
ret = encoder.write_frame(frame);
|
ret = encoder.write_frame(frame, frame_idx_);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
av_strerror(ret, errbuf, sizeof(errbuf));
|
av_strerror(ret, errbuf, sizeof(errbuf));
|
||||||
logger()->critical("Error encoding/writing frame: {}", errbuf);
|
logger()->critical("Error encoding/writing frame: {}", errbuf);
|
||||||
|
Loading…
Reference in New Issue
Block a user