int normalize_mix_level; /* mix level normalization (boolean) */
int dither_method; /* dither algorithm */
char * name; /* Output track name */
- int delay;
} out;
/* Input */
if ( ( pv->frameno_in ) == pv->job->areBframes )
{
pv->dts_delay = buf->s.start;
- pv->job->config.h264.init_delay = pv->dts_delay;
+ pv->job->config.init_delay = pv->dts_delay;
}
}
}
hb_error("encavcodecaInit: hb_avcodec_open() failed");
return 1;
}
+ w->config->init_delay = av_rescale_q(context->delay, context->time_base,
+ (AVRational){1, 90000});
+
// avcodec_open populates the opts dictionary with the
// things it didn't recognize.
AVDictionaryEntry *t = NULL;
w->config->extradata.length = context->extradata_size;
}
- audio->config.out.delay = av_rescale_q(context->delay, context->time_base,
- (AVRational){1, 90000});
-
return 0;
}
audio->config.out.samplerate));
frame.pts = av_rescale(frame.pts, pv->context->sample_rate, 90000);
-
// Encode
ret = avcodec_send_frame(pv->context, &frame);
if (ret < 0)
buf->s.start = pic_out->i_pts;
buf->s.stop = buf->s.start + buf->s.duration;
buf->s.renderOffset = pic_out->i_dts;
- if ( !w->config->h264.init_delay && pic_out->i_dts < 0 )
+ if ( !w->config->init_delay && pic_out->i_dts < 0 )
{
- w->config->h264.init_delay = -pic_out->i_dts;
+ w->config->init_delay = -pic_out->i_dts;
}
/* Determine what type of frame we have. */
buf->s.stop = pic_out->pts + buf->s.duration;
buf->s.start = pic_out->pts;
buf->s.renderOffset = pic_out->dts;
- if (w->config->h264.init_delay == 0 && pic_out->dts < 0)
+ if (w->config->init_delay == 0 && pic_out->dts < 0)
{
- w->config->h264.init_delay -= pic_out->dts;
+ w->config->init_delay -= pic_out->dts;
}
switch (pic_out->sliceType)
typedef struct hb_metadata_s hb_metadata_t;
typedef struct hb_coverart_s hb_coverart_t;
typedef struct hb_state_s hb_state_t;
-typedef union hb_esconfig_u hb_esconfig_t;
+typedef struct hb_esconfig_s hb_esconfig_t;
typedef struct hb_work_private_s hb_work_private_t;
typedef struct hb_work_object_s hb_work_object_t;
typedef struct hb_filter_private_s hb_filter_private_t;
* Work objects
**********************************************************************/
#define HB_CONFIG_MAX_SIZE (2*8192)
-union hb_esconfig_u
+struct hb_esconfig_s
{
+ int init_delay;
+
+ union
+ {
struct
{
int sps_length;
uint8_t pps[HB_CONFIG_MAX_SIZE];
int pps_length;
- int init_delay;
} h264;
struct
uint8_t headers[3][HB_CONFIG_MAX_SIZE];
char *language;
} vorbis;
+ };
};
enum
AVFormatContext * oc;
AVRational time_base;
+ int64_t delay;
int ntracks;
hb_mux_data_t ** tracks;
return out;
}
+static int64_t compute_delay(hb_job_t * job)
+{
+ int64_t delay = 0;
+
+ if (job->config.init_delay > delay)
+ delay = job->config.init_delay;
+
+ int ii, count;
+ count = hb_list_count(job->list_audio);
+ for (ii = 0; ii < count; ii++)
+ {
+ hb_audio_t * audio = hb_list_item(job->list_audio, ii);
+ if (audio->priv.config.init_delay > delay)
+ delay = audio->priv.config.init_delay;
+ }
+
+ return delay;
+}
+
/**********************************************************************
* avformatInit
**********************************************************************
uint8_t need_fonts = 0;
char *lang;
+ m->delay = AV_NOPTS_VALUE;
max_tracks = 1 + hb_list_count( job->list_audio ) +
hb_list_count( job->list_subtitle );
hb_job_t * job = m->job;
uint8_t * sub_out = NULL;
+ if (m->delay == AV_NOPTS_VALUE)
+ {
+ m->delay = compute_delay(m->job);
+ }
if (track->type == MUX_TYPE_VIDEO && (job->mux & HB_MUX_MASK_MP4))
{
// compute dts duration for MP4 files
return 0;
}
+ buf->s.start += m->delay;
+ if (buf->s.renderOffset != AV_NOPTS_VALUE)
+ {
+ buf->s.renderOffset += m->delay;
+ }
+ if (buf->s.stop != AV_NOPTS_VALUE)
+ {
+ buf->s.stop += m->delay;
+ }
if (track->type == MUX_TYPE_VIDEO && (job->mux & HB_MUX_MASK_MKV) &&
buf->s.renderOffset < 0)
{