Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h264: using consts in MbPartPredMode function #25

Merged
merged 2 commits into from
Jul 7, 2019

Conversation

saxon-milton
Copy link
Member

@saxon-milton saxon-milton commented Jul 5, 2019

Resolves #14
Replacing usage of strings to represent macroblock partition prediction modes with int8 consts. Also made changes to affected code.

@saxon-milton saxon-milton merged commit 4b1f4bc into master Jul 7, 2019
errPartition = errors.New("partition must be 0")
)

func MbPartPredMode(data *SliceData, sliceType string, mbType, partition int) (mbPartPredMode, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't make exported functions return unexported types.

Copy link
Member Author

Choose a reason for hiding this comment

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

The function was already exported, and thought changing it would have been out of scope of the PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, but the return type could have been exported.

}
return modeName
return -1, errPartition
Copy link
Collaborator

Choose a reason for hiding this comment

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

-1 can have a name.

@@ -20,11 +20,16 @@ import (
"github.com/pkg/errors"
)

type macroblockPredictionMode uint8
type mbPartPredMode int8
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason for reducing the length of this name?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm trying to keep the naming more consistent with the specs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Clarity is more important than matching the spec; if matching the spec helps, do it, otherwise improve on it. A good example is the crypto/tls package and its constants/field names compared with the relevant RFCs.

Copy link
Member Author

Choose a reason for hiding this comment

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

I really think matching the specs as much as possible (unless it breaks go style) is good. It helps to find things in the spec more easily.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I disagree.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, i'll move away from that idea. Please take a look at the code and create issues if you see naming that could be better.

modeName := "UnknownPartPredMode"
// Errors used by MbPartPredMode.
var (
errNaMode = errors.New("no mode for given slice and mb type")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comments for these?

Copy link
Member Author

Choose a reason for hiding this comment

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

what kind of comments do they need ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Explaining what they mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

issues created


const (
intra4x4 macroblockPredictionMode = iota
intra4x4 mbPartPredMode = iota
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think these names could be better.

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.

h264/mbType.go: MbPartPredModes should be int consts not strings
3 participants