AOMedia AV1 Codec
encode_strategy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019, Alliance for Open Media. All rights reserved
3 *
4 * This source code is subject to the terms of the BSD 2 Clause License and
5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 * was not distributed with this source code in the LICENSE file, you can
7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 * Media Patent License 1.0 was not distributed with this source code in the
9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10 */
11
15#ifndef AOM_AV1_ENCODER_ENCODE_STRATEGY_H_
16#define AOM_AV1_ENCODER_ENCODE_STRATEGY_H_
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22#include <stdint.h>
23
24#include "aom/aom_encoder.h"
25
26#include "av1/encoder/encoder.h"
27#include "av1/encoder/firstpass.h"
28
55int av1_encode_strategy(AV1_COMP *const cpi, size_t *const size,
56 uint8_t *const dest, unsigned int *frame_flags,
57 int64_t *const time_stamp, int64_t *const time_end,
58 const aom_rational64_t *const timestamp_ratio,
59 int *const pop_lookahead, int flush);
60
62// Set individual buffer update flags based on frame reference type.
63// force_refresh_all is used when we have a KEY_FRAME or S_FRAME. It forces all
64// refresh_*_frame flags to be set, because we refresh all buffers in this case.
65void av1_configure_buffer_updates(AV1_COMP *const cpi,
66 RefreshFrameInfo *const refresh_frame,
67 const FRAME_UPDATE_TYPE type,
68 const REFBUF_STATE refbuf_state,
69 int force_refresh_all);
70
71int av1_get_refresh_frame_flags(
72 const AV1_COMP *const cpi, const EncodeFrameParams *const frame_params,
73 FRAME_UPDATE_TYPE frame_update_type, int gf_index, int cur_disp_order,
74 RefFrameMapPair ref_frame_map_pairs[REF_FRAMES]);
75
76int av1_get_refresh_ref_frame_map(int refresh_frame_flags);
77
88void av1_get_ref_frames(RefFrameMapPair ref_frame_map_pairs[REF_FRAMES],
89 int cur_frame_disp, const AV1_COMP *cpi, int gf_index,
90 int is_parallel_encode,
91 int remapped_ref_idx[REF_FRAMES]);
92
93int is_forced_keyframe_pending(struct lookahead_ctx *lookahead,
94 const int up_to_index,
95 const COMPRESSOR_STAGE compressor_stage);
96
97static AOM_INLINE int is_frame_droppable(
98 const RTC_REF *const rtc_ref,
99 const ExtRefreshFrameFlagsInfo *const ext_refresh_frame_flags) {
100 // Droppable frame is only used by external refresh flags. VoD setting won't
101 // trigger its use case.
102 if (rtc_ref->set_ref_frame_config)
103 return rtc_ref->non_reference_frame;
104 else if (ext_refresh_frame_flags->update_pending)
105 return !(ext_refresh_frame_flags->alt_ref_frame ||
106 ext_refresh_frame_flags->alt2_ref_frame ||
107 ext_refresh_frame_flags->bwd_ref_frame ||
108 ext_refresh_frame_flags->golden_frame ||
109 ext_refresh_frame_flags->last_frame);
110 else
111 return 0;
112}
113
114static AOM_INLINE int get_current_frame_ref_type(const AV1_COMP *const cpi) {
115 // We choose the reference "type" of this frame from the flags which indicate
116 // which reference frames will be refreshed by it. More than one of these
117 // flags may be set, so the order here implies an order of precedence. This is
118 // just used to choose the primary_ref_frame (as the most recent reference
119 // buffer of the same reference-type as the current frame).
120
121 switch (cpi->ppi->gf_group.layer_depth[cpi->gf_frame_index]) {
122 case 0: return 0;
123 case 1: return 1;
124 case MAX_ARF_LAYERS:
125 case MAX_ARF_LAYERS + 1: return 4;
126 default: return 7;
127 }
128}
129
130int av1_calc_refresh_idx_for_intnl_arf(
131 AV1_COMP *cpi, RefFrameMapPair ref_frame_map_pairs[REF_FRAMES],
132 int gf_index);
134#ifdef __cplusplus
135} // extern "C"
136#endif
137
138#endif // AOM_AV1_ENCODER_ENCODE_STRATEGY_H_
Describes the encoder algorithm interface to applications.
Declares top-level encoder structures and functions.
int av1_encode_strategy(AV1_COMP *const cpi, size_t *const size, uint8_t *const dest, unsigned int *frame_flags, int64_t *const time_stamp, int64_t *const time_end, const aom_rational64_t *const timestamp_ratio, int *const pop_lookahead, int flush)
Implement high-level encode strategy.
Definition encode_strategy.c:1229
Top level encoder structure.
Definition encoder.h:2866
unsigned char gf_frame_index
Definition encoder.h:3124
AV1_PRIMARY * ppi
Definition encoder.h:2870
GF_GROUP gf_group
Definition encoder.h:2686
contains per-frame encoding parameters decided upon by av1_encode_strategy() and passed down to av1_e...
Definition encoder.h:3680
Frame refresh flags set by the external interface.
Definition encoder.h:2251
bool golden_frame
Definition encoder.h:2253
bool bwd_ref_frame
Definition encoder.h:2254
bool update_pending
Definition encoder.h:2260
bool last_frame
Definition encoder.h:2252
bool alt_ref_frame
Definition encoder.h:2256
bool alt2_ref_frame
Definition encoder.h:2255
Refresh frame flags for different type of frames.
Definition encoder.h:2147