mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-02-23 16:50:52 +08:00
优化SEI/AUD帧处理逻辑
This commit is contained in:
@@ -153,6 +153,10 @@ bool H264Track::ready() const {
|
||||
bool H264Track::inputFrame(const Frame::Ptr &frame) {
|
||||
using H264FrameInternal = FrameInternal<H264FrameNoCacheAble>;
|
||||
int type = H264_TYPE(frame->data()[frame->prefixSize()]);
|
||||
if (type == H264Frame::NAL_AUD) {
|
||||
// AUD帧丢弃
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((type == H264Frame::NAL_B_P || type == H264Frame::NAL_IDR) && ready()) {
|
||||
return inputFrame_l(frame);
|
||||
|
||||
@@ -205,7 +205,11 @@ bool FrameMerger::willFlush(const Frame::Ptr &frame) const{
|
||||
|
||||
case mp4_nal_size:
|
||||
case h264_prefix: {
|
||||
if (!_have_decode_able_frame) {
|
||||
if (frame->dropAble() && !_have_config_frame) {
|
||||
// 遇到SEI帧且未缓存配置帧,flush之前的帧
|
||||
return true;
|
||||
}
|
||||
if (!_have_decode_able_frame && !_have_drop_able_frame) {
|
||||
// 缓存中没有有效的能解码的帧,所以这次不flush [AUTO-TRANSLATED:5d860722]
|
||||
// There are no valid frames that can be decoded in the cache, so no flush this time.
|
||||
return _frame_cache.size() > kMaxFrameCacheSize;
|
||||
@@ -290,6 +294,8 @@ bool FrameMerger::inputFrame(const Frame::Ptr &frame, onOutput cb, BufferLikeStr
|
||||
cb(back->dts(), back->pts(), merged_frame, have_key_frame);
|
||||
_frame_cache.clear();
|
||||
_have_decode_able_frame = false;
|
||||
_have_drop_able_frame = false;
|
||||
_have_config_frame = false;
|
||||
}
|
||||
|
||||
if (!frame) {
|
||||
@@ -299,6 +305,12 @@ bool FrameMerger::inputFrame(const Frame::Ptr &frame, onOutput cb, BufferLikeStr
|
||||
if (frame->decodeAble()) {
|
||||
_have_decode_able_frame = true;
|
||||
}
|
||||
if (frame->dropAble()) {
|
||||
_have_drop_able_frame = true;
|
||||
}
|
||||
if (frame->configFrame()) {
|
||||
_have_config_frame = true;
|
||||
}
|
||||
_cb = std::move(cb);
|
||||
_frame_cache.emplace_back(Frame::getCacheAbleFrame(frame));
|
||||
return true;
|
||||
|
||||
@@ -660,6 +660,8 @@ private:
|
||||
private:
|
||||
int _type;
|
||||
bool _have_decode_able_frame = false;
|
||||
bool _have_drop_able_frame = false;
|
||||
bool _have_config_frame = false;
|
||||
onOutput _cb;
|
||||
toolkit::List<Frame::Ptr> _frame_cache;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user