/* Routine to create a global VO/VOL header for MP4 container. What we do here is extract the header from the Xvid bitstream as it is encoded. We also strip the repeated headers from the bitstream when a global header is requested for MPEG-4 ISO compliance. */
int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned int header_len, unsigned int frame_len)
/* Routine to create a global VO/VOL header for MP4 container. What we do here is extract the header from the Xvid bitstream as it is encoded. We also strip the repeated headers from the bitstream when a global header is requested for MPEG-4 ISO compliance. */
int xvid_strip_vol_header(AVCodecContext *avctx, unsigned char *frame, unsigned int header_len, unsigned int frame_len)
{
    int vo_len = 0, i;
    for( i = 0; i < header_len - 3; i++ ) {
        if( frame[i] == 0x00 &&
            frame[i+1] == 0x00 &&
            frame[i+2] == 0x01 &&
            frame[i+3] == 0xB6 ) {
            vo_len = i;
            break;
        }
    }
    if( vo_len > 0 ) {
        if( avctx->extradata == NULL ) {
            avctx->extradata = av_malloc(vo_len);
            memcpy(avctx->extradata, frame, vo_len);
            avctx->extradata_size = vo_len;
        }
        memmove(frame, &(frame[vo_len]), frame_len - vo_len);
        return frame_len - vo_len;
    } else
        return frame_len;
}