Skip to content

Commit 6bac0f1

Browse files
committed
Merge pull request ob-encoder#3 from gfto/fixes
Crash fix and random warning fixes
2 parents 1a85ea9 + eafbd4d commit 6bac0f1

File tree

9 files changed

+35
-74
lines changed

9 files changed

+35
-74
lines changed

encoders/smoothing.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void *start_smoothing( void *ptr )
5252
}
5353
}
5454

55-
int64_t send_delta = 0;
55+
//int64_t send_delta = 0;
5656

5757
while( 1 )
5858
{

filters/video/video.c

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,6 @@ static int set_sar( obe_raw_frame_t *raw_frame, int is_wide )
165165
return -1;
166166
}
167167

168-
static void scale_plane_c( uint16_t *src, int stride, int width, int height, int lshift, int rshift )
169-
{
170-
for( int i = 0; i < height; i++ )
171-
{
172-
for( int j = 0; j < width; j++ )
173-
src[j] = (src[j] << lshift) + (src[j] >> rshift);
174-
175-
src += stride / 2;
176-
}
177-
}
178-
179168
static void dither_row_10_to_8_c( uint16_t *src, uint8_t *dst, const uint16_t *dither, int width, int stride )
180169
{
181170
const int scale = 511;
@@ -272,7 +261,6 @@ static void blank_lines( obe_raw_frame_t *raw_frame )
272261
/* All SDI input is 10-bit 4:2:2 */
273262
/* FIXME: assumes planar, non-interleaved format */
274263
uint16_t *y, *u, *v;
275-
int cur_line = raw_frame->img.first_line;
276264

277265
y = (uint16_t*)raw_frame->img.plane[0];
278266
u = (uint16_t*)raw_frame->img.plane[1];
@@ -281,33 +269,6 @@ static void blank_lines( obe_raw_frame_t *raw_frame )
281269
blank_line( y, u, v, raw_frame->img.width / 2 );
282270
}
283271

284-
static int scale_frame( obe_vid_filter_ctx_t *vfilt, obe_raw_frame_t *raw_frame )
285-
{
286-
obe_image_t *img = &raw_frame->img;
287-
288-
/* TODO: when frames are needed for reference we can't scale in-place */
289-
290-
/* this function mimics how swscale does upconversion. 8-bit is converted
291-
* to 16-bit through left shifting the orginal value with 8 and then adding
292-
* the original value to that. This effectively keeps the full color range
293-
* while also being fast. for n-bit we basically do the same thing, but we
294-
* discard the lower 16-n bits. */
295-
const int lshift = 16-obe_cli_csps[img->csp].bit_depth;
296-
const int rshift = 2*obe_cli_csps[img->csp].bit_depth - 16;
297-
for( int i = 0; i < img->planes; i++ )
298-
{
299-
uint16_t *src = (uint16_t*)img->plane[i];
300-
int height = obe_cli_csps[img->csp].height[i] * img->height;
301-
int width = obe_cli_csps[img->csp].width[i] * img->width;
302-
303-
vfilt->scale_plane( src, img->stride[i], width, height, lshift, rshift );
304-
}
305-
306-
img->csp = img->csp == PIX_FMT_YUV420P ? PIX_FMT_YUV420P10 : PIX_FMT_YUV422P10;
307-
308-
return 0;
309-
}
310-
311272
static int resize_frame( obe_vid_filter_ctx_t *vfilt, obe_raw_frame_t *raw_frame, int width )
312273
{
313274
obe_image_t tmp_image = {0};

input/sdi/decklink/decklink.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ const static struct obe_to_decklink video_conn_tab[] =
6464
{ INPUT_VIDEO_CONNECTION_COMPONENT, bmdVideoConnectionComponent },
6565
{ INPUT_VIDEO_CONNECTION_COMPOSITE, bmdVideoConnectionComposite },
6666
{ INPUT_VIDEO_CONNECTION_S_VIDEO, bmdVideoConnectionSVideo },
67-
{ -1, -1 },
67+
{ -1, 0 },
6868
};
6969

7070
const static struct obe_to_decklink audio_conn_tab[] =
7171
{
7272
{ INPUT_AUDIO_EMBEDDED, bmdAudioConnectionEmbedded },
7373
{ INPUT_AUDIO_AES_EBU, bmdAudioConnectionAESEBU },
7474
{ INPUT_AUDIO_ANALOGUE, bmdAudioConnectionAnalog },
75-
{ -1, -1 },
75+
{ -1, 0 },
7676
};
7777

