static slurm_addr_t * _build_node_addr ( char * node_list , uint32_t node_cnt , uint32_t pack_job_id ) {
 hostlist_t host_list = NULL ;
 struct node_record * node_ptr ;
 slurm_addr_t * node_addr ;
 char * this_node_name ;
 int error_code = SLURM_SUCCESS , node_inx = 0 ;
 if ( ( host_list = hostlist_create ( node_list ) ) == NULL ) {
 error ( "%s hostlist_create error for pack job %u (%s): %m" , __func__ , pack_job_id , node_list ) ;
 return NULL ;
 }
 node_addr = xmalloc ( sizeof ( slurm_addr_t ) * node_cnt ) ;
 while ( ( this_node_name = hostlist_shift ( host_list ) ) ) {
 if ( ( node_ptr = find_node_record ( this_node_name ) ) ) {
 memcpy ( node_addr + node_inx , & node_ptr -> slurm_addr , sizeof ( slurm_addr_t ) ) ;
 node_inx ++ ;
 }
 else {
 error ( "%s: Invalid node %s in pack job %u" , __func__ , this_node_name , pack_job_id ) ;
 error_code = SLURM_ERROR ;
 }
 free ( this_node_name ) ;
 if ( error_code != SLURM_SUCCESS ) break ;
 }
 hostlist_destroy ( host_list ) ;
 if ( error_code != SLURM_SUCCESS ) xfree ( node_addr ) ;
 return node_addr ;
 }


static ossl_inline int sk_ ## t1 ## _find ( STACK_OF ( t1 ) * sk , t2 * ptr ) {
 return OPENSSL_sk_find ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;
 }
 static ossl_inline int sk_ ## t1 ## _find_ex ( STACK_OF ( t1 ) * sk , t2 * ptr ) {
 return OPENSSL_sk_find_ex ( ( OPENSSL_STACK * ) sk , ( const void * ) ptr ) ;
 }
 static ossl_inline void sk_ ## t1 ## _sort ( STACK_OF ( t1 ) * sk ) {
 OPENSSL_sk_sort ( ( OPENSSL_STACK * ) sk ) ;
 }
 static ossl_inline int sk_ ## t1 ## _is_sorted ( const STACK_OF ( t1 ) * sk ) {
 return OPENSSL_sk_is_sorted ( ( const OPENSSL_STACK * ) sk ) ;
 }
 static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _dup ( const STACK_OF ( t1 ) * sk ) {
 return ( STACK_OF ( t1 ) * ) OPENSSL_sk_dup ( ( const OPENSSL_STACK * ) sk ) ;
 }
 static ossl_inline STACK_OF ( t1 ) * sk_ ## t1 ## _deep_copy ( const STACK_OF ( t1 ) * sk , sk_ ## t1 ## _copyfunc copyfunc , sk_ ## t1 ## _freefunc freefunc ) {
 return ( STACK_OF ( t1 ) * ) OPENSSL_sk_deep_copy ( ( const OPENSSL_STACK * ) sk , ( OPENSSL_sk_copyfunc ) copyfunc , ( OPENSSL_sk_freefunc ) freefunc ) ;
 }
 static ossl_inline sk_ ## t1 ## _compfunc sk_ ## t1 ## _set_cmp_func ( STACK_OF ( t1 ) * sk , sk_ ## t1 ## _compfunc compare ) {
 return ( sk_ ## t1 ## _compfunc ) OPENSSL_sk_set_cmp_func ( ( OPENSSL_STACK * ) sk , ( OPENSSL_sk_compfunc ) compare ) ;
 }
 # define DEFINE_SPECIAL_STACK_OF ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , t2 , t2 ) # define DEFINE_STACK_OF ( t ) SKM_DEFINE_STACK_OF ( t , t , t ) # define DEFINE_SPECIAL_STACK_OF_CONST ( t1 , t2 ) SKM_DEFINE_STACK_OF ( t1 , const t2 , t2 ) # define DEFINE_STACK_OF_CONST ( t ) SKM_DEFINE_STACK_OF ( t , const t , t ) typedef char * OPENSSL_STRING ;
 typedef const char * OPENSSL_CSTRING ;
 DEFINE_SPECIAL_STACK_OF ( OPENSSL_STRING , char ) DEFINE_SPECIAL_STACK_OF_CONST ( OPENSSL_CSTRING , char )


static void compute_rematrixing_strategy(AC3EncodeContext *s) { int nb_coefs; int blk, bnd, i; AC3Block *block, *av_uninit(block0); if (s->channel_mode != AC3_CHMODE_STEREO) return; for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { block = &s->blocks[blk]; block->new_rematrixing_strategy = !blk; if (!s->rematrixing_enabled) { block0 = block; continue; } block->num_rematrixing_bands = 4; if (block->cpl_in_use) { block->num_rematrixing_bands -= (s->start_freq[CPL_CH] <= 61); block->num_rematrixing_bands -= (s->start_freq[CPL_CH] == 37); if (blk && block->num_rematrixing_bands != block0->num_rematrixing_bands) block->new_rematrixing_strategy = 1; } nb_coefs = FFMIN(block->end_freq[1], block->end_freq[2]); for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++) { /* calculate calculate sum of squared coeffs for one band in one block */ int start = ff_ac3_rematrix_band_tab[bnd]; int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]); CoefSumType sum[4] = {0,}; for (i = start; i < end; i++) { CoefType lt = block->mdct_coef[1][i]; CoefType rt = block->mdct_coef[2][i]; CoefType md = lt + rt; CoefType sd = lt - rt; MAC_COEF(sum[0], lt, lt); MAC_COEF(sum[1], rt, rt); MAC_COEF(sum[2], md, md); MAC_COEF(sum[3], sd, sd); } /* compare sums to determine if rematrixing will be used for this band */ if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1])) block->rematrixing_flags[bnd] = 1; else block->rematrixing_flags[bnd] = 0; /* determine if new rematrixing flags will be sent */ if (blk && block->rematrixing_flags[bnd] != block0->rematrixing_flags[bnd]) { block->new_rematrixing_strategy = 1; } } block0 = block; } }


int dtls1_send_server_certificate ( SSL * s ) {
 unsigned long l ;
 X509 * x ;
 if ( s -> state == SSL3_ST_SW_CERT_A ) {
 x = ssl_get_server_send_cert ( s ) ;
 if ( x == NULL ) {
 if ( ( s -> s3 -> tmp . new_cipher -> algorithm_mkey != SSL_kKRB5 ) || ( s -> s3 -> tmp . new_cipher -> algorithm_auth != SSL_aKRB5 ) ) {
 SSLerr ( SSL_F_DTLS1_SEND_SERVER_CERTIFICATE , ERR_R_INTERNAL_ERROR ) ;
 return ( 0 ) ;
 }
 }
 l = dtls1_output_cert_chain ( s , x ) ;
 if ( ! l ) {
 SSLerr ( SSL_F_DTLS1_SEND_SERVER_CERTIFICATE , ERR_R_INTERNAL_ERROR ) ;
 return ( 0 ) ;
 }
 s -> state = SSL3_ST_SW_CERT_B ;
 s -> init_num = ( int ) l ;
 s -> init_off = 0 ;
 dtls1_buffer_message ( s , 0 ) ;
 }
 return ( dtls1_do_write ( s , SSL3_RT_HANDSHAKE ) ) ;
 }


void hrtimer_init_sleeper(struct hrtimer_sleeper *sl, struct task_struct *task)
{
	sl->timer.function = hrtimer_wakeup;
	sl->task = task;
#ifdef CONFIG_HIGH_RES_TIMERS
	sl->timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_RESTART;
#endif
}


static void gen_mfsrin_64b(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); #else TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG); return; } t0 = tcg_temp_new(); tcg_gen_shri_tl(t0, cpu_gpr[rB(ctx->opcode)], 28); tcg_gen_andi_tl(t0, t0, 0xF); gen_helper_load_sr(cpu_gpr[rD(ctx->opcode)], cpu_env, t0); tcg_temp_free(t0); #endif }


float4 get_func_rows ( Oid funcid ) {
 HeapTuple tp ;
 float4 result ;
 tp = SearchSysCache1 ( PROCOID , ObjectIdGetDatum ( funcid ) ) ;
 if ( ! HeapTupleIsValid ( tp ) ) elog ( ERROR , "cache lookup failed for function %u" , funcid ) ;
 result = ( ( Form_pg_proc ) GETSTRUCT ( tp ) ) -> prorows ;
 ReleaseSysCache ( tp ) ;
 return result ;
 }


static inline int hrtimer_cb_pending(struct hrtimer *timer) { return 0; }


static PyObject * string_rindex ( PyStringObject * self , PyObject * args ) {
 Py_ssize_t result = string_find_internal ( self , args , - 1 ) ;
 if ( result == - 2 ) return NULL ;
 if ( result == - 1 ) {
 PyErr_SetString ( PyExc_ValueError , "substring not found" ) ;
 return NULL ;
 }
 return PyInt_FromSsize_t ( result ) ;
 }


static ssize_t qio_channel_websock_write_wire ( QIOChannelWebsock * ioc , Error * * errp ) {
 ssize_t ret ;
 ssize_t done = 0 ;
 if ( ! ioc -> ping_reply . offset ) {
 qio_channel_websock_encode ( ioc ) ;
 }
 else if ( ! ioc -> encoutput . offset ) {
 buffer_move_empty ( & ioc -> encoutput , & ioc -> ping_reply ) ;
 }
 while ( ioc -> encoutput . offset > 0 ) {
 ret = qio_channel_write ( ioc -> master , ( char * ) ioc -> encoutput . buffer , ioc -> encoutput . offset , errp ) ;
 if ( ret < 0 ) {
 if ( ret == QIO_CHANNEL_ERR_BLOCK && done > 0 ) {
 return done ;
 }
 else {
 return ret ;
 }
 }
 buffer_advance ( & ioc -> encoutput , ret ) ;
 done += ret ;
 }
 return done ;
 }


void __init hrtimers_init(void)
{
	hrtimer_cpu_notify(&hrtimers_nb, (unsigned long)CPU_UP_PREPARE,
			  (void *)(long)smp_processor_id());
	register_cpu_notifier(&hrtimers_nb);
#ifdef CONFIG_HIGH_RES_TIMERS
	open_softirq(HRTIMER_SOFTIRQ, run_hrtimer_softirq, NULL);
#endif
}


static inline void ipv6_addr_set ( struct in6_addr * addr , __be32 w1 , __be32 w2 , __be32 w3 , __be32 w4 ) {
 addr -> s6_addr32 [ 0 ] = w1 ;
 addr -> s6_addr32 [ 1 ] = w2 ;
 addr -> s6_addr32 [ 2 ] = w3 ;
 addr -> s6_addr32 [ 3 ] = w4 ;
 }


static int dissect_pvfs2_getattr_response ( tvbuff_t * tvb , proto_tree * tree , int offset , packet_info * pinfo ) {
 offset = dissect_pvfs_object_attr ( tvb , tree , offset , pinfo ) ;
 return offset ;
 }


long hrtimer_nanosleep(struct timespec *rqtp, struct timespec __user *rmtp,
		       const enum hrtimer_mode mode, const clockid_t clockid)
{
	struct restart_block *restart;
	struct hrtimer_sleeper t;
	struct timespec tu;
	ktime_t rem;

	hrtimer_init(&t.timer, clockid, mode);
	t.timer.expires = timespec_to_ktime(*rqtp);
	if (do_nanosleep(&t, mode))
		return 0;

	/* Absolute timers do not update the rmtp value and restart: */
	if (mode == HRTIMER_MODE_ABS)
		return -ERESTARTNOHAND;

	if (rmtp) {
		rem = ktime_sub(t.timer.expires, t.timer.base->get_time());
		if (rem.tv64 <= 0)
			return 0;
		tu = ktime_to_timespec(rem);
		if (copy_to_user(rmtp, &tu, sizeof(tu)))
			return -EFAULT;
	}

	restart = &current_thread_info()->restart_block;
	restart->fn = hrtimer_nanosleep_restart;
	restart->arg0 = (unsigned long) t.timer.base->index;
	restart->arg1 = (unsigned long) rmtp;
	restart->arg2 = t.timer.expires.tv64 & 0xFFFFFFFF;
	restart->arg3 = t.timer.expires.tv64 >> 32;

	return -ERESTART_RESTARTBLOCK;
}


static byte * i_alloc_byte_array_immovable ( gs_memory_t * mem , uint num_elements , uint elt_size , client_name_t cname ) {
 gs_ref_memory_t * const imem = ( gs_ref_memory_t * ) mem ;
 obj_header_t * obj ;
 ulong lsize ;
 # ifdef MEMENTO if ( Memento_failThisEvent ( ) ) return NULL ;
 # endif if ( alloc_array_check_size ( num_elements , elt_size , & lsize ) == false ) return NULL ;
 obj = alloc_obj ( imem , lsize , & st_bytes , ALLOC_IMMOVABLE | ALLOC_DIRECT , cname ) ;
 if_debug6m ( 'A' , mem , "[a%d|+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n" , alloc_trace_space ( imem ) , client_name_string ( cname ) , ( ulong ) num_elements * elt_size , num_elements , elt_size , ( ulong ) obj ) ;
 return ( byte * ) obj ;
 }


av_cold void ff_psy_end(FFPsyContext *ctx) { if (ctx->model->end) ctx->model->end(ctx); av_freep(&ctx->bands); av_freep(&ctx->num_bands); av_freep(&ctx->group); av_freep(&ctx->ch); }


static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
					    struct hrtimer_clock_base *base)
{
	return 0;
}


