void SFS_Expression(ScriptParser *parser)
{
	u32 val = gf_bs_read_int(parser->bs, NUMBITS_EXPR_TYPE);
	if (parser->codec->LastError) return;

	switch(val) {
	case ET_CURVED_EXPR:
		SFS_AddString(parser, "(");
		SFS_CompoundExpression(parser);
		SFS_AddString(parser, ")");
		break;
	case ET_NEGATIVE:
		SFS_AddString(parser, "-");
		SFS_Expression(parser);
		break;
	case ET_NOT:
		SFS_AddString(parser, "!");
		SFS_Expression(parser);
		break;
	case ET_ONESCOMP:
		SFS_AddString(parser, "~");
		SFS_Expression(parser);
		break;
	case ET_INCREMENT:
		SFS_AddString(parser, "++");
		SFS_Expression(parser);
		break;
	case ET_DECREMENT:
		SFS_AddString(parser, "--");
		SFS_Expression(parser);
		break;
	case ET_POST_INCREMENT:
		SFS_Expression(parser);
		SFS_AddString(parser, "++");
		break;
	case ET_POST_DECREMENT:
		SFS_Expression(parser);
		SFS_AddString(parser, "--");
		break;
	case ET_CONDTEST:
		SFS_Expression(parser);
		SFS_AddString(parser, " ? ");
		SFS_Expression(parser);
		SFS_AddString(parser, " : ");
		SFS_Expression(parser);
		break;
	case ET_STRING:
		SFS_AddString(parser, "'");
		SFS_GetString(parser);
		SFS_AddString(parser, "'");
		break;
	case ET_NUMBER:
		SFS_GetNumber(parser);
		break;
	case ET_IDENTIFIER:
		SFS_Identifier(parser);
		break;
	case ET_FUNCTION_CALL:
		SFS_FunctionCall(parser);
		break;
	case ET_NEW:
		SFS_NewObject(parser);
		break;
	case ET_OBJECT_MEMBER_ACCESS:
		SFS_ObjectMemberAccess(parser);
		break;
	case ET_OBJECT_METHOD_CALL:
		SFS_ObjectMethodCall(parser);
		break;
	case ET_ARRAY_DEREFERENCE:
		SFS_ArrayDeref(parser);
		break;

	case ET_MULTIPLY:
		SFS_Expression(parser);
		SFS_AddString(parser, "*");
		SFS_Expression(parser);
		break;
	case ET_DIVIDE:
		SFS_Expression(parser);
		SFS_AddString(parser, "/");
		SFS_Expression(parser);
		break;
	case ET_MOD:
		SFS_Expression(parser);
		SFS_AddString(parser, "%");
		SFS_Expression(parser);
		break;
	case ET_PLUS:
		SFS_Expression(parser);
		SFS_AddString(parser, "+");
		SFS_Expression(parser);
		break;
	case ET_MINUS:
		SFS_Expression(parser);
		SFS_AddString(parser, "-");
		SFS_Expression(parser);
		break;
	case ET_LSHIFT:
		SFS_Expression(parser);
		SFS_AddString(parser, "<<");
		SFS_Expression(parser);
		break;
	case ET_RSHIFT:
		SFS_Expression(parser);
		SFS_AddString(parser, ">>");
		SFS_Expression(parser);
		break;
	case ET_RSHIFTFILL:
		SFS_Expression(parser);
		SFS_AddString(parser, ">>>");
		SFS_Expression(parser);
		break;
	case ET_AND:
		SFS_Expression(parser);
		SFS_AddString(parser, "&");
		SFS_Expression(parser);
		break;
	case ET_XOR:
		SFS_Expression(parser);
		SFS_AddString(parser, "^");
		SFS_Expression(parser);
		break;
	case ET_OR:
		SFS_Expression(parser);
		SFS_AddString(parser, "|");
		SFS_Expression(parser);
		break;
	case ET_LT:
		SFS_Expression(parser);
		SFS_AddString(parser, "<");
		SFS_Expression(parser);
		break;
	case ET_LE:
		SFS_Expression(parser);
		SFS_AddString(parser, "<=");
		SFS_Expression(parser);
		break;
	case ET_GT:
		SFS_Expression(parser);
		SFS_AddString(parser, ">");
		SFS_Expression(parser);
		break;
	case ET_GE:
		SFS_Expression(parser);
		SFS_AddString(parser, ">=");
		SFS_Expression(parser);
		break;
	case ET_EQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "==");
		SFS_Expression(parser);
		break;
	case ET_NE:
		SFS_Expression(parser);
		SFS_AddString(parser, "!=");
		SFS_Expression(parser);
		break;
	case ET_LAND:
		SFS_Expression(parser);
		SFS_AddString(parser, "&&");
		SFS_Expression(parser);
		break;
	case ET_LOR:
		SFS_Expression(parser);
		SFS_AddString(parser, "||");
		SFS_Expression(parser);
		break;
	case ET_ASSIGN:
		SFS_Expression(parser);
		SFS_AddString(parser, "=");
		SFS_Expression(parser);
		break;
	case ET_PLUSEQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "+=");
		SFS_Expression(parser);
		break;
	case ET_MINUSEQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "-=");
		SFS_Expression(parser);
		break;
	case ET_MULTIPLYEQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "*=");
		SFS_Expression(parser);
		break;
	case ET_DIVIDEEQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "/=");
		SFS_Expression(parser);
		break;
	case ET_MODEQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "%=");
		SFS_Expression(parser);
		break;
	case ET_LSHIFTEQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "<<=");
		SFS_Expression(parser);
		break;
	case ET_RSHIFTEQ:
		SFS_Expression(parser);
		SFS_AddString(parser, ">>=");
		SFS_Expression(parser);
		break;
	case ET_RSHIFTFILLEQ:
		SFS_Expression(parser);
		SFS_AddString(parser, ">>>=");
		SFS_Expression(parser);
		break;
	case ET_ANDEQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "&=");
		SFS_Expression(parser);
		break;
	case ET_XOREQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "^=");
		SFS_Expression(parser);
		break;
	case ET_OREQ:
		SFS_Expression(parser);
		SFS_AddString(parser, "|=");
		SFS_Expression(parser);
		break;
	case ET_BOOLEAN:
		SFS_GetBoolean(parser);
		break;
	case ET_VAR:
		SFS_AddString(parser, "var ");
		SFS_Arguments(parser, GF_TRUE);
		break;
	case ET_FUNCTION_ASSIGN:
		SFS_AddString(parser, "function ");
		SFS_Arguments(parser, GF_FALSE);
		SFS_StatementBlock(parser, GF_TRUE);
		break;
	default:
		parser->codec->LastError = GF_NON_COMPLIANT_BITSTREAM;
		break;
	}
}


static void cdxl_decode_ham8 ( CDXLVideoContext * c , AVFrame * frame ) {
 AVCodecContext * avctx = c -> avctx ;
 uint32_t new_palette [ 64 ] , r , g , b ;
 uint8_t * ptr , * out , index , op ;
 int x , y ;
 ptr = c -> new_video ;
 out = frame -> data [ 0 ] ;
 import_palette ( c , new_palette ) ;
 import_format ( c , avctx -> width , c -> new_video ) ;
 for ( y = 0 ;
 y < avctx -> height ;
 y ++ ) {
 r = new_palette [ 0 ] & 0xFF0000 ;
 g = new_palette [ 0 ] & 0xFF00 ;
 b = new_palette [ 0 ] & 0xFF ;
 for ( x = 0 ;
 x < avctx -> width ;
 x ++ ) {
 index = * ptr ++ ;
 op = index >> 6 ;
 index &= 63 ;
 switch ( op ) {
 case 0 : r = new_palette [ index ] & 0xFF0000 ;
 g = new_palette [ index ] & 0xFF00 ;
 b = new_palette [ index ] & 0xFF ;
 break ;
 case 1 : b = ( index << 2 ) | ( b & 3 ) ;
 break ;
 case 2 : r = ( index << 18 ) | ( r & ( 3 << 16 ) ) ;
 break ;
 case 3 : g = ( index << 10 ) | ( g & ( 3 << 8 ) ) ;
 break ;
 }
 AV_WL24 ( out + x * 3 , r | g | b ) ;
 }
 out += frame -> linesize [ 0 ] ;
 }
 }


static int vnc_start_vencrypt_handshake(struct VncState *vs) { int ret; if ((ret = gnutls_handshake(vs->tls.session)) < 0) { if (!gnutls_error_is_fatal(ret)) { VNC_DEBUG("Handshake interrupted (blocking)\n"); if (!gnutls_record_get_direction(vs->tls.session)) qemu_set_fd_handler(vs->csock, vnc_tls_handshake_io, NULL, vs); else qemu_set_fd_handler(vs->csock, NULL, vnc_tls_handshake_io, vs); return 0; } VNC_DEBUG("Handshake failed %s\n", gnutls_strerror(ret)); vnc_client_error(vs); return -1; } if (vs->vd->tls.x509verify) { if (vnc_tls_validate_certificate(vs) < 0) { VNC_DEBUG("Client verification failed\n"); vnc_client_error(vs); return -1; } else { VNC_DEBUG("Client verification passed\n"); } } VNC_DEBUG("Handshake done, switching to TLS data mode\n"); qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, vnc_client_write, vs); start_auth_vencrypt_subauth(vs); return 0; }


static int hci_sock_getname(struct socket *sock, struct sockaddr *addr,
			    int *addr_len, int peer)
{
	struct sockaddr_hci *haddr = (struct sockaddr_hci *) addr;
	struct sock *sk = sock->sk;
	struct hci_dev *hdev = hci_pi(sk)->hdev;

	BT_DBG("sock %p sk %p", sock, sk);

	if (!hdev)
		return -EBADFD;

	lock_sock(sk);

	*addr_len = sizeof(*haddr);
	haddr->hci_family = AF_BLUETOOTH;
	haddr->hci_dev    = hdev->id;

	release_sock(sk);
	return 0;
}


static inline struct sk_buff * pfkey_xfrm_state2msg ( const struct xfrm_state * x ) {
 struct sk_buff * skb ;
 skb = __pfkey_xfrm_state2msg ( x , 1 , 3 ) ;
 return skb ;
 }


static ossl_inline void lh_ ## type ## _stats_bio ( const LHASH_OF ( type ) * lh , BIO * out ) {
 OPENSSL_LH_stats_bio ( ( const OPENSSL_LHASH * ) lh , out ) ;
 }
 static ossl_inline unsigned long lh_ ## type ## _get_down_load ( LHASH_OF ( type ) * lh ) {
 return OPENSSL_LH_get_down_load ( ( OPENSSL_LHASH * ) lh ) ;
 }
 static ossl_inline void lh_ ## type ## _set_down_load ( LHASH_OF ( type ) * lh , unsigned long dl ) {
 OPENSSL_LH_set_down_load ( ( OPENSSL_LHASH * ) lh , dl ) ;
 }
 static ossl_inline void lh_ ## type ## _doall ( LHASH_OF ( type ) * lh , void ( * doall ) ( type * ) ) {
 OPENSSL_LH_doall ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNC ) doall ) ;
 }
 LHASH_OF ( type ) # define IMPLEMENT_LHASH_DOALL_ARG_CONST ( type , argtype ) int_implement_lhash_doall ( type , argtype , const type ) # define IMPLEMENT_LHASH_DOALL_ARG ( type , argtype ) int_implement_lhash_doall ( type , argtype , type ) # define int_implement_lhash_doall ( type , argtype , cbargtype ) static ossl_inline void lh_ ## type ## _doall_ ## argtype ( LHASH_OF ( type ) * lh , void ( * fn ) ( cbargtype * , argtype * ) , argtype * arg ) {
 OPENSSL_LH_doall_arg ( ( OPENSSL_LHASH * ) lh , ( OPENSSL_LH_DOALL_FUNCARG ) fn , ( void * ) arg ) ;
 }
 LHASH_OF ( type ) DEFINE_LHASH_OF ( OPENSSL_STRING )


static av_cold int libssh_authentication(LIBSSHContext *libssh, const char *user, const char *password) { int authorized = 0; int auth_methods; if (user) ssh_options_set(libssh->session, SSH_OPTIONS_USER, user); if (ssh_userauth_none(libssh->session, NULL) == SSH_AUTH_SUCCESS) return 0; auth_methods = ssh_userauth_list(libssh->session, NULL); if (auth_methods & SSH_AUTH_METHOD_PUBLICKEY) { if (libssh->priv_key) { ssh_string pub_key; ssh_private_key priv_key; int type; if (!ssh_try_publickey_from_file(libssh->session, libssh->priv_key, &pub_key, &type)) { priv_key = privatekey_from_file(libssh->session, libssh->priv_key, type, password); if (ssh_userauth_pubkey(libssh->session, NULL, pub_key, priv_key) == SSH_AUTH_SUCCESS) { av_log(libssh, AV_LOG_DEBUG, "Authentication successful with selected private key.\n"); authorized = 1; } } else { av_log(libssh, AV_LOG_DEBUG, "Invalid key is provided.\n"); return AVERROR(EACCES); } } else if (ssh_userauth_autopubkey(libssh->session, password) == SSH_AUTH_SUCCESS) { av_log(libssh, AV_LOG_DEBUG, "Authentication successful with auto selected key.\n"); authorized = 1; } } if (!authorized && (auth_methods & SSH_AUTH_METHOD_PASSWORD)) { if (ssh_userauth_password(libssh->session, NULL, password) == SSH_AUTH_SUCCESS) { av_log(libssh, AV_LOG_DEBUG, "Authentication successful with password.\n"); authorized = 1; } } if (!authorized) { av_log(libssh, AV_LOG_ERROR, "Authentication failed.\n"); return AVERROR(EACCES); } return 0; }


int gif_write(ByteIOContext *pb, AVImageInfo *info) { gif_image_write_header(pb, info->width, info->height, (uint32_t *)info->pict.data[1]); gif_image_write_image(pb, 0, 0, info->width, info->height, info->pict.data[0], info->pict.linesize[0], PIX_FMT_PAL8); put_byte(pb, 0x3b); put_flush_packet(pb); return 0; }


