56 if (
frame->needs_fg) {
68 frame->nb_rpl_elems = 0;
78 const int x_cb = x0 >>
fc->ps.sps->ctb_log2_size_y;
79 const int y_cb = y0 >>
fc->ps.sps->ctb_log2_size_y;
80 const int pic_width_cb =
fc->ps.pps->ctb_width;
81 const int ctb_addr_rs = y_cb * pic_width_cb + x_cb;
116 if (!p->has_lock || !p->has_cond)
130 if (
frame->frame->buf[0])
137 if (
fc->sei.common.itut_t35.lcevc) {
151 frame->nb_rpl_elems =
s->current_frame.nb_units;
154 if (!
frame->tab_dmvr_mvf)
160 frame->ctb_count =
pps->ctb_width *
pps->ctb_height;
161 for (
int j = 0; j <
frame->ctb_count; j++)
164 win->left_offset =
pps->r->pps_scaling_win_left_offset * (1 <<
sps->hshift[
CHROMA]);
165 win->right_offset =
pps->r->pps_scaling_win_right_offset * (1 <<
sps->hshift[
CHROMA]);
166 win->top_offset =
pps->r->pps_scaling_win_top_offset * (1 <<
sps->vshift[
CHROMA]);
167 win->bottom_offset =
pps->r->pps_scaling_win_bottom_offset * (1 <<
sps->vshift[
CHROMA]);
168 frame->ref_width =
pps->r->pps_pic_width_in_luma_samples -
win->left_offset -
win->right_offset;
169 frame->ref_height =
pps->r->pps_pic_height_in_luma_samples -
win->bottom_offset -
win->top_offset;
171 if (
fc->sei.frame_field_info.present) {
180 if (!
frame->progress)
198 bool has_b =
false, has_inter =
false;
206 if (
fc->ps.ph.r->ph_inter_slice_allowed_flag) {
209 for (
int i = 0;
i <
current->nb_units && !has_b;
i++) {
213 has_inter |= !
IS_I(rsh);
229 const int poc =
ph->poc;
236 if (
frame->frame->buf[0] &&
frame->sequence ==
s->seq_decode &&
253 else if (
ph->r->ph_pic_output_flag)
256 if (!
ph->r->ph_non_ref_pic_flag)
260 ref->sequence =
s->seq_decode;
261 ref->frame->crop_left =
fc->ps.pps->r->pps_conf_win_left_offset <<
fc->ps.sps->hshift[
CHROMA];
262 ref->frame->crop_right =
fc->ps.pps->r->pps_conf_win_right_offset <<
fc->ps.sps->hshift[
CHROMA];
263 ref->frame->crop_top =
fc->ps.pps->r->pps_conf_win_top_offset <<
fc->ps.sps->vshift[
CHROMA];
264 ref->frame->crop_bottom =
fc->ps.pps->r->pps_conf_win_bottom_offset <<
fc->ps.sps->vshift[
CHROMA];
274 int min_poc = INT_MAX;
277 if (no_output_of_prior_pics_flag) {
281 frame->sequence ==
s->seq_output) {
290 frame->sequence ==
s->seq_output) {
292 if (
frame->poc < min_poc || nb_output == 1) {
293 min_poc =
frame->poc;
300 if (!
flush &&
s->seq_output ==
s->seq_decode &&
sps &&
301 nb_output <= sps->
r->sps_dpb_params.dpb_max_num_reorder_pics[
sps->r->sps_max_sublayers_minus1])
324 "Output frame with POC %d.\n",
frame->poc);
328 if (
s->seq_output !=
s->seq_decode)
329 s->seq_output = (
s->seq_output + 1) & 0xff;
339 const int poc =
fc->ps.ph.poc;
341 int min_poc = INT_MAX;
345 if ((
frame->flags) &&
346 frame->sequence ==
s->seq_output &&
352 if (
sps && dpb >=
sps->r->sps_dpb_params.dpb_max_dec_pic_buffering_minus1[
sps->r->sps_max_sublayers_minus1] + 1) {
355 if ((
frame->flags) &&
356 frame->sequence ==
s->seq_output &&
359 min_poc =
frame->poc;
367 frame->sequence ==
s->seq_output &&
368 frame->poc <= min_poc) {
379 const unsigned mask = use_msb ? ~0 :
fc->ps.sps->max_pic_order_cnt_lsb - 1;
383 if (
ref->frame->buf[0] &&
ref->sequence ==
s->seq_decode) {
407 if (!
s->avctx->hwaccel) {
408 if (!
sps->pixel_shift) {
409 for (
int i = 0;
frame->frame->buf[
i];
i++)
410 memset(
frame->frame->buf[
i]->data, 1 << (
sps->bit_depth - 1),
411 frame->frame->buf[
i]->size);
413 for (
int i = 0;
frame->frame->data[
i];
i++)
414 for (
int y = 0; y < (
pps->height >>
sps->vshift[
i]); y++) {
423 frame->sequence =
s->seq_decode;
431#define CHECK_MAX(d) (frame->ref_##d * frame->sps->r->sps_pic_##d##_max_in_luma_samples >= ref->ref_##d * (frame->pps->r->pps_pic_##d##_in_luma_samples - max))
432#define CHECK_SAMPLES(d) (frame->pps->r->pps_pic_##d##_in_luma_samples == ref->pps->r->pps_pic_##d##_in_luma_samples)
439 return frame->ref_width * 2 >=
ref->ref_width &&
440 frame->ref_height * 2 >=
ref->ref_height &&
441 frame->ref_width <=
ref->ref_width * 8 &&
442 frame->ref_height <=
ref->ref_height * 8 &&
448#define RPR_SCALE(f) (((ref->f << 14) + (fc->ref->f >> 1)) / fc->ref->f)
451 int poc,
int ref_flag, uint8_t use_msb)
461 const bool recovering =
s->no_output_before_recovery_flag &&
464 if (ref_corrupt && !recovering) {
482 refp->
is_scaled =
ref->sps->r->sps_num_subpics_minus1 !=
fc->ref->sps->r->sps_num_subpics_minus1||
483 memcmp(&
ref->scaling_win, &
fc->ref->scaling_win,
sizeof(
ref->scaling_win)) ||
484 ref->pps->r->pps_pic_width_in_luma_samples !=
fc->ref->pps->r->pps_pic_width_in_luma_samples ||
485 ref->pps->r->pps_pic_height_in_luma_samples !=
fc->ref->pps->r->pps_pic_height_in_luma_samples;
522 if (!((
sps->r->sps_weighted_pred_flag ||
523 sps->r->sps_weighted_bipred_flag) &&
i != 0))
529 const int lx,
const int j,
const int max_poc_lsb)
536 lt_poc += poc -
delta * max_poc_lsb - (poc & (max_poc_lsb - 1));
537 *prev_delta_poc_msb =
delta;
548 const int max_poc_lsb =
sps->max_pic_order_cnt_lsb;
557 for (
int lx =
L0; lx <=
L1; lx++) {
560 int poc_base =
ph->poc;
561 int prev_delta_poc_msb = 0;
575 poc =
poc_lt(&prev_delta_poc_msb,
ph->poc, ref_lists, lx, j, max_poc_lsb);
589 if (
ph->r->ph_temporal_mvp_enabled_flag &&
595 fc->ref->collocated_ref = refp->
ref;
633 return p->progress[l->
vp] > l->
y;
659 prev = &(*prev)->
next;
671 if (p->progress[vp] < y) {
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static float win(SuperEqualizerContext *s, float n, int N)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
static const uint16_t fc[]
int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef **buf)
Similar to ff_frame_new_side_data, but using an existing buffer ref.
int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it.
void(* flush)(AVBSFContext *ctx)
static struct @111144215057303131116103221376075045141373005341 current
#define AV_CODEC_FLAG2_SHOW_ALL
Show all frames before the first keyframe.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN
Decoding only.
#define AV_CODEC_FLAG_OUTPUT_CORRUPT
Output even those frames that might be corrupted.
@ AV_PICTURE_STRUCTURE_BOTTOM_FIELD
coded as bottom field
@ AV_PICTURE_STRUCTURE_TOP_FIELD
coded as top field
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
#define AV_FRAME_FLAG_CORRUPT
The frame data may be corrupted, e.g.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
@ AV_FRAME_DATA_LCEVC
Raw LCEVC payload data, as a uint8_t array, with NAL emulation bytes intact.
@ AV_FRAME_DATA_FILM_GRAIN_PARAMS
Film grain parameters for a frame, described by AVFilmGrainParams.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
static HEVCFrame * find_ref_idx(HEVCContext *s, HEVCLayerContext *l, int poc, uint8_t use_msb)
static int add_candidate_ref(HEVCContext *s, HEVCLayerContext *l, RefPicList *rps, int list_idx, int poc, int ref_flag, uint8_t use_msb)
static void mark_ref(HEVCFrame *frame, int flag)
static HEVCFrame * alloc_frame(HEVCContext *s, HEVCLayerContext *l)
static int init_slice_rpl(HEVCContext *s)
static HEVCFrame * generate_missing_ref(HEVCContext *s, HEVCLayerContext *l, int poc)
Multithreading API for decoders.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static int ff_mutex_unlock(AVMutex *mutex)
static int ff_cond_destroy(AVCond *cond)
static int ff_mutex_lock(AVMutex *mutex)
static int ff_mutex_destroy(AVMutex *mutex)
static int ff_cond_init(AVCond *cond, const void *attr)
static int ff_cond_signal(AVCond *cond)
static int ff_mutex_init(AVMutex *mutex, const void *attr)
static const uint16_t mask[17]
Memory handling functions.
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
#define VVC_FRAME_FLAG_OUTPUT
#define VVC_FRAME_FLAG_BUMPING
#define VVC_FRAME_FLAG_SHORT_REF
#define VVC_FRAME_FLAG_CORRUPT
#define VVC_FRAME_FLAG_LONG_REF
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
const void * av_refstruct_ref_c(const void *obj)
Analog of av_refstruct_ref(), but for constant objects.
void * av_refstruct_pool_get(AVRefStructPool *pool)
Get an object from the pool, reusing an old one from the pool when available.
static void * av_refstruct_allocz(size_t size)
Equivalent to av_refstruct_alloc_ext(size, 0, NULL, NULL)
static void * av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj))
A wrapper around av_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
#define FF_ARRAY_ELEMS(a)
This structure describes decoded (raw) audio or video data.
Coded bitstream fragment structure, combining one or more units.
Coded bitstream unit structure.
void * content_ref
If content is reference counted, a RefStruct reference backing content.
CodedBitstreamUnitType type
Codec-specific type of this unit.
atomic_int progress[VVC_PROGRESS_LAST]
VVCProgressListener * listener[VVC_PROGRESS_LAST]
uint8_t abs_delta_poc_st[VVC_MAX_REF_ENTRIES]
uint8_t strp_entry_sign_flag[VVC_MAX_REF_ENTRIES]
uint8_t inter_layer_ref_pic_flag[VVC_MAX_REF_ENTRIES]
uint8_t rpls_poc_lsb_lt[VVC_MAX_REF_ENTRIES]
uint8_t st_ref_pic_flag[VVC_MAX_REF_ENTRIES]
uint8_t ltrp_in_header_flag
uint8_t delta_poc_msb_cycle_present_flag[2][VVC_MAX_REF_ENTRIES]
uint16_t delta_poc_msb_cycle_lt[2][VVC_MAX_REF_ENTRIES]
H266RefPicListStruct rpl_ref_list[2]
uint16_t poc_lsb_lt[2][VVC_MAX_REF_ENTRIES]
VVCRefPic refs[VVC_MAX_REF_ENTRIES]
const VVCSPS * sps
RefStruct reference.
VVCProgressListener * next
progress_done_fn progress_done
int scale[2]
RefPicScale[].
int is_scaled
RprConstraintsActiveFlag.
const H266RawSliceHeader * r
RefStruct reference.
const uint32_t * ctb_addr_in_curr_slice
CtbAddrInCurrSlice.
uint32_t num_ctus_in_curr_slice
NumCtusInCurrSlice.
uint8_t ctb_log2_size_y
CtbLog2SizeY.
static int ref[MAX_W *MAX_W]
RefStruct is an API for creating reference-counted objects with minimal overhead.
#define GDR_IS_RECOVERED(s)
void ff_vvc_add_progress_listener(VVCFrame *frame, VVCProgressListener *l)
void ff_vvc_clear_refs(VVCFrameContext *fc)
static FrameProgress * alloc_progress(void)
const RefPicList * ff_vvc_get_ref_list(const VVCFrameContext *fc, const VVCFrame *ref, int x0, int y0)
int ff_vvc_frame_rpl(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
void ff_vvc_unref_frame(VVCFrameContext *fc, VVCFrame *frame, int flags)
void ff_vvc_bump_frame(VVCContext *s, VVCFrameContext *fc)
void ff_vvc_report_frame_finished(VVCFrame *frame)
void ff_vvc_report_progress(VVCFrame *frame, const VVCProgress vp, const int y)
static void free_progress(AVRefStructOpaque unused, void *obj)
int ff_vvc_output_frame(VVCContext *s, VVCFrameContext *fc, AVFrame *out, const int no_output_of_prior_pics_flag, int flush)
int ff_vvc_slice_rpl(VVCContext *s, VVCFrameContext *fc, SliceContext *sc)
static VVCProgressListener * get_done_listener(FrameProgress *p, const VVCProgress vp)
int ff_vvc_set_new_ref(VVCContext *s, VVCFrameContext *fc, AVFrame **frame)
static int check_candidate_ref(const VVCFrame *frame, const VVCRefPic *refp)
static void add_listener(VVCProgressListener **prev, VVCProgressListener *l)
void ff_vvc_flush_dpb(VVCFrameContext *fc)
static void set_pict_type(AVFrame *frame, const VVCContext *s, const VVCFrameContext *fc)
static int delta_poc_st(const H266RefPicListStruct *rpls, const int lx, const int i, const VVCSPS *sps)
static VVCProgressListener * remove_listener(VVCProgressListener **prev, VVCProgressListener *l)
static int poc_lt(int *prev_delta_poc_msb, const int poc, const H266RefPicLists *ref_lists, const int lx, const int j, const int max_poc_lsb)
static int is_progress_done(const FrameProgress *p, const VVCProgressListener *l)