| | |
| | | #include <libavutil/imgutils.h>
|
| | | #include <libavutil/opt.h>
|
| | | #include <libavformat/avformat.h>
|
| | | |
| | | #include <libyuv.h>
|
| | | }
|
| | |
|
| | | #include <libyuv.h>
|
| | |
|
| | | PL_H264Encoder_Config::PL_H264Encoder_Config() :
|
| | | inBufferSize(2*1024*1024), // 2MByte
|
| | |
| | |
|
| | | ~H264Encoder_Internal()
|
| | | {
|
| | | delete[] buffer;
|
| | | buffer = nullptr;
|
| | | }
|
| | |
|
| | | void reset()
|
| | |
| | | pAVFormatContext = nullptr;
|
| | |
|
| | | if (buffer != nullptr)
|
| | | {
|
| | | delete[] buffer;
|
| | | buffer = new uint8_t[config.inBufferSize];
|
| | | buffer = nullptr;
|
| | | }
|
| | | }
|
| | | };
|
| | |
|
| | |
| | | PL_H264Encoder_Config* config = (PL_H264Encoder_Config*)args;
|
| | | in->config = *config;
|
| | | }
|
| | | |
| | | in->buffer = new uint8_t[in->config.inBufferSize];
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | {
|
| | | in->frameCount++;
|
| | | LOGP(DEBUG, "Succeed to encode (1) frame=%d, size=%d", in->frameCount, pAVPacket.size);
|
| | | memcpy(in->buffer, pAVPacket.data, pAVPacket.size);
|
| | | memcpy(in->buffer, pAVPacket.data, pAVPacket.size);//#todo check inBufferSize
|
| | | in->buffSize = pAVPacket.size;
|
| | | av_free_packet(&pAVPacket);
|
| | | }
|
| | |
| | | in->lastFrame.buffSize = in->buffSize;
|
| | | in->lastFrame.width = frame->width;
|
| | | in->lastFrame.height = frame->height;
|
| | | in->lastFrame.pts = frame->pts;
|
| | | //#todo resetPts
|
| | |
|
| | | if (in->config.resetPTS)
|
| | | gettimeofday(&(in->lastFrame.pts),NULL);
|
| | | else
|
| | | in->lastFrame.pts = frame->pts;
|
| | | }
|
| | |
|
| | | return ret;
|