Skip to content

Commit

Permalink
Rename _DEBUG to KVZ_DEBUG
Browse files Browse the repository at this point in the history
  • Loading branch information
ari-koivula committed Sep 15, 2015
1 parent ec2d8d6 commit f1ac0e6
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/bitstream.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void kvz_bitstream_align(bitstream_t *stream);
void kvz_bitstream_align_zero(bitstream_t *stream);

/* In debug mode print out some extra info */
#ifdef NOTDEFINED//_DEBUG
#ifdef KVZ_DEBUG_PRINT_CABAC
/* Counter to keep up with bits written */
#define WRITE_U(stream, data, bits, name) { printf("%-40s u(%d) : %d\n", name,bits,data); kvz_bitstream_put(stream,data,bits);}
#define WRITE_UE(stream, data, name) { printf("%-40s ue(v): %d\n", name,data); bitstream_put_ue(stream,data);}
Expand Down
4 changes: 2 additions & 2 deletions src/encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ encoder_control_t* kvz_encoder_control_init(const kvz_config *const cfg) {
printf("Wavefront Parallel Processing: disabled\n");
}
printf("\n");
#endif //_DEBUG
#endif //KVZ_DEBUG
}

assert(WITHIN(cfg->pu_depth_inter.min, PU_DEPTH_INTER_MIN, PU_DEPTH_INTER_MAX));
Expand Down Expand Up @@ -512,7 +512,7 @@ void kvz_encoder_control_input_init(encoder_control_t * const encoder,
encoder->in.pixels_per_pic = encoder->in.width * encoder->in.height;


#ifdef _DEBUG
#ifdef KVZ_DEBUG
if (width != encoder->in.width || height != encoder->in.height) {
printf("Picture buffer has been extended to be a multiple of the smallest block size:\r\n");
printf(" Width = %d (%d), Height = %d (%d)\r\n", width, encoder->in.width, height,
Expand Down
10 changes: 5 additions & 5 deletions src/encoder_state-bitstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void encoder_state_write_bitstream_vid_parameter_set(encoder_state_t * co
{
bitstream_t * const stream = &state->stream;
int i;
#ifdef _DEBUG
#ifdef KVZ_DEBUG
printf("=========== Video Parameter Set ID: 0 ===========\n");
#endif

Expand Down Expand Up @@ -181,7 +181,7 @@ static void encoder_state_write_bitstream_VUI(encoder_state_t * const state)
{
bitstream_t * const stream = &state->stream;
const encoder_control_t * const encoder = state->encoder_control;
#ifdef _DEBUG
#ifdef KVZ_DEBUG
printf("=========== VUI Set ID: 0 ===========\n");
#endif
if (encoder->vui.sar_width > 0 && encoder->vui.sar_height > 0) {
Expand Down Expand Up @@ -283,7 +283,7 @@ static void encoder_state_write_bitstream_seq_parameter_set(encoder_state_t * co
bitstream_t * const stream = &state->stream;
const encoder_control_t * encoder = state->encoder_control;

#ifdef _DEBUG
#ifdef KVZ_DEBUG
printf("=========== Sequence Parameter Set ID: 0 ===========\n");
#endif

Expand Down Expand Up @@ -388,7 +388,7 @@ static void encoder_state_write_bitstream_pic_parameter_set(encoder_state_t * co
{
const encoder_control_t * const encoder = state->encoder_control;
bitstream_t * const stream = &state->stream;
#ifdef _DEBUG
#ifdef KVZ_DEBUG
printf("=========== Picture Parameter Set ID: 0 ===========\n");
#endif
WRITE_UE(stream, 0, "pic_parameter_set_id");
Expand Down Expand Up @@ -649,7 +649,7 @@ void kvz_encoder_state_write_bitstream_slice_header(encoder_state_t * const stat
}
} else ref_negative = state->global->ref->used_size;

#ifdef _DEBUG
#ifdef KVZ_DEBUG
printf("=========== Slice ===========\n");
#endif
WRITE_U(stream, (state->slice->start_in_rs == 0), 1, "first_slice_segment_in_pic_flag");
Expand Down
8 changes: 4 additions & 4 deletions src/encoder_state-ctors_dtors.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static void encoder_state_config_wfrow_finalize(encoder_state_t * const state) {
//Nothing to do (yet?)
}

#ifdef _DEBUG_PRINT_THREADING_INFO
#ifdef KVZ_DEBUG_PRINT_THREADING_INFO
static void encoder_state_dump_graphviz(const encoder_state_t * const state) {
int i;

Expand Down Expand Up @@ -267,7 +267,7 @@ static void encoder_state_dump_graphviz(const encoder_state_t * const state) {
printf("\n\n\n\n\n");
}
}
#endif //_DEBUG
#endif //KVZ_DEBUG_PRINT_THREADING_INFO

int kvz_encoder_state_init(encoder_state_t * const child_state, encoder_state_t * const parent_state) {
//We require that, if parent_state is NULL:
Expand Down Expand Up @@ -635,9 +635,9 @@ int kvz_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
}
}

#ifdef _DEBUG_PRINT_THREADING_INFO
#ifdef KVZ_DEBUG_PRINT_THREADING_INFO
if (!parent_state) encoder_state_dump_graphviz(child_state);
#endif //_DEBUG
#endif //KVZ_DEBUG_PRINT_THREADING_INFO
return 1;
}

Expand Down
14 changes: 7 additions & 7 deletions src/encoderstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@ static void encoder_state_encode_leaf(encoder_state_t * const state) {

encoder_state_worker_encode_lcu(&state->lcu_order[i]);

#ifdef _DEBUG
#ifdef KVZ_DEBUG
{
const lcu_order_element_t * const lcu = &state->lcu_order[i];
PERFORMANCE_MEASURE_END(KVZ_PERF_LCU, state->encoder_control->threadqueue, "type=encode_lcu,frame=%d,tile=%d,slice=%d,px_x=%d-%d,px_y=%d-%d", state->global->frame, state->tile->id, state->slice->id, lcu->position_px.x + state->tile->lcu_offset_x * LCU_WIDTH, lcu->position_px.x + state->tile->lcu_offset_x * LCU_WIDTH + lcu->size.x - 1, lcu->position_px.y + state->tile->lcu_offset_y * LCU_WIDTH, lcu->position_px.y + state->tile->lcu_offset_y * LCU_WIDTH + lcu->size.y - 1);
}
#endif //_DEBUG
#endif //KVZ_DEBUG
}

if (state->encoder_control->sao_enable) {
Expand All @@ -348,7 +348,7 @@ static void encoder_state_encode_leaf(encoder_state_t * const state) {

for (int i = 0; i < state->lcu_order_count; ++i) {
const lcu_order_element_t * const lcu = &state->lcu_order[i];
#ifdef _DEBUG
#ifdef KVZ_DEBUG
char job_description[256];
sprintf(job_description, "type=encode_lcu,frame=%d,tile=%d,slice=%d,px_x=%d-%d,px_y=%d-%d", state->global->frame, state->tile->id, state->slice->id, lcu->position_px.x + state->tile->lcu_offset_x * LCU_WIDTH, lcu->position_px.x + state->tile->lcu_offset_x * LCU_WIDTH + lcu->size.x - 1, lcu->position_px.y + state->tile->lcu_offset_y * LCU_WIDTH, lcu->position_px.y + state->tile->lcu_offset_y * LCU_WIDTH + lcu->size.y - 1);
#else
Expand Down Expand Up @@ -410,7 +410,7 @@ static void encoder_state_worker_encode_children(void * opaque) {
PERFORMANCE_MEASURE_END(KVZ_PERF_BSLEAF, sub_state->encoder_control->threadqueue, "type=encoder_state_write_bitstream_leaf,frame=%d,tile=%d,slice=%d,px_x=%d-%d,px_y=%d-%d", sub_state->global->frame, sub_state->tile->id, sub_state->slice->id, sub_state->lcu_order[0].position_px.x + sub_state->tile->lcu_offset_x * LCU_WIDTH, sub_state->lcu_order[sub_state->lcu_order_count - 1].position_px.x + sub_state->lcu_order[sub_state->lcu_order_count - 1].size.x + sub_state->tile->lcu_offset_x * LCU_WIDTH - 1, sub_state->lcu_order[0].position_px.y + sub_state->tile->lcu_offset_y * LCU_WIDTH, sub_state->lcu_order[sub_state->lcu_order_count - 1].position_px.y + sub_state->lcu_order[sub_state->lcu_order_count - 1].size.y + sub_state->tile->lcu_offset_y * LCU_WIDTH - 1);
} else {
threadqueue_job_t *job;
#ifdef _DEBUG
#ifdef KVZ_DEBUG
char job_description[256];
sprintf(job_description, "type=encoder_state_write_bitstream_leaf,frame=%d,tile=%d,slice=%d,px_x=%d-%d,px_y=%d-%d", sub_state->global->frame, sub_state->tile->id, sub_state->slice->id, sub_state->lcu_order[0].position_px.x + sub_state->tile->lcu_offset_x * LCU_WIDTH, sub_state->lcu_order[sub_state->lcu_order_count-1].position_px.x + sub_state->lcu_order[sub_state->lcu_order_count-1].size.x + sub_state->tile->lcu_offset_x * LCU_WIDTH - 1, sub_state->lcu_order[0].position_px.y + sub_state->tile->lcu_offset_y * LCU_WIDTH, sub_state->lcu_order[sub_state->lcu_order_count-1].position_px.y + sub_state->lcu_order[sub_state->lcu_order_count-1].size.y + sub_state->tile->lcu_offset_y * LCU_WIDTH - 1);
#else
Expand Down Expand Up @@ -525,7 +525,7 @@ static void encoder_state_encode(encoder_state_t * const main_state) {
for (i=0; main_state->children[i].encoder_control; ++i) {
//If we don't have wavefronts, parallelize encoding of children.
if (main_state->children[i].type != ENCODER_STATE_TYPE_WAVEFRONT_ROW) {
#ifdef _DEBUG
#ifdef KVZ_DEBUG
char job_description[256];
switch (main_state->children[i].type) {
case ENCODER_STATE_TYPE_TILE:
Expand Down Expand Up @@ -568,7 +568,7 @@ static void encoder_state_encode(encoder_state_t * const main_state) {
for (y = 0; y < frame->height_in_lcu; ++y) {
worker_sao_reconstruct_lcu_data *data = MALLOC(worker_sao_reconstruct_lcu_data, 1);
threadqueue_job_t *job;
#ifdef _DEBUG
#ifdef KVZ_DEBUG
char job_description[256];
sprintf(job_description, "type=sao,frame=%d,tile=%d,px_x=%d-%d,px_y=%d-%d", main_state->global->frame, main_state->tile->id, main_state->tile->lcu_offset_x * LCU_WIDTH, main_state->tile->lcu_offset_x * LCU_WIDTH + main_state->tile->frame->width - 1, (main_state->tile->lcu_offset_y + y) * LCU_WIDTH, MIN(main_state->tile->lcu_offset_y * LCU_WIDTH + main_state->tile->frame->height, (main_state->tile->lcu_offset_y + y + 1) * LCU_WIDTH)-1);
#else
Expand Down Expand Up @@ -834,7 +834,7 @@ void kvz_encode_one_frame(encoder_state_t * const state)
//kvz_threadqueue_flush(main_state->encoder_control->threadqueue);
{
threadqueue_job_t *job;
#ifdef _DEBUG
#ifdef KVZ_DEBUG
char job_description[256];
sprintf(job_description, "type=write_bitstream,frame=%d", state->global->frame);
#else
Expand Down
4 changes: 2 additions & 2 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
lcu_t *const lcu = &work_tree[depth];

int x_local = (x&0x3f), y_local = (y&0x3f);
#ifdef _DEBUG
#ifdef KVZ_DEBUG
int debug_split = 0;
#endif
PERFORMANCE_MEASURE_START(KVZ_PERF_SEARCHCU);
Expand Down Expand Up @@ -678,7 +678,7 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
// Copy split modes to this depth.
cost = split_cost;
work_tree_copy_up(x, y, depth, work_tree);
#if _DEBUG
#if KVZ_DEBUG
debug_split = 1;
#endif
} else if (depth > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/strategyselector.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "global.h"

#if defined(_DEBUG) && !defined(DEBUG_STRATEGYSELECTOR)
#if defined(KVZ_DEBUG) && !defined(DEBUG_STRATEGYSELECTOR)
# define DEBUG_STRATEGYSELECTOR
#endif

Expand Down
42 changes: 21 additions & 21 deletions src/threadqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
#include <stdlib.h>
#include <string.h>

#ifdef _DEBUG
#ifdef KVZ_DEBUG
#include <string.h>
#endif //_DEBUG
#endif //KVZ_DEBUG

#include "global.h"
#include "threadqueue.h"
Expand Down Expand Up @@ -81,9 +81,9 @@ static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) {
threadqueue_queue_t * const threadqueue = threadqueue_worker_spec->threadqueue;
threadqueue_job_t * next_job = NULL;

#ifdef _DEBUG
#ifdef KVZ_DEBUG
GET_TIME(&threadqueue->debug_clock_thread_start[threadqueue_worker_spec->worker_id]);
#endif //_DEBUG
#endif //KVZ_DEBUG

for(;;) {
int i = 0;
Expand Down Expand Up @@ -148,17 +148,17 @@ static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) {
//Unlock the queue
PTHREAD_UNLOCK(&threadqueue->lock);

#ifdef _DEBUG
#ifdef KVZ_DEBUG
job->debug_worker_id = threadqueue_worker_spec->worker_id;
GET_TIME(&job->debug_clock_start);
#endif //_DEBUG
#endif //KVZ_DEBUG

job->fptr(job->arg);

#ifdef _DEBUG
#ifdef KVZ_DEBUG
job->debug_worker_id = threadqueue_worker_spec->worker_id;
GET_TIME(&job->debug_clock_stop);
#endif //_DEBUG
#endif //KVZ_DEBUG

//Re-lock the job to update its status and treat its dependencies
PTHREAD_LOCK(&job->lock);
Expand Down Expand Up @@ -216,11 +216,11 @@ static void* threadqueue_worker(void* threadqueue_worker_spec_opaque) {
assert(threadqueue->stop);
--threadqueue->threads_running;

#ifdef _DEBUG
#ifdef KVZ_DEBUG
GET_TIME(&threadqueue->debug_clock_thread_end[threadqueue_worker_spec->worker_id]);

fprintf(threadqueue->debug_log, "\t%d\t-\t%lf\t+%lf\t-\tthread\n", threadqueue_worker_spec->worker_id, CLOCK_T_AS_DOUBLE(threadqueue->debug_clock_thread_start[threadqueue_worker_spec->worker_id]), CLOCK_T_DIFF(threadqueue->debug_clock_thread_start[threadqueue_worker_spec->worker_id], threadqueue->debug_clock_thread_end[threadqueue_worker_spec->worker_id]));
#endif //_DEBUG
#endif //KVZ_DEBUG

PTHREAD_UNLOCK(&threadqueue->lock);

Expand Down Expand Up @@ -259,13 +259,13 @@ int kvz_threadqueue_init(threadqueue_queue_t * const threadqueue, int thread_cou
fprintf(stderr, "Could not malloc threadqueue->threads!\n");
return 0;
}
#ifdef _DEBUG
#ifdef KVZ_DEBUG
threadqueue->debug_clock_thread_start = MALLOC(CLOCK_T, thread_count);
assert(threadqueue->debug_clock_thread_start);
threadqueue->debug_clock_thread_end = MALLOC(CLOCK_T, thread_count);
assert(threadqueue->debug_clock_thread_end);
threadqueue->debug_log = fopen("threadqueue.log", "w");
#endif //_DEBUG
#endif //KVZ_DEBUG

threadqueue->queue = NULL;
threadqueue->queue_size = 0;
Expand Down Expand Up @@ -306,8 +306,8 @@ int kvz_threadqueue_init(threadqueue_queue_t * const threadqueue, int thread_cou
*/
static void threadqueue_free_job(threadqueue_queue_t * const threadqueue, int i)
{
#ifdef _DEBUG
#if _DEBUG & KVZ_PERF_JOB
#ifdef KVZ_DEBUG
#if KVZ_DEBUG & KVZ_PERF_JOB
int j;
GET_TIME(&threadqueue->queue[i]->debug_clock_dequeue);
fprintf(threadqueue->debug_log, "%p\t%d\t%lf\t+%lf\t+%lf\t+%lf\t%s\n", threadqueue->queue[i], threadqueue->queue[i]->debug_worker_id, CLOCK_T_AS_DOUBLE(threadqueue->queue[i]->debug_clock_enqueue), CLOCK_T_DIFF(threadqueue->queue[i]->debug_clock_enqueue, threadqueue->queue[i]->debug_clock_start), CLOCK_T_DIFF(threadqueue->queue[i]->debug_clock_start, threadqueue->queue[i]->debug_clock_stop), CLOCK_T_DIFF(threadqueue->queue[i]->debug_clock_stop, threadqueue->queue[i]->debug_clock_dequeue), threadqueue->queue[i]->debug_description);
Expand All @@ -333,8 +333,8 @@ static void threadqueue_free_jobs(threadqueue_queue_t * const threadqueue) {
}
threadqueue->queue_count = 0;
threadqueue->queue_start = 0;
#ifdef _DEBUG
#if _DEBUG & KVZ_PERF_JOB
#ifdef KVZ_DEBUG
#if KVZ_DEBUG & KVZ_PERF_JOB
{
CLOCK_T time;
GET_TIME(&time);
Expand Down Expand Up @@ -391,7 +391,7 @@ int kvz_threadqueue_finalize(threadqueue_queue_t * const threadqueue) {
}
}

#ifdef _DEBUG
#ifdef KVZ_DEBUG
FREE_POINTER(threadqueue->debug_clock_thread_start);
FREE_POINTER(threadqueue->debug_clock_thread_end);
fclose(threadqueue->debug_log);
Expand Down Expand Up @@ -522,7 +522,7 @@ threadqueue_job_t * kvz_threadqueue_submit(threadqueue_queue_t * const threadque

job = MALLOC(threadqueue_job_t, 1);

#ifdef _DEBUG
#ifdef KVZ_DEBUG
if (debug_description) {
size_t desc_len = MIN(255, strlen(debug_description));
char* desc;
Expand All @@ -542,7 +542,7 @@ threadqueue_job_t * kvz_threadqueue_submit(threadqueue_queue_t * const threadque
job->debug_description = desc;
}
GET_TIME(&job->debug_clock_enqueue);
#endif //_DEBUG
#endif //KVZ_DEBUG

if (!job) {
fprintf(stderr, "Could not alloc job!\n");
Expand Down Expand Up @@ -646,7 +646,7 @@ int kvz_threadqueue_job_unwait_job(threadqueue_queue_t * const threadqueue, thre
return 1;
}

#ifdef _DEBUG
#ifdef KVZ_DEBUG
int threadqueue_log(threadqueue_queue_t * threadqueue, const CLOCK_T *start, const CLOCK_T *stop, const char* debug_description) {
int i, thread_id = -1;
FILE* output;
Expand Down Expand Up @@ -690,4 +690,4 @@ int threadqueue_log(threadqueue_queue_t * threadqueue, const CLOCK_T *start, con
}
return 1;
}
#endif //_DEBUG
#endif //KVZ_DEBUG
10 changes: 5 additions & 5 deletions src/threadqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ typedef struct threadqueue_job_t {
void (*fptr)(void *arg);
void *arg;

#ifdef _DEBUG
#ifdef KVZ_DEBUG
const char* debug_description;

int debug_worker_id;
Expand Down Expand Up @@ -82,7 +82,7 @@ typedef struct {
unsigned int queue_waiting_dependency; //Number of jobs waiting for a dependency to complete
unsigned int queue_running; //Number of jobs running

#ifdef _DEBUG
#ifdef KVZ_DEBUG
//Format: pointer <tab> worker id <tab> time enqueued <tab> time started <tab> time stopped <tab> time dequeued <tab> job description
//For threads, pointer = "" and job description == "thread", time enqueued and time dequeued are equal to "-"
//For flush, pointer = "" and job description == "FLUSH", time enqueued, time dequeued and time started are equal to "-"
Expand Down Expand Up @@ -116,7 +116,7 @@ int kvz_threadqueue_waitfor(threadqueue_queue_t * threadqueue, threadqueue_job_t
//Free ressources in a threadqueue
int kvz_threadqueue_finalize(threadqueue_queue_t * threadqueue);

#ifdef _DEBUG
#ifdef KVZ_DEBUG
int threadqueue_log(threadqueue_queue_t * threadqueue, const CLOCK_T *start, const CLOCK_T *stop, const char* debug_description);

// Bitmasks for PERFORMANCE_MEASURE_START and PERFORMANCE_MEASURE_END.
Expand All @@ -128,8 +128,8 @@ int threadqueue_log(threadqueue_queue_t * threadqueue, const CLOCK_T *start, con
#define KVZ_PERF_SEARCHCU (1 << 5)
#define KVZ_PERF_SEARCHPX (1 << 6)

#define IMPL_PERFORMANCE_MEASURE_START(mask) CLOCK_T start, stop; if ((_DEBUG) & mask) { GET_TIME(&start); }
#define IMPL_PERFORMANCE_MEASURE_END(mask, threadqueue, str, ...) { if ((_DEBUG) & mask) { GET_TIME(&stop); {char job_description[256]; sprintf(job_description, (str), __VA_ARGS__); threadqueue_log((threadqueue), &start, &stop, job_description);}} } \
#define IMPL_PERFORMANCE_MEASURE_START(mask) CLOCK_T start, stop; if ((KVZ_DEBUG) & mask) { GET_TIME(&start); }
#define IMPL_PERFORMANCE_MEASURE_END(mask, threadqueue, str, ...) { if ((KVZ_DEBUG) & mask) { GET_TIME(&stop); {char job_description[256]; sprintf(job_description, (str), __VA_ARGS__); threadqueue_log((threadqueue), &start, &stop, job_description);}} } \

#ifdef _MSC_VER
// Disable VS conditional expression warning from debug code.
Expand Down

0 comments on commit f1ac0e6

Please sign in to comment.