void ES_MPEG2Audio::Parse(STREAM_PKT* pkt) { int p = es_parsed; int l; while ((l = es_len - p) > 3) { if (FindHeaders(es_buf + p, l) < 0) break; p++; } es_parsed = p; if (es_found_frame && l >= m_FrameSize) { bool streamChange = SetAudioInformation(m_Channels, m_SampleRate, m_BitRate, 0, 0); pkt->pid = pid; pkt->data = &es_buf[p]; pkt->size = m_FrameSize; pkt->duration = 90000 * 1152 / m_SampleRate; pkt->dts = m_DTS; pkt->pts = m_PTS; pkt->streamChange = streamChange; es_consumed = p + m_FrameSize; es_parsed = es_consumed; es_found_frame = false; } }
void cParserAC3::Parse(sStreamPacket *pkt, sStreamPacket *pkt_side_data) { int p = m_PesParserPtr; int l; while ((l = m_PesBufferPtr - p) > 8) { if (FindHeaders(m_PesBuffer + p, l) < 0) break; p++; } m_PesParserPtr = p; if (m_FoundFrame && l >= m_FrameSize) { bool streamChange = m_Stream->SetAudioInformation(m_Channels, m_SampleRate, m_BitRate, 0, 0); pkt->id = m_pID; pkt->data = &m_PesBuffer[p]; pkt->size = m_FrameSize; pkt->duration = 90000 * 1536 / m_SampleRate; pkt->dts = m_DTS; pkt->pts = m_PTS; pkt->streamChange = streamChange; m_PesNextFramePtr = p + m_FrameSize; m_PesParserPtr = 0; m_FoundFrame = false; } }
void cParserMPEG2Audio::Parse(unsigned char *data, int size, bool pusi) { if (pusi) { /* Payload unit start */ m_PESStart = true; m_firstPUSIseen = true; } /* Wait for first pusi */ if (!m_firstPUSIseen) return; if (m_PESStart) { int hlen = ParsePESHeader(data, size); if (hlen <= 0) return; data += hlen; size -= hlen; m_PESStart = false; assert(size >= 0); if(size == 0) return; } while (size > 0) { uint8_t *outbuf; int outlen; int rlen = FindHeaders(&outbuf, &outlen, data, size, m_curPTS, m_curDTS); if (rlen < 0) break; m_curPTS = DVD_NOPTS_VALUE; m_curDTS = DVD_NOPTS_VALUE; if (outlen) { sStreamPacket pkt; pkt.data = outbuf; pkt.size = outlen; pkt.duration = 90000 * 1152 / m_SampleRate; pkt.dts = m_DTS; if (pkt.dts == DVD_NOPTS_VALUE) pkt.dts = m_NextDTS; pkt.pts = pkt.dts; m_NextDTS = pkt.dts + pkt.duration; m_demuxer->SendPacket(&pkt); } data += rlen; size -= rlen; } }