front-end/build/ffmpeg/libavcodec/hevc_parser.c
/**
 * Find the end of the current frame in the bitstream.
 * @return the position of the first byte of the next frame, or END_NOT_FOUND
 */
Find the end of the current frame in the bitstream.
@return the position of the first byte of the next frame, or END_NOT_FOUND
Find the end of the current frame in the bitstream . @return the position of the first byte of the next frame or END_NOT_FOUND
static int hevc_find_frame_end(AVCodecParserContext *s, const uint8_t *buf,
                               int buf_size)
{
    int i;
    ParseContext *pc = &((HEVCParseContext *)s->priv_data)->pc;
    for (i = 0; i < buf_size; i++) {
        int nut;
        pc->state64 = (pc->state64 << 8) | buf[i];
        if (((pc->state64 >> 3 * 8) & 0xFFFFFF) != START_CODE)
            continue;
        nut = (pc->state64 >> 2 * 8 + 1) & 0x3F;
        if ((nut >= NAL_VPS && nut <= NAL_AUD) || nut == NAL_SEI_PREFIX ||
            (nut >= 41 && nut <= 44) || (nut >= 48 && nut <= 55)) {
            if (pc->frame_start_found) {
                pc->frame_start_found = 0;
                return i - 5;
            }
        } else if (nut <= NAL_RASL_R ||
                   (nut >= NAL_BLA_W_LP && nut <= NAL_CRA_NUT)) {
            int first_slice_segment_in_pic_flag = buf[i] >> 7;
            if (first_slice_segment_in_pic_flag) {
                if (!pc->frame_start_found) {
                    pc->frame_start_found = 1;
                } else { 
                    pc->frame_start_found = 0;
                    return i - 5;
                }
            }
        }
    }
    return END_NOT_FOUND;
}
static int hevc_find_frame_end ( AVCodecParserContext * s , const uint8_t * buf , int buf_size ) { int i ; ParseContext * pc = & ( ( HEVCParseContext * ) s -> priv_data ) -> pc ; for ( i = 0 ; i < buf_size ; i ++ ) { int nut ; pc -> state64 = ( pc -> state64 << 8 ) | buf [ i ] ; if ( ( ( pc -> state64 >> 3 * 8 ) & 0xFFFFFF ) != START_CODE ) continue ; nut = ( pc -> state64 >> 2 * 8 + 1 ) & 0x3F ; if ( ( nut >= NAL_VPS && nut <= NAL_AUD ) || nut == NAL_SEI_PREFIX || ( nut >= 41 && nut <= 44 ) || ( nut >= 48 && nut <= 55 ) ) { if ( pc -> frame_start_found ) { pc -> frame_start_found = 0 ; return i - 5 ; } } else if ( nut <= NAL_RASL_R || ( nut >= NAL_BLA_W_LP && nut <= NAL_CRA_NUT ) ) { int first_slice_segment_in_pic_flag = buf [ i ] >> 7 ; if ( first_slice_segment_in_pic_flag ) { if ( ! pc -> frame_start_found ) { pc -> frame_start_found = 1 ; } else { pc -> frame_start_found = 0 ; return i - 5 ; } } } } return END_NOT_FOUND ; }
Find the end of the current frame in the bitstream.
Find the end of the current frame in the bitstream .
// Beginning of access unit // First slice of next frame found