mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-04-11 00:56:13 +00:00
refactoring
This commit is contained in:
@@ -66,7 +66,7 @@ static boolean _jpeg_empty_output_buffer(j_compress_ptr jpeg);
|
|||||||
static void _jpeg_term_destination(j_compress_ptr jpeg);
|
static void _jpeg_term_destination(j_compress_ptr jpeg);
|
||||||
|
|
||||||
|
|
||||||
unsigned long jpeg_compress_buffer(struct device_t *dev, int index) {
|
void jpeg_compress_buffer(struct device_t *dev, int index) {
|
||||||
// This function based on compress_image_to_jpeg() from mjpg-streamer
|
// This function based on compress_image_to_jpeg() from mjpg-streamer
|
||||||
|
|
||||||
struct jpeg_compress_struct jpeg;
|
struct jpeg_compress_struct jpeg;
|
||||||
@@ -107,7 +107,6 @@ unsigned long jpeg_compress_buffer(struct device_t *dev, int index) {
|
|||||||
jpeg_destroy_compress(&jpeg);
|
jpeg_destroy_compress(&jpeg);
|
||||||
free(line_buffer);
|
free(line_buffer);
|
||||||
assert(dev->run->pictures[index].size > 0);
|
assert(dev->run->pictures[index].size > 0);
|
||||||
return dev->run->pictures[index].size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _jpeg_set_dest_picture(j_compress_ptr jpeg, unsigned char *picture, unsigned long *written) {
|
static void _jpeg_set_dest_picture(j_compress_ptr jpeg, unsigned char *picture, unsigned long *written) {
|
||||||
|
|||||||
@@ -26,4 +26,4 @@
|
|||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
|
||||||
|
|
||||||
unsigned long jpeg_compress_buffer(struct device_t *dev, int index);
|
void jpeg_compress_buffer(struct device_t *dev, int index);
|
||||||
|
|||||||
@@ -390,7 +390,6 @@ static void *_stream_worker_thread(void *v_ctx) {
|
|||||||
A_PTHREAD_M_UNLOCK(ctx->has_job_mutex);
|
A_PTHREAD_M_UNLOCK(ctx->has_job_mutex);
|
||||||
|
|
||||||
if (!*ctx->workers_stop) {
|
if (!*ctx->workers_stop) {
|
||||||
unsigned long compressed;
|
|
||||||
time_t start_sec;
|
time_t start_sec;
|
||||||
time_t stop_sec;
|
time_t stop_sec;
|
||||||
long start_msec;
|
long start_msec;
|
||||||
@@ -401,7 +400,7 @@ static void *_stream_worker_thread(void *v_ctx) {
|
|||||||
|
|
||||||
LOG_DEBUG("Worker %d compressing JPEG ...", ctx->index);
|
LOG_DEBUG("Worker %d compressing JPEG ...", ctx->index);
|
||||||
|
|
||||||
compressed = jpeg_compress_buffer(ctx->dev, ctx->index);
|
jpeg_compress_buffer(ctx->dev, ctx->index);
|
||||||
|
|
||||||
if (_stream_release_buffer(ctx->dev, &ctx->buf_info) == 0) {
|
if (_stream_release_buffer(ctx->dev, &ctx->buf_info) == 0) {
|
||||||
*ctx->has_job = false;
|
*ctx->has_job = false;
|
||||||
@@ -417,7 +416,10 @@ static void *_stream_worker_thread(void *v_ctx) {
|
|||||||
*ctx->last_comp_time = last_comp_time;
|
*ctx->last_comp_time = last_comp_time;
|
||||||
A_PTHREAD_M_UNLOCK(ctx->last_comp_time_mutex);
|
A_PTHREAD_M_UNLOCK(ctx->last_comp_time_mutex);
|
||||||
|
|
||||||
LOG_PERF("Compressed JPEG size=%ld; time=%0.3Lf (worker %d)", compressed, last_comp_time, ctx->index);
|
LOG_PERF(
|
||||||
|
"Compressed JPEG size=%ld; time=%0.3Lf (worker %d)",
|
||||||
|
ctx->dev->run->pictures[ctx->index].size, last_comp_time, ctx->index
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
*ctx->job_failed = true;
|
*ctx->job_failed = true;
|
||||||
*ctx->has_job = false;
|
*ctx->has_job = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user