static void flush_encoders(void) { int i, ret; for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; AVCodecContext *enc = ost->enc_ctx; OutputFile *of = output_files[ost->file_index]; if (!ost->encoding_needed) continue; // Try to enable encoding with no input frames. // Maybe we should just let encoding fail instead. if (!ost->initialized) { FilterGraph *fg = ost->filter->graph; char error[1024]; av_log(NULL, AV_LOG_WARNING, "Finishing stream %d:%d without any data written to it.\n", ost->file_index, ost->st->index); if (ost->filter && !fg->graph) { int x; for (x = 0; x < fg->nb_inputs; x++) { InputFilter *ifilter = fg->inputs[x]; if (ifilter->format < 0) { AVCodecParameters *par = ifilter->ist->st->codecpar; // We never got any input. Set a fake format, which will // come from libavformat. ifilter->format = par->format; ifilter->sample_rate = par->sample_rate; ifilter->channels = par->channels; ifilter->channel_layout = par->channel_layout; ifilter->width = par->width; ifilter->height = par->height; ifilter->sample_aspect_ratio = par->sample_aspect_ratio; } } if (!ifilter_has_all_input_formats(fg)) continue; ret = configure_filtergraph(fg); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error configuring filter graph\n"); exit_program(1); } finish_output_stream(ost); } ret = init_output_stream(ost, error, sizeof(error)); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n", ost->file_index, ost->index, error); exit_program(1); } } if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1) continue; #if FF_API_LAVF_FMT_RAWPICTURE if (enc->codec_type == AVMEDIA_TYPE_VIDEO && (of->ctx->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == AV_CODEC_ID_RAWVIDEO) continue; #endif if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO) continue; avcodec_send_frame(enc, NULL); for (;;) { const char *desc = NULL; AVPacket pkt; int pkt_size; switch (enc->codec_type) { case AVMEDIA_TYPE_AUDIO: desc = "audio"; break; case AVMEDIA_TYPE_VIDEO: desc = "video"; break; default: av_assert0(0); } av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; update_benchmark(NULL); ret = avcodec_receive_packet(enc, &pkt); update_benchmark("flush_%s %d.%d", desc, ost->file_index, ost->index); if (ret < 0 && ret != AVERROR_EOF) { av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n", desc, av_err2str(ret)); exit_program(1); } if (ost->logfile && enc->stats_out) { fprintf(ost->logfile, "%s", enc->stats_out); } if (ret == AVERROR_EOF) { break; } if (ost->finished & MUXER_FINISHED) { av_packet_unref(&pkt); continue; } av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase); pkt_size = pkt.size; output_packet(of, &pkt, ost); if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) { do_video_stats(ost, pkt_size); } } } }


static void _UTF16LEOpen ( UConverter * cnv , UConverterLoadArgs * pArgs , UErrorCode * pErrorCode ) {
 if ( UCNV_GET_VERSION ( cnv ) <= 1 ) {
 _UTF16LEReset ( cnv , UCNV_RESET_BOTH ) ;
 }
 else {
 * pErrorCode = U_ILLEGAL_ARGUMENT_ERROR ;
 }
 }


static int is_known_bootstrap_register ( guint64 addr , u3v_conv_info_t * u3v_conv_info ) {
 const gchar * address_string = NULL ;
 guint32 offset_address ;
 if ( addr < 0x10000 ) {
 offset_address = ( guint32 ) addr ;
 address_string = try_val_to_str ( offset_address , bootstrap_register_names_abrm ) ;
 }
 if ( u3v_conv_info -> sbrm_addr != 0 && ( addr >= u3v_conv_info -> sbrm_addr ) ) {
 offset_address = ( guint32 ) ( addr - u3v_conv_info -> sbrm_addr ) ;
 address_string = try_val_to_str ( offset_address , bootstrap_register_names_sbrm ) ;
 }
 if ( u3v_conv_info -> sirm_addr != 0 && ( addr >= u3v_conv_info -> sirm_addr ) ) {
 offset_address = ( guint32 ) ( addr - u3v_conv_info -> sirm_addr ) ;
 address_string = try_val_to_str ( offset_address , bootstrap_register_names_sirm ) ;
 }
 if ( u3v_conv_info -> eirm_addr != 0 && ( addr >= u3v_conv_info -> eirm_addr ) ) {
 offset_address = ( guint32 ) ( addr - u3v_conv_info -> eirm_addr ) ;
 address_string = try_val_to_str ( offset_address , bootstrap_register_names_eirm ) ;
 }
 return address_string != NULL ;
 }


sPAPRTCETable *spapr_tce_find_by_liobn(uint32_t liobn) { sPAPRTCETable *tcet; if (liobn & 0xFFFFFFFF00000000ULL) { hcall_dprintf("Request for out-of-bounds LIOBN 0x" TARGET_FMT_lx "\n", liobn); return NULL; } QLIST_FOREACH(tcet, &spapr_tce_tables, list) { if (tcet->liobn == liobn) { return tcet; } } return NULL; }


static gboolean prplcb_xfer_new_send_cb(gpointer data, gint fd, b_input_condition cond)
{
	PurpleXfer *xfer = data;
	struct im_connection *ic = purple_ic_by_pa(xfer->account);
	struct prpl_xfer_data *px = xfer->ui_data;
	PurpleBuddy *buddy;
	const char *who;

	buddy = purple_find_buddy(xfer->account, xfer->who);
	who = buddy ? purple_buddy_get_name(buddy) : xfer->who;

	/* TODO(wilmer): After spreading some more const goodness in BitlBee,
	   remove the evil cast below. */
	px->ft = imcb_file_send_start(ic, (char *) who, xfer->filename, xfer->size);
	px->ft->data = px;

	px->ft->accept = prpl_xfer_accept;
	px->ft->canceled = prpl_xfer_canceled;
	px->ft->free = prpl_xfer_free;
	px->ft->write_request = prpl_xfer_write_request;

	return FALSE;
}


static inline const guint8 * get_stringzpad_value ( wmem_allocator_t * scope , tvbuff_t * tvb , gint start , gint length , gint * ret_length , const guint encoding ) {
 if ( length == - 1 ) {
 length = tvb_ensure_captured_length_remaining ( tvb , start ) ;
 }
 * ret_length = length ;
 return tvb_get_string_enc ( scope , tvb , start , length , encoding ) ;
 }


static void dtap_gcc_set_param ( tvbuff_t * tvb , proto_tree * tree , packet_info * pinfo _U_ , guint32 offset , guint len ) {
 guint32 curr_offset ;
 guint32 consumed ;
 guint curr_len ;
 curr_offset = offset ;
 curr_len = len ;
 proto_tree_add_bits_item ( tree , hf_gsm_a_spare_bits , tvb , curr_offset << 3 , 4 , ENC_NA ) ;
 ELEM_MAND_V ( GSM_A_PDU_TYPE_DTAP , DE_GCC_STATE_ATTR , NULL ) ;
 }


hb_bool_t _hb_graphite2_shape ( hb_shape_plan_t * shape_plan , hb_font_t * font , hb_buffer_t * buffer , const hb_feature_t * features , unsigned int num_features ) {
 hb_face_t * face = font -> face ;
 gr_face * grface = HB_SHAPER_DATA_GET ( face ) -> grface ;
 gr_font * grfont = HB_SHAPER_DATA_GET ( font ) ;
 const char * lang = hb_language_to_string ( hb_buffer_get_language ( buffer ) ) ;
 const char * lang_end = lang ? strchr ( lang , '-' ) : NULL ;
 int lang_len = lang_end ? lang_end - lang : - 1 ;
 gr_feature_val * feats = gr_face_featureval_for_lang ( grface , lang ? hb_tag_from_string ( lang , lang_len ) : 0 ) ;
 for ( unsigned int i = 0 ;
 i < num_features ;
 i ++ ) {
 const gr_feature_ref * fref = gr_face_find_fref ( grface , features [ i ] . tag ) ;
 if ( fref ) gr_fref_set_feature_value ( fref , features [ i ] . value , feats ) ;
 }
 gr_segment * seg = NULL ;
 const gr_slot * is ;
 unsigned int ci = 0 , ic = 0 ;
 float curradvx = 0. , curradvy = 0. ;
 unsigned int scratch_size ;
 hb_buffer_t : : scratch_buffer_t * scratch = buffer -> get_scratch_buffer ( & scratch_size ) ;
 uint32_t * chars = ( uint32_t * ) scratch ;
 for ( unsigned int i = 0 ;
 i < buffer -> len ;
 ++ i ) chars [ i ] = buffer -> info [ i ] . codepoint ;
 hb_tag_t script_tag [ 2 ] ;
 hb_ot_tags_from_script ( hb_buffer_get_script ( buffer ) , & script_tag [ 0 ] , & script_tag [ 1 ] ) ;
 seg = gr_make_seg ( grfont , grface , script_tag [ 1 ] == HB_TAG_NONE ? script_tag [ 0 ] : script_tag [ 1 ] , feats , gr_utf32 , chars , buffer -> len , | ( hb_buffer_get_direction ( buffer ) == HB_DIRECTION_RTL ? 1 : 0 ) ) ;
 if ( unlikely ( ! seg ) ) {
 if ( feats ) gr_featureval_destroy ( feats ) ;
 return false ;
 }
 unsigned int glyph_count = gr_seg_n_slots ( seg ) ;
 if ( unlikely ( ! glyph_count ) ) {
 if ( feats ) gr_featureval_destroy ( feats ) ;
 gr_seg_destroy ( seg ) ;
 buffer -> len = 0 ;
 return true ;
 }
 buffer -> ensure ( glyph_count ) ;
 scratch = buffer -> get_scratch_buffer ( & scratch_size ) ;
 while ( ( DIV_CEIL ( sizeof ( hb_graphite2_cluster_t ) * buffer -> len , sizeof ( * scratch ) ) + DIV_CEIL ( sizeof ( hb_codepoint_t ) * glyph_count , sizeof ( * scratch ) ) ) > scratch_size ) {
 if ( unlikely ( ! buffer -> ensure ( buffer -> allocated * 2 ) ) ) {
 if ( feats ) gr_featureval_destroy ( feats ) ;
 gr_seg_destroy ( seg ) ;
 return false ;
 }
 scratch = buffer -> get_scratch_buffer ( & scratch_size ) ;
 }
 # define ALLOCATE_ARRAY ( Type , name , len ) Type * name = ( Type * ) scratch ;
 {
 unsigned int _consumed = DIV_CEIL ( ( len ) * sizeof ( Type ) , sizeof ( * scratch ) ) ;
 assert ( _consumed <= scratch_size ) ;
 scratch += _consumed ;
 scratch_size -= _consumed ;
 }
 ALLOCATE_ARRAY ( hb_graphite2_cluster_t , clusters , buffer -> len ) ;
 ALLOCATE_ARRAY ( hb_codepoint_t , gids , glyph_count ) ;
 # undef ALLOCATE_ARRAY memset ( clusters , 0 , sizeof ( clusters [ 0 ] ) * buffer -> len ) ;
 hb_codepoint_t * pg = gids ;
 clusters [ 0 ] . cluster = buffer -> info [ 0 ] . cluster ;
 for ( is = gr_seg_first_slot ( seg ) , ic = 0 ;
 is ;
 is = gr_slot_next_in_segment ( is ) , ic ++ ) {
 unsigned int before = gr_slot_before ( is ) ;
 unsigned int after = gr_slot_after ( is ) ;
 * pg = gr_slot_gid ( is ) ;
 pg ++ ;
 while ( clusters [ ci ] . base_char > before && ci ) {
 clusters [ ci - 1 ] . num_chars += clusters [ ci ] . num_chars ;
 clusters [ ci - 1 ] . num_glyphs += clusters [ ci ] . num_glyphs ;
 ci -- ;
 }
 if ( gr_slot_can_insert_before ( is ) && clusters [ ci ] . num_chars && before >= clusters [ ci ] . base_char + clusters [ ci ] . num_chars ) {
 hb_graphite2_cluster_t * c = clusters + ci + 1 ;
 c -> base_char = clusters [ ci ] . base_char + clusters [ ci ] . num_chars ;
 c -> cluster = buffer -> info [ c -> base_char ] . cluster ;
 c -> num_chars = before - c -> base_char ;
 c -> base_glyph = ic ;
 c -> num_glyphs = 0 ;
 ci ++ ;
 }
 clusters [ ci ] . num_glyphs ++ ;
 if ( clusters [ ci ] . base_char + clusters [ ci ] . num_chars < after + 1 ) clusters [ ci ] . num_chars = after + 1 - clusters [ ci ] . base_char ;
 }
 ci ++ ;
 for ( unsigned int i = 0 ;
 i < ci ;
 ++ i ) {
 for ( unsigned int j = 0 ;
 j < clusters [ i ] . num_glyphs ;
 ++ j ) {
 hb_glyph_info_t * info = & buffer -> info [ clusters [ i ] . base_glyph + j ] ;
 info -> codepoint = gids [ clusters [ i ] . base_glyph + j ] ;
 info -> cluster = clusters [ i ] . cluster ;
 }
 }
 buffer -> len = glyph_count ;
 if ( ! HB_DIRECTION_IS_BACKWARD ( buffer -> props . direction ) ) {
 hb_glyph_position_t * pPos ;
 for ( pPos = hb_buffer_get_glyph_positions ( buffer , NULL ) , is = gr_seg_first_slot ( seg ) ;
 is ;
 pPos ++ , is = gr_slot_next_in_segment ( is ) ) {
 pPos -> x_offset = gr_slot_origin_X ( is ) - curradvx ;
 pPos -> y_offset = gr_slot_origin_Y ( is ) - curradvy ;
 pPos -> x_advance = gr_slot_advance_X ( is , grface , grfont ) ;
 pPos -> y_advance = gr_slot_advance_Y ( is , grface , grfont ) ;
 curradvx += pPos -> x_advance ;
 curradvy += pPos -> y_advance ;
 }
 pPos [ - 1 ] . x_advance += gr_seg_advance_X ( seg ) - curradvx ;
 }
 else {
 hb_glyph_position_t * pPos = hb_buffer_get_glyph_positions ( buffer , NULL ) + buffer -> len - 1 ;
 const hb_glyph_info_t * info = buffer -> info + buffer -> len - 1 ;
 const hb_glyph_info_t * tinfo ;
 const gr_slot * tis ;
 int currclus = - 1 ;
 float clusx = 0. , clusy = 0. ;
 for ( is = gr_seg_last_slot ( seg ) ;
 is ;
 pPos -- , info -- , is = gr_slot_prev_in_segment ( is ) ) {
 if ( info -> cluster != currclus ) {
 curradvx += clusx ;
 curradvy += clusy ;
 currclus = info -> cluster ;
 clusx = 0. ;
 clusy = 0. ;
 for ( tis = is , tinfo = info ;
 tis && tinfo -> cluster == currclus ;
 tis = gr_slot_prev_in_segment ( tis ) , tinfo -- ) {
 clusx += gr_slot_advance_X ( tis , grface , grfont ) ;
 clusy += gr_slot_advance_Y ( tis , grface , grfont ) ;
 }
 curradvx += clusx ;
 curradvy += clusy ;
 }
 pPos -> x_advance = gr_slot_advance_X ( is , grface , grfont ) ;
 pPos -> y_advance = gr_slot_advance_Y ( is , grface , grfont ) ;
 curradvx -= pPos -> x_advance ;
 curradvy -= pPos -> y_advance ;
 pPos -> x_offset = gr_slot_origin_X ( is ) - curradvx ;
 pPos -> y_offset = gr_slot_origin_Y ( is ) - curradvy ;
 }
 hb_buffer_reverse_clusters ( buffer ) ;
 }
 if ( feats ) gr_featureval_destroy ( feats ) ;
 gr_seg_destroy ( seg ) ;
 return true ;
 }


static void set_result_format_version ( ulong new_version ) {
 switch ( new_version ) {
 case 1 : break ;
 case 2 : break ;
 default : die ( "Version format %lu has not yet been implemented" , new_version ) ;
 break ;
 }
 opt_result_format_version = new_version ;
 }


static void address_space_update_ioeventfds(AddressSpace *as) { FlatView *view; FlatRange *fr; unsigned ioeventfd_nb = 0; MemoryRegionIoeventfd *ioeventfds = NULL; AddrRange tmp; unsigned i; view = as->current_map; FOR_EACH_FLAT_RANGE(fr, view) { for (i = 0; i < fr->mr->ioeventfd_nb; ++i) { tmp = addrrange_shift(fr->mr->ioeventfds[i].addr, int128_sub(fr->addr.start, int128_make64(fr->offset_in_region))); if (addrrange_intersects(fr->addr, tmp)) { ++ioeventfd_nb; ioeventfds = g_realloc(ioeventfds, ioeventfd_nb * sizeof(*ioeventfds)); ioeventfds[ioeventfd_nb-1] = fr->mr->ioeventfds[i]; ioeventfds[ioeventfd_nb-1].addr = tmp; } } } address_space_add_del_ioeventfds(as, ioeventfds, ioeventfd_nb, as->ioeventfds, as->ioeventfd_nb); g_free(as->ioeventfds); as->ioeventfds = ioeventfds; as->ioeventfd_nb = ioeventfd_nb; }


TSMBuffer TSMBufferCreate ( void ) {
 TSMBuffer bufp ;
 HdrHeapSDKHandle * new_heap = new HdrHeapSDKHandle ;
 new_heap -> m_heap = new_HdrHeap ( ) ;
 bufp = ( TSMBuffer ) new_heap ;
 sdk_assert ( sdk_sanity_check_mbuffer ( bufp ) == TS_SUCCESS ) ;
 return bufp ;
 }


bool BrotliDecompressorImpl::process(Common::BrotliContext& ctx, Buffer::Instance& output_buffer) {
  BrotliDecoderResult result;
  result = BrotliDecoderDecompressStream(state_.get(), &ctx.avail_in_, &ctx.next_in_,
                                         &ctx.avail_out_, &ctx.next_out_, nullptr);
  if (result == BROTLI_DECODER_RESULT_ERROR) {
    // TODO(rojkov): currently the Brotli library doesn't specify possible errors in its API. Add
    // more detailed stats when they are documented.
    stats_.brotli_error_.inc();
    return false;
  }

  ctx.updateOutput(output_buffer);

  return true;
}


static void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift, Error **errp) { long rc; /* Clean up any HPT info from a previous boot */ g_free(spapr->htab); spapr->htab = NULL; spapr->htab_shift = 0; close_htab_fd(spapr); rc = kvmppc_reset_htab(shift); if (rc < 0) { /* kernel-side HPT needed, but couldn't allocate one */ error_setg_errno(errp, errno, "Failed to allocate KVM HPT of order %d (try smaller maxmem?)", shift); /* This is almost certainly fatal, but if the caller really * wants to carry on with shift == 0, it's welcome to try */ } else if (rc > 0) { /* kernel-side HPT allocated */ if (rc != shift) { error_setg(errp, "Requested order %d HPT, but kernel allocated order %ld (try smaller maxmem?)", shift, rc); } spapr->htab_shift = shift; kvmppc_kern_htab = true; } else { /* kernel-side HPT not needed, allocate in userspace instead */ size_t size = 1ULL << shift; int i; spapr->htab = qemu_memalign(size, size); if (!spapr->htab) { error_setg_errno(errp, errno, "Could not allocate HPT of order %d", shift); return; } memset(spapr->htab, 0, size); spapr->htab_shift = shift; kvmppc_kern_htab = false; for (i = 0; i < size / HASH_PTE_SIZE_64; i++) { DIRTY_HPTE(HPTE(spapr->htab, i)); } } }


