const char *get_mkvCodec(int codec_ind) { int real_index = get_real_index (codec_ind); if(real_index >= 0 && real_index < MAX_VCODECS) return (listSupVCodecs[get_real_index (codec_ind)].mkv_codec); else { fprintf(stderr, "VCODEC: (mkvCodec) bad codec index\n"); return NULL; } }
void update_lr() { for ( int i = 0; i < OFFSET; ++ i ) R[i] = get_real_index(0); R[START_INDEX] = get_real_index(0); for ( int i = 0; i < N; ++ i ) { const int& real_index = get_real_index(i); L[real_index] = real_index - 1; R[real_index] = real_index + 1; } for ( int i = 0; i < OFFSET; ++ i ) R[OFFSET + N + i] = 2 * OFFSET + N - 1; }
t_hs hs_slice(t_hs hs, int start_index, int end_index) { int length; start_index = get_real_index(hs, start_index); end_index = get_real_index(hs, end_index); if (start_index < 0 || end_index < 0) return (hs_new_empty()); length = end_index - start_index; if (length < 0) length = 0; return (hs_new_from_n_chars(length, hs._chars + start_index)); }
void remove( const int& raw_id ) { const int& real_id = get_real_index(raw_id); const int& l_id = L[real_id]; const int& r_id = R[real_id]; R[l_id] = r_id; L[r_id] = l_id; }
vcodecs_data *get_codec_defaults(int codec_ind) { int real_index = get_real_index (codec_ind); if(real_index >= 0 && real_index < MAX_VCODECS) return (&(listSupVCodecs[real_index])); else { fprintf(stderr, "VCODEC: (defaults) bad codec index\n"); return NULL; } }
gboolean isVcodecValid(int codec_ind) { int real_index = get_real_index (codec_ind); if(real_index >= 0 && real_index < MAX_VCODECS) return (listSupVCodecs[real_index].valid); else { fprintf(stderr, "VCODEC: (isValid) bad codec index\n"); return FALSE; } }
int get_vcodec_id(int codec_ind) { int real_index = get_real_index (codec_ind); if(real_index >= 0 && real_index < MAX_VCODECS) return (listSupVCodecs[real_index].codec_id); else { fprintf(stderr, "VCODEC: (id) bad codec index\n"); return 0; } }
void *get_mkvCodecPriv(int codec_ind) { int real_index = get_real_index (codec_ind); if(real_index >= 0 && real_index < MAX_VCODECS) return ((void *) listSupVCodecs[real_index].mkv_codecPriv); else { fprintf(stderr, "VCODEC: (mkvCodecPriv) bad codec index\n"); return NULL; } }
const char *get_desc4cc(int codec_ind) { int real_index = get_real_index (codec_ind); if(real_index >= 0 && real_index < MAX_VCODECS) return (listSupVCodecs[real_index].description); else { fprintf(stderr, "VCODEC: (desc4cc) bad codec index\n"); return NULL; } }
const char *get_vid4cc(int codec_ind) { int real_index = get_real_index (codec_ind); if(real_index >= 0 && real_index < MAX_VCODECS) return (listSupVCodecs[real_index].compressor); else { fprintf(stderr, "VCODEC: (4cc) bad codec index\n"); return NULL; } }
int set_mkvCodecPriv(int codec_ind, int width, int height, struct lavcData* data) { int size = 0; int real_index = get_real_index (codec_ind); if(real_index < 0 || real_index >= MAX_VCODECS) { fprintf(stderr, "VCODEC: (set mkvCodecPriv) bad codec index\n"); return 0; } if(listSupVCodecs[real_index].codec_id == AV_CODEC_ID_THEORA) { //get the 3 first header packets uint8_t *header_start[3]; int header_len[3]; int first_header_size; first_header_size = 42; //vorbis = 30 if (avpriv_split_xiph_headers(data->codec_context->extradata, data->codec_context->extradata_size, first_header_size, header_start, header_len) < 0) { fprintf(stderr, "VCODEC: theora codec - Extradata corrupt.\n"); return -1; } //get the allocation needed for headers size int header_lace_size[2]; header_lace_size[0]=0; header_lace_size[1]=0; int i; for (i = 0; i < header_len[0] / 255; i++) header_lace_size[0]++; header_lace_size[0]++; for (i = 0; i < header_len[1] / 255; i++) header_lace_size[1]++; header_lace_size[1]++; size = 1 + //number of packets -1 header_lace_size[0] + //first packet size header_lace_size[1] + //second packet size header_len[0] + //first packet header header_len[1] + //second packet header header_len[2]; //third packet header //should check and clean before allocating ?? data->priv_data = g_new0(BYTE, size); //write header BYTE* tmp = data->priv_data; *tmp++ = 0x02; //number of packets -1 //size of head 1 for (i = 0; i < header_len[0] / 0xff; i++) *tmp++ = 0xff; *tmp++ = header_len[0] % 0xff; //size of head 2 for (i = 0; i < header_len[1] / 0xff; i++) *tmp++ = 0xff; *tmp++ = header_len[1] % 0xff; //add headers for(i=0; i<3; i++) { memcpy(tmp, header_start[i] , header_len[i]); tmp += header_len[i]; } listSupVCodecs[real_index].mkv_codecPriv = data->priv_data; } else if(listSupVCodecs[real_index].mkv_codecPriv != NULL) { mkv_codecPriv.biWidth = width; mkv_codecPriv.biHeight = height; mkv_codecPriv.biCompression = listSupVCodecs[real_index].mkv_4cc; if(listSupVCodecs[real_index].codec_id != CODEC_DIB) { mkv_codecPriv.biSizeImage = width*height*2; mkv_codecPriv.biHeight =-height; } else mkv_codecPriv.biSizeImage = width*height*3; /*rgb*/ size = 40; //40 bytes } return (size); }
template <class Func> void each( Func func ) { std::cout << "N = " << N << std::endl; for ( int i = R[START_INDEX]; i < get_real_index(N); i = R[i] ) { func(get_raw_index(i)); } }
void update_id() { for ( int i = 0; i < N; ++ i ) { id[get_real_index(i)] = i; } }