static void n8x0_init(QEMUMachineInitArgs *args, struct arm_boot_info *binfo, int model) { MemoryRegion *sysmem = get_system_memory(); struct n800_s *s = (struct n800_s *) g_malloc0(sizeof(*s)); int sdram_size = binfo->ram_size; s->mpu = omap2420_mpu_init(sysmem, sdram_size, args->cpu_model); /* Setup peripherals * * Believed external peripherals layout in the N810: * (spi bus 1) * tsc2005 * lcd_mipid * (spi bus 2) * Conexant cx3110x (WLAN) * optional: pc2400m (WiMAX) * (i2c bus 0) * TLV320AIC33 (audio codec) * TCM825x (camera by Toshiba) * lp5521 (clever LEDs) * tsl2563 (light sensor, hwmon, model 7, rev. 0) * lm8323 (keypad, manf 00, rev 04) * (i2c bus 1) * tmp105 (temperature sensor, hwmon) * menelaus (pm) * (somewhere on i2c - maybe N800-only) * tea5761 (FM tuner) * (serial 0) * GPS * (some serial port) * csr41814 (Bluetooth) */ n8x0_gpio_setup(s); n8x0_nand_setup(s); n8x0_i2c_setup(s); if (model == 800) n800_tsc_kbd_setup(s); else if (model == 810) { n810_tsc_setup(s); n810_kbd_setup(s); } n8x0_spi_setup(s); n8x0_dss_setup(s); n8x0_cbus_setup(s); n8x0_uart_setup(s); if (usb_enabled(false)) { n8x0_usb_setup(s); } if (args->kernel_filename) { /* Or at the linux loader. */ binfo->kernel_filename = args->kernel_filename; binfo->kernel_cmdline = args->kernel_cmdline; binfo->initrd_filename = args->initrd_filename; arm_load_kernel(s->mpu->cpu, binfo); qemu_register_reset(n8x0_boot_init, s); } if (option_rom[0].name && (args->boot_device[0] == 'n' || !args->kernel_filename)) { uint8_t nolo_tags[0x10000]; /* No, wait, better start at the ROM. */ s->mpu->cpu->env.regs[15] = OMAP2_Q2_BASE + 0x400000; /* This is intended for loading the `secondary.bin' program from * Nokia images (the NOLO bootloader). The entry point seems * to be at OMAP2_Q2_BASE + 0x400000. * * The `2nd.bin' files contain some kind of earlier boot code and * for them the entry point needs to be set to OMAP2_SRAM_BASE. * * The code above is for loading the `zImage' file from Nokia * images. */ load_image_targphys(option_rom[0].name, OMAP2_Q2_BASE + 0x400000, sdram_size - 0x400000); n800_setup_nolo_tags(nolo_tags); cpu_physical_memory_write(OMAP2_SRAM_BASE, nolo_tags, 0x10000); } }


static bool bad_domain(const char *domain)
{
  return !strchr(domain, '.') && !strcasecompare(domain, "localhost");
}


void fz_new_cmm_context ( fz_context * ctx ) {
 ctx -> cmm_instance = fz_cmm_new_instance ( ctx ) ;
 }


void http_hdr_version_set ( HTTPHdrImpl * hh , int32_t ver ) {
 hh -> m_version = ver ;
 }


