h264参考框架 [英] h264 reference frames

查看:162
本文介绍了h264参考框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在h264流中查找参考帧的算法.我在不同解决方案中看到的最常见的方法是找到访问单元定界符和IDR类型的NAL.不幸的是,我检查的大多数流都没有IDR类型的NAL. 我将非常感谢您的帮助. 问候 贾塞克

I'm looking for a algorithm of finding reference frames in h264 stream. The most common metod I saw in different solutions was finding access unit delimiters and NAL of IDR type. Unfortunatelly most streams I checked didn't have NAL of IDR type. I'll be gratefull for help. Regards Jacek

推荐答案

H264帧被称为起始代码前缀的特殊标记拆分,该标记为 0x00 0x00 0x01 0x00 0x00 0x00 0x01 .两个起始码之间的所有数据都包含一个以H264语言表示的NAL单元.因此,您要做的就是在h264流中搜索startcode前缀.起始码前缀之后的字节立即是 NAL标头. NAL标头的最低5位将为您提供NAL单元类型.如果nal_unit_type = 5,则该特定NAL单元是参考帧.

H264 frames split up by a special tag, called the startcode prefix, which is either of 0x00 0x00 0x01 OR 0x00 0x00 0x00 0x01. All the data between two startcodes comprises a NAL unit in H264 speak. So what you want to do is search for the startcode prefix in your h264 stream. The byte following the startcode prefix immediately is the NAL header. The lowest 5 bits of the NAL header will give you the NAL unit type. If nal_unit_type = 5, that particular NAL unit is a reference frame.

类似这样的东西:

void h264_find_IDR_frame(char *buf)
{
    while(1)
    {
        if (buf[0]==0x00 && buf[1]==0x00 && buf[2]==0x01)
        {
            // Found a NAL unit with 3-byte startcode
            if(buf[3] & 0x1F == 0x5)
            {
                // Found a reference frame, do something with it
            }
            break;
        }
        else if (buf[0]==0x00 && buf[1]==0x00 && buf[2]==0x00 && buf[3]==0x01)
        {
            // Found a NAL unit with 4-byte startcode
            if(buf[4] & 0x1F == 0x5)
            {
                // Found a reference frame, do something with it
            }
            break;
        }
        buf++;
    }
}

这篇关于h264参考框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