static void qcms_transform_module_clut ( struct qcms_modular_transform * transform , float * src , float * dest , size_t length ) {
 size_t i ;
 int xy_len = 1 ;
 int x_len = transform -> grid_size ;
 int len = x_len * x_len ;
 float * r_table = transform -> r_clut ;
 float * g_table = transform -> g_clut ;
 float * b_table = transform -> b_clut ;
 assert ( transform -> grid_size >= 1 ) ;
 for ( i = 0 ;
 i < length ;
 i ++ ) {
 float device_r = * src ++ ;
 float device_g = * src ++ ;
 float device_b = * src ++ ;
 float linear_r = lut_interp_linear_float ( device_r , transform -> input_clut_table_r , transform -> input_clut_table_length ) ;
 float linear_g = lut_interp_linear_float ( device_g , transform -> input_clut_table_g , transform -> input_clut_table_length ) ;
 float linear_b = lut_interp_linear_float ( device_b , transform -> input_clut_table_b , transform -> input_clut_table_length ) ;
 int x = floor ( linear_r * ( transform -> grid_size - 1 ) ) ;
 int y = floor ( linear_g * ( transform -> grid_size - 1 ) ) ;
 int z = floor ( linear_b * ( transform -> grid_size - 1 ) ) ;
 int x_n = ceil ( linear_r * ( transform -> grid_size - 1 ) ) ;
 int y_n = ceil ( linear_g * ( transform -> grid_size - 1 ) ) ;
 int z_n = ceil ( linear_b * ( transform -> grid_size - 1 ) ) ;
 float x_d = linear_r * ( transform -> grid_size - 1 ) - x ;
 float y_d = linear_g * ( transform -> grid_size - 1 ) - y ;
 float z_d = linear_b * ( transform -> grid_size - 1 ) - z ;
 float r_x1 = lerp ( CLU ( r_table , x , y , z ) , CLU ( r_table , x_n , y , z ) , x_d ) ;
 float r_x2 = lerp ( CLU ( r_table , x , y_n , z ) , CLU ( r_table , x_n , y_n , z ) , x_d ) ;
 float r_y1 = lerp ( r_x1 , r_x2 , y_d ) ;
 float r_x3 = lerp ( CLU ( r_table , x , y , z_n ) , CLU ( r_table , x_n , y , z_n ) , x_d ) ;
 float r_x4 = lerp ( CLU ( r_table , x , y_n , z_n ) , CLU ( r_table , x_n , y_n , z_n ) , x_d ) ;
 float r_y2 = lerp ( r_x3 , r_x4 , y_d ) ;
 float clut_r = lerp ( r_y1 , r_y2 , z_d ) ;
 float g_x1 = lerp ( CLU ( g_table , x , y , z ) , CLU ( g_table , x_n , y , z ) , x_d ) ;
 float g_x2 = lerp ( CLU ( g_table , x , y_n , z ) , CLU ( g_table , x_n , y_n , z ) , x_d ) ;
 float g_y1 = lerp ( g_x1 , g_x2 , y_d ) ;
 float g_x3 = lerp ( CLU ( g_table , x , y , z_n ) , CLU ( g_table , x_n , y , z_n ) , x_d ) ;
 float g_x4 = lerp ( CLU ( g_table , x , y_n , z_n ) , CLU ( g_table , x_n , y_n , z_n ) , x_d ) ;
 float g_y2 = lerp ( g_x3 , g_x4 , y_d ) ;
 float clut_g = lerp ( g_y1 , g_y2 , z_d ) ;
 float b_x1 = lerp ( CLU ( b_table , x , y , z ) , CLU ( b_table , x_n , y , z ) , x_d ) ;
 float b_x2 = lerp ( CLU ( b_table , x , y_n , z ) , CLU ( b_table , x_n , y_n , z ) , x_d ) ;
 float b_y1 = lerp ( b_x1 , b_x2 , y_d ) ;
 float b_x3 = lerp ( CLU ( b_table , x , y , z_n ) , CLU ( b_table , x_n , y , z_n ) , x_d ) ;
 float b_x4 = lerp ( CLU ( b_table , x , y_n , z_n ) , CLU ( b_table , x_n , y_n , z_n ) , x_d ) ;
 float b_y2 = lerp ( b_x3 , b_x4 , y_d ) ;
 float clut_b = lerp ( b_y1 , b_y2 , z_d ) ;
 float pcs_r = lut_interp_linear_float ( clut_r , transform -> output_clut_table_r , transform -> output_clut_table_length ) ;
 float pcs_g = lut_interp_linear_float ( clut_g , transform -> output_clut_table_g , transform -> output_clut_table_length ) ;
 float pcs_b = lut_interp_linear_float ( clut_b , transform -> output_clut_table_b , transform -> output_clut_table_length ) ;
 * dest ++ = clamp_float ( pcs_r ) ;
 * dest ++ = clamp_float ( pcs_g ) ;
 * dest ++ = clamp_float ( pcs_b ) ;
 }
 }


static void U_CALLCONV UConverter_fromUnicode_ISCII_OFFSETS_LOGIC ( UConverterFromUnicodeArgs * args , UErrorCode * err ) {
 const UChar * source = args -> source ;
 const UChar * sourceLimit = args -> sourceLimit ;
 unsigned char * target = ( unsigned char * ) args -> target ;
 unsigned char * targetLimit = ( unsigned char * ) args -> targetLimit ;
 int32_t * offsets = args -> offsets ;
 uint32_t targetByteUnit = 0x0000 ;
 UChar32 sourceChar = 0x0000 ;
 UChar32 tempContextFromUnicode = 0x0000 ;
 UConverterDataISCII * converterData ;
 uint16_t newDelta = 0 ;
 uint16_t range = 0 ;
 UBool deltaChanged = FALSE ;
 if ( ( args -> converter == NULL ) || ( args -> targetLimit < args -> target ) || ( args -> sourceLimit < args -> source ) ) {
 * err = U_ILLEGAL_ARGUMENT_ERROR ;
 return ;
 }
 converterData = ( UConverterDataISCII * ) args -> converter -> extraInfo ;
 newDelta = converterData -> currentDeltaFromUnicode ;
 range = ( uint16_t ) ( newDelta / DELTA ) ;
 if ( ( sourceChar = args -> converter -> fromUChar32 ) != 0 ) {
 goto getTrail ;
 }
 while ( source < sourceLimit ) {
 if ( args -> converter -> fromUnicodeStatus == LF ) {
 targetByteUnit = ATR << 8 ;
 targetByteUnit += ( uint8_t ) lookupInitialData [ range ] . isciiLang ;
 args -> converter -> fromUnicodeStatus = 0x0000 ;
 WRITE_TO_TARGET_FROM_U ( args , offsets , source , target , targetLimit , targetByteUnit , err ) ;
 if ( U_FAILURE ( * err ) ) {
 break ;
 }
 }
 sourceChar = * source ++ ;
 tempContextFromUnicode = converterData -> contextCharFromUnicode ;
 targetByteUnit = missingCharMarker ;
 if ( sourceChar <= ASCII_END ) {
 args -> converter -> fromUnicodeStatus = sourceChar ;
 WRITE_TO_TARGET_FROM_U ( args , offsets , source , target , targetLimit , sourceChar , err ) ;
 if ( U_FAILURE ( * err ) ) {
 break ;
 }
 continue ;
 }
 switch ( sourceChar ) {
 case ZWNJ : if ( converterData -> contextCharFromUnicode ) {
 converterData -> contextCharFromUnicode = 0x00 ;
 targetByteUnit = ISCII_HALANT ;
 }
 else {
 converterData -> contextCharFromUnicode = 0x00 ;
 continue ;
 }
 break ;
 case ZWJ : if ( converterData -> contextCharFromUnicode ) {
 targetByteUnit = ISCII_NUKTA ;
 }
 else {
 targetByteUnit = ISCII_INV ;
 }
 converterData -> contextCharFromUnicode = 0x00 ;
 break ;
 default : if ( ( uint16_t ) ( INDIC_BLOCK_END - sourceChar ) <= INDIC_RANGE ) {
 if ( sourceChar != DANDA && sourceChar != DOUBLE_DANDA ) {
 range = ( uint16_t ) ( ( sourceChar - INDIC_BLOCK_BEGIN ) / DELTA ) ;
 newDelta = ( uint16_t ) ( range * DELTA ) ;
 if ( newDelta != converterData -> currentDeltaFromUnicode || converterData -> isFirstBuffer ) {
 converterData -> currentDeltaFromUnicode = newDelta ;
 converterData -> currentMaskFromUnicode = lookupInitialData [ range ] . maskEnum ;
 deltaChanged = TRUE ;
 converterData -> isFirstBuffer = FALSE ;
 }
 if ( converterData -> currentDeltaFromUnicode == PNJ_DELTA ) {
 if ( sourceChar == PNJ_TIPPI ) {
 sourceChar = PNJ_BINDI ;
 }
 else if ( sourceChar == PNJ_ADHAK ) {
 converterData -> contextCharFromUnicode = PNJ_ADHAK ;
 }
 }
 sourceChar -= converterData -> currentDeltaFromUnicode ;
 }
 targetByteUnit = fromUnicodeTable [ ( uint8_t ) sourceChar ] ;
 if ( ( validityTable [ ( uint8_t ) sourceChar ] & converterData -> currentMaskFromUnicode ) == 0 ) {
 if ( converterData -> currentDeltaFromUnicode != ( TELUGU_DELTA ) || sourceChar != VOCALLIC_RR ) {
 targetByteUnit = missingCharMarker ;
 }
 }
 if ( deltaChanged ) {
 uint32_t temp = 0 ;
 temp = ( uint16_t ) ( ATR << 8 ) ;
 temp += ( uint16_t ) ( ( uint8_t ) lookupInitialData [ range ] . isciiLang ) ;
 deltaChanged = FALSE ;
 WRITE_TO_TARGET_FROM_U ( args , offsets , source , target , targetLimit , temp , err ) ;
 if ( U_FAILURE ( * err ) ) {
 break ;
 }
 }
 if ( converterData -> currentDeltaFromUnicode == PNJ_DELTA && ( sourceChar + PNJ_DELTA ) == PNJ_ADHAK ) {
 continue ;
 }
 }
 converterData -> contextCharFromUnicode = 0x00 ;
 break ;
 }
 if ( converterData -> currentDeltaFromUnicode == PNJ_DELTA && tempContextFromUnicode == PNJ_ADHAK && isPNJConsonant ( ( sourceChar + PNJ_DELTA ) ) ) {
 converterData -> contextCharFromUnicode = 0x0000 ;
 targetByteUnit = targetByteUnit << 16 | ISCII_HALANT << 8 | targetByteUnit ;
 WRITE_TO_TARGET_FROM_U ( args , offsets , source , target , targetLimit , targetByteUnit , err ) ;
 if ( U_FAILURE ( * err ) ) {
 break ;
 }
 }
 else if ( targetByteUnit != missingCharMarker ) {
 if ( targetByteUnit == ISCII_HALANT ) {
 converterData -> contextCharFromUnicode = ( UChar ) targetByteUnit ;
 }
 WRITE_TO_TARGET_FROM_U ( args , offsets , source , target , targetLimit , targetByteUnit , err ) ;
 if ( U_FAILURE ( * err ) ) {
 break ;
 }
 }
 else {
 if ( U16_IS_SURROGATE ( sourceChar ) ) {
 if ( U16_IS_SURROGATE_LEAD ( sourceChar ) ) {
 getTrail : if ( source < sourceLimit ) {
 UChar trail = ( * source ) ;
 if ( U16_IS_TRAIL ( trail ) ) {
 source ++ ;
 sourceChar = U16_GET_SUPPLEMENTARY ( sourceChar , trail ) ;
 * err = U_INVALID_CHAR_FOUND ;
 }
 else {
 * err = U_ILLEGAL_CHAR_FOUND ;
 }
 }
 else {
 * err = U_ZERO_ERROR ;
 }
 }
 else {
 * err = U_ILLEGAL_CHAR_FOUND ;
 }
 }
 else {
 * err = U_INVALID_CHAR_FOUND ;
 }
 args -> converter -> fromUChar32 = sourceChar ;
 break ;
 }
 }
 args -> source = source ;
 args -> target = ( char * ) target ;
 }


CairoFont::getGlyph(CharCode code,
		    Unicode *u, int uLen) {
  FT_UInt gid;

  if (codeToGID && code < codeToGIDLen) {
    gid = (FT_UInt)codeToGID[code];
  } else {
    gid = (FT_UInt)code;
  }
  return gid;
}


static unsigned tget_short(GetByteContext *gb, int le) { unsigned v = le ? bytestream2_get_le16u(gb) : bytestream2_get_be16u(gb); return v; }


