int av_opt_set(void *obj, const char *name, const char *val, int search_flags)

{

    int ret;

    void *dst, *target_obj;

    const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);

    if (!o || !target_obj)

        return AVERROR_OPTION_NOT_FOUND;

    if (!val && (o->type != AV_OPT_TYPE_STRING &&

                 o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT &&

                 o->type != AV_OPT_TYPE_IMAGE_SIZE && o->type != AV_OPT_TYPE_VIDEO_RATE &&

                 o->type != AV_OPT_TYPE_DURATION && o->type != AV_OPT_TYPE_COLOR &&

                 o->type != AV_OPT_TYPE_CHANNEL_LAYOUT))

        return AVERROR(EINVAL);



    dst = ((uint8_t*)target_obj) + o->offset;

    switch (o->type) {

    case AV_OPT_TYPE_STRING:   return set_string(obj, o, val, dst);

    case AV_OPT_TYPE_BINARY:   return set_string_binary(obj, o, val, dst);

    case AV_OPT_TYPE_FLAGS:

    case AV_OPT_TYPE_INT:

    case AV_OPT_TYPE_INT64:

    case AV_OPT_TYPE_FLOAT:

    case AV_OPT_TYPE_DOUBLE:

    case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, target_obj, o, val, dst);

    case AV_OPT_TYPE_IMAGE_SIZE:

        if (!val || !strcmp(val, "none")) {

            *(int *)dst = *((int *)dst + 1) = 0;

            return 0;

        }

        ret = av_parse_video_size(dst, ((int *)dst) + 1, val);

        if (ret < 0)

            av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as image size\n", val);

        return ret;

    case AV_OPT_TYPE_VIDEO_RATE:

        if (!val) {

            ret = AVERROR(EINVAL);

        } else {

            ret = av_parse_video_rate(dst, val);

        }

        if (ret < 0)

            av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as video rate\n", val);

        return ret;

    case AV_OPT_TYPE_PIXEL_FMT:

        if (!val || !strcmp(val, "none")) {

            ret = AV_PIX_FMT_NONE;

        } else {

            ret = av_get_pix_fmt(val);

            if (ret == AV_PIX_FMT_NONE) {

                char *tail;

                ret = strtol(val, &tail, 0);

                if (*tail || (unsigned)ret >= AV_PIX_FMT_NB) {

                    av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as pixel format\n", val);

                    return AVERROR(EINVAL);

                }

            }

        }

        *(enum AVPixelFormat *)dst = ret;

        return 0;

    case AV_OPT_TYPE_SAMPLE_FMT:

        if (!val || !strcmp(val, "none")) {

            ret = AV_SAMPLE_FMT_NONE;

        } else {

            ret = av_get_sample_fmt(val);

            if (ret == AV_SAMPLE_FMT_NONE) {

                char *tail;

                ret = strtol(val, &tail, 0);

                if (*tail || (unsigned)ret >= AV_SAMPLE_FMT_NB) {

                    av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as sample format\n", val);

                    return AVERROR(EINVAL);

                }

            }

        }

        *(enum AVSampleFormat *)dst = ret;

        return 0;

    case AV_OPT_TYPE_DURATION:

        if (!val) {

            *(int64_t *)dst = 0;

            return 0;

        } else {

            if ((ret = av_parse_time(dst, val, 1)) < 0)

                av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val);

            return ret;

        }

        break;

    case AV_OPT_TYPE_COLOR:

        if (!val) {

            return 0;

        } else {

            ret = av_parse_color(dst, val, -1, obj);

            if (ret < 0)

                av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as color\n", val);

            return ret;

        }

        break;

    case AV_OPT_TYPE_CHANNEL_LAYOUT:

        if (!val || !strcmp(val, "none")) {

            *(int64_t *)dst = 0;

        } else {

#if FF_API_GET_CHANNEL_LAYOUT_COMPAT

            int64_t cl = ff_get_channel_layout(val, 0);

#else

            int64_t cl = av_get_channel_layout(val);

#endif

            if (!cl) {

                av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as channel layout\n", val);

                ret = AVERROR(EINVAL);

            }

            *(int64_t *)dst = cl;

            return ret;

        }

        break;

    }



    av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");

    return AVERROR(EINVAL);

}

