CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/HW/MpegDemux.h
Views: 1401
// This is a simple version MpegDemux that can get media's audio stream.1// Thanks to JPCSP project.23#pragma once45#include "Common/CommonTypes.h"6#include "Core/HW/BufferQueue.h"78class PointerWrap;910class MpegDemux11{12public:13MpegDemux(int size, int offset);14~MpegDemux();1516bool addStreamData(const u8 *buf, int addSize);17bool demux(int audioChannel);1819// return its framesize20int getNextAudioFrame(u8 **buf, int *headerCode1, int *headerCode2, s64 *pts = NULL);21bool hasNextAudioFrame(int *gotsizeOut, int *frameSizeOut, int *headerCode1, int *headerCode2);2223int getRemainSize() const {24return m_len - m_readSize;25}2627void DoState(PointerWrap &p);2829private:30struct PesHeader {31s64 pts;32s64 dts;33int channel;3435PesHeader(int chan) {36pts = 0;37dts = 0;38channel = chan;39}40};4142int read8() {43return m_buf[m_index++];44}45int read16() {46return (read8() << 8) | read8();47}48int read24() {49return (read8() << 16) | (read8() << 8) | read8();50}51s64 readPts() {52return readPts(read8());53}54s64 readPts(int c) {55return (((s64) (c & 0x0E)) << 29) | ((read16() >> 1) << 15) | (read16() >> 1);56}57bool isEOF() const {58return m_index >= m_readSize;59}60void skip(int n) {61if (n > 0) {62m_index += n;63}64}65int readPesHeader(PesHeader &pesHeader, int length, int startCode);66int demuxStream(bool bdemux, int startCode, int length, int channel);67bool skipPackHeader();6869int m_index;70int m_len;71u8 *m_buf;72BufferQueue m_audioStream;73u8 m_audioFrame[0x2000];74int m_audioChannel;75int m_readSize;76};77787980