avdevice/dshow: query graph and sample time only once
No need to query twice, use value we've already unconditionally got. Improve variable names Signed-off-by: Diederick Niehorster <dcnieho@gmail.com> Reviewed-by: Roger Pack <rogerdpack2@gmail.com>
This commit is contained in:
committed by
Gyan Doshi
parent
7dc33aad45
commit
584b0fbe4b
@@ -295,9 +295,10 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample)
|
|||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
int buf_size; /* todo should be a long? */
|
int buf_size; /* todo should be a long? */
|
||||||
int index;
|
int index;
|
||||||
int64_t curtime;
|
int64_t chosentime;
|
||||||
int64_t orig_curtime;
|
int64_t sampletime;
|
||||||
int64_t graphtime;
|
int64_t graphtime;
|
||||||
|
int use_sample_time = 1;
|
||||||
const char *devtypename = (devtype == VideoDevice) ? "video" : "audio";
|
const char *devtypename = (devtype == VideoDevice) ? "video" : "audio";
|
||||||
IReferenceClock *clock = pin->filter->clock;
|
IReferenceClock *clock = pin->filter->clock;
|
||||||
int64_t dummy;
|
int64_t dummy;
|
||||||
@@ -313,24 +314,27 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample)
|
|||||||
s = priv_data;
|
s = priv_data;
|
||||||
ctx = s->priv_data;
|
ctx = s->priv_data;
|
||||||
|
|
||||||
IMediaSample_GetTime(sample, &orig_curtime, &dummy);
|
IMediaSample_GetTime(sample, &sampletime, &dummy);
|
||||||
orig_curtime += pin->filter->start_time;
|
|
||||||
IReferenceClock_GetTime(clock, &graphtime);
|
IReferenceClock_GetTime(clock, &graphtime);
|
||||||
if (devtype == VideoDevice && !ctx->use_video_device_timestamps) {
|
if (devtype == VideoDevice && !ctx->use_video_device_timestamps) {
|
||||||
/* PTS from video devices is unreliable. */
|
/* PTS from video devices is unreliable. */
|
||||||
IReferenceClock_GetTime(clock, &curtime);
|
chosentime = graphtime;
|
||||||
|
use_sample_time = 0;
|
||||||
} else {
|
} else {
|
||||||
IMediaSample_GetTime(sample, &curtime, &dummy);
|
if (sampletime > 400000000000000000LL) {
|
||||||
if(curtime > 400000000000000000LL) {
|
|
||||||
/* initial frames sometimes start < 0 (shown as a very large number here,
|
/* initial frames sometimes start < 0 (shown as a very large number here,
|
||||||
like 437650244077016960 which FFmpeg doesn't like.
|
like 437650244077016960 which FFmpeg doesn't like).
|
||||||
TODO figure out math. For now just drop them. */
|
TODO figure out math. For now just drop them. */
|
||||||
av_log(NULL, AV_LOG_DEBUG,
|
av_log(NULL, AV_LOG_DEBUG,
|
||||||
"dshow dropping initial (or ending) frame with odd PTS too high %"PRId64"\n", curtime);
|
"dshow dropping initial (or ending) frame with odd PTS too high %"PRId64"\n", sampletime);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
curtime += pin->filter->start_time;
|
chosentime = sampletime;
|
||||||
}
|
}
|
||||||
|
// media sample time is relative to graph start time
|
||||||
|
sampletime += pin->filter->start_time;
|
||||||
|
if (use_sample_time)
|
||||||
|
chosentime += pin->filter->start_time;
|
||||||
|
|
||||||
buf_size = IMediaSample_GetActualDataLength(sample);
|
buf_size = IMediaSample_GetActualDataLength(sample);
|
||||||
IMediaSample_GetPointer(sample, &buf);
|
IMediaSample_GetPointer(sample, &buf);
|
||||||
@@ -338,8 +342,8 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample)
|
|||||||
|
|
||||||
av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size %8d "
|
av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size %8d "
|
||||||
"timestamp %"PRId64" orig timestamp %"PRId64" graph timestamp %"PRId64" diff %"PRId64" %s\n",
|
"timestamp %"PRId64" orig timestamp %"PRId64" graph timestamp %"PRId64" diff %"PRId64" %s\n",
|
||||||
devtypename, buf_size, curtime, orig_curtime, graphtime, graphtime - orig_curtime, ctx->device_name[devtype]);
|
devtypename, buf_size, chosentime, sampletime, graphtime, graphtime - sampletime, ctx->device_name[devtype]);
|
||||||
pin->filter->callback(priv_data, index, buf, buf_size, curtime, devtype);
|
pin->filter->callback(priv_data, index, buf, buf_size, chosentime, devtype);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user