int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) { int i, count, ret, read_size, j; AVStream *st; AVPacket pkt1, *pkt; int64_t old_offset = avio_tell(ic->pb); int orig_nb_streams = ic->nb_streams; // new streams might appear, no options for those for(i=0;i<ic->nb_streams;i++) { AVCodec *codec; AVDictionary *thread_opt = NULL; st = ic->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { /* if(!st->time_base.num) st->time_base= */ if(!st->codec->time_base.num) st->codec->time_base= st->time_base; } //only for the split stuff if (!st->parser && !(ic->flags & AVFMT_FLAG_NOPARSE)) { st->parser = av_parser_init(st->codec->codec_id); if(st->need_parsing == AVSTREAM_PARSE_HEADERS && st->parser){ st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; } } assert(!st->codec->codec); codec = avcodec_find_decoder(st->codec->codec_id); /* force thread count to 1 since the h264 decoder will not extract SPS * and PPS to extradata during multi-threaded decoding */ av_dict_set(options ? &options[i] : &thread_opt, "threads", "1", 0); /* Ensure that subtitle_header is properly set. */ if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE && codec && !st->codec->codec) avcodec_open2(st->codec, codec, options ? &options[i] : &thread_opt); //try to just open decoders, in case this is enough to get parameters if(!has_codec_parameters(st->codec)){ if (codec && !st->codec->codec) avcodec_open2(st->codec, codec, options ? &options[i] : &thread_opt); } if (!options) av_dict_free(&thread_opt); } for (i=0; i<ic->nb_streams; i++) { ic->streams[i]->info->last_dts = AV_NOPTS_VALUE; } count = 0; read_size = 0; for(;;) { if (ff_check_interrupt(&ic->interrupt_callback)){ ret= AVERROR_EXIT; av_log(ic, AV_LOG_DEBUG, "interrupted\n"); break; } /* check if one codec still needs to be handled */ for(i=0;i<ic->nb_streams;i++) { int fps_analyze_framecount = 20; st = ic->streams[i]; if (!has_codec_parameters(st->codec)) break; /* if the timebase is coarse (like the usual millisecond precision of mkv), we need to analyze more frames to reliably arrive at the correct fps */ if (av_q2d(st->time_base) > 0.0005) fps_analyze_framecount *= 2; if (ic->fps_probe_size >= 0) fps_analyze_framecount = ic->fps_probe_size; /* variable fps and no guess at the real fps */ if( tb_unreliable(st->codec) && !(st->r_frame_rate.num && st->avg_frame_rate.num) && st->info->duration_count < fps_analyze_framecount && st->codec->codec_type == AVMEDIA_TYPE_VIDEO) break; if(st->parser && st->parser->parser->split && !st->codec->extradata) break; if(st->first_dts == AV_NOPTS_VALUE) break; } if (i == ic->nb_streams) { /* NOTE: if the format has no header, then we need to read some packets to get most of the streams, so we cannot stop here */ if (!(ic->ctx_flags & AVFMTCTX_NOHEADER)) { /* if we found the info for all the codecs, we can stop */ ret = count; av_log(ic, AV_LOG_DEBUG, "All info found\n"); break; } } /* we did not get all the codec info, but we read too much data */ if (read_size >= ic->probesize) { ret = count; av_log(ic, AV_LOG_DEBUG, "Probe buffer size limit %d reached\n", ic->probesize); break; } /* NOTE: a new stream can be added there if no header in file (AVFMTCTX_NOHEADER) */ ret = read_frame_internal(ic, &pkt1); if (ret == AVERROR(EAGAIN)) continue; if (ret < 0) { /* EOF or error*/ AVPacket empty_pkt = { 0 }; int err; av_init_packet(&empty_pkt); ret = -1; /* we could not have all the codec parameters before EOF */ for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; /* flush the decoders */ do { err = try_decode_frame(st, &empty_pkt, (options && i < orig_nb_streams) ? &options[i] : NULL); } while (err > 0 && !has_codec_parameters(st->codec)); if (err < 0) { av_log(ic, AV_LOG_WARNING, "decoding for stream %d failed\n", st->index); } else if (!has_codec_parameters(st->codec)){ char buf[256]; avcodec_string(buf, sizeof(buf), st->codec, 0); av_log(ic, AV_LOG_WARNING, "Could not find codec parameters (%s)\n", buf); } else { ret = 0; } } break; } pkt= add_to_pktbuf(&ic->packet_buffer, &pkt1, &ic->packet_buffer_end); if ((ret = av_dup_packet(pkt)) < 0) goto find_stream_info_err; read_size += pkt->size; st = ic->streams[pkt->stream_index]; if (st->codec_info_nb_frames>1) { if (st->time_base.den > 0 && av_rescale_q(st->info->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration) { av_log(ic, AV_LOG_WARNING, "max_analyze_duration reached\n"); break; } st->info->codec_info_duration += pkt->duration; } { int64_t last = st->info->last_dts; if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && pkt->dts > last){ int64_t duration= pkt->dts - last; double dur= duration * av_q2d(st->time_base); // if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // av_log(NULL, AV_LOG_ERROR, "%f\n", dur); if (st->info->duration_count < 2) memset(st->info->duration_error, 0, sizeof(st->info->duration_error)); for (i=1; i<FF_ARRAY_ELEMS(st->info->duration_error); i++) { int framerate= get_std_framerate(i); int ticks= lrintf(dur*framerate/(1001*12)); double error = dur - (double)ticks*1001*12 / framerate; st->info->duration_error[i] += error*error; } st->info->duration_count++; // ignore the first 4 values, they might have some random jitter if (st->info->duration_count > 3) st->info->duration_gcd = av_gcd(st->info->duration_gcd, duration); } if (last == AV_NOPTS_VALUE || st->info->duration_count <= 1) st->info->last_dts = pkt->dts; } if(st->parser && st->parser->parser->split && !st->codec->extradata){ int i= st->parser->parser->split(st->codec, pkt->data, pkt->size); if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) { st->codec->extradata_size= i; st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size); memset(st->codec->extradata + i, 0, FF_INPUT_BUFFER_PADDING_SIZE); } } /* if still no information, we try to open the codec and to decompress the frame. We try to avoid that in most cases as it takes longer and uses more memory. For MPEG-4, we need to decompress for QuickTime. If CODEC_CAP_CHANNEL_CONF is set this will force decoding of at least one frame of codec data, this makes sure the codec initializes the channel configuration and does not only trust the values from the container. */ try_decode_frame(st, pkt, (options && i < orig_nb_streams ) ? &options[i] : NULL); st->codec_info_nb_frames++; count++; } // close codecs which were opened in try_decode_frame() for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; if(st->codec->codec) avcodec_close(st->codec); } for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; if (st->codec_info_nb_frames>2 && !st->avg_frame_rate.num && st->info->codec_info_duration) av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den, (st->codec_info_nb_frames-2)*(int64_t)st->time_base.den, st->info->codec_info_duration*(int64_t)st->time_base.num, 60000); if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { // the check for tb_unreliable() is not completely correct, since this is not about handling // a unreliable/inexact time base, but a time base that is finer than necessary, as e.g. // ipmovie.c produces. if (tb_unreliable(st->codec) && st->info->duration_count > 15 && st->info->duration_gcd > 1 && !st->r_frame_rate.num) av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, st->time_base.den, st->time_base.num * st->info->duration_gcd, INT_MAX); if (st->info->duration_count && !st->r_frame_rate.num && tb_unreliable(st->codec) /*&& //FIXME we should not special-case MPEG-2, but this needs testing with non-MPEG-2 ... st->time_base.num*duration_sum[i]/st->info->duration_count*101LL > st->time_base.den*/){ int num = 0; double best_error= 2*av_q2d(st->time_base); best_error = best_error*best_error*st->info->duration_count*1000*12*30; for (j=1; j<FF_ARRAY_ELEMS(st->info->duration_error); j++) { double error = st->info->duration_error[j] * get_std_framerate(j); // if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // av_log(NULL, AV_LOG_ERROR, "%f %f\n", get_std_framerate(j) / 12.0/1001, error); if(error < best_error){ best_error= error; num = get_std_framerate(j); } } // do not increase frame rate by more than 1 % in order to match a standard rate. if (num && (!st->r_frame_rate.num || (double)num/(12*1001) < 1.01 * av_q2d(st->r_frame_rate))) av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, num, 12*1001, INT_MAX); } if (!st->r_frame_rate.num){ if( st->codec->time_base.den * (int64_t)st->time_base.num <= st->codec->time_base.num * st->codec->ticks_per_frame * (int64_t)st->time_base.den){ st->r_frame_rate.num = st->codec->time_base.den; st->r_frame_rate.den = st->codec->time_base.num * st->codec->ticks_per_frame; }else{ st->r_frame_rate.num = st->time_base.den; st->r_frame_rate.den = st->time_base.num; } } }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if(!st->codec->bits_per_coded_sample) st->codec->bits_per_coded_sample= av_get_bits_per_sample(st->codec->codec_id); // set stream disposition based on audio service type switch (st->codec->audio_service_type) { case AV_AUDIO_SERVICE_TYPE_EFFECTS: st->disposition = AV_DISPOSITION_CLEAN_EFFECTS; break; case AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED: st->disposition = AV_DISPOSITION_VISUAL_IMPAIRED; break; case AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED: st->disposition = AV_DISPOSITION_HEARING_IMPAIRED; break; case AV_AUDIO_SERVICE_TYPE_COMMENTARY: st->disposition = AV_DISPOSITION_COMMENT; break; case AV_AUDIO_SERVICE_TYPE_KARAOKE: st->disposition = AV_DISPOSITION_KARAOKE; break; } } } estimate_timings(ic, old_offset); compute_chapters_end(ic); #if 0 /* correct DTS for B-frame streams with no timestamps */ for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if(b-frames){ ppktl = &ic->packet_buffer; while(ppkt1){ if(ppkt1->stream_index != i) continue; if(ppkt1->pkt->dts < 0) break; if(ppkt1->pkt->pts != AV_NOPTS_VALUE) break; ppkt1->pkt->dts -= delta; ppkt1= ppkt1->next; } if(ppkt1) continue; st->cur_dts -= delta; } } } #endif find_stream_info_err: for (i=0; i < ic->nb_streams; i++) { if (ic->streams[i]->codec) ic->streams[i]->codec->thread_count = 0; av_freep(&ic->streams[i]->info); } return ret; }


static void dcr_write_sdram (void *opaque, int dcrn, uint32_t val) { ppc4xx_sdram_t *sdram; sdram = opaque; switch (dcrn) { case SDRAM0_CFGADDR: sdram->addr = val; break; case SDRAM0_CFGDATA: switch (sdram->addr) { case 0x00: /* SDRAM_BESR0 */ sdram->besr0 &= ~val; break; case 0x08: /* SDRAM_BESR1 */ sdram->besr1 &= ~val; break; case 0x10: /* SDRAM_BEAR */ sdram->bear = val; break; case 0x20: /* SDRAM_CFG */ val &= 0xFFE00000; if (!(sdram->cfg & 0x80000000) && (val & 0x80000000)) { #ifdef DEBUG_SDRAM printf("%s: enable SDRAM controller\n", __func__); #endif /* validate all RAM mappings */ sdram_map_bcr(sdram); sdram->status &= ~0x80000000; } else if ((sdram->cfg & 0x80000000) && !(val & 0x80000000)) { #ifdef DEBUG_SDRAM printf("%s: disable SDRAM controller\n", __func__); #endif /* invalidate all RAM mappings */ sdram_unmap_bcr(sdram); sdram->status |= 0x80000000; } if (!(sdram->cfg & 0x40000000) && (val & 0x40000000)) sdram->status |= 0x40000000; else if ((sdram->cfg & 0x40000000) && !(val & 0x40000000)) sdram->status &= ~0x40000000; sdram->cfg = val; break; case 0x24: /* SDRAM_STATUS */ /* Read-only register */ break; case 0x30: /* SDRAM_RTR */ sdram->rtr = val & 0x3FF80000; break; case 0x34: /* SDRAM_PMIT */ sdram->pmit = (val & 0xF8000000) | 0x07C00000; break; case 0x40: /* SDRAM_B0CR */ sdram_set_bcr(&sdram->bcr[0], val, sdram->cfg & 0x80000000); break; case 0x44: /* SDRAM_B1CR */ sdram_set_bcr(&sdram->bcr[1], val, sdram->cfg & 0x80000000); break; case 0x48: /* SDRAM_B2CR */ sdram_set_bcr(&sdram->bcr[2], val, sdram->cfg & 0x80000000); break; case 0x4C: /* SDRAM_B3CR */ sdram_set_bcr(&sdram->bcr[3], val, sdram->cfg & 0x80000000); break; case 0x80: /* SDRAM_TR */ sdram->tr = val & 0x018FC01F; break; case 0x94: /* SDRAM_ECCCFG */ sdram->ecccfg = val & 0x00F00000; break; case 0x98: /* SDRAM_ECCESR */ val &= 0xFFF0F000; if (sdram->eccesr == 0 && val != 0) qemu_irq_raise(sdram->irq); else if (sdram->eccesr != 0 && val == 0) qemu_irq_lower(sdram->irq); sdram->eccesr = val; break; default: /* Error */ break; } break; } }


static inline int tcg_global_reg_new_internal(TCGType type, int reg, const char *name) { TCGContext *s = &tcg_ctx; TCGTemp *ts; int idx; #if TCG_TARGET_REG_BITS == 32 if (type != TCG_TYPE_I32) tcg_abort(); #endif if (tcg_regset_test_reg(s->reserved_regs, reg)) tcg_abort(); idx = s->nb_globals; tcg_temp_alloc(s, s->nb_globals + 1); ts = &s->temps[s->nb_globals]; ts->base_type = type; ts->type = type; ts->fixed_reg = 1; ts->reg = reg; ts->name = name; s->nb_globals++; tcg_regset_set_reg(s->reserved_regs, reg); return idx; }


  void Compute(OpKernelContext* context) override {
    const Tensor& tensor_in = context->input(0);
    const Tensor& grad_in = context->input(1);
    const Tensor& argmax = context->input(2);

    PoolParameters params{context,
                          ksize_,
                          stride_,
                          padding_,
                          /*explicit_paddings=*/{},
                          FORMAT_NHWC,
                          tensor_in.shape()};
    if (!context->status().ok()) {
      return;
    }

    TensorShape out_shape({params.tensor_in_batch, params.tensor_in_rows,
                           params.tensor_in_cols, params.depth});
    Tensor* grad_out = nullptr;
    OP_REQUIRES_OK(context, context->forward_input_or_allocate_output(
                                {0}, 0, out_shape, &grad_out));

    LaunchMaxPoolingGradWithArgmax<Device, T>::launch(
        context, params, grad_in, argmax, grad_out, include_batch_in_index_);
  }


static picture_t * vout_new_buffer ( decoder_t * p_dec ) {
 decoder_owner_sys_t * p_owner = p_dec -> p_owner ;
 if ( p_owner -> p_vout == NULL || p_dec -> fmt_out . video . i_width != p_owner -> video . i_width || p_dec -> fmt_out . video . i_height != p_owner -> video . i_height || p_dec -> fmt_out . video . i_visible_width != p_owner -> video . i_visible_width || p_dec -> fmt_out . video . i_visible_height != p_owner -> video . i_visible_height || p_dec -> fmt_out . video . i_x_offset != p_owner -> video . i_x_offset || p_dec -> fmt_out . video . i_y_offset != p_owner -> video . i_y_offset || p_dec -> fmt_out . i_codec != p_owner -> video . i_chroma || ( int64_t ) p_dec -> fmt_out . video . i_sar_num * p_owner -> video . i_sar_den != ( int64_t ) p_dec -> fmt_out . video . i_sar_den * p_owner -> video . i_sar_num || p_dec -> fmt_out . video . orientation != p_owner -> video . orientation ) {
 vout_thread_t * p_vout ;
 if ( ! p_dec -> fmt_out . video . i_width || ! p_dec -> fmt_out . video . i_height ) {
 return NULL ;
 }
 video_format_t fmt = p_dec -> fmt_out . video ;
 fmt . i_chroma = p_dec -> fmt_out . i_codec ;
 p_owner -> video = fmt ;
 if ( vlc_fourcc_IsYUV ( fmt . i_chroma ) ) {
 const vlc_chroma_description_t * dsc = vlc_fourcc_GetChromaDescription ( fmt . i_chroma ) ;
 for ( unsigned int i = 0 ;
 dsc && i < dsc -> plane_count ;
 i ++ ) {
 while ( fmt . i_width % dsc -> p [ i ] . w . den ) fmt . i_width ++ ;
 while ( fmt . i_height % dsc -> p [ i ] . h . den ) fmt . i_height ++ ;
 }
 }
 if ( ! fmt . i_visible_width || ! fmt . i_visible_height ) {
 if ( p_dec -> fmt_in . video . i_visible_width && p_dec -> fmt_in . video . i_visible_height ) {
 fmt . i_visible_width = p_dec -> fmt_in . video . i_visible_width ;
 fmt . i_visible_height = p_dec -> fmt_in . video . i_visible_height ;
 fmt . i_x_offset = p_dec -> fmt_in . video . i_x_offset ;
 fmt . i_y_offset = p_dec -> fmt_in . video . i_y_offset ;
 }
 else {
 fmt . i_visible_width = fmt . i_width ;
 fmt . i_visible_height = fmt . i_height ;
 fmt . i_x_offset = 0 ;
 fmt . i_y_offset = 0 ;
 }
 }
 if ( fmt . i_visible_height == 1088 && var_CreateGetBool ( p_dec , "hdtv-fix" ) ) {
 fmt . i_visible_height = 1080 ;
 if ( ! ( fmt . i_sar_num % 136 ) ) {
 fmt . i_sar_num *= 135 ;
 fmt . i_sar_den *= 136 ;
 }
 msg_Warn ( p_dec , "Fixing broken HDTV stream (display_height=1088)" ) ;
 }
 if ( ! fmt . i_sar_num || ! fmt . i_sar_den ) {
 fmt . i_sar_num = 1 ;
 fmt . i_sar_den = 1 ;
 }
 vlc_ureduce ( & fmt . i_sar_num , & fmt . i_sar_den , fmt . i_sar_num , fmt . i_sar_den , 50000 ) ;
 vlc_mutex_lock ( & p_owner -> lock ) ;
 p_vout = p_owner -> p_vout ;
 p_owner -> p_vout = NULL ;
 vlc_mutex_unlock ( & p_owner -> lock ) ;
 unsigned dpb_size ;
 switch ( p_dec -> fmt_in . i_codec ) {
 case VLC_CODEC_HEVC : case VLC_CODEC_H264 : case VLC_CODEC_DIRAC : dpb_size = 18 ;
 break ;
 case VLC_CODEC_VP5 : case VLC_CODEC_VP6 : case VLC_CODEC_VP6F : case VLC_CODEC_VP8 : dpb_size = 3 ;
 break ;
 default : dpb_size = 2 ;
 break ;
 }
 p_vout = input_resource_RequestVout ( p_owner -> p_resource , p_vout , & fmt , dpb_size + p_dec -> i_extra_picture_buffers + 1 , true ) ;
 vlc_mutex_lock ( & p_owner -> lock ) ;
 p_owner -> p_vout = p_vout ;
 DecoderUpdateFormatLocked ( p_dec ) ;
 vlc_mutex_unlock ( & p_owner -> lock ) ;
 if ( p_owner -> p_input != NULL ) input_SendEventVout ( p_owner -> p_input ) ;
 if ( p_vout == NULL ) {
 msg_Err ( p_dec , "failed to create video output" ) ;
 p_dec -> b_error = true ;
 return NULL ;
 }
 }
 for ( ;
 ;
 ) {
 if ( DecoderIsExitRequested ( p_dec ) || p_dec -> b_error ) return NULL ;
 picture_t * p_picture = vout_GetPicture ( p_owner -> p_vout ) ;
 if ( p_picture ) return p_picture ;
 if ( DecoderIsFlushing ( p_dec ) ) return NULL ;
 DecoderSignalWait ( p_dec , true ) ;
 vout_FixLeaks ( p_owner -> p_vout ) ;
 msleep ( VOUT_OUTMEM_SLEEP ) ;
 }
 }


void * hb_shape_plan_get_user_data ( hb_shape_plan_t * shape_plan , hb_user_data_key_t * key ) {
 return hb_object_get_user_data ( shape_plan , key ) ;
 }


uint64_t ram_bytes_remaining(void) { return ram_state->migration_dirty_pages * TARGET_PAGE_SIZE; }


static int msix_is_masked(PCIDevice *dev, int vector) { unsigned offset = vector * PCI_MSIX_ENTRY_SIZE + PCI_MSIX_ENTRY_VECTOR_CTRL; return dev->msix_function_masked || dev->msix_table_page[offset] & PCI_MSIX_ENTRY_CTRL_MASKBIT; }


njs_promise_perform_race_handler(njs_vm_t *vm, njs_iterator_args_t *args,
    njs_value_t *value, int64_t index)
{
    njs_int_t                    ret;
    njs_value_t                  arguments[2], next;
    njs_promise_capability_t     *capability;
    njs_promise_iterator_args_t  *pargs;

    pargs = (njs_promise_iterator_args_t *) args;

    ret = njs_function_call(vm, pargs->function, pargs->constructor, value,
                            1, &next);
    if (njs_slow_path(ret == NJS_ERROR)) {
        return ret;
    }

    capability = pargs->capability;

    arguments[0] = capability->resolve;
    arguments[1] = capability->reject;

    (void) njs_promise_invoke_then(vm, &next, arguments, 2);

    return NJS_OK;
}


static void opt_audio_sample_fmt(const char *arg) { if (strcmp(arg, "list")) audio_sample_fmt = av_get_sample_fmt(arg); else { list_fmts(av_get_sample_fmt_string, AV_SAMPLE_FMT_NB); ffmpeg_exit(0); } }


static void e1000e_rss_parse_packet ( E1000ECore * core , struct NetRxPkt * pkt , E1000E_RSSInfo * info ) {
 trace_e1000e_rx_rss_started ( ) ;
 if ( ! e1000e_rss_enabled ( core ) ) {
 info -> enabled = false ;
 info -> hash = 0 ;
 info -> queue = 0 ;
 info -> type = 0 ;
 trace_e1000e_rx_rss_disabled ( ) ;
 return ;
 }
 info -> enabled = true ;
 info -> type = e1000e_rss_get_hash_type ( core , pkt ) ;
 trace_e1000e_rx_rss_type ( info -> type ) ;
 if ( info -> type == E1000_MRQ_RSS_TYPE_NONE ) {
 info -> hash = 0 ;
 info -> queue = 0 ;
 return ;
 }
 info -> hash = e1000e_rss_calc_hash ( core , pkt , info ) ;
 info -> queue = E1000_RSS_QUEUE ( & core -> mac [ RETA ] , info -> hash ) ;
 }


static inline guint64 get_uint64_value ( proto_tree * tree , tvbuff_t * tvb , gint offset , guint length , const guint encoding ) {
 guint64 value ;
 gboolean length_error ;
 switch ( length ) {
 case 1 : value = tvb_get_guint8 ( tvb , offset ) ;
 break ;
 case 2 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letohs ( tvb , offset ) : tvb_get_ntohs ( tvb , offset ) ;
 break ;
 case 3 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letoh24 ( tvb , offset ) : tvb_get_ntoh24 ( tvb , offset ) ;
 break ;
 case 4 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letohl ( tvb , offset ) : tvb_get_ntohl ( tvb , offset ) ;
 break ;
 case 5 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letoh40 ( tvb , offset ) : tvb_get_ntoh40 ( tvb , offset ) ;
 break ;
 case 6 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letoh48 ( tvb , offset ) : tvb_get_ntoh48 ( tvb , offset ) ;
 break ;
 case 7 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letoh56 ( tvb , offset ) : tvb_get_ntoh56 ( tvb , offset ) ;
 break ;
 case 8 : value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letoh64 ( tvb , offset ) : tvb_get_ntoh64 ( tvb , offset ) ;
 break ;
 default : if ( length < 1 ) {
 length_error = TRUE ;
 value = 0 ;
 }
 else {
 length_error = FALSE ;
 value = ( encoding & ENC_LITTLE_ENDIAN ) ? tvb_get_letoh64 ( tvb , offset ) : tvb_get_ntoh64 ( tvb , offset ) ;
 }
 report_type_length_mismatch ( tree , "an unsigned integer" , length , length_error ) ;
 break ;
 }
 return value ;
 }


static inline Quantum GetPixelReadMask ( const Image * restrict image , const Quantum * restrict pixel ) {
 if ( image -> channel_map [ ReadMaskPixelChannel ] . traits == UndefinedPixelTrait ) return ( ( Quantum ) QuantumRange ) ;
 return ( pixel [ image -> channel_map [ ReadMaskPixelChannel ] . offset ] ) ;
 }


static float get_band_cost_UQUAD_mips(struct AACEncContext *s, PutBitContext *pb, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits) { const float Q34 = ff_aac_pow34sf_tab[POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512]; const float IQ = ff_aac_pow2sf_tab [POW_SF2_ZERO + scale_idx - SCALE_ONE_POS + SCALE_DIV_512]; int i; float cost = 0; int curbits = 0; int qc1, qc2, qc3, qc4; uint8_t *p_bits = (uint8_t*)ff_aac_spectral_bits[cb-1]; float *p_codes = (float *)ff_aac_codebook_vectors[cb-1]; for (i = 0; i < size; i += 4) { const float *vec; int curidx; float *in_pos = (float *)&in[i]; float di0, di1, di2, di3; int t0, t1, t2, t3, t4; qc1 = scaled[i ] * Q34 + ROUND_STANDARD; qc2 = scaled[i+1] * Q34 + ROUND_STANDARD; qc3 = scaled[i+2] * Q34 + ROUND_STANDARD; qc4 = scaled[i+3] * Q34 + ROUND_STANDARD; __asm__ volatile ( ".set push \n\t" ".set noreorder \n\t" "ori %[t4], $zero, 2 \n\t" "slt %[t0], %[t4], %[qc1] \n\t" "slt %[t1], %[t4], %[qc2] \n\t" "slt %[t2], %[t4], %[qc3] \n\t" "slt %[t3], %[t4], %[qc4] \n\t" "movn %[qc1], %[t4], %[t0] \n\t" "movn %[qc2], %[t4], %[t1] \n\t" "movn %[qc3], %[t4], %[t2] \n\t" "movn %[qc4], %[t4], %[t3] \n\t" ".set pop \n\t" : [qc1]"+r"(qc1), [qc2]"+r"(qc2), [qc3]"+r"(qc3), [qc4]"+r"(qc4), [t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3), [t4]"=&r"(t4) ); curidx = qc1; curidx *= 3; curidx += qc2; curidx *= 3; curidx += qc3; curidx *= 3; curidx += qc4; curbits += p_bits[curidx]; curbits += uquad_sign_bits[curidx]; vec = &p_codes[curidx*4]; __asm__ volatile ( ".set push \n\t" ".set noreorder \n\t" "lwc1 %[di0], 0(%[in_pos]) \n\t" "lwc1 %[di1], 4(%[in_pos]) \n\t" "lwc1 %[di2], 8(%[in_pos]) \n\t" "lwc1 %[di3], 12(%[in_pos]) \n\t" "abs.s %[di0], %[di0] \n\t" "abs.s %[di1], %[di1] \n\t" "abs.s %[di2], %[di2] \n\t" "abs.s %[di3], %[di3] \n\t" "lwc1 $f0, 0(%[vec]) \n\t" "lwc1 $f1, 4(%[vec]) \n\t" "lwc1 $f2, 8(%[vec]) \n\t" "lwc1 $f3, 12(%[vec]) \n\t" "nmsub.s %[di0], %[di0], $f0, %[IQ] \n\t" "nmsub.s %[di1], %[di1], $f1, %[IQ] \n\t" "nmsub.s %[di2], %[di2], $f2, %[IQ] \n\t" "nmsub.s %[di3], %[di3], $f3, %[IQ] \n\t" ".set pop \n\t" : [di0]"=&f"(di0), [di1]"=&f"(di1), [di2]"=&f"(di2), [di3]"=&f"(di3) : [in_pos]"r"(in_pos), [vec]"r"(vec), [IQ]"f"(IQ) : "$f0", "$f1", "$f2", "$f3", "memory" ); cost += di0 * di0 + di1 * di1 + di2 * di2 + di3 * di3; } if (bits) *bits = curbits; return cost * lambda + curbits; }


static void sdl_grab_start(void) { /* * If the application is not active, do not try to enter grab state. This * prevents 'SDL_WM_GrabInput(SDL_GRAB_ON)' from blocking all the * application (SDL bug). */ if (!(SDL_GetAppState() & SDL_APPINPUTFOCUS)) { return; } if (guest_cursor) { SDL_SetCursor(guest_sprite); if (!kbd_mouse_is_absolute() && !absolute_enabled) SDL_WarpMouse(guest_x, guest_y); } else sdl_hide_cursor(); if (SDL_WM_GrabInput(SDL_GRAB_ON) == SDL_GRAB_ON) { gui_grab = 1; sdl_update_caption(); } else sdl_show_cursor(); }


static void libschroedinger_free_frame(void *data) { FFSchroEncodedFrame *enc_frame = data; av_freep(&enc_frame->p_encbuf); av_free(enc_frame); }


static int decode_element ( AVCodecContext * avctx , AVFrame * frame , int ch_index , int channels ) {
 ALACContext * alac = avctx -> priv_data ;
 int has_size , bps , is_compressed , decorr_shift , decorr_left_weight , ret ;
 uint32_t output_samples ;
 int i , ch ;
 skip_bits ( & alac -> gb , 4 ) ;
 skip_bits ( & alac -> gb , 12 ) ;
 has_size = get_bits1 ( & alac -> gb ) ;
 alac -> extra_bits = get_bits ( & alac -> gb , 2 ) << 3 ;
 bps = alac -> sample_size - alac -> extra_bits + channels - 1 ;
 if ( bps > 32 ) {
 av_log ( avctx , AV_LOG_ERROR , "bps is unsupported: %d\n" , bps ) ;
 return AVERROR_PATCHWELCOME ;
 }
 is_compressed = ! get_bits1 ( & alac -> gb ) ;
 if ( has_size ) output_samples = get_bits_long ( & alac -> gb , 32 ) ;
 else output_samples = alac -> max_samples_per_frame ;
 if ( ! output_samples || output_samples > alac -> max_samples_per_frame ) {
 av_log ( avctx , AV_LOG_ERROR , "invalid samples per frame: %d\n" , output_samples ) ;
 return AVERROR_INVALIDDATA ;
 }
 if ( ! alac -> nb_samples ) {
 frame -> nb_samples = output_samples ;
 if ( ( ret = ff_get_buffer ( avctx , frame ) ) < 0 ) {
 av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
 return ret ;
 }
 }
 else if ( output_samples != alac -> nb_samples ) {
 av_log ( avctx , AV_LOG_ERROR , "sample count mismatch: %u != %d\n" , output_samples , alac -> nb_samples ) ;
 return AVERROR_INVALIDDATA ;
 }
 alac -> nb_samples = output_samples ;
 if ( alac -> sample_size > 16 ) {
 for ( ch = 0 ;
 ch < channels ;
 ch ++ ) alac -> output_samples_buffer [ ch ] = ( int32_t * ) frame -> extended_data [ ch_index + ch ] ;
 }
 if ( is_compressed ) {
 int16_t lpc_coefs [ 2 ] [ 32 ] ;
 int lpc_order [ 2 ] ;
 int prediction_type [ 2 ] ;
 int lpc_quant [ 2 ] ;
 int rice_history_mult [ 2 ] ;
 decorr_shift = get_bits ( & alac -> gb , 8 ) ;
 decorr_left_weight = get_bits ( & alac -> gb , 8 ) ;
 for ( ch = 0 ;
 ch < channels ;
 ch ++ ) {
 prediction_type [ ch ] = get_bits ( & alac -> gb , 4 ) ;
 lpc_quant [ ch ] = get_bits ( & alac -> gb , 4 ) ;
 rice_history_mult [ ch ] = get_bits ( & alac -> gb , 3 ) ;
 lpc_order [ ch ] = get_bits ( & alac -> gb , 5 ) ;
 for ( i = lpc_order [ ch ] - 1 ;
 i >= 0 ;
 i -- ) lpc_coefs [ ch ] [ i ] = get_sbits ( & alac -> gb , 16 ) ;
 }
 if ( alac -> extra_bits ) {
 for ( i = 0 ;
 i < alac -> nb_samples ;
 i ++ ) {
 for ( ch = 0 ;
 ch < channels ;
 ch ++ ) alac -> extra_bits_buffer [ ch ] [ i ] = get_bits ( & alac -> gb , alac -> extra_bits ) ;
 }
 }
 for ( ch = 0 ;
 ch < channels ;
 ch ++ ) {
 rice_decompress ( alac , alac -> predict_error_buffer [ ch ] , alac -> nb_samples , bps , rice_history_mult [ ch ] * alac -> rice_history_mult / 4 ) ;
 if ( prediction_type [ ch ] == 15 ) {
 lpc_prediction ( alac -> predict_error_buffer [ ch ] , alac -> predict_error_buffer [ ch ] , alac -> nb_samples , bps , NULL , 31 , 0 ) ;
 }
 else if ( prediction_type [ ch ] > 0 ) {
 av_log ( avctx , AV_LOG_WARNING , "unknown prediction type: %i\n" , prediction_type [ ch ] ) ;
 }
 lpc_prediction ( alac -> predict_error_buffer [ ch ] , alac -> output_samples_buffer [ ch ] , alac -> nb_samples , bps , lpc_coefs [ ch ] , lpc_order [ ch ] , lpc_quant [ ch ] ) ;
 }
 }
 else {
 for ( i = 0 ;
 i < alac -> nb_samples ;
 i ++ ) {
 for ( ch = 0 ;
 ch < channels ;
 ch ++ ) {
 alac -> output_samples_buffer [ ch ] [ i ] = get_sbits_long ( & alac -> gb , alac -> sample_size ) ;
 }
 }
 alac -> extra_bits = 0 ;
 decorr_shift = 0 ;
 decorr_left_weight = 0 ;
 }
 if ( channels == 2 && decorr_left_weight ) {
 decorrelate_stereo ( alac -> output_samples_buffer , alac -> nb_samples , decorr_shift , decorr_left_weight ) ;
 }
 if ( alac -> extra_bits ) {
 append_extra_bits ( alac -> output_samples_buffer , alac -> extra_bits_buffer , alac -> extra_bits , channels , alac -> nb_samples ) ;
 }
 switch ( alac -> sample_size ) {
 case 16 : {
 for ( ch = 0 ;
 ch < channels ;
 ch ++ ) {
 int16_t * outbuffer = ( int16_t * ) frame -> extended_data [ ch_index + ch ] ;
 for ( i = 0 ;
 i < alac -> nb_samples ;
 i ++ ) * outbuffer ++ = alac -> output_samples_buffer [ ch ] [ i ] ;
 }
 }
 break ;
 case 24 : {
 for ( ch = 0 ;
 ch < channels ;
 ch ++ ) {
 for ( i = 0 ;
 i < alac -> nb_samples ;
 i ++ ) alac -> output_samples_buffer [ ch ] [ i ] <<= 8 ;
 }
 }
 break ;
 }
 return 0 ;
 }


static int dissect_h225_T_h4501SupplementaryService_item ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
 # line 736 "./asn1/h225/h225.cnf" tvbuff_t * h4501_tvb = NULL ;
 offset = dissect_per_octet_string ( tvb , offset , actx , tree , hf_index , NO_BOUND , NO_BOUND , FALSE , & h4501_tvb ) ;
 if ( h4501_tvb && tvb_reported_length ( h4501_tvb ) ) {
 call_dissector ( h4501_handle , h4501_tvb , actx -> pinfo , tree ) ;
 }
 return offset ;
 }


static void push_output_configuration(AACContext *ac) { if (ac->oc[1].status == OC_LOCKED || ac->oc[0].status == OC_NONE) { ac->oc[0] = ac->oc[1]; } ac->oc[1].status = OC_NONE; }


dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, enum dshowDeviceType devtype, IBaseFilter **pfilter) { struct dshow_ctx *ctx = avctx->priv_data; IBaseFilter *device_filter = NULL; IEnumMoniker *classenum = NULL; IMoniker *m = NULL; const char *device_name = ctx->device_name[devtype]; int r; const GUID *device_guid[2] = { &CLSID_VideoInputDeviceCategory, &CLSID_AudioInputDeviceCategory }; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio"; r = ICreateDevEnum_CreateClassEnumerator(devenum, device_guid[devtype], (IEnumMoniker **) &classenum, 0); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not enumerate %s devices.\n", devtypename); return AVERROR(EIO); } while (IEnumMoniker_Next(classenum, 1, &m, NULL) == S_OK && !device_filter) { IPropertyBag *bag = NULL; char *buf = NULL; VARIANT var; r = IMoniker_BindToStorage(m, 0, 0, &IID_IPropertyBag, (void *) &bag); if (r != S_OK) goto fail1; var.vt = VT_BSTR; r = IPropertyBag_Read(bag, L"FriendlyName", &var, NULL); if (r != S_OK) goto fail1; buf = dup_wchar_to_utf8(var.bstrVal); if (pfilter) { if (strcmp(device_name, buf)) goto fail1; IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void *) &device_filter); } else { av_log(avctx, AV_LOG_INFO, " \"%s\"\n", buf); } fail1: if (buf) av_free(buf); if (bag) IPropertyBag_Release(bag); IMoniker_Release(m); } IEnumMoniker_Release(classenum); if (pfilter) { if (!device_filter) { av_log(avctx, AV_LOG_ERROR, "Could not find %s device.\n", devtypename); return AVERROR(EIO); } *pfilter = device_filter; } return 0; }