static int transform_hook_handler ( TSCont contp , TSEvent event , void * edata ) {
 TSHttpTxn txnp = nullptr ;
 TransformTestData * data = nullptr ;
 CHECK_SPURIOUS_EVENT ( contp , event , edata ) ;
 data = ( TransformTestData * ) TSContDataGet ( contp ) ;
 switch ( event ) {
 case TS_EVENT_HTTP_READ_REQUEST_HDR : txnp = ( TSHttpTxn ) edata ;
 TSSkipRemappingSet ( txnp , 1 ) ;
 TSHttpTxnReenable ( txnp , TS_EVENT_HTTP_CONTINUE ) ;
 break ;
 case TS_EVENT_HTTP_READ_RESPONSE_HDR : txnp = ( TSHttpTxn ) edata ;
 if ( transformable ( txnp , data ) ) {
 transform_add ( txnp , data ) ;
 }
 {
 TSMBuffer bufp ;
 TSMLoc hdr ;
 TSMLoc field ;
 if ( TSHttpTxnClientReqGet ( txnp , & bufp , & hdr ) != TS_SUCCESS ) {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransform" , "TestCase" , TC_FAIL , "TSHttpTxnClientReqGet returns 0" ) ;
 }
 else {
 if ( TS_NULL_MLOC == ( field = TSMimeHdrFieldFind ( bufp , hdr , "Request" , - 1 ) ) ) {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransform" , "TestCase" , TC_FAIL , "Didn't find field request" ) ;
 }
 else {
 int reqid = TSMimeHdrFieldValueIntGet ( bufp , hdr , field , 0 ) ;
 if ( reqid == 1 ) {
 TSHttpTxnTransformedRespCache ( txnp , 0 ) ;
 TSHttpTxnUntransformedRespCache ( txnp , 1 ) ;
 }
 if ( reqid == 2 ) {
 TSHttpTxnTransformedRespCache ( txnp , 1 ) ;
 TSHttpTxnUntransformedRespCache ( txnp , 0 ) ;
 }
 if ( TSHandleMLocRelease ( bufp , hdr , field ) != TS_SUCCESS ) {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransform" , "TestCase" , TC_FAIL , "Unable to release handle to field in Client request" ) ;
 }
 }
 if ( TSHandleMLocRelease ( bufp , TS_NULL_MLOC , hdr ) != TS_SUCCESS ) {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransform" , "TestCase" , TC_FAIL , "Unable to release handle to Client request" ) ;
 }
 }
 }
 TSHttpTxnHookAdd ( txnp , TS_HTTP_SEND_RESPONSE_HDR_HOOK , contp ) ;
 TSHttpTxnReenable ( txnp , TS_EVENT_HTTP_CONTINUE ) ;
 break ;
 case TS_EVENT_HTTP_SEND_RESPONSE_HDR : {
 TSMBuffer bufp ;
 TSMLoc hdr ;
 txnp = ( TSHttpTxn ) edata ;
 if ( TSHttpTxnTransformRespGet ( txnp , & bufp , & hdr ) != TS_SUCCESS ) {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransformRespGet" , "TestCase" , TC_FAIL , "TSHttpTxnTransformRespGet returns 0" ) ;
 data -> test_passed_txn_transform_resp_get = false ;
 }
 else {
 if ( ( bufp == reinterpret_cast < TSMBuffer > ( & ( ( ( HttpSM * ) txnp ) -> t_state . hdr_info . transform_response ) ) ) && ( hdr == reinterpret_cast < TSMLoc > ( ( & ( ( ( HttpSM * ) txnp ) -> t_state . hdr_info . transform_response ) ) -> m_http ) ) ) {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransformRespGet" , "TestCase" , TC_PASS , "ok" ) ;
 }
 else {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransformRespGet" , "TestCase" , TC_FAIL , "Value's Mismatch" ) ;
 data -> test_passed_txn_transform_resp_get = false ;
 }
 if ( TSHandleMLocRelease ( bufp , TS_NULL_MLOC , hdr ) != TS_SUCCESS ) {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransformRespGet" , "TestCase" , TC_FAIL , "Unable to release handle to Transform header handle" ) ;
 }
 }
 }
 TSHttpTxnReenable ( txnp , TS_EVENT_HTTP_CONTINUE ) ;
 break ;
 case TS_EVENT_IMMEDIATE : case TS_EVENT_TIMEOUT : switch ( data -> req_no ) {
 case 1 : if ( data -> browser1 -> status == REQUEST_INPROGRESS ) {
 TSContSchedule ( contp , 25 , TS_THREAD_POOL_DEFAULT ) ;
 return 0 ;
 }
 data -> req_no ++ ;
 Debug ( UTDBG_TAG "_transform" , "Running Browser 2" ) ;
 synclient_txn_send_request ( data -> browser2 , data -> request2 ) ;
 TSContSchedule ( contp , 25 , TS_THREAD_POOL_DEFAULT ) ;
 return 0 ;
 case 2 : if ( data -> browser2 -> status == REQUEST_INPROGRESS ) {
 TSContSchedule ( contp , 25 , TS_THREAD_POOL_DEFAULT ) ;
 return 0 ;
 }
 data -> req_no ++ ;
 Debug ( UTDBG_TAG "_transform" , "Running Browser 3" ) ;
 synclient_txn_send_request ( data -> browser3 , data -> request1 ) ;
 TSContSchedule ( contp , 25 , TS_THREAD_POOL_DEFAULT ) ;
 return 0 ;
 case 3 : if ( data -> browser3 -> status == REQUEST_INPROGRESS ) {
 TSContSchedule ( contp , 25 , TS_THREAD_POOL_DEFAULT ) ;
 return 0 ;
 }
 data -> req_no ++ ;
 Debug ( UTDBG_TAG "_transform" , "Running Browser 4" ) ;
 synclient_txn_send_request ( data -> browser4 , data -> request2 ) ;
 TSContSchedule ( contp , 25 , TS_THREAD_POOL_DEFAULT ) ;
 return 0 ;
 case 4 : if ( data -> browser4 -> status == REQUEST_INPROGRESS ) {
 TSContSchedule ( contp , 25 , TS_THREAD_POOL_DEFAULT ) ;
 return 0 ;
 }
 synserver_delete ( data -> os ) ;
 data -> os = nullptr ;
 data -> req_no ++ ;
 TSfree ( data -> request1 ) ;
 TSfree ( data -> request2 ) ;
 break ;
 default : SDK_RPRINT ( data -> test , "TSHttpTxnTransform" , "TestCase" , TC_FAIL , "Something terribly wrong with the test" ) ;
 exit ( 0 ) ;
 }
 {
 if ( ( strstr ( data -> browser1 -> response , TRANSFORM_APPEND_STRING ) != nullptr ) && ( strstr ( data -> browser3 -> response , TRANSFORM_APPEND_STRING ) == nullptr ) ) {
 SDK_RPRINT ( data -> test , "TSHttpTxnUntransformedResponseCache" , "TestCase1" , TC_PASS , "ok" ) ;
 data -> test_passed_txn_untransformed_resp_cache = true ;
 }
 else {
 SDK_RPRINT ( data -> test , "TSHttpTxnUntransformedResponseCache" , "TestCase1" , TC_FAIL , "Value's Mismatch" ) ;
 }
 if ( ( strstr ( data -> browser2 -> response , TRANSFORM_APPEND_STRING ) != nullptr ) && ( strstr ( data -> browser4 -> response , TRANSFORM_APPEND_STRING ) != nullptr ) ) {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransformedResponseCache" , "TestCase1" , TC_PASS , "ok" ) ;
 data -> test_passed_txn_transformed_resp_cache = true ;
 }
 else {
 SDK_RPRINT ( data -> test , "TSHttpTxnTransformedResponseCache" , "TestCase1" , TC_FAIL , "Value's Mismatch" ) ;
 }
 * ( data -> pstatus ) = REGRESSION_TEST_PASSED ;
 if ( data -> browser1 -> status != REQUEST_SUCCESS ) {
 SDK_RPRINT ( data -> test , "TSTransformCreate" , "TestCase1" , TC_FAIL , "Browser 1 status was not REQUEST_SUCCESS" ) ;
 * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
 }
 if ( data -> browser2 -> status != REQUEST_SUCCESS ) {
 SDK_RPRINT ( data -> test , "TSTransformCreate" , "TestCase1" , TC_FAIL , "Browser 2 status was not REQUEST_SUCCESS" ) ;
 * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
 }
 if ( data -> browser3 -> status != REQUEST_SUCCESS ) {
 SDK_RPRINT ( data -> test , "TSTransformCreate" , "TestCase1" , TC_FAIL , "Browser 3 status was not REQUEST_SUCCESS" ) ;
 * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
 }
 if ( data -> browser4 -> status != REQUEST_SUCCESS ) {
 SDK_RPRINT ( data -> test , "TSTransformCreate" , "TestCase1" , TC_FAIL , "Browser 4 status was not REQUEST_SUCCESS" ) ;
 * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
 }
 if ( data -> test_passed_txn_transform_resp_get != true ) {
 SDK_RPRINT ( data -> test , "TSTransformCreate" , "TestCase1" , TC_FAIL , "did not pass transform_resp_get" ) ;
 * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
 }
 if ( data -> test_passed_txn_transformed_resp_cache != true ) {
 SDK_RPRINT ( data -> test , "TSTransformCreate" , "TestCase1" , TC_FAIL , "did not pass transformed_resp_cache" ) ;
 * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
 }
 if ( data -> test_passed_txn_untransformed_resp_cache != true ) {
 SDK_RPRINT ( data -> test , "TSTransformCreate" , "TestCase1" , TC_FAIL , "did not pass untransformed_resp_cache" ) ;
 * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
 }
 if ( data -> test_passed_transform_create != true ) {
 SDK_RPRINT ( data -> test , "TSTransformCreate" , "TestCase1" , TC_FAIL , "did not pass transform_create" ) ;
 * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
 }
 synclient_txn_delete ( data -> browser1 ) ;
 synclient_txn_delete ( data -> browser2 ) ;
 synclient_txn_delete ( data -> browser3 ) ;
 synclient_txn_delete ( data -> browser4 ) ;
 TSContDataSet ( contp , nullptr ) ;
 data -> magic = MAGIC_DEAD ;
 TSfree ( data ) ;
 }
 break ;
 default : * ( data -> pstatus ) = REGRESSION_TEST_FAILED ;
 SDK_RPRINT ( data -> test , "TSHttpTxnTransform" , "TestCase1" , TC_FAIL , "Unexpected event %d" , event ) ;
 break ;
 }
 return 0 ;
 }


int fw_cfg_add_i16(FWCfgState *s, uint16_t key, uint16_t value) { uint16_t *copy; copy = g_malloc(sizeof(value)); *copy = cpu_to_le16(value); return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value)); }


m4_dumpdef (struct obstack *obs, int argc, token_data **argv)
{
  symbol *s;
  int i;
  struct dump_symbol_data data;
  const builtin *bp;

  data.obs = obs;
  data.base = (symbol **) obstack_base (obs);
  data.size = 0;

  if (argc == 1)
    {
      hack_all_symbols (dump_symbol, &data);
    }
  else
    {
      for (i = 1; i < argc; i++)
	{
	  s = lookup_symbol (TOKEN_DATA_TEXT (argv[i]), SYMBOL_LOOKUP);
	  if (s != NULL && SYMBOL_TYPE (s) != TOKEN_VOID)
	    dump_symbol (s, &data);
	  else
	    M4ERROR ((warning_status, 0,
		      "undefined macro `%s'", TOKEN_DATA_TEXT (argv[i])));
	}
    }

  /* Make table of symbols invisible to expand_macro ().  */

  obstack_finish (obs);

  qsort (data.base, data.size, sizeof (symbol *), dumpdef_cmp);

  for (; data.size > 0; --data.size, data.base++)
    {
      DEBUG_PRINT1 ("%s:\t", SYMBOL_NAME (data.base[0]));

      switch (SYMBOL_TYPE (data.base[0]))
	{
	case TOKEN_TEXT:
	  if (debug_level & DEBUG_TRACE_QUOTE)
	    DEBUG_PRINT3 ("%s%s%s\n",
			  lquote.string, SYMBOL_TEXT (data.base[0]), rquote.string);
	  else
	    DEBUG_PRINT1 ("%s\n", SYMBOL_TEXT (data.base[0]));
	  break;

	case TOKEN_FUNC:
	  bp = find_builtin_by_addr (SYMBOL_FUNC (data.base[0]));
	  if (bp == NULL)
	    {
	      M4ERROR ((warning_status, 0, "\
INTERNAL ERROR: builtin not found in builtin table"));
	      abort ();
	    }
	  DEBUG_PRINT1 ("<%s>\n", bp->name);
	  break;

	default:
	  M4ERROR ((warning_status, 0,
		    "INTERNAL ERROR: bad token data type in m4_dumpdef ()"));
	  abort ();
	  break;
	}
    }
}


static char * StrTok ( char * * Src , const char * Del ) {
 char * TmpPtr ;
 char * RetPtr ;
 if ( * Src != NULL ) {
 RetPtr = * Src ;
 TmpPtr = strstr ( * Src , Del ) ;
 if ( TmpPtr != NULL ) {
 * TmpPtr = '\0' ;
 * Src = TmpPtr + strlen ( Del ) ;
 }
 else * Src = NULL ;
 return RetPtr ;
 }
 return NULL ;
 }


void cpu_synchronize_all_states ( void ) {
 CPUArchState * env ;
 for ( env = first_cpu ;
 env ;
 env = env -> next_cpu ) {
 cpu_synchronize_state ( ENV_GET_CPU ( env ) ) ;
 }
 }


static inline MagickBooleanType IsPixelInfoGray ( const PixelInfo * restrict pixel_info ) {
 if ( ( pixel_info -> colorspace != GRAYColorspace ) && ( pixel_info -> colorspace != RGBColorspace ) ) return ( MagickFalse ) ;
 if ( ( AbsolutePixelValue ( pixel_info -> red - pixel_info -> green ) < MagickEpsilon ) && ( AbsolutePixelValue ( pixel_info -> green - pixel_info -> blue ) < MagickEpsilon ) ) return ( MagickTrue ) ;
 return ( MagickFalse ) ;
 }


