static void obs_x264_video_info(void *data, struct video_scale_info *info) { struct obs_x264 *obsx264 = data; enum video_format pref_format; pref_format = obs_encoder_get_preferred_video_format(obsx264->encoder); if (!valid_format(pref_format)) { pref_format = valid_format(info->format) ? info->format : VIDEO_FORMAT_NV12; } info->format = pref_format; }
static void obs_qsv_video_info(void *data, struct video_scale_info *info) { struct obs_qsv *obsqsv = data; enum video_format pref_format; pref_format = obs_encoder_get_preferred_video_format(obsqsv->encoder); if (!valid_format(pref_format)) { pref_format = valid_format(info->format) ? info->format : VIDEO_FORMAT_NV12; } info->format = pref_format; cap_resolution(obsqsv->encoder, info); }
/* * The seq command will print out a numeric sequence from 1, the default, * to a user specified upper limit by 1. The lower bound and increment * maybe indicated by the user on the command line. The sequence can * be either whole, the default, or decimal numbers. */ int main(int argc, char *argv[]) { int c = 0, errflg = 0; int equalize = 0; double first = 1.0; double last = 0.0; double incr = 0.0; struct lconv *locale; char *fmt = NULL; const char *sep = "\n"; const char *term = NULL; char pad = ZERO; /* Determine the locale's decimal point. */ locale = localeconv(); if (locale && locale->decimal_point && locale->decimal_point[0] != '\0') decimal_point = locale->decimal_point; /* * Process options, but handle negative numbers separately * least they trip up getopt(3). */ while ((optind < argc) && !numeric(argv[optind]) && (c = getopt(argc, argv, "f:hs:t:w")) != -1) { switch (c) { case 'f': /* format (plan9) */ fmt = optarg; equalize = 0; break; case 's': /* separator (GNU) */ sep = unescape(optarg); break; case 't': /* terminator (new) */ term = unescape(optarg); break; case 'w': /* equal width (plan9) */ if (!fmt) if (equalize++) pad = SPACE; break; case 'h': /* help (GNU) */ default: errflg++; break; } } argc -= optind; argv += optind; if (argc < 1 || argc > 3) errflg++; if (errflg) { fprintf(stderr, "usage: %s [-w] [-f format] [-s string] [-t string] [first [incr]] last\n", getprogname()); exit(1); } last = e_atof(argv[argc - 1]); if (argc > 1) first = e_atof(argv[0]); if (argc > 2) { incr = e_atof(argv[1]); /* Plan 9/GNU don't do zero */ if (incr == 0.0) errx(1, "zero %screment", (first < last)? "in" : "de"); } /* default is one for Plan 9/GNU work alike */ if (incr == 0.0) incr = (first < last) ? 1.0 : -1.0; if (incr <= 0.0 && first < last) errx(1, "needs positive increment"); if (incr >= 0.0 && first > last) errx(1, "needs negative decrement"); if (fmt != NULL) { if (!valid_format(fmt)) errx(1, "invalid format string: `%s'", fmt); fmt = unescape(fmt); /* * XXX to be bug for bug compatible with Plan 9 add a * newline if none found at the end of the format string. */ } else fmt = generate_format(first, incr, last, equalize, pad); if (incr > 0) { for (; first <= last; first += incr) { printf(fmt, first); fputs(sep, stdout); } } else { for (; first >= last; first += incr) { printf(fmt, first); fputs(sep, stdout); } } if (term != NULL) fputs(term, stdout); return (0); }
U_CFUNC PHP_FUNCTION(datefmt_format_object) { zval *object, *format = NULL; const char *locale_str = NULL; size_t locale_len; bool pattern = false; UDate date; TimeZone *timeZone = NULL; UErrorCode status = U_ZERO_ERROR; DateFormat *df = NULL; Calendar *cal = NULL; DateFormat::EStyle dateStyle = DateFormat::kDefault, timeStyle = DateFormat::kDefault; if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|zs!", &object, &format, &locale_str, &locale_len) == FAILURE) { RETURN_FALSE; } if (!locale_str) { locale_str = intl_locale_get_default(); } if (format == NULL || Z_TYPE_P(format) == IS_NULL) { //nothing } else if (Z_TYPE_P(format) == IS_ARRAY) { HashTable *ht = Z_ARRVAL_P(format); HashPosition pos = {0}; zval *z; if (zend_hash_num_elements(ht) != 2) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format_object: bad format; if array, it must have " "two elements", 0); RETURN_FALSE; } zend_hash_internal_pointer_reset_ex(ht, &pos); z = zend_hash_get_current_data_ex(ht, &pos); if (!valid_format(z)) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format_object: bad format; the date format (first " "element of the array) is not valid", 0); RETURN_FALSE; } dateStyle = (DateFormat::EStyle)Z_LVAL_P(z); zend_hash_move_forward_ex(ht, &pos); z = zend_hash_get_current_data_ex(ht, &pos); if (!valid_format(z)) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format_object: bad format; the time format (" "second element of the array) is not valid", 0); RETURN_FALSE; } timeStyle = (DateFormat::EStyle)Z_LVAL_P(z); } else if (Z_TYPE_P(format) == IS_LONG) { if (!valid_format(format)) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format_object: the date/time format type is invalid", 0); RETURN_FALSE; } dateStyle = timeStyle = (DateFormat::EStyle)Z_LVAL_P(format); } else { convert_to_string_ex(format); if (Z_STRLEN_P(format) == 0) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format_object: the format is empty", 0); RETURN_FALSE; } pattern = true; } //there's no support for relative time in ICU yet timeStyle = (DateFormat::EStyle)(timeStyle & ~DateFormat::kRelative); zend_class_entry *instance_ce = Z_OBJCE_P(object); if (instanceof_function(instance_ce, Calendar_ce_ptr)) { Calendar *obj_cal = calendar_fetch_native_calendar(object); if (obj_cal == NULL) { intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_format_object: bad IntlCalendar instance: " "not initialized properly", 0); RETURN_FALSE; } timeZone = obj_cal->getTimeZone().clone(); date = obj_cal->getTime(status); if (U_FAILURE(status)) { intl_error_set(NULL, status, "datefmt_format_object: error obtaining instant from " "IntlCalendar", 0); RETVAL_FALSE; goto cleanup; } cal = obj_cal->clone(); } else if (instanceof_function(instance_ce, php_date_get_date_ce())) { if (intl_datetime_decompose(object, &date, &timeZone, NULL, "datefmt_format_object") == FAILURE) { RETURN_FALSE; } cal = new GregorianCalendar(Locale::createFromName(locale_str), status); if (U_FAILURE(status)) { intl_error_set(NULL, status, "datefmt_format_object: could not create GregorianCalendar", 0); RETVAL_FALSE; goto cleanup; } } else { intl_error_set(NULL, status, "datefmt_format_object: the passed object " "must be an instance of either IntlCalendar or DateTime", 0); RETURN_FALSE; } if (pattern) { df = new SimpleDateFormat( UnicodeString(Z_STRVAL_P(format), Z_STRLEN_P(format), UnicodeString::kInvariant), Locale::createFromName(locale_str), status); if (U_FAILURE(status)) { intl_error_set(NULL, status, "datefmt_format_object: could not create SimpleDateFormat", 0); RETVAL_FALSE; goto cleanup; } } else { df = DateFormat::createDateTimeInstance(dateStyle, timeStyle, Locale::createFromName(locale_str)); if (df == NULL) { /* according to ICU sources, this should never happen */ intl_error_set(NULL, status, "datefmt_format_object: could not create DateFormat", 0); RETVAL_FALSE; goto cleanup; } } //must be in this order (or have the cal adopt the tz) df->adoptCalendar(cal); cal = NULL; df->adoptTimeZone(timeZone); timeZone = NULL; { char *ret_str; int ret_str_len; UnicodeString result = UnicodeString(); df->format(date, result); if (intl_charFromString(result, &ret_str, &ret_str_len, &status) == FAILURE) { intl_error_set(NULL, status, "datefmt_format_object: error converting result to UTF-8", 0); RETVAL_FALSE; goto cleanup; } RETVAL_STRINGL(ret_str, ret_str_len); //??? efree(ret_str); } cleanup: delete df; delete timeZone; delete cal; }