int ff_pred_weight_table ( H264Context * h ) {
 int list , i ;
 int luma_def , chroma_def ;
 h -> use_weight = 0 ;
 h -> use_weight_chroma = 0 ;
 h -> luma_log2_weight_denom = get_ue_golomb ( & h -> gb ) ;
 if ( h -> sps . chroma_format_idc ) h -> chroma_log2_weight_denom = get_ue_golomb ( & h -> gb ) ;
 luma_def = 1 << h -> luma_log2_weight_denom ;
 chroma_def = 1 << h -> chroma_log2_weight_denom ;
 for ( list = 0 ;
 list < 2 ;
 list ++ ) {
 h -> luma_weight_flag [ list ] = 0 ;
 h -> chroma_weight_flag [ list ] = 0 ;
 for ( i = 0 ;
 i < h -> ref_count [ list ] ;
 i ++ ) {
 int luma_weight_flag , chroma_weight_flag ;
 luma_weight_flag = get_bits1 ( & h -> gb ) ;
 if ( luma_weight_flag ) {
 h -> luma_weight [ i ] [ list ] [ 0 ] = get_se_golomb ( & h -> gb ) ;
 h -> luma_weight [ i ] [ list ] [ 1 ] = get_se_golomb ( & h -> gb ) ;
 if ( h -> luma_weight [ i ] [ list ] [ 0 ] != luma_def || h -> luma_weight [ i ] [ list ] [ 1 ] != 0 ) {
 h -> use_weight = 1 ;
 h -> luma_weight_flag [ list ] = 1 ;
 }
 }
 else {
 h -> luma_weight [ i ] [ list ] [ 0 ] = luma_def ;
 h -> luma_weight [ i ] [ list ] [ 1 ] = 0 ;
 }
 if ( h -> sps . chroma_format_idc ) {
 chroma_weight_flag = get_bits1 ( & h -> gb ) ;
 if ( chroma_weight_flag ) {
 int j ;
 for ( j = 0 ;
 j < 2 ;
 j ++ ) {
 h -> chroma_weight [ i ] [ list ] [ j ] [ 0 ] = get_se_golomb ( & h -> gb ) ;
 h -> chroma_weight [ i ] [ list ] [ j ] [ 1 ] = get_se_golomb ( & h -> gb ) ;
 if ( h -> chroma_weight [ i ] [ list ] [ j ] [ 0 ] != chroma_def || h -> chroma_weight [ i ] [ list ] [ j ] [ 1 ] != 0 ) {
 h -> use_weight_chroma = 1 ;
 h -> chroma_weight_flag [ list ] = 1 ;
 }
 }
 }
 else {
 int j ;
 for ( j = 0 ;
 j < 2 ;
 j ++ ) {
 h -> chroma_weight [ i ] [ list ] [ j ] [ 0 ] = chroma_def ;
 h -> chroma_weight [ i ] [ list ] [ j ] [ 1 ] = 0 ;
 }
 }
 }
 }
 if ( h -> slice_type_nos != AV_PICTURE_TYPE_B ) break ;
 }
 h -> use_weight = h -> use_weight || h -> use_weight_chroma ;
 return 0 ;
 }


