| 4711 | } |
| 4712 | |
| 4713 | static hb_buffer_t * generate_output_data(hb_stream_t *stream, int curstream) |
| 4714 | { |
| 4715 | hb_buffer_list_t list; |
| 4716 | hb_buffer_t *buf = NULL; |
| 4717 | |
| 4718 | hb_buffer_list_clear(&list); |
| 4719 | hb_ts_stream_t * ts_stream = &stream->ts.list[curstream]; |
| 4720 | hb_buffer_t * b = ts_stream->buf; |
| 4721 | if (!ts_stream->pes_info_valid) |
| 4722 | { |
| 4723 | if (!hb_parse_ps(stream, b->data, b->size, &ts_stream->pes_info)) |
| 4724 | { |
| 4725 | b->size = 0; |
| 4726 | ts_stream->packet_len = 0; |
| 4727 | ts_stream->packet_offset = 0; |
| 4728 | return NULL; |
| 4729 | } |
| 4730 | ts_stream->pes_info_valid = 1; |
| 4731 | ts_stream->packet_offset = ts_stream->pes_info.header_len; |
| 4732 | } |
| 4733 | |
| 4734 | uint8_t *tdat = b->data + ts_stream->packet_offset; |
| 4735 | int es_size = b->size - ts_stream->packet_offset; |
| 4736 | |
| 4737 | if (ts_stream->packet_len >= ts_stream->pes_info.packet_len + 6) |
| 4738 | { |
| 4739 | // Remove trailing stuffing bytes (DVB subtitles) |
| 4740 | es_size -= ts_stream->pes_info.stuffing_len; |
| 4741 | } |
| 4742 | if (es_size <= 0) |
| 4743 | { |
| 4744 | if (ts_stream->pes_info.packet_len > 0 && |
| 4745 | ts_stream->packet_len >= ts_stream->pes_info.packet_len + 6) |
| 4746 | { |
| 4747 | ts_stream->pes_info_valid = 0; |
| 4748 | ts_stream->packet_len = 0; |
| 4749 | } |
| 4750 | b->size = 0; |
| 4751 | ts_stream->packet_offset = 0; |
| 4752 | return NULL; |
| 4753 | } |
| 4754 | |
| 4755 | int pes_idx; |
| 4756 | pes_idx = ts_stream->pes_list; |
| 4757 | hb_pes_stream_t *pes_stream = &stream->pes.list[pes_idx]; |
| 4758 | if (stream->need_keyframe) |
| 4759 | { |
| 4760 | // we're looking for the first video frame because we're |
| 4761 | // doing random access during 'scan' |
| 4762 | int kind = pes_stream->stream_kind; |
| 4763 | if (kind != V || !isIframe(stream, tdat, es_size)) |
| 4764 | { |
| 4765 | // not the video stream or didn't find an I frame |
| 4766 | // but we'll only wait 255 video frames for an I frame. |
| 4767 | if (kind != V || ++stream->need_keyframe < 512) |
| 4768 | { |
| 4769 | b->size = 0; |
| 4770 | ts_stream->pes_info_valid = 0; |
no test coverage detected