@@ -77,8 +77,7 @@ struct state_video_compress_oapv {
7777 oapv_bitb_t bitb{}; // bitstream buffer (output)
7878 oapve_stat_t stat{}; // encoding status (output)
7979
80- oapv_frms_t input_frm{}; // frame for input
81- oapv_imgb_t *imgb = nullptr ; // planar pixel data of input frame
80+ Oapv_Frames input_frms; // frame for input
8281
8382 video_desc saved_desc{}; // last configured video description
8483
@@ -89,7 +88,6 @@ struct state_video_compress_oapv {
8988};
9089
9190state_video_compress_oapv::~state_video_compress_oapv () {
92- ug_oapv_imgb_free (imgb);
9391 free (bitb.addr );
9492}
9593
@@ -296,16 +294,14 @@ bool configure_with(state_video_compress_oapv *s, video_desc desc){
296294
297295 s->cdsc .param [FRM_INDEX ].profile_idc = map_color_spaces_to_profiles (conv_struct->dst_color_format );
298296
299- s->imgb = create_oapv_imgb (desc.width , desc.height , conv_struct->dst_color_format );
300- if (!s->imgb ){
297+ if (!s->input_frms .configure_with (desc.width , desc.height , conv_struct->dst_color_format )){
301298 log_msg (LOG_LEVEL_ERROR , MOD_NAME " Failed to set up input buffer\n " );
302299 return false ;
303300 }
304- s->input_frm .frm [FRM_INDEX ].imgb = s->imgb ;
305301
306302 int raw_bytes = 0 ;
307- for (int i = 0 ; i < s->imgb ->np ; i++) {
308- raw_bytes += s->imgb ->bsize [i];
303+ for (int i = 0 ; i < s->input_frms . get_primary ()-> imgb ->np ; i++) {
304+ raw_bytes += s->input_frms . get_primary ()-> imgb ->bsize [i];
309305 }
310306 // allocate bitstream buffer with size based on raw input size * 2 for safe upper bound
311307 const int new_buf_size = raw_bytes * 2 ;
@@ -365,10 +361,10 @@ shared_ptr<video_frame> openapv_compress_tile(void *state, shared_ptr<video_fram
365361 }
366362
367363 struct tile *in_tile = vf_get_tile (tile.get (), 0 );
368- s->convert_to_planar ((const uint8_t *) in_tile->data , desc.width , desc.height , s->imgb );
364+ s->convert_to_planar ((const uint8_t *) in_tile->data , desc.width , desc.height , s->input_frms . get_primary ()-> imgb );
369365
370366 s->bitb .ssize = 0 ;
371- int ret = oapve_encode (s->enc_h .get (), & s->input_frm , nullptr , &s->bitb , &s->stat , nullptr );
367+ int ret = oapve_encode (s->enc_h .get (), s->input_frms . get_frms () , nullptr , &s->bitb , &s->stat , nullptr );
372368 if (OAPV_FAILED (ret)) {
373369 MSG (ERROR , " oapve_encode failed: %s (%d) (frame dropped)\n " , oapv_err_str (ret), ret);
374370 return {};
@@ -414,11 +410,6 @@ void* openapv_compress_init(module */*parent*/, const char *opts) {
414410
415411 s->cdsc.max_num_frms = MAX_NUM_FRMS ;
416412
417- s->input_frm.num_frms = MAX_NUM_FRMS ;
418- s->input_frm.frm[FRM_INDEX ].pbu_type = OAPV_PBU_TYPE_PRIMARY_FRAME ;
419- s->input_frm.frm[FRM_INDEX ].group_id = 1 ;
420- s->input_frm.frm[FRM_INDEX ].imgb = s->imgb;
421-
422413 if (opts && opts[0 ] != ' \0 ' ) {
423414 char *fmt = strdup (opts);
424415 if (!s->parse_fmt (fmt)) {
0 commit comments