MT#65420 simplify and move set_av_opt_intstr

Change-Id: I0d6bac7441432756fe01f45f3a87f12b8e1db1e6
pull/2169/head
Richard Fuchs 3 weeks ago
parent 91ec5aff6a
commit 2ab27737ff

@ -3,18 +3,6 @@
#include "bitstr.h"
static int codeclib_set_av_opt_intstr(encoder_t *enc, const char *opt, str *val) {
int i = val ? str_to_i(val, -1) : -1;
if (i == -1) {
ilog(LOG_WARN, "Failed to parse '" STR_FORMAT "' as integer value for ffmpeg option '%s'",
STR_FMT0(val), opt);
return -1;
}
return codeclib_set_av_opt_int(enc, opt, i);
}
static const unsigned int amr_bitrates[AMR_FT_TYPES] = {
4750, // 0
5150, // 1
@ -155,12 +143,8 @@ static void amr_set_enc_codec_options(str *key, str *value, void *data) {
; // not an encoder option
else if (!str_cmp(key, "mode-change-interval"))
; // not an encoder option
else {
// our string might not be null terminated
char *s = g_strdup_printf(STR_FORMAT, STR_FMT(key));
codeclib_set_av_opt_intstr(enc, s, value);
g_free(s);
}
else
codeclib_set_av_opt_intstr(enc, key, value);
}
static void amr_set_enc_options(encoder_t *enc, const str *codec_opts) {
amr_set_encdec_options(&enc->codec_options, enc->def);

@ -316,6 +316,18 @@ int codeclib_set_av_opt_int(encoder_t *enc, const char *opt, int64_t val) {
}
int codeclib_set_av_opt_intstr(encoder_t *enc, const str *opt, const str *val) {
g_autoptr(char) s = g_strdup_printf(STR_FORMAT, STR_FMT(opt));
int i = val ? str_to_i(val, -1) : -1;
if (i == -1) {
ilog(LOG_WARN, "Failed to parse '" STR_FORMAT "' as integer value for ffmpeg option '%s'",
STR_FMT0(val), s);
return -1;
}
return codeclib_set_av_opt_int(enc, s, i);
}
codec_def_t *codec_def_make_generic_av(enum AVCodecID id) {
{
RWLOCK_R(&generic_ffmpeg_codecs_lock);

@ -27,6 +27,7 @@ int avc_encoder_input(encoder_t *enc, AVFrame **frame);
void avc_encoder_close(encoder_t *enc);
int codeclib_set_av_opt_int(encoder_t *enc, const char *opt, int64_t val);
int codeclib_set_av_opt_intstr(encoder_t *enc, const str *opt, const str *val);
void codeclib_key_value_parse(const str *instr,
void (*cb)(str *key, str *value, void *data), void *data);

Loading…
Cancel
Save