parsing - h264 reference frames -
i'm looking algorithm of finding reference frames in h264 stream. common metod saw in different solutions finding access unit delimiters , nal of idr type. unfortunatelly streams checked didn't have nal of idr type. i'll gratefull help. regards jacek
h264 frames split special tag, called startcode prefix, either of 0x00 0x00 0x01 or 0x00 0x00 0x00 0x01. data between 2 startcodes comprises nal unit in h264 speak. want search startcode prefix in h264 stream. byte following startcode prefix nal header. lowest 5 bits of nal header give nal unit type. if nal_unit_type = 5, particular nal unit reference frame.
something this:
void h264_find_idr_frame(char *buf) { while(1) { if (buf[0]==0x00 && buf[1]==0x00 && buf[2]==0x01) { // found nal unit 3-byte startcode if(buf[3] & 0x1f == 0x5) { // found reference frame, } break; } else if (buf[0]==0x00 && buf[1]==0x00 && buf[2]==0x00 && buf[3]==0x01) { // found nal unit 4-byte startcode if(buf[4] & 0x1f == 0x5) { // found reference frame, } break; } buf++; } }
Comments
Post a Comment