#include "audio_encoder.h"
#include "defs.h"
#include "shared/timebase.h"
#include "print_latency.h"
#include "audio_encoder.h"
#include "defs.h"
#include "shared/timebase.h"
#include "print_latency.h"
#define SURFACE_NUM 16 /* 16 surfaces for source YUV */
#define MAX_NUM_REF1 16 // Seemingly a hardware-fixed value, not related to SURFACE_NUM
#define MAX_NUM_REF2 32 // Seemingly a hardware-fixed value, not related to SURFACE_NUM
#define SURFACE_NUM 16 /* 16 surfaces for source YUV */
#define MAX_NUM_REF1 16 // Seemingly a hardware-fixed value, not related to SURFACE_NUM
#define MAX_NUM_REF2 32 // Seemingly a hardware-fixed value, not related to SURFACE_NUM
void open_output_file(const std::string &filename);
void encode_thread_func();
void encode_remaining_frames_as_p(int encoding_frame_num, int gop_start_display_frame_num, int64_t last_dts);
void open_output_file(const std::string &filename);
void encode_thread_func();
void encode_remaining_frames_as_p(int encoding_frame_num, int gop_start_display_frame_num, int64_t last_dts);
void pass_frame(PendingFrame frame, int display_frame_num, int64_t pts, int64_t duration);
void encode_frame(PendingFrame frame, int encoding_frame_num, int display_frame_num, int gop_start_display_frame_num,
int frame_type, int64_t pts, int64_t dts, int64_t duration, movit::YCbCrLumaCoefficients ycbcr_coefficients);
void pass_frame(PendingFrame frame, int display_frame_num, int64_t pts, int64_t duration);
void encode_frame(PendingFrame frame, int encoding_frame_num, int display_frame_num, int gop_start_display_frame_num,
int frame_type, int64_t pts, int64_t dts, int64_t duration, movit::YCbCrLumaCoefficients ycbcr_coefficients);
VideoCodecInterface *disk_encoder;
std::unique_ptr<V4LOutput> v4l_output; // nullptr if not using V4L2 output.
VideoCodecInterface *disk_encoder;
std::unique_ptr<V4LOutput> v4l_output; // nullptr if not using V4L2 output.
static constexpr int initial_qp = 15;
static constexpr int minimal_qp = 0;
static constexpr int intra_period = 30;
static constexpr int initial_qp = 15;
static constexpr int minimal_qp = 0;
static constexpr int intra_period = 30;