Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "bitstreamIO.h"
- #include <fstream>
- #include <iostream>
- //#include "sample_defs.h"
- //#include "exceptions.h"
- BitstreamIO::BitstreamIO(mfxBitstream *h264Bitstream)
- {
- h264BitstreamLength = sizeof(h264Bitstream);
- curH264Bitstream = (mfxBitstream *)malloc(sizeof(h264Bitstream));
- }
- BitstreamIO::~BitstreamIO()
- {
- }
- void BitstreamIO::switchStreams(mfxBitstream *h264Bitstream)
- {
- free(curH264Bitstream->Data);
- free(curH264Bitstream);
- //h264BitstreamLength = sizeof(h264Bitstream);
- curH264Bitstream = (mfxBitstream *)malloc(sizeof(h264Bitstream));
- memset(curH264Bitstream,0,sizeof(curH264Bitstream));
- curH264Bitstream->Data = (mfxU8 *)malloc(h264Bitstream->DataLength);
- curH264Bitstream->DataLength = h264Bitstream->DataLength;
- curH264Bitstream->DataOffset = h264Bitstream->DataOffset;
- curH264Bitstream->MaxLength = h264Bitstream->MaxLength;
- memcpy(curH264Bitstream->Data,h264Bitstream->Data,h264Bitstream->DataLength);
- }
- //Only function needed since only using this class to read a h264 frame from a bitstream
- //Note: must remember to free outBitstream later
- mfxI32 BitstreamIO::Read(mfxBitstream *outBitstream)
- {
- //Again, not thread safe
- //outBitstream=h264BitstreamPtr;
- outBitstream->DataLength = curH264Bitstream->DataLength;
- outBitstream->DataFlag = curH264Bitstream->DataFlag;
- outBitstream->DataOffset = curH264Bitstream->DataOffset;
- outBitstream->MaxLength = curH264Bitstream->MaxLength;
- outBitstream->TimeStamp = curH264Bitstream->TimeStamp;
- if(curH264Bitstream->Data != NULL)
- {
- if(outBitstream->Data != NULL)
- {
- free(outBitstream->Data);
- }
- if(outBitstream->DataLength != 0)
- {
- outBitstream->Data = (mfxU8 *)malloc(curH264Bitstream->DataLength);
- memcpy(outBitstream->Data,curH264Bitstream->Data,outBitstream->DataLength);
- }
- }
- mfxI32 nBytesRead = h264BitstreamLength;
- return nBytesRead;
- }
- //Do not currently need to use if only using this class to read a h264 frame from a bitstream
- mfxI32 BitstreamIO::Write(mfxBitstream *outBitStream)
- {
- return 0;
- }
- //Do not currently need to use if only using this class to read a h264 frame from a bitstream
- mfxI64 BitstreamIO::Seek(mfxI64 offset, mfxSeekOrigin origin)
- {
- return origin;
- }
Add Comment
Please, Sign In to add comment