int av_opt_set(void *obj, const char *name, const char *val, int search_flags)

{

    int ret;

    void *dst, *target_obj;

    const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);

    if (!o || !target_obj)

        return AVERROR_OPTION_NOT_FOUND;

    if (!val && (o->type != AV_OPT_TYPE_STRING &&

                 o->type != AV_OPT_TYPE_PIXEL_FMT && o->type != AV_OPT_TYPE_SAMPLE_FMT &&

                 o->type != AV_OPT_TYPE_IMAGE_SIZE && o->type != AV_OPT_TYPE_VIDEO_RATE &&

                 o->type != AV_OPT_TYPE_DURATION && o->type != AV_OPT_TYPE_COLOR &&

                 o->type != AV_OPT_TYPE_CHANNEL_LAYOUT))

        return AVERROR(EINVAL);



    dst = ((uint8_t*)target_obj) + o->offset;

    switch (o->type) {

    case AV_OPT_TYPE_STRING:   return set_string(obj, o, val, dst);

    case AV_OPT_TYPE_BINARY:   return set_string_binary(obj, o, val, dst);

    case AV_OPT_TYPE_FLAGS:

    case AV_OPT_TYPE_INT:

    case AV_OPT_TYPE_INT64:

    case AV_OPT_TYPE_FLOAT:

    case AV_OPT_TYPE_DOUBLE:

    case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, target_obj, o, val, dst);

    case AV_OPT_TYPE_IMAGE_SIZE:

        if (!val || !strcmp(val, "none")) {

            *(int *)dst = *((int *)dst + 1) = 0;

            return 0;

        }

        ret = av_parse_video_size(dst, ((int *)dst) + 1, val);

        if (ret < 0)

            av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as image size\n", val);

        return ret;

    case AV_OPT_TYPE_VIDEO_RATE:

        if (!val) {

            ret = AVERROR(EINVAL);

        } else {

            ret = av_parse_video_rate(dst, val);

        }

        if (ret < 0)

            av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as video rate\n", val);

        return ret;

    case AV_OPT_TYPE_PIXEL_FMT:

        if (!val || !strcmp(val, "none")) {

            ret = AV_PIX_FMT_NONE;

        } else {

            ret = av_get_pix_fmt(val);

            if (ret == AV_PIX_FMT_NONE) {

                char *tail;

                ret = strtol(val, &tail, 0);

                if (*tail || (unsigned)ret >= AV_PIX_FMT_NB) {

                    av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as pixel format\n", val);

                    return AVERROR(EINVAL);

                }

            }

        }

        *(enum AVPixelFormat *)dst = ret;

        return 0;

    case AV_OPT_TYPE_SAMPLE_FMT:

        if (!val || !strcmp(val, "none")) {

            ret = AV_SAMPLE_FMT_NONE;

        } else {

            ret = av_get_sample_fmt(val);

            if (ret == AV_SAMPLE_FMT_NONE) {

                char *tail;

                ret = strtol(val, &tail, 0);

                if (*tail || (unsigned)ret >= AV_SAMPLE_FMT_NB) {

                    av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as sample format\n", val);

                    return AVERROR(EINVAL);

                }

            }

        }

        *(enum AVSampleFormat *)dst = ret;

        return 0;

    case AV_OPT_TYPE_DURATION:

        if (!val) {

            *(int64_t *)dst = 0;

            return 0;

        } else {

            if ((ret = av_parse_time(dst, val, 1)) < 0)

                av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", val);

            return ret;

        }

        break;

    case AV_OPT_TYPE_COLOR:

        if (!val) {

            return 0;

        } else {

            ret = av_parse_color(dst, val, -1, obj);

            if (ret < 0)

                av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as color\n", val);

            return ret;

        }

        break;

    case AV_OPT_TYPE_CHANNEL_LAYOUT:

        if (!val || !strcmp(val, "none")) {

            *(int64_t *)dst = 0;

        } else {

#if FF_API_GET_CHANNEL_LAYOUT_COMPAT

            int64_t cl = ff_get_channel_layout(val, 0);

#else

            int64_t cl = av_get_channel_layout(val);

#endif

            if (!cl) {

                av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as channel layout\n", val);

                ret = AVERROR(EINVAL);

            }

            *(int64_t *)dst = cl;

            return ret;

        }

        break;

    }



    av_log(obj, AV_LOG_ERROR, "Invalid option type.\n");

    return AVERROR(EINVAL);

}

    int ret;