BrotliContext::BrotliContext(const uint32_t chunk_size)
    : chunk_size_{chunk_size}, chunk_ptr_{std::make_unique<uint8_t[]>(chunk_size)}, next_in_{},
      next_out_{chunk_ptr_.get()}, avail_in_{0}, avail_out_{chunk_size} {}


ALGnew(PyObject *self, PyObject *args, PyObject *kwdict)
{
	unsigned char *key, *IV;
	ALGobject * new=NULL;
	int keylen, IVlen=0, mode=MODE_ECB, segment_size=0;
	PyObject *counter = NULL;
	int counter_shortcut = 0;
#ifdef PCT_ARC2_MODULE
        int effective_keylen = 1024;    /* this is a weird default, but it's compatible with old versions of PyCrypto */
#endif
	/* Set default values */
	if (!PyArg_ParseTupleAndKeywords(args, kwdict, "s#|is#Oi"
#ifdef PCT_ARC2_MODULE
					 "i"
#endif
					 , kwlist,
					 &key, &keylen, &mode, &IV, &IVlen,
					 &counter, &segment_size
#ifdef PCT_ARC2_MODULE
					 , &effective_keylen
#endif
		))
	{
		return NULL;
	}

	if (mode<MODE_ECB || mode>MODE_CTR)
	{
		PyErr_Format(PyExc_ValueError,
			     "Unknown cipher feedback mode %i",
			     mode);
		return NULL;
	}
	if (mode == MODE_PGP) {
		PyErr_Format(PyExc_ValueError,
			     "MODE_PGP is not supported anymore");
		return NULL;
	}
	if (KEY_SIZE!=0 && keylen!=KEY_SIZE)
	{
		PyErr_Format(PyExc_ValueError,
			     "Key must be %i bytes long, not %i",
			     KEY_SIZE, keylen);
		return NULL;
	}
	if (KEY_SIZE==0 && keylen==0)
	{
		PyErr_SetString(PyExc_ValueError,
				"Key cannot be the null string");
		return NULL;
	}
	if (IVlen != BLOCK_SIZE && mode != MODE_ECB && mode != MODE_CTR)
	{
		PyErr_Format(PyExc_ValueError,
			     "IV must be %i bytes long", BLOCK_SIZE);
		return NULL;
	}

	/* Mode-specific checks */
	if (mode == MODE_CFB) {
		if (segment_size == 0) segment_size = 8;
		if (segment_size < 1 || segment_size > BLOCK_SIZE*8 || ((segment_size & 7) != 0)) {
			PyErr_Format(PyExc_ValueError,
				     "segment_size must be multiple of 8 (bits) "
				     "between 1 and %i", BLOCK_SIZE*8);
			return NULL;
		}
	}
	if (mode == MODE_CTR) {
		if (counter == NULL) {
			PyErr_SetString(PyExc_TypeError,
					"'counter' keyword parameter is required with CTR mode");
			return NULL;
		} else if (Py_TYPE(counter) == PCT_CounterBEType || Py_TYPE(counter) == PCT_CounterLEType) {
			counter_shortcut = 1;
		} else if (!PyCallable_Check(counter)) {
			PyErr_SetString(PyExc_ValueError,
					"'counter' parameter must be a callable object");
			return NULL;
		}
	} else {
		if (counter != NULL) {
			PyErr_SetString(PyExc_ValueError,
					"'counter' parameter only useful with CTR mode");
			return NULL;
		}
	}

	/* Cipher-specific checks */
#ifdef PCT_ARC2_MODULE
        if (effective_keylen<0 || effective_keylen>1024) {
		PyErr_Format(PyExc_ValueError,
			     "RC2: effective_keylen must be between 0 and 1024, not %i",
			     effective_keylen);
		return NULL;
        }
#endif

	/* Copy parameters into object */
	new = newALGobject();
	new->segment_size = segment_size;
	new->counter = counter;
	Py_XINCREF(counter);
	new->counter_shortcut = counter_shortcut;
#ifdef PCT_ARC2_MODULE
        new->st.effective_keylen = effective_keylen;
#endif

	block_init(&(new->st), key, keylen);
	if (PyErr_Occurred())
	{
		Py_DECREF(new);
		return NULL;
	}
	memset(new->IV, 0, BLOCK_SIZE);
	memset(new->oldCipher, 0, BLOCK_SIZE);
	memcpy(new->IV, IV, IVlen);
	new->mode = mode;
	new->count=BLOCK_SIZE;   /* stores how many bytes in new->oldCipher have been used */
	return new;
}


static void yuv2yuv1_c(SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW) { int i; for (i=0; i<dstW; i++) { int val= (lumSrc[i]+64)>>7; dest[i]= av_clip_uint8(val); } if (uDest) for (i=0; i<chrDstW; i++) { int u=(chrUSrc[i]+64)>>7; int v=(chrVSrc[i]+64)>>7; uDest[i]= av_clip_uint8(u); vDest[i]= av_clip_uint8(v); } if (CONFIG_SWSCALE_ALPHA && aDest) for (i=0; i<dstW; i++) { int val= (alpSrc[i]+64)>>7; aDest[i]= av_clip_uint8(val); } }


static void process_command(GAState *s, QDict *req) { QObject *rsp = NULL; int ret; g_assert(req); g_debug("processing command"); rsp = qmp_dispatch(QOBJECT(req)); if (rsp) { ret = send_response(s, rsp); if (ret) { g_warning("error sending response: %s", strerror(ret)); } qobject_decref(rsp); } else { g_warning("error getting response"); } }


static void fadst8 ( const tran_low_t * input , tran_low_t * output ) {
 tran_high_t s0 , s1 , s2 , s3 , s4 , s5 , s6 , s7 ;
 tran_high_t x0 = input [ 7 ] ;
 tran_high_t x1 = input [ 0 ] ;
 tran_high_t x2 = input [ 5 ] ;
 tran_high_t x3 = input [ 2 ] ;
 tran_high_t x4 = input [ 3 ] ;
 tran_high_t x5 = input [ 4 ] ;
 tran_high_t x6 = input [ 1 ] ;
 tran_high_t x7 = input [ 6 ] ;
 s0 = cospi_2_64 * x0 + cospi_30_64 * x1 ;
 s1 = cospi_30_64 * x0 - cospi_2_64 * x1 ;
 s2 = cospi_10_64 * x2 + cospi_22_64 * x3 ;
 s3 = cospi_22_64 * x2 - cospi_10_64 * x3 ;
 s4 = cospi_18_64 * x4 + cospi_14_64 * x5 ;
 s5 = cospi_14_64 * x4 - cospi_18_64 * x5 ;
 s6 = cospi_26_64 * x6 + cospi_6_64 * x7 ;
 s7 = cospi_6_64 * x6 - cospi_26_64 * x7 ;
 x0 = fdct_round_shift ( s0 + s4 ) ;
 x1 = fdct_round_shift ( s1 + s5 ) ;
 x2 = fdct_round_shift ( s2 + s6 ) ;
 x3 = fdct_round_shift ( s3 + s7 ) ;
 x4 = fdct_round_shift ( s0 - s4 ) ;
 x5 = fdct_round_shift ( s1 - s5 ) ;
 x6 = fdct_round_shift ( s2 - s6 ) ;
 x7 = fdct_round_shift ( s3 - s7 ) ;
 s0 = x0 ;
 s1 = x1 ;
 s2 = x2 ;
 s3 = x3 ;
 s4 = cospi_8_64 * x4 + cospi_24_64 * x5 ;
 s5 = cospi_24_64 * x4 - cospi_8_64 * x5 ;
 s6 = - cospi_24_64 * x6 + cospi_8_64 * x7 ;
 s7 = cospi_8_64 * x6 + cospi_24_64 * x7 ;
 x0 = s0 + s2 ;
 x1 = s1 + s3 ;
 x2 = s0 - s2 ;
 x3 = s1 - s3 ;
 x4 = fdct_round_shift ( s4 + s6 ) ;
 x5 = fdct_round_shift ( s5 + s7 ) ;
 x6 = fdct_round_shift ( s4 - s6 ) ;
 x7 = fdct_round_shift ( s5 - s7 ) ;
 s2 = cospi_16_64 * ( x2 + x3 ) ;
 s3 = cospi_16_64 * ( x2 - x3 ) ;
 s6 = cospi_16_64 * ( x6 + x7 ) ;
 s7 = cospi_16_64 * ( x6 - x7 ) ;
 x2 = fdct_round_shift ( s2 ) ;
 x3 = fdct_round_shift ( s3 ) ;
 x6 = fdct_round_shift ( s6 ) ;
 x7 = fdct_round_shift ( s7 ) ;
 output [ 0 ] = x0 ;
 output [ 1 ] = - x4 ;
 output [ 2 ] = x6 ;
 output [ 3 ] = - x2 ;
 output [ 4 ] = x3 ;
 output [ 5 ] = - x7 ;
 output [ 6 ] = x5 ;
 output [ 7 ] = - x1 ;
 }


