| | |
| | | return true;
|
| | | }
|
| | |
|
| | | bool decodeH264(H264Decoder_Internal* in, uint8_t* buffer, size_t buffSize) |
| | | bool decodeH264(H264Decoder_Internal* in, uint8_t* buffer, size_t buffSize, timeval pts) |
| | | {
|
| | | AVPacket packet = {0};
|
| | | int gotPicture = buffSize; // frameFinished
|
| | |
| | | {
|
| | | printf("av_packet_from_data error\n");
|
| | | return false;
|
| | | } |
| | | }
|
| | | |
| | | packet.pts = packet.dts = (pts.tv_sec * 1000 * 1000 + pts.tv_usec) / 90000;
|
| | |
|
| | | // decode
|
| | | avcodec_decode_video2(in->pAVCodecContext, in->pAVFrame, &gotPicture, &packet);
|
| | |
| | |
|
| | | bool ret = false;
|
| | | if (pm.type == PipeMaterial::PMT_BYTES)
|
| | | ret = decodeH264(in, pm.buffer, pm.buffSize);
|
| | | {
|
| | | timeval pts = {0};
|
| | | ret = decodeH264(in, pm.buffer, pm.buffSize, pts);
|
| | | }
|
| | | else if (pm.type == PipeMaterial::PMT_FRAME)
|
| | | {
|
| | | MB_Frame* frame = (MB_Frame*)pm.buffer;
|
| | |
|
| | | ret = decodeH264(in, frame->buffer, frame->buffSize);
|
| | | ret = decodeH264(in, frame->buffer, frame->buffSize, frame->pts);
|
| | | if (ret)
|
| | | {
|
| | | in->lastFrame.type = MB_Frame::MBFT_PTR_AVFRAME;
|