MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / alloc_frame

Function alloc_frame

libavcodec/vvc/refs.c:122–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122static VVCFrame *alloc_frame(VVCContext *s, VVCFrameContext *fc)
123{
124 const VVCSPS *sps = fc->ps.sps;
125 const VVCPPS *pps = fc->ps.pps;
126 for (int i = 0; i < FF_ARRAY_ELEMS(fc->DPB); i++) {
127 int ret;
128 VVCFrame *frame = &fc->DPB[i];
129 VVCWindow *win = &frame->scaling_win;
130 if (frame->frame->buf[0])
131 continue;
132
133 frame->sps = av_refstruct_ref_c(fc->ps.sps);
134 frame->pps = av_refstruct_ref_c(fc->ps.pps);
135
136 // Add LCEVC SEI metadata here, as it's needed in get_buffer()
137 if (fc->sei.common.lcevc.info) {
138 HEVCSEILCEVC *lcevc = &fc->sei.common.lcevc;
139 ret = ff_frame_new_side_data_from_buf(s->avctx, frame->frame,
140 AV_FRAME_DATA_LCEVC, &lcevc->info);
141 if (ret < 0)
142 goto fail;
143 }
144
145 ret = ff_thread_get_buffer(s->avctx, frame->frame, AV_GET_BUFFER_FLAG_REF);
146 if (ret < 0)
147 return NULL;
148
149 frame->rpl = av_refstruct_allocz(s->current_frame.nb_units * sizeof(RefPicListTab));
150 if (!frame->rpl)
151 goto fail;
152 frame->nb_rpl_elems = s->current_frame.nb_units;
153
154 frame->tab_dmvr_mvf = av_refstruct_pool_get(fc->tab_dmvr_mvf_pool);
155 if (!frame->tab_dmvr_mvf)
156 goto fail;
157
158 frame->rpl_tab = av_refstruct_pool_get(fc->rpl_tab_pool);
159 if (!frame->rpl_tab)
160 goto fail;
161 frame->ctb_count = pps->ctb_width * pps->ctb_height;
162 for (int j = 0; j < frame->ctb_count; j++)
163 frame->rpl_tab[j] = frame->rpl;
164
165 win->left_offset = pps->r->pps_scaling_win_left_offset * (1 << sps->hshift[CHROMA]);
166 win->right_offset = pps->r->pps_scaling_win_right_offset * (1 << sps->hshift[CHROMA]);
167 win->top_offset = pps->r->pps_scaling_win_top_offset * (1 << sps->vshift[CHROMA]);
168 win->bottom_offset = pps->r->pps_scaling_win_bottom_offset * (1 << sps->vshift[CHROMA]);
169 frame->ref_width = pps->r->pps_pic_width_in_luma_samples - win->left_offset - win->right_offset;
170 frame->ref_height = pps->r->pps_pic_height_in_luma_samples - win->bottom_offset - win->top_offset;
171
172 if (fc->sei.frame_field_info.present) {
173 if (fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD)
174 frame->frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
175 if (fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_TOP_FIELD ||
176 fc->sei.frame_field_info.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD)
177 frame->frame->flags |= AV_FRAME_FLAG_INTERLACED;
178 }
179

Callers 2

ff_vvc_set_new_refFunction · 0.70
generate_missing_refFunction · 0.70

Calls 9

av_refstruct_ref_cFunction · 0.85
av_refstruct_alloczFunction · 0.85
av_refstruct_pool_getFunction · 0.85
alloc_progressFunction · 0.85
ff_vvc_unref_frameFunction · 0.85
av_logFunction · 0.85
ff_thread_get_bufferFunction · 0.50

Tested by

no test coverage detected