7878
const static struct obe_to_decklink_video video_format_tab[] =
@@ -93,7 +93,7 @@ const static struct obe_to_decklink_video video_format_tab[] =
9393
{ INPUT_VIDEO_FORMAT_1080P_50, bmdModeHD1080p50, 1, 50 },
9494
{ INPUT_VIDEO_FORMAT_1080P_5994, bmdModeHD1080p5994, 1001, 60000 },
9595
{ INPUT_VIDEO_FORMAT_1080P_60, bmdModeHD1080p6000, 1, 60 },
96-
{ -1, -1, -1, -1 },
96+
{ -1, 0, -1, -1 },
9797
};
9898

9999
class DeckLinkCaptureDelegate;

input/sdi/linsys/linsys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ struct linsys_status
212212

213213
static inline void obe_decode_line( linsys_ctx_t *linsys_ctx, const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v )
214214
{
215-
uint32_t val;
215+
uint32_t val = 0;
216216
int w;
217217

218218
w = (linsys_ctx->width / 6) * 6;

input/sdi/sdi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void obe_v210_planar_unpack_c( const uint32_t *src, uint16_t *y, uint16_t *u, ui
5050
void obe_v210_line_to_nv20_c( uint32_t *src, uint16_t *dst, int width )
5151
{
5252
int w;
53-
uint32_t val;
53+
uint32_t val = 0;
5454
uint16_t *uv = dst + width;
5555
for( w = 0; w < width - 5; w += 6 )
5656
{

mux/ts/ts.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ void *open_muxer( void *ptr )
387387
{
388388
video_found = 0;
389389
video_dts = 0;
390-
int64_t lowest_pts = -1, largest_pts = -1;
391390

392391
pthread_mutex_lock( &h->mux_queue.mutex );
393392

obe.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,13 @@ static int obe_validate_input_params( obe_input_t *input_device )
559559
return 0;
560560
}
561561

562+
static int __pthread_join( pthread_t thread, void **retval )
563+
{
564+
if ( thread )
565+
return pthread_join( thread, retval );
566+
return -1;
567+
}
568+
562569
int obe_probe_device( obe_t *h, obe_input_t *input_device, obe_input_program_t *program )
563570
{
564571
pthread_t thread;
@@ -659,7 +666,7 @@ int obe_probe_device( obe_t *h, obe_input_t *input_device, obe_input_program_t *
659666
}
660667

661668
pthread_cancel( thread );
662-
pthread_join( thread, &ret_ptr );
669+
__pthread_join( thread, &ret_ptr );
663670

664671
cur_devices = h->num_devices;
665672

@@ -1224,7 +1231,7 @@ void obe_close( obe_t *h )
12241231
for( int i = 0; i < h->num_devices; i++ )
12251232
{
12261233
pthread_cancel( h->devices[i]->device_thread );
1227-
pthread_join( h->devices[i]->device_thread, &ret_ptr );
1234+
__pthread_join( h->devices[i]->device_thread, &ret_ptr );
12281235
}
12291236

12301237
fprintf( stderr, "input cancelled \n" );
@@ -1236,7 +1243,7 @@ void obe_close( obe_t *h )
12361243
h->filters[i]->cancel_thread = 1;
12371244
pthread_cond_signal( &h->filters[i]->queue.in_cv );
12381245
pthread_mutex_unlock( &h->filters[i]->queue.mutex );
1239-
pthread_join( h->filters[i]->filter_thread, &ret_ptr );
1246+
__pthread_join( h->filters[i]->filter_thread, &ret_ptr );
12401247
}
12411248

12421249
fprintf( stderr, "filters cancelled \n" );
@@ -1248,7 +1255,7 @@ void obe_close( obe_t *h )
12481255
h->encoders[i]->cancel_thread = 1;
12491256
pthread_cond_signal( &h->encoders[i]->queue.in_cv );
12501257
pthread_mutex_unlock( &h->encoders[i]->queue.mutex );
1251-
pthread_join( h->encoders[i]->encoder_thread, &ret_ptr );
1258+
__pthread_join( h->encoders[i]->encoder_thread, &ret_ptr );
12521259
}
12531260

12541261
fprintf( stderr, "encoders cancelled \n" );
@@ -1264,7 +1271,8 @@ void obe_close( obe_t *h )
12641271
pthread_mutex_lock( &h->obe_clock_mutex );
12651272
pthread_cond_broadcast( &h->obe_clock_cv );
12661273
pthread_mutex_unlock( &h->obe_clock_mutex );
1267-
pthread_join( h->enc_smoothing_thread, &ret_ptr );
1274+
if ( h->enc_smoothing_thread )
1275+
__pthread_join( h->enc_smoothing_thread, &ret_ptr );
12681276
}
12691277

12701278
fprintf( stderr, "encoder smoothing cancelled \n" );
@@ -1274,7 +1282,7 @@ void obe_close( obe_t *h )
12741282
h->cancel_mux_thread = 1;
12751283
pthread_cond_signal( &h->mux_queue.in_cv );
12761284
pthread_mutex_unlock( &h->mux_queue.mutex );
1277-
pthread_join( h->mux_thread, &ret_ptr );
1285+
__pthread_join( h->mux_thread, &ret_ptr );
12781286

12791287
fprintf( stderr, "mux cancelled \n" );
12801288

@@ -1283,7 +1291,7 @@ void obe_close( obe_t *h )
12831291
h->cancel_mux_smoothing_thread = 1;
12841292
pthread_cond_signal( &h->mux_smoothing_queue.in_cv );
12851293
pthread_mutex_unlock( &h->mux_smoothing_queue.mutex );
1286-
pthread_join( h->mux_smoothing_thread, &ret_ptr );
1294+
__pthread_join( h->mux_smoothing_thread, &ret_ptr );
12871295

12881296
fprintf( stderr, "mux smoothing cancelled \n" );
12891297

@@ -1294,10 +1302,10 @@ void obe_close( obe_t *h )
12941302
h->outputs[i]->cancel_thread = 1;
12951303
pthread_cond_signal( &h->outputs[i]->queue.in_cv );
12961304
pthread_mutex_unlock( &h->outputs[i]->queue.mutex );
1297-
pthread_join( h->outputs[i]->output_thread, &ret_ptr );
1305+
__pthread_join( h->outputs[i]->output_thread, &ret_ptr );
12981306
/* could be blocking on OS so have to cancel thread too */
12991307
pthread_cancel( h->outputs[i]->output_thread );
1300-
pthread_join( h->outputs[i]->output_thread, &ret_ptr );
1308+
__pthread_join( h->outputs[i]->output_thread, &ret_ptr );
13011309
}
13021310

13031311
fprintf( stderr, "output thread cancelled \n" );

obecli.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,6 @@ static int obe_otoi( char *str, int def )
329329
return ret;
330330
}
331331