long vnc_client_write_sasl(VncState *vs) { long ret; VNC_DEBUG("Write SASL: Pending output %p size %zd offset %zd " "Encoded: %p size %d offset %d\n", vs->output.buffer, vs->output.capacity, vs->output.offset, vs->sasl.encoded, vs->sasl.encodedLength, vs->sasl.encodedOffset); if (!vs->sasl.encoded) { int err; err = sasl_encode(vs->sasl.conn, (char *)vs->output.buffer, vs->output.offset, (const char **)&vs->sasl.encoded, &vs->sasl.encodedLength); if (err != SASL_OK) return vnc_client_io_error(vs, -1, NULL); vs->sasl.encodedRawLength = vs->output.offset; vs->sasl.encodedOffset = 0; ret = vnc_client_write_buf(vs, vs->sasl.encoded + vs->sasl.encodedOffset, vs->sasl.encodedLength - vs->sasl.encodedOffset); if (!ret) return 0; vs->sasl.encodedOffset += ret; if (vs->sasl.encodedOffset == vs->sasl.encodedLength) { vs->output.offset -= vs->sasl.encodedRawLength; vs->sasl.encoded = NULL; vs->sasl.encodedOffset = vs->sasl.encodedLength = 0; /* Can't merge this block with one above, because * someone might have written more unencrypted * data in vs->output while we were processing * SASL encoded output */ if (vs->output.offset == 0) { if (vs->ioc_tag) { g_source_remove(vs->ioc_tag); vs->ioc_tag = qio_channel_add_watch( vs->ioc, G_IO_IN, vnc_client_io, vs, NULL); return ret;


static int kvm_put_vcpu_events ( X86CPU * cpu , int level ) {
 CPUState * cs = CPU ( cpu ) ;
 CPUX86State * env = & cpu -> env ;
 struct kvm_vcpu_events events = {
 }
 ;
 if ( ! kvm_has_vcpu_events ( ) ) {
 return 0 ;
 }
 events . exception . injected = ( env -> exception_injected >= 0 ) ;
 events . exception . nr = env -> exception_injected ;
 events . exception . has_error_code = env -> has_error_code ;
 events . exception . error_code = env -> error_code ;
 events . exception . pad = 0 ;
 events . interrupt . injected = ( env -> interrupt_injected >= 0 ) ;
 events . interrupt . nr = env -> interrupt_injected ;
 events . interrupt . soft = env -> soft_interrupt ;
 events . nmi . injected = env -> nmi_injected ;
 events . nmi . pending = env -> nmi_pending ;
 events . nmi . masked = ! ! ( env -> hflags2 & HF2_NMI_MASK ) ;
 events . nmi . pad = 0 ;
 events . sipi_vector = env -> sipi_vector ;
 events . flags = 0 ;
 if ( has_msr_smbase ) {
 events . smi . smm = ! ! ( env -> hflags & HF_SMM_MASK ) ;
 events . smi . smm_inside_nmi = ! ! ( env -> hflags2 & HF2_SMM_INSIDE_NMI_MASK ) ;
 if ( kvm_irqchip_in_kernel ( ) ) {
 events . smi . pending = cs -> interrupt_request & CPU_INTERRUPT_SMI ;
 events . smi . latched_init = cs -> interrupt_request & CPU_INTERRUPT_INIT ;
 cs -> interrupt_request &= ~ ( CPU_INTERRUPT_INIT | CPU_INTERRUPT_SMI ) ;
 }
 else {
 events . smi . pending = 0 ;
 events . smi . latched_init = 0 ;
 }
 if ( ! cpu -> kvm_no_smi_migration ) {
 events . flags |= KVM_VCPUEVENT_VALID_SMM ;
 }
 }
 if ( level >= KVM_PUT_RESET_STATE ) {
 events . flags |= KVM_VCPUEVENT_VALID_NMI_PENDING ;
 if ( env -> mp_state == KVM_MP_STATE_SIPI_RECEIVED ) {
 events . flags |= KVM_VCPUEVENT_VALID_SIPI_VECTOR ;
 }
 }
 return kvm_vcpu_ioctl ( CPU ( cpu ) , KVM_SET_VCPU_EVENTS , & events ) ;
 }


static PyObject * getServerPrincipalDetails ( PyObject * self , PyObject * args ) {
 const char * service = NULL ;
 const char * hostname = NULL ;
 char * result ;
 if ( ! PyArg_ParseTuple ( args , "ss" , & service , & hostname ) ) return NULL ;
 result = server_principal_details ( service , hostname ) ;
 if ( result != NULL ) {
 PyObject * pyresult = Py_BuildValue ( "s" , result ) ;
 free ( result ) ;
 return pyresult ;
 }
 else return NULL ;
 }


int LibRaw::unpack(void)
{
  CHECK_ORDER_HIGH(LIBRAW_PROGRESS_LOAD_RAW);
  CHECK_ORDER_LOW(LIBRAW_PROGRESS_IDENTIFY);
  try {

    if(!libraw_internal_data.internal_data.input)
      return LIBRAW_INPUT_CLOSED;

    RUN_CALLBACK(LIBRAW_PROGRESS_LOAD_RAW,0,2);
    if (O.shot_select >= P1.raw_count)
      return LIBRAW_REQUEST_FOR_NONEXISTENT_IMAGE;

    if(!load_raw)
      return LIBRAW_UNSPECIFIED_ERROR;

    // already allocated ?
    if(imgdata.image)
      {
        free(imgdata.image);
        imgdata.image = 0;
      }
    if(imgdata.rawdata.raw_alloc)
      {
        free(imgdata.rawdata.raw_alloc);
        imgdata.rawdata.raw_alloc = 0;
      }
    if (libraw_internal_data.unpacker_data.meta_length)
      {
        libraw_internal_data.internal_data.meta_data =
          (char *) malloc (libraw_internal_data.unpacker_data.meta_length);
        merror (libraw_internal_data.internal_data.meta_data, "LibRaw::unpack()");
      }

    libraw_decoder_info_t decoder_info;
    get_decoder_info(&decoder_info);

    int save_iwidth = S.iwidth, save_iheight = S.iheight, save_shrink = IO.shrink;

    int rwidth = S.raw_width, rheight = S.raw_height;
    if( !IO.fuji_width)
      {
        // adjust non-Fuji allocation
        if(rwidth < S.width + S.left_margin)
          rwidth = S.width + S.left_margin;
        if(rheight < S.height + S.top_margin)
          rheight = S.height + S.top_margin;
      }

    imgdata.rawdata.raw_image = 0;
    imgdata.rawdata.color4_image = 0;
    imgdata.rawdata.color3_image = 0;
	imgdata.rawdata.float_image = 0;
	imgdata.rawdata.float3_image = 0;

#ifdef USE_DNGSDK
	if(imgdata.idata.dng_version && dnghost && valid_for_dngsdk() && load_raw != &LibRaw::pentax_4shot_load_raw)
	{
		int rr = try_dngsdk();
	}
#endif

#ifdef USE_RAWSPEED
	if(!raw_was_read())
	{
		int rawspeed_enabled = 1;

		if(imgdata.idata.dng_version && libraw_internal_data.unpacker_data.tiff_samples == 2)
			rawspeed_enabled = 0;

		if(imgdata.idata.raw_count > 1)
			rawspeed_enabled = 0;

		// Disable rawspeed for double-sized Oly files
		if(!strncasecmp(imgdata.idata.make,"Olympus",7) &&
			( ( imgdata.sizes.raw_width > 6000) || !strncasecmp(imgdata.idata.model,"SH-2",4) || !strncasecmp(imgdata.idata.model,"SH-3",4) || !strncasecmp(imgdata.idata.model,"TG-4",4))
			)
			rawspeed_enabled = 0;

		if(imgdata.idata.dng_version && imgdata.idata.filters==0 && libraw_internal_data.unpacker_data.tiff_bps == 8) // Disable for 8 bit
			rawspeed_enabled = 0;

		if(load_raw == &LibRaw::packed_load_raw && !strncasecmp(imgdata.idata.make,"Nikon",5) && !strncasecmp(imgdata.idata.model,"E",1) )
			rawspeed_enabled = 0;

		// RawSpeed Supported,
		if(O.use_rawspeed  && rawspeed_enabled
			&& !(is_sraw() && (O.raw_processing_options & (LIBRAW_PROCESSING_SRAW_NO_RGB | LIBRAW_PROCESSING_SRAW_NO_INTERPOLATE)))
			&& (decoder_info.decoder_flags & LIBRAW_DECODER_TRYRAWSPEED) && _rawspeed_camerameta)
		{
			int rr = try_rawspeed();
		}
	}
#endif
    if(!raw_was_read()) //RawSpeed failed or not run
      {
        // Not allocated on RawSpeed call, try call LibRaow
		int zero_rawimage = 0;
        if(decoder_info.decoder_flags &  LIBRAW_DECODER_OWNALLOC)
          {
            // x3f foveon decoder and DNG float
            // Do nothing! Decoder will allocate data internally
          }
        else if(imgdata.idata.filters || P1.colors == 1) // Bayer image or single color -> decode to raw_image
          {
            imgdata.rawdata.raw_alloc = malloc(rwidth*(rheight+8)*sizeof(imgdata.rawdata.raw_image[0]));
            imgdata.rawdata.raw_image = (ushort*) imgdata.rawdata.raw_alloc;
            if(!S.raw_pitch)
                S.raw_pitch = S.raw_width*2; // Bayer case, not set before
          }
        else // NO LEGACY FLAG if (decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY)
          {
            // sRAW and old Foveon decoders only, so extra buffer size is just 1/4
            S.iwidth = S.width;
            S.iheight= S.height;
            IO.shrink = 0;
			if(!S.raw_pitch)
				S.raw_pitch = (decoder_info.decoder_flags & LIBRAW_DECODER_LEGACY_WITH_MARGINS) ? S.raw_width*8 : S.width*8;
            // allocate image as temporary buffer, size
            imgdata.rawdata.raw_alloc = 0;
            imgdata.image = (ushort (*)[4]) calloc(unsigned(S.raw_width)*unsigned(S.raw_height),sizeof(*imgdata.image));
			if(!(decoder_info.decoder_flags &  LIBRAW_DECODER_ADOBECOPYPIXEL))
			{
				imgdata.rawdata.raw_image = (ushort*) imgdata.image ;
				zero_rawimage = 1;
			}
          }
        ID.input->seek(libraw_internal_data.unpacker_data.data_offset, SEEK_SET);

        unsigned m_save = C.maximum;
        if(load_raw == &LibRaw::unpacked_load_raw && !strcasecmp(imgdata.idata.make,"Nikon"))
          C.maximum=65535;
        (this->*load_raw)();
		if(zero_rawimage)
			imgdata.rawdata.raw_image = 0;
        if(load_raw == &LibRaw::unpacked_load_raw && !strcasecmp(imgdata.idata.make,"Nikon"))
          C.maximum = m_save;
        if(decoder_info.decoder_flags &  LIBRAW_DECODER_OWNALLOC)
          {
            // x3f foveon decoder only: do nothing

          }
        else if (!(imgdata.idata.filters || P1.colors == 1) ) // legacy decoder, ownalloc handled above
          {
            // successfully decoded legacy image, attach image to raw_alloc
            imgdata.rawdata.raw_alloc = imgdata.image;
		    imgdata.rawdata.color4_image = (ushort (*)[4]) imgdata.rawdata.raw_alloc;
            imgdata.image = 0;
            // Restore saved values. Note: Foveon have masked frame
            // Other 4-color legacy data: no borders
			if(!(libraw_internal_data.unpacker_data.load_flags & 256))
			{
				S.raw_width = S.width;
				S.left_margin = 0;
				S.raw_height = S.height;
				S.top_margin = 0;
			}
          }
      }

    if(imgdata.rawdata.raw_image)
      crop_masked_pixels(); // calculate black levels

    // recover image sizes
    S.iwidth = save_iwidth;
    S.iheight = save_iheight;
    IO.shrink = save_shrink;

    // adjust black to possible maximum
    unsigned int i = C.cblack[3];
    unsigned int c;
    for(c=0;c<3;c++)
      if (i > C.cblack[c]) i = C.cblack[c];
    for (c=0;c<4;c++)
      C.cblack[c] -= i;
    C.black += i;

    // Save color,sizes and internal data into raw_image fields
    memmove(&imgdata.rawdata.color,&imgdata.color,sizeof(imgdata.color));
    memmove(&imgdata.rawdata.sizes,&imgdata.sizes,sizeof(imgdata.sizes));
    memmove(&imgdata.rawdata.iparams,&imgdata.idata,sizeof(imgdata.idata));
    memmove(&imgdata.rawdata.ioparams,&libraw_internal_data.internal_output_params,sizeof(libraw_internal_data.internal_output_params));

    SET_PROC_FLAG(LIBRAW_PROGRESS_LOAD_RAW);
    RUN_CALLBACK(LIBRAW_PROGRESS_LOAD_RAW,1,2);

    return 0;
  }
  catch ( LibRaw_exceptions err) {
    EXCEPTION_HANDLER(err);
  }
  catch (std::exception ee) {
    EXCEPTION_HANDLER(LIBRAW_EXCEPTION_IO_CORRUPT);
  }
}


static int finish_frame(AVCodecContext *avctx, AVFrame *pict) { RV34DecContext *r = avctx->priv_data; MpegEncContext *s = &r->s; int got_picture = 0, ret; ff_er_frame_end(&s->er); ff_mpv_frame_end(s); s->mb_num_left = 0; if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0); if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { if ((ret = av_frame_ref(pict, s->current_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->current_picture_ptr); got_picture = 1; } else if (s->last_picture_ptr != NULL) { if ((ret = av_frame_ref(pict, s->last_picture_ptr->f)) < 0) return ret; ff_print_debug_info(s, s->last_picture_ptr); got_picture = 1; } return got_picture; }


  void Compute(OpKernelContext* context) override {
    const Tensor& input = context->input(0);
    const TensorShape& input_shape = input.shape();

    const Tensor& out_backprop = context->input(2);
    const TensorShape& out_backprop_shape = out_backprop.shape();

    TensorShape filter_shape;
    if (takes_shape_) {
      const Tensor& filter_sizes = context->input(1);
      OP_REQUIRES_OK(context, TensorShapeUtils::MakeShape(
                                  filter_sizes.vec<int32>(), &filter_shape));
    } else {
      filter_shape = context->input(1).shape();
    }

    ConvBackpropDimensions dims;
    OP_REQUIRES_OK(context,
                   ConvBackpropComputeDimensions(
                       "Conv3DBackpropFilterOp", /*num_spatial_dims=*/3,
                       input_shape, filter_shape, out_backprop_shape, stride_,
                       padding_, data_format_, &dims));

    Tensor* filter_backprop;
    OP_REQUIRES_OK(context,
                   context->allocate_output(0, filter_shape, &filter_backprop));

    if (input_shape.num_elements() == 0) {
      filter_backprop->template flat<T>().setZero();
      return;
    }

    int64 top_pad_planes, bottom_pad_planes;
    int64 top_pad_rows, bottom_pad_rows;
    int64 left_pad_cols, right_pad_cols;

    OP_REQUIRES_OK(context, GetWindowedOutputSizeVerbose(
                                dims.spatial_dims[0].input_size,
                                dims.spatial_dims[0].filter_size,
                                dims.spatial_dims[0].stride, padding_,
                                &dims.spatial_dims[0].output_size,
                                &top_pad_planes, &bottom_pad_planes));
    OP_REQUIRES_OK(context, GetWindowedOutputSizeVerbose(
                                dims.spatial_dims[1].input_size,
                                dims.spatial_dims[1].filter_size,
                                dims.spatial_dims[1].stride, padding_,
                                &dims.spatial_dims[1].output_size,
                                &top_pad_rows, &bottom_pad_rows));
    OP_REQUIRES_OK(context, GetWindowedOutputSizeVerbose(
                                dims.spatial_dims[2].input_size,
                                dims.spatial_dims[2].filter_size,
                                dims.spatial_dims[2].stride, padding_,
                                &dims.spatial_dims[2].output_size,
                                &left_pad_cols, &right_pad_cols));

    // TODO(ezhulenev): Extract work size and shard estimation to shared
    // functions in conv_grad_ops, and update 2d convolution backprop.

    // The total dimension size of each kernel.
    const int64 filter_total_size =
        dims.spatial_dims[0].filter_size * dims.spatial_dims[1].filter_size *
        dims.spatial_dims[2].filter_size * dims.in_depth;
    // The output image size is the spatial size of the output.
    const int64 output_image_size = dims.spatial_dims[0].output_size *
                                    dims.spatial_dims[1].output_size *
                                    dims.spatial_dims[2].output_size;

    // Shard 'batch' images (volumes) into 'shard_size' groups of images
    // (volumes) to be fed into the parallel matmul. Calculate 'shard_size' by
    // dividing the L3 cache size ('target_working_set_size') by the matmul size
    // of an individual image ('work_unit_size').

    const auto cache_sizes = Eigen::internal::CacheSizes();
    const ptrdiff_t l3_cache_size = cache_sizes.m_l3;

    // TODO(andydavis)
    // *) Consider reducing 'target_working_set_size' if L3 is shared by
    //    other concurrently running tensorflow ops.
    const size_t target_working_set_size = l3_cache_size / sizeof(T);

    const int64 size_A = output_image_size * filter_total_size;

    const int64 size_B = output_image_size * dims.out_depth;

    const int64 size_C = filter_total_size * dims.out_depth;

    const int64 work_unit_size = size_A + size_B + size_C;

    const size_t shard_size =
        (target_working_set_size + work_unit_size - 1) / work_unit_size;

    // Total number of elements in all the tensors used by this kernel.
    int64 total_tensor_elements = input_shape.num_elements() +
                                  filter_shape.num_elements() +
                                  out_backprop_shape.num_elements();

    // Shape of the temporary workspace buffer.
    TensorShape col_buffer_shape = {static_cast<int64>(shard_size),
                                    static_cast<int64>(output_image_size),
                                    static_cast<int64>(filter_total_size)};
    int64 col_buffer_elements = col_buffer_shape.num_elements();

    // If the temporary allocation overhead is too large, fallback on Eigen
    // implementation which requires much less memory.
    int64 col_buffer_overhead = col_buffer_elements / total_tensor_elements;
    if (col_buffer_overhead > kMaxTempAllocationOverhead) {
      VLOG(2) << "Fallback on Eigen implementation of Conv3DBackpropFilterOp: "
                 "col_buffer_overhead="
              << col_buffer_overhead;

      functor::CuboidConvolutionBackwardFilter<Device, T>()(
          context->eigen_device<Device>(),
          filter_backprop->tensor<T, 5>(),                 // filter_backward
          input.tensor<T, 5>(),                            // input
          out_backprop.tensor<T, 5>(),                     // output_backward
          static_cast<int>(dims.spatial_dims[0].stride),   // stride_planes
          static_cast<int>(dims.spatial_dims[1].stride),   // stride_rows
          static_cast<int>(dims.spatial_dims[2].stride));  // stride_cols

      return;
    }

    Tensor col_buffer;
    OP_REQUIRES_OK(context,
                   context->allocate_temp(DataTypeToEnum<T>::value,
                                          col_buffer_shape, &col_buffer));

    // The input offset corresponding to a single input image.
    const int64 input_offset = dims.spatial_dims[0].input_size *
                               dims.spatial_dims[1].input_size *
                               dims.spatial_dims[2].input_size * dims.in_depth;
    // The output offset corresponding to a single output image.
    const int64 output_offset =
        dims.spatial_dims[0].output_size * dims.spatial_dims[1].output_size *
        dims.spatial_dims[2].output_size * dims.out_depth;

    const T* input_data = input.template flat<T>().data();
    T* col_buffer_data = col_buffer.template flat<T>().data();
    const T* out_backprop_data = out_backprop.template flat<T>().data();
    T* filter_backprop_data = filter_backprop->template flat<T>().data();

    typedef Eigen::TensorMap<Eigen::Tensor<T, 2, Eigen::RowMajor>,
                             Eigen::Unaligned>
        TensorMap;
    typedef Eigen::TensorMap<Eigen::Tensor<const T, 2, Eigen::RowMajor>,
                             Eigen::Unaligned>
        ConstTensorMap;

    TensorMap C(filter_backprop_data, filter_total_size, dims.out_depth);
    C.setZero();

    // Initialize contraction dims (we need to transpose 'A' below).
    Eigen::array<Eigen::IndexPair<Eigen::DenseIndex>, 1> contract_dims;
    contract_dims[0].first = 0;
    contract_dims[0].second = 0;

    auto worker_threads = *(context->device()->tensorflow_cpu_worker_threads());

    for (int image_id = 0; image_id < dims.batch_size; image_id += shard_size) {
      const int shard_limit =
          std::min(static_cast<int>(shard_size),
                   static_cast<int>(dims.batch_size) - image_id);

      auto shard = [&input_data, &col_buffer_data, &dims, &top_pad_planes,
                    &top_pad_rows, &left_pad_cols, &bottom_pad_planes,
                    &bottom_pad_rows, &right_pad_cols, &input_offset,
                    &size_A](int64 start, int64 limit) {
        for (int shard_id = start; shard_id < limit; ++shard_id) {
          const T* input_data_shard = input_data + shard_id * input_offset;
          T* col_data_shard = col_buffer_data + shard_id * size_A;

          // When we compute the gradient with respect to the filters, we need
          // to do im2col to allow gemm-type computation.
          Im2col<T>(input_data_shard, dims.in_depth,
                    // Input spatial dimensions.
                    dims.spatial_dims[0].input_size,  // input planes
                    dims.spatial_dims[1].input_size,  // input rows
                    dims.spatial_dims[2].input_size,  // input cols
                    // Filter spatial dimensions.
                    dims.spatial_dims[0].filter_size,  // filter planes
                    dims.spatial_dims[1].filter_size,  // filter rows
                    dims.spatial_dims[2].filter_size,  // filter cols
                    // Spatial padding.
                    top_pad_planes, top_pad_rows, left_pad_cols,
                    bottom_pad_planes, bottom_pad_rows, right_pad_cols,
                    // Spatial striding.
                    dims.spatial_dims[0].stride,  // stride planes
                    dims.spatial_dims[1].stride,  // stride rows
                    dims.spatial_dims[2].stride,  // stride cols
                    col_data_shard);
        }
      };
      Shard(worker_threads.num_threads, worker_threads.workers, shard_limit,
            size_A, shard);

      ConstTensorMap A(col_buffer_data, output_image_size * shard_limit,
                       filter_total_size);
      ConstTensorMap B(out_backprop_data, output_image_size * shard_limit,
                       dims.out_depth);

      // Gradient with respect to filter.
      C.device(context->eigen_cpu_device()) += A.contract(B, contract_dims);

      input_data += input_offset * shard_limit;
      out_backprop_data += output_offset * shard_limit;
    }
  }


static const SvcInternal * get_const_svc_internal ( const SvcContext * svc_ctx ) {
 if ( svc_ctx == NULL ) return NULL ;
 return ( const SvcInternal * ) svc_ctx -> internal ;
 }


build_header(BIOSLinker *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev, const char *oem_id, const char *oem_table_id) { memcpy(&h->signature, sig, 4); h->length = cpu_to_le32(len); h->revision = rev; if (oem_id) { strncpy((char *)h->oem_id, oem_id, sizeof h->oem_id); } else { memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6); } if (oem_table_id) { strncpy((char *)h->oem_table_id, oem_table_id, sizeof(h->oem_table_id)); } else { memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4); memcpy(h->oem_table_id + 4, sig, 4); } h->oem_revision = cpu_to_le32(1); memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4); h->asl_compiler_revision = cpu_to_le32(1); h->checksum = 0; /* Checksum to be filled in by Guest linker */ bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, h, len, &h->checksum); }


static int usbredir_check_filter(USBRedirDevice *dev) { if (dev->interface_info.interface_count == 0) { ERROR("No interface info for device\n"); goto error; } if (dev->filter_rules) { if (!usbredirparser_peer_has_cap(dev->parser, usb_redir_cap_connect_device_version)) { ERROR("Device filter specified and peer does not have the " "connect_device_version capability\n"); goto error; } if (usbredirfilter_check( dev->filter_rules, dev->filter_rules_count, dev->device_info.device_class, dev->device_info.device_subclass, dev->device_info.device_protocol, dev->interface_info.interface_class, dev->interface_info.interface_subclass, dev->interface_info.interface_protocol, dev->interface_info.interface_count, dev->device_info.vendor_id, dev->device_info.product_id, dev->device_info.device_version_bcd, 0) != 0) { goto error; } } return 0; error: usbredir_device_disconnect(dev); if (usbredirparser_peer_has_cap(dev->parser, usb_redir_cap_filter)) { usbredirparser_send_filter_reject(dev->parser); usbredirparser_do_write(dev->parser); } return -1; }


I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_irq sci_irq, qemu_irq smi_irq, int kvm_enabled, FWCfgState *fw_cfg, DeviceState **piix4_pm) { DeviceState *dev; PIIX4PMState *s; dev = DEVICE(pci_create(bus, devfn, TYPE_PIIX4_PM)); qdev_prop_set_uint32(dev, "smb_io_base", smb_io_base); if (piix4_pm) { *piix4_pm = dev; } s = PIIX4_PM(dev); s->irq = sci_irq; s->smi_irq = smi_irq; s->kvm_enabled = kvm_enabled; if (xen_enabled()) { s->use_acpi_pci_hotplug = false; } qdev_init_nofail(dev); if (fw_cfg) { uint8_t suspend[6] = {128, 0, 0, 129, 128, 128}; suspend[3] = 1 | ((!s->disable_s3) << 7); suspend[4] = s->s4_val | ((!s->disable_s4) << 7); fw_cfg_add_file(fw_cfg, "etc/system-states", g_memdup(suspend, 6), 6); } return s->smb.smbus; }


static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) { AVCodecContext *VideoCodec = s->streams[0]->codec; AVCodecContext *AudioCodec = s->streams[1]->codec; int AudioRate = AudioCodec->sample_rate; int FrameRate = ((VideoCodec->time_base.den) * (0x10000))/ (VideoCodec->time_base.num); int audio_kbitrate= AudioCodec->bit_rate / 1000; int video_kbitrate= FFMIN(VideoCodec->bit_rate / 1000, 800 - audio_kbitrate); put_be32(pb, 0x94 ); /* size */ put_tag(pb, "uuid"); put_tag(pb, "PROF"); put_be32(pb, 0x21d24fce ); /* 96 bit UUID */ put_be32(pb, 0xbb88695c ); put_be32(pb, 0xfac9c740 ); put_be32(pb, 0x0 ); /* ? */ put_be32(pb, 0x3 ); /* 3 sections ? */ put_be32(pb, 0x14 ); /* size */ put_tag(pb, "FPRF"); put_be32(pb, 0x0 ); /* ? */ put_be32(pb, 0x0 ); /* ? */ put_be32(pb, 0x0 ); /* ? */ put_be32(pb, 0x2c ); /* size */ put_tag(pb, "APRF"); /* audio */ put_be32(pb, 0x0 ); put_be32(pb, 0x2 ); /* TrackID */ put_tag(pb, "mp4a"); put_be32(pb, 0x20f ); put_be32(pb, 0x0 ); put_be32(pb, audio_kbitrate); put_be32(pb, audio_kbitrate); put_be32(pb, AudioRate ); put_be32(pb, AudioCodec->channels ); put_be32(pb, 0x34 ); /* size */ put_tag(pb, "VPRF"); /* video */ put_be32(pb, 0x0 ); put_be32(pb, 0x1 ); /* TrackID */ put_tag(pb, "mp4v"); put_be32(pb, 0x103 ); put_be32(pb, 0x0 ); put_be32(pb, video_kbitrate); put_be32(pb, video_kbitrate); put_be32(pb, FrameRate); put_be32(pb, FrameRate); put_be16(pb, VideoCodec->width); put_be16(pb, VideoCodec->height); put_be32(pb, 0x010001); /* ? */ }


