- 论坛徽章:
- 11
|
疯狂用 goto:
int sysinfo::build_chain(pix_fmt* fmt, chain* ptr){
list<format_conv_t *> temp;
list<format_conv_t *>* plist = &ptr->converter;
list<pix_fmt *>::iterator it1;
list<format_conv_t *>::iterator it2;
LABEL1:
for(it1 = sflist.begin(); it1 != sflist.end(); ++it1){
pix_fmt* p = *it1;
if(pix_fmt_equal(p, fmt)){
for(it2 = plist->begin(); it2 != plist->end(); ++it2){
conv_list.push_back(*it2);
}
for(it2 = temp.begin(); it2 != temp.end(); ++it2){
conv_list.push_back(*it2);
}
return 0;
}
}
LABEL2:
for(it2 = conv_list.begin(); it2 != conv_list.end(); ++it2){
pix_fmt* p = &((*it2)->in);
if(pix_fmt_equal(p, fmt)){
fmt = &((*it2)->out);
plist->push_back(*it2);
conv_list.erase(it2);
goto LABEL1;
}
}
if(plist->empty()){
if(temp.empty()){
return -1;
}
return build_gdi_chain(fmt, ptr, &temp);
}
format_conv_t* conv = plist->back();
if(pix_fmt_equal(fmt, sf_gdi) || accept(fmt, &temp)){
temp.push_back(conv);
}
fmt = &conv->in;
plist->pop_back();
goto LABEL2;
}
stream_buffer* sysinfo::pts_buffer_pop(){
int ms;
LABEL1:
EnterCriticalSection(&cse);
if(pts_list.empty()){
ms = INFINITE;
LABEL2:
ResetEvent(hevent);
LeaveCriticalSection(&cse);
DWORD err = WaitForSingleObject(hevent, ms);
if(err == WAIT_FAILED){
return NULL;
}
goto LABEL1;
}
stream_buffer* buffer = pts_list.front();
DWORD pts = (DWORD) (buffer->media.pts & 0xffffffff);
DWORD tick = timeGetTime();
if(pts > tick){
ms = pts - tick;
goto LABEL2;
}
my_pop_heap(pts_list.begin(), pts_list.end());
assert(pts_list.back() == buffer);
pts_list.pop_back();
LeaveCriticalSection(&cse);
buffer->next = NULL;
return buffer;
} |
|