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

Function decavcodecaWork

libhb/decavcodec.c:652–744  ·  view source on GitHub ↗

* Work *********************************************************************** * **********************************************************************/

Source from the content-addressed store, hash-verified

650 *
651 **********************************************************************/
652static int decavcodecaWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
653 hb_buffer_t ** buf_out )
654{
655 hb_work_private_t * pv = w->private_data;
656 hb_buffer_t * in = *buf_in;
657
658 // libavcodec/mpeg12dec.c requires buffers to be zero padded.
659 // If not zero padded, it can get stuck in an infinite loop.
660 // It's likely there are other decoders that expect the same.
661 if (in->data != NULL)
662 {
663 memset(in->data + in->size, 0, in->alloc - in->size);
664 }
665
666 if (in->s.flags & HB_BUF_FLAG_EOF)
667 {
668 /* EOF on input stream - send it downstream & say that we're done */
669 audioParserFlush(w);
670 decodeAudio(pv, NULL);
671 hb_buffer_list_append(&pv->list, in);
672 *buf_in = NULL;
673 *buf_out = hb_buffer_list_clear(&pv->list);
674 return HB_WORK_DONE;
675 }
676
677 *buf_out = NULL;
678
679 int pos, len;
680 int64_t pts = in->s.start;
681
682 // There are a 3 scenarios that can happen here.
683 // 1. The buffer contains exactly one frame of data
684 // 2. The buffer contains multiple frames of data
685 // 3. The buffer contains a partial frame of data
686 //
687 // In scenario 2, we want to be sure that the timestamps are only
688 // applied to the first frame in the buffer. Additional frames
689 // in the buffer will have their timestamps computed in sync.
690 //
691 // In scenario 3, we need to save the ancillary buffer info of an
692 // unfinished frame so it can be applied when we receive the last
693 // buffer of that frame.
694 if (!pv->unfinished)
695 {
696 // New packet, and no previous data pending
697 pv->packet_info.scr_sequence = in->s.scr_sequence;
698 pv->packet_info.new_chap = in->s.new_chap;
699 pv->packet_info.frametype = in->s.frametype;
700 pv->packet_info.discard = !!(in->s.flags & HB_FLAG_DISCARD);
701 }
702 for (pos = 0; pos < in->size; pos += len)
703 {
704 uint8_t * pout = NULL;
705 int pout_len = 0;
706 int64_t parser_pts;
707
708 if ( pv->parser != NULL )
709 {

Callers

nothing calls this directly

Calls 4

audioParserFlushFunction · 0.85
decodeAudioFunction · 0.85
hb_buffer_list_appendFunction · 0.85
hb_buffer_list_clearFunction · 0.85

Tested by

no test coverage detected