static int rtp_packetize_g726_24 ( sout_stream_id_sys_t * id , block_t * in ) {
 return rtp_packetize_g726 ( id , in , 8 ) ;
 }


static void spr_write_403_pbr (void *opaque, int sprn) { DisasContext *ctx = opaque; gen_op_store_403_pb(sprn - SPR_403_PBL1); RET_STOP(ctx); }


static int mpeg4_decode_partition_b ( MpegEncContext * s , int mb_count ) {
 int mb_num = 0 ;
 static const int8_t quant_tab [ 4 ] = {
 - 1 , - 2 , 1 , 2 }
 ;
 s -> mb_x = s -> resync_mb_x ;
 s -> first_slice_line = 1 ;
 for ( s -> mb_y = s -> resync_mb_y ;
 mb_num < mb_count ;
 s -> mb_y ++ ) {
 ff_init_block_index ( s ) ;
 for ( ;
 mb_num < mb_count && s -> mb_x < s -> mb_width ;
 s -> mb_x ++ ) {
 const int xy = s -> mb_x + s -> mb_y * s -> mb_stride ;
 mb_num ++ ;
 ff_update_block_index ( s ) ;
 if ( s -> mb_x == s -> resync_mb_x && s -> mb_y == s -> resync_mb_y + 1 ) s -> first_slice_line = 0 ;
 if ( s -> pict_type == AV_PICTURE_TYPE_I ) {
 int ac_pred = get_bits1 ( & s -> gb ) ;
 int cbpy = get_vlc2 ( & s -> gb , ff_h263_cbpy_vlc . table , CBPY_VLC_BITS , 1 ) ;
 if ( cbpy < 0 ) {
 av_log ( s -> avctx , AV_LOG_ERROR , "cbpy corrupted at %d %d\n" , s -> mb_x , s -> mb_y ) ;
 return - 1 ;
 }
 s -> cbp_table [ xy ] |= cbpy << 2 ;
 s -> current_picture . mb_type [ xy ] |= ac_pred * MB_TYPE_ACPRED ;
 }
 else {
 if ( IS_INTRA ( s -> current_picture . mb_type [ xy ] ) ) {
 int dir = 0 , i ;
 int ac_pred = get_bits1 ( & s -> gb ) ;
 int cbpy = get_vlc2 ( & s -> gb , ff_h263_cbpy_vlc . table , CBPY_VLC_BITS , 1 ) ;
 if ( cbpy < 0 ) {
 av_log ( s -> avctx , AV_LOG_ERROR , "I cbpy corrupted at %d %d\n" , s -> mb_x , s -> mb_y ) ;
 return - 1 ;
 }
 if ( s -> cbp_table [ xy ] & 8 ) {
 ff_set_qscale ( s , s -> qscale + quant_tab [ get_bits ( & s -> gb , 2 ) ] ) ;
 }
 s -> current_picture . qscale_table [ xy ] = s -> qscale ;
 for ( i = 0 ;
 i < 6 ;
 i ++ ) {
 int dc_pred_dir ;
 int dc = mpeg4_decode_dc ( s , i , & dc_pred_dir ) ;
 if ( dc < 0 ) {
 av_log ( s -> avctx , AV_LOG_ERROR , "DC corrupted at %d %d\n" , s -> mb_x , s -> mb_y ) ;
 return - 1 ;
 }
 dir <<= 1 ;
 if ( dc_pred_dir ) dir |= 1 ;
 }
 s -> cbp_table [ xy ] &= 3 ;
 s -> cbp_table [ xy ] |= cbpy << 2 ;
 s -> current_picture . mb_type [ xy ] |= ac_pred * MB_TYPE_ACPRED ;
 s -> pred_dir_table [ xy ] = dir ;
 }
 else if ( IS_SKIP ( s -> current_picture . mb_type [ xy ] ) ) {
 s -> current_picture . qscale_table [ xy ] = s -> qscale ;
 s -> cbp_table [ xy ] = 0 ;
 }
 else {
 int cbpy = get_vlc2 ( & s -> gb , ff_h263_cbpy_vlc . table , CBPY_VLC_BITS , 1 ) ;
 if ( cbpy < 0 ) {
 av_log ( s -> avctx , AV_LOG_ERROR , "P cbpy corrupted at %d %d\n" , s -> mb_x , s -> mb_y ) ;
 return - 1 ;
 }
 if ( s -> cbp_table [ xy ] & 8 ) {
 ff_set_qscale ( s , s -> qscale + quant_tab [ get_bits ( & s -> gb , 2 ) ] ) ;
 }
 s -> current_picture . qscale_table [ xy ] = s -> qscale ;
 s -> cbp_table [ xy ] &= 3 ;
 s -> cbp_table [ xy ] |= ( cbpy ^ 0xf ) << 2 ;
 }
 }
 }
 if ( mb_num >= mb_count ) return 0 ;
 s -> mb_x = 0 ;
 }
 return 0 ;
 }


