61 lines · 1016 B · C
RawDownload
#include <u.h>#include <libc.h>#include <thread.h>#include "stream.h"#include "decoder.h"#include "frame.h" extern Decoderops av1ops, h264ops, vpxops; static struct {	char *name;	Decoderops *o;	int fmt;}ops[] = {	{"AV1", &av1ops, FmtAV1},	{"H264", &h264ops, FmtH264},	{"VP8", &vpxops, FmtVP8},	{"VP9", &vpxops, FmtVP9},}; Decoder *Dopen(Stream *s){	Decoder *d;	int i; 	if((d = calloc(1, sizeof(*d))) == nil)		return nil; 	d->timebase = (double)s->timebase.num/(double)s->timebase.denum;	d->s = s;	d->frames = chancreate(sizeof(Frame*), 24);	d->finished = chancreate(sizeof(void*), 0); 	for(i = 0; i < nelem(ops); i++){		if(ops[i].fmt == s->fmt){			if(ops[i].o->open(d) < 0){				werrstr("%s: %r", ops[i].name);				goto err;			}			d->ops = ops[i].o;			snprint(d->info, sizeof(d->info), "%s", ops[i].name);			break;		}	} 	assert(i < nelem(ops)); 	return d;err:	return nil;} voidDclose(Decoder *d){	d->ops->close(d);	chanclose(d->frames);	recvp(d->finished);	free(d);}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t