@@ -107,6 +107,10 @@ void setChannelLayout(
107107
108108namespace {
109109#if LIBAVFILTER_VERSION_MAJOR > 7 // FFmpeg > 4
110+
111+ // Returns:
112+ // - the srcAVFrame's channel layout if srcAVFrame has desiredNumChannels
113+ // - the default channel layout with desiredNumChannels otherwise.
110114AVChannelLayout getDesiredChannelLayout (
111115 int desiredNumChannels,
112116 const UniqueAVFrame& srcAVFrame) {
@@ -118,8 +122,10 @@ AVChannelLayout getDesiredChannelLayout(
118122 }
119123 return desiredLayout;
120124}
125+
121126#else
122127
128+ // Same as above
123129int64_t getDesiredChannelLayout (
124130 int desiredNumChannels,
125131 const UniqueAVFrame& srcAVFrame) {
@@ -134,6 +140,7 @@ int64_t getDesiredChannelLayout(
134140#endif
135141} // namespace
136142
143+ // Sets dstAVFrame' channel layout to getDesiredChannelLayout(): see doc above
137144void setChannelLayout (
138145 UniqueAVFrame& dstAVFrame,
139146 const UniqueAVFrame& srcAVFrame,
@@ -147,11 +154,9 @@ void setChannelLayout(
147154 " Couldn't copy channel layout to avFrame: " ,
148155 getFFMPEGErrorStringFromErrorCode (status));
149156#else
150- if (desiredNumChannels == sourceNumChannels) {
151- dstAVFrame->channel_layout =
152- getDesiredChannelLayout (desiredNumChannels, srcAVFrame);
153- dstAVFrame->channels = desiredNumChannels;
154- }
157+ dstAVFrame->channel_layout =
158+ getDesiredChannelLayout (desiredNumChannels, srcAVFrame);
159+ dstAVFrame->channels = desiredNumChannels;
155160#endif
156161}
157162
0 commit comments