mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-13 11:03:43 +00:00
refactoring
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
const unsigned BLANK_JPG_WIDTH = 640;
|
const unsigned BLANK_JPG_WIDTH = 640;
|
||||||
const unsigned BLANK_JPG_HEIGHT = 480;
|
const unsigned BLANK_JPG_HEIGHT = 480;
|
||||||
|
|
||||||
const unsigned long BLANK_JPG_SIZE = 13845;
|
const size_t BLANK_JPG_SIZE = 13845;
|
||||||
|
|
||||||
const unsigned char BLANK_JPG_DATA[] = {
|
const unsigned char BLANK_JPG_DATA[] = {
|
||||||
0xFF, 0xD8, 0xFF, 0xE1, 0x09, 0x50, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x6E, 0x73, 0x2E, 0x61, 0x64, 0x6F, 0x62, 0x65,
|
0xFF, 0xD8, 0xFF, 0xE1, 0x09, 0x50, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x6E, 0x73, 0x2E, 0x61, 0x64, 0x6F, 0x62, 0x65,
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ static void _device_open_alloc_picbufs(struct device_t *dev) {
|
|||||||
|
|
||||||
dev->run->max_picture_size = ((dev->run->width * dev->run->height) << 1) * 2;
|
dev->run->max_picture_size = ((dev->run->width * dev->run->height) << 1) * 2;
|
||||||
for (unsigned index = 0; index < dev->run->n_buffers; ++index) {
|
for (unsigned index = 0; index < dev->run->n_buffers; ++index) {
|
||||||
LOG_DEBUG("Allocating picture buffer %u sized %lu bytes... ", index, dev->run->max_picture_size);
|
LOG_DEBUG("Allocating picture buffer %u sized %zu bytes... ", index, dev->run->max_picture_size);
|
||||||
A_CALLOC(dev->run->pictures[index].data, dev->run->max_picture_size);
|
A_CALLOC(dev->run->pictures[index].data, dev->run->max_picture_size);
|
||||||
dev->run->pictures[index].allocated = dev->run->max_picture_size;
|
dev->run->pictures[index].allocated = dev->run->max_picture_size;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ struct hw_buffer_t {
|
|||||||
|
|
||||||
struct picture_t {
|
struct picture_t {
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
unsigned long size;
|
size_t size;
|
||||||
unsigned long allocated;
|
size_t allocated;
|
||||||
long double grab_time;
|
long double grab_time;
|
||||||
long double encode_begin_time;
|
long double encode_begin_time;
|
||||||
long double encode_end_time;
|
long double encode_end_time;
|
||||||
@@ -65,7 +65,7 @@ struct device_runtime_t {
|
|||||||
// unsigned n_workers; // FIXME
|
// unsigned n_workers; // FIXME
|
||||||
struct hw_buffer_t *hw_buffers;
|
struct hw_buffer_t *hw_buffers;
|
||||||
struct picture_t *pictures;
|
struct picture_t *pictures;
|
||||||
unsigned long max_picture_size;
|
size_t max_picture_size;
|
||||||
bool capturing;
|
bool capturing;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ struct device_t {
|
|||||||
unsigned n_buffers;
|
unsigned n_buffers;
|
||||||
unsigned n_workers;
|
unsigned n_workers;
|
||||||
unsigned desired_fps;
|
unsigned desired_fps;
|
||||||
unsigned min_frame_size;
|
size_t min_frame_size;
|
||||||
bool persistent;
|
bool persistent;
|
||||||
unsigned timeout;
|
unsigned timeout;
|
||||||
unsigned error_delay;
|
unsigned error_delay;
|
||||||
|
|||||||
@@ -43,11 +43,11 @@ struct _jpeg_dest_manager_t {
|
|||||||
struct jpeg_destination_mgr mgr; // Default manager
|
struct jpeg_destination_mgr mgr; // Default manager
|
||||||
JOCTET *buffer; // Start of buffer
|
JOCTET *buffer; // Start of buffer
|
||||||
unsigned char *outbuffer_cursor;
|
unsigned char *outbuffer_cursor;
|
||||||
unsigned long *written;
|
size_t *written;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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, size_t *written);
|
||||||
|
|
||||||
static void _jpeg_write_scanlines_yuyv(
|
static void _jpeg_write_scanlines_yuyv(
|
||||||
struct jpeg_compress_struct *jpeg, const unsigned char *data,
|
struct jpeg_compress_struct *jpeg, const unsigned char *data,
|
||||||
@@ -114,7 +114,7 @@ void cpu_encoder_compress_buffer(struct device_t *dev, unsigned index, unsigned
|
|||||||
assert(dev->run->pictures[index].size <= dev->run->max_picture_size);
|
assert(dev->run->pictures[index].size <= dev->run->max_picture_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, size_t *written) {
|
||||||
struct _jpeg_dest_manager_t *dest;
|
struct _jpeg_dest_manager_t *dest;
|
||||||
|
|
||||||
if (jpeg->dest == NULL) {
|
if (jpeg->dest == NULL) {
|
||||||
|
|||||||
@@ -173,8 +173,8 @@ int omx_encoder_prepare_live(struct omx_encoder_t *omx, struct device_t *dev, un
|
|||||||
|
|
||||||
int omx_encoder_compress_buffer(struct omx_encoder_t *omx, struct device_t *dev, unsigned index) {
|
int omx_encoder_compress_buffer(struct omx_encoder_t *omx, struct device_t *dev, unsigned index) {
|
||||||
OMX_ERRORTYPE error;
|
OMX_ERRORTYPE error;
|
||||||
unsigned slice_size = omx->input_buffer->nAllocLen;
|
size_t slice_size = omx->input_buffer->nAllocLen;
|
||||||
unsigned pos = 0;
|
size_t pos = 0;
|
||||||
|
|
||||||
if ((error = OMX_FillThisBuffer(omx->encoder, omx->output_buffer)) != OMX_ErrorNone) {
|
if ((error = OMX_FillThisBuffer(omx->encoder, omx->output_buffer)) != OMX_ErrorNone) {
|
||||||
LOG_OMX_ERROR(error, "Failed to request filling of the output buffer on encoder");
|
LOG_OMX_ERROR(error, "Failed to request filling of the output buffer on encoder");
|
||||||
|
|||||||
@@ -497,7 +497,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
|
|||||||
if (!client->advance_headers) {
|
if (!client->advance_headers) {
|
||||||
assert(evbuffer_add_printf(buf,
|
assert(evbuffer_add_printf(buf,
|
||||||
"Content-Type: image/jpeg" RN
|
"Content-Type: image/jpeg" RN
|
||||||
"Content-Length: %lu" RN
|
"Content-Length: %zu" RN
|
||||||
"X-Timestamp: %.06Lf" RN
|
"X-Timestamp: %.06Lf" RN
|
||||||
"%s",
|
"%s",
|
||||||
EXPOSED(picture.size) * sizeof(*EXPOSED(picture.data)),
|
EXPOSED(picture.size) * sizeof(*EXPOSED(picture.data)),
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ static void *_stream_worker_thread(void *v_ctx) {
|
|||||||
A_PTHREAD_M_UNLOCK(ctx->last_comp_time_mutex);
|
A_PTHREAD_M_UNLOCK(ctx->last_comp_time_mutex);
|
||||||
|
|
||||||
LOG_VERBOSE(
|
LOG_VERBOSE(
|
||||||
"Compressed JPEG size=%ld; time=%0.3Lf; worker=%u; buffer=%u",
|
"Compressed JPEG size=%zu; time=%0.3Lf; worker=%u; buffer=%u",
|
||||||
PICTURE(size), last_comp_time, ctx->number, ctx->buf_index
|
PICTURE(size), last_comp_time, ctx->number, ctx->buf_index
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ def main():
|
|||||||
|
|
||||||
text = ",\n\t".join(", ".join(row) for row in rows)
|
text = ",\n\t".join(", ".join(row) for row in rows)
|
||||||
text = "const unsigned char %s_JPG_DATA[] = {\n\t%s\n};\n" % (prefix, text)
|
text = "const unsigned char %s_JPG_DATA[] = {\n\t%s\n};\n" % (prefix, text)
|
||||||
text = "const unsigned long %s_JPG_SIZE = %d;\n\n" % (prefix, len(jpg_data)) + text
|
text = "const size_t %s_JPG_SIZE = %d;\n\n" % (prefix, len(jpg_data)) + text
|
||||||
text = "const unsigned %s_JPG_HEIGHT = %d;\n\n" % (prefix, height) + text
|
text = "const unsigned %s_JPG_HEIGHT = %d;\n\n" % (prefix, height) + text
|
||||||
text = "const unsigned %s_JPG_WIDTH = %d;\n" % (prefix, width) + text
|
text = "const unsigned %s_JPG_WIDTH = %d;\n" % (prefix, width) + text
|
||||||
text = textwrap.dedent("""
|
text = textwrap.dedent("""
|
||||||
|
|||||||
Reference in New Issue
Block a user