EFI_STATUS verify_image(void *data, unsigned int datasize,
			EFI_LOADED_IMAGE *li,
			PE_COFF_LOADER_IMAGE_CONTEXT *context)
{
	EFI_STATUS efi_status;
	UINT8 sha1hash[SHA1_DIGEST_SIZE];
	UINT8 sha256hash[SHA256_DIGEST_SIZE];

	/*
	 * The binary header contains relevant context and section pointers
	 */
	efi_status = read_header(data, datasize, context);
	if (EFI_ERROR(efi_status)) {
		perror(L"Failed to read header: %r\n", efi_status);
		return efi_status;
	}

	/*
	 * We only need to verify the binary if we're in secure mode
	 */
	efi_status = generate_hash(data, datasize, context, sha256hash,
				   sha1hash);
	if (EFI_ERROR(efi_status))
		return efi_status;

	/* Measure the binary into the TPM */
#ifdef REQUIRE_TPM
	efi_status =
#endif
	tpm_log_pe((EFI_PHYSICAL_ADDRESS)(UINTN)data, datasize,
		   (EFI_PHYSICAL_ADDRESS)(UINTN)context->ImageAddress,
		   li->FilePath, sha1hash, 4);
#ifdef REQUIRE_TPM
	if (efi_status != EFI_SUCCESS) {
		return efi_status;
	}
#endif

	if (secure_mode()) {
		efi_status = verify_buffer(data, datasize,
					   context, sha256hash, sha1hash);
		if (EFI_ERROR(efi_status)) {
			if (verbose)
				console_print(L"Verification failed: %r\n", efi_status);
			else
				console_error(L"Verification failed", efi_status);
			return efi_status;
		} else if (verbose)
			console_print(L"Verification succeeded\n");
	}

	return EFI_SUCCESS;
}


TEST_F ( ProfileInfoCacheTest , GAIAName ) {
 GetCache ( ) -> AddProfileToCache ( GetProfilePath ( "path_1" ) , ASCIIToUTF16 ( "Person 1" ) , base : : string16 ( ) , 0 , std : : string ( ) ) ;
 base : : string16 profile_name ( ASCIIToUTF16 ( "Person 2" ) ) ;
 GetCache ( ) -> AddProfileToCache ( GetProfilePath ( "path_2" ) , profile_name , base : : string16 ( ) , 0 , std : : string ( ) ) ;
 int index1 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( "path_1" ) ) ;
 int index2 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( "path_2" ) ) ;
 EXPECT_TRUE ( GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index1 ) . empty ( ) ) ;
 EXPECT_TRUE ( GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index2 ) . empty ( ) ) ;
 base : : string16 gaia_name ( ASCIIToUTF16 ( "Pat Smith" ) ) ;
 GetCache ( ) -> SetGAIANameOfProfileAtIndex ( index2 , gaia_name ) ;
 index1 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( "path_1" ) ) ;
 index2 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( "path_2" ) ) ;
 EXPECT_TRUE ( GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index1 ) . empty ( ) ) ;
 EXPECT_EQ ( gaia_name , GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index2 ) ) ;
 EXPECT_EQ ( gaia_name , GetCache ( ) -> GetNameOfProfileAtIndex ( index2 ) ) ;
 base : : string16 custom_name ( ASCIIToUTF16 ( "Custom name" ) ) ;
 GetCache ( ) -> SetNameOfProfileAtIndex ( index2 , custom_name ) ;
 GetCache ( ) -> SetProfileIsUsingDefaultNameAtIndex ( index2 , false ) ;
 index1 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( "path_1" ) ) ;
 index2 = GetCache ( ) -> GetIndexOfProfileWithPath ( GetProfilePath ( "path_2" ) ) ;
 EXPECT_EQ ( custom_name , GetCache ( ) -> GetNameOfProfileAtIndex ( index2 ) ) ;
 EXPECT_EQ ( gaia_name , GetCache ( ) -> GetGAIANameOfProfileAtIndex ( index2 ) ) ;
 }


static int h261_decode_mb_skipped ( H261Context * h , int mba1 , int mba2 ) {
 MpegEncContext * const s = & h -> s ;
 int i ;
 s -> mb_intra = 0 ;
 for ( i = mba1 ;
 i < mba2 ;
 i ++ ) {
 int j , xy ;
 s -> mb_x = ( ( h -> gob_number - 1 ) % 2 ) * 11 + i % 11 ;
 s -> mb_y = ( ( h -> gob_number - 1 ) / 2 ) * 3 + i / 11 ;
 xy = s -> mb_x + s -> mb_y * s -> mb_stride ;
 ff_init_block_index ( s ) ;
 ff_update_block_index ( s ) ;
 for ( j = 0 ;
 j < 6 ;
 j ++ ) s -> block_last_index [ j ] = - 1 ;
 s -> mv_dir = MV_DIR_FORWARD ;
 s -> mv_type = MV_TYPE_16X16 ;
 s -> current_picture . f . mb_type [ xy ] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0 ;
 s -> mv [ 0 ] [ 0 ] [ 0 ] = 0 ;
 s -> mv [ 0 ] [ 0 ] [ 1 ] = 0 ;
 s -> mb_skipped = 1 ;
 h -> mtype &= ~ MB_TYPE_H261_FIL ;
 ff_MPV_decode_mb ( s , s -> block ) ;
 }
 return 0 ;
 }


static int coroutine_fn bdrv_co_do_copy_on_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { /* Perform I/O through a temporary buffer so that users who scribble over * their read buffer while the operation is in progress do not end up * modifying the image file. This is critical for zero-copy guest I/O * where anything might happen inside guest memory. */ void *bounce_buffer; BlockDriver *drv = bs->drv; struct iovec iov; QEMUIOVector bounce_qiov; int64_t cluster_sector_num; int cluster_nb_sectors; size_t skip_bytes; int ret; /* Cover entire cluster so no additional backing file I/O is required when * allocating cluster in the image file. */ bdrv_round_to_clusters(bs, sector_num, nb_sectors, &cluster_sector_num, &cluster_nb_sectors); trace_bdrv_co_do_copy_on_readv(bs, sector_num, nb_sectors, cluster_sector_num, cluster_nb_sectors); iov.iov_len = cluster_nb_sectors * BDRV_SECTOR_SIZE; iov.iov_base = bounce_buffer = qemu_blockalign(bs, iov.iov_len); qemu_iovec_init_external(&bounce_qiov, &iov, 1); ret = drv->bdrv_co_readv(bs, cluster_sector_num, cluster_nb_sectors, &bounce_qiov); if (ret < 0) { goto err; } if (drv->bdrv_co_write_zeroes && buffer_is_zero(bounce_buffer, iov.iov_len)) { ret = bdrv_co_do_write_zeroes(bs, cluster_sector_num, cluster_nb_sectors, 0); } else { /* This does not change the data on the disk, it is not necessary * to flush even in cache=writethrough mode. */ ret = drv->bdrv_co_writev(bs, cluster_sector_num, cluster_nb_sectors, &bounce_qiov); } if (ret < 0) { /* It might be okay to ignore write errors for guest requests. If this * is a deliberate copy-on-read then we don't want to ignore the error. * Simply report it in all cases. */ goto err; } skip_bytes = (sector_num - cluster_sector_num) * BDRV_SECTOR_SIZE; qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, nb_sectors * BDRV_SECTOR_SIZE); err: qemu_vfree(bounce_buffer); return ret; }


static int local_create_mapped_attr_dir(FsContext *ctx, const char *path) { int err; char attr_dir[PATH_MAX]; char *tmp_path = strdup(path); snprintf(attr_dir, PATH_MAX, "%s/%s/%s", ctx->fs_root, dirname(tmp_path), VIRTFS_META_DIR); err = mkdir(attr_dir, 0700); if (err < 0 && errno == EEXIST) { err = 0; } free(tmp_path); return err; }


static int openpic_init(SysBusDevice *dev) { OpenPICState *opp = FROM_SYSBUS(typeof (*opp), dev); int i, j; struct memreg list_le[] = { {"glb", &openpic_glb_ops_le, true, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE}, {"tmr", &openpic_tmr_ops_le, true, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE}, {"msi", &openpic_msi_ops_le, true, OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE}, {"src", &openpic_src_ops_le, true, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE}, {"cpu", &openpic_cpu_ops_le, true, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE}, }; struct memreg list_be[] = { {"glb", &openpic_glb_ops_be, true, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE}, {"tmr", &openpic_tmr_ops_be, true, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE}, {"msi", &openpic_msi_ops_be, true, OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE}, {"src", &openpic_src_ops_be, true, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE}, {"cpu", &openpic_cpu_ops_be, true, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE}, }; struct memreg *list; switch (opp->model) { case OPENPIC_MODEL_FSL_MPIC_20: default: opp->flags |= OPENPIC_FLAG_IDE_CRIT; opp->nb_irqs = 80; opp->vid = VID_REVISION_1_2; opp->veni = VENI_GENERIC; opp->vector_mask = 0xFFFF; opp->tifr_reset = 0; opp->ipvp_reset = IPVP_MASK_MASK; opp->ide_reset = 1 << 0; opp->max_irq = FSL_MPIC_20_MAX_IRQ; opp->irq_ipi0 = FSL_MPIC_20_IPI_IRQ; opp->irq_tim0 = FSL_MPIC_20_TMR_IRQ; opp->irq_msi = FSL_MPIC_20_MSI_IRQ; opp->brr1 = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN; msi_supported = true; list = list_be; break; case OPENPIC_MODEL_RAVEN: opp->nb_irqs = RAVEN_MAX_EXT; opp->vid = VID_REVISION_1_3; opp->veni = VENI_GENERIC; opp->vector_mask = 0xFF; opp->tifr_reset = 4160000; opp->ipvp_reset = IPVP_MASK_MASK | IPVP_MODE_MASK; opp->ide_reset = 0; opp->max_irq = RAVEN_MAX_IRQ; opp->irq_ipi0 = RAVEN_IPI_IRQ; opp->irq_tim0 = RAVEN_TMR_IRQ; opp->brr1 = -1; list = list_le; /* Don't map MSI region */ list[2].map = false; /* Only UP supported today */ if (opp->nb_cpus != 1) { return -EINVAL; } break; } memory_region_init(&opp->mem, "openpic", 0x40000); for (i = 0; i < ARRAY_SIZE(list_le); i++) { if (!list[i].map) { continue; } memory_region_init_io(&opp->sub_io_mem[i], list[i].ops, opp, list[i].name, list[i].size); memory_region_add_subregion(&opp->mem, list[i].start_addr, &opp->sub_io_mem[i]); } for (i = 0; i < opp->nb_cpus; i++) { opp->dst[i].irqs = g_new(qemu_irq, OPENPIC_OUTPUT_NB); for (j = 0; j < OPENPIC_OUTPUT_NB; j++) { sysbus_init_irq(dev, &opp->dst[i].irqs[j]); } } register_savevm(&opp->busdev.qdev, "openpic", 0, 2, openpic_save, openpic_load, opp); sysbus_init_mmio(dev, &opp->mem); qdev_init_gpio_in(&dev->qdev, openpic_set_irq, opp->max_irq); return 0; }


QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id) { QemuOpts *opts; TAILQ_FOREACH(opts, &list->head, next) { if (!opts->id) { continue; } if (strcmp(opts->id, id) != 0) { continue; } return opts; } return NULL; }


int remoteRemoveClientStream ( struct qemud_client * client , struct qemud_client_stream * stream ) {
 VIR_DEBUG ( "client=%p proc=%d serial=%d" , client , stream -> procedure , stream -> serial ) ;
 struct qemud_client_stream * curr = client -> streams ;
 struct qemud_client_stream * prev = NULL ;
 struct qemud_client_filter * filter = NULL ;
 if ( client -> filters == & stream -> filter ) {
 client -> filters = client -> filters -> next ;
 }
 else {
 filter = client -> filters ;
 while ( filter ) {
 if ( filter -> next == & stream -> filter ) {
 filter -> next = filter -> next -> next ;
 break ;
 }
 filter = filter -> next ;
 }
 }
 if ( ! stream -> closed ) {
 virStreamEventRemoveCallback ( stream -> st ) ;
 virStreamAbort ( stream -> st ) ;
 }
 while ( curr ) {
 if ( curr == stream ) {
 if ( prev ) prev -> next = curr -> next ;
 else client -> streams = curr -> next ;
 remoteFreeClientStream ( client , stream ) ;
 return 0 ;
 }
 prev = curr ;
 curr = curr -> next ;
 }
 return - 1 ;
 }


static void flush_dpb(AVCodecContext *avctx) { H264Context *h = avctx->priv_data; int i; memset(h->delayed_pic, 0, sizeof(h->delayed_pic)); ff_h264_flush_change(h); if (h->DPB) for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) ff_h264_unref_picture(h, &h->DPB[i]); h->cur_pic_ptr = NULL; ff_h264_unref_picture(h, &h->cur_pic); h->mb_y = 0; ff_h264_free_tables(h); h->context_initialized = 0; }


void auth_server_connection_deinit ( struct auth_server_connection * * _conn ) {
 struct auth_server_connection * conn = * _conn ;
 * _conn = NULL ;
 auth_server_connection_disconnect ( conn , "deinitializing" ) ;
 i_assert ( hash_table_count ( conn -> requests ) == 0 ) ;
 hash_table_destroy ( & conn -> requests ) ;
 array_free ( & conn -> available_auth_mechs ) ;
 pool_unref ( & conn -> pool ) ;
 }


static int load_refcount_block(BlockDriverState *bs, int64_t refcount_block_offset, void **refcount_block) { BDRVQcow2State *s = bs->opaque; int ret; BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD); ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset, refcount_block); return ret; }


static pcp_conv_info_t * get_pcp_conversation_info ( packet_info * pinfo ) {
 conversation_t * conversation ;
 pcp_conv_info_t * pcp_conv_info ;
 conversation = find_conversation ( pinfo -> num , & pinfo -> src , & pinfo -> dst , pinfo -> ptype , pinfo -> srcport , pinfo -> destport , 0 ) ;
 DISSECTOR_ASSERT ( conversation ) ;
 pcp_conv_info = ( pcp_conv_info_t * ) conversation_get_proto_data ( conversation , proto_pcp ) ;
 DISSECTOR_ASSERT ( pcp_conv_info ) ;
 return pcp_conv_info ;
 }


static int usbredir_handle_status(USBRedirDevice *dev, int status, int actual_len) { switch (status) { case usb_redir_success: return actual_len; case usb_redir_stall: return USB_RET_STALL; case usb_redir_cancelled: WARNING("returning cancelled packet to HC?\n"); return USB_RET_NAK; case usb_redir_inval: WARNING("got invalid param error from usb-host?\n"); return USB_RET_NAK; case usb_redir_babble: return USB_RET_BABBLE; case usb_redir_ioerror: case usb_redir_timeout: default: return USB_RET_IOERROR; } }


