static void vlVdpDecoderFixVC1Startcode(uint32_t *num_buffers, const void *buffers[], unsigned sizes[]) { static const uint8_t vc1_startcode[] = { 0x00, 0x00, 0x01, 0x0D }; struct vl_vlc vlc; unsigned i; /* search the first 64 bytes for a startcode */ vl_vlc_init(&vlc, *num_buffers, buffers, sizes); while (vl_vlc_search_byte(&vlc, 64*8, 0x00) && vl_vlc_bits_left(&vlc) >= 32) { uint32_t value = vl_vlc_peekbits(&vlc, 32); if (value == 0x0000010D || value == 0x0000010C || value == 0x0000010B) return; vl_vlc_eatbits(&vlc, 8); } /* none found, ok add one manually */ VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Manually adding VC-1 startcode\n"); for (i = *num_buffers; i > 0; --i) { buffers[i] = buffers[i - 1]; sizes[i] = sizes[i - 1]; } ++(*num_buffers); buffers[0] = vc1_startcode; sizes[0] = 4; }
static unsigned int bufHasStartcode(vlVaBuffer *buf, unsigned int code, unsigned int bits) { struct vl_vlc vlc = {0}; int i; /* search the first 64 bytes for a startcode */ vl_vlc_init(&vlc, 1, (const void * const*)&buf->data, &buf->size); for (i = 0; i < 64 && vl_vlc_bits_left(&vlc) >= bits; ++i) { if (vl_vlc_peekbits(&vlc, bits) == code) return 1; vl_vlc_eatbits(&vlc, 8); vl_vlc_fillbits(&vlc); } return 0; }