#include "h264data.h"
#include "mpegutils.h"
#include "parser.h"
+#include "refstruct.h"
#include "startcode.h"
typedef struct H264ParseContext {
s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
ff_h264_sei_uninit(&p->sei);
- p->sei.frame_packing.arrangement_cancel_flag = -1;
- p->sei.unregistered.x264_build = -1;
+ p->sei.common.frame_packing.arrangement_cancel_flag = -1;
+ p->sei.common.unregistered.x264_build = -1;
if (!buf_size)
return 0;
goto fail;
}
- av_buffer_unref(&p->ps.pps_ref);
- p->ps.pps = NULL;
- p->ps.sps = NULL;
- p->ps.pps_ref = av_buffer_ref(p->ps.pps_list[pps_id]);
- if (!p->ps.pps_ref)
- goto fail;
- p->ps.pps = (const PPS*)p->ps.pps_ref->data;
+ ff_refstruct_replace(&p->ps.pps, p->ps.pps_list[pps_id]);
p->ps.sps = p->ps.pps->sps;
sps = p->ps.sps;
}
if (sps->timing_info_present_flag) {
int64_t den = sps->time_scale;
- if (p->sei.unregistered.x264_build < 44U)
+ if (p->sei.common.unregistered.x264_build < 44U)
den *= 2;
av_reduce(&avctx->framerate.den, &avctx->framerate.num,
- sps->num_units_in_tick * avctx->ticks_per_frame, den, 1 << 30);
+ sps->num_units_in_tick * 2, den, 1 << 30);
}
av_freep(&rbsp.rbsp_buffer);
{
H264ParseContext *p = s->priv_data;
ParseContext *pc = &p->pc;
+ AVRational time_base = { 0, 1 };
int next;
if (!p->got_first) {
parse_nal_units(s, avctx, buf, buf_size);
if (avctx->framerate.num)
- avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
+ time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){2, 1}));
if (p->sei.picture_timing.cpb_removal_delay >= 0) {
s->dts_sync_point = p->sei.buffering_period.present;
s->dts_ref_dts_delta = p->sei.picture_timing.cpb_removal_delay;
}
if (s->dts_sync_point >= 0) {
- int64_t den = avctx->time_base.den * (int64_t)avctx->pkt_timebase.num;
+ int64_t den = time_base.den * (int64_t)avctx->pkt_timebase.num;
if (den > 0) {
- int64_t num = avctx->time_base.num * (int64_t)avctx->pkt_timebase.den;
+ int64_t num = time_base.num * (int64_t)avctx->pkt_timebase.den;
if (s->dts != AV_NOPTS_VALUE) {
// got DTS from the stream, update reference timestamp
- p->reference_dts = s->dts - av_rescale(s->dts_ref_dts_delta, num, den);
+ p->reference_dts = av_sat_sub64(s->dts, av_rescale(s->dts_ref_dts_delta, num, den));
} else if (p->reference_dts != AV_NOPTS_VALUE) {
// compute DTS based on reference timestamp
- s->dts = p->reference_dts + av_rescale(s->dts_ref_dts_delta, num, den);
+ s->dts = av_sat_add64(p->reference_dts, av_rescale(s->dts_ref_dts_delta, num, den));
}
if (p->reference_dts != AV_NOPTS_VALUE && s->pts == AV_NOPTS_VALUE)