static void pred_temp_direct_motion(const H264Context *const h, H264SliceContext *sl, int *mb_type) { int b8_stride = 2; int b4_stride = h->b_stride; int mb_xy = sl->mb_xy, mb_y = sl->mb_y; int mb_type_col[2]; const int16_t (*l1mv0)[2], (*l1mv1)[2]; const int8_t *l1ref0, *l1ref1; const int is_b8x8 = IS_8X8(*mb_type); unsigned int sub_mb_type; int i8, i4; assert(sl->ref_list[1][0].reference & 3); await_reference_mb_row(h, sl->ref_list[1][0].parent, sl->mb_y + !!IS_INTERLACED(*mb_type)); if (IS_INTERLACED(sl->ref_list[1][0].parent->mb_type[mb_xy])) { // AFL/AFR/FR/FL -> AFL/FL if (!IS_INTERLACED(*mb_type)) { // AFR/FR -> AFL/FL mb_y = (sl->mb_y & ~1) + sl->col_parity; mb_xy = sl->mb_x + ((sl->mb_y & ~1) + sl->col_parity) * h->mb_stride; b8_stride = 0; } else { mb_y += sl->col_fieldoff; mb_xy += h->mb_stride * sl->col_fieldoff; // non-zero for FL -> FL & differ parity } goto single_col; } else { // AFL/AFR/FR/FL -> AFR/FR if (IS_INTERLACED(*mb_type)) { // AFL /FL -> AFR/FR mb_y = sl->mb_y & ~1; mb_xy = sl->mb_x + (sl->mb_y & ~1) * h->mb_stride; mb_type_col[0] = sl->ref_list[1][0].parent->mb_type[mb_xy]; mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy + h->mb_stride]; b8_stride = 2 + 4 * h->mb_stride; b4_stride *= 6; if (IS_INTERLACED(mb_type_col[0]) != IS_INTERLACED(mb_type_col[1])) { mb_type_col[0] &= ~MB_TYPE_INTERLACED; mb_type_col[1] &= ~MB_TYPE_INTERLACED; } sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if ((mb_type_col[0] & MB_TYPE_16x16_OR_INTRA) && (mb_type_col[1] & MB_TYPE_16x16_OR_INTRA) && !is_b8x8) { *mb_type |= MB_TYPE_16x8 | MB_TYPE_L0L1 | MB_TYPE_DIRECT2; /* B_16x8 */ } else { *mb_type |= MB_TYPE_8x8 | MB_TYPE_L0L1; } } else { // AFR/FR -> AFR/FR single_col: mb_type_col[0] = mb_type_col[1] = sl->ref_list[1][0].parent->mb_type[mb_xy]; sub_mb_type = MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT2; /* B_SUB_8x8 */ if (!is_b8x8 && (mb_type_col[0] & MB_TYPE_16x16_OR_INTRA)) { *mb_type |= MB_TYPE_16x16 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT2; /* B_16x16 */ } else if (!is_b8x8 && (mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16))) { *mb_type |= MB_TYPE_L0L1 | MB_TYPE_DIRECT2 | (mb_type_col[0] & (MB_TYPE_16x8 | MB_TYPE_8x16)); } else { if (!h->sps.direct_8x8_inference_flag) { /* FIXME: save sub mb types from previous frames (or derive * from MVs) so we know exactly what block size to use */ sub_mb_type = MB_TYPE_8x8 | MB_TYPE_P0L0 | MB_TYPE_P0L1 | MB_TYPE_DIRECT2; /* B_SUB_4x4 */ } *mb_type |= MB_TYPE_8x8 | MB_TYPE_L0L1; } } } await_reference_mb_row(h, sl->ref_list[1][0].parent, mb_y); l1mv0 = &sl->ref_list[1][0].parent->motion_val[0][h->mb2b_xy[mb_xy]]; l1mv1 = &sl->ref_list[1][0].parent->motion_val[1][h->mb2b_xy[mb_xy]]; l1ref0 = &sl->ref_list[1][0].parent->ref_index[0][4 * mb_xy]; l1ref1 = &sl->ref_list[1][0].parent->ref_index[1][4 * mb_xy]; if (!b8_stride) { if (sl->mb_y & 1) { l1ref0 += 2; l1ref1 += 2; l1mv0 += 2 * b4_stride; l1mv1 += 2 * b4_stride; } } { const int *map_col_to_list0[2] = { sl->map_col_to_list0[0], sl->map_col_to_list0[1] }; const int *dist_scale_factor = sl->dist_scale_factor; int ref_offset; if (FRAME_MBAFF(h) && IS_INTERLACED(*mb_type)) { map_col_to_list0[0] = sl->map_col_to_list0_field[sl->mb_y & 1][0]; map_col_to_list0[1] = sl->map_col_to_list0_field[sl->mb_y & 1][1]; dist_scale_factor = sl->dist_scale_factor_field[sl->mb_y & 1]; } ref_offset = (sl->ref_list[1][0].parent->mbaff << 4) & (mb_type_col[0] >> 3); if (IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col[0])) { int y_shift = 2 * !IS_INTERLACED(*mb_type); assert(h->sps.direct_8x8_inference_flag); for (i8 = 0; i8 < 4; i8++) { const int x8 = i8 & 1; const int y8 = i8 >> 1; int ref0, scale; const int16_t (*l1mv)[2] = l1mv0; if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8])) continue; sl->sub_mb_type[i8] = sub_mb_type; fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1); if (IS_INTRA(mb_type_col[y8])) { fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 1); fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 4); fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 4); continue; } ref0 = l1ref0[x8 + y8 * b8_stride]; if (ref0 >= 0) ref0 = map_col_to_list0[0][ref0 + ref_offset]; else { ref0 = map_col_to_list0[1][l1ref1[x8 + y8 * b8_stride] + ref_offset]; l1mv = l1mv1; } scale = dist_scale_factor[ref0]; fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, ref0, 1); { const int16_t *mv_col = l1mv[x8 * 3 + y8 * b4_stride]; int my_col = (mv_col[1] << y_shift) / 2; int mx = (scale * mv_col[0] + 128) >> 8; int my = (scale * my_col + 128) >> 8; fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, pack16to32(mx, my), 4); fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, pack16to32(mx - mv_col[0], my - my_col), 4); } } return; } /* one-to-one mv scaling */ if (IS_16X16(*mb_type)) { int ref, mv0, mv1; fill_rectangle(&sl->ref_cache[1][scan8[0]], 4, 4, 8, 0, 1); if (IS_INTRA(mb_type_col[0])) { ref = mv0 = mv1 = 0; } else { const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset] : map_col_to_list0[1][l1ref1[0] + ref_offset]; const int scale = dist_scale_factor[ref0]; const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0]; int mv_l0[2]; mv_l0[0] = (scale * mv_col[0] + 128) >> 8; mv_l0[1] = (scale * mv_col[1] + 128) >> 8; ref = ref0; mv0 = pack16to32(mv_l0[0], mv_l0[1]); mv1 = pack16to32(mv_l0[0] - mv_col[0], mv_l0[1] - mv_col[1]); } fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1); fill_rectangle(&sl->mv_cache[0][scan8[0]], 4, 4, 8, mv0, 4); fill_rectangle(&sl->mv_cache[1][scan8[0]], 4, 4, 8, mv1, 4); } else { for (i8 = 0; i8 < 4; i8++) { const int x8 = i8 & 1; const int y8 = i8 >> 1; int ref0, scale; const int16_t (*l1mv)[2] = l1mv0; if (is_b8x8 && !IS_DIRECT(sl->sub_mb_type[i8])) continue; sl->sub_mb_type[i8] = sub_mb_type; fill_rectangle(&sl->ref_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 1); if (IS_INTRA(mb_type_col[0])) { fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 1); fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, 0, 4); fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, 0, 4); continue; } assert(b8_stride == 2); ref0 = l1ref0[i8]; if (ref0 >= 0) ref0 = map_col_to_list0[0][ref0 + ref_offset]; else { ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset]; l1mv = l1mv1; } scale = dist_scale_factor[ref0]; fill_rectangle(&sl->ref_cache[0][scan8[i8 * 4]], 2, 2, 8, ref0, 1); if (IS_SUB_8X8(sub_mb_type)) { const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride]; int mx = (scale * mv_col[0] + 128) >> 8; int my = (scale * mv_col[1] + 128) >> 8; fill_rectangle(&sl->mv_cache[0][scan8[i8 * 4]], 2, 2, 8, pack16to32(mx, my), 4); fill_rectangle(&sl->mv_cache[1][scan8[i8 * 4]], 2, 2, 8, pack16to32(mx - mv_col[0], my - mv_col[1]), 4); } else { for (i4 = 0; i4 < 4; i4++) { const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) + (y8 * 2 + (i4 >> 1)) * b4_stride]; int16_t *mv_l0 = sl->mv_cache[0][scan8[i8 * 4 + i4]]; mv_l0[0] = (scale * mv_col[0] + 128) >> 8; mv_l0[1] = (scale * mv_col[1] + 128) >> 8; AV_WN32A(sl->mv_cache[1][scan8[i8 * 4 + i4]], pack16to32(mv_l0[0] - mv_col[0], mv_l0[1] - mv_col[1])); } } } } } }


static void redohhead ( struct alltabs * at , int isv ) {
 int i ;
 struct hhead * head ;
 FILE * f ;
 if ( ! isv ) {
 f = at -> hheadf = tmpfile ( ) ;
 head = & at -> hhead ;
 }
 else {
 f = at -> vheadf = tmpfile ( ) ;
 head = & at -> vhead ;
 }
 putlong ( f , head -> version ) ;
 putshort ( f , head -> ascender ) ;
 putshort ( f , head -> descender ) ;
 putshort ( f , head -> linegap ) ;
 putshort ( f , head -> maxwidth ) ;
 putshort ( f , head -> minlsb ) ;
 putshort ( f , head -> minrsb ) ;
 putshort ( f , head -> maxextent ) ;
 putshort ( f , head -> caretSlopeRise ) ;
 putshort ( f , head -> caretSlopeRun ) ;
 for ( i = 0 ;
 i < 5 ;
 ++ i ) putshort ( f , head -> mbz [ i ] ) ;
 putshort ( f , head -> metricformat ) ;
 putshort ( f , head -> numMetrics ) ;
 if ( ! isv ) {
 at -> hheadlen = ftell ( f ) ;
 if ( ( at -> hheadlen & 2 ) != 0 ) putshort ( f , 0 ) ;
 }
 else {
 at -> vheadlen = ftell ( f ) ;
 if ( ( at -> vheadlen & 2 ) != 0 ) putshort ( f , 0 ) ;
 }
 }


ntoa (int32_t value, int radix)
{
  bool negative;
  uint32_t uvalue;
  static char str[256];
  char *s = &str[sizeof str];

  *--s = '\0';

  if (value < 0)
    {
      negative = true;
      uvalue = -(uint32_t) value;
    }
  else
    {
      negative = false;
      uvalue = (uint32_t) value;
    }

  do
    {
      *--s = digits[uvalue % radix];
      uvalue /= radix;
    }
  while (uvalue > 0);

  if (negative)
    *--s = '-';
  return s;
}


static int wc3_read_packet(AVFormatContext *s, AVPacket *pkt) { Wc3DemuxContext *wc3 = s->priv_data; ByteIOContext *pb = s->pb; unsigned int fourcc_tag; unsigned int size; int packet_read = 0; int ret = 0; unsigned char text[1024]; unsigned int palette_number; int i; unsigned char r, g, b; int base_palette_index; while (!packet_read) { fourcc_tag = get_le32(pb); /* chunk sizes are 16-bit aligned */ size = (get_be32(pb) + 1) & (~1); if (url_feof(pb)) return AVERROR(EIO); switch (fourcc_tag) { case BRCH_TAG: /* no-op */ break; case SHOT_TAG: /* load up new palette */ palette_number = get_le32(pb); if (palette_number >= wc3->palette_count) return AVERROR_INVALIDDATA; base_palette_index = palette_number * PALETTE_COUNT * 3; for (i = 0; i < PALETTE_COUNT; i++) { r = wc3->palettes[base_palette_index + i * 3 + 0]; g = wc3->palettes[base_palette_index + i * 3 + 1]; b = wc3->palettes[base_palette_index + i * 3 + 2]; wc3->palette_control.palette[i] = (r << 16) | (g << 8) | (b); } wc3->palette_control.palette_changed = 1; break; case VGA__TAG: /* send out video chunk */ ret= av_get_packet(pb, pkt, size); pkt->stream_index = wc3->video_stream_index; pkt->pts = wc3->pts; packet_read = 1; break; case TEXT_TAG: /* subtitle chunk */ #if 0 url_fseek(pb, size, SEEK_CUR); #else if ((unsigned)size > sizeof(text) || (ret = get_buffer(pb, text, size)) != size) ret = AVERROR(EIO); else { int i = 0; av_log (s, AV_LOG_DEBUG, "Subtitle time!\n"); av_log (s, AV_LOG_DEBUG, " inglish: %s\n", &text[i + 1]); i += text[i] + 1; av_log (s, AV_LOG_DEBUG, " doytsch: %s\n", &text[i + 1]); i += text[i] + 1; av_log (s, AV_LOG_DEBUG, " fronsay: %s\n", &text[i + 1]); } #endif break; case AUDI_TAG: /* send out audio chunk */ ret= av_get_packet(pb, pkt, size); pkt->stream_index = wc3->audio_stream_index; pkt->pts = wc3->pts; /* time to advance pts */ wc3->pts++; packet_read = 1; break; default: av_log (s, AV_LOG_ERROR, " unrecognized WC3 chunk: %c%c%c%c (0x%02X%02X%02X%02X)\n", (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24), (uint8_t)fourcc_tag, (uint8_t)(fourcc_tag >> 8), (uint8_t)(fourcc_tag >> 16), (uint8_t)(fourcc_tag >> 24)); ret = AVERROR_INVALIDDATA; packet_read = 1; break; } } return ret; }


m4_placeholder (struct obstack *obs, int argc, token_data **argv)
{
  M4ERROR ((warning_status, 0, "\
builtin `%s' requested by frozen file is not supported", ARG (0)));
}


static int dmg_read_resource_fork(BlockDriverState *bs, DmgHeaderState *ds, uint64_t info_begin, uint64_t info_length) { BDRVDMGState *s = bs->opaque; int ret; uint32_t count, rsrc_data_offset; uint8_t *buffer = NULL; uint64_t info_end; uint64_t offset; /* read offset from begin of resource fork (info_begin) to resource data */ ret = read_uint32(bs, info_begin, &rsrc_data_offset); if (ret < 0) { goto fail; } else if (rsrc_data_offset > info_length) { ret = -EINVAL; goto fail; } /* read length of resource data */ ret = read_uint32(bs, info_begin + 8, &count); if (ret < 0) { goto fail; } else if (count == 0 || rsrc_data_offset + count > info_length) { ret = -EINVAL; goto fail; } /* begin of resource data (consisting of one or more resources) */ offset = info_begin + rsrc_data_offset; /* end of resource data (there is possibly a following resource map * which will be ignored). */ info_end = offset + count; /* read offsets (mish blocks) from one or more resources in resource data */ while (offset < info_end) { /* size of following resource */ ret = read_uint32(bs, offset, &count); if (ret < 0) { goto fail; } else if (count == 0) { ret = -EINVAL; goto fail; } offset += 4; buffer = g_realloc(buffer, count); ret = bdrv_pread(bs->file, offset, buffer, count); if (ret < 0) { goto fail; } ret = dmg_read_mish_block(s, ds, buffer, count); if (ret < 0) { goto fail; } /* advance offset by size of resource */ offset += count; } ret = 0; fail: g_free(buffer); return ret; }


void virtio_scsi_common_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(dev); int i; virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI, sizeof(VirtIOSCSIConfig)); s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *)); s->sense_size = VIRTIO_SCSI_SENSE_SIZE; s->cdb_size = VIRTIO_SCSI_CDB_SIZE; s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_ctrl); s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_event); for (i = 0; i < s->conf.num_queues; i++) { s->cmd_vqs[i] = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, virtio_scsi_handle_cmd); } }