matroska_ebmlnum_uint (uint8_t *data, uint32_t size, uint64_t *num) { int len_mask = 0x80, read = 1, n = 1, num_ffs = 0; uint64_t total; if (size <= 0) return AVERROR_INVALIDDATA; total = data[0]; while (read <= 8 && !(total & len_mask)) { read++; len_mask >>= 1; } if (read > 8) return AVERROR_INVALIDDATA; if ((total &= (len_mask - 1)) == len_mask - 1) num_ffs++; if (size < read) return AVERROR_INVALIDDATA; while (n < read) { if (data[n] == 0xff) num_ffs++; total = (total << 8) | data[n]; n++; } if (!total) return AVERROR_INVALIDDATA; if (read == num_ffs) *num = (uint64_t)-1; else *num = total; return read; }


void connection_destroy(void *opaque) { Connection *conn = opaque; g_queue_foreach(&conn->primary_list, packet_destroy, NULL); g_queue_free(&conn->primary_list); g_queue_foreach(&conn->secondary_list, packet_destroy, NULL); g_queue_free(&conn->secondary_list); g_slice_free(Connection, conn); }


void TSVConnAbort ( TSVConn connp , int error ) {
 sdk_assert ( sdk_sanity_check_iocore_structure ( connp ) == TS_SUCCESS ) ;
 VConnection * vc = ( VConnection * ) connp ;
 vc -> do_io_close ( error ) ;
 }


static void evhttp_request_dispatch ( struct evhttp_connection * evcon ) {
 struct evhttp_request * req = TAILQ_FIRST ( & evcon -> requests ) ;
 if ( req == NULL ) return ;
 evhttp_connection_stop_detectclose ( evcon ) ;
 assert ( evcon -> state == EVCON_IDLE ) ;
 evcon -> state = EVCON_WRITING ;
 evhttp_make_header ( evcon , req ) ;
 evhttp_write_buffer ( evcon , evhttp_write_connectioncb , NULL ) ;
 }


        void handle()
        {
            // TODO(EDev): cancel_deadline_timer should be looked into, it might be a good idea to add it to handle_url() and then restart the timer once everything passes
            cancel_deadline_timer();
            bool is_invalid_request = false;
            add_keep_alive_ = false;

            req_.remote_ip_address = adaptor_.remote_endpoint().address().to_string();

            add_keep_alive_ = req_.keep_alive;
            close_connection_ = req_.close_connection;

            if (req_.check_version(1, 1)) // HTTP/1.1
            {
                if (!req_.headers.count("host"))
                {
                    is_invalid_request = true;
                    res = response(400);
                }
                if (req_.upgrade)
                {
                    // h2 or h2c headers
                    if (req_.get_header_value("upgrade").substr(0, 2) == "h2")
                    {
                        // TODO(ipkn): HTTP/2
                        // currently, ignore upgrade header
                    }
                    else
                    {
                        close_connection_ = true;
                        handler_->handle_upgrade(req_, res, std::move(adaptor_));
                        return;
                    }
                }
            }

            CROW_LOG_INFO << "Request: " << utility::lexical_cast<std::string>(adaptor_.remote_endpoint()) << " " << this << " HTTP/" << (char)(req_.http_ver_major + '0') << "." << (char)(req_.http_ver_minor + '0') << ' ' << method_name(req_.method) << " " << req_.url;

            need_to_call_after_handlers_ = false;
            if (!is_invalid_request)
            {
                res.complete_request_handler_ = [] {};
                res.is_alive_helper_ = [this]() -> bool {
                    return adaptor_.is_open();
                };

                ctx_ = detail::context<Middlewares...>();
                req_.middleware_context = static_cast<void*>(&ctx_);
                req_.middleware_container = static_cast<void*>(middlewares_);
                req_.io_service = &adaptor_.get_io_service();

                detail::middleware_call_helper<detail::middleware_call_criteria_only_global,
                                               0, decltype(ctx_), decltype(*middlewares_)>({}, *middlewares_, req_, res, ctx_);

                if (!res.completed_)
                {
                    res.complete_request_handler_ = [this] {
                        this->complete_request();
                    };
                    need_to_call_after_handlers_ = true;
                    handler_->handle(req_, res, routing_handle_result_);
                    if (add_keep_alive_)
                        res.set_header("connection", "Keep-Alive");
                }
                else
                {
                    complete_request();
                }
            }
            else
            {
                complete_request();
            }
        }


bool ispidowner ( pid_t pid ) {
 char path [ MAXPATHLEN ] ;
 struct stat sbuf ;
 snprintf ( path , sizeof ( path ) , "/proc/%d" , pid ) ;
 if ( stat ( path , & sbuf ) != 0 ) return ( FALSE ) ;
 if ( getuid ( ) != sbuf . st_uid ) return ( FALSE ) ;
 return ( TRUE ) ;
 }


char *ogs_nas_5gs_suci_from_mobile_identity(
        ogs_nas_5gs_mobile_identity_t *mobile_identity)
{
    ogs_nas_5gs_mobile_identity_suci_t *mobile_identity_suci = NULL;
    ogs_plmn_id_t plmn_id;
    char tmp[OGS_MAX_IMSI_BCD_LEN+1];
    char routing_indicator[5];
    char *suci = NULL;

    ogs_assert(mobile_identity);

    mobile_identity_suci =
        (ogs_nas_5gs_mobile_identity_suci_t *)mobile_identity->buffer;
    ogs_assert(mobile_identity_suci);

    ogs_expect_or_return_val(mobile_identity_suci->h.supi_format ==
            OGS_NAS_5GS_SUPI_FORMAT_IMSI, NULL);
    ogs_expect_or_return_val(mobile_identity_suci->protection_scheme_id ==
            OGS_NAS_5GS_NULL_SCHEME, NULL);

    suci = ogs_msprintf("suci-%d-", mobile_identity_suci->h.supi_format);
    ogs_expect_or_return_val(suci, NULL);

    ogs_nas_to_plmn_id(&plmn_id, &mobile_identity_suci->nas_plmn_id);
    if (ogs_plmn_id_mnc_len(&plmn_id) == 2) {
        suci = ogs_mstrcatf(suci, "%03d-%02d-",
                ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));
        ogs_expect_or_return_val(suci, NULL);
    } else {
        suci = ogs_mstrcatf(suci, "%03d-%03d-",
                ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id));
        ogs_expect_or_return_val(suci, NULL);
    }

    memset(routing_indicator, 0, sizeof(routing_indicator));
    if (mobile_identity_suci->routing_indicator1 != 0xf) {
        routing_indicator[0] =
            mobile_identity_suci->routing_indicator1 + '0';
        if (mobile_identity_suci->routing_indicator2 != 0xf) {
            routing_indicator[1] =
                mobile_identity_suci->routing_indicator2 + '0';
            if (mobile_identity_suci->routing_indicator3 != 0xf) {
                routing_indicator[2] =
                    mobile_identity_suci->routing_indicator3 + '0';
                if (mobile_identity_suci->routing_indicator4 != 0xf)
                    routing_indicator[3] =
                        mobile_identity_suci->routing_indicator4 + '0';
            }
        }
    }

    ogs_expect_or_return_val(mobile_identity->length > 8, NULL);
    ogs_buffer_to_bcd(mobile_identity_suci->scheme_output,
            mobile_identity->length - 8, tmp);

    suci = ogs_mstrcatf(suci, "%s-%d-%d-%s",
            routing_indicator,
            mobile_identity_suci->protection_scheme_id,
            mobile_identity_suci->home_network_pki_value,
            tmp);
    ogs_expect(suci);

    return suci;
}


static int caif_seqpkt_recvmsg(struct kiocb *iocb, struct socket *sock,
				struct msghdr *m, size_t len, int flags)

{
	struct sock *sk = sock->sk;
	struct sk_buff *skb;
	int ret;
	int copylen;

	ret = -EOPNOTSUPP;
	if (m->msg_flags&MSG_OOB)
		goto read_error;

	skb = skb_recv_datagram(sk, flags, 0 , &ret);
	if (!skb)
		goto read_error;
	copylen = skb->len;
	if (len < copylen) {
		m->msg_flags |= MSG_TRUNC;
		copylen = len;
	}

	ret = skb_copy_datagram_iovec(skb, 0, m->msg_iov, copylen);
	if (ret)
		goto out_free;

	ret = (flags & MSG_TRUNC) ? skb->len : copylen;
out_free:
	skb_free_datagram(sk, skb);
	caif_check_flow_release(sk);
	return ret;

read_error:
	return ret;
}


static int proc_drop_privileges ( struct usb_dev_state * ps , void __user * arg ) {
 u32 data ;
 if ( copy_from_user ( & data , arg , sizeof ( data ) ) ) return - EFAULT ;
 ps -> interface_allowed_mask &= data ;
 ps -> privileges_dropped = true ;
 return 0 ;
 }


void object_unparent(Object *obj) { object_ref(obj); if (obj->parent) { object_property_del_child(obj->parent, obj, NULL); } if (obj->class->unparent) { (obj->class->unparent)(obj); } object_unref(obj); }


int msnprintf ( char * buf , size_t bufsiz , const char * fmt , ... ) {
 va_list ap ;
 size_t rc ;
 va_start ( ap , fmt ) ;
 rc = mvsnprintf ( buf , bufsiz , fmt , ap ) ;
 va_end ( ap ) ;
 return rc ;
 }


static int isoent_make_path_table_2 ( struct archive_write * a , struct vdd * vdd , int depth , int * dir_number ) {
 struct isoent * np ;
 struct isoent * * enttbl ;
 struct path_table * pt ;
 int i ;
 pt = & vdd -> pathtbl [ depth ] ;
 if ( pt -> cnt == 0 ) {
 pt -> sorted = NULL ;
 return ( ARCHIVE_OK ) ;
 }
 enttbl = malloc ( pt -> cnt * sizeof ( struct isoent * ) ) ;
 if ( enttbl == NULL ) {
 archive_set_error ( & a -> archive , ENOMEM , "Can't allocate memory" ) ;
 return ( ARCHIVE_FATAL ) ;
 }
 pt -> sorted = enttbl ;
 for ( np = pt -> first ;
 np != NULL ;
 np = np -> ptnext ) * enttbl ++ = np ;
 enttbl = pt -> sorted ;
 switch ( vdd -> vdd_type ) {
 case VDD_PRIMARY : case VDD_ENHANCED : # ifdef __COMPAR_FN_T qsort ( enttbl , pt -> cnt , sizeof ( struct isoent * ) , ( __compar_fn_t ) _compare_path_table ) ;
 # else qsort ( enttbl , pt -> cnt , sizeof ( struct isoent * ) , _compare_path_table ) ;
 # endif break ;
 case VDD_JOLIET : # ifdef __COMPAR_FN_T qsort ( enttbl , pt -> cnt , sizeof ( struct isoent * ) , ( __compar_fn_t ) _compare_path_table_joliet ) ;
 # else qsort ( enttbl , pt -> cnt , sizeof ( struct isoent * ) , _compare_path_table_joliet ) ;
 # endif break ;
 }
 for ( i = 0 ;
 i < pt -> cnt ;
 i ++ ) enttbl [ i ] -> dir_number = ( * dir_number ) ++ ;
 return ( ARCHIVE_OK ) ;
 }


static void segmentation_test_function ( VP8_COMP * cpi ) {
 unsigned char * seg_map ;
 signed char feature_data [ MB_LVL_MAX ] [ MAX_MB_SEGMENTS ] ;
 CHECK_MEM_ERROR ( seg_map , vpx_calloc ( cpi -> common . mb_rows * cpi -> common . mb_cols , 1 ) ) ;
 set_segmentation_map ( cpi , seg_map ) ;
 enable_segmentation ( cpi ) ;
 feature_data [ MB_LVL_ALT_Q ] [ 0 ] = 0 ;
 feature_data [ MB_LVL_ALT_Q ] [ 1 ] = 4 ;
 feature_data [ MB_LVL_ALT_Q ] [ 2 ] = 0 ;
 feature_data [ MB_LVL_ALT_Q ] [ 3 ] = 0 ;
 feature_data [ MB_LVL_ALT_LF ] [ 0 ] = 0 ;
 feature_data [ MB_LVL_ALT_LF ] [ 1 ] = 0 ;
 feature_data [ MB_LVL_ALT_LF ] [ 2 ] = 0 ;
 feature_data [ MB_LVL_ALT_LF ] [ 3 ] = 0 ;
 set_segment_data ( cpi , & feature_data [ 0 ] [ 0 ] , SEGMENT_DELTADATA ) ;
 vpx_free ( seg_map ) ;
 seg_map = 0 ;
 }


IN_PROC_BROWSER_TEST_F ( ContentFaviconDriverTest , ReplaceFaviconWithTouchIconViaJavascript ) {
 ASSERT_TRUE ( embedded_test_server ( ) -> Start ( ) ) ;
 GURL url = embedded_test_server ( ) -> GetURL ( "/favicon/page_change_favicon_type_to_touch_icon_via_js.html" ) ;
 PendingTaskWaiter waiter ( web_contents ( ) ) ;
 waiter . AlsoRequireTitle ( base : : ASCIIToUTF16 ( "OK" ) ) ;
 ui_test_utils : : NavigateToURLWithDisposition ( browser ( ) , url , WindowOpenDisposition : : CURRENT_TAB , ui_test_utils : : BROWSER_TEST_NONE ) ;
 waiter . Wait ( ) ;
 EXPECT_EQ ( nullptr , GetFaviconForPageURL ( url , favicon_base : : IconType : : kFavicon ) . bitmap_data ) ;
 }


static void tgen_brcond(TCGContext *s, TCGType type, TCGCond c, TCGReg r1, TCGArg c2, int c2const, TCGLabel *l) { int cc; if (facilities & FACILITY_GEN_INST_EXT) { bool is_unsigned = is_unsigned_cond(c); bool in_range; S390Opcode opc; cc = tcg_cond_to_s390_cond[c]; if (!c2const) { opc = (type == TCG_TYPE_I32 ? (is_unsigned ? RIE_CLRJ : RIE_CRJ) : (is_unsigned ? RIE_CLGRJ : RIE_CGRJ)); tgen_compare_branch(s, opc, cc, r1, c2, l); return; } /* COMPARE IMMEDIATE AND BRANCH RELATIVE has an 8-bit immediate field. If the immediate we've been given does not fit that range, we'll fall back to separate compare and branch instructions using the larger comparison range afforded by COMPARE IMMEDIATE. */ if (type == TCG_TYPE_I32) { if (is_unsigned) { opc = RIE_CLIJ; in_range = (uint32_t)c2 == (uint8_t)c2; } else { opc = RIE_CIJ; in_range = (int32_t)c2 == (int8_t)c2; } } else { if (is_unsigned) { opc = RIE_CLGIJ; in_range = (uint64_t)c2 == (uint8_t)c2; } else { opc = RIE_CGIJ; in_range = (int64_t)c2 == (int8_t)c2; } } if (in_range) { tgen_compare_imm_branch(s, opc, cc, r1, c2, l); return; } } cc = tgen_cmp(s, type, c, r1, c2, c2const, false); tgen_branch(s, cc, l); }


