Generate DTS by rearranging PTS in this sequence: pts0 - delay, pts1 - delay, pts2 - delay, pts1, pts2, pts3... Where pts0 - ptsN are in decoded monotonically increasing presentation order and delay == pts1 (1 being the number of frames the decoder must delay before it has sufficient information to decode). The number of frames to delay is set by job->areBframes, so it is configurable. This guara
| 1240 | // |
| 1241 | // This is similar to how x264 generates DTS |
| 1242 | static hb_buffer_t * process_delay_list( hb_work_private_t * pv, hb_buffer_t * buf ) |
| 1243 | { |
| 1244 | if (pv->job->areBframes) |
| 1245 | { |
| 1246 | // Has dts_delay been set yet? |
| 1247 | hb_buffer_list_append(&pv->delay_list, buf); |
| 1248 | if (pv->frameno_in <= pv->job->areBframes) |
| 1249 | { |
| 1250 | // dts_delay not yet set. queue up buffers till it is set. |
| 1251 | return NULL; |
| 1252 | } |
| 1253 | |
| 1254 | // We have dts_delay. Apply it to any queued buffers renderOffset |
| 1255 | // and return all queued buffers. |
| 1256 | buf = hb_buffer_list_head(&pv->delay_list); |
| 1257 | while (buf != NULL) |
| 1258 | { |
| 1259 | // Use the cached frame info to get the start time of Nth frame |
| 1260 | // Note that start Nth frame != start time this buffer since the |
| 1261 | // output buffers have rearranged start times. |
| 1262 | if (pv->frameno_out < pv->job->areBframes) |
| 1263 | { |
| 1264 | int64_t start = get_frame_start( pv, pv->frameno_out ); |
| 1265 | buf->s.renderOffset = start - pv->dts_delay; |
| 1266 | } |
| 1267 | else |
| 1268 | { |
| 1269 | buf->s.renderOffset = get_frame_start(pv, |
| 1270 | pv->frameno_out - pv->job->areBframes); |
| 1271 | } |
| 1272 | buf = buf->next; |
| 1273 | pv->frameno_out++; |
| 1274 | } |
| 1275 | buf = hb_buffer_list_clear(&pv->delay_list); |
| 1276 | return buf; |
| 1277 | } |
| 1278 | else if (buf != NULL) |
| 1279 | { |
| 1280 | buf->s.renderOffset = buf->s.start; |
| 1281 | return buf; |
| 1282 | } |
| 1283 | return NULL; |
| 1284 | } |
| 1285 | |
| 1286 | static uint8_t convert_pict_type(const AVPacket *pkt, uint16_t *sflags) |
| 1287 | { |
no test coverage detected