static void rv34_decoder_free ( RV34DecContext * r ) {
 av_freep ( & r -> intra_types_hist ) ;
 r -> intra_types = NULL ;
 av_freep ( & r -> tmp_b_block_base ) ;
 av_freep ( & r -> mb_type ) ;
 av_freep ( & r -> cbp_luma ) ;
 av_freep ( & r -> cbp_chroma ) ;
 av_freep ( & r -> deblock_coefs ) ;
 }


static void encode_breakout_test ( VP9_COMP * cpi , MACROBLOCK * x , BLOCK_SIZE bsize , int mi_row , int mi_col , MV_REFERENCE_FRAME ref_frame , PREDICTION_MODE this_mode , unsigned int var_y , unsigned int sse_y , struct buf_2d yv12_mb [ ] [ MAX_MB_PLANE ] , int * rate , int64_t * dist ) {
 MACROBLOCKD * xd = & x -> e_mbd ;
 MB_MODE_INFO * mbmi = & xd -> mi [ 0 ] . src_mi -> mbmi ;
 const BLOCK_SIZE uv_size = get_plane_block_size ( bsize , & xd -> plane [ 1 ] ) ;
 unsigned int var = var_y , sse = sse_y ;
 unsigned int thresh_ac ;
 unsigned int thresh_dc ;
 if ( x -> encode_breakout > 0 ) {
 const unsigned int max_thresh = 36000 ;
 const unsigned int min_thresh = MIN ( ( ( unsigned int ) x -> encode_breakout << 4 ) , max_thresh ) ;
 thresh_ac = ( xd -> plane [ 0 ] . dequant [ 1 ] * xd -> plane [ 0 ] . dequant [ 1 ] ) / 9 ;
 thresh_ac = clamp ( thresh_ac , min_thresh , max_thresh ) ;
 thresh_ac >>= - ( b_width_log2 ( bsize ) + b_height_log2 ( bsize ) ) ;
 thresh_dc = ( xd -> plane [ 0 ] . dequant [ 0 ] * xd -> plane [ 0 ] . dequant [ 0 ] >> 6 ) ;
 }
 else {
 thresh_ac = 0 ;
 thresh_dc = 0 ;
 }
 if ( var <= thresh_ac && ( sse - var ) <= thresh_dc ) {
 unsigned int sse_u , sse_v ;
 unsigned int var_u , var_v ;
 if ( x -> encode_breakout == 0 ) {
 xd -> plane [ 1 ] . pre [ 0 ] = yv12_mb [ ref_frame ] [ 1 ] ;
 xd -> plane [ 2 ] . pre [ 0 ] = yv12_mb [ ref_frame ] [ 2 ] ;
 vp9_build_inter_predictors_sbuv ( xd , mi_row , mi_col , bsize ) ;
 }
 var_u = cpi -> fn_ptr [ uv_size ] . vf ( x -> plane [ 1 ] . src . buf , x -> plane [ 1 ] . src . stride , xd -> plane [ 1 ] . dst . buf , xd -> plane [ 1 ] . dst . stride , & sse_u ) ;
 if ( ( var_u * 4 <= thresh_ac ) && ( sse_u - var_u <= thresh_dc ) ) {
 var_v = cpi -> fn_ptr [ uv_size ] . vf ( x -> plane [ 2 ] . src . buf , x -> plane [ 2 ] . src . stride , xd -> plane [ 2 ] . dst . buf , xd -> plane [ 2 ] . dst . stride , & sse_v ) ;
 if ( ( var_v * 4 <= thresh_ac ) && ( sse_v - var_v <= thresh_dc ) ) {
 x -> skip = 1 ;
 * rate = cpi -> inter_mode_cost [ mbmi -> mode_context [ ref_frame ] ] [ INTER_OFFSET ( this_mode ) ] ;
 * dist = ( sse << 4 ) ;
 }
 }
 }
 }


include (int argc, token_data **argv, bool silent)
{
  FILE *fp;
  char *name;

  if (bad_argc (argv[0], argc, 2, 2))
    return;

  fp = m4_path_search (ARG (1), &name);
  if (fp == NULL)
    {
      if (!silent)
	{
	  M4ERROR ((warning_status, errno, "cannot open `%s'", ARG (1)));
	  retcode = EXIT_FAILURE;
	}
      return;
    }

  push_file (fp, name, true);
  free (name);
}


m4_sysval (struct obstack *obs, int argc, token_data **argv)
{
  shipout_int (obs, (sysval == -1 ? 127
		     : (M4SYSVAL_EXITBITS (sysval)
			| M4SYSVAL_TERMSIGBITS (sysval))));
}


m4_m4exit (struct obstack *obs, int argc, token_data **argv)
{
  int exit_code = EXIT_SUCCESS;

  /* Warn on bad arguments, but still exit.  */
  bad_argc (argv[0], argc, 1, 2);
  if (argc >= 2 && !numeric_arg (argv[0], ARG (1), &exit_code))
    exit_code = EXIT_FAILURE;
  if (exit_code < 0 || exit_code > 255)
    {
      M4ERROR ((warning_status, 0,
		"exit status out of range: `%d'", exit_code));
      exit_code = EXIT_FAILURE;
    }
  /* Change debug stream back to stderr, to force flushing debug stream and
     detect any errors it might have encountered.  */
  debug_set_output (NULL);
  debug_flush_files ();
  if (exit_code == EXIT_SUCCESS && retcode != EXIT_SUCCESS)
    exit_code = retcode;
  /* Propagate non-zero status to atexit handlers.  */
  if (exit_code != EXIT_SUCCESS)
    exit_failure = exit_code;
  exit (exit_code);
}


