Skip to content

Conversation

@dhruv2295
Copy link

No description provided.

}

private fun findPrevKeyFrame(positionUs: Long, keyFrameTimestampsUs: ArrayList<Long>): Long {
for(i in 0 until keyFrameTimestampsUs.size) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we already have a search method.
We should use that.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we are relying on search to request and add more keyframes if required.
which means We should not use keyFrameTimestampUs list.

And let's use proper variable names

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A list cannot have a name like keyFrameTimestampsUs

}

private val stubs = ArrayDeque<Stub>()
private val bucketListMap = LinkedHashMap<Long, ArrayList<Stub>>()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can create the final list in runtime in the reorder method itself

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should maintain as minimal state as possible.
And in this case, we don't get a huge advantage by maintaining this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initially i had this inside only. but it didn't make sense creating new list for every request @sahilbajaj . that's why moved it to global

Copy link

@sahilbajaj sahilbajaj Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will happen for every batch. And batch frequency is big enough.. like more than 1 sec on an average
And lists will be small in size.
It's not a considerable optimization for sure. Not worth it

finalList.clear()

forEach {
val keyFrame = findPrevKeyFrame(it.positionUs, keyFrameTimestampsUs)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

findPrevKeyFrame can return -1.
Either we stop returning -1 from there.. or Handle -1 here, whichever is better

Copy link

@sahilbajaj sahilbajaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

@dhruv2295 dhruv2295 force-pushed the thumbnailBucketSorting branch from 5c636eb to 1b827fe Compare February 28, 2022 10:05
forEach {
val nextKeyFrameIndex = source.search(it.positionUs)
val previousKeyFrameUs =
source.keyFrameTimestampsUsList[

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be replaced with another extension method.
like source.getKeyFrameAt(pos: Int)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, the list shouldn't be exposed outside.

@sahilbajaj sahilbajaj force-pushed the thumbnailBucketSorting branch from 1e8c8bc to d24387f Compare February 28, 2022 17:13
@sahilbajaj sahilbajaj merged commit c282629 into dev Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants