LCOV - code coverage report
Current view: top level - Codec - EbEncodeContext.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 67 68 98.5 %
Date: 2019-11-25 17:38:06 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             : * Copyright(c) 2019 Intel Corporation
       3             : * SPDX - License - Identifier: BSD - 2 - Clause - Patent
       4             : */
       5             : 
       6             : #include <stdlib.h>
       7             : 
       8             : #include "EbDefinitions.h"
       9             : #include "EbEncodeContext.h"
      10             : #include "EbPictureManagerQueue.h"
      11             : #include "EbCabacContextModel.h"
      12             : #include "EbSvtAv1ErrorCodes.h"
      13             : 
      14           2 : static void encode_context_dctor(EbPtr p)
      15             : {
      16           2 :     EncodeContext* obj = (EncodeContext*)p;
      17           2 :     EB_DESTROY_MUTEX(obj->total_number_of_recon_frame_mutex);
      18           2 :     EB_DESTROY_MUTEX(obj->hl_rate_control_historgram_queue_mutex);
      19           2 :     EB_DESTROY_MUTEX(obj->rate_table_update_mutex);
      20           2 :     EB_DESTROY_MUTEX(obj->sc_buffer_mutex);
      21           2 :     EB_DESTROY_MUTEX(obj->shared_reference_mutex);
      22             : #if TWO_PASS
      23           2 :     EB_DESTROY_MUTEX(obj->stat_file_mutex);
      24             : #endif
      25             : 
      26           2 :     EB_DELETE(obj->prediction_structure_group_ptr);
      27        4098 :     EB_DELETE_PTR_ARRAY(obj->picture_decision_reorder_queue, PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH);
      28        4098 :     EB_DELETE_PTR_ARRAY(obj->picture_manager_reorder_queue, PICTURE_MANAGER_REORDER_QUEUE_MAX_DEPTH);
      29           2 :     EB_FREE(obj->pre_assignment_buffer);
      30       10002 :     EB_DELETE_PTR_ARRAY(obj->input_picture_queue, INPUT_QUEUE_MAX_DEPTH);
      31       10002 :     EB_DELETE_PTR_ARRAY(obj->reference_picture_queue, REFERENCE_QUEUE_MAX_DEPTH);
      32       10002 :     EB_DELETE_PTR_ARRAY(obj->picture_decision_pa_reference_queue, PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH);
      33        4098 :     EB_DELETE_PTR_ARRAY(obj->initial_rate_control_reorder_queue, INITIAL_RATE_CONTROL_REORDER_QUEUE_MAX_DEPTH);
      34        4098 :     EB_DELETE_PTR_ARRAY(obj->hl_rate_control_historgram_queue, HIGH_LEVEL_RATE_CONTROL_HISTOGRAM_QUEUE_MAX_DEPTH);
      35        4098 :     EB_DELETE_PTR_ARRAY(obj->packetization_reorder_queue, PACKETIZATION_REORDER_QUEUE_MAX_DEPTH);
      36           2 :     EB_FREE_ARRAY(obj->rate_control_tables_array);
      37           2 : }
      38             : 
      39           2 : EbErrorType encode_context_ctor(
      40             :     EncodeContext *encode_context_ptr,
      41             :     EbPtr object_init_data_ptr)
      42             : {
      43             :     uint32_t pictureIndex;
      44           2 :     EbErrorType return_error = EB_ErrorNone;
      45             : 
      46           2 :     encode_context_ptr->dctor = encode_context_dctor;
      47             : 
      48           2 :     object_init_data_ptr = 0;
      49           2 :     CHECK_REPORT_ERROR(
      50             :         (object_init_data_ptr == 0),
      51             :         encode_context_ptr->app_callback_ptr,
      52             :         EB_ENC_EC_ERROR29);
      53             : 
      54           2 :     EB_CREATE_MUTEX(encode_context_ptr->total_number_of_recon_frame_mutex);
      55           2 :     EB_ALLOC_PTR_ARRAY(encode_context_ptr->picture_decision_reorder_queue, PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH);
      56             : 
      57        4098 :     for (pictureIndex = 0; pictureIndex < PICTURE_DECISION_REORDER_QUEUE_MAX_DEPTH; ++pictureIndex) {
      58        4096 :         EB_NEW(encode_context_ptr->picture_decision_reorder_queue[pictureIndex],
      59             :             picture_decision_reorder_entry_ctor,
      60             :             pictureIndex);
      61             :     }
      62             : 
      63           2 :     EB_ALLOC_PTR_ARRAY(encode_context_ptr->picture_manager_reorder_queue,  PICTURE_MANAGER_REORDER_QUEUE_MAX_DEPTH);
      64             : 
      65        4098 :     for (pictureIndex = 0; pictureIndex < PICTURE_MANAGER_REORDER_QUEUE_MAX_DEPTH; ++pictureIndex) {
      66        4096 :         EB_NEW(encode_context_ptr->picture_manager_reorder_queue[pictureIndex], picture_manager_reorder_entry_ctor, pictureIndex);
      67             :     }
      68             : 
      69           2 :     EB_ALLOC_PTR_ARRAY(encode_context_ptr->pre_assignment_buffer, PRE_ASSIGNMENT_MAX_DEPTH);
      70             : 
      71           2 :     EB_ALLOC_PTR_ARRAY(encode_context_ptr->input_picture_queue, INPUT_QUEUE_MAX_DEPTH);
      72             : 
      73       10002 :     for (pictureIndex = 0; pictureIndex < INPUT_QUEUE_MAX_DEPTH; ++pictureIndex) {
      74       10000 :          EB_NEW(encode_context_ptr->input_picture_queue[pictureIndex], input_queue_entry_ctor);
      75             :     }
      76             : 
      77           2 :     EB_ALLOC_PTR_ARRAY(encode_context_ptr->reference_picture_queue, REFERENCE_QUEUE_MAX_DEPTH);
      78             : 
      79       10002 :     for (pictureIndex = 0; pictureIndex < REFERENCE_QUEUE_MAX_DEPTH; ++pictureIndex) {
      80       10000 :         EB_NEW(encode_context_ptr->reference_picture_queue[pictureIndex], reference_queue_entry_ctor);
      81             :     }
      82             : 
      83           2 :     EB_ALLOC_PTR_ARRAY(encode_context_ptr->picture_decision_pa_reference_queue, PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH);
      84             : 
      85       10002 :     for (pictureIndex = 0; pictureIndex < PICTURE_DECISION_PA_REFERENCE_QUEUE_MAX_DEPTH; ++pictureIndex) {
      86       10000 :         EB_NEW(encode_context_ptr->picture_decision_pa_reference_queue[pictureIndex], pa_reference_queue_entry_ctor);
      87             :     }
      88             : 
      89           2 :     EB_ALLOC_PTR_ARRAY(encode_context_ptr->initial_rate_control_reorder_queue, INITIAL_RATE_CONTROL_REORDER_QUEUE_MAX_DEPTH);
      90             : 
      91        4098 :     for (pictureIndex = 0; pictureIndex < INITIAL_RATE_CONTROL_REORDER_QUEUE_MAX_DEPTH; ++pictureIndex) {
      92        4096 :         EB_NEW(encode_context_ptr->initial_rate_control_reorder_queue[pictureIndex],
      93             :             initial_rate_control_reorder_entry_ctor,
      94             :             pictureIndex);
      95             :     }
      96             : 
      97           2 :     EB_ALLOC_PTR_ARRAY(encode_context_ptr->hl_rate_control_historgram_queue, HIGH_LEVEL_RATE_CONTROL_HISTOGRAM_QUEUE_MAX_DEPTH);
      98             : 
      99        4098 :     for (pictureIndex = 0; pictureIndex < HIGH_LEVEL_RATE_CONTROL_HISTOGRAM_QUEUE_MAX_DEPTH; ++pictureIndex) {
     100        4096 :         EB_NEW(encode_context_ptr->hl_rate_control_historgram_queue[pictureIndex],
     101             :             hl_rate_control_histogram_entry_ctor,
     102             :             pictureIndex);
     103             :     }
     104             :     // HLRateControl Historgram Queue Mutex
     105           2 :     EB_CREATE_MUTEX(encode_context_ptr->hl_rate_control_historgram_queue_mutex);
     106             : 
     107           2 :     EB_ALLOC_PTR_ARRAY(encode_context_ptr->packetization_reorder_queue, PACKETIZATION_REORDER_QUEUE_MAX_DEPTH);
     108             : 
     109        4098 :     for (pictureIndex = 0; pictureIndex < PACKETIZATION_REORDER_QUEUE_MAX_DEPTH; ++pictureIndex) {
     110        4096 :         EB_NEW(encode_context_ptr->packetization_reorder_queue[pictureIndex],
     111             :             packetization_reorder_entry_ctor,
     112             :             pictureIndex);
     113             :     }
     114             : 
     115           2 :     encode_context_ptr->current_input_poc = -1;
     116           2 :     encode_context_ptr->initial_picture = EB_TRUE;
     117             : 
     118             :     // Sequence Termination Flags
     119           2 :     encode_context_ptr->terminating_picture_number = ~0u;
     120             : 
     121             :     // Signalling the need for a td structure to be written in the bitstream - on when the sequence starts
     122           2 :     encode_context_ptr->td_needed = EB_TRUE;
     123             : 
     124             :     // Rate Control Bit Tables
     125           2 :     EB_MALLOC_ARRAY(encode_context_ptr->rate_control_tables_array, TOTAL_NUMBER_OF_INITIAL_RC_TABLES_ENTRY);
     126             : 
     127           2 :     return_error = rate_control_tables_init(encode_context_ptr->rate_control_tables_array);
     128           2 :     if (return_error == EB_ErrorInsufficientResources)
     129           0 :         return EB_ErrorInsufficientResources;
     130             :     // RC Rate Table Update Mutex
     131           2 :     EB_CREATE_MUTEX(encode_context_ptr->rate_table_update_mutex);
     132             : 
     133           2 :     EB_CREATE_MUTEX(encode_context_ptr->sc_buffer_mutex);
     134           2 :     encode_context_ptr->enc_mode                      = SPEED_CONTROL_INIT_MOD;
     135           2 :     encode_context_ptr->previous_selected_ref_qp      = 32;
     136           2 :     encode_context_ptr->max_coded_poc_selected_ref_qp = 32;
     137             : 
     138           2 :     EB_CREATE_MUTEX(encode_context_ptr->shared_reference_mutex);
     139             : #if TWO_PASS
     140           2 :     EB_CREATE_MUTEX(encode_context_ptr->stat_file_mutex);
     141             : #endif
     142           2 :     return EB_ErrorNone;
     143             : }

Generated by: LCOV version 1.14