Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
better stats and tweaks.
Browse files Browse the repository at this point in the history
Change-Id: I0dde132d43569a7c0a584ba77dd4000098d5d16c
  • Loading branch information
jimbankoski committed Feb 3, 2015
1 parent 82fea0f commit 7ebefb6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ C_DEPS := \
UNAME := $(shell uname)

ifeq ($(UNAME), Linux)
C_FLAGS = -DLINUX -O0 -g3 -Wall -c -fmessage-length=0 -m64 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
C_FLAGS = -DLINUX -O3 -g3 -Wall -c -fmessage-length=0 -m64 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)"
RLIBS := -lvpx -lpthread -lrt -lSDL
SLIBS := -lvpx -lpthread -lrt
L_FLAGS := -m64
Expand Down
9 changes: 5 additions & 4 deletions grabcompressandsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ int start_capture(void) {
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
setfps.parm.capture.timeperframe.numerator = 1;
setfps.parm.capture.timeperframe.denominator = capture_frame_rate;

FAIL_ON_NONZERO(ioctl(fd, VIDIOC_S_PARM, &setfps))


memset(&rb, 0, sizeof(struct v4l2_requestbuffers));
rb.count = NB_BUFFER;
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
Expand Down Expand Up @@ -797,9 +797,9 @@ int main(int argc, char *argv[]) {
cfg.rc_min_quantizer = 20;
cfg.rc_max_quantizer = 50;
cfg.rc_dropframe_thresh = 1;
cfg.rc_buf_optimal_sz = 1000;
cfg.rc_buf_initial_sz = 1000;
cfg.rc_buf_sz = 1000;
cfg.rc_buf_optimal_sz = 200;
cfg.rc_buf_initial_sz = 200;
cfg.rc_buf_sz = 200;
cfg.g_error_resilient = 1;
cfg.kf_mode = VPX_KF_DISABLED;
cfg.kf_max_dist = 999999;
Expand Down Expand Up @@ -992,6 +992,7 @@ int main(int argc, char *argv[]) {
vpx_codec_control_(&encoder, VP9E_SET_TILE_COLUMNS, 2);
vpx_codec_control_(&encoder, VP9E_SET_FRAME_PARALLEL_DECODING, 1);
vpx_codec_control_(&encoder, VP8E_SET_ENABLEAUTOALTREF, 0);
vpx_codec_control_(&encoder, VP8E_SET_GF_CBR_BOOST_PCT, 200);
}
create_packetizer(&x, XOR, fec_numerator, fec_denominator);
//HRE(CoInitialize(NULL));
Expand Down
53 changes: 33 additions & 20 deletions receivedecompressandplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -548,19 +548,14 @@ void check_recovery(DEPACKETIZER *p, PACKET *x) {
given_up = 0;
}
}
double bits = 0;
unsigned short last = 0;

int read_packet(DEPACKETIZER *p, tc8 *data, unsigned int size) {
PACKET *x = (PACKET *) data;
unsigned int skip_fill = 0;
x->seq = R2(x->seq);
x->timestamp = R4(x->timestamp);
//vpxlog_dbg(LOG_PACKET, "Received Packet %d, %u : new: %d, frame type: "
// "%d given_up: %d oldest: %d \n", x->seq, p->p[x->seq&PSM].timestamp,
// x->new_frame, x->frame_type, given_up, p->oldest_seq);

// random drops
if ((rand() & 1023) < drop_simulation)
return 0;

// wrong ssrc exit
if (p->ssrc != x->ssrc)
Expand Down Expand Up @@ -995,30 +990,26 @@ int age_skip_store(DEPACKETIZER *p, struct vpxsocket *vpx_sock,
return 0;
}
#define SHOW_WINDOW 1
#define DEBUG_FILES 1
//#define DEBUG_FILES 1
#ifdef DEBUG_FILES
void debug_frame(FILE *outFile, vpx_image_t *img) {
unsigned char *in = img->planes[VPX_PLANE_Y];

for (int i = 0; i < display_height; i++, in +=
img->stride[VPX_PLANE_Y]) {
for (int i = 0; i < display_height; i++, in += img->stride[VPX_PLANE_Y]) {
fwrite(in, display_width, 1, outFile);
}

in = img->planes[VPX_PLANE_U];

for (int i = 0; i < display_height / 2; i++, in +=
img->stride[VPX_PLANE_U]) {
for (int i = 0; i < display_height / 2; i++, in += img->stride[VPX_PLANE_U]) {
fwrite(in, display_width / 2, 1, outFile);
}

in = img->planes[VPX_PLANE_V];

for (int i = 0; i < display_height / 2; i++, in +=
img->stride[VPX_PLANE_V]) {
for (int i = 0; i < display_height / 2; i++, in += img->stride[VPX_PLANE_V]) {
fwrite(in, display_width / 2, 1, outFile);
}

}
#endif

Expand Down Expand Up @@ -1148,10 +1139,10 @@ int main(int argc, char *argv[]) {
buf = (uint8_t *) malloc(display_width * display_height * 3 / 2);

/* Config post processing settings for decoder */
ppcfg.post_proc_flag = VP8_DEMACROBLOCK | VP8_DEBLOCK;
ppcfg.deblocking_level = 4;
ppcfg.noise_level = 1;
vpx_codec_control(&decoder, VP8_SET_POSTPROC, &ppcfg);
//ppcfg.post_proc_flag = VP8_DEMACROBLOCK | VP8_DEBLOCK;
//ppcfg.deblocking_level = 4;
//ppcfg.noise_level = 44;
//vpx_codec_control(&decoder, VP8_SET_POSTPROC, &ppcfg);

create_depacketizer(&y);

Expand Down Expand Up @@ -1213,6 +1204,7 @@ int main(int argc, char *argv[]) {
setup_surface();
#endif

unsigned int frames_shown = 0;
/* Message loop for display window's thread */
while (!_kbhit() && signalquit) {
rc = vpx_net_recvfrom(&vpx_sock, one_packet, sizeof(one_packet),
Expand All @@ -1229,7 +1221,12 @@ int main(int argc, char *argv[]) {
if (bytes_read) {
unsigned int timestamp;
unsigned int size;
read_packet(&y, one_packet, bytes_read);

// random drops
if ((rand() & 1023) > drop_simulation) {
read_packet(&y, one_packet, bytes_read);
bits += bytes_read * 8;
}

while (get_frame(&y, compressed_video_buffer,
sizeof(compressed_video_buffer), &size, &timestamp)) {
Expand Down Expand Up @@ -1264,6 +1261,8 @@ int main(int argc, char *argv[]) {
img = vpx_codec_get_frame(&decoder, &iter);
#ifdef SHOW_WINDOW
show_frame(img);
frames_shown++;

#endif
#ifdef DEBUG_FILES
debug_frame(out_file, img);
Expand Down Expand Up @@ -1292,6 +1291,20 @@ int main(int argc, char *argv[]) {
} else
age_skip_store(&y, &vpx_sock2, &address2);

// Collect some stats
unsigned short elapsed = (unsigned short) ((get_time() & 0xffff) - last);
if (bits != 0 && elapsed > 1000) {
double bitrate = 1.0 * bits / elapsed;
double framerate = 1000.0 * frames_shown / elapsed;
bits = 0;
frames_shown = 0;
printf("bitrate: %14.4f fps: %14.4f\n", bitrate, framerate);
last = (unsigned short) (get_time() & 0xffff);
}
if (bits == 0)
last = (unsigned short) (get_time() & 0xffff);


}
vpxlog_dbg(ERRORS, "Exited successfully.\n");

Expand Down

0 comments on commit 7ebefb6

Please sign in to comment.