refactoring

This commit is contained in:
Devaev Maxim 2019-03-05 14:23:11 +03:00
parent 502aa3a0cb
commit f439f37526
8 changed files with 14 additions and 14 deletions

View File

@ -23,7 +23,7 @@
const unsigned BLANK_JPG_WIDTH = 640;
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[] = {
0xFF, 0xD8, 0xFF, 0xE1, 0x09, 0x50, 0x68, 0x74, 0x74, 0x70, 0x3A, 0x2F, 0x2F, 0x6E, 0x73, 0x2E, 0x61, 0x64, 0x6F, 0x62, 0x65,

View File

@ -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;
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);
dev->run->pictures[index].allocated = dev->run->max_picture_size;
}

View File

@ -49,8 +49,8 @@ struct hw_buffer_t {
struct picture_t {
unsigned char *data;
unsigned long size;
unsigned long allocated;
size_t size;
size_t allocated;
long double grab_time;
long double encode_begin_time;
long double encode_end_time;
@ -65,7 +65,7 @@ struct device_runtime_t {
// unsigned n_workers; // FIXME
struct hw_buffer_t *hw_buffers;
struct picture_t *pictures;
unsigned long max_picture_size;
size_t max_picture_size;
bool capturing;
};
@ -98,7 +98,7 @@ struct device_t {
unsigned n_buffers;
unsigned n_workers;
unsigned desired_fps;
unsigned min_frame_size;
size_t min_frame_size;
bool persistent;
unsigned timeout;
unsigned error_delay;

View File

@ -43,11 +43,11 @@ struct _jpeg_dest_manager_t {
struct jpeg_destination_mgr mgr; // Default manager
JOCTET *buffer; // Start of buffer
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(
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);
}
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;
if (jpeg->dest == NULL) {

View File

@ -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) {
OMX_ERRORTYPE error;
unsigned slice_size = omx->input_buffer->nAllocLen;
unsigned pos = 0;
size_t slice_size = omx->input_buffer->nAllocLen;
size_t pos = 0;
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");

View File

@ -497,7 +497,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
if (!client->advance_headers) {
assert(evbuffer_add_printf(buf,
"Content-Type: image/jpeg" RN
"Content-Length: %lu" RN
"Content-Length: %zu" RN
"X-Timestamp: %.06Lf" RN
"%s",
EXPOSED(picture.size) * sizeof(*EXPOSED(picture.data)),

View File

@ -454,7 +454,7 @@ static void *_stream_worker_thread(void *v_ctx) {
A_PTHREAD_M_UNLOCK(ctx->last_comp_time_mutex);
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
);
} else {

View File

@ -46,7 +46,7 @@ def main():
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 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_WIDTH = %d;\n" % (prefix, width) + text
text = textwrap.dedent("""