xref: /aosp_15_r20/external/libvpx/vp9/vp9_cx_iface.h (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
1 /*
2  *  Copyright (c) 2019 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef VPX_VP9_VP9_CX_IFACE_H_
12 #define VPX_VP9_VP9_CX_IFACE_H_
13 #include "vp9/encoder/vp9_encoder.h"
14 #include "vp9/common/vp9_onyxc_int.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 VP9EncoderConfig vp9_get_encoder_config(int frame_width, int frame_height,
21                                         vpx_rational_t frame_rate,
22                                         int target_bitrate, int encode_speed,
23                                         int target_level,
24                                         vpx_enc_pass enc_pass);
25 
26 void vp9_dump_encoder_config(const VP9EncoderConfig *oxcf, FILE *fp);
27 
28 FRAME_INFO vp9_get_frame_info(const VP9EncoderConfig *oxcf);
29 
30 static INLINE int64_t
timebase_units_to_ticks(const vpx_rational64_t * timestamp_ratio,int64_t n)31 timebase_units_to_ticks(const vpx_rational64_t *timestamp_ratio, int64_t n) {
32   return n * timestamp_ratio->num / timestamp_ratio->den;
33 }
34 
35 static INLINE int64_t
ticks_to_timebase_units(const vpx_rational64_t * timestamp_ratio,int64_t n)36 ticks_to_timebase_units(const vpx_rational64_t *timestamp_ratio, int64_t n) {
37   int64_t round = timestamp_ratio->num / 2;
38   if (round > 0) --round;
39   return (n * timestamp_ratio->den + round) / timestamp_ratio->num;
40 }
41 
42 void vp9_set_first_pass_stats(VP9EncoderConfig *oxcf,
43                               const vpx_fixed_buf_t *stats);
44 
45 #ifdef __cplusplus
46 }  // extern "C"
47 #endif
48 
49 #endif  // VPX_VP9_VP9_CX_IFACE_H_
50