diff options
Diffstat (limited to 'libhb')
-rw-r--r-- | libhb/deca52.c | 8 | ||||
-rw-r--r-- | libhb/decavcodec.c | 8 | ||||
-rw-r--r-- | libhb/decpgssub.c | 4 | ||||
-rw-r--r-- | libhb/decvobsub.c | 12 | ||||
-rw-r--r-- | libhb/demuxmpeg.c | 16 | ||||
-rw-r--r-- | libhb/enclame.c | 2 | ||||
-rw-r--r-- | libhb/fifo.c | 12 | ||||
-rw-r--r-- | libhb/hbffmpeg.h | 1 | ||||
-rw-r--r-- | libhb/muxavformat.c | 14 | ||||
-rw-r--r-- | libhb/muxmp4.c | 2 | ||||
-rw-r--r-- | libhb/reader.c | 18 | ||||
-rw-r--r-- | libhb/rendersub.c | 6 | ||||
-rw-r--r-- | libhb/stream.c | 30 | ||||
-rw-r--r-- | libhb/sync.c | 18 |
14 files changed, 77 insertions, 74 deletions
diff --git a/libhb/deca52.c b/libhb/deca52.c index 015d00b39..925e824b2 100644 --- a/libhb/deca52.c +++ b/libhb/deca52.c @@ -232,7 +232,7 @@ static int deca52Work( hb_work_object_t * w, hb_buffer_t ** buf_in, return HB_WORK_DONE; } - if ( (*buf_in)->s.start < -1 && pv->next_expected_pts == 0 ) + if ( (*buf_in)->s.start < 0 && pv->next_expected_pts == 0 ) { // discard buffers that start before video time 0 *buf_out = NULL; @@ -331,15 +331,15 @@ static hb_buffer_t* Decode(hb_work_object_t *w) // spec says that the PTS is the start time of the first frame // that starts in the PES frame so we only use the PTS once then // get the following frames' PTS from the frame length. - ipts = -1; + ipts = AV_NOPTS_VALUE; } double frame_dur = (6. * 256. * 90000.) / pv->rate; double pts; - if (hb_gui_use_hwd_flag == 1 && ipts != -1) + if (hb_gui_use_hwd_flag == 1 && ipts != AV_NOPTS_VALUE) pts = ((double)ipts >= pv->next_expected_pts) ? (double)ipts : pv->next_expected_pts; else - pts = (ipts != -1) ? (double)ipts : pv->next_expected_pts; + pts = (ipts != AV_NOPTS_VALUE) ? (double)ipts : pv->next_expected_pts; /* AC3 passthrough: don't decode the AC3 frame */ if (audio->config.out.codec == HB_ACODEC_AC3_PASS) diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 73692de5f..b94168724 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -196,7 +196,7 @@ static int64_t heap_pop( pts_heap_t *heap ) if ( heap->nheap <= 0 ) { - return -1; + return AV_NOPTS_VALUE; } // return the top of the heap then put the bottom element on top, @@ -546,7 +546,7 @@ static int decavcodecaWork( hb_work_object_t * w, hb_buffer_t ** buf_in, *buf_out = NULL; - if ( in->s.start < -1 && pv->pts_next <= 0 ) + if ( in->s.start < 0 && pv->pts_next <= 0 ) { // discard buffers that start before video time 0 return HB_WORK_OK; @@ -566,8 +566,6 @@ static int decavcodecaWork( hb_work_object_t * w, hb_buffer_t ** buf_in, len = av_parser_parse2( pv->parser, pv->context, &pout, &pout_len, in->data + pos, in->size - pos, cur, cur, 0 ); cur = pv->parser->pts; - if ( cur == AV_NOPTS_VALUE ) - cur = -1; } else { @@ -2115,7 +2113,7 @@ static void decodeAudio(hb_audio_t *audio, hb_work_private_t *pv, uint8_t *data, int pos = 0; // If we are given a pts, use it; but don't lose partial ticks. - if (pts != -1 && (int64_t)pv->pts_next != pts) + if (pts != AV_NOPTS_VALUE && (int64_t)pv->pts_next != pts) pv->pts_next = pts; while (pos < size) { diff --git a/libhb/decpgssub.c b/libhb/decpgssub.c index aac70db2e..8ac87ea0e 100644 --- a/libhb/decpgssub.c +++ b/libhb/decpgssub.c @@ -211,7 +211,7 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, avp.data = in->data; avp.size = in->size; // libav wants pkt pts in AV_TIME_BASE units - if (in->s.start != -1) + if (in->s.start != AV_NOPTS_VALUE) { avp.pts = av_rescale(in->s.start, AV_TIME_BASE, 90000); } @@ -378,7 +378,7 @@ static int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, out->s.frametype = HB_FRAME_SUBTITLE; out->sequence = in->sequence; } - out->s.renderOffset = -1; + out->s.renderOffset = AV_NOPTS_VALUE; out->s.start = out->s.stop = pts; } else diff --git a/libhb/decvobsub.c b/libhb/decvobsub.c index 3b6c3cb79..605e22a94 100644 --- a/libhb/decvobsub.c +++ b/libhb/decvobsub.c @@ -177,7 +177,7 @@ int decsubWork( hb_work_object_t * w, hb_buffer_t ** buf_in, pv->size_got = 0; pv->size_rle = 0; - if ( pv->pts_stop != -1 ) + if ( pv->pts_stop != AV_NOPTS_VALUE ) { // If we don't get a valid next timestamp, use the stop time // of the current sub as the start of the next. @@ -225,8 +225,8 @@ static void ParseControls( hb_work_object_t * w ) int command; int date, next; - pv->pts_start = -1; - pv->pts_stop = -1; + pv->pts_start = AV_NOPTS_VALUE; + pv->pts_stop = AV_NOPTS_VALUE; pv->pts_forced = 0; pv->alpha[3] = 0; @@ -271,7 +271,7 @@ static void ParseControls( hb_work_object_t * w ) break; case 0x02: // 0x02 - STP_DSP - Stop Display, no arguments - if(pv->pts_stop == -1) + if(pv->pts_stop == AV_NOPTS_VALUE) pv->pts_stop = pv->pts + date * 1024; break; @@ -347,7 +347,7 @@ static void ParseControls( hb_work_object_t * w ) } // fading-out - if( currAlpha < lastAlpha && pv->pts_stop == -1 ) + if (currAlpha < lastAlpha && pv->pts_stop == AV_NOPTS_VALUE) { pv->pts_stop = pv->pts + date * 1024; } @@ -382,7 +382,7 @@ static void ParseControls( hb_work_object_t * w ) i = next; } // Generate timestamps if they are not set - if( pv->pts_start == -1 ) + if( pv->pts_start == AV_NOPTS_VALUE ) { // Set pts to end of last sub if the start time is unknown. pv->pts_start = pv->pts; diff --git a/libhb/demuxmpeg.c b/libhb/demuxmpeg.c index e3000f207..3a965debb 100644 --- a/libhb/demuxmpeg.c +++ b/libhb/demuxmpeg.c @@ -39,10 +39,11 @@ static inline void check_mpeg_scr( hb_psdemux_t *state, int64_t scr, int tol ) // 'tol'ms between the last scr & this or if this scr goes back // by more than half a frame time. int64_t scr_delta = scr - state->last_scr; - if ( state->last_scr == -1 || scr_delta > 90*tol || scr_delta < -90*10 ) + if (state->last_scr == AV_NOPTS_VALUE || + scr_delta > 90*tol || scr_delta < -90*10) { ++state->scr_changes; - state->last_pts = -1; + state->last_pts = AV_NOPTS_VALUE; } state->last_scr = scr; } @@ -128,7 +129,7 @@ void hb_demux_dvd_ps( hb_buffer_t * buf, hb_list_t * list_es, hb_psdemux_t* stat int pes_header_d_length; int pes_header_end; int has_pts; - int64_t pts = -1, dts = -1; + int64_t pts = AV_NOPTS_VALUE, dts = AV_NOPTS_VALUE; pos += 3; /* packet_start_code_prefix */ id = d[pos]; @@ -220,7 +221,7 @@ void hb_demux_dvd_ps( hb_buffer_t * buf, hb_list_t * list_es, hb_psdemux_t* stat buf_es->s.id = id; buf_es->s.start = pts; buf_es->s.renderOffset = dts; - buf_es->s.stop = -1; + buf_es->s.stop = AV_NOPTS_VALUE; if ( state && id == 0xE0) { // Consume a chapter break, and apply it to the ES. @@ -266,7 +267,7 @@ void hb_demux_mpeg( hb_buffer_t *buf, hb_list_t *list_es, hb_psdemux_t *state ) { // we have a new pcr check_mpeg_scr( state, buf->s.pcr, 300 ); - buf->s.pcr = -1; + buf->s.pcr = AV_NOPTS_VALUE; // Some streams have consistantly bad PCRs or SCRs // So filter out the offset if ( buf->s.start >= 0 ) @@ -348,8 +349,9 @@ void hb_demux_null( hb_buffer_t * buf, hb_list_t * list_es, hb_psdemux_t* state { // if we don't have a time offset yet, // use this timestamp as the offset. - if ( state->scr_changes == 0 && - ( buf->s.start != -1 || buf->s.renderOffset != -1 ) ) + if (state->scr_changes == 0 && + (buf->s.start != AV_NOPTS_VALUE || + buf->s.renderOffset != AV_NOPTS_VALUE)) { ++state->scr_changes; state->last_scr = buf->s.start >= 0 ? buf->s.start : buf->s.renderOffset; diff --git a/libhb/enclame.c b/libhb/enclame.c index 6cb4ab3a3..1329836e5 100644 --- a/libhb/enclame.c +++ b/libhb/enclame.c @@ -94,7 +94,7 @@ int enclameInit( hb_work_object_t * w, hb_job_t * job ) audio->config.out.samples_per_frame = 1152; pv->list = hb_list_init(); - pv->pts = -1; + pv->pts = AV_NOPTS_VALUE; return 0; } diff --git a/libhb/fifo.c b/libhb/fifo.c index a782ebb25..fe1ea5ea6 100644 --- a/libhb/fifo.c +++ b/libhb/fifo.c @@ -341,9 +341,9 @@ hb_buffer_t * hb_buffer_init_internal( int size , int needsMapped ) b->alloc = buffer_pool->buffer_size; b->size = size; b->data = data; - b->s.start = -1; - b->s.stop = -1; - b->s.renderOffset = -1; + b->s.start = AV_NOPTS_VALUE; + b->s.stop = AV_NOPTS_VALUE; + b->s.renderOffset = AV_NOPTS_VALUE; /* OpenCL */ b->cl.buffer = buffer; @@ -407,9 +407,9 @@ hb_buffer_t * hb_buffer_init_internal( int size , int needsMapped ) buffers.allocated += b->alloc; hb_unlock(buffers.lock); } - b->s.start = -1; - b->s.stop = -1; - b->s.renderOffset = -1; + b->s.start = AV_NOPTS_VALUE; + b->s.stop = AV_NOPTS_VALUE; + b->s.renderOffset = AV_NOPTS_VALUE; return b; } diff --git a/libhb/hbffmpeg.h b/libhb/hbffmpeg.h index 94b1a903e..b1379d006 100644 --- a/libhb/hbffmpeg.h +++ b/libhb/hbffmpeg.h @@ -13,6 +13,7 @@ #include "libavutil/imgutils.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" +#include "libavutil/avutil.h" #include "libswscale/swscale.h" #include "libavresample/avresample.h" #include "common.h" diff --git a/libhb/muxavformat.c b/libhb/muxavformat.c index 7766d9854..277e15992 100644 --- a/libhb/muxavformat.c +++ b/libhb/muxavformat.c @@ -48,7 +48,7 @@ struct hb_mux_object_s int ntracks; hb_mux_data_t ** tracks; - int delay; + int64_t delay; }; enum @@ -130,7 +130,7 @@ static int avformatInit( hb_mux_object_t * m ) char *lang; - m->delay = -1; + m->delay = AV_NOPTS_VALUE; max_tracks = 1 + hb_list_count( job->list_audio ) + hb_list_count( job->list_subtitle ); @@ -951,20 +951,20 @@ static void computeDelay(hb_mux_object_t *m) static int avformatMux(hb_mux_object_t *m, hb_mux_data_t *track, hb_buffer_t *buf) { AVPacket pkt; - int64_t dts, pts, duration = -1; + int64_t dts, pts, duration = AV_NOPTS_VALUE; hb_job_t *job = m->job; uint8_t tx3g_out[2048]; - if (m->delay == -1) + if (m->delay == AV_NOPTS_VALUE) { computeDelay(m); } if (buf != NULL) { - if (buf->s.start != -1) + if (buf->s.start != AV_NOPTS_VALUE) buf->s.start += m->delay; - if (buf->s.renderOffset != -1) + if (buf->s.renderOffset != AV_NOPTS_VALUE) buf->s.renderOffset += m->delay; } @@ -981,7 +981,7 @@ static int avformatMux(hb_mux_object_t *m, hb_mux_data_t *track, hb_buffer_t *bu if (buf == NULL) return 0; - if (buf->s.renderOffset == -1) + if (buf->s.renderOffset == AV_NOPTS_VALUE) { dts = av_rescale_q(buf->s.start, (AVRational){1,90000}, track->st->time_base); diff --git a/libhb/muxmp4.c b/libhb/muxmp4.c index 4cc9d5d0f..dba02fd07 100644 --- a/libhb/muxmp4.c +++ b/libhb/muxmp4.c @@ -691,7 +691,7 @@ static int MP4Mux( hb_mux_object_t * m, hb_mux_data_t * mux_data, hb_buffer_t * buf ) { hb_job_t * job = m->job; - int64_t duration, stop = -1; + int64_t duration, stop = AV_NOPTS_VALUE; int64_t offset = 0; hb_buffer_t *tmp; diff --git a/libhb/reader.c b/libhb/reader.c index a7405fed7..22324f4d4 100644 --- a/libhb/reader.c +++ b/libhb/reader.c @@ -119,7 +119,7 @@ static int hb_reader_init( hb_work_object_t * w, hb_job_t * job ) r->stream_timing[0].startup = 10; r->stream_timing[1].id = -1; - r->demux.last_scr = -1; + r->demux.last_scr = AV_NOPTS_VALUE; if ( !job->pts_to_start ) r->start_found = 1; @@ -552,8 +552,10 @@ void ReadLoop( void * _w ) // The first data packet with a PTS from an audio or video stream // that we're decoding defines 'time zero'. Discard packets until // we get one. - if ( buf->s.start != -1 && buf->s.renderOffset != -1 && - ( buf->s.id == r->title->video_id || is_audio( r, buf->s.id ) ) ) + if (buf->s.start != AV_NOPTS_VALUE && + buf->s.renderOffset != AV_NOPTS_VALUE && + (buf->s.id == r->title->video_id || + is_audio( r, buf->s.id))) { // force a new scr offset computation r->scr_changes = r->demux.scr_changes - 1; @@ -572,7 +574,7 @@ void ReadLoop( void * _w ) if ( r->job->indepth_scan || fifos ) { - if ( buf->s.renderOffset != -1 ) + if ( buf->s.renderOffset != AV_NOPTS_VALUE ) { if ( r->scr_changes != r->demux.scr_changes ) { @@ -597,12 +599,12 @@ void ReadLoop( void * _w ) // frame but video & subtitles don't. Clear // the timestamps so the decoder will generate // them from the frame durations. - buf->s.start = -1; - buf->s.renderOffset = -1; + buf->s.start = AV_NOPTS_VALUE; + buf->s.renderOffset = AV_NOPTS_VALUE; } } } - if ( buf->s.start != -1 ) + if ( buf->s.start != AV_NOPTS_VALUE ) { int64_t start = buf->s.start - r->scr_offset; @@ -634,7 +636,7 @@ void ReadLoop( void * _w ) // buf->s.start - r->scr_offset); buf->s.start -= r->scr_offset; } - if ( buf->s.renderOffset != -1 ) + if ( buf->s.renderOffset != AV_NOPTS_VALUE ) { // This packet is referenced to the same SCR as the last. // Adjust timestamp to remove the System Clock Reference diff --git a/libhb/rendersub.c b/libhb/rendersub.c index f42bdf8eb..7d45e315c 100644 --- a/libhb/rendersub.c +++ b/libhb/rendersub.c @@ -258,8 +258,8 @@ static void ApplyVOBSubs( hb_filter_private_t * pv, hb_buffer_t * buf ) else next = NULL; - if ((sub->s.stop != -1 && sub->s.stop <= buf->s.start) || - (next != NULL && sub->s.stop == -1 && next->s.start <= buf->s.start)) + if ((sub->s.stop != AV_NOPTS_VALUE && sub->s.stop <= buf->s.start) || + (next != NULL && sub->s.stop == AV_NOPTS_VALUE && next->s.start <= buf->s.start)) { // Subtitle stop is in the past, delete it hb_list_rem( pv->sub_list, sub ); @@ -548,7 +548,7 @@ static int ssa_work( hb_filter_object_t * filter, { // Parse MKV-SSA packet // SSA subtitles always have an explicit stop time, so we - // do not need to do special processing for stop == -1 + // do not need to do special processing for stop == AV_NOPTS_VALUE ass_process_chunk( pv->ssaTrack, (char*)sub->data, sub->size, sub->s.start / 90, (sub->s.stop - sub->s.start) / 90 ); diff --git a/libhb/stream.c b/libhb/stream.c index 2c1757005..06abe32a6 100644 --- a/libhb/stream.c +++ b/libhb/stream.c @@ -1472,7 +1472,7 @@ static hb_buffer_t * hb_ps_stream_getVideo( } if ( stream->pes.list[idx].stream_kind == V ) { - if ( pes_info.pts != -1 ) + if ( pes_info.pts != AV_NOPTS_VALUE ) { *pi = pes_info; return buf; @@ -3170,8 +3170,8 @@ static int hb_parse_ps( hb_pes_info_t *pes_info ) { memset( pes_info, 0, sizeof( hb_pes_info_t ) ); - pes_info->pts = -1; - pes_info->dts = -1; + pes_info->pts = AV_NOPTS_VALUE; + pes_info->dts = AV_NOPTS_VALUE; bitbuf_t bb, cc; bits_init(&bb, buf, len, 0); @@ -3462,7 +3462,7 @@ static hb_buffer_t * hb_ps_stream_decode( hb_stream_t *stream ) buf->size -= pes_info.header_len; if ( buf->size == 0 ) continue; - stream->pes.scr = -1; + stream->pes.scr = AV_NOPTS_VALUE; return buf; } } @@ -4521,7 +4521,7 @@ static hb_buffer_t * generate_output_data(hb_stream_t *stream, int curstream) } else { - buf->s.pcr = -1; + buf->s.pcr = AV_NOPTS_VALUE; } // check if this packet was referenced to an older pcr and if that @@ -4531,10 +4531,10 @@ static hb_buffer_t * generate_output_data(hb_stream_t *stream, int curstream) // we've sent up a new pcr but have a packet referenced to an // old pcr and the difference was enough to trigger a discontinuity // correction. smash the timestamps or we'll mess up the correction. - buf->s.start = -1; - buf->s.renderOffset = -1; - buf->s.stop = -1; - buf->s.pcr = -1; + buf->s.start = AV_NOPTS_VALUE; + buf->s.renderOffset = AV_NOPTS_VALUE; + buf->s.stop = AV_NOPTS_VALUE; + buf->s.pcr = AV_NOPTS_VALUE; } else { @@ -4887,9 +4887,9 @@ void hb_ts_stream_reset(hb_stream_t *stream) stream->ts.found_pcr = 0; stream->ts.pcr_out = 0; stream->ts.pcr_in = 0; - stream->ts.pcr = -1; + stream->ts.pcr = AV_NOPTS_VALUE; stream->ts.pcr_current = -1; - stream->ts.last_timestamp = -1; + stream->ts.last_timestamp = AV_NOPTS_VALUE; stream->frames = 0; stream->errors = 0; @@ -4902,7 +4902,7 @@ void hb_ps_stream_reset(hb_stream_t *stream) stream->need_keyframe = 1; stream->pes.found_scr = 0; - stream->pes.scr = -1; + stream->pes.scr = AV_NOPTS_VALUE; stream->frames = 0; stream->errors = 0; @@ -5521,7 +5521,7 @@ static hb_title_t *ffmpeg_title_scan( hb_stream_t *stream, hb_title_t *title ) static int64_t av_to_hb_pts( int64_t pts, double conv_factor ) { if ( pts == AV_NOPTS_VALUE ) - return -1; + return AV_NOPTS_VALUE; return (int64_t)( (double)pts * conv_factor ); } @@ -5643,11 +5643,11 @@ hb_buffer_t * hb_ffmpeg_read( hb_stream_t *stream ) buf->s.start = av_to_hb_pts( stream->ffmpeg_pkt->pts, tsconv ); buf->s.renderOffset = av_to_hb_pts( stream->ffmpeg_pkt->dts, tsconv ); - if ( buf->s.renderOffset >= 0 && buf->s.start == -1 ) + if ( buf->s.renderOffset >= 0 && buf->s.start == AV_NOPTS_VALUE ) { buf->s.start = buf->s.renderOffset; } - else if ( buf->s.renderOffset == -1 && buf->s.start >= 0 ) + else if ( buf->s.renderOffset == AV_NOPTS_VALUE && buf->s.start >= 0 ) { buf->s.renderOffset = buf->s.start; } diff --git a/libhb/sync.c b/libhb/sync.c index 3b0ee7e19..c95f9ad26 100644 --- a/libhb/sync.c +++ b/libhb/sync.c @@ -129,7 +129,7 @@ hb_work_object_t * hb_sync_init( hb_job_t * job ) pv->common = calloc( 1, sizeof( hb_sync_common_t ) ); pv->common->ref++; pv->common->mutex = hb_lock_init(); - pv->common->audio_pts_thresh = -1; + pv->common->audio_pts_thresh = AV_NOPTS_VALUE; pv->common->next_frame = hb_cond_init(); pv->common->pts_count = 1; if ( job->frame_to_start || job->pts_to_start ) @@ -316,7 +316,7 @@ static hb_buffer_t * mergeSubtitles(subtitle_sanitizer_t *sanitizer, int end) a->next = NULL; buf = a; } - else if (a != NULL && a->s.stop != -1) + else if (a != NULL && a->s.stop != AV_NOPTS_VALUE) { b = a->next; @@ -345,7 +345,7 @@ static hb_buffer_t * mergeSubtitles(subtitle_sanitizer_t *sanitizer, int end) sprintf((char*)buf->data, "%s\n%s", a->data, b->data); hb_buffer_close(&a); - if (b->s.stop != -1 && ABS(b->s.stop - b->s.start) <= 18000) + if (b->s.stop != AV_NOPTS_VALUE && ABS(b->s.stop - b->s.start) <= 18000) { // b and a completely overlap, remove b sanitizer->list_current = b->next; @@ -374,10 +374,10 @@ static hb_buffer_t * mergeSubtitles(subtitle_sanitizer_t *sanitizer, int end) if (buf != NULL) { - if (buf->s.stop != -1) + if (buf->s.stop != AV_NOPTS_VALUE) buf->s.duration = buf->s.stop - buf->s.start; else - buf->s.duration = -1; + buf->s.duration = AV_NOPTS_VALUE; if (last == NULL) { out = last = buf; @@ -416,13 +416,13 @@ static hb_buffer_t * sanitizeSubtitle( hb_lock( pv->common->mutex ); sub->s.start -= pv->common->video_pts_slip; - if (sub->s.stop != -1) + if (sub->s.stop != AV_NOPTS_VALUE) sub->s.stop -= pv->common->video_pts_slip; - if (sub->s.renderOffset != -1) + if (sub->s.renderOffset != AV_NOPTS_VALUE) sub->s.renderOffset -= pv->common->video_pts_slip; hb_unlock( pv->common->mutex ); - if (sanitizer->last != NULL && sanitizer->last->s.stop == -1) + if (sanitizer->last != NULL && sanitizer->last->s.stop == AV_NOPTS_VALUE) { sanitizer->last->s.stop = sub->s.start; } @@ -845,7 +845,7 @@ int syncVideoWork( hb_work_object_t * w, hb_buffer_t ** buf_in, sync->cur = cur = next; cur->sub = NULL; cur->s.start -= pv->common->video_pts_slip; - if (cur->s.renderOffset != -1) + if (cur->s.renderOffset != AV_NOPTS_VALUE) cur->s.renderOffset -= pv->common->video_pts_slip; cur->s.stop -= pv->common->video_pts_slip; sync->pts_skip = 0; |