本文整理汇总了C++中AP4_Sample::GetCtsDelta方法的典型用法代码示例。如果您正苦于以下问题:C++ AP4_Sample::GetCtsDelta方法的具体用法?C++ AP4_Sample::GetCtsDelta怎么用?C++ AP4_Sample::GetCtsDelta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP4_Sample
的用法示例。
在下文中一共展示了AP4_Sample::GetCtsDelta方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSampleDescription
/*----------------------------------------------------------------------
| AP4_Track::Clone
+---------------------------------------------------------------------*/
AP4_Track*
AP4_Track::Clone(AP4_Result* result)
{
AP4_SyntheticSampleTable* sample_table = new AP4_SyntheticSampleTable();
// default return value
if (result) *result = AP4_SUCCESS;
// add clones of the sample descriptions to the new sample table
for (unsigned int i=0; ;i++) {
AP4_SampleDescription* sample_description = GetSampleDescription(i);
if (sample_description == NULL) break;
sample_table->AddSampleDescription(sample_description->Clone());
}
AP4_Sample sample;
AP4_Ordinal index = 0;
while (AP4_SUCCEEDED(GetSample(index, sample))) {
AP4_ByteStream* data_stream;
data_stream = sample.GetDataStream();
sample_table->AddSample(*data_stream,
sample.GetOffset(),
sample.GetSize(),
sample.GetDuration(),
sample.GetDescriptionIndex(),
sample.GetDts(),
sample.GetCtsDelta(),
sample.IsSync());
AP4_RELEASE(data_stream); // release our ref, the table has kept its own ref.
index++;
}
// create the cloned track
AP4_Track* clone = new AP4_Track(GetType(),
sample_table,
GetId(),
GetMovieTimeScale(),
GetDuration(),
GetMediaTimeScale(),
GetMediaDuration(),
GetTrackLanguage(),
GetWidth(),
GetHeight());
return clone;
}
示例2: GetSampleCount
/*----------------------------------------------------------------------
| AP4_SampleTable::GenerateStblAtom
+---------------------------------------------------------------------*/
AP4_Result
AP4_SampleTable::GenerateStblAtom(AP4_ContainerAtom*& stbl)
{
// create the stbl container
stbl = new AP4_ContainerAtom(AP4_ATOM_TYPE_STBL);
// create the stsd atom
AP4_StsdAtom* stsd = new AP4_StsdAtom(this);
// create the stsz atom
AP4_StszAtom* stsz = new AP4_StszAtom();
// create the stsc atom
AP4_StscAtom* stsc = new AP4_StscAtom();
// create the stts atom
AP4_SttsAtom* stts = new AP4_SttsAtom();
// create the stss atom
AP4_StssAtom* stss = new AP4_StssAtom();
// declare the ctts atom (may be created later)
AP4_CttsAtom* ctts = NULL;
// start chunk table
AP4_Ordinal current_chunk_index = 0;
AP4_Size current_chunk_size = 0;
AP4_Position current_chunk_offset = 0;
AP4_Cardinal current_samples_in_chunk = 0;
AP4_Ordinal current_sample_description_index = 0;
AP4_UI32 current_duration = 0;
AP4_Cardinal current_duration_run = 0;
AP4_UI32 current_cts_delta = 0;
AP4_Cardinal current_cts_delta_run = 0;
AP4_Array<AP4_Position> chunk_offsets;
// process all the samples
bool all_samples_are_sync = false;
AP4_Cardinal sample_count = GetSampleCount();
for (AP4_Ordinal i=0; i<sample_count; i++) {
AP4_Sample sample;
GetSample(i, sample);
// update DTS table
AP4_UI32 new_duration = sample.GetDuration();
if (new_duration != current_duration && current_duration_run != 0) {
// emit a new stts entry
stts->AddEntry(current_duration_run, current_duration);
// reset the run count
current_duration_run = 0;
}
++current_duration_run;
current_duration = new_duration;
// update CTS table
AP4_UI32 new_cts_delta = sample.GetCtsDelta();
if (new_cts_delta != current_cts_delta && current_cts_delta_run != 0) {
// create a ctts atom if we don't have one
if (ctts == NULL) ctts = new AP4_CttsAtom();
//emit a new ctts entry
ctts->AddEntry(current_cts_delta_run, current_cts_delta);
// reset the run count
current_cts_delta_run = 0;
}
++current_cts_delta_run;
current_cts_delta = new_cts_delta;
// add an entry into the stsz atom
stsz->AddEntry(sample.GetSize());
// update the sync sample table
if (sample.IsSync()) {
stss->AddEntry(i+1);
if (i==0) all_samples_are_sync = true;
} else {
all_samples_are_sync = false;
}
// see in which chunk this sample is
AP4_Ordinal chunk_index = 0;
AP4_Ordinal position_in_chunk = 0;
AP4_Result result = GetSampleChunkPosition(i, chunk_index, position_in_chunk);
if (AP4_SUCCEEDED(result)) {
if (chunk_index != current_chunk_index && current_samples_in_chunk != 0) {
// new chunk
chunk_offsets.Append(current_chunk_offset);
current_chunk_offset += current_chunk_size;
stsc->AddEntry(1,
current_samples_in_chunk,
current_sample_description_index+1);
current_samples_in_chunk = 0;
current_chunk_size = 0;
//.........这里部分代码省略.........