Skip to content

Commit

Permalink
Merge branch 'los-exit-ms'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Toth committed Sep 21, 2018
2 parents 86642c1 + 1b7091c commit 746d056
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
9 changes: 8 additions & 1 deletion encoders/video/avc/x264.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,14 @@ printf("Malloc failed\n");
* is disconnected, suggestedint a BM firmware bug.
* We'll use the audio clock regardless, for both audio and video compressors.
*/
int64_t new_dts = avfm->audio_pts + 24299700 - abs(coded_frame->real_dts - coded_frame->real_pts) + (2 * frame_duration);
int64_t new_dts = 0;
if (h->obe_system == OBE_SYSTEM_TYPE_LOWEST_LATENCY || h->obe_system == OBE_SYSTEM_TYPE_LOW_LATENCY) {
new_dts = avfm->audio_pts + 0 -
abs(coded_frame->real_dts - coded_frame->real_pts) + (2 * frame_duration);
} else {
new_dts = avfm->audio_pts + 24299700 -
abs(coded_frame->real_dts - coded_frame->real_pts) + (2 * frame_duration);
}

/* We need to userstand, for this temporal frame, how much it varies from the dts. */
int64_t pts_diff = coded_frame->real_dts - coded_frame->real_pts;
Expand Down
22 changes: 16 additions & 6 deletions input/sdi/decklink/decklink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ typedef struct
int enable_vanc_cache;
int enable_bitstream_audio;
int enable_patch1;
int enable_los_exit_ms;

/* Output */
int probe_success;
Expand Down Expand Up @@ -1115,12 +1116,19 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived( IDeckLinkVideoInputFram
if( cur_frame_time - decklink_ctx->last_frame_time >= SDI_MAX_DELAY )
{
//system("/storage/dev/DEKTEC-DTU351/DTCOLLECTOR/obe-error.sh");
syslog(LOG_WARNING, "Decklink card index %i: No frame received for %"PRIi64" ms",
decklink_opts_->card_idx,
(cur_frame_time - decklink_ctx->last_frame_time) / 1000 );
printf("Decklink card index %i: No frame received for %"PRIi64" ms",
decklink_opts_->card_idx,
(cur_frame_time - decklink_ctx->last_frame_time) / 1000 );
int noFrameMS = (cur_frame_time - decklink_ctx->last_frame_time) / 1000;

char msg[128];
sprintf(msg, "Decklink card index %i: No frame received for %"PRIi64" ms", decklink_opts_->card_idx, noFrameMS);
syslog(LOG_WARNING, msg);
printf("%s\n", msg);

if (OPTION_ENABLED_(los_exit_ms) && noFrameMS >= OPTION_ENABLED_(los_exit_ms)) {
sprintf(msg, "Terminating encoder as enable_los_exit_ms is active.");
syslog(LOG_WARNING, msg);
printf("%s\n", msg);
exit(0);
}
#if FRAME_CACHING
int clocks_missed = (cur_frame_time - decklink_ctx->last_frame_time) * 27;
printf("Injected cached frames for %d missed, duration %" PRIi64 "\n", clocks_missed, frame_duration);
Expand Down Expand Up @@ -2135,6 +2143,7 @@ static void *probe_stream( void *ptr )
decklink_opts->enable_vanc_cache = user_opts->enable_vanc_cache;
decklink_opts->enable_bitstream_audio = user_opts->enable_bitstream_audio;
decklink_opts->enable_patch1 = user_opts->enable_patch1;
decklink_opts->enable_los_exit_ms = user_opts->enable_los_exit_ms;

decklink_opts->probe = non_display_parser->probe = 1;

Expand Down Expand Up @@ -2350,6 +2359,7 @@ static void *open_input( void *ptr )
decklink_opts->enable_vanc_cache = user_opts->enable_vanc_cache;
decklink_opts->enable_bitstream_audio = user_opts->enable_bitstream_audio;
decklink_opts->enable_patch1 = user_opts->enable_patch1;
decklink_opts->enable_los_exit_ms = user_opts->enable_los_exit_ms;

decklink_ctx = &decklink_opts->decklink_ctx;

Expand Down
1 change: 1 addition & 0 deletions obe/obe.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ typedef struct
int enable_vanc_cache;
int enable_bitstream_audio;
int enable_patch1;
int enable_los_exit_ms;
} obe_input_t;

/**** Stream Formats ****/
Expand Down
6 changes: 4 additions & 2 deletions obe/obecli.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static const char * entropy_modes[] = { "cabac", "cavlc", NULL };

static const char * system_opts[] = { "system-type", "max-probe-time", NULL };
static const char * input_opts[] = { "location", "card-idx", "video-format", "video-connection", "audio-connection",
"smpte2038", "scte35", "vanc-cache", "bitstream-audio", "patch1", NULL };
"smpte2038", "scte35", "vanc-cache", "bitstream-audio", "patch1", "los-exit-ms", NULL };
static const char * add_opts[] = { "type" };
/* TODO: split the stream options into general options, video options, ts options */
static const char * stream_opts[] = { "action", "format",
Expand Down Expand Up @@ -543,6 +543,7 @@ static int set_input( char *command, obecli_command_t *child )
char *vanc_cache = obe_get_option( input_opts[7], opts );
char *bitstream_audio = obe_get_option( input_opts[8], opts );
char *patch1 = obe_get_option( input_opts[9], opts );
char *los_exit_ms = obe_get_option( input_opts[10], opts );

FAIL_IF_ERROR( video_format && ( check_enum_value( video_format, input_video_formats ) < 0 ),
"Invalid video format\n" );
Expand All @@ -568,6 +569,7 @@ static int set_input( char *command, obecli_command_t *child )
cli.input.enable_smpte2038 = obe_otoi( smpte2038, cli.input.enable_smpte2038 );
cli.input.enable_scte35 = obe_otoi( scte35, cli.input.enable_scte35 );
cli.input.enable_vanc_cache = obe_otoi( vanc_cache, cli.input.enable_vanc_cache );
cli.input.enable_los_exit_ms = obe_otoi( los_exit_ms, cli.input.enable_los_exit_ms );
cli.input.card_idx = obe_otoi( card_idx, cli.input.card_idx );
if( video_format )
parse_enum_value( video_format, input_video_formats, &cli.input.video_format );
Expand Down Expand Up @@ -1772,7 +1774,7 @@ static void _usage(const char *prog, int exitcode)
{
printf("\nOpen Broadcast Encoder command line interface.\n");
printf("Including Kernel Labs enhancements.\n");
printf("Version 1.8 (" GIT_VERSION ")\n");
printf("Version 1.10 (" GIT_VERSION ")\n");
printf("x264 build#%d (%dbit support)\n", X264_BUILD, X264_BIT_DEPTH);
printf("Decklink SDK %s\n", BLACKMAGIC_DECKLINK_API_VERSION_STRING);
printf("\n");
Expand Down

0 comments on commit 746d056

Please sign in to comment.