static void spr_write_ibatl_h (void *opaque, int sprn) { DisasContext *ctx = opaque; gen_op_store_ibatl((sprn - SPR_IBAT4L) / 2); RET_STOP(ctx); }


static int vscsi_queue_cmd(VSCSIState *s, vscsi_req *req) { union srp_iu *srp = &req->iu.srp; SCSIDevice *sdev; int n, id, lun; vscsi_decode_id_lun(be64_to_cpu(srp->cmd.lun), &id, &lun); /* Qemu vs. linux issue with LUNs to be sorted out ... */ sdev = (id < 8 && lun < 16) ? s->bus.devs[id] : NULL; if (!sdev) { dprintf("VSCSI: Command for id %d with no drive\n", id); if (srp->cmd.cdb[0] == INQUIRY) { vscsi_inquiry_no_target(s, req); } else { vscsi_makeup_sense(s, req, ILLEGAL_REQUEST, 0x24, 0x00); vscsi_send_rsp(s, req, CHECK_CONDITION, 0, 0); } return 1; } req->lun = lun; req->sreq = scsi_req_new(sdev, req->qtag, lun, req); n = scsi_req_enqueue(req->sreq, srp->cmd.cdb); dprintf("VSCSI: Queued command tag 0x%x CMD 0x%x ID %d LUN %d ret: %d\n", req->qtag, srp->cmd.cdb[0], id, lun, n); if (n) { /* Transfer direction must be set before preprocessing the * descriptors */ req->writing = (n < 1); /* Preprocess RDMA descriptors */ vscsi_preprocess_desc(req); /* Get transfer direction and initiate transfer */ if (n > 0) { req->data_len = n; } else if (n < 0) { req->data_len = -n; } scsi_req_continue(req->sreq); } /* Don't touch req here, it may have been recycled already */ return 0; }


CreateUserMapping(CreateUserMappingStmt *stmt)
{
	Relation	rel;
	Datum		useoptions;
	Datum		values[Natts_pg_user_mapping];
	bool		nulls[Natts_pg_user_mapping];
	HeapTuple	tuple;
	Oid			useId;
	Oid			umId;
	ObjectAddress myself;
	ObjectAddress referenced;
	ForeignServer *srv;
	ForeignDataWrapper *fdw;
	RoleSpec   *role = (RoleSpec *) stmt->user;

	rel = table_open(UserMappingRelationId, RowExclusiveLock);

	if (role->roletype == ROLESPEC_PUBLIC)
		useId = ACL_ID_PUBLIC;
	else
		useId = get_rolespec_oid(stmt->user, false);

	/* Check that the server exists. */
	srv = GetForeignServerByName(stmt->servername, false);

	user_mapping_ddl_aclcheck(useId, srv->serverid, stmt->servername);

	/*
	 * Check that the user mapping is unique within server.
	 */
	umId = GetSysCacheOid2(USERMAPPINGUSERSERVER, Anum_pg_user_mapping_oid,
						   ObjectIdGetDatum(useId),
						   ObjectIdGetDatum(srv->serverid));

	if (OidIsValid(umId))
	{
		if (stmt->if_not_exists)
		{
			ereport(NOTICE,
					(errcode(ERRCODE_DUPLICATE_OBJECT),
					 errmsg("user mapping for \"%s\" already exists for server \"%s\", skipping",
							MappingUserName(useId),
							stmt->servername)));

			table_close(rel, RowExclusiveLock);
			return InvalidObjectAddress;
		}
		else
			ereport(ERROR,
					(errcode(ERRCODE_DUPLICATE_OBJECT),
					 errmsg("user mapping for \"%s\" already exists for server \"%s\"",
							MappingUserName(useId),
							stmt->servername)));
	}

	fdw = GetForeignDataWrapper(srv->fdwid);

	/*
	 * Insert tuple into pg_user_mapping.
	 */
	memset(values, 0, sizeof(values));
	memset(nulls, false, sizeof(nulls));

	umId = GetNewOidWithIndex(rel, UserMappingOidIndexId,
							  Anum_pg_user_mapping_oid);
	values[Anum_pg_user_mapping_oid - 1] = ObjectIdGetDatum(umId);
	values[Anum_pg_user_mapping_umuser - 1] = ObjectIdGetDatum(useId);
	values[Anum_pg_user_mapping_umserver - 1] = ObjectIdGetDatum(srv->serverid);

	/* Add user options */
	useoptions = transformGenericOptions(UserMappingRelationId,
										 PointerGetDatum(NULL),
										 stmt->options,
										 fdw->fdwvalidator);

	if (PointerIsValid(DatumGetPointer(useoptions)))
		values[Anum_pg_user_mapping_umoptions - 1] = useoptions;
	else
		nulls[Anum_pg_user_mapping_umoptions - 1] = true;

	tuple = heap_form_tuple(rel->rd_att, values, nulls);

	CatalogTupleInsert(rel, tuple);

	heap_freetuple(tuple);

	/* Add dependency on the server */
	myself.classId = UserMappingRelationId;
	myself.objectId = umId;
	myself.objectSubId = 0;

	referenced.classId = ForeignServerRelationId;
	referenced.objectId = srv->serverid;
	referenced.objectSubId = 0;
	recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);

	if (OidIsValid(useId))
	{
		/* Record the mapped user dependency */
		recordDependencyOnOwner(UserMappingRelationId, umId, useId);
	}

	/*
	 * Perhaps someday there should be a recordDependencyOnCurrentExtension
	 * call here; but since roles aren't members of extensions, it seems like
	 * user mappings shouldn't be either.  Note that the grammar and pg_dump
	 * would need to be extended too if we change this.
	 */

	/* Post creation hook for new user mapping */
	InvokeObjectPostCreateHook(UserMappingRelationId, umId, 0);

	table_close(rel, RowExclusiveLock);

	return myself;
}


ImmutableConstantOp::ImmutableConstantOp(OpKernelConstruction* context)
    : OpKernel(context) {
  OP_REQUIRES_OK(context,
                 context->GetAttr(kMemoryRegionNameAttr, &region_name_));
  OP_REQUIRES_OK(context, context->GetAttr(kDTypeAttr, &dtype_));
  OP_REQUIRES_OK(context, context->GetAttr(kShapeAttr, &shape_));
}


  virtual void ComputeWithReservedSpace(OpKernelContext* context,
                                        bool use_reserved_space) {
    Tensor y_backprop = context->input(0);
    Tensor x = context->input(1);
    const Tensor& scale = context->input(2);
    // When is_training=True, batch mean and variance/inverted variance are
    // saved in the forward pass to be reused here. When is_training=False,
    // population mean and variance need to be forwarded here to compute the
    // gradients.
    const Tensor& saved_mean_or_pop_mean = context->input(3);
    // The Eigen implementation saves variance in the forward pass, while cuDNN
    // saves inverted variance.
    const Tensor& saved_maybe_inv_var_or_pop_var = context->input(4);
    bool use_activation = activation_mode_ != FbnActivationMode::kIdentity;
    const Tensor* offset = use_activation ? &context->input(6) : nullptr;
    const Tensor* y = use_activation ? &context->input(7) : nullptr;

    OP_REQUIRES(context, y_backprop.dims() == 4 || y_backprop.dims() == 5,
                errors::InvalidArgument("input must be 4 or 5-dimensional",
                                        y_backprop.shape().DebugString()));
    OP_REQUIRES(context, x.dims() == 4 || x.dims() == 5,
                errors::InvalidArgument("input must be 4 or 5-dimensional",
                                        x.shape().DebugString()));
    OP_REQUIRES(context, scale.dims() == 1,
                errors::InvalidArgument("scale must be 1-dimensional",
                                        scale.shape().DebugString()));
    OP_REQUIRES(
        context, saved_mean_or_pop_mean.dims() == 1,
        errors::InvalidArgument("saved mean must be 1-dimensional",
                                saved_mean_or_pop_mean.shape().DebugString()));
    OP_REQUIRES(context, saved_maybe_inv_var_or_pop_var.dims() == 1,
                errors::InvalidArgument(
                    "saved variance must be 1-dimensional",
                    saved_maybe_inv_var_or_pop_var.shape().DebugString()));
    if (use_activation) {
      OP_REQUIRES(
          context, x.dim_size(3) % 4 == 0,
          errors::InvalidArgument("FusedBatchNormGrad with activation requires "
                                  "channel dimension to be a multiple of 4."));
      OP_REQUIRES(context, offset->dims() == 1,
                  errors::InvalidArgument("offset must be 1-dimensional",
                                          offset->shape().DebugString()));
    }
    bool use_reshape = (x.dims() == 5);
    auto x_shape = x.shape();
    TensorShape dest_shape;
    if (use_reshape) {
      const int64_t in_batch = GetTensorDim(x, tensor_format_, 'N');
      int64_t in_planes = GetTensorDim(x, tensor_format_, '0');
      int64_t in_rows = GetTensorDim(x, tensor_format_, '1');
      int64_t in_cols = GetTensorDim(x, tensor_format_, '2');
      const int64_t in_depth = GetTensorDim(x, tensor_format_, 'C');
      dest_shape = ShapeFromFormat(tensor_format_, in_batch,
                                   {{in_planes, in_rows * in_cols}}, in_depth);
      OP_REQUIRES(context, x.CopyFrom(x, dest_shape),
                  errors::InvalidArgument("Error during tensor copy."));
      OP_REQUIRES(context, y_backprop.CopyFrom(y_backprop, dest_shape),
                  errors::InvalidArgument("Error during tensor copy."));
    }

    Tensor* x_backprop = nullptr;
    auto alloc_shape = use_reshape ? dest_shape : x_shape;
    OP_REQUIRES_OK(context,
                   context->allocate_output(0, alloc_shape, &x_backprop));

    const TensorShape& scale_offset_shape = scale.shape();
    Tensor* scale_backprop = nullptr;
    OP_REQUIRES_OK(context, context->allocate_output(1, scale_offset_shape,
                                                     &scale_backprop));
    Tensor* offset_backprop = nullptr;
    OP_REQUIRES_OK(context, context->allocate_output(2, scale_offset_shape,
                                                     &offset_backprop));
    // Two placeholders for estimated_mean and estimated_variance, which are
    // used for inference and thus not needed here for gradient computation.
    // They are filled with zeros so as to avoid NaN outputs.
    Tensor* placeholder_1 = nullptr;
    OP_REQUIRES_OK(
        context, context->allocate_output(3, TensorShape({0}), &placeholder_1));
    Tensor* placeholder_2 = nullptr;
    OP_REQUIRES_OK(
        context, context->allocate_output(4, TensorShape({0}), &placeholder_2));

    Tensor* side_input_backprop = nullptr;
    if (has_side_input_) {
      OP_REQUIRES_OK(context, context->allocate_output(5, alloc_shape,
                                                       &side_input_backprop));
    }

    // If input is empty, set gradients w.r.t scale/offset to zero.
    if (x.shape().num_elements() == 0) {
      functor::SetZeroFunctor<Device, U> f;
      f(context->eigen_device<Device>(), scale_backprop->flat<U>());
      f(context->eigen_device<Device>(), offset_backprop->flat<U>());
      return;
    }

    if (is_training_) {
      functor::FusedBatchNormGrad<Device, T, U>()(
          context, y_backprop, x, scale, offset, saved_mean_or_pop_mean,
          saved_maybe_inv_var_or_pop_var, y, epsilon_, activation_mode_,
          x_backprop, scale_backprop, offset_backprop, side_input_backprop,
          use_reserved_space, tensor_format_);
    } else {
      OP_REQUIRES(
          context,
          activation_mode_ == FbnActivationMode::kIdentity && !has_side_input_,
          errors::InvalidArgument(
              "FusedBatchNormGrad with activation is only supported "
              "when is_training=True."));
      // Necessary layout conversion is currently done in python.
      OP_REQUIRES(context, tensor_format_ == FORMAT_NHWC,
                  errors::InvalidArgument(
                      "The implementation of "
                      "FusedBatchNormGrad with is_training=False only support "
                      "NHWC tensor format for now."));
      functor::FusedBatchNormFreezeGrad<Device, T, U>()(
          context, y_backprop, x, scale, saved_mean_or_pop_mean,
          saved_maybe_inv_var_or_pop_var, epsilon_, x_backprop, scale_backprop,
          offset_backprop);
    }
    if (use_reshape) {
      OP_REQUIRES(context, x_backprop->CopyFrom(*x_backprop, x_shape),
                  errors::InvalidArgument("Error during tensor copy."));
    }
  }


vcard_emul_mirror_card(VReader *vreader) { /* * lookup certs using the C_FindObjects. The Stan Cert handle won't give * us the real certs until we log in. */ PK11GenericObject *firstObj, *thisObj; int cert_count; unsigned char **certs; int *cert_len; VCardKey **keys; PK11SlotInfo *slot; PRBool ret; slot = vcard_emul_reader_get_slot(vreader); if (slot == NULL) { return NULL; } firstObj = PK11_FindGenericObjects(slot, CKO_CERTIFICATE); if (firstObj == NULL) { return NULL; } /* count the certs */ cert_count = 0; for (thisObj = firstObj; thisObj; thisObj = PK11_GetNextGenericObject(thisObj)) { cert_count++; } if (cert_count == 0) { PK11_DestroyGenericObjects(firstObj); return NULL; } /* allocate the arrays */ ret = vcard_emul_alloc_arrays(&certs, &cert_len, &keys, cert_count); if (ret == PR_FALSE) { return NULL; } /* fill in the arrays */ cert_count = 0; for (thisObj = firstObj; thisObj; thisObj = PK11_GetNextGenericObject(thisObj)) { SECItem derCert; CERTCertificate *cert; SECStatus rv; rv = PK11_ReadRawAttribute(PK11_TypeGeneric, thisObj, CKA_VALUE, &derCert); if (rv != SECSuccess) { continue; } /* create floating temp cert. This gives us a cert structure even if * the token isn't logged in */ cert = CERT_NewTempCertificate(CERT_GetDefaultCertDB(), &derCert, NULL, PR_FALSE, PR_TRUE); SECITEM_FreeItem(&derCert, PR_FALSE); if (cert == NULL) { continue; } certs[cert_count] = cert->derCert.data; cert_len[cert_count] = cert->derCert.len; keys[cert_count] = vcard_emul_make_key(slot, cert); cert_count++; CERT_DestroyCertificate(cert); /* key obj still has a reference */ } /* now create the card */ return vcard_emul_make_card(vreader, certs, cert_len, keys, cert_count); }