static int dissect_rsl_ie_ch_id ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , int offset , gboolean is_mandatory ) {
 proto_item * ti ;
 proto_tree * ie_tree ;
 guint8 length ;
 int ie_offset ;
 guint8 ie_id ;
 if ( is_mandatory == FALSE ) {
 ie_id = tvb_get_guint8 ( tvb , offset ) ;
 if ( ie_id != RSL_IE_CH_ID ) return offset ;
 }
 ie_tree = proto_tree_add_subtree ( tree , tvb , offset , 0 , ett_ie_ch_id , & ti , "Channel Identification IE" ) ;
 proto_tree_add_item ( ie_tree , hf_rsl_ie_id , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
 offset ++ ;
 length = tvb_get_guint8 ( tvb , offset ) ;
 proto_item_set_len ( ti , length + 2 ) ;
 proto_tree_add_item ( ie_tree , hf_rsl_ie_length , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
 offset ++ ;
 ie_offset = offset ;
 proto_tree_add_item ( ie_tree , hf_rsl_channel_description_tag , tvb , offset , 1 , ENC_NA ) ;
 de_rr_ch_dsc ( tvb , ie_tree , pinfo , offset + 1 , length , NULL , 0 ) ;
 offset += 4 ;
 proto_tree_add_item ( ie_tree , hf_rsl_mobile_allocation_tag , tvb , offset , 2 , ENC_NA ) ;
 return ie_offset + length ;
 }


TSReturnCode sdk_sanity_check_field_handle ( TSMLoc field , TSMLoc parent_hdr = nullptr ) {
 if ( field == TS_NULL_MLOC ) {
 return TS_ERROR ;
 }
 MIMEFieldSDKHandle * field_handle = ( MIMEFieldSDKHandle * ) field ;
 if ( field_handle -> m_type != HDR_HEAP_OBJ_FIELD_SDK_HANDLE ) {
 return TS_ERROR ;
 }
 if ( parent_hdr != nullptr ) {
 MIMEHdrImpl * mh = _hdr_mloc_to_mime_hdr_impl ( parent_hdr ) ;
 if ( field_handle -> mh != mh ) {
 return TS_ERROR ;
 }
 }
 return TS_SUCCESS ;
 }


static int exec_close(MigrationState *s) { int ret = 0; DPRINTF("exec_close\n"); ret = qemu_fclose(s->opaque); s->opaque = NULL; s->fd = -1; if (ret >= 0 && !(WIFEXITED(ret) && WEXITSTATUS(ret) == 0)) { /* close succeeded, but non-zero exit code: */ ret = -EIO; /* fake errno value */ } return ret; }


process_request(isc_httpd_t *httpd, isc_region_t *region, size_t *buflen) {
	char *s = NULL, *p = NULL, *urlend = NULL;
	size_t limit = sizeof(httpd->recvbuf) - httpd->recvlen - 1;
	size_t len = region->length;
	int delim;
	bool truncated = false;

	if (len > limit) {
		len = limit;
		truncated = true;
	}

	if (len > 0U) {
		if (httpd->truncated) {
			return (ISC_R_NOSPACE);
		}
		memmove(httpd->recvbuf + httpd->recvlen, region->base, len);
		httpd->recvlen += len;
		httpd->recvbuf[httpd->recvlen] = 0;
		isc_region_consume(region, len);
	}
	if (truncated) {
		httpd->truncated = true;
	}
	httpd->headers = NULL;
	*buflen = httpd->recvlen;

	/*
	 * If we don't find a blank line in our buffer, return that we need
	 * more data.
	 */
	s = strstr(httpd->recvbuf, "\r\n\r\n");
	delim = 2;
	if (s == NULL) {
		s = strstr(httpd->recvbuf, "\n\n");
		delim = 1;
		if (s == NULL) {
			return (httpd->truncated ? ISC_R_NOSPACE
						 : ISC_R_NOTFOUND);
		}
		httpd->consume = s + 2 - httpd->recvbuf;
	} else {
		httpd->consume = s + 4 - httpd->recvbuf;
	}

	/*
	 * NULL terminate the request at the blank line.
	 */
	s[delim] = 0;

	/*
	 * Determine if this is a POST or GET method.  Any other values will
	 * cause an error to be returned.
	 */
	if (strncmp(httpd->recvbuf, "GET ", 4) == 0) {
		httpd->method = METHOD_GET;
		p = httpd->recvbuf + 4;
	} else if (strncmp(httpd->recvbuf, "POST ", 5) == 0) {
		httpd->method = METHOD_POST;
		p = httpd->recvbuf + 5;
	} else {
		return (ISC_R_RANGE);
	}

	/*
	 * From now on, p is the start of our buffer.
	 */

	/*
	 * Extract the URL.
	 */
	s = p;
	while (LENGTHOK(s) && BUFLENOK(s) &&
	       (*s != '\n' && *s != '\r' && *s != '\0' && *s != ' '))
	{
		s++;
	}
	if (!LENGTHOK(s)) {
		return (ISC_R_NOTFOUND);
	}
	if (!BUFLENOK(s)) {
		return (ISC_R_NOMEMORY);
	}
	urlend = s;

	/*
	 * Make the URL relative.
	 */
	if (strncmp(p, "http://", 7) == 0 || strncmp(p, "https://", 8) == 0) {
		/* Skip first '/' */
		while (*p != '/' && *p != 0) {
			p++;
		}
		if (*p == 0) {
			return (ISC_R_RANGE);
		}
		p++;
		/* Skip second '/' */
		while (*p != '/' && *p != 0) {
			p++;
		}
		if (*p == 0) {
			return (ISC_R_RANGE);
		}
		p++;
		/* Find third '/' */
		while (*p != '/' && *p != 0) {
			p++;
		}
		if (*p == 0) {
			p--;
			*p = '/';
		}
	}

	httpd->url = p;
	p = s + 1;
	s = p;

	/*
	 * Now, see if there is a question mark in the URL.  If so, this is
	 * part of the query string, and we will split it from the URL.
	 */
	httpd->querystring = strchr(httpd->url, '?');
	if (httpd->querystring != NULL) {
		*(httpd->querystring) = 0;
		httpd->querystring++;
	}

	/*
	 * Extract the HTTP/1.X protocol.  We will bounce on anything but
	 * HTTP/1.0 or HTTP/1.1 for now.
	 */
	while (LENGTHOK(s) && BUFLENOK(s) &&
	       (*s != '\n' && *s != '\r' && *s != '\0')) {
		s++;
	}
	if (!LENGTHOK(s)) {
		return (ISC_R_NOTFOUND);
	}
	if (!BUFLENOK(s)) {
		return (ISC_R_NOMEMORY);
	}
	/*
	 * Check that we have the expected eol delimiter.
	 */
	if (strncmp(s, delim == 1 ? "\n" : "\r\n", delim) != 0) {
		return (ISC_R_RANGE);
	}
	*s = 0;
	if ((strncmp(p, "HTTP/1.0", 8) != 0) &&
	    (strncmp(p, "HTTP/1.1", 8) != 0)) {
		return (ISC_R_RANGE);
	}
	httpd->protocol = p;
	p = s + delim; /* skip past eol */
	s = p;

	httpd->headers = s;

	if (have_header(httpd, "Connection:", "close", ", \t\r\n", NULL)) {
		httpd->flags |= HTTPD_CLOSE;
	}

	if (have_header(httpd, "Host:", NULL, NULL, NULL)) {
		httpd->flags |= HTTPD_FOUNDHOST;
	}

	if (strncmp(httpd->protocol, "HTTP/1.0", 8) == 0) {
		if (have_header(httpd, "Connection:", "Keep-Alive", ", \t\r\n",
				NULL)) {
			httpd->flags |= HTTPD_KEEPALIVE;
		} else {
			httpd->flags |= HTTPD_CLOSE;
		}
	}

	/*
	 * Check for Accept-Encoding:
	 */
#ifdef HAVE_ZLIB
	if (have_header(httpd, "Accept-Encoding:", "deflate", ";, \t\r\n",
			NULL)) {
		httpd->flags |= HTTPD_ACCEPT_DEFLATE;
	}
#endif /* ifdef HAVE_ZLIB */

	/*
	 * Standards compliance hooks here.
	 */
	if (strcmp(httpd->protocol, "HTTP/1.1") == 0 &&
	    ((httpd->flags & HTTPD_FOUNDHOST) == 0))
	{
		return (ISC_R_RANGE);
	}

	/*
	 * Looks like a a valid request, so now we know we won't have
	 * to process this buffer again. We can NULL-terminate the
	 * URL for the caller's benefit, and set recvlen to 0 so
	 * the next read will overwrite this one instead of appending
	 * to the buffer.
	 */
	*urlend = 0;

	return (ISC_R_SUCCESS);
}


static void count_file ( GFileInfo * info , CommonJob * job , SourceInfo * source_info ) {
 source_info -> num_files += 1 ;
 source_info -> num_bytes += g_file_info_get_size ( info ) ;
 if ( source_info -> num_files_since_progress ++ > 100 ) {
 report_preparing_count_progress ( job , source_info ) ;
 source_info -> num_files_since_progress = 0 ;
 }
 }


static int selinux_inode_mknod ( struct inode * dir , struct dentry * dentry , umode_t mode , dev_t dev ) {
 return may_create ( dir , dentry , inode_mode_to_security_class ( mode ) ) ;
 }


static int decode_band_types(AACContext *ac, enum BandType band_type[120], int band_type_run_end[120], GetBitContext *gb, IndividualChannelStream *ics) { int g, idx = 0; const int bits = (ics->window_sequence[0] == EIGHT_SHORT_SEQUENCE) ? 3 : 5; for (g = 0; g < ics->num_window_groups; g++) { int k = 0; while (k < ics->max_sfb) { uint8_t sect_end = k; int sect_len_incr; int sect_band_type = get_bits(gb, 4); if (sect_band_type == 12) { av_log(ac->avctx, AV_LOG_ERROR, "invalid band type\n"); return -1; } do { sect_len_incr = get_bits(gb, bits); sect_end += sect_len_incr; if (get_bits_left(gb) < 0) { av_log(ac->avctx, AV_LOG_ERROR, overread_err); return -1; } if (sect_end > ics->max_sfb) { av_log(ac->avctx, AV_LOG_ERROR, "Number of bands (%d) exceeds limit (%d).\n", sect_end, ics->max_sfb); return -1; } } while (sect_len_incr == (1 << bits) - 1); for (; k < sect_end; k++) { band_type [idx] = sect_band_type; band_type_run_end[idx++] = sect_end; } } } return 0; }


int ff_hevc_decode_nal_sps(HEVCContext *s) { const AVPixFmtDescriptor *desc; GetBitContext *gb = &s->HEVClc->gb; int ret = 0; unsigned int sps_id = 0; int log2_diff_max_min_transform_block_size; int bit_depth_chroma, start, vui_present, sublayer_ordering_info; int i; HEVCSPS *sps; AVBufferRef *sps_buf = av_buffer_allocz(sizeof(*sps)); if (!sps_buf) return AVERROR(ENOMEM); sps = (HEVCSPS*)sps_buf->data; av_log(s->avctx, AV_LOG_DEBUG, "Decoding SPS\n"); // Coded parameters sps->vps_id = get_bits(gb, 4); if (sps->vps_id >= MAX_VPS_COUNT) { av_log(s->avctx, AV_LOG_ERROR, "VPS id out of range: %d\n", sps->vps_id); ret = AVERROR_INVALIDDATA; goto err; } if (!s->vps_list[sps->vps_id]) { av_log(s->avctx, AV_LOG_ERROR, "VPS %d does not exist\n", sps->vps_id); ret = AVERROR_INVALIDDATA; goto err; } sps->max_sub_layers = get_bits(gb, 3) + 1; if (sps->max_sub_layers > MAX_SUB_LAYERS) { av_log(s->avctx, AV_LOG_ERROR, "sps_max_sub_layers out of range: %d\n", sps->max_sub_layers); ret = AVERROR_INVALIDDATA; goto err; } skip_bits1(gb); // temporal_id_nesting_flag if (parse_ptl(s, &sps->ptl, sps->max_sub_layers) < 0) goto err; sps_id = get_ue_golomb_long(gb); if (sps_id >= MAX_SPS_COUNT) { av_log(s->avctx, AV_LOG_ERROR, "SPS id out of range: %d\n", sps_id); ret = AVERROR_INVALIDDATA; goto err; } sps->chroma_format_idc = get_ue_golomb_long(gb); if (sps->chroma_format_idc == 3) sps->separate_colour_plane_flag = get_bits1(gb); if (sps->separate_colour_plane_flag) sps->chroma_format_idc = 0; sps->width = get_ue_golomb_long(gb); sps->height = get_ue_golomb_long(gb); if ((ret = av_image_check_size(sps->width, sps->height, 0, s->avctx)) < 0) goto err; if (get_bits1(gb)) { // pic_conformance_flag //TODO: * 2 is only valid for 420 sps->pic_conf_win.left_offset = get_ue_golomb_long(gb) * 2; sps->pic_conf_win.right_offset = get_ue_golomb_long(gb) * 2; sps->pic_conf_win.top_offset = get_ue_golomb_long(gb) * 2; sps->pic_conf_win.bottom_offset = get_ue_golomb_long(gb) * 2; if (s->avctx->flags2 & CODEC_FLAG2_IGNORE_CROP) { av_log(s->avctx, AV_LOG_DEBUG, "discarding sps conformance window, " "original values are l:%u r:%u t:%u b:%u\n", sps->pic_conf_win.left_offset, sps->pic_conf_win.right_offset, sps->pic_conf_win.top_offset, sps->pic_conf_win.bottom_offset); sps->pic_conf_win.left_offset = sps->pic_conf_win.right_offset = sps->pic_conf_win.top_offset = sps->pic_conf_win.bottom_offset = 0; } sps->output_window = sps->pic_conf_win; } sps->bit_depth = get_ue_golomb_long(gb) + 8; bit_depth_chroma = get_ue_golomb_long(gb) + 8; if (sps->chroma_format_idc && bit_depth_chroma != sps->bit_depth) { av_log(s->avctx, AV_LOG_ERROR, "Luma bit depth (%d) is different from chroma bit depth (%d), " "this is unsupported.\n", sps->bit_depth, bit_depth_chroma); ret = AVERROR_INVALIDDATA; goto err; } switch (sps->bit_depth) { case 8: if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY8; if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P; if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P; if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P; break; case 9: if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY16; if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P9; if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P9; if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P9; break; case 10: if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY16; if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P10; if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P10; if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P10; break; case 12: if (sps->chroma_format_idc == 0) sps->pix_fmt = AV_PIX_FMT_GRAY16; if (sps->chroma_format_idc == 1) sps->pix_fmt = AV_PIX_FMT_YUV420P12; if (sps->chroma_format_idc == 2) sps->pix_fmt = AV_PIX_FMT_YUV422P12; if (sps->chroma_format_idc == 3) sps->pix_fmt = AV_PIX_FMT_YUV444P12; break; default: av_log(s->avctx, AV_LOG_ERROR, "4:2:0, 4:2:2, 4:4:4 supports are currently specified for 8, 10 and 12 bits.\n"); ret = AVERROR_PATCHWELCOME; goto err; } desc = av_pix_fmt_desc_get(sps->pix_fmt); if (!desc) { ret = AVERROR(EINVAL); goto err; } sps->hshift[0] = sps->vshift[0] = 0; sps->hshift[2] = sps->hshift[1] = desc->log2_chroma_w; sps->vshift[2] = sps->vshift[1] = desc->log2_chroma_h; sps->pixel_shift = sps->bit_depth > 8; sps->log2_max_poc_lsb = get_ue_golomb_long(gb) + 4; if (sps->log2_max_poc_lsb > 16) { av_log(s->avctx, AV_LOG_ERROR, "log2_max_pic_order_cnt_lsb_minus4 out range: %d\n", sps->log2_max_poc_lsb - 4); ret = AVERROR_INVALIDDATA; goto err; } sublayer_ordering_info = get_bits1(gb); start = sublayer_ordering_info ? 0 : sps->max_sub_layers - 1; for (i = start; i < sps->max_sub_layers; i++) { sps->temporal_layer[i].max_dec_pic_buffering = get_ue_golomb_long(gb) + 1; sps->temporal_layer[i].num_reorder_pics = get_ue_golomb_long(gb); sps->temporal_layer[i].max_latency_increase = get_ue_golomb_long(gb) - 1; if (sps->temporal_layer[i].max_dec_pic_buffering > MAX_DPB_SIZE) { av_log(s->avctx, AV_LOG_ERROR, "sps_max_dec_pic_buffering_minus1 out of range: %d\n", sps->temporal_layer[i].max_dec_pic_buffering - 1); ret = AVERROR_INVALIDDATA; goto err; } if (sps->temporal_layer[i].num_reorder_pics > sps->temporal_layer[i].max_dec_pic_buffering - 1) { av_log(s->avctx, AV_LOG_WARNING, "sps_max_num_reorder_pics out of range: %d\n", sps->temporal_layer[i].num_reorder_pics); if (s->avctx->err_recognition & AV_EF_EXPLODE || sps->temporal_layer[i].num_reorder_pics > MAX_DPB_SIZE - 1) { ret = AVERROR_INVALIDDATA; goto err; } sps->temporal_layer[i].max_dec_pic_buffering = sps->temporal_layer[i].num_reorder_pics + 1; } } if (!sublayer_ordering_info) { for (i = 0; i < start; i++) { sps->temporal_layer[i].max_dec_pic_buffering = sps->temporal_layer[start].max_dec_pic_buffering; sps->temporal_layer[i].num_reorder_pics = sps->temporal_layer[start].num_reorder_pics; sps->temporal_layer[i].max_latency_increase = sps->temporal_layer[start].max_latency_increase; } } sps->log2_min_cb_size = get_ue_golomb_long(gb) + 3; sps->log2_diff_max_min_coding_block_size = get_ue_golomb_long(gb); sps->log2_min_tb_size = get_ue_golomb_long(gb) + 2; log2_diff_max_min_transform_block_size = get_ue_golomb_long(gb); sps->log2_max_trafo_size = log2_diff_max_min_transform_block_size + sps->log2_min_tb_size; if (sps->log2_min_tb_size >= sps->log2_min_cb_size) { av_log(s->avctx, AV_LOG_ERROR, "Invalid value for log2_min_tb_size"); ret = AVERROR_INVALIDDATA; goto err; } sps->max_transform_hierarchy_depth_inter = get_ue_golomb_long(gb); sps->max_transform_hierarchy_depth_intra = get_ue_golomb_long(gb); sps->scaling_list_enable_flag = get_bits1(gb); if (sps->scaling_list_enable_flag) { set_default_scaling_list_data(&sps->scaling_list); if (get_bits1(gb)) { ret = scaling_list_data(s, &sps->scaling_list, sps); if (ret < 0) goto err; } } sps->amp_enabled_flag = get_bits1(gb); sps->sao_enabled = get_bits1(gb); sps->pcm_enabled_flag = get_bits1(gb); if (sps->pcm_enabled_flag) { sps->pcm.bit_depth = get_bits(gb, 4) + 1; sps->pcm.bit_depth_chroma = get_bits(gb, 4) + 1; sps->pcm.log2_min_pcm_cb_size = get_ue_golomb_long(gb) + 3; sps->pcm.log2_max_pcm_cb_size = sps->pcm.log2_min_pcm_cb_size + get_ue_golomb_long(gb); if (sps->pcm.bit_depth > sps->bit_depth) { av_log(s->avctx, AV_LOG_ERROR, "PCM bit depth (%d) is greater than normal bit depth (%d)\n", sps->pcm.bit_depth, sps->bit_depth); ret = AVERROR_INVALIDDATA; goto err; } sps->pcm.loop_filter_disable_flag = get_bits1(gb); } sps->nb_st_rps = get_ue_golomb_long(gb); if (sps->nb_st_rps > MAX_SHORT_TERM_RPS_COUNT) { av_log(s->avctx, AV_LOG_ERROR, "Too many short term RPS: %d.\n", sps->nb_st_rps); ret = AVERROR_INVALIDDATA; goto err; } for (i = 0; i < sps->nb_st_rps; i++) { if ((ret = ff_hevc_decode_short_term_rps(s, &sps->st_rps[i], sps, 0)) < 0) goto err; } sps->long_term_ref_pics_present_flag = get_bits1(gb); if (sps->long_term_ref_pics_present_flag) { sps->num_long_term_ref_pics_sps = get_ue_golomb_long(gb); if (sps->num_long_term_ref_pics_sps > 31U) { av_log(s->avctx, AV_LOG_ERROR, "num_long_term_ref_pics_sps %d is out of range.\n", sps->num_long_term_ref_pics_sps); goto err; } for (i = 0; i < sps->num_long_term_ref_pics_sps; i++) { sps->lt_ref_pic_poc_lsb_sps[i] = get_bits(gb, sps->log2_max_poc_lsb); sps->used_by_curr_pic_lt_sps_flag[i] = get_bits1(gb); } } sps->sps_temporal_mvp_enabled_flag = get_bits1(gb); sps->sps_strong_intra_smoothing_enable_flag = get_bits1(gb); sps->vui.sar = (AVRational){0, 1}; vui_present = get_bits1(gb); if (vui_present) decode_vui(s, sps); if (get_bits1(gb)) { // sps_extension_flag int sps_extension_flag[1]; for (i = 0; i < 1; i++) sps_extension_flag[i] = get_bits1(gb); skip_bits(gb, 7); //sps_extension_7bits = get_bits(gb, 7); if (sps_extension_flag[0]) { int extended_precision_processing_flag; int high_precision_offsets_enabled_flag; int cabac_bypass_alignment_enabled_flag; sps->transform_skip_rotation_enabled_flag = get_bits1(gb); sps->transform_skip_context_enabled_flag = get_bits1(gb); sps->implicit_rdpcm_enabled_flag = get_bits1(gb); sps->explicit_rdpcm_enabled_flag = get_bits1(gb); extended_precision_processing_flag = get_bits1(gb); if (extended_precision_processing_flag) av_log(s->avctx, AV_LOG_WARNING, "extended_precision_processing_flag not yet implemented\n"); sps->intra_smoothing_disabled_flag = get_bits1(gb); high_precision_offsets_enabled_flag = get_bits1(gb); if (high_precision_offsets_enabled_flag) av_log(s->avctx, AV_LOG_WARNING, "high_precision_offsets_enabled_flag not yet implemented\n"); sps->persistent_rice_adaptation_enabled_flag = get_bits1(gb); cabac_bypass_alignment_enabled_flag = get_bits1(gb); if (cabac_bypass_alignment_enabled_flag) av_log(s->avctx, AV_LOG_WARNING, "cabac_bypass_alignment_enabled_flag not yet implemented\n"); } } if (s->apply_defdispwin) { sps->output_window.left_offset += sps->vui.def_disp_win.left_offset; sps->output_window.right_offset += sps->vui.def_disp_win.right_offset; sps->output_window.top_offset += sps->vui.def_disp_win.top_offset; sps->output_window.bottom_offset += sps->vui.def_disp_win.bottom_offset; } if (sps->output_window.left_offset & (0x1F >> (sps->pixel_shift)) && !(s->avctx->flags & CODEC_FLAG_UNALIGNED)) { sps->output_window.left_offset &= ~(0x1F >> (sps->pixel_shift)); av_log(s->avctx, AV_LOG_WARNING, "Reducing left output window to %d " "chroma samples to preserve alignment.\n", sps->output_window.left_offset); } sps->output_width = sps->width - (sps->output_window.left_offset + sps->output_window.right_offset); sps->output_height = sps->height - (sps->output_window.top_offset + sps->output_window.bottom_offset); if (sps->output_width <= 0 || sps->output_height <= 0) { av_log(s->avctx, AV_LOG_WARNING, "Invalid visible frame dimensions: %dx%d.\n", sps->output_width, sps->output_height); if (s->avctx->err_recognition & AV_EF_EXPLODE) { ret = AVERROR_INVALIDDATA; goto err; } av_log(s->avctx, AV_LOG_WARNING, "Displaying the whole video surface.\n"); memset(&sps->pic_conf_win, 0, sizeof(sps->pic_conf_win)); memset(&sps->output_window, 0, sizeof(sps->output_window)); sps->output_width = sps->width; sps->output_height = sps->height; } // Inferred parameters sps->log2_ctb_size = sps->log2_min_cb_size + sps->log2_diff_max_min_coding_block_size; sps->log2_min_pu_size = sps->log2_min_cb_size - 1; sps->ctb_width = (sps->width + (1 << sps->log2_ctb_size) - 1) >> sps->log2_ctb_size; sps->ctb_height = (sps->height + (1 << sps->log2_ctb_size) - 1) >> sps->log2_ctb_size; sps->ctb_size = sps->ctb_width * sps->ctb_height; sps->min_cb_width = sps->width >> sps->log2_min_cb_size; sps->min_cb_height = sps->height >> sps->log2_min_cb_size; sps->min_tb_width = sps->width >> sps->log2_min_tb_size; sps->min_tb_height = sps->height >> sps->log2_min_tb_size; sps->min_pu_width = sps->width >> sps->log2_min_pu_size; sps->min_pu_height = sps->height >> sps->log2_min_pu_size; sps->tb_mask = (1 << (sps->log2_ctb_size - sps->log2_min_tb_size)) - 1; sps->qp_bd_offset = 6 * (sps->bit_depth - 8); if (sps->width & ((1 << sps->log2_min_cb_size) - 1) || sps->height & ((1 << sps->log2_min_cb_size) - 1)) { av_log(s->avctx, AV_LOG_ERROR, "Invalid coded frame dimensions.\n"); goto err; } if (sps->log2_ctb_size > MAX_LOG2_CTB_SIZE) { av_log(s->avctx, AV_LOG_ERROR, "CTB size out of range: 2^%d\n", sps->log2_ctb_size); goto err; } if (sps->max_transform_hierarchy_depth_inter > sps->log2_ctb_size - sps->log2_min_tb_size) { av_log(s->avctx, AV_LOG_ERROR, "max_transform_hierarchy_depth_inter out of range: %d\n", sps->max_transform_hierarchy_depth_inter); goto err; } if (sps->max_transform_hierarchy_depth_intra > sps->log2_ctb_size - sps->log2_min_tb_size) { av_log(s->avctx, AV_LOG_ERROR, "max_transform_hierarchy_depth_intra out of range: %d\n", sps->max_transform_hierarchy_depth_intra); goto err; } if (sps->log2_max_trafo_size > FFMIN(sps->log2_ctb_size, 5)) { av_log(s->avctx, AV_LOG_ERROR, "max transform block size out of range: %d\n", sps->log2_max_trafo_size); goto err; } if (get_bits_left(gb) < 0) { av_log(s->avctx, AV_LOG_ERROR, "Overread SPS by %d bits\n", -get_bits_left(gb)); goto err; } if (s->avctx->debug & FF_DEBUG_BITSTREAM) { av_log(s->avctx, AV_LOG_DEBUG, "Parsed SPS: id %d; coded wxh: %dx%d; " "cropped wxh: %dx%d; pix_fmt: %s.\n", sps_id, sps->width, sps->height, sps->output_width, sps->output_height, av_get_pix_fmt_name(sps->pix_fmt)); } /* check if this is a repeat of an already parsed SPS, then keep the * original one. * otherwise drop all PPSes that depend on it */ if (s->sps_list[sps_id] && !memcmp(s->sps_list[sps_id]->data, sps_buf->data, sps_buf->size)) { av_buffer_unref(&sps_buf); } else { for (i = 0; i < FF_ARRAY_ELEMS(s->pps_list); i++) { if (s->pps_list[i] && ((HEVCPPS*)s->pps_list[i]->data)->sps_id == sps_id) av_buffer_unref(&s->pps_list[i]); } if (s->sps_list[sps_id] && s->sps == (HEVCSPS*)s->sps_list[sps_id]->data) { av_buffer_unref(&s->current_sps); s->current_sps = av_buffer_ref(s->sps_list[sps_id]); if (!s->current_sps) s->sps = NULL; } av_buffer_unref(&s->sps_list[sps_id]); s->sps_list[sps_id] = sps_buf; } return 0; err: av_buffer_unref(&sps_buf); return ret; }


void HELPER(ove)(CPUOpenRISCState *env, target_ulong test) { if (unlikely(test)) { OpenRISCCPU *cpu = openrisc_env_get_cpu(env); CPUState *cs = CPU(cpu); cs->exception_index = EXCP_RANGE; cpu_loop_exit_restore(cs, GETPC()); } }


static int64_t qemu_icount_round ( int64_t count ) {
 return ( count + ( 1 << icount_time_shift ) - 1 ) >> icount_time_shift ;
 }