Skip to content

Commit fcb1241

Browse files
committed
vcomp/lavc: simplify get_first_matching_pix_fmt
the iteration over the codec-supported pixfmts was a bit clumpy + improve var names + codec_pix_fmt - const ptr (not to be tempted to iterate with this var directly)
1 parent ecc8a51 commit fcb1241

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/video_compress/libavcodec.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -810,21 +810,22 @@ void print_pix_fmts(const list<enum AVPixelFormat>
810810
* Unusable pixel formats and a currently selected one are removed from
811811
* req_pix_fmts.
812812
*/
813-
static enum AVPixelFormat get_first_matching_pix_fmt(list<enum AVPixelFormat>::const_iterator &it,
814-
list<enum AVPixelFormat>::const_iterator end,
815-
const enum AVPixelFormat *codec_pix_fmts)
813+
static enum AVPixelFormat
814+
get_first_matching_pix_fmt(list<enum AVPixelFormat>::const_iterator &req_it,
815+
list<enum AVPixelFormat>::const_iterator end,
816+
const enum AVPixelFormat *const codec_pix_fmts)
816817
{
817818
if(codec_pix_fmts == NULL)
818819
return AV_PIX_FMT_NONE;
819820

820-
for ( ; it != end; it++) {
821-
const enum AVPixelFormat *tmp = codec_pix_fmts;
822-
enum AVPixelFormat fmt;
823-
while((fmt = *tmp++) != AV_PIX_FMT_NONE) {
824-
if (fmt == *it) {
825-
enum AVPixelFormat ret = *it++;
821+
for ( ; req_it != end; req_it++) {
822+
const enum AVPixelFormat *codec_it = codec_pix_fmts;
823+
while (*codec_it != AV_PIX_FMT_NONE) {
824+
if (*codec_it == *req_it) {
825+
enum AVPixelFormat ret = *req_it++;
826826
return ret;
827827
}
828+
codec_it++;
828829
}
829830
}
830831

0 commit comments

Comments
 (0)