| 288 | } |
| 289 | |
| 290 | static hb_buffer_t * CreateSilenceBuf( sync_stream_t * stream, |
| 291 | int64_t dur, int64_t pts ) |
| 292 | { |
| 293 | double frame_dur, next_pts, duration; |
| 294 | int size; |
| 295 | hb_buffer_list_t list; |
| 296 | hb_buffer_t * buf; |
| 297 | |
| 298 | if (stream->audio.audio->config.out.codec & HB_ACODEC_PASS_FLAG) |
| 299 | { |
| 300 | return NULL; |
| 301 | } |
| 302 | duration = dur; |
| 303 | // Although frame size isn't technically important any more, we |
| 304 | // keep audio buffer durations <= input audio buffer durations. |
| 305 | frame_dur = (90000. * stream->audio.audio->config.in.samples_per_frame) / |
| 306 | stream->audio.audio->config.in.samplerate; |
| 307 | // Audio mixdown occurs in decoders before sync. |
| 308 | // So number of channels here is output channel count. |
| 309 | // But audio samplerate conversion happens in later here in sync.c |
| 310 | // FilterAudioFrame, so samples_per_frame is still the input sample count. |
| 311 | size = sizeof(float) * stream->audio.audio->config.in.samples_per_frame * |
| 312 | hb_mixdown_get_discrete_channel_count( |
| 313 | stream->audio.audio->config.out.mixdown); |
| 314 | |
| 315 | hb_buffer_list_clear(&list); |
| 316 | next_pts = pts; |
| 317 | while (duration >= frame_dur) |
| 318 | { |
| 319 | buf = hb_buffer_init(size); |
| 320 | memset(buf->data, 0, buf->size); |
| 321 | buf->s.start = next_pts; |
| 322 | next_pts += frame_dur; |
| 323 | buf->s.stop = next_pts; |
| 324 | buf->s.duration = frame_dur; |
| 325 | duration -= frame_dur; |
| 326 | hb_buffer_list_append(&list, buf); |
| 327 | } |
| 328 | if (duration > 0) |
| 329 | { |
| 330 | // Make certain size is even multiple of sample size * num channels |
| 331 | size = (int)(duration * stream->audio.audio->config.in.samplerate / |
| 332 | 90000) * sizeof(float) * |
| 333 | hb_mixdown_get_discrete_channel_count( |
| 334 | stream->audio.audio->config.out.mixdown); |
| 335 | if (size > 0) |
| 336 | { |
| 337 | buf = hb_buffer_init(size); |
| 338 | memset(buf->data, 0, buf->size); |
| 339 | buf->s.start = next_pts; |
| 340 | next_pts += duration; |
| 341 | buf->s.stop = next_pts; |
| 342 | buf->s.duration = duration; |
| 343 | hb_buffer_list_append(&list, buf); |
| 344 | } |
| 345 | } |
| 346 | return hb_buffer_list_clear(&list); |
| 347 | } |
no test coverage detected