DriveInfo *drive_init(QemuOpts *opts, void *opaque, int *fatal_error) { const char *buf; const char *file = NULL; char devname[128]; const char *serial; const char *mediastr = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriver *drv = NULL; QEMUMachine *machine = opaque; int max_devs; int index; int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; const char *devaddr; DriveInfo *dinfo; int snapshot = 0; *fatal_error = 1; translation = BIOS_ATA_TRANSLATION_AUTO; if (machine && machine->use_scsi) { type = IF_SCSI; max_devs = MAX_SCSI_DEVS; pstrcpy(devname, sizeof(devname), "scsi"); } else { type = IF_IDE; max_devs = MAX_IDE_DEVS; pstrcpy(devname, sizeof(devname), "ide"); } media = MEDIA_DISK; /* extract parameters */ bus_id = qemu_opt_get_number(opts, "bus", 0); unit_id = qemu_opt_get_number(opts, "unit", -1); index = qemu_opt_get_number(opts, "index", -1); cyls = qemu_opt_get_number(opts, "cyls", 0); heads = qemu_opt_get_number(opts, "heads", 0); secs = qemu_opt_get_number(opts, "secs", 0); snapshot = qemu_opt_get_bool(opts, "snapshot", 0); ro = qemu_opt_get_bool(opts, "readonly", 0); file = qemu_opt_get(opts, "file"); serial = qemu_opt_get(opts, "serial"); if ((buf = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(devname, sizeof(devname), buf); if (!strcmp(buf, "ide")) { type = IF_IDE; max_devs = MAX_IDE_DEVS; } else if (!strcmp(buf, "scsi")) { type = IF_SCSI; max_devs = MAX_SCSI_DEVS; } else if (!strcmp(buf, "floppy")) { type = IF_FLOPPY; max_devs = 0; } else if (!strcmp(buf, "pflash")) { type = IF_PFLASH; max_devs = 0; } else if (!strcmp(buf, "mtd")) { type = IF_MTD; max_devs = 0; } else if (!strcmp(buf, "sd")) { type = IF_SD; max_devs = 0; } else if (!strcmp(buf, "virtio")) { type = IF_VIRTIO; max_devs = 0; } else if (!strcmp(buf, "xen")) { type = IF_XEN; max_devs = 0; } else if (!strcmp(buf, "none")) { type = IF_NONE; max_devs = 0; } else { fprintf(stderr, "qemu: unsupported bus type '%s'\n", buf); return NULL; } } if (cyls || heads || secs) { if (cyls < 1 || (type == IF_IDE && cyls > 16383)) { fprintf(stderr, "qemu: '%s' invalid physical cyls number\n", buf); return NULL; } if (heads < 1 || (type == IF_IDE && heads > 16)) { fprintf(stderr, "qemu: '%s' invalid physical heads number\n", buf); return NULL; } if (secs < 1 || (type == IF_IDE && secs > 63)) { fprintf(stderr, "qemu: '%s' invalid physical secs number\n", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "trans")) != NULL) { if (!cyls) { fprintf(stderr, "qemu: '%s' trans must be used with cyls,heads and secs\n", buf); return NULL; } if (!strcmp(buf, "none")) translation = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(buf, "lba")) translation = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(buf, "auto")) translation = BIOS_ATA_TRANSLATION_AUTO; else { fprintf(stderr, "qemu: '%s' invalid translation type\n", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "media")) != NULL) { if (!strcmp(buf, "disk")) { media = MEDIA_DISK; } else if (!strcmp(buf, "cdrom")) { if (cyls || secs || heads) { fprintf(stderr, "qemu: '%s' invalid physical CHS format\n", buf); return NULL; } media = MEDIA_CDROM; } else { fprintf(stderr, "qemu: '%s' invalid media\n", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "cache")) != NULL) { if (!strcmp(buf, "off") || !strcmp(buf, "none")) { bdrv_flags |= BDRV_O_NOCACHE; } else if (!strcmp(buf, "writeback")) { } else if (!strcmp(buf, "writethrough")) { /* this is the default */ } else { fprintf(stderr, "qemu: invalid cache option\n"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((buf = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(buf, "native")) { bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(buf, "threads")) { /* this is the default */ } else { fprintf(stderr, "qemu: invalid aio option\n"); return NULL; } } #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(buf, "?") == 0) { fprintf(stderr, "qemu: Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); fprintf(stderr, "\n"); return NULL; } drv = bdrv_find_whitelisted_format(buf); if (!drv) { fprintf(stderr, "qemu: '%s' invalid format\n", buf); return NULL; } } on_write_error = BLOCK_ERR_STOP_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO) { fprintf(stderr, "werror is no supported by this format\n"); return NULL; } on_write_error = parse_block_error_action(buf, 0); if (on_write_error < 0) { return NULL; } } on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO) { fprintf(stderr, "rerror is no supported by this format\n"); return NULL; } on_read_error = parse_block_error_action(buf, 1); if (on_read_error < 0) { return NULL; } } if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { fprintf(stderr, "addr is not supported\n"); return NULL; } } /* compute bus and unit according index */ if (index != -1) { if (bus_id != 0 || unit_id != -1) { fprintf(stderr, "qemu: index cannot be used with bus and unit\n"); return NULL; } if (max_devs == 0) { unit_id = index; bus_id = 0; } else { unit_id = index % max_devs; bus_id = index / max_devs; } } /* if user doesn't specify a unit_id, * try to find the first free */ if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } /* check unit id */ if (max_devs && unit_id >= max_devs) { fprintf(stderr, "qemu: unit %d too big (max is %d)\n", unit_id, max_devs - 1); return NULL; } /* * ignore multiple definitions */ if (drive_get(type, bus_id, unit_id) != NULL) { *fatal_error = 0; return NULL; } /* init */ dinfo = qemu_mallocz(sizeof(*dinfo)); if ((buf = qemu_opts_id(opts)) != NULL) { dinfo->id = qemu_strdup(buf); } else { /* no id supplied -> create one */ dinfo->id = qemu_mallocz(32); if (type == IF_IDE || type == IF_SCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; if (max_devs) snprintf(dinfo->id, 32, "%s%i%s%i", devname, bus_id, mediastr, unit_id); else snprintf(dinfo->id, 32, "%s%s%i", devname, mediastr, unit_id); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->devaddr = devaddr; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->on_read_error = on_read_error; dinfo->on_write_error = on_write_error; dinfo->opts = opts; if (serial) strncpy(dinfo->serial, serial, sizeof(serial)); QTAILQ_INSERT_TAIL(&drives, dinfo, next); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(media) { case MEDIA_DISK: if (cyls != 0) { bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs); bdrv_set_translation_hint(dinfo->bdrv, translation); } break; case MEDIA_CDROM: bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_CDROM); break; } break; case IF_SD: /* FIXME: This isn't really a floppy, but it's a reasonable approximation. */ case IF_FLOPPY: bdrv_set_type_hint(dinfo->bdrv, BDRV_TYPE_FLOPPY); break; case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: /* add virtio block device */ opts = qemu_opts_create(&qemu_device_opts, NULL, 0); qemu_opt_set(opts, "driver", "virtio-blk-pci"); qemu_opt_set(opts, "drive", dinfo->id); if (devaddr) qemu_opt_set(opts, "addr", devaddr); break; case IF_COUNT: abort(); } if (!file) { *fatal_error = 0; return NULL; } if (snapshot) { /* always use write-back with snapshot */ bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB); } if (media == MEDIA_CDROM) { /* CDROM is fine for any interface, don't check. */ ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY) { fprintf(stderr, "qemu: readonly flag not supported for drive with this interface\n"); return NULL; } } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; if (bdrv_open(dinfo->bdrv, file, bdrv_flags, drv) < 0) { fprintf(stderr, "qemu: could not open disk image %s: %s\n", file, strerror(errno)); return NULL; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; *fatal_error = 0; return dinfo; }


issue_expect_message (int expected)
{
  if (expected == '\n')
    M4ERROR ((EXIT_FAILURE, 0, "expecting line feed in frozen file"));
  else
    M4ERROR ((EXIT_FAILURE, 0, "expecting character `%c' in frozen file",
	      expected));
}


int av_opt_is_set_to_default(void *obj, const AVOption *o) { int64_t i64; double d, d2; float f; AVRational q; int ret, w, h; char *str; void *dst; if (!o || !obj) return AVERROR(EINVAL); dst = ((uint8_t*)obj) + o->offset; switch (o->type) { case AV_OPT_TYPE_CONST: return 1; case AV_OPT_TYPE_FLAGS: case AV_OPT_TYPE_PIXEL_FMT: case AV_OPT_TYPE_SAMPLE_FMT: case AV_OPT_TYPE_INT: case AV_OPT_TYPE_CHANNEL_LAYOUT: case AV_OPT_TYPE_DURATION: case AV_OPT_TYPE_INT64: read_number(o, dst, NULL, NULL, &i64); return o->default_val.i64 == i64; case AV_OPT_TYPE_STRING: str = *(char **)dst; if (str == o->default_val.str) //2 NULLs return 1; if (!str || !o->default_val.str) //1 NULL return 0; return !strcmp(str, o->default_val.str); case AV_OPT_TYPE_DOUBLE: read_number(o, dst, &d, NULL, NULL); return o->default_val.dbl == d; case AV_OPT_TYPE_FLOAT: read_number(o, dst, &d, NULL, NULL); f = o->default_val.dbl; d2 = f; return d2 == d; case AV_OPT_TYPE_RATIONAL: q = av_d2q(o->default_val.dbl, INT_MAX); return !av_cmp_q(*(AVRational*)dst, q); case AV_OPT_TYPE_BINARY: { struct { uint8_t *data; int size; } tmp = {0}; int opt_size = *(int *)((void **)dst + 1); void *opt_ptr = *(void **)dst; if (!opt_ptr && (!o->default_val.str || !strlen(o->default_val.str))) return 1; if (opt_ptr && o->default_val.str && !strlen(o->default_val.str)) return 0; if (opt_size != strlen(o->default_val.str) / 2) return 0; ret = set_string_binary(NULL, NULL, o->default_val.str, &tmp.data); if (!ret) ret = !memcmp(opt_ptr, tmp.data, tmp.size); av_free(tmp.data); return ret; } case AV_OPT_TYPE_DICT: /* Binary and dict have not default support yet. Any pointer is not default. */ return !!(*(void **)dst); case AV_OPT_TYPE_IMAGE_SIZE: if (!o->default_val.str || !strcmp(o->default_val.str, "none")) w = h = 0; else if ((ret = av_parse_video_size(&w, &h, o->default_val.str)) < 0) return ret; return (w == *(int *)dst) && (h == *((int *)dst+1)); case AV_OPT_TYPE_VIDEO_RATE: q = (AVRational){0, 0}; if (o->default_val.str) av_parse_video_rate(&q, o->default_val.str); return !av_cmp_q(*(AVRational*)dst, q); case AV_OPT_TYPE_COLOR: { uint8_t color[4] = {0, 0, 0, 0}; if (o->default_val.str) av_parse_color(color, o->default_val.str, -1, NULL); return !memcmp(color, dst, sizeof(color)); } default: av_log(obj, AV_LOG_WARNING, "Not supported option type: %d, option name: %s\n", o->type, o->name); break; } return AVERROR_PATCHWELCOME; }


asn1_id_decode(struct asn1_ctx *ctx,
	       unsigned int *cls, unsigned int *con, unsigned int *tag)
{
	unsigned char ch;

	if (!asn1_octet_decode(ctx, &ch))
		return 0;

	*cls = (ch & 0xC0) >> 6;
	*con = (ch & 0x20) >> 5;
	*tag = (ch & 0x1F);

	if (*tag == 0x1F) {
		if (!asn1_tag_decode(ctx, tag))
			return 0;
	}
	return 1;
}


int ioinst_handle_msch(CPUS390XState *env, uint64_t reg1, uint32_t ipb) { int cssid, ssid, schid, m; SubchDev *sch; SCHIB *schib; uint64_t addr; int ret = -ENODEV; int cc; hwaddr len = sizeof(*schib); if (ioinst_disassemble_sch_ident(reg1, &m, &cssid, &ssid, &schid)) { program_interrupt(env, PGM_OPERAND, 2); return -EIO; } trace_ioinst_sch_id("msch", cssid, ssid, schid); addr = decode_basedisp_s(env, ipb); if (addr & 3) { program_interrupt(env, PGM_SPECIFICATION, 2); return -EIO; } schib = s390_cpu_physical_memory_map(env, addr, &len, 0); if (!schib || len != sizeof(*schib)) { program_interrupt(env, PGM_ADDRESSING, 2); cc = -EIO; goto out; } if (!ioinst_schib_valid(schib)) { program_interrupt(env, PGM_OPERAND, 2); cc = -EIO; goto out; } sch = css_find_subch(m, cssid, ssid, schid); if (sch && css_subch_visible(sch)) { ret = css_do_msch(sch, schib); } switch (ret) { case -ENODEV: cc = 3; break; case -EBUSY: cc = 2; break; case 0: cc = 0; break; default: cc = 1; break; } out: s390_cpu_physical_memory_unmap(env, schib, len, 0); return cc; }


static void virtio_ioport_write ( void * opaque , uint32_t addr , uint32_t val ) {
 VirtIOPCIProxy * proxy = opaque ;
 VirtIODevice * vdev = proxy -> vdev ;
 target_phys_addr_t pa ;
 switch ( addr ) {
 case VIRTIO_PCI_GUEST_FEATURES : if ( val & ( 1 << VIRTIO_F_BAD_FEATURE ) ) {
 if ( vdev -> bad_features ) val = proxy -> host_features & vdev -> bad_features ( vdev ) ;
 else val = 0 ;
 }
 if ( vdev -> set_features ) vdev -> set_features ( vdev , val ) ;
 vdev -> guest_features = val ;
 break ;
 case VIRTIO_PCI_QUEUE_PFN : pa = ( target_phys_addr_t ) val << VIRTIO_PCI_QUEUE_ADDR_SHIFT ;
 if ( pa == 0 ) {
 virtio_reset ( proxy -> vdev ) ;
 msix_unuse_all_vectors ( & proxy -> pci_dev ) ;
 }
 else virtio_queue_set_addr ( vdev , vdev -> queue_sel , pa ) ;
 break ;
 case VIRTIO_PCI_QUEUE_SEL : if ( val < VIRTIO_PCI_QUEUE_MAX ) vdev -> queue_sel = val ;
 break ;
 case VIRTIO_PCI_QUEUE_NOTIFY : virtio_queue_notify ( vdev , val ) ;
 break ;
 case VIRTIO_PCI_STATUS : vdev -> status = val & 0xFF ;
 if ( vdev -> status == 0 ) {
 virtio_reset ( proxy -> vdev ) ;
 msix_unuse_all_vectors ( & proxy -> pci_dev ) ;
 }
 break ;
 case VIRTIO_MSI_CONFIG_VECTOR : msix_vector_unuse ( & proxy -> pci_dev , vdev -> config_vector ) ;
 if ( msix_vector_use ( & proxy -> pci_dev , val ) < 0 ) val = VIRTIO_NO_VECTOR ;
 vdev -> config_vector = val ;
 break ;
 case VIRTIO_MSI_QUEUE_VECTOR : msix_vector_unuse ( & proxy -> pci_dev , virtio_queue_vector ( vdev , vdev -> queue_sel ) ) ;
 if ( msix_vector_use ( & proxy -> pci_dev , val ) < 0 ) val = VIRTIO_NO_VECTOR ;
 virtio_queue_set_vector ( vdev , vdev -> queue_sel , val ) ;
 break ;
 default : fprintf ( stderr , "%s: unexpected address 0x%x value 0x%x\n" , __func__ , addr , val ) ;
 break ;
 }
 }


static inline void mangle_address(unsigned char *begin,
				  unsigned char *addr,
				  const struct oct1_map *map,
				  __sum16 *check)
{
	if (map->from == NOCT1(addr)) {
		u_int32_t old;

		if (debug)
			memcpy(&old, addr, sizeof(old));

		*addr = map->to;

		/* Update UDP checksum if being used */
		if (*check) {
			fast_csum(check,
				  &map->from, &map->to, addr - begin);

		}

		if (debug)
			printk(KERN_DEBUG "bsalg: mapped %u.%u.%u.%u to "
			       "%u.%u.%u.%u\n", NIPQUAD(old), NIPQUAD(*addr));
	}
}


static int vnc_auth_sasl_check_access(VncState *vs) { const void *val; int err; err = sasl_getprop(vs->sasl.conn, SASL_USERNAME, &val); if (err != SASL_OK) { VNC_DEBUG("cannot query SASL username on connection %d (%s)\n", err, sasl_errstring(err, NULL, NULL)); return -1; } if (val == NULL) { VNC_DEBUG("no client username was found\n"); return -1; } VNC_DEBUG("SASL client username %s\n", (const char *)val); vs->sasl.username = qemu_strdup((const char*)val); return 0; }


void mainwindows_init ( void ) {
 screen_width = term_width ;
 screen_height = term_height ;
 mainwindows = NULL ;
 active_mainwin = NULL ;
 clrtoeol_info = g_new0 ( MAIN_WINDOW_BORDER_REC , 1 ) ;
 screen_reserved_top = screen_reserved_bottom = 0 ;
 screen_reserved_left = screen_reserved_right = 0 ;
 command_bind ( "window grow" , NULL , ( SIGNAL_FUNC ) cmd_window_grow ) ;
 command_bind ( "window shrink" , NULL , ( SIGNAL_FUNC ) cmd_window_shrink ) ;
 command_bind ( "window size" , NULL , ( SIGNAL_FUNC ) cmd_window_size ) ;
 command_bind ( "window balance" , NULL , ( SIGNAL_FUNC ) cmd_window_balance ) ;
 command_bind ( "window hide" , NULL , ( SIGNAL_FUNC ) cmd_window_hide ) ;
 command_bind ( "window show" , NULL , ( SIGNAL_FUNC ) cmd_window_show ) ;
 command_bind ( "window up" , NULL , ( SIGNAL_FUNC ) cmd_window_up ) ;
 command_bind ( "window down" , NULL , ( SIGNAL_FUNC ) cmd_window_down ) ;
 command_bind ( "window left" , NULL , ( SIGNAL_FUNC ) cmd_window_left ) ;
 command_bind ( "window right" , NULL , ( SIGNAL_FUNC ) cmd_window_right ) ;
 command_bind ( "window dup" , NULL , ( SIGNAL_FUNC ) cmd_window_dup ) ;
 command_bind ( "window ddown" , NULL , ( SIGNAL_FUNC ) cmd_window_ddown ) ;
 command_bind ( "window dleft" , NULL , ( SIGNAL_FUNC ) cmd_window_dleft ) ;
 command_bind ( "window dright" , NULL , ( SIGNAL_FUNC ) cmd_window_dright ) ;
 command_bind ( "window stick" , NULL , ( SIGNAL_FUNC ) cmd_window_stick ) ;
 command_bind ( "window move left" , NULL , ( SIGNAL_FUNC ) cmd_window_move_left ) ;
 command_bind ( "window move right" , NULL , ( SIGNAL_FUNC ) cmd_window_move_right ) ;
 command_bind ( "window move up" , NULL , ( SIGNAL_FUNC ) cmd_window_move_up ) ;
 command_bind ( "window move down" , NULL , ( SIGNAL_FUNC ) cmd_window_move_down ) ;
 command_bind ( "window move dleft" , NULL , ( SIGNAL_FUNC ) cmd_window_move_dleft ) ;
 command_bind ( "window move dright" , NULL , ( SIGNAL_FUNC ) cmd_window_move_dright ) ;
 command_bind ( "window rgrow" , NULL , ( SIGNAL_FUNC ) cmd_window_rgrow ) ;
 command_bind ( "window rshrink" , NULL , ( SIGNAL_FUNC ) cmd_window_rshrink ) ;
 command_bind ( "window rsize" , NULL , ( SIGNAL_FUNC ) cmd_window_rsize ) ;
 command_bind ( "window rbalance" , NULL , ( SIGNAL_FUNC ) cmd_window_rbalance ) ;
 command_bind ( "window rshow" , NULL , ( SIGNAL_FUNC ) cmd_window_rshow ) ;
 signal_add ( "window print info" , ( SIGNAL_FUNC ) sig_window_print_info ) ;
 }


static int make_cdt16_entry(int p1, int p2, int16_t *cdt) { int r, b, lo; b = cdt[p2]; r = cdt[p1] << 11; lo = b + r; return (lo + (lo << 16)) << 1; }


static void openpic_tmr_write(void *opaque, hwaddr addr, uint64_t val, unsigned len) { OpenPICState *opp = opaque; int idx; DPRINTF("%s: addr %08x <= %08x\n", __func__, addr, val); if (addr & 0xF) return; idx = (addr >> 6) & 0x3; addr = addr & 0x30; if (addr == 0x0) { /* TIFR (TFRR) */ opp->tifr = val; return; } switch (addr & 0x30) { case 0x00: /* TICC (GTCCR) */ break; case 0x10: /* TIBC (GTBCR) */ if ((opp->timers[idx].ticc & TICC_TOG) != 0 && (val & TIBC_CI) == 0 && (opp->timers[idx].tibc & TIBC_CI) != 0) { opp->timers[idx].ticc &= ~TICC_TOG; } opp->timers[idx].tibc = val; break; case 0x20: /* TIVP (GTIVPR) */ write_IRQreg_ipvp(opp, opp->irq_tim0 + idx, val); break; case 0x30: /* TIDE (GTIDR) */ write_IRQreg_ide(opp, opp->irq_tim0 + idx, val); break; } }


static void arm_mptimer_reset ( DeviceState * dev ) {
 ARMMPTimerState * s = FROM_SYSBUS ( ARMMPTimerState , SYS_BUS_DEVICE ( dev ) ) ;
 int i ;
 for ( i = 0 ;
 i < ARRAY_SIZE ( s -> timerblock ) ;
 i ++ ) {
 timerblock_reset ( & s -> timerblock [ i ] ) ;
 }
 }


EXCLUSIVE_REGRESSION_TEST ( SDK_API_TSHttpConnectServerIntercept ) ( RegressionTest * test , int , int * pstatus ) {
 * pstatus = REGRESSION_TEST_INPROGRESS ;
 TSDebug ( UTDBG_TAG , "Starting test TSHttpConnectServerintercept" ) ;
 TSCont cont_test = TSContCreate ( cont_test_handler , TSMutexCreate ( ) ) ;
 ConnectTestData * data = ( ConnectTestData * ) TSmalloc ( sizeof ( ConnectTestData ) ) ;
 TSContDataSet ( cont_test , data ) ;
 data -> test = test ;
 data -> pstatus = pstatus ;
 data -> magic = MAGIC_ALIVE ;
 data -> test_case = TEST_CASE_CONNECT_ID2 ;
 TSHttpHookAdd ( TS_HTTP_READ_REQUEST_HDR_HOOK , cont_test ) ;
 data -> os = synserver_create ( SYNSERVER_DUMMY_PORT ) ;
 data -> browser = synclient_txn_create ( ) ;
 data -> request = generate_request ( 10 ) ;
 sockaddr_in addr ;
 ats_ip4_set ( & addr , 2 , 2 ) ;
 data -> vc = TSHttpConnect ( ats_ip_sa_cast ( & addr ) ) ;
 synclient_txn_send_request_to_vc ( data -> browser , data -> request , data -> vc ) ;
 TSContSchedule ( cont_test , 25 , TS_THREAD_POOL_DEFAULT ) ;
 return ;
 }


static inline void tcg_out_dat_rI(TCGContext *s, int cond, int opc, TCGArg dst, TCGArg lhs, TCGArg rhs, int rhs_is_const) { /* Emit either the reg,imm or reg,reg form of a data-processing insn. * rhs must satisfy the "rI" constraint. */ if (rhs_is_const) { int rot = encode_imm(rhs); assert(rot >= 0); tcg_out_dat_imm(s, cond, opc, dst, lhs, rotl(rhs, rot) | (rot << 7)); } else { tcg_out_dat_reg(s, cond, opc, dst, lhs, rhs, SHIFT_IMM_LSL(0)); } }


static void ipip6_tunnel_bind_dev(struct net_device *dev)
{
	struct net_device *tdev = NULL;
	struct ip_tunnel *tunnel;
	struct iphdr *iph;

	tunnel = netdev_priv(dev);
	iph = &tunnel->parms.iph;

	if (iph->daddr) {
		struct flowi fl = { .nl_u = { .ip4_u =
					      { .daddr = iph->daddr,
						.saddr = iph->saddr,
						.tos = RT_TOS(iph->tos) } },
				    .oif = tunnel->parms.link,
				    .proto = IPPROTO_IPV6 };
		struct rtable *rt;
		if (!ip_route_output_key(dev_net(dev), &rt, &fl)) {
			tdev = rt->u.dst.dev;
			ip_rt_put(rt);
		}
		dev->flags |= IFF_POINTOPOINT;
	}

	if (!tdev && tunnel->parms.link)
		tdev = __dev_get_by_index(dev_net(dev), tunnel->parms.link);

	if (tdev) {
		dev->hard_header_len = tdev->hard_header_len + sizeof(struct iphdr);
		dev->mtu = tdev->mtu - sizeof(struct iphdr);
		if (dev->mtu < IPV6_MIN_MTU)
			dev->mtu = IPV6_MIN_MTU;
	}
	dev->iflink = tunnel->parms.link;
}


ipip6_tunnel_del_prl(struct ip_tunnel *t, struct ip_tunnel_prl *a)
{
	struct ip_tunnel_prl_entry *x, **p;
	int err = 0;

	write_lock(&ipip6_lock);

	if (a && a->addr != htonl(INADDR_ANY)) {
		for (p = &t->prl; *p; p = &(*p)->next) {
			if ((*p)->addr == a->addr) {
				x = *p;
				*p = x->next;
				kfree(x);
				t->prl_count--;
				goto out;
			}
		}
		err = -ENXIO;
	} else {
		while (t->prl) {
			x = t->prl;
			t->prl = t->prl->next;
			kfree(x);
			t->prl_count--;
		}
	}
out:
	write_unlock(&ipip6_lock);
	return 0;
}


isatap_chksrc(struct sk_buff *skb, struct iphdr *iph, struct ip_tunnel *t)
{
	struct ip_tunnel_prl_entry *p;
	int ok = 1;

	read_lock(&ipip6_lock);
	p = __ipip6_tunnel_locate_prl(t, iph->saddr);
	if (p) {
		if (p->flags & PRL_DEFAULT)
			skb->ndisc_nodetype = NDISC_NODETYPE_DEFAULT;
		else
			skb->ndisc_nodetype = NDISC_NODETYPE_NODEFAULT;
	} else {
		struct in6_addr *addr6 = &ipv6_hdr(skb)->saddr;
		if (ipv6_addr_is_isatap(addr6) &&
		    (addr6->s6_addr32[3] == iph->saddr) &&
		    ipv6_chk_prefix(addr6, t->dev))
			skb->ndisc_nodetype = NDISC_NODETYPE_HOST;
		else
			ok = 0;
	}
	read_unlock(&ipip6_lock);
	return ok;
}


static void sdhci_initfn(Object *obj) { SDHCIState *s = SDHCI(obj); DriveInfo *di; di = drive_get_next(IF_SD); s->card = sd_init(di ? di->bdrv : NULL, false); if (s->card == NULL) { exit(1); } s->eject_cb = qemu_allocate_irqs(sdhci_insert_eject_cb, s, 1)[0]; s->ro_cb = qemu_allocate_irqs(sdhci_card_readonly_cb, s, 1)[0]; sd_set_cb(s->card, s->ro_cb, s->eject_cb); s->insert_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_raise_insertion_irq, s); s->transfer_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, sdhci_do_data_transfer, s); }


static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) { ASFContext *asf = s->priv_data; ff_asf_guid g; ByteIOContext *pb = s->pb; AVStream *st; ASFStream *asf_st; int size, i; int64_t gsize; AVRational dar[128]; uint32_t bitrate[128]; memset(dar, 0, sizeof(dar)); memset(bitrate, 0, sizeof(bitrate)); get_guid(pb, &g); if (guidcmp(&g, &ff_asf_header)) return -1; get_le64(pb); get_le32(pb); get_byte(pb); get_byte(pb); memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid)); for(;;) { uint64_t gpos= url_ftell(pb); get_guid(pb, &g); gsize = get_le64(pb); dprintf(s, "%08"PRIx64": ", gpos); print_guid(&g); dprintf(s, " size=0x%"PRIx64"\n", gsize); if (!guidcmp(&g, &ff_asf_data_header)) { asf->data_object_offset = url_ftell(pb); // if not streaming, gsize is not unlimited (how?), and there is enough space in the file.. if (!(asf->hdr.flags & 0x01) && gsize >= 100) { asf->data_object_size = gsize - 24; } else { asf->data_object_size = (uint64_t)-1; } break; } if (gsize < 24) return -1; if (!guidcmp(&g, &ff_asf_file_header)) { get_guid(pb, &asf->hdr.guid); asf->hdr.file_size = get_le64(pb); asf->hdr.create_time = get_le64(pb); asf->nb_packets = get_le64(pb); asf->hdr.play_time = get_le64(pb); asf->hdr.send_time = get_le64(pb); asf->hdr.preroll = get_le32(pb); asf->hdr.ignore = get_le32(pb); asf->hdr.flags = get_le32(pb); asf->hdr.min_pktsize = get_le32(pb); asf->hdr.max_pktsize = get_le32(pb); asf->hdr.max_bitrate = get_le32(pb); s->packet_size = asf->hdr.max_pktsize; } else if (!guidcmp(&g, &ff_asf_stream_header)) { enum AVMediaType type; int type_specific_size, sizeX; uint64_t total_size; unsigned int tag1; int64_t pos1, pos2, start_time; int test_for_ext_stream_audio, is_dvr_ms_audio=0; if (s->nb_streams == ASF_MAX_STREAMS) { av_log(s, AV_LOG_ERROR, "too many streams\n"); return AVERROR(EINVAL); } pos1 = url_ftell(pb); st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ asf_st = av_mallocz(sizeof(ASFStream)); if (!asf_st) return AVERROR(ENOMEM); st->priv_data = asf_st; start_time = asf->hdr.preroll; asf_st->stream_language_index = 128; // invalid stream index means no language info if(!(asf->hdr.flags & 0x01)) { // if we aren't streaming... st->duration = asf->hdr.play_time / (10000000 / 1000) - start_time; } get_guid(pb, &g); test_for_ext_stream_audio = 0; if (!guidcmp(&g, &ff_asf_audio_stream)) { type = AVMEDIA_TYPE_AUDIO; } else if (!guidcmp(&g, &ff_asf_video_stream)) { type = AVMEDIA_TYPE_VIDEO; } else if (!guidcmp(&g, &ff_asf_command_stream)) { type = AVMEDIA_TYPE_DATA; } else if (!guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) { test_for_ext_stream_audio = 1; type = AVMEDIA_TYPE_UNKNOWN; } else { return -1; } get_guid(pb, &g); total_size = get_le64(pb); type_specific_size = get_le32(pb); get_le32(pb); st->id = get_le16(pb) & 0x7f; /* stream id */ // mapping of asf ID to AV stream ID; asf->asfid2avid[st->id] = s->nb_streams - 1; get_le32(pb); if (test_for_ext_stream_audio) { get_guid(pb, &g); if (!guidcmp(&g, &ff_asf_ext_stream_audio_stream)) { type = AVMEDIA_TYPE_AUDIO; is_dvr_ms_audio=1; get_guid(pb, &g); get_le32(pb); get_le32(pb); get_le32(pb); get_guid(pb, &g); get_le32(pb); } } st->codec->codec_type = type; if (type == AVMEDIA_TYPE_AUDIO) { ff_get_wav_header(pb, st->codec, type_specific_size); if (is_dvr_ms_audio) { // codec_id and codec_tag are unreliable in dvr_ms // files. Set them later by probing stream. st->codec->codec_id = CODEC_ID_PROBE; st->codec->codec_tag = 0; } if (st->codec->codec_id == CODEC_ID_AAC) { st->need_parsing = AVSTREAM_PARSE_NONE; } else { st->need_parsing = AVSTREAM_PARSE_FULL; } /* We have to init the frame size at some point .... */ pos2 = url_ftell(pb); if (gsize >= (pos2 + 8 - pos1 + 24)) { asf_st->ds_span = get_byte(pb); asf_st->ds_packet_size = get_le16(pb); asf_st->ds_chunk_size = get_le16(pb); get_le16(pb); //ds_data_size get_byte(pb); //ds_silence_data } //printf("Descrambling: ps:%d cs:%d ds:%d s:%d sd:%d\n", // asf_st->ds_packet_size, asf_st->ds_chunk_size, // asf_st->ds_data_size, asf_st->ds_span, asf_st->ds_silence_data); if (asf_st->ds_span > 1) { if (!asf_st->ds_chunk_size || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1) || asf_st->ds_packet_size % asf_st->ds_chunk_size) asf_st->ds_span = 0; // disable descrambling } switch (st->codec->codec_id) { case CODEC_ID_MP3: st->codec->frame_size = MPA_FRAME_SIZE; break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: st->codec->frame_size = 1; break; default: /* This is probably wrong, but it prevents a crash later */ st->codec->frame_size = 1; break; } } else if (type == AVMEDIA_TYPE_VIDEO) { get_le32(pb); get_le32(pb); get_byte(pb); size = get_le16(pb); /* size */ sizeX= get_le32(pb); /* size */ st->codec->width = get_le32(pb); st->codec->height = get_le32(pb); /* not available for asf */ get_le16(pb); /* panes */ st->codec->bits_per_coded_sample = get_le16(pb); /* depth */ tag1 = get_le32(pb); url_fskip(pb, 20); // av_log(s, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX); size= sizeX; if (size > 40) { st->codec->extradata_size = size - 40; st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); get_buffer(pb, st->codec->extradata, st->codec->extradata_size); } /* Extract palette from extradata if bpp <= 8 */ /* This code assumes that extradata contains only palette */ /* This is true for all paletted codecs implemented in ffmpeg */ if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) { st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); #if HAVE_BIGENDIAN for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]); #else memcpy(st->codec->palctrl->palette, st->codec->extradata, FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); #endif st->codec->palctrl->palette_changed = 1; } st->codec->codec_tag = tag1; st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1); if(tag1 == MKTAG('D', 'V', 'R', ' ')) st->need_parsing = AVSTREAM_PARSE_FULL; if(st->codec->codec_id == CODEC_ID_H264) st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; } pos2 = url_ftell(pb); url_fskip(pb, gsize - (pos2 - pos1 + 24)); } else if (!guidcmp(&g, &ff_asf_comment_header)) { int len1, len2, len3, len4, len5; len1 = get_le16(pb); len2 = get_le16(pb); len3 = get_le16(pb); len4 = get_le16(pb); len5 = get_le16(pb); get_tag(s, "title" , 0, len1); get_tag(s, "author" , 0, len2); get_tag(s, "copyright", 0, len3); get_tag(s, "comment" , 0, len4); url_fskip(pb, len5); } else if (!guidcmp(&g, &stream_bitrate_guid)) { int stream_count = get_le16(pb); int j; // av_log(s, AV_LOG_ERROR, "stream bitrate properties\n"); // av_log(s, AV_LOG_ERROR, "streams %d\n", streams); for(j = 0; j < stream_count; j++) { int flags, bitrate, stream_id; flags= get_le16(pb); bitrate= get_le32(pb); stream_id= (flags & 0x7f); // av_log(s, AV_LOG_ERROR, "flags: 0x%x stream id %d, bitrate %d\n", flags, stream_id, bitrate); asf->stream_bitrates[stream_id]= bitrate; } } else if (!guidcmp(&g, &ff_asf_language_guid)) { int j; int stream_count = get_le16(pb); for(j = 0; j < stream_count; j++) { char lang[6]; unsigned int lang_len = get_byte(pb); get_str16_nolen(pb, lang_len, lang, sizeof(lang)); if (j < 128) av_strlcpy(asf->stream_languages[j], lang, sizeof(*asf->stream_languages)); } } else if (!guidcmp(&g, &ff_asf_extended_content_header)) { int desc_count, i; desc_count = get_le16(pb); for(i=0;i<desc_count;i++) { int name_len,value_type,value_len; char name[1024]; name_len = get_le16(pb); if (name_len%2) // must be even, broken lavf versions wrote len-1 name_len += 1; get_str16_nolen(pb, name_len, name, sizeof(name)); value_type = get_le16(pb); value_len = get_le16(pb); if (!value_type && value_len%2) value_len += 1; get_tag(s, name, value_type, value_len); } } else if (!guidcmp(&g, &ff_asf_metadata_header)) { int n, stream_num, name_len, value_len, value_type, value_num; n = get_le16(pb); for(i=0;i<n;i++) { char name[1024]; get_le16(pb); //lang_list_index stream_num= get_le16(pb); name_len= get_le16(pb); value_type= get_le16(pb); value_len= get_le32(pb); get_str16_nolen(pb, name_len, name, sizeof(name)); //av_log(s, AV_LOG_ERROR, "%d %d %d %d %d <%s>\n", i, stream_num, name_len, value_type, value_len, name); value_num= get_le16(pb);//we should use get_value() here but it does not work 2 is le16 here but le32 elsewhere url_fskip(pb, value_len - 2); if(stream_num<128){ if (!strcmp(name, "AspectRatioX")) dar[stream_num].num= value_num; else if(!strcmp(name, "AspectRatioY")) dar[stream_num].den= value_num; } } } else if (!guidcmp(&g, &ff_asf_ext_stream_header)) { int ext_len, payload_ext_ct, stream_ct; uint32_t ext_d, leak_rate, stream_num; unsigned int stream_languageid_index; get_le64(pb); // starttime get_le64(pb); // endtime leak_rate = get_le32(pb); // leak-datarate get_le32(pb); // bucket-datasize get_le32(pb); // init-bucket-fullness get_le32(pb); // alt-leak-datarate get_le32(pb); // alt-bucket-datasize get_le32(pb); // alt-init-bucket-fullness get_le32(pb); // max-object-size get_le32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved) stream_num = get_le16(pb); // stream-num stream_languageid_index = get_le16(pb); // stream-language-id-index if (stream_num < 128) asf->streams[stream_num].stream_language_index = stream_languageid_index; get_le64(pb); // avg frametime in 100ns units stream_ct = get_le16(pb); //stream-name-count payload_ext_ct = get_le16(pb); //payload-extension-system-count if (stream_num < 128) bitrate[stream_num] = leak_rate; for (i=0; i<stream_ct; i++){ get_le16(pb); ext_len = get_le16(pb); url_fseek(pb, ext_len, SEEK_CUR); } for (i=0; i<payload_ext_ct; i++){ get_guid(pb, &g); ext_d=get_le16(pb); ext_len=get_le32(pb); url_fseek(pb, ext_len, SEEK_CUR); } // there could be a optional stream properties object to follow // if so the next iteration will pick it up continue; } else if (!guidcmp(&g, &ff_asf_head1_guid)) { int v1, v2; get_guid(pb, &g); v1 = get_le32(pb); v2 = get_le16(pb); continue; } else if (!guidcmp(&g, &ff_asf_marker_header)) { int i, count, name_len; char name[1024]; get_le64(pb); // reserved 16 bytes get_le64(pb); // ... count = get_le32(pb); // markers count get_le16(pb); // reserved 2 bytes name_len = get_le16(pb); // name length for(i=0;i<name_len;i++){ get_byte(pb); // skip the name } for(i=0;i<count;i++){ int64_t pres_time; int name_len; get_le64(pb); // offset, 8 bytes pres_time = get_le64(pb); // presentation time get_le16(pb); // entry length get_le32(pb); // send time get_le32(pb); // flags name_len = get_le32(pb); // name length get_str16_nolen(pb, name_len * 2, name, sizeof(name)); ff_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name ); } #if 0 } else if (!guidcmp(&g, &ff_asf_codec_comment_header)) { int len, v1, n, num; char str[256], *q; char tag[16]; get_guid(pb, &g); print_guid(&g); n = get_le32(pb); for(i=0;i<n;i++) { num = get_le16(pb); /* stream number */ get_str16(pb, str, sizeof(str)); get_str16(pb, str, sizeof(str)); len = get_le16(pb); q = tag; while (len > 0) { v1 = get_byte(pb); if ((q - tag) < sizeof(tag) - 1) *q++ = v1; len--; } *q = '\0'; } #endif } else if (url_feof(pb)) { return -1; } else { if (!s->keylen) { if (!guidcmp(&g, &ff_asf_content_encryption)) { av_log(s, AV_LOG_WARNING, "DRM protected stream detected, decoding will likely fail!\n"); } else if (!guidcmp(&g, &ff_asf_ext_content_encryption)) { av_log(s, AV_LOG_WARNING, "Ext DRM protected stream detected, decoding will likely fail!\n"); } else if (!guidcmp(&g, &ff_asf_digital_signature)) { av_log(s, AV_LOG_WARNING, "Digital signature detected, decoding will likely fail!\n"); } } } if(url_ftell(pb) != gpos + gsize) av_log(s, AV_LOG_DEBUG, "gpos mismatch our pos=%"PRIu64", end=%"PRIu64"\n", url_ftell(pb)-gpos, gsize); url_fseek(pb, gpos + gsize, SEEK_SET); } get_guid(pb, &g); get_le64(pb); get_byte(pb); get_byte(pb); if (url_feof(pb)) return -1; asf->data_offset = url_ftell(pb); asf->packet_size_left = 0; for(i=0; i<128; i++){ int stream_num= asf->asfid2avid[i]; if(stream_num>=0){ AVStream *st = s->streams[stream_num]; if (!st->codec->bit_rate) st->codec->bit_rate = bitrate[i]; if (dar[i].num > 0 && dar[i].den > 0) av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, dar[i].num, dar[i].den, INT_MAX); //av_log(s, AV_LOG_ERROR, "dar %d:%d sar=%d:%d\n", dar[i].num, dar[i].den, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); // copy and convert language codes to the frontend if (asf->streams[i].stream_language_index < 128) { const char *rfc1766 = asf->stream_languages[asf->streams[i].stream_language_index]; if (rfc1766 && strlen(rfc1766) > 1) { const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; // ignore country code if any const char *iso6392 = av_convert_lang_to(primary_tag, AV_LANG_ISO639_2_BIBL); if (iso6392) av_metadata_set2(&st->metadata, "language", iso6392, 0); } } } } return 0; }


static int mpeg_field_start ( MpegEncContext * s , const uint8_t * buf , int buf_size ) {
 AVCodecContext * avctx = s -> avctx ;
 Mpeg1Context * s1 = ( Mpeg1Context * ) s ;
 if ( s -> first_field || s -> picture_structure == PICT_FRAME ) {
 if ( ff_MPV_frame_start ( s , avctx ) < 0 ) return - 1 ;
 ff_mpeg_er_frame_start ( s ) ;
 s -> current_picture_ptr -> f . repeat_pict = 0 ;
 if ( s -> repeat_first_field ) {
 if ( s -> progressive_sequence ) {
 if ( s -> top_field_first ) s -> current_picture_ptr -> f . repeat_pict = 4 ;
 else s -> current_picture_ptr -> f . repeat_pict = 2 ;
 }
 else if ( s -> progressive_frame ) {
 s -> current_picture_ptr -> f . repeat_pict = 1 ;
 }
 }
 * s -> current_picture_ptr -> f . pan_scan = s1 -> pan_scan ;
 if ( HAVE_THREADS && ( avctx -> active_thread_type & FF_THREAD_FRAME ) ) ff_thread_finish_setup ( avctx ) ;
 }
 else {
 int i ;
 if ( ! s -> current_picture_ptr ) {
 av_log ( s -> avctx , AV_LOG_ERROR , "first field missing\n" ) ;
 return - 1 ;
 }
 if ( s -> avctx -> hwaccel && ( s -> avctx -> slice_flags & SLICE_FLAG_ALLOW_FIELD ) ) {
 if ( s -> avctx -> hwaccel -> end_frame ( s -> avctx ) < 0 ) av_log ( avctx , AV_LOG_ERROR , "hardware accelerator failed to decode first field\n" ) ;
 }
 for ( i = 0 ;
 i < 4 ;
 i ++ ) {
 s -> current_picture . f . data [ i ] = s -> current_picture_ptr -> f . data [ i ] ;
 if ( s -> picture_structure == PICT_BOTTOM_FIELD ) {
 s -> current_picture . f . data [ i ] += s -> current_picture_ptr -> f . linesize [ i ] ;
 }
 }
 }
 if ( avctx -> hwaccel ) {
 if ( avctx -> hwaccel -> start_frame ( avctx , buf , buf_size ) < 0 ) return - 1 ;
 }
 if ( CONFIG_MPEG_XVMC_DECODER && s -> avctx -> xvmc_acceleration ) if ( ff_xvmc_field_start ( s , avctx ) < 0 ) return - 1 ;
 return 0 ;
 }


static int cdxl_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt) { CDXLVideoContext *c = avctx->priv_data; AVFrame * const p = data; int ret, w, h, encoding, aligned_width, buf_size = pkt->size; const uint8_t *buf = pkt->data; if (buf_size < 32) return AVERROR_INVALIDDATA; encoding = buf[1] & 7; c->format = buf[1] & 0xE0; w = AV_RB16(&buf[14]); h = AV_RB16(&buf[16]); c->bpp = buf[19]; c->palette_size = AV_RB16(&buf[20]); c->palette = buf + 32; c->video = c->palette + c->palette_size; c->video_size = buf_size - c->palette_size - 32; if (c->palette_size > 512) return AVERROR_INVALIDDATA; if (buf_size < c->palette_size + 32) return AVERROR_INVALIDDATA; if (c->bpp < 1) return AVERROR_INVALIDDATA; if (c->format != BIT_PLANAR && c->format != BIT_LINE && c->format != CHUNKY) { avpriv_request_sample(avctx, "Pixel format 0x%0x", c->format); return AVERROR_PATCHWELCOME; } if ((ret = ff_set_dimensions(avctx, w, h)) < 0) return ret; if (c->format == CHUNKY) aligned_width = avctx->width; else aligned_width = FFALIGN(c->avctx->width, 16); c->padded_bits = aligned_width - c->avctx->width; if (c->video_size < aligned_width * avctx->height * c->bpp / 8) return AVERROR_INVALIDDATA; if (!encoding && c->palette_size && c->bpp <= 8) { avctx->pix_fmt = AV_PIX_FMT_PAL8; } else if (encoding == 1 && (c->bpp == 6 || c->bpp == 8)) { if (c->palette_size != (1 << (c->bpp - 1))) return AVERROR_INVALIDDATA; avctx->pix_fmt = AV_PIX_FMT_BGR24; } else if (!encoding && c->bpp == 24 && c->format == CHUNKY && !c->palette_size) { avctx->pix_fmt = AV_PIX_FMT_RGB24; } else { avpriv_request_sample(avctx, "Encoding %d, bpp %d and format 0x%x", encoding, c->bpp, c->format); return AVERROR_PATCHWELCOME; } if ((ret = ff_get_buffer(avctx, p, 0)) < 0) return ret; p->pict_type = AV_PICTURE_TYPE_I; if (encoding) { av_fast_padded_malloc(&c->new_video, &c->new_video_size, h * w + AV_INPUT_BUFFER_PADDING_SIZE); if (!c->new_video) return AVERROR(ENOMEM); if (c->bpp == 8) cdxl_decode_ham8(c, p); else cdxl_decode_ham6(c, p); } else if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { cdxl_decode_rgb(c, p); } else { cdxl_decode_raw(c, p); } *got_frame = 1; return buf_size; }


int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx) { struct vaapi_context * const vactx = avctx->hwaccel_context; MpegEncContext *s = avctx->priv_data; int ret; ret = ff_vaapi_commit_slices(vactx); if (ret < 0) goto finish; ret = ff_vaapi_render_picture(vactx, ff_vaapi_get_surface_id(&s->current_picture_ptr->f)); if (ret < 0) goto finish; ff_mpeg_draw_horiz_band(s, 0, s->avctx->height); finish: ff_vaapi_common_end_frame(avctx); return ret; }


static void switched_to_fair(struct rq *rq, struct task_struct *p,
			     int running)
{
	/*
	 * We were most likely switched from sched_rt, so
	 * kick off the schedule if running, otherwise just see
	 * if we can still preempt the current task.
	 */
	if (running)
		resched_task(rq->curr);
	else
		check_preempt_curr(rq, p);
}


static void pdf_run_q ( fz_context * ctx , pdf_processor * proc ) {
 pdf_run_processor * pr = ( pdf_run_processor * ) proc ;
 pdf_gsave ( ctx , pr ) ;
 }


move_one_task_fair(struct rq *this_rq, int this_cpu, struct rq *busiest,
		   struct sched_domain *sd, enum cpu_idle_type idle)
{
	struct cfs_rq *busy_cfs_rq;
	struct rq_iterator cfs_rq_iterator;

	cfs_rq_iterator.start = load_balance_start_fair;
	cfs_rq_iterator.next = load_balance_next_fair;

	for_each_leaf_cfs_rq(busiest, busy_cfs_rq) {
		/*
		 * pass busy_cfs_rq argument into
		 * load_balance_[start|next]_fair iterators
		 */
		cfs_rq_iterator.arg = busy_cfs_rq;
		if (iter_move_one_task(this_rq, this_cpu, busiest, sd, idle,
				       &cfs_rq_iterator))
		    return 1;
	}

	return 0;
}