#include "defs.h"
#include "timebase.h"
#include "print_latency.h"
+#include "ref_counted_gl_sync.h"
+#include "va_display_with_cleanup.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
};
typedef struct __bitstream bitstream;
+namespace movit {
+class ResourcePool;
+}
+class DiskSpaceEstimator;
+class QSurface;
+class X264Encoder;
+
class QuickSyncEncoderImpl {
public:
QuickSyncEncoderImpl(const std::string &filename, movit::ResourcePool *resource_pool, QSurface *surface, const std::string &va_display, int width, int height, AVOutputFormat *oformat, X264Encoder *x264_encoder, DiskSpaceEstimator *disk_space_estimator);
int build_packed_seq_buffer(movit::YCbCrLumaCoefficients ycbcr_coefficients, unsigned char **header_buffer);
int build_packed_slice_buffer(unsigned char **header_buffer);
int init_va(const std::string &va_display);
- int deinit_va();
void enable_zerocopy_if_possible();
- VADisplay va_open_display(const std::string &va_display);
- void va_close_display(VADisplay va_dpy);
int setup_encode();
void release_encode();
void update_ReferenceFrames(int current_display_frame, int frame_type);
bool is_shutdown = false;
bool has_released_gl_resources = false;
- std::atomic<bool> use_zerocopy;
- int drm_fd = -1;
+ std::atomic<bool> use_zerocopy{false};
std::thread encode_thread, storage_thread;
std::map<int, PendingFrame> reorder_buffer;
int quicksync_encoding_frame_num = 0;
+ std::mutex file_audio_encoder_mutex;
std::unique_ptr<AudioEncoder> file_audio_encoder;
X264Encoder *x264_encoder; // nullptr if not using x264.
Mux* stream_mux = nullptr; // To HTTP.
std::unique_ptr<Mux> file_mux; // To local disk.
- Display *x11_display = nullptr;
-
// Encoder parameters
- VADisplay va_dpy;
+ std::unique_ptr<VADisplayWithCleanup> va_dpy;
VAProfile h264_profile = (VAProfile)~0;
VAConfigAttrib config_attrib[VAConfigAttribTypeMax];
int config_attrib_num = 0, enc_packed_header_idx;
int h264_entropy_mode = 1; /* cabac */
int ip_period = 3;
- int rc_mode = -1;
unsigned int current_ref_frame_num = 0; // Encoding frame order within this GOP, sans B-frames.
int frame_width;