332-
static char *obe_otos( char *str, char *def )
333-
{
334-
return str ? str : def;
335-
}
336-
337332
static int check_enum_value( const char *arg, const char * const *names )
338333
{
339334
for( int i = 0; names[i]; i++ )
@@ -948,7 +943,6 @@ static int set_outputs( char *command, obecli_command_t *child )
948943
return -1;
949944

950945
int tok_len = strcspn( command, " " );
951-
int str_len = strlen( command );
952946
command[tok_len] = 0;
953947

954948
num_outputs = obe_otoi( command, num_outputs );
@@ -973,7 +967,6 @@ static int set_output( char *command, obecli_command_t *child )
973967
{
974968
command += tok_len+1;
975969
int tok_len2 = strcspn( command, ":" );
976-
int str_len2 = strlen( command );
977970
command[tok_len2] = 0;
978971
int output_id = obe_otoi( command, -1 );
979972
FAIL_IF_ERROR( output_id < 0 || output_id > cli.output.num_outputs-1, "Invalid output id\n" );

output/ip/ip.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,6 @@ struct ip_status
5959
hnd_t *ip_handle;
6060
};
6161

62-
static int64_t obe_gettime(void)
63-
{
64-
struct timeval tv;
65-
gettimeofday(&tv,NULL);
66-
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
67-
}
68-
69-
static uint64_t obe_ntp_time(void)
70-
{
71-
return (obe_gettime() / 1000) * 1000 + NTP_OFFSET_US;
72-
}
73-
7462
static int rtp_open( hnd_t *p_handle, obe_udp_opts_t *udp_opts )
7563
{
7664
obe_rtp_ctx *p_rtp = calloc( 1, sizeof(*p_rtp) );
@@ -93,6 +81,18 @@ static int rtp_open( hnd_t *p_handle, obe_udp_opts_t *udp_opts )
9381
return 0;
9482
}
9583
#if 0
84+
static int64_t obe_gettime(void)
85+
{
86+
struct timeval tv;
87+
gettimeofday(&tv,NULL);
88+
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
89+
}
90+
91+
static uint64_t obe_ntp_time(void)
92+
{
93+
return (obe_gettime() / 1000) * 1000 + NTP_OFFSET_US;
94+
}
95+
9696
static int write_rtcp_pkt( hnd_t handle )
9797
{
9898
obe_rtp_ctx *p_rtp = handle;

0 commit comments

Comments
 (0)