static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, unsigned src_size) { const uint16_t *end; #ifdef HAVE_MMX const uint16_t *mm_end; #endif uint8_t *d = (uint8_t *)dst; const uint16_t *s = (const uint16_t *)src; end = s + src_size/2; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s):"memory"); __asm __volatile("pxor %%mm7,%%mm7\n\t":::"memory"); mm_end = end - 3; while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movq %1, %%mm0\n\t" "movq %1, %%mm1\n\t" "movq %1, %%mm2\n\t" "pand %2, %%mm0\n\t" "pand %3, %%mm1\n\t" "pand %4, %%mm2\n\t" "psllq $3, %%mm0\n\t" "psrlq $2, %%mm1\n\t" "psrlq $7, %%mm2\n\t" "movq %%mm0, %%mm3\n\t" "movq %%mm1, %%mm4\n\t" "movq %%mm2, %%mm5\n\t" "punpcklwd %%mm7, %%mm0\n\t" "punpcklwd %%mm7, %%mm1\n\t" "punpcklwd %%mm7, %%mm2\n\t" "punpckhwd %%mm7, %%mm3\n\t" "punpckhwd %%mm7, %%mm4\n\t" "punpckhwd %%mm7, %%mm5\n\t" "psllq $8, %%mm1\n\t" "psllq $16, %%mm2\n\t" "por %%mm1, %%mm0\n\t" "por %%mm2, %%mm0\n\t" "psllq $8, %%mm4\n\t" "psllq $16, %%mm5\n\t" "por %%mm4, %%mm3\n\t" "por %%mm5, %%mm3\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm3, 8%0\n\t" :"=m"(*d) :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r) :"memory"); d += 16; s += 4; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { #if 0 //slightly slower on athlon int bgr= *s++; *((uint32_t*)d)++ = ((bgr&0x1F)<<3) + ((bgr&0x3E0)<<6) + ((bgr&0x7C00)<<9); #else //FIXME this is very likely wrong for bigendian (and the following converters too) register uint16_t bgr; bgr = *s++; #ifdef WORDS_BIGENDIAN *d++ = 0; *d++ = (bgr&0x1F)<<3; *d++ = (bgr&0x3E0)>>2; *d++ = (bgr&0x7C00)>>7; #else *d++ = (bgr&0x1F)<<3; *d++ = (bgr&0x3E0)>>2; *d++ = (bgr&0x7C00)>>7; *d++ = 0; #endif #endif } }


static int xio3130_upstream_initfn(PCIDevice *d) { PCIEPort *p = PCIE_PORT(d); int rc; Error *err = NULL; pci_bridge_initfn(d, TYPE_PCIE_BUS); pcie_port_init_reg(d); rc = msi_init(d, XIO3130_MSI_OFFSET, XIO3130_MSI_NR_VECTOR, XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_64BIT, XIO3130_MSI_SUPPORTED_FLAGS & PCI_MSI_FLAGS_MASKBIT, &err); if (rc < 0) { assert(rc == -ENOTSUP); error_report_err(err); goto err_bridge; } rc = pci_bridge_ssvid_init(d, XIO3130_SSVID_OFFSET, XIO3130_SSVID_SVID, XIO3130_SSVID_SSID); if (rc < 0) { goto err_bridge; } rc = pcie_cap_init(d, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_UPSTREAM, p->port); if (rc < 0) { goto err_msi; } pcie_cap_flr_init(d); pcie_cap_deverr_init(d); rc = pcie_aer_init(d, XIO3130_AER_OFFSET, PCI_ERR_SIZEOF); if (rc < 0) { goto err; } return 0; err: pcie_cap_exit(d); err_msi: msi_uninit(d); err_bridge: pci_bridge_exitfn(d); return rc; }


static GList * get_trash_dirs_for_mount ( GMount * mount ) {
 GFile * root ;
 GFile * trash ;
 char * relpath ;
 GList * list ;
 root = g_mount_get_root ( mount ) ;
 if ( root == NULL ) {
 return NULL ;
 }
 list = NULL ;
 if ( g_file_is_native ( root ) ) {
 relpath = g_strdup_printf ( ".Trash/%d" , getuid ( ) ) ;
 trash = g_file_resolve_relative_path ( root , relpath ) ;
 g_free ( relpath ) ;
 list = g_list_prepend ( list , g_file_get_child ( trash , "files" ) ) ;
 list = g_list_prepend ( list , g_file_get_child ( trash , "info" ) ) ;
 g_object_unref ( trash ) ;
 relpath = g_strdup_printf ( ".Trash-%d" , getuid ( ) ) ;
 trash = g_file_get_child ( root , relpath ) ;
 g_free ( relpath ) ;
 list = g_list_prepend ( list , g_file_get_child ( trash , "files" ) ) ;
 list = g_list_prepend ( list , g_file_get_child ( trash , "info" ) ) ;
 g_object_unref ( trash ) ;
 }
 g_object_unref ( root ) ;
 return list ;
 }


static inline int ir2_get_code ( GetBitContext * gb ) {
 return get_vlc2 ( gb , ir2_vlc . table , CODE_VLC_BITS , 1 ) + 1 ;
 }


int pkey_gost_decrypt(EVP_PKEY_CTX *pctx, unsigned char *key,
                      size_t *key_len, const unsigned char *in, size_t in_len)
{
    struct gost_pmeth_data *gctx = EVP_PKEY_CTX_get_data(pctx);
    switch (gctx->cipher_nid)
    {
        case NID_id_Gost28147_89:
        case NID_undef: /* FIXME */
            return pkey_GOST_ECcp_decrypt(pctx, key, key_len, in, in_len);
        case NID_kuznyechik_ctr:
        case NID_magma_ctr:
            return pkey_gost2018_decrypt(pctx, key, key_len, in, in_len);
        default:
      GOSTerr(GOST_F_PKEY_GOST_DECRYPT, ERR_R_INTERNAL_ERROR);
      return -1;
    }
}


int wpa_decrypt ( u_char * mac , u_char * data , size_t len , struct wpa_sa sa ) {
 if ( sa . algo == WPA_KEY_CCMP ) {
 return wpa_ccmp_decrypt ( mac , data , len , sa ) ;
 }
 else if ( sa . algo == WPA_KEY_TKIP ) {
 return wpa_tkip_decrypt ( mac , data , len , sa ) ;
 }
 return - E_NOTHANDLED ;
 }


void debugCB_fromU ( const void * context , UConverterFromUnicodeArgs * fromUArgs , const UChar * codeUnits , int32_t length , UChar32 codePoint , UConverterCallbackReason reason , UErrorCode * err ) {
 debugCBContext * ctx = ( debugCBContext * ) context ;
 # if DEBUG_TMI printf ( "debugCB_fromU: Context %p:%d called, reason %d on cnv %p [err=%s]\n" , ctx , ctx -> serial , reason , fromUArgs -> converter , u_errorName ( * err ) ) ;
 # endif if ( ctx -> magic != 0xC0FFEE ) {
 fprintf ( stderr , "debugCB_fromU: Context %p:%d magic is 0x%x should be 0xC0FFEE.\n" , ctx , ctx -> serial , ctx -> magic ) ;
 return ;
 }
 if ( reason == UCNV_CLONE ) {
 UConverterFromUCallback saveCallback ;
 const void * saveContext ;
 debugCBContext * cloned ;
 UErrorCode subErr = U_ZERO_ERROR ;
 # if DEBUG_TMI printf ( "debugCB_fromU: cloning..\n" ) ;
 # endif cloned = debugCB_clone ( ctx ) ;
 if ( cloned == NULL ) {
 fprintf ( stderr , "debugCB_fromU: internal clone failed on %p\n" , ctx ) ;
 * err = U_MEMORY_ALLOCATION_ERROR ;
 return ;
 }
 ucnv_setFromUCallBack ( fromUArgs -> converter , cloned -> subCallback , cloned -> subContext , & saveCallback , & saveContext , & subErr ) ;
 if ( cloned -> subCallback != NULL ) {
 # if DEBUG_TMI printf ( "debugCB_fromU:%p calling subCB %p\n" , ctx , cloned -> subCallback ) ;
 # endif cloned -> subCallback ( cloned -> subContext , fromUArgs , codeUnits , length , codePoint , reason , err ) ;
 }
 else {
 printf ( "debugCB_fromU:%p, NOT calling subCB, it's NULL\n" , ctx ) ;
 }
 ucnv_setFromUCallBack ( fromUArgs -> converter , saveCallback , cloned , & cloned -> subCallback , & cloned -> subContext , & subErr ) ;
 if ( U_FAILURE ( subErr ) ) {
 * err = subErr ;
 }
 }
 if ( ctx -> subCallback != NULL && reason != UCNV_CLONE ) {
 ctx -> subCallback ( ctx -> subContext , fromUArgs , codeUnits , length , codePoint , reason , err ) ;
 }
 if ( reason == UCNV_CLOSE ) {
 # if DEBUG_TMI printf ( "debugCB_fromU: Context %p:%d closing\n" , ctx , ctx -> serial ) ;
 # endif free ( ctx ) ;
 }
 # if DEBUG_TMI printf ( "debugCB_fromU: leaving cnv %p, ctx %p: err %s\n" , fromUArgs -> converter , ctx , u_errorName ( * err ) ) ;
 # endif }


static long media_device_enum_entities(struct media_device *mdev,
				       struct media_entity_desc __user *uent)
{
	struct media_entity *ent;
	struct media_entity_desc u_ent;

	if (copy_from_user(&u_ent.id, &uent->id, sizeof(u_ent.id)))
		return -EFAULT;

	ent = find_entity(mdev, u_ent.id);

	if (ent == NULL)
		return -EINVAL;

	u_ent.id = ent->id;
	if (ent->name) {
		strncpy(u_ent.name, ent->name, sizeof(u_ent.name));
		u_ent.name[sizeof(u_ent.name) - 1] = '\0';
	} else {
		memset(u_ent.name, 0, sizeof(u_ent.name));
	}
	u_ent.type = ent->type;
	u_ent.revision = ent->revision;
	u_ent.flags = ent->flags;
	u_ent.group_id = ent->group_id;
	u_ent.pads = ent->num_pads;
	u_ent.links = ent->num_links - ent->num_backlinks;
	memcpy(&u_ent.raw, &ent->info, sizeof(ent->info));
	if (copy_to_user(uent, &u_ent, sizeof(u_ent)))
		return -EFAULT;
	return 0;
}


static int dissect_h245_IS13818AudioLayer ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
 offset = dissect_per_choice ( tvb , offset , actx , tree , hf_index , ett_h245_IS13818AudioLayer , IS13818AudioLayer_choice , NULL ) ;
 return offset ;
 }


TEST_F ( MultiBufferTest , ReadAllAdvanceFirst_NeverDefer2 ) {
 multibuffer_ . SetMaxWriters ( 1 ) ;
 size_t pos = 0 ;
 size_t end = 10000 ;
 multibuffer_ . SetFileSize ( 10000 ) ;
 multibuffer_ . SetMustReadWholeFile ( true ) ;
 multibuffer_ . SetMaxBlocksAfterDefer ( - 10000 ) ;
 media : : MultiBufferReader reader ( & multibuffer_ , pos , end , base : : Callback < void ( int64_t , int64_t ) > ( ) ) ;
 reader . SetMaxBuffer ( 2000 , 5000 ) ;
 reader . SetPreload ( 1000 , 1000 ) ;
 while ( pos < end ) {
 unsigned char buffer [ 27 ] ;
 buffer [ 17 ] = 17 ;
 size_t to_read = std : : min < size_t > ( end - pos , 17 ) ;
 while ( AdvanceAll ( ) ) ;
 int64_t bytes = reader . TryRead ( buffer , to_read ) ;
 EXPECT_GT ( bytes , 0 ) ;
 EXPECT_EQ ( buffer [ 17 ] , 17 ) ;
 for ( int64_t i = 0 ;
 i < bytes ;
 i ++ ) {
 uint8_t expected = static_cast < uint8_t > ( ( pos * 15485863 ) >> 16 ) ;
 EXPECT_EQ ( expected , buffer [ i ] ) << " pos = " << pos ;
 pos ++ ;
 }
 }
 }


iscsi_aio_write16_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { IscsiAIOCB *acb = opaque; trace_iscsi_aio_write16_cb(iscsi, status, acb, acb->canceled); g_free(acb->buf); acb->buf = NULL; if (acb->canceled != 0) { return; } acb->status = 0; if (status < 0) { error_report("Failed to write16 data to iSCSI lun. %s", iscsi_get_error(iscsi)); acb->status = -EIO; } iscsi_schedule_bh(acb); }


void _moddeinit(module_unload_intent_t intent)
{
	service_named_unbind_command("chanserv", &cs_flags);
}


static void virtio_balloon_handle_output ( VirtIODevice * vdev , VirtQueue * vq ) {
 VirtIOBalloon * s = to_virtio_balloon ( vdev ) ;
 VirtQueueElement elem ;
 MemoryRegionSection section ;
 while ( virtqueue_pop ( vq , & elem ) ) {
 size_t offset = 0 ;
 uint32_t pfn ;
 while ( iov_to_buf ( elem . out_sg , elem . out_num , offset , & pfn , 4 ) == 4 ) {
 ram_addr_t pa ;
 ram_addr_t addr ;
 pa = ( ram_addr_t ) ldl_p ( & pfn ) << VIRTIO_BALLOON_PFN_SHIFT ;
 offset += 4 ;
 section = memory_region_find ( get_system_memory ( ) , pa , 1 ) ;
 if ( ! section . size || ! memory_region_is_ram ( section . mr ) ) continue ;
 addr = section . offset_within_region ;
 balloon_page ( memory_region_get_ram_ptr ( section . mr ) + addr , ! ! ( vq == s -> dvq ) ) ;
 }
 virtqueue_push ( vq , & elem , offset ) ;
 virtio_notify ( vdev , vq ) ;
 }
 }


