Skip to content

Commit 785a05e

Browse files
committed
vcomp/lavc: improve codec printout
- print "Supported pixel formats" just in DEBUG - actually it isn't useful much, it doesn't list all the pixfmts but just those usable with input pixel format - print rather "Usable pixel formats" which is the intersect of 'Codec supported' and 'Supported' pixel formats + rename the option
1 parent 0977a88 commit 785a05e

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/video_compress/libavcodec.cpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static void set_codec_thread_mode(AVCodecContext *codec_ctx, struct setparam_par
190190

191191
static void print_codec_aux_usage(string const &name);
192192
static bool show_coder_help(string const &name, bool encoder = true);
193-
static void print_codec_supp_pix_fmts(const enum AVPixelFormat *first);
193+
static void print_codec_supp_pix_fmts(const enum AVPixelFormat *codec_pix_fmts);
194194
void usage(bool full);
195195
static void cleanup(struct state_video_compress_libav *s);
196196

@@ -780,25 +780,41 @@ static int vaapi_init(struct AVCodecContext *s){
780780
}
781781
#endif
782782

783-
void print_codec_supp_pix_fmts(const enum AVPixelFormat *first) {
783+
void
784+
print_codec_supp_pix_fmts(const enum AVPixelFormat *const codec_pix_fmts)
785+
{
784786
log_msg(log_level,
785787
MOD_NAME "Codec supported pixel formats: " TBOLD("%s") "\n",
786-
get_avpixfmts_names(first));
788+
get_avpixfmts_names(codec_pix_fmts));
787789
}
788790

789-
void print_pix_fmts(const list<enum AVPixelFormat>
790-
&req_pix_fmts, const enum AVPixelFormat *first) {
791-
print_codec_supp_pix_fmts(first);
791+
void
792+
print_pix_fmts(const list<enum AVPixelFormat> &req_pix_fmts,
793+
const enum AVPixelFormat *const codec_pix_fmts)
794+
{
795+
print_codec_supp_pix_fmts(codec_pix_fmts);
792796

797+
// available pixel formats with respect to input pixel format
793798
enum AVPixelFormat pixfmts[AV_PIX_FMT_NB];
794799
enum AVPixelFormat *pixfmts_it = pixfmts;
800+
// intersection of pixfmts and codec_pix_fmts (codec supported fmts)
801+
enum AVPixelFormat intersect[AV_PIX_FMT_NB];
802+
enum AVPixelFormat *intersect_it = intersect;
795803
for (const auto &c : req_pix_fmts) {
796804
*pixfmts_it++ = c;
805+
const enum AVPixelFormat *codec_it = codec_pix_fmts;
806+
while (*codec_it != AV_PIX_FMT_NONE) {
807+
if (c == *codec_it++) {
808+
*intersect_it++ = c;
809+
break;
810+
}
811+
}
797812
}
798-
*pixfmts_it++ = AV_PIX_FMT_NONE;
799-
log_msg(log_level,
800-
MOD_NAME "Supported pixel formats: " TBOLD("%s") "\n",
801-
get_avpixfmts_names(pixfmts));
813+
*pixfmts_it = *intersect_it = AV_PIX_FMT_NONE;
814+
log_msg(log_level, MOD_NAME "Usable pixel formats: " TBOLD("%s") "\n",
815+
get_avpixfmts_names(intersect));
816+
MSG(DEBUG, "Supported pixel formats: " TBOLD("%s") "\n",
817+
get_avpixfmts_names(pixfmts));
802818
}
803819

804820
/**

0 commit comments

Comments
 (0)