MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / adjust_frame_rate

Function adjust_frame_rate

libhb/vfr.c:201–352  ·  view source on GitHub ↗

This section of the code implements video frame rate control. Since filters are allowed to duplicate and drop frames (which changes the timing), this has to be the last thing done in render. There are three options, selected by the value of cfr: 0 - Variable Frame Rate (VFR) or 'same as source': frame times are left alone 1 - Constant Frame Rate (CFR): Frame timings are adjusted so that all frame

Source from the content-addressed store, hash-verified

199// times are left alone.
200//
201static hb_buffer_t * adjust_frame_rate( hb_filter_private_t * pv,
202 hb_buffer_t * in )
203{
204
205 if (pv->cfr == 0)
206 {
207 if (in)
208 {
209 ++pv->count_frames;
210 pv->out_last_stop = in->s.stop;
211 }
212 return in;
213 }
214
215 int count;
216
217 // in == NULL signals we are flushing the frame_rate_list
218 if (in != NULL)
219 {
220 if (pv->out_last_stop == (int64_t)AV_NOPTS_VALUE)
221 {
222 pv->out_last_stop = in->s.start;
223 }
224
225#if defined(HB_DEBUG_CFR_DROPS)
226 in->s.pcr = pv->sequence++;
227#endif
228 hb_list_add(pv->frame_rate_list, in);
229 count = hb_list_count(pv->frame_rate_list);
230 if (count < 2)
231 {
232 return NULL;
233 }
234
235 hb_buffer_t * penultimate, * ultimate;
236 penultimate = hb_list_item(pv->frame_rate_list, count - 2);
237 ultimate = hb_list_item(pv->frame_rate_list, count - 1);
238
239 pv->frame_metric[count - 1] = pv->metric->work(pv->metric, penultimate, ultimate);
240
241 if (count < pv->frame_analysis_depth)
242 {
243 return NULL;
244 }
245 }
246 else
247 {
248 count = hb_list_count(pv->frame_rate_list);
249 }
250
251 hb_buffer_list_t list;
252 hb_buffer_t * out;
253 double cfr_stop;
254 int drop_frame;
255
256 hb_buffer_list_clear(&list);
257
258 drop_frame = find_drop_frame(pv, count);

Callers 2

flush_framesFunction · 0.85
hb_vfr_workFunction · 0.85

Calls 11

hb_list_addFunction · 0.85
hb_list_countFunction · 0.85
hb_list_itemFunction · 0.85
hb_buffer_list_clearFunction · 0.85
find_drop_frameFunction · 0.85
hb_logFunction · 0.85
hb_list_remFunction · 0.85
hb_buffer_closeFunction · 0.85
delete_metricFunction · 0.85
hb_buffer_list_appendFunction · 0.85
hb_buffer_shallow_dupFunction · 0.85

Tested by

no test coverage detected