Skip to content

Commit

Permalink
two things conflated in this commit: conversion from wayland to gtk a…
Browse files Browse the repository at this point in the history
…pp, and addition of fftw for spectrogram. fun.
  • Loading branch information
dsheeler committed Mar 5, 2017
1 parent a679967 commit 0543ff4
Show file tree
Hide file tree
Showing 4 changed files with 400 additions and 504 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ LFLAGS = $(shell pkg-config --libs wayland-client) \
$(shell pkg-config --libs wayland-cursor) \
$(shell pkg-config --libs cairo) \
$(shell pkg-config --libs pangocairo) \
$(shell pkg-config --libs gtk+-3.0) \
$(shell pkg-config --libs fftw3) \
-lccv -lm -lpng -ljpeg -lswscale -lavutil -lswresample \
-lavformat -lavcodec -lpthread -ljack
LIBS =
CFLAGS = -Wall -g $(shell pkg-config --cflags pangocairo)
CFLAGS = -Wall -g $(shell pkg-config --cflags pangocairo) \
$(shell pkg-config --cflags gtk+-3.0) \
$(shell pkg-config --cflags fftw3)
SRCS = v4l2_wayland.c muxing.c sound_shape.c midi.c kmeter.c
OBJS = $(SRCS:.c=.o)
HDRS = muxing.h sound_shape.h midi.h v4l2_wayland.h kmeter.h
Expand Down
10 changes: 4 additions & 6 deletions muxing.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int write_audio_frame(dingle_dots_t *dd, AVFormatContext *oc,
exit(1);
}
frame = ost->frame;
printf("audio time: %f\n", ost->samples_count / (double) c->sample_rate);
//printf("audio time: %f\n", ost->samples_count / (double) c->sample_rate);
frame->pts = av_rescale_q(ost->samples_count,
(AVRational){1, c->sample_rate}, c->time_base);
av_init_packet(&pkt);
Expand Down Expand Up @@ -274,7 +274,7 @@ static void open_video(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, A
fprintf(stderr, "Could not allocate video frame\n");
exit(1);
}
ost->frame->format = AV_PIX_FMT_RGB32;
ost->frame->format = AV_PIX_FMT_RGBA;
ost->frame->width = width;
ost->frame->height = height;
ost->out_frame.size = 4 * width * height;
Expand Down Expand Up @@ -327,23 +327,21 @@ int get_video_frame(OutputStream *ost, AVFrame **ret_frame) {
now = &ost->out_frame.ts;
diff = now->tv_sec + 1e-9*now->tv_nsec - (ost->first_time.tv_sec +
1e-9*ost->first_time.tv_nsec);
printf("video time : %f\n", diff);
//printf("video time : %f\n", diff);
ost->next_pts = (int) c->time_base.den * diff / c->time_base.num;
if (!ost->sws_ctx) {
ost->sws_ctx = sws_getContext(c->width, c->height,
AV_PIX_FMT_RGB32, c->width, c->height, c->pix_fmt,
AV_PIX_FMT_BGRA, c->width, c->height, c->pix_fmt,
SCALE_FLAGS, NULL, NULL, NULL);
if (!ost->sws_ctx) {
fprintf(stderr,
"Could not initialize the conversion context\n");
exit(1);
}
}
printf("before sws_scale get_video_frame \n");
sws_scale(ost->sws_ctx, (const uint8_t * const *)ost->frame->data,
ost->frame->linesize, 0, c->height, ost->tmp_frame->data,
ost->tmp_frame->linesize);
printf("after sws_scale get_video_frame\n");
ost->tmp_frame->pts = ost->frame->pts = ost->next_pts;
*ret_frame = ost->tmp_frame;
return 0;
Expand Down
Loading

0 comments on commit 0543ff4

Please sign in to comment.