int FUNC_0(void *VAR_0, const char *VAR_1, const char *VAR_2, int VAR_3)

{

    int VAR_4;

    void *VAR_5, *VAR_6;

    const AVOption *VAR_7 = av_opt_find2(VAR_0, VAR_1, NULL, 0, VAR_3, &VAR_6);

    if (!VAR_7 || !VAR_6)

        return AVERROR_OPTION_NOT_FOUND;

    if (!VAR_2 && (VAR_7->type != AV_OPT_TYPE_STRING &&

                 VAR_7->type != AV_OPT_TYPE_PIXEL_FMT && VAR_7->type != AV_OPT_TYPE_SAMPLE_FMT &&

                 VAR_7->type != AV_OPT_TYPE_IMAGE_SIZE && VAR_7->type != AV_OPT_TYPE_VIDEO_RATE &&

                 VAR_7->type != AV_OPT_TYPE_DURATION && VAR_7->type != AV_OPT_TYPE_COLOR &&

                 VAR_7->type != AV_OPT_TYPE_CHANNEL_LAYOUT))

        return AVERROR(EINVAL);



    VAR_5 = ((uint8_t*)VAR_6) + VAR_7->offset;

    switch (VAR_7->type) {

    case AV_OPT_TYPE_STRING:   return set_string(VAR_0, VAR_7, VAR_2, VAR_5);

    case AV_OPT_TYPE_BINARY:   return set_string_binary(VAR_0, VAR_7, VAR_2, VAR_5);

    case AV_OPT_TYPE_FLAGS:

    case AV_OPT_TYPE_INT:

    case AV_OPT_TYPE_INT64:

    case AV_OPT_TYPE_FLOAT:

    case AV_OPT_TYPE_DOUBLE:

    case AV_OPT_TYPE_RATIONAL: return set_string_number(VAR_0, VAR_6, VAR_7, VAR_2, VAR_5);

    case AV_OPT_TYPE_IMAGE_SIZE:

        if (!VAR_2 || !strcmp(VAR_2, "none")) {

            *(int *)VAR_5 = *((int *)VAR_5 + 1) = 0;

            return 0;

        }

        VAR_4 = av_parse_video_size(VAR_5, ((int *)VAR_5) + 1, VAR_2);

        if (VAR_4 < 0)

            av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as image size\n", VAR_2);

        return VAR_4;

    case AV_OPT_TYPE_VIDEO_RATE:

        if (!VAR_2) {

            VAR_4 = AVERROR(EINVAL);

        } else {

            VAR_4 = av_parse_video_rate(VAR_5, VAR_2);

        }

        if (VAR_4 < 0)

            av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as video rate\n", VAR_2);

        return VAR_4;

    case AV_OPT_TYPE_PIXEL_FMT:

        if (!VAR_2 || !strcmp(VAR_2, "none")) {

            VAR_4 = AV_PIX_FMT_NONE;

        } else {

            VAR_4 = av_get_pix_fmt(VAR_2);

            if (VAR_4 == AV_PIX_FMT_NONE) {

                char *VAR_9;

                VAR_4 = strtol(VAR_2, &VAR_9, 0);

                if (*VAR_9 || (unsigned)VAR_4 >= AV_PIX_FMT_NB) {

                    av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as pixel format\n", VAR_2);

                    return AVERROR(EINVAL);

                }

            }

        }

        *(enum AVPixelFormat *)VAR_5 = VAR_4;

        return 0;

    case AV_OPT_TYPE_SAMPLE_FMT:

        if (!VAR_2 || !strcmp(VAR_2, "none")) {

            VAR_4 = AV_SAMPLE_FMT_NONE;

        } else {

            VAR_4 = av_get_sample_fmt(VAR_2);

            if (VAR_4 == AV_SAMPLE_FMT_NONE) {

                char *VAR_9;

                VAR_4 = strtol(VAR_2, &VAR_9, 0);

                if (*VAR_9 || (unsigned)VAR_4 >= AV_SAMPLE_FMT_NB) {

                    av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as sample format\n", VAR_2);

                    return AVERROR(EINVAL);

                }

            }

        }

        *(enum AVSampleFormat *)VAR_5 = VAR_4;

        return 0;

    case AV_OPT_TYPE_DURATION:

        if (!VAR_2) {

            *(int64_t *)VAR_5 = 0;

            return 0;

        } else {

            if ((VAR_4 = av_parse_time(VAR_5, VAR_2, 1)) < 0)

                av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", VAR_2);

            return VAR_4;

        }

        break;

    case AV_OPT_TYPE_COLOR:

        if (!VAR_2) {

            return 0;

        } else {

            VAR_4 = av_parse_color(VAR_5, VAR_2, -1, VAR_0);

            if (VAR_4 < 0)

                av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as color\n", VAR_2);

            return VAR_4;

        }

        break;

    case AV_OPT_TYPE_CHANNEL_LAYOUT:

        if (!VAR_2 || !strcmp(VAR_2, "none")) {

            *(int64_t *)VAR_5 = 0;

        } else {

#if FF_API_GET_CHANNEL_LAYOUT_COMPAT

            int64_t cl = ff_get_channel_layout(VAR_2, 0);

#else

            int64_t cl = av_get_channel_layout(VAR_2);

#endif

            if (!cl) {

                av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as channel layout\n", VAR_2);

                VAR_4 = AVERROR(EINVAL);

            }

            *(int64_t *)VAR_5 = cl;

            return VAR_4;

        }

        break;

    }



    av_log(VAR_0, AV_LOG_ERROR, "Invalid option type.\n");

    return AVERROR(EINVAL);

}

