Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge

  • Loading branch information...
commit 757c014007c4a99501f3cc5ab673999b8bbfd783 2 parents 5dbaf7d + 130306d
Steve Strong srstrong authored
4 Makefile
View
@@ -11,7 +11,9 @@ ifeq ($(UNAME), Darwin)
LDFLAGS += -L$(ERL_DIR)/lib $(FFMPEG_STATIC_LIBS) $(FFMPEG_DYN_LIBS) -lz -lm -lpthread -framework CoreFoundation -framework VideoDecodeAcceleration -framework CoreVideo
endif
ifeq ($(UNAME), Linux)
- LDFLAGS += -Wl,-Bstatic $(FFMPEG_STATIC_LIBS) -Wl,-Bdynamic -lz $(FFMPEG_DYN_LIBS) -lm -lpthread
+ ERL_DIR = $(shell erl -noshell -eval 'io:format("~p~n", [code:lib_dir(erl_interface)])' -eval 'init:stop()')
+ CFLAGS += -I $(ERL_DIR)/include
+ LDFLAGS += -L$(ERL_DIR)/lib -Wl,-Bstatic $(FFMPEG_STATIC_LIBS) -Wl,-Bdynamic -lz $(FFMPEG_DYN_LIBS) -lm -lpthread
endif
.PHONY: default all clean
98 c_src/async_parallel_filter.c
View
@@ -119,44 +119,27 @@ typedef struct _thread_struct_t
typedef struct _codec_t
{
AVClass *av_class;
- int pass_through;
thread_struct *threads;
} codec_t;
static void process(ID3ASFilterContext *context, AVFrame *frame, AVRational timebase)
{
- /*
- for (int i = 0; i < context->num_downstream_filters; i++)
- {
- AVFrame *foo = av_frame_clone(frame);
- context->downstream_filters[i]->filter->execute(context->downstream_filters[i], foo, timebase);
- av_frame_free(&foo);
- }
- return;
- */
-
codec_t *this = context->priv_data;
- if (this->pass_through) {
- send_to_graph(context, frame, timebase);
+ for (int i = 0; i < context->num_downstream_filters; i++) {
+
+ frame_entry_t *frame_entry = (frame_entry_t *) malloc(sizeof(frame_entry_t));
+ frame_entry->timebase = timebase;
+ frame_entry->frame = av_frame_clone(frame);
+ frame_entry->exit_thread = 0;
+
+ ADD_TO_QUEUE(context, this->threads[i].inbound_frame_queue, frame_entry);
}
- else {
-
+
+ if (sync_mode) {
for (int i = 0; i < context->num_downstream_filters; i++) {
-
- frame_entry_t *frame_entry = (frame_entry_t *) malloc(sizeof(frame_entry_t));
- frame_entry->timebase = timebase;
- frame_entry->frame = av_frame_clone(frame);
- frame_entry->exit_thread = 0;
-
- ADD_TO_QUEUE(context, this->threads[i].inbound_frame_queue, frame_entry);
- }
-
- if (sync_mode) {
- for (int i = 0; i < context->num_downstream_filters; i++) {
- pthread_cond_wait(&this->threads[i].complete, &this->threads[i].complete_mutex);
- }
+ pthread_cond_wait(&this->threads[i].complete, &this->threads[i].complete_mutex);
}
}
}
@@ -165,21 +148,16 @@ static void flush(ID3ASFilterContext *context)
{
codec_t *this = context->priv_data;
- if (this->pass_through) {
- flush_graph(context);
- }
- else {
- for (int i = 0; i < context->num_downstream_filters; i++) {
-
- frame_entry_t *frame_entry = (frame_entry_t *) malloc(sizeof(frame_entry_t));
- frame_entry->exit_thread = 1;
-
- ADD_TO_QUEUE(context, this->threads[i].inbound_frame_queue, frame_entry);
- }
+ for (int i = 0; i < context->num_downstream_filters; i++) {
- for (int i = 0; i < context->num_downstream_filters; i++) {
- pthread_join(this->threads[i].thread, NULL);
- }
+ frame_entry_t *frame_entry = (frame_entry_t *) malloc(sizeof(frame_entry_t));
+ frame_entry->exit_thread = 1;
+
+ ADD_TO_QUEUE(context, this->threads[i].inbound_frame_queue, frame_entry);
+ }
+
+ for (int i = 0; i < context->num_downstream_filters; i++) {
+ pthread_join(this->threads[i].thread, NULL);
}
}
@@ -228,28 +206,22 @@ static void init(ID3ASFilterContext *context, AVDictionary *codec_options)
{
codec_t *this = context->priv_data;
- if (context->num_downstream_filters < 2) {
- this->pass_through = 1;
- }
- else {
- this->pass_through = 0;
- this->threads = (thread_struct *) malloc(sizeof(thread_struct) * context->num_downstream_filters);
+ this->threads = (thread_struct *) malloc(sizeof(thread_struct) * context->num_downstream_filters);
- for (int i = 0; i < context->num_downstream_filters; i++)
- {
- this->threads[i].thread_id = thread_id++;
- this->threads[i].context = context;
- this->threads[i].downstream_filter = context->downstream_filters[i];
- this->threads[i].codec_t = this;
- pthread_cond_init(&this->threads[i].complete, NULL);
- pthread_mutex_init(&this->threads[i].complete_mutex, NULL);
- pthread_mutex_lock(&this->threads[i].complete_mutex);
-
- INIT_QUEUE(this->threads[i].inbound_frame_queue);
-
- pthread_create(&this->threads[i].thread, NULL, &thread_proc, &this->threads[i]);
- }
- }
+ for (int i = 0; i < context->num_downstream_filters; i++)
+ {
+ this->threads[i].thread_id = thread_id++;
+ this->threads[i].context = context;
+ this->threads[i].downstream_filter = context->downstream_filters[i];
+ this->threads[i].codec_t = this;
+ pthread_cond_init(&this->threads[i].complete, NULL);
+ pthread_mutex_init(&this->threads[i].complete_mutex, NULL);
+ pthread_mutex_lock(&this->threads[i].complete_mutex);
+
+ INIT_QUEUE(this->threads[i].inbound_frame_queue);
+
+ pthread_create(&this->threads[i].thread, NULL, &thread_proc, &this->threads[i]);
+ }
}
static const AVOption options[] = {
1  c_src/effects_processor.c
View
@@ -40,7 +40,6 @@ static void process(ID3ASFilterContext *context, AVFrame *frame, AVRational time
ERROR("Error from get_frame");
exit(-1);
}
-
send_to_graph(context, this->output_frame, this->output_timebase);
av_frame_unref(this->output_frame);
3  c_src/video_encoded_input.c
View
@@ -20,7 +20,6 @@ typedef struct _codec_t
static int decode(ID3ASFilterContext *context, AVPacket *pkt)
{
-
codec_t *this = context->priv_data;
int got_frame = 0;
int len = avcodec_decode_video2(this->context, this->frame, &got_frame, pkt);
@@ -33,6 +32,8 @@ static int decode(ID3ASFilterContext *context, AVPacket *pkt)
}
else if (got_frame)
{
+ av_frame_make_writable(this->frame);
+
add_frame_info_to_frame(this->frame_info_queue, this->frame);
this->frame->pts = this->frame->pkt_pts;
18 c_src/video_raw_generator.c
View
@@ -22,7 +22,7 @@ typedef struct _codec_t
static int read_exact(int fd, unsigned char *buf, int len)
{
int i, got = 0;
-
+
do {
if ((i = read(fd, buf + got, len - got)) <= 0)
{
@@ -43,6 +43,13 @@ static void process(ID3ASFilterContext *context,
{
codec_t *this = context->priv_data;
+ this->frame->format = this->pixfmt;
+ this->frame->width = this->width;
+ this->frame->height = this->height;
+ this->frame->interlaced_frame = this->interlaced ? 1 : 0;
+
+ av_frame_get_buffer(this->frame, 32);
+
read_exact(this->device_fd, this->data, this->data_size);
avpicture_fill((AVPicture *) this->frame, this->data, this->pixfmt, this->width, this->height);
@@ -52,6 +59,8 @@ static void process(ID3ASFilterContext *context,
set_frame_metadata(this->frame, metadata);
send_to_graph(context, this->frame, NINETY_KHZ);
+
+ av_frame_unref(this->frame);
}
static void flush(ID3ASFilterContext *context)
@@ -64,14 +73,9 @@ static void init(ID3ASFilterContext *context, AVDictionary *codec_options)
codec_t *this = context->priv_data;
this->frame = av_frame_alloc();
- this->frame->format = this->pixfmt;
- this->frame->width = this->width;
- this->frame->height = this->height;
- this->frame->interlaced_frame = this->interlaced ? 1 : 0;
-
this->data_size = avpicture_fill((AVPicture *) this->frame, NULL, this->pixfmt, this->width, this->height);
this->data = malloc(this->data_size);
-
+
this->device_fd = open(this->device_name, O_RDONLY);
}
Please sign in to comment.
Something went wrong with that request. Please try again.