@@ -67,14 +67,14 @@ using oapve_uniq = std::unique_ptr<std::remove_pointer_t<oapve_t>, deleter_from_
6767
6868struct state_video_compress_oapv {
6969 state_video_compress_oapv () = default ;
70- ~state_video_compress_oapv ();
7170
7271 bool parse_fmt (char *fmt);
7372
7473 oapve_uniq enc_h; // OAPV encoder handle
7574 oapve_cdesc_t cdsc{}; // description used for encoder creation (params, threads, …)
7675
7776 oapv_bitb_t bitb{}; // bitstream buffer (output)
77+ std::vector<char > bitb_data;
7878 oapve_stat_t stat{}; // encoding status (output)
7979
8080 Oapv_Frames input_frms; // frame for input
@@ -87,10 +87,6 @@ struct state_video_compress_oapv {
8787 uv_to_openapv_conversion_f convert_to_planar = nullptr ;
8888};
8989
90- state_video_compress_oapv::~state_video_compress_oapv () {
91- free (bitb.addr );
92- }
93-
9490int map_color_spaces_to_profiles (int cs) {
9591 switch (cs) {
9692 case OAPV_CS_YCBCR4444_10LE :
@@ -306,16 +302,10 @@ bool configure_with(state_video_compress_oapv *s, video_desc desc){
306302 // allocate bitstream buffer with size based on raw input size * 2 for safe upper bound
307303 const int new_buf_size = raw_bytes * 2 ;
308304
309- if (new_buf_size != s->cdsc .max_bs_buf_size || s->bitb .addr == nullptr ) {
310- free (s->bitb .addr );
311- s->bitb .addr = malloc (new_buf_size);
312- if (s->bitb .addr == nullptr ) {
313- log_msg (LOG_LEVEL_ERROR , MOD_NAME " Failed to allocate bitstream buffer (%d bytes)\n " , new_buf_size);
314- return false ;
315- }
316- s->bitb .bsize = new_buf_size;
317- s->cdsc .max_bs_buf_size = new_buf_size;
318- }
305+ s->bitb_data .resize (new_buf_size);
306+ s->bitb .addr = s->bitb_data .data ();
307+ s->bitb .bsize = new_buf_size;
308+ s->cdsc .max_bs_buf_size = new_buf_size;
319309
320310 s->enc_h .reset ();
321311 int ret;
0 commit comments