int FUNC_0(void *VAR_0, const char *VAR_1, const char *VAR_2, int VAR_3)
{ int VAR_4; void *VAR_5, *VAR_6; const AVOption *VAR_7 = av_opt_find2(VAR_0, VAR_1, NULL, 0, VAR_3, &VAR_6); if (!VAR_7 || !VAR_6)
return AVERROR_OPTION_NOT_FOUND; if (!VAR_2 && (VAR_7->type != AV_OPT_TYPE_STRING &&
VAR_7->type != AV_OPT_TYPE_PIXEL_FMT && VAR_7->type != AV_OPT_TYPE_SAMPLE_FMT &&
VAR_7->type != AV_OPT_TYPE_IMAGE_SIZE && VAR_7->type != AV_OPT_TYPE_VIDEO_RATE &&
VAR_7->type != AV_OPT_TYPE_DURATION && VAR_7->type != AV_OPT_TYPE_COLOR &&
VAR_7->type != AV_OPT_TYPE_CHANNEL_LAYOUT))
return AVERROR(EINVAL); VAR_5 = ((uint8_t*)VAR_6) + VAR_7->offset; switch (VAR_7->type) { case AV_OPT_TYPE_STRING:   return set_string(VAR_0, VAR_7, VAR_2, VAR_5); case AV_OPT_TYPE_BINARY:   return set_string_binary(VAR_0, VAR_7, VAR_2, VAR_5); case AV_OPT_TYPE_FLAGS:
case AV_OPT_TYPE_INT:
case AV_OPT_TYPE_INT64:
case AV_OPT_TYPE_FLOAT:
case AV_OPT_TYPE_DOUBLE:
case AV_OPT_TYPE_RATIONAL: return set_string_number(VAR_0, VAR_6, VAR_7, VAR_2, VAR_5); case AV_OPT_TYPE_IMAGE_SIZE:
if (!VAR_2 || !strcmp(VAR_2, "none")) { *(int *)VAR_5 = *((int *)VAR_5 + 1) = 0; return 0; } VAR_4 = av_parse_video_size(VAR_5, ((int *)VAR_5) + 1, VAR_2); if (VAR_4 < 0)
av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as image size\n", VAR_2); return VAR_4; case AV_OPT_TYPE_VIDEO_RATE:
if (!VAR_2) { VAR_4 = AVERROR(EINVAL); } else { VAR_4 = av_parse_video_rate(VAR_5, VAR_2); } if (VAR_4 < 0)
av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as video rate\n", VAR_2); return VAR_4; case AV_OPT_TYPE_PIXEL_FMT:
if (!VAR_2 || !strcmp(VAR_2, "none")) { VAR_4 = AV_PIX_FMT_NONE; } else { VAR_4 = av_get_pix_fmt(VAR_2); if (VAR_4 == AV_PIX_FMT_NONE) { char *VAR_9; VAR_4 = strtol(VAR_2, &VAR_9, 0); if (*VAR_9 || (unsigned)VAR_4 >= AV_PIX_FMT_NB) { av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as pixel format\n", VAR_2); return AVERROR(EINVAL); } } } *(enum AVPixelFormat *)VAR_5 = VAR_4; return 0; case AV_OPT_TYPE_SAMPLE_FMT:
if (!VAR_2 || !strcmp(VAR_2, "none")) { VAR_4 = AV_SAMPLE_FMT_NONE; } else { VAR_4 = av_get_sample_fmt(VAR_2); if (VAR_4 == AV_SAMPLE_FMT_NONE) { char *VAR_9; VAR_4 = strtol(VAR_2, &VAR_9, 0); if (*VAR_9 || (unsigned)VAR_4 >= AV_SAMPLE_FMT_NB) { av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as sample format\n", VAR_2); return AVERROR(EINVAL); } } } *(enum AVSampleFormat *)VAR_5 = VAR_4; return 0; case AV_OPT_TYPE_DURATION:
if (!VAR_2) { *(int64_t *)VAR_5 = 0; return 0; } else { if ((VAR_4 = av_parse_time(VAR_5, VAR_2, 1)) < 0)
av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as duration\n", VAR_2); return VAR_4; } break; case AV_OPT_TYPE_COLOR:
if (!VAR_2) { return 0; } else { VAR_4 = av_parse_color(VAR_5, VAR_2, -1, VAR_0); if (VAR_4 < 0)
av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as color\n", VAR_2); return VAR_4; } break; case AV_OPT_TYPE_CHANNEL_LAYOUT:
if (!VAR_2 || !strcmp(VAR_2, "none")) { *(int64_t *)VAR_5 = 0; } else { #if FF_API_GET_CHANNEL_LAYOUT_COMPAT
int64_t cl = ff_get_channel_layout(VAR_2, 0); #else
int64_t cl = av_get_channel_layout(VAR_2); #endif
if (!cl) { av_log(VAR_0, AV_LOG_ERROR, "Unable to parse option value \"%s\" as channel layout\n", VAR_2); VAR_4 = AVERROR(EINVAL); } *(int64_t *)VAR_5 = cl; return VAR_4; } break; } av_log(VAR_0, AV_LOG_ERROR, "Invalid option type.\n"); return AVERROR(EINVAL); }