static uint64_t hpdmc_read(void *opaque, target_phys_addr_t addr, unsigned size) { MilkymistHpdmcState *s = opaque; uint32_t r = 0; addr >>= 2; switch (addr) { case R_SYSTEM: case R_BYPASS: case R_TIMING: case R_IODELAY: r = s->regs[addr]; break; default: error_report("milkymist_hpdmc: read access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } trace_milkymist_hpdmc_memory_read(addr << 2, r); return r; }


int fill_schema_column_privileges ( THD * thd , TABLE_LIST * tables , COND * cond ) {
 # ifndef NO_EMBEDDED_ACCESS_CHECKS int error = 0 ;
 uint index ;
 char buff [ 100 ] ;
 TABLE * table = tables -> table ;
 bool no_global_access = check_access ( thd , SELECT_ACL , "mysql" , 0 , 1 , 1 , 0 ) ;
 char * curr_host = thd -> security_ctx -> priv_host_name ( ) ;
 DBUG_ENTER ( "fill_schema_table_privileges" ) ;
 rw_rdlock ( & LOCK_grant ) ;
 for ( index = 0 ;
 index < column_priv_hash . records ;
 index ++ ) {
 const char * user , * host , * is_grantable = "YES" ;
 GRANT_TABLE * grant_table = ( GRANT_TABLE * ) hash_element ( & column_priv_hash , index ) ;
 if ( ! ( user = grant_table -> user ) ) user = "" ;
 if ( ! ( host = grant_table -> host . hostname ) ) host = "" ;
 if ( no_global_access && ( strcmp ( thd -> security_ctx -> priv_user , user ) || my_strcasecmp ( system_charset_info , curr_host , host ) ) ) continue ;
 ulong table_access = grant_table -> cols ;
 if ( table_access != 0 ) {
 if ( ! ( grant_table -> privs & GRANT_ACL ) ) is_grantable = "NO" ;
 ulong test_access = table_access & ~ GRANT_ACL ;
 strxmov ( buff , "'" , user , "'@'" , host , "'" , NullS ) ;
 if ( ! test_access ) continue ;
 else {
 ulong j ;
 int cnt ;
 for ( cnt = 0 , j = SELECT_ACL ;
 j <= TABLE_ACLS ;
 cnt ++ , j <<= 1 ) {
 if ( test_access & j ) {
 for ( uint col_index = 0 ;
 col_index < grant_table -> hash_columns . records ;
 col_index ++ ) {
 GRANT_COLUMN * grant_column = ( GRANT_COLUMN * ) hash_element ( & grant_table -> hash_columns , col_index ) ;
 if ( ( grant_column -> rights & j ) && ( table_access & j ) ) {
 if ( update_schema_privilege ( thd , table , buff , grant_table -> db , grant_table -> tname , grant_column -> column , grant_column -> key_length , command_array [ cnt ] , command_lengths [ cnt ] , is_grantable ) ) {
 error = 1 ;
 goto err ;
 }
 }
 }
 }
 }
 }
 }
 }
 err : rw_unlock ( & LOCK_grant ) ;
 DBUG_RETURN ( error ) ;
 # else return ( 0 ) ;
 # endif }


static struct block_device *add_partition(struct gendisk *disk, int partno,
				sector_t start, sector_t len, int flags,
				struct partition_meta_info *info)
{
	dev_t devt = MKDEV(0, 0);
	struct device *ddev = disk_to_dev(disk);
	struct device *pdev;
	struct block_device *bdev;
	const char *dname;
	int err;

	lockdep_assert_held(&disk->open_mutex);

	if (partno >= disk_max_parts(disk))
		return ERR_PTR(-EINVAL);

	/*
	 * Partitions are not supported on zoned block devices that are used as
	 * such.
	 */
	switch (disk->queue->limits.zoned) {
	case BLK_ZONED_HM:
		pr_warn("%s: partitions not supported on host managed zoned block device\n",
			disk->disk_name);
		return ERR_PTR(-ENXIO);
	case BLK_ZONED_HA:
		pr_info("%s: disabling host aware zoned block device support due to partitions\n",
			disk->disk_name);
		blk_queue_set_zoned(disk, BLK_ZONED_NONE);
		break;
	case BLK_ZONED_NONE:
		break;
	}

	if (xa_load(&disk->part_tbl, partno))
		return ERR_PTR(-EBUSY);

	/* ensure we always have a reference to the whole disk */
	get_device(disk_to_dev(disk));

	err = -ENOMEM;
	bdev = bdev_alloc(disk, partno);
	if (!bdev)
		goto out_put_disk;

	bdev->bd_start_sect = start;
	bdev_set_nr_sectors(bdev, len);

	pdev = &bdev->bd_device;
	dname = dev_name(ddev);
	if (isdigit(dname[strlen(dname) - 1]))
		dev_set_name(pdev, "%sp%d", dname, partno);
	else
		dev_set_name(pdev, "%s%d", dname, partno);

	device_initialize(pdev);
	pdev->class = &block_class;
	pdev->type = &part_type;
	pdev->parent = ddev;

	/* in consecutive minor range? */
	if (bdev->bd_partno < disk->minors) {
		devt = MKDEV(disk->major, disk->first_minor + bdev->bd_partno);
	} else {
		err = blk_alloc_ext_minor();
		if (err < 0)
			goto out_put;
		devt = MKDEV(BLOCK_EXT_MAJOR, err);
	}
	pdev->devt = devt;

	if (info) {
		err = -ENOMEM;
		bdev->bd_meta_info = kmemdup(info, sizeof(*info), GFP_KERNEL);
		if (!bdev->bd_meta_info)
			goto out_put;
	}

	/* delay uevent until 'holders' subdir is created */
	dev_set_uevent_suppress(pdev, 1);
	err = device_add(pdev);
	if (err)
		goto out_put;

	err = -ENOMEM;
	bdev->bd_holder_dir = kobject_create_and_add("holders", &pdev->kobj);
	if (!bdev->bd_holder_dir)
		goto out_del;

	dev_set_uevent_suppress(pdev, 0);
	if (flags & ADDPART_FLAG_WHOLEDISK) {
		err = device_create_file(pdev, &dev_attr_whole_disk);
		if (err)
			goto out_del;
	}

	/* everything is up and running, commence */
	err = xa_insert(&disk->part_tbl, partno, bdev, GFP_KERNEL);
	if (err)
		goto out_del;
	bdev_add(bdev, devt);

	/* suppress uevent if the disk suppresses it */
	if (!dev_get_uevent_suppress(ddev))
		kobject_uevent(&pdev->kobj, KOBJ_ADD);
	return bdev;

out_del:
	kobject_put(bdev->bd_holder_dir);
	device_del(pdev);
out_put:
	put_device(pdev);
out_put_disk:
	put_disk(disk);
	return ERR_PTR(err);
}


  void Compute(tensorflow::OpKernelContext* context) override {
    const tensorflow::Tensor* data;
    OP_REQUIRES_OK(context, context->input("data", &data));
    const auto& input_data = data->flat<tstring>().data();

    const tensorflow::Tensor* splits;
    OP_REQUIRES_OK(context, context->input("data_splits", &splits));
    const auto& splits_vec = splits->flat<SPLITS_TYPE>();

    int num_batch_items = splits_vec.size() - 1;
    tensorflow::Tensor* ngrams_splits;
    OP_REQUIRES_OK(
        context, context->allocate_output(1, splits->shape(), &ngrams_splits));
    auto ngrams_splits_data = ngrams_splits->flat<SPLITS_TYPE>().data();

    // If there is no data or size, return an empty RT.
    if (data->flat<tstring>().size() == 0 || splits_vec.size() == 0) {
      tensorflow::Tensor* empty;
      OP_REQUIRES_OK(context,
                     context->allocate_output(0, data->shape(), &empty));
      for (int i = 0; i <= num_batch_items; ++i) {
        ngrams_splits_data[i] = 0;
      }
      return;
    }

    ngrams_splits_data[0] = 0;
    for (int i = 1; i <= num_batch_items; ++i) {
      int length = splits_vec(i) - splits_vec(i - 1);
      int num_ngrams = 0;
      for (int ngram_width : ngram_widths_)
        num_ngrams += get_num_ngrams(length, ngram_width);
      if (preserve_short_ && length > 0 && num_ngrams == 0) {
        num_ngrams = 1;
      }
      ngrams_splits_data[i] = ngrams_splits_data[i - 1] + num_ngrams;
    }

    tensorflow::Tensor* ngrams;
    OP_REQUIRES_OK(
        context,
        context->allocate_output(
            0, TensorShape({ngrams_splits_data[num_batch_items]}), &ngrams));
    auto ngrams_data = ngrams->flat<tstring>().data();

    for (int i = 0; i < num_batch_items; ++i) {
      auto data_start = &input_data[splits_vec(i)];
      int output_start_idx = ngrams_splits_data[i];
      for (int ngram_width : ngram_widths_) {
        auto output_start = &ngrams_data[output_start_idx];
        int length = splits_vec(i + 1) - splits_vec(i);
        int num_ngrams = get_num_ngrams(length, ngram_width);
        CreateNgrams(data_start, output_start, num_ngrams, ngram_width);
        output_start_idx += num_ngrams;
      }
      // If we're preserving short sequences, check to see if no sequence was
      // generated by comparing the current output start idx to the original
      // one (ngram_splits_data). If no ngrams were generated, then they will
      // be equal (since we increment output_start_idx by num_ngrams every
      // time we create a set of ngrams.)
      if (preserve_short_ && output_start_idx == ngrams_splits_data[i]) {
        int data_length = splits_vec(i + 1) - splits_vec(i);
        // One legitimate reason to not have any ngrams when preserve_short_
        // is true is if the sequence itself is empty. In that case, move on.
        if (data_length == 0) {
          continue;
        }
        // We don't have to worry about dynamic padding sizes here: if padding
        // was dynamic, every sequence would have had sufficient padding to
        // generate at least one ngram.
        int ngram_width = data_length + 2 * pad_width_;
        auto output_start = &ngrams_data[output_start_idx];
        int num_ngrams = 1;
        CreateNgrams(data_start, output_start, num_ngrams, ngram_width);
      }
    }
  }


static unsigned int _warc_rdtyp ( const char * buf , size_t bsz ) {
 static const char _key [ ] = "\r\nWARC-Type:" ;
 const char * val , * eol ;
 if ( ( val = xmemmem ( buf , bsz , _key , sizeof ( _key ) - 1U ) ) == NULL ) {
 return WT_NONE ;
 }
 val += sizeof ( _key ) - 1U ;
 if ( ( eol = _warc_find_eol ( val , buf + bsz - val ) ) == NULL ) {
 return WT_NONE ;
 }
 while ( val < eol && ( * val == ' ' || * val == '\t' ) ) ++ val ;
 if ( val + 8U == eol ) {
 if ( memcmp ( val , "resource" , 8U ) == 0 ) return WT_RSRC ;
 else if ( memcmp ( val , "response" , 8U ) == 0 ) return WT_RSP ;
 }
 return WT_NONE ;
 }


afs_int32 listMax ( struct rx_call * call , afs_int32 * uid , afs_int32 * gid ) {
 afs_int32 code ;
 struct ubik_trans * tt ;
 code = Initdb ( ) ;
 if ( code != PRSUCCESS ) return code ;
 code = ubik_BeginTransReadAny ( dbase , UBIK_READTRANS , & tt ) ;
 if ( code ) return code ;
 code = ubik_SetLock ( tt , 1 , 1 , LOCKREAD ) ;
 if ( code ) ABORT_WITH ( tt , code ) ;
 code = read_DbHeader ( tt ) ;
 if ( code ) ABORT_WITH ( tt , code ) ;
 code = GetMax ( tt , uid , gid ) ;
 if ( code != PRSUCCESS ) ABORT_WITH ( tt , code ) ;
 code = ubik_EndTrans ( tt ) ;
 if ( code ) return code ;
 return PRSUCCESS ;
 }


static void hugetlbfs_put_super(struct super_block *sb)
{
	struct hugetlbfs_sb_info *sbi = HUGETLBFS_SB(sb);

	if (sbi) {
		sb->s_fs_info = NULL;
		kfree(sbi);
	}
}


static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset, int mquant) { GetBitContext *gb = &v->s.gb; MpegEncContext *s = &v->s; int dc_pred_dir = 0; /* Direction of the DC prediction used */ int run_diff, i; int16_t *dc_val; int16_t *ac_val, *ac_val2; int dcdiff; int a_avail = v->a_avail, c_avail = v->c_avail; int use_pred = s->ac_pred; int scale; int q1, q2 = 0; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; /* Get DC differential */ if (n < 4) { dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); } else { dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); } if (dcdiff < 0){ av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n"); return -1; } if (dcdiff) { if (dcdiff == 119 /* ESC index value */) { /* TODO: Optimize */ if (mquant == 1) dcdiff = get_bits(gb, 10); else if (mquant == 2) dcdiff = get_bits(gb, 9); else dcdiff = get_bits(gb, 8); } else { if (mquant == 1) dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; else if (mquant == 2) dcdiff = (dcdiff<<1) + get_bits(gb, 1) - 1; } if (get_bits(gb, 1)) dcdiff = -dcdiff; } /* Prediction */ dcdiff += vc1_pred_dc(&v->s, v->overlap, mquant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir); *dc_val = dcdiff; /* Store the quantized DC coeff, used for prediction */ if (n < 4) { block[0] = dcdiff * s->y_dc_scale; } else { block[0] = dcdiff * s->c_dc_scale; } /* Skip ? */ run_diff = 0; i = 0; //AC Decoding i = 1; /* check if AC is needed at all and adjust direction if needed */ if(!a_avail) dc_pred_dir = 1; if(!c_avail) dc_pred_dir = 0; if(!a_avail && !c_avail) use_pred = 0; ac_val = s->ac_val[0][0] + s->block_index[n] * 16; ac_val2 = ac_val; scale = mquant * 2 + v->halfpq; if(dc_pred_dir) //left ac_val -= 16; else //top ac_val -= 16 * s->block_wrap[n]; q1 = s->current_picture.qscale_table[mb_pos]; if(dc_pred_dir && c_avail) q2 = s->current_picture.qscale_table[mb_pos - 1]; if(!dc_pred_dir && a_avail) q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride]; if(n && n<4) q2 = q1; if(coded) { int last = 0, skip, value; const int8_t *zz_table; int k; if(v->s.ac_pred) { if(!dc_pred_dir) zz_table = vc1_horizontal_zz; else zz_table = vc1_vertical_zz; } else zz_table = vc1_normal_zz; while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); i += skip; if(i > 63) break; block[zz_table[i++]] = value; } /* apply AC prediction if needed */ if(use_pred) { /* scale predictors if needed*/ if(q2 && q1!=q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; if(dc_pred_dir) { //left for(k = 1; k < 8; k++) block[k << 3] += (ac_val[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18; } else { //top for(k = 1; k < 8; k++) block[k] += (ac_val[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } else { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) block[k << 3] += ac_val[k]; } else { //top for(k = 1; k < 8; k++) block[k] += ac_val[k + 8]; } } } /* save AC coeffs for further prediction */ for(k = 1; k < 8; k++) { ac_val2[k] = block[k << 3]; ac_val2[k + 8] = block[k]; } /* scale AC coeffs */ for(k = 1; k < 64; k++) if(block[k]) { block[k] *= scale; if(!v->pquantizer) block[k] += (block[k] < 0) ? -mquant : mquant; } if(use_pred) i = 63; } else { // no AC coeffs int k; memset(ac_val2, 0, 16 * 2); if(dc_pred_dir) {//left if(use_pred) { memcpy(ac_val2, ac_val, 8 * 2); if(q2 && q1!=q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; for(k = 1; k < 8; k++) ac_val2[k] = (ac_val2[k] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } } else {//top if(use_pred) { memcpy(ac_val2 + 8, ac_val + 8, 8 * 2); if(q2 && q1!=q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; for(k = 1; k < 8; k++) ac_val2[k + 8] = (ac_val2[k + 8] * q2 * vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } } /* apply AC prediction if needed */ if(use_pred) { if(dc_pred_dir) { //left for(k = 1; k < 8; k++) { block[k << 3] = ac_val2[k] * scale; if(!v->pquantizer && block[k << 3]) block[k << 3] += (block[k << 3] < 0) ? -mquant : mquant; } } else { //top for(k = 1; k < 8; k++) { block[k] = ac_val2[k + 8] * scale; if(!v->pquantizer && block[k]) block[k] += (block[k] < 0) ? -mquant : mquant; } } i = 63; } } s->block_last_index[n] = i; return 0; }


int qcow2_alloc_clusters_at(BlockDriverState *bs, uint64_t offset, int nb_clusters) { BDRVQcowState *s = bs->opaque; uint64_t cluster_index; uint64_t old_free_cluster_index; int i, refcount, ret; /* Check how many clusters there are free */ cluster_index = offset >> s->cluster_bits; for(i = 0; i < nb_clusters; i++) { refcount = get_refcount(bs, cluster_index++); if (refcount < 0) { return refcount; } else if (refcount != 0) { break; } } /* And then allocate them */ ret = update_refcount(bs, offset, i << s->cluster_bits, 1); if (ret < 0) { return ret; } return i; }


static void ps2_common_post_load ( PS2State * s ) {
 PS2Queue * q = & s -> queue ;
 uint8_t i , size ;
 uint8_t tmp_data [ PS2_QUEUE_SIZE ] ;
 size = ( q -> count < 0 || q -> count > PS2_QUEUE_SIZE ) ? 0 : q -> count ;
 for ( i = 0 ;
 i < size ;
 i ++ ) {
 if ( q -> rptr < 0 || q -> rptr >= sizeof ( q -> data ) ) {
 q -> rptr = 0 ;
 }
 tmp_data [ i ] = q -> data [ q -> rptr ++ ] ;
 }
 memcpy ( q -> data , tmp_data , size ) ;
 q -> rptr = 0 ;
 q -> wptr = size ;
 q -> count = size ;
 s -> update_irq ( s -> update_arg , q -> count != 0 ) ;
 }


static vpx_codec_err_t ctrl_set_scale_mode ( vpx_codec_alg_priv_t * ctx , va_list args ) {
 vpx_scaling_mode_t * const mode = va_arg ( args , vpx_scaling_mode_t * ) ;
 if ( mode ) {
 const int res = vp9_set_internal_size ( ctx -> cpi , ( VPX_SCALING ) mode -> h_scaling_mode , ( VPX_SCALING ) mode -> v_scaling_mode ) ;
 return ( res == 0 ) ? VPX_CODEC_OK : VPX_CODEC_INVALID_PARAM ;
 }
 else {
 return VPX_CODEC_INVALID_PARAM ;
 }
 }


static void ulti_convert_yuv ( AVFrame * frame , int x , int y , uint8_t * luma , int chroma ) {
 uint8_t * y_plane , * cr_plane , * cb_plane ;
 int i ;
 y_plane = frame -> data [ 0 ] + x + y * frame -> linesize [ 0 ] ;
 cr_plane = frame -> data [ 1 ] + ( x / 4 ) + ( y / 4 ) * frame -> linesize [ 1 ] ;
 cb_plane = frame -> data [ 2 ] + ( x / 4 ) + ( y / 4 ) * frame -> linesize [ 2 ] ;
 cr_plane [ 0 ] = ulti_chromas [ chroma >> 4 ] ;
 cb_plane [ 0 ] = ulti_chromas [ chroma & 0xF ] ;
 for ( i = 0 ;
 i < 16 ;
 i ++ ) {
 y_plane [ i & 3 ] = ulti_lumas [ luma [ i ] ] ;
 if ( ( i & 3 ) == 3 ) {
 / ext row y_plane += frame -> linesize [ 0 ] ;
 }
 }
 }


agoo_con_create(agooErr err, int sock, uint64_t id, agooBind b) {
    agooCon	c;

    if (NULL == (c = (agooCon)AGOO_CALLOC(1, sizeof(struct _agooCon)))) {
	AGOO_ERR_MEM(err, "Connection");
    } else {
	c->sock = sock;
	c->id = id;
	c->timeout = dtime() + CON_TIMEOUT;
	c->bind = b;
	c->loop = NULL;
	pthread_mutex_init(&c->res_lock, 0);
    }
    return c;
}


Oid get_op_rettype ( Oid opno ) {
 HeapTuple tp ;
 tp = SearchSysCache1 ( OPEROID , ObjectIdGetDatum ( opno ) ) ;
 if ( HeapTupleIsValid ( tp ) ) {
 Form_pg_operator optup = ( Form_pg_operator ) GETSTRUCT ( tp ) ;
 Oid result ;
 result = optup -> oprresult ;
 ReleaseSysCache ( tp ) ;
 return result ;
 }
 else return InvalidOid ;
 }


agoo_http_init() {
    const char	**kp = header_keys;

    memset(&key_cache, 0, sizeof(struct _cache));
    for (; NULL != *kp; kp++) {
	key_set(*kp);
    }
}


int m_authenticate(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
{
  struct Client* acptr;
  int first = 0;
  char realhost[HOSTLEN + 3];
  char *hoststr = (cli_sockhost(cptr) ? cli_sockhost(cptr) : cli_sock_ip(cptr));

  if (!CapActive(cptr, CAP_SASL))
    return 0;

  if (parc < 2) /* have enough parameters? */
    return need_more_params(cptr, "AUTHENTICATE");

  if (strlen(parv[1]) > 400)
    return send_reply(cptr, ERR_SASLTOOLONG);

  if (IsSASLComplete(cptr))
    return send_reply(cptr, ERR_SASLALREADY);

  /* Look up the target server */
  if (!(acptr = cli_saslagent(cptr))) {
    if (strcmp(feature_str(FEAT_SASL_SERVER), "*"))
      acptr = find_match_server((char *)feature_str(FEAT_SASL_SERVER));
    else
      acptr = NULL;
  }

  if (!acptr && strcmp(feature_str(FEAT_SASL_SERVER), "*"))
    return send_reply(cptr, ERR_SASLFAIL, ": service unavailable");

  /* If it's to us, do nothing; otherwise, forward the query */
  if (acptr && IsMe(acptr))
    return 0;

  /* Generate an SASL session cookie if not already generated */
  if (!cli_saslcookie(cptr)) {
    do {
      cli_saslcookie(cptr) = ircrandom() & 0x7fffffff;
    } while (!cli_saslcookie(cptr));
    first = 1;
  }

  if (strchr(hoststr, ':') != NULL)
    ircd_snprintf(0, realhost, sizeof(realhost), "[%s]", hoststr);
  else
    ircd_strncpy(realhost, hoststr, sizeof(realhost));

  if (acptr) {
    if (first) {
      if (!EmptyString(cli_sslclifp(cptr)))
        sendcmdto_one(&me, CMD_SASL, acptr, "%C %C!%u.%u S %s :%s", acptr, &me,
                      cli_fd(cptr), cli_saslcookie(cptr),
                      parv[1], cli_sslclifp(cptr));
      else
        sendcmdto_one(&me, CMD_SASL, acptr, "%C %C!%u.%u S :%s", acptr, &me,
                      cli_fd(cptr), cli_saslcookie(cptr), parv[1]);
      if (feature_bool(FEAT_SASL_SENDHOST))
        sendcmdto_one(&me, CMD_SASL, acptr, "%C %C!%u.%u H :%s@%s:%s", acptr, &me,
                      cli_fd(cptr), cli_saslcookie(cptr), cli_username(cptr),
                      realhost, cli_sock_ip(cptr));
    } else {
      sendcmdto_one(&me, CMD_SASL, acptr, "%C %C!%u.%u C :%s", acptr, &me,
                    cli_fd(cptr), cli_saslcookie(cptr), parv[1]);
    }
  } else {
    if (first) {
      if (!EmptyString(cli_sslclifp(cptr)))
        sendcmdto_serv_butone(&me, CMD_SASL, cptr, "* %C!%u.%u S %s :%s", &me,
                              cli_fd(cptr), cli_saslcookie(cptr),
                              parv[1], cli_sslclifp(cptr));
      else
        sendcmdto_serv_butone(&me, CMD_SASL, cptr, "* %C!%u.%u S :%s", &me,
                              cli_fd(cptr), cli_saslcookie(cptr), parv[1]);
      if (feature_bool(FEAT_SASL_SENDHOST))
        sendcmdto_serv_butone(&me, CMD_SASL, cptr, "* %C!%u.%u H :%s@%s:%s", &me,
                              cli_fd(cptr), cli_saslcookie(cptr), cli_username(cptr),
                              realhost, cli_sock_ip(cptr));
    } else {
      sendcmdto_serv_butone(&me, CMD_SASL, cptr, "* %C!%u.%u C :%s", &me,
                            cli_fd(cptr), cli_saslcookie(cptr), parv[1]);
    }
  }

  if (!t_active(&cli_sasltimeout(cptr)))
    timer_add(timer_init(&cli_sasltimeout(cptr)), sasl_timeout_callback, (void*) cptr,
              TT_RELATIVE, feature_int(FEAT_SASL_TIMEOUT));

  return 0;
}


static guint reginfo ( int * hf_ptr , const char * name , const char * abbr , const char * desc , enum ftenum ft , field_display_e base , value_string_ext * vs_ext , guint32 mask ) {
 hf_register_info hf ;
 hf . p_id = hf_ptr ;
 hf . hfinfo . name = name ;
 hf . hfinfo . abbrev = abbr ;
 hf . hfinfo . type = ft ;
 hf . hfinfo . display = base ;
 hf . hfinfo . strings = NULL ;
 hf . hfinfo . bitmask = mask ;
 hf . hfinfo . blurb = desc ;
 HFILL_INIT ( hf ) ;
 if ( vs_ext ) {
 hf . hfinfo . strings = vs_ext ;
 }
 wmem_array_append_one ( build_dict . hf , hf ) ;
 return wmem_array_get_count ( build_dict . hf ) ;
 }


static void setup_loopfilter ( struct loopfilter * lf , struct vp9_read_bit_buffer * rb ) {
 lf -> filter_level = vp9_rb_read_literal ( rb , 6 ) ;
 lf -> sharpness_level = vp9_rb_read_literal ( rb , 3 ) ;
 lf -> mode_ref_delta_update = 0 ;
 lf -> mode_ref_delta_enabled = vp9_rb_read_bit ( rb ) ;
 if ( lf -> mode_ref_delta_enabled ) {
 lf -> mode_ref_delta_update = vp9_rb_read_bit ( rb ) ;
 if ( lf -> mode_ref_delta_update ) {
 int i ;
 for ( i = 0 ;
 i < MAX_REF_LF_DELTAS ;
 i ++ ) if ( vp9_rb_read_bit ( rb ) ) lf -> ref_deltas [ i ] = vp9_rb_read_signed_literal ( rb , 6 ) ;
 for ( i = 0 ;
 i < MAX_MODE_LF_DELTAS ;
 i ++ ) if ( vp9_rb_read_bit ( rb ) ) lf -> mode_deltas [ i ] = vp9_rb_read_signed_literal ( rb , 6 ) ;
 }
 }
 }


static void test_simplewrite ( void ) {
 struct event ev ;
 setup_test ( "Simple write: " ) ;
 event_set ( & ev , pair [ 0 ] , EV_WRITE , simple_write_cb , & ev ) ;
 if ( event_add ( & ev , NULL ) == - 1 ) exit ( 1 ) ;
 event_dispatch ( ) ;
 cleanup_test ( ) ;
 }


void css_generate_sch_crws(uint8_t cssid, uint8_t ssid, uint16_t schid, int hotplugged, int add) { uint8_t guest_cssid; bool chain_crw; if (add && !hotplugged) { return; } if (channel_subsys.max_cssid == 0) { /* Default cssid shows up as 0. */ guest_cssid = (cssid == channel_subsys.default_cssid) ? 0 : cssid; } else { /* Show real cssid to the guest. */ guest_cssid = cssid; } /* * Only notify for higher subchannel sets/channel subsystems if the * guest has enabled it. */ if ((ssid > channel_subsys.max_ssid) || (guest_cssid > channel_subsys.max_cssid) || ((channel_subsys.max_cssid == 0) && (cssid != channel_subsys.default_cssid))) { return; } chain_crw = (channel_subsys.max_ssid > 0) || (channel_subsys.max_cssid > 0); css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, chain_crw ? 1 : 0, schid); if (chain_crw) { css_queue_crw(CRW_RSC_SUBCH, CRW_ERC_IPI, 0, (guest_cssid << 8) | (ssid << 4)); } /* RW_ERC_IPI --> clear pending interrupts */ css_clear_io_interrupt(css_do_build_subchannel_id(cssid, ssid), schid); }


static void show_string ( fz_context * ctx , pdf_run_processor * pr , unsigned char * buf , int len ) {
 pdf_gstate * gstate = pr -> gstate + pr -> gtop ;
 pdf_font_desc * fontdesc = gstate -> text . font ;
 unsigned char * end = buf + len ;
 unsigned int cpt ;
 int cid ;
 while ( buf < end ) {
 int w = pdf_decode_cmap ( fontdesc -> encoding , buf , end , & cpt ) ;
 buf += w ;
 cid = pdf_lookup_cmap ( fontdesc -> encoding , cpt ) ;
 if ( cid >= 0 ) pdf_show_char ( ctx , pr , cid ) ;
 else fz_warn ( ctx , "cannot encode character" ) ;
 if ( cpt == 32 && w == 1 ) pdf_show_space ( ctx , pr , gstate -> text . word_space ) ;
 }
 }


static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_sps, uint8_t(*scaling_matrix4)[16], uint8_t(*scaling_matrix8)[64]) { int fallback_sps = !is_sps && sps->scaling_matrix_present; const uint8_t *fallback[4] = { fallback_sps ? sps->scaling_matrix4[0] : default_scaling4[0], fallback_sps ? sps->scaling_matrix4[3] : default_scaling4[1], fallback_sps ? sps->scaling_matrix8[0] : default_scaling8[0], fallback_sps ? sps->scaling_matrix8[3] : default_scaling8[1] }; if (get_bits1(&h->gb)) { sps->scaling_matrix_present |= is_sps; decode_scaling_list(h, scaling_matrix4[0], 16, default_scaling4[0], fallback[0]); // Intra, Y decode_scaling_list(h, scaling_matrix4[1], 16, default_scaling4[0], scaling_matrix4[0]); // Intra, Cr decode_scaling_list(h, scaling_matrix4[2], 16, default_scaling4[0], scaling_matrix4[1]); // Intra, Cb decode_scaling_list(h, scaling_matrix4[3], 16, default_scaling4[1], fallback[1]); // Inter, Y decode_scaling_list(h, scaling_matrix4[4], 16, default_scaling4[1], scaling_matrix4[3]); // Inter, Cr decode_scaling_list(h, scaling_matrix4[5], 16, default_scaling4[1], scaling_matrix4[4]); // Inter, Cb if (is_sps || pps->transform_8x8_mode) { decode_scaling_list(h, scaling_matrix8[0], 64, default_scaling8[0], fallback[2]); // Intra, Y if (sps->chroma_format_idc == 3) { decode_scaling_list(h, scaling_matrix8[1], 64, default_scaling8[0], scaling_matrix8[0]); // Intra, Cr decode_scaling_list(h, scaling_matrix8[2], 64, default_scaling8[0], scaling_matrix8[1]); // Intra, Cb } decode_scaling_list(h, scaling_matrix8[3], 64, default_scaling8[1], fallback[3]); // Inter, Y if (sps->chroma_format_idc == 3) { decode_scaling_list(h, scaling_matrix8[4], 64, default_scaling8[1], scaling_matrix8[3]); // Inter, Cr decode_scaling_list(h, scaling_matrix8[5], 64, default_scaling8[1], scaling_matrix8[4]); // Inter, Cb } } } }


static void macio_nvram_writeb(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MacIONVRAMState *s = opaque; addr = (addr >> s->it_shift) & (s->size - 1); s->data[addr] = value; NVR_DPRINTF("writeb addr %04x val %x\n", (int)addr, value); }