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

Function Encode

libhb/platform/macosx/encca_aac.c:496–548  ·  view source on GitHub ↗

* Encode *********************************************************************** * **********************************************************************/

Source from the content-addressed store, hash-verified

494 *
495 **********************************************************************/
496static hb_buffer_t* Encode(hb_work_object_t *w)
497{
498 hb_work_private_t *pv = w->private_data;
499 UInt32 npackets = 1;
500
501 // Check if we need more data or we have already got to EOF
502 // if so, we need to call the audio converter again even
503 // without data to get out the remaining packets.
504 if (pv->input_done != 1 &&
505 (pv->ibytes = hb_list_bytes(pv->list)) < pv->isamples * pv->isamplesiz)
506 {
507 return NULL;
508 }
509
510 hb_buffer_t *obuf;
511 AudioStreamPacketDescription odesc = { 0 };
512 AudioBufferList obuflist =
513 {
514 .mNumberBuffers = 1,
515 .mBuffers = { { .mNumberChannels = pv->nchannels } },
516 };
517
518 obuf = hb_buffer_init(pv->omaxpacket);
519 obuflist.mBuffers[0].mDataByteSize = obuf->size;
520 obuflist.mBuffers[0].mData = obuf->data;
521
522 OSStatus err = AudioConverterFillComplexBuffer(pv->converter,
523 inInputDataProc, pv,
524 &npackets, &obuflist, &odesc);
525
526 if (err != noErr && err != 1)
527 {
528 hb_log("encCoreAudio: unexpected error in AudioConverterFillComplexBuffer()");
529 }
530 // only drop the output buffer if it's actually empty
531 if (!npackets || odesc.mDataByteSize <= 0)
532 {
533 hb_buffer_close(&obuf);
534 return NULL;
535 }
536
537 obuf->size = odesc.mDataByteSize;
538 obuf->s.start = pv->first_pts - pv->delay +
539 90000LL * pv->samples / pv->osamplerate;
540 pv->samples += pv->isamples;
541 obuf->s.stop = pv->first_pts - pv->delay +
542 90000LL * pv->samples / pv->osamplerate;
543 obuf->s.duration = (double)90000 * pv->isamples / pv->osamplerate;
544 obuf->s.type = AUDIO_BUF;
545 obuf->s.frametype = HB_FRAME_AUDIO;
546
547 return obuf;
548}
549
550static void Flush(hb_work_object_t *w, hb_buffer_list_t * list)
551{

Callers 2

FlushFunction · 0.70
encCoreAudioWorkFunction · 0.70

Calls 4

hb_list_bytesFunction · 0.85
hb_buffer_initFunction · 0.85
hb_logFunction · 0.85
hb_buffer_closeFunction · 0.85

Tested by

no test coverage detected