Skip to content

Commit ff3e34e

Browse files
committed
vcomp/lavc: remove codec_params
After recent changes, the map was accessed exclusively with get_codec_params so squash the data there.
1 parent fd38dbf commit ff3e34e

File tree

1 file changed

+25
-37
lines changed

1 file changed

+25
-37
lines changed

src/video_compress/libavcodec.cpp

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -192,57 +192,45 @@ static void print_codec_supp_pix_fmts(const enum AVPixelFormat *first);
192192
void usage(bool full);
193193
static void cleanup(struct state_video_compress_libav *s);
194194

195-
static map<codec_t, codec_params_t> codec_params = {
196-
{ H264, codec_params_t{
195+
const char *get_vp9_encoder(bool /* rgb */) {
196+
#ifdef __x86_64__
197+
return __builtin_cpu_supports("avx2") ? nullptr : "libaom-av1";
198+
#else
199+
return nullptr;
200+
#endif
201+
}
202+
codec_params_t
203+
get_codec_params(codec_t ug_codec)
204+
{
205+
switch (ug_codec) {
206+
case H264: return {
197207
[](bool is_rgb) { return is_rgb ? "libx264rgb" : "libx264"; },
198208
0.07 * 2 /* for H.264: 1 - low motion, 2 - medium motion, 4 - high motion */
199209
* 2, // take into consideration that our H.264 is less effective due to specific preset/tune
200210
// note - not used for libx264, which uses CRF by default
201211
setparam_h264_h265_av1,
202212
100
203-
}},
204-
{ H265, codec_params_t{
213+
};
214+
case H265: return {
205215
[](bool) { return "libx265"; },
206216
0.04 * 2 * 2, // note - not used for libx265, which uses CRF by default
207217
setparam_h264_h265_av1,
208218
101
209-
}},
210-
{ JPEG, codec_params_t{
211-
nullptr,
212-
1.2,
213-
setparam_jpeg,
214-
102
215-
}},
216-
{ VP8, codec_params_t{
217-
nullptr,
218-
0.4,
219-
setparam_vp8_vp9,
220-
103
221-
}},
222-
{ VP9, codec_params_t{
223-
[](bool) {
224-
return
225-
#ifdef __x86_64__
226-
!__builtin_cpu_supports("avx2") ? "libvpx-vp9" :
227-
#endif
228-
nullptr; },
229-
0.4,
230-
setparam_vp8_vp9,
231-
104
232-
}},
233-
{ AV1, codec_params_t{
219+
};
220+
case JPEG:
221+
return { nullptr, 1.2, setparam_jpeg, 102 };
222+
case VP8:
223+
return { nullptr, 0.4, setparam_vp8_vp9, 103 };
224+
case VP9:
225+
return { get_vp9_encoder, 0.4, setparam_vp8_vp9, 104 };
226+
case AV1: return {
234227
[](bool) { return is_arm_mac() ? "libaom-av1" : "libsvtav1"; },
235228
0.1,
236229
setparam_h264_h265_av1,
237230
600
238-
}},
239-
};
240-
codec_params_t
241-
get_codec_params(codec_t ug_codec)
242-
{
243-
auto it = codec_params.find(ug_codec);
244-
if (it != codec_params.end()) {
245-
return it->second;
231+
};
232+
default:
233+
break;
246234
}
247235
int capabilities_priority = 500 + (int) ug_codec;
248236
double avg_bpp = 0;

0 commit comments

Comments
 (0)