lookahead.h
Go to the documentation of this file.
/*
* Copyright (c) 2016, Alliance for Open Media. All rights reserved.
*
* This source code is subject to the terms of the BSD 2 Clause License and
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
* was not distributed with this source code in the LICENSE file, you can
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
* Media Patent License 1.0 was not distributed with this source code in the
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
#ifndef AOM_AV1_ENCODER_LOOKAHEAD_H_
#define AOM_AV1_ENCODER_LOOKAHEAD_H_
#include <stdbool.h>
#include "aom_scale/yv12config.h"
#include "aom/aom_integer.h"
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_LAG_BUFFERS 48
#define MAX_LAP_BUFFERS 48
#define MAX_TOTAL_BUFFERS (MAX_LAG_BUFFERS + MAX_LAP_BUFFERS)
#define LAP_LAG_IN_FRAMES 17
struct lookahead_entry {
YV12_BUFFER_CONFIG img;
int64_t ts_start;
int64_t ts_end;
int display_idx;
aom_enc_frame_flags_t flags;
};
// The max of past frames we want to keep in the queue.
#define MAX_PRE_FRAMES 1
enum { ENCODE_STAGE, LAP_STAGE, MAX_STAGES } UENUM1BYTE(COMPRESSOR_STAGE);
struct read_ctx {
int sz; /* Number of buffers currently in the queue */
int read_idx; /* Read index */
int pop_sz; /* Size to check for pop condition */
int valid; /* Is this ctx valid? */
};
struct lookahead_ctx {
int max_sz; /* Absolute size of the queue */
int write_idx; /* Write index */
struct read_ctx read_ctxs[MAX_STAGES]; /* Read context */
struct lookahead_entry *buf; /* Buffer list */
int push_frame_count; /* Number of frames that have been pushed in the queue*/
uint8_t
max_pre_frames; /* Maximum number of past frames allowed in the queue */
};
struct lookahead_ctx *av1_lookahead_init(
int width, int height, int subsampling_x, int subsampling_y,
int use_highbitdepth, int depth, int border_in_pixels, int byte_alignment,
int num_lap_buffers, bool is_all_intra, bool alloc_pyramid);
void av1_lookahead_destroy(struct lookahead_ctx *ctx);
int av1_lookahead_full(const struct lookahead_ctx *ctx);
int av1_lookahead_push(struct lookahead_ctx *ctx, const YV12_BUFFER_CONFIG *src,
int64_t ts_start, int64_t ts_end, int use_highbitdepth,
bool alloc_pyramid, aom_enc_frame_flags_t flags);
struct lookahead_entry *av1_lookahead_pop(struct lookahead_ctx *ctx, int drain,
COMPRESSOR_STAGE stage);
struct lookahead_entry *av1_lookahead_peek(struct lookahead_ctx *ctx, int index,
COMPRESSOR_STAGE stage);
int av1_lookahead_depth(struct lookahead_ctx *ctx, COMPRESSOR_STAGE stage);
int av1_lookahead_pop_sz(struct lookahead_ctx *ctx, COMPRESSOR_STAGE stage);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // AOM_AV1_ENCODER_LOOKAHEAD_H_
aom_enc_frame_flags_t
long aom_enc_frame_flags_t
Encoded Frame Flags.
Definition aom_encoder.h:377
av1_lookahead_pop
struct lookahead_entry * av1_lookahead_pop(struct lookahead_ctx *ctx, int drain, COMPRESSOR_STAGE stage)
Get the next source buffer to encode.
av1_lookahead_peek
struct lookahead_entry * av1_lookahead_peek(struct lookahead_ctx *ctx, int index, COMPRESSOR_STAGE stage)
Get a future source buffer to encode.
av1_lookahead_full
int av1_lookahead_full(const struct lookahead_ctx *ctx)
Check if lookahead buffer is full.
av1_lookahead_pop_sz
int av1_lookahead_pop_sz(struct lookahead_ctx *ctx, COMPRESSOR_STAGE stage)
Get pop_sz value.
av1_lookahead_depth
int av1_lookahead_depth(struct lookahead_ctx *ctx, COMPRESSOR_STAGE stage)
Get the number of frames currently in the lookahead queue.
av1_lookahead_push
int av1_lookahead_push(struct lookahead_ctx *ctx, const YV12_BUFFER_CONFIG *src, int64_t ts_start, int64_t ts_end, int use_highbitdepth, bool alloc_pyramid, aom_enc_frame_flags_t flags)
Enqueue a source buffer.
av1_lookahead_init
struct lookahead_ctx * av1_lookahead_init(int width, int height, int subsampling_x, int subsampling_y, int use_highbitdepth, int depth, int border_in_pixels, int byte_alignment, int num_lap_buffers, bool is_all_intra, bool alloc_pyramid)
Initializes the lookahead stage.
av1_lookahead_destroy
void av1_lookahead_destroy(struct lookahead_ctx *ctx)
Destroys the lookahead stage.