void s390_ipl_prepare_cpu(S390CPU *cpu) { S390IPLState *ipl = get_ipl_device(); cpu->env.psw.addr = ipl->start_addr; cpu->env.psw.mask = IPL_PSW_MASK; if (!ipl->kernel || ipl->iplb_valid) { cpu->env.psw.addr = ipl->bios_start_addr; if (!ipl->iplb_valid) { ipl->iplb_valid = s390_gen_initial_iplb(ipl); } } if (ipl->netboot) { if (load_netboot_image(&err) < 0) { error_report_err(err); vm_stop(RUN_STATE_INTERNAL_ERROR); } ipl->iplb.ccw.netboot_start_addr = ipl->start_addr; } }


static void rtas_ibm_os_term(PowerPCCPU *cpu, sPAPRMachineState *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { target_ulong ret = 0; qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); rtas_st(rets, 0, ret); }


static Image * ReadARTImage ( const ImageInfo * image_info , ExceptionInfo * exception ) {
 const unsigned char * pixels ;
 Image * image ;
 QuantumInfo * quantum_info ;
 QuantumType quantum_type ;
 MagickBooleanType status ;
 size_t length ;
 ssize_t count , y ;
 assert ( image_info != ( const ImageInfo * ) NULL ) ;
 assert ( image_info -> signature == MagickSignature ) ;
 if ( image_info -> debug != MagickFalse ) ( void ) LogMagickEvent ( TraceEvent , GetMagickModule ( ) , "%s" , image_info -> filename ) ;
 assert ( exception != ( ExceptionInfo * ) NULL ) ;
 assert ( exception -> signature == MagickSignature ) ;
 image = AcquireImage ( image_info ) ;
 status = OpenBlob ( image_info , image , ReadBinaryBlobMode , exception ) ;
 if ( status == MagickFalse ) {
 image = DestroyImageList ( image ) ;
 return ( ( Image * ) NULL ) ;
 }
 image -> depth = 1 ;
 image -> endian = MSBEndian ;
 ( void ) ReadBlobLSBShort ( image ) ;
 image -> columns = ( size_t ) ReadBlobLSBShort ( image ) ;
 ( void ) ReadBlobLSBShort ( image ) ;
 image -> rows = ( size_t ) ReadBlobLSBShort ( image ) ;
 if ( ( image -> columns == 0 ) || ( image -> rows == 0 ) ) ThrowReaderException ( CorruptImageError , "ImproperImageHeader" ) ;
 if ( AcquireImageColormap ( image , 2 ) == MagickFalse ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ;
 if ( image_info -> ping != MagickFalse ) {
 ( void ) CloseBlob ( image ) ;
 return ( GetFirstImageInList ( image ) ) ;
 }
 status = SetImageExtent ( image , image -> columns , image -> rows ) ;
 if ( status == MagickFalse ) {
 InheritException ( exception , & image -> exception ) ;
 return ( DestroyImageList ( image ) ) ;
 }
 SetImageColorspace ( image , GRAYColorspace ) ;
 quantum_type = IndexQuantum ;
 quantum_info = AcquireQuantumInfo ( image_info , image ) ;
 if ( quantum_info == ( QuantumInfo * ) NULL ) ThrowReaderException ( ResourceLimitError , "MemoryAllocationFailed" ) ;
 length = GetQuantumExtent ( image , quantum_info , quantum_type ) ;
 for ( y = 0 ;
 y < ( ssize_t ) image -> rows ;
 y ++ ) {
 register PixelPacket * magick_restrict q ;
 q = QueueAuthenticPixels ( image , 0 , y , image -> columns , 1 , exception ) ;
 if ( q == ( PixelPacket * ) NULL ) break ;
 pixels = ( const unsigned char * ) ReadBlobStream ( image , length , GetQuantumPixels ( quantum_info ) , & count ) ;
 if ( count != ( ssize_t ) length ) ThrowReaderException ( CorruptImageError , "UnableToReadImageData" ) ;
 ( void ) ImportQuantumPixels ( image , ( CacheView * ) NULL , quantum_info , quantum_type , pixels , exception ) ;
 ( void ) ReadBlobStream ( image , ( size_t ) ( - ( ssize_t ) length ) & 0x01 , GetQuantumPixels ( quantum_info ) , & count ) ;
 if ( SyncAuthenticPixels ( image , exception ) == MagickFalse ) break ;
 status = SetImageProgress ( image , LoadImageTag , ( MagickOffsetType ) y , image -> rows ) ;
 if ( status == MagickFalse ) break ;
 }
 SetQuantumImageType ( image , quantum_type ) ;
 quantum_info = DestroyQuantumInfo ( quantum_info ) ;
 if ( EOFBlob ( image ) != MagickFalse ) ThrowFileException ( exception , CorruptImageError , "UnexpectedEndOfFile" , image -> filename ) ;
 ( void ) CloseBlob ( image ) ;
 return ( GetFirstImageInList ( image ) ) ;
 }


static int mov_read_stsz(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; unsigned int i, entries, sample_size, field_size, num_bytes; GetBitContext gb; unsigned char* buf; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; sc = st->priv_data; avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ if (atom.type == MKTAG('s','t','s','z')) { sample_size = avio_rb32(pb); if (!sc->sample_size) /* do not overwrite value computed in stsd */ sc->sample_size = sample_size; field_size = 32; } else { sample_size = 0; avio_rb24(pb); /* reserved */ field_size = avio_r8(pb); } entries = avio_rb32(pb); av_log(c->fc, AV_LOG_TRACE, "sample_size = %d sample_count = %d\n", sc->sample_size, entries); sc->sample_count = entries; if (sample_size) return 0; if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) { av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size); return AVERROR_INVALIDDATA; } if (!entries) return 0; if (entries >= UINT_MAX / sizeof(int) || entries >= (UINT_MAX - 4) / field_size) return AVERROR_INVALIDDATA; sc->sample_sizes = av_malloc(entries * sizeof(int)); if (!sc->sample_sizes) return AVERROR(ENOMEM); num_bytes = (entries*field_size+4)>>3; buf = av_malloc(num_bytes+FF_INPUT_BUFFER_PADDING_SIZE); if (!buf) { av_freep(&sc->sample_sizes); return AVERROR(ENOMEM); } if (avio_read(pb, buf, num_bytes) < num_bytes) { av_freep(&sc->sample_sizes); av_free(buf); return AVERROR_INVALIDDATA; } init_get_bits(&gb, buf, 8*num_bytes); for (i = 0; i < entries && !pb->eof_reached; i++) { sc->sample_sizes[i] = get_bits_long(&gb, field_size); sc->data_size += sc->sample_sizes[i]; } sc->sample_count = i; av_free(buf); if (pb->eof_reached) return AVERROR_EOF; return 0; }


TEST_F ( UsbBlocklistTest , StaticEntries ) {
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0010 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0018 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0030 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0110 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0111 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0112 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0113 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0114 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0115 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0116 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0120 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0200 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0211 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0401 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0402 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0403 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0404 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0405 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0406 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0407 , 0x0100 }
 ) ) ;
 EXPECT_TRUE ( list ( ) . IsExcluded ( {
 0x1050 , 0x0410 , 0x0100 }
 ) ) ;
 EXPECT_FALSE ( list ( ) . IsExcluded ( {
 0x104F , 0x0200 , 0x0100 }
 ) ) ;
 EXPECT_FALSE ( list ( ) . IsExcluded ( {
 0x1051 , 0x0200 , 0x0100 }
 ) ) ;
 }


static int parse_ipsecrequest ( struct xfrm_policy * xp , struct sadb_x_ipsecrequest * rq ) {
 struct net * net = xp_net ( xp ) ;
 struct xfrm_tmpl * t = xp -> xfrm_vec + xp -> xfrm_nr ;
 int mode ;
 if ( xp -> xfrm_nr >= XFRM_MAX_DEPTH ) return - ELOOP ;
 if ( rq -> sadb_x_ipsecrequest_mode == 0 ) return - EINVAL ;
 t -> id . proto = rq -> sadb_x_ipsecrequest_proto ;
 if ( ( mode = pfkey_mode_to_xfrm ( rq -> sadb_x_ipsecrequest_mode ) ) < 0 ) return - EINVAL ;
 t -> mode = mode ;
 if ( rq -> sadb_x_ipsecrequest_level == IPSEC_LEVEL_USE ) t -> optional = 1 ;
 else if ( rq -> sadb_x_ipsecrequest_level == IPSEC_LEVEL_UNIQUE ) {
 t -> reqid = rq -> sadb_x_ipsecrequest_reqid ;
 if ( t -> reqid > IPSEC_MANUAL_REQID_MAX ) t -> reqid = 0 ;
 if ( ! t -> reqid && ! ( t -> reqid = gen_reqid ( net ) ) ) return - ENOBUFS ;
 }
 if ( t -> mode == XFRM_MODE_TUNNEL ) {
 u8 * sa = ( u8 * ) ( rq + 1 ) ;
 int family , socklen ;
 family = pfkey_sockaddr_extract ( ( struct sockaddr * ) sa , & t -> saddr ) ;
 if ( ! family ) return - EINVAL ;
 socklen = pfkey_sockaddr_len ( family ) ;
 if ( pfkey_sockaddr_extract ( ( struct sockaddr * ) ( sa + socklen ) , & t -> id . daddr ) != family ) return - EINVAL ;
 t -> encap_family = family ;
 }
 else t -> encap_family = xp -> family ;
 t -> allalgs = 1 ;
 xp -> xfrm_nr ++ ;
 return 0 ;
 }


void ff_acelp_lspd2lpc(const double *lsp, float *lpc) { double pa[6], qa[6]; int i; lsp2polyf(lsp, pa, 5); lsp2polyf(lsp + 1, qa, 5); for (i=4; i>=0; i--) { double paf = pa[i+1] + pa[i]; double qaf = qa[i+1] - qa[i]; lpc[i ] = 0.5*(paf+qaf); lpc[9-i] = 0.5*(paf-qaf); } }


void ff_put_h264_qpel8_mc33_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_hv_qrt_8w_msa(src + stride - 2, src - (stride * 2) + sizeof(uint8_t), stride, dst, stride, 8); }


static void fdct4 ( const int16_t * input , int16_t * output ) {
 int16_t step [ 4 ] ;
 int temp1 , temp2 ;
 step [ 0 ] = input [ 0 ] + input [ 3 ] ;
 step [ 1 ] = input [ 1 ] + input [ 2 ] ;
 step [ 2 ] = input [ 1 ] - input [ 2 ] ;
 step [ 3 ] = input [ 0 ] - input [ 3 ] ;
 temp1 = ( step [ 0 ] + step [ 1 ] ) * cospi_16_64 ;
 temp2 = ( step [ 0 ] - step [ 1 ] ) * cospi_16_64 ;
 output [ 0 ] = fdct_round_shift ( temp1 ) ;
 output [ 2 ] = fdct_round_shift ( temp2 ) ;
 temp1 = step [ 2 ] * cospi_24_64 + step [ 3 ] * cospi_8_64 ;
 temp2 = - step [ 2 ] * cospi_8_64 + step [ 3 ] * cospi_24_64 ;
 output [ 1 ] = fdct_round_shift ( temp1 ) ;
 output [ 3 ] = fdct_round_shift ( temp2 ) ;
 }


TEST_F ( FullscreenControllerStateUnitTest , DISABLED_DebugLogStateTables ) {
 std : : ostringstream output ;
 output << "\n\nTransition Table:" ;
 output << GetTransitionTableAsString ( ) ;
 output << "\n\nInitial transitions:" ;
 output << GetStateTransitionsAsString ( ) ;
 for ( int state1_int = 0 ;
 state1_int < NUM_STATES ;
 ++ state1_int ) {
 State state1 = static_cast < State > ( state1_int ) ;
 for ( int state2_int = 0 ;
 state2_int < NUM_STATES ;
 ++ state2_int ) {
 State state2 = static_cast < State > ( state2_int ) ;
 if ( ShouldSkipStateAndEventPair ( state1 , EVENT_INVALID ) || ShouldSkipStateAndEventPair ( state2 , EVENT_INVALID ) ) continue ;
 if ( NextTransitionInShortestPath ( state1 , state2 , NUM_STATES ) . state == STATE_INVALID ) {
 LOG ( ERROR ) << "Should be skipping state transitions for: " << GetStateString ( state1 ) << " " << GetStateString ( state2 ) ;
 }
 }
 }
 output << "\n\nAll transitions:" ;
 output << GetStateTransitionsAsString ( ) ;
 LOG ( INFO ) << output . str ( ) ;
 }


static int ppce500_load_device_tree(CPUPPCState *env, QEMUMachineInitArgs *args, PPCE500Params *params, hwaddr addr, hwaddr initrd_base, hwaddr initrd_size) { int ret = -1; uint64_t mem_reg_property[] = { 0, cpu_to_be64(args->ram_size) }; int fdt_size; void *fdt; uint8_t hypercall[16]; uint32_t clock_freq = 400000000; uint32_t tb_freq = 400000000; int i; char compatible_sb[] = "fsl,mpc8544-immr\0simple-bus"; char soc[128]; char mpic[128]; uint32_t mpic_ph; uint32_t msi_ph; char gutil[128]; char pci[128]; char msi[128]; uint32_t *pci_map = NULL; int len; uint32_t pci_ranges[14] = { 0x2000000, 0x0, 0xc0000000, 0x0, 0xc0000000, 0x0, 0x20000000, 0x1000000, 0x0, 0x0, 0x0, 0xe1000000, 0x0, 0x10000, }; QemuOpts *machine_opts = qemu_get_machine_opts(); const char *dtb_file = qemu_opt_get(machine_opts, "dtb"); const char *toplevel_compat = qemu_opt_get(machine_opts, "dt_compatible"); if (dtb_file) { char *filename; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, dtb_file); if (!filename) { goto out; } fdt = load_device_tree(filename, &fdt_size); if (!fdt) { goto out; } goto done; } fdt = create_device_tree(&fdt_size); if (fdt == NULL) { goto out; } /* Manipulate device tree in memory. */ qemu_devtree_setprop_cell(fdt, "/", "#address-cells", 2); qemu_devtree_setprop_cell(fdt, "/", "#size-cells", 2); qemu_devtree_add_subnode(fdt, "/memory"); qemu_devtree_setprop_string(fdt, "/memory", "device_type", "memory"); qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property, sizeof(mem_reg_property)); qemu_devtree_add_subnode(fdt, "/chosen"); if (initrd_size) { ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start", initrd_base); if (ret < 0) { fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); } ret = qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end", (initrd_base + initrd_size)); if (ret < 0) { fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); } } ret = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs", args->kernel_cmdline); if (ret < 0) fprintf(stderr, "couldn't set /chosen/bootargs\n"); if (kvm_enabled()) { /* Read out host's frequencies */ clock_freq = kvmppc_get_clockfreq(); tb_freq = kvmppc_get_tbfreq(); /* indicate KVM hypercall interface */ qemu_devtree_add_subnode(fdt, "/hypervisor"); qemu_devtree_setprop_string(fdt, "/hypervisor", "compatible", "linux,kvm"); kvmppc_get_hypercall(env, hypercall, sizeof(hypercall)); qemu_devtree_setprop(fdt, "/hypervisor", "hcall-instructions", hypercall, sizeof(hypercall)); /* if KVM supports the idle hcall, set property indicating this */ if (kvmppc_get_hasidle(env)) { qemu_devtree_setprop(fdt, "/hypervisor", "has-idle", NULL, 0); } } /* Create CPU nodes */ qemu_devtree_add_subnode(fdt, "/cpus"); qemu_devtree_setprop_cell(fdt, "/cpus", "#address-cells", 1); qemu_devtree_setprop_cell(fdt, "/cpus", "#size-cells", 0); /* We need to generate the cpu nodes in reverse order, so Linux can pick the first node as boot node and be happy */ for (i = smp_cpus - 1; i >= 0; i--) { CPUState *cpu; char cpu_name[128]; uint64_t cpu_release_addr = MPC8544_SPIN_BASE + (i * 0x20); cpu = qemu_get_cpu(i); if (cpu == NULL) { continue; } env = cpu->env_ptr; snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x", cpu->cpu_index); qemu_devtree_add_subnode(fdt, cpu_name); qemu_devtree_setprop_cell(fdt, cpu_name, "clock-frequency", clock_freq); qemu_devtree_setprop_cell(fdt, cpu_name, "timebase-frequency", tb_freq); qemu_devtree_setprop_string(fdt, cpu_name, "device_type", "cpu"); qemu_devtree_setprop_cell(fdt, cpu_name, "reg", cpu->cpu_index); qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-line-size", env->dcache_line_size); qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-line-size", env->icache_line_size); qemu_devtree_setprop_cell(fdt, cpu_name, "d-cache-size", 0x8000); qemu_devtree_setprop_cell(fdt, cpu_name, "i-cache-size", 0x8000); qemu_devtree_setprop_cell(fdt, cpu_name, "bus-frequency", 0); if (cpu->cpu_index) { qemu_devtree_setprop_string(fdt, cpu_name, "status", "disabled"); qemu_devtree_setprop_string(fdt, cpu_name, "enable-method", "spin-table"); qemu_devtree_setprop_u64(fdt, cpu_name, "cpu-release-addr", cpu_release_addr); } else { qemu_devtree_setprop_string(fdt, cpu_name, "status", "okay"); } } qemu_devtree_add_subnode(fdt, "/aliases"); /* XXX These should go into their respective devices' code */ snprintf(soc, sizeof(soc), "/soc@%llx", MPC8544_CCSRBAR_BASE); qemu_devtree_add_subnode(fdt, soc); qemu_devtree_setprop_string(fdt, soc, "device_type", "soc"); qemu_devtree_setprop(fdt, soc, "compatible", compatible_sb, sizeof(compatible_sb)); qemu_devtree_setprop_cell(fdt, soc, "#address-cells", 1); qemu_devtree_setprop_cell(fdt, soc, "#size-cells", 1); qemu_devtree_setprop_cells(fdt, soc, "ranges", 0x0, MPC8544_CCSRBAR_BASE >> 32, MPC8544_CCSRBAR_BASE, MPC8544_CCSRBAR_SIZE); /* XXX should contain a reasonable value */ qemu_devtree_setprop_cell(fdt, soc, "bus-frequency", 0); snprintf(mpic, sizeof(mpic), "%s/pic@%llx", soc, MPC8544_MPIC_REGS_OFFSET); qemu_devtree_add_subnode(fdt, mpic); qemu_devtree_setprop_string(fdt, mpic, "device_type", "open-pic"); qemu_devtree_setprop_string(fdt, mpic, "compatible", "fsl,mpic"); qemu_devtree_setprop_cells(fdt, mpic, "reg", MPC8544_MPIC_REGS_OFFSET, 0x40000); qemu_devtree_setprop_cell(fdt, mpic, "#address-cells", 0); qemu_devtree_setprop_cell(fdt, mpic, "#interrupt-cells", 2); mpic_ph = qemu_devtree_alloc_phandle(fdt); qemu_devtree_setprop_cell(fdt, mpic, "phandle", mpic_ph); qemu_devtree_setprop_cell(fdt, mpic, "linux,phandle", mpic_ph); qemu_devtree_setprop(fdt, mpic, "interrupt-controller", NULL, 0); /* * We have to generate ser1 first, because Linux takes the first * device it finds in the dt as serial output device. And we generate * devices in reverse order to the dt. */ dt_serial_create(fdt, MPC8544_SERIAL1_REGS_OFFSET, soc, mpic, "serial1", 1, false); dt_serial_create(fdt, MPC8544_SERIAL0_REGS_OFFSET, soc, mpic, "serial0", 0, true); snprintf(gutil, sizeof(gutil), "%s/global-utilities@%llx", soc, MPC8544_UTIL_OFFSET); qemu_devtree_add_subnode(fdt, gutil); qemu_devtree_setprop_string(fdt, gutil, "compatible", "fsl,mpc8544-guts"); qemu_devtree_setprop_cells(fdt, gutil, "reg", MPC8544_UTIL_OFFSET, 0x1000); qemu_devtree_setprop(fdt, gutil, "fsl,has-rstcr", NULL, 0); snprintf(msi, sizeof(msi), "/%s/msi@%llx", soc, MPC8544_MSI_REGS_OFFSET); qemu_devtree_add_subnode(fdt, msi); qemu_devtree_setprop_string(fdt, msi, "compatible", "fsl,mpic-msi"); qemu_devtree_setprop_cells(fdt, msi, "reg", MPC8544_MSI_REGS_OFFSET, 0x200); msi_ph = qemu_devtree_alloc_phandle(fdt); qemu_devtree_setprop_cells(fdt, msi, "msi-available-ranges", 0x0, 0x100); qemu_devtree_setprop_phandle(fdt, msi, "interrupt-parent", mpic); qemu_devtree_setprop_cells(fdt, msi, "interrupts", 0xe0, 0x0, 0xe1, 0x0, 0xe2, 0x0, 0xe3, 0x0, 0xe4, 0x0, 0xe5, 0x0, 0xe6, 0x0, 0xe7, 0x0); qemu_devtree_setprop_cell(fdt, msi, "phandle", msi_ph); qemu_devtree_setprop_cell(fdt, msi, "linux,phandle", msi_ph); snprintf(pci, sizeof(pci), "/pci@%llx", MPC8544_PCI_REGS_BASE); qemu_devtree_add_subnode(fdt, pci); qemu_devtree_setprop_cell(fdt, pci, "cell-index", 0); qemu_devtree_setprop_string(fdt, pci, "compatible", "fsl,mpc8540-pci"); qemu_devtree_setprop_string(fdt, pci, "device_type", "pci"); qemu_devtree_setprop_cells(fdt, pci, "interrupt-map-mask", 0xf800, 0x0, 0x0, 0x7); pci_map = pci_map_create(fdt, qemu_devtree_get_phandle(fdt, mpic), params->pci_first_slot, params->pci_nr_slots, &len); qemu_devtree_setprop(fdt, pci, "interrupt-map", pci_map, len); qemu_devtree_setprop_phandle(fdt, pci, "interrupt-parent", mpic); qemu_devtree_setprop_cells(fdt, pci, "interrupts", 24, 2); qemu_devtree_setprop_cells(fdt, pci, "bus-range", 0, 255); for (i = 0; i < 14; i++) { pci_ranges[i] = cpu_to_be32(pci_ranges[i]); } qemu_devtree_setprop_cell(fdt, pci, "fsl,msi", msi_ph); qemu_devtree_setprop(fdt, pci, "ranges", pci_ranges, sizeof(pci_ranges)); qemu_devtree_setprop_cells(fdt, pci, "reg", MPC8544_PCI_REGS_BASE >> 32, MPC8544_PCI_REGS_BASE, 0, 0x1000); qemu_devtree_setprop_cell(fdt, pci, "clock-frequency", 66666666); qemu_devtree_setprop_cell(fdt, pci, "#interrupt-cells", 1); qemu_devtree_setprop_cell(fdt, pci, "#size-cells", 2); qemu_devtree_setprop_cell(fdt, pci, "#address-cells", 3); qemu_devtree_setprop_string(fdt, "/aliases", "pci0", pci); params->fixup_devtree(params, fdt); if (toplevel_compat) { qemu_devtree_setprop(fdt, "/", "compatible", toplevel_compat, strlen(toplevel_compat) + 1); } done: qemu_devtree_dumpdtb(fdt, fdt_size); ret = rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); if (ret < 0) { goto out; } g_free(fdt); ret = fdt_size; out: g_free(pci_map); return ret; }


static void acpi_get_pci_holes(Range *hole, Range *hole64) { Object *pci_host; pci_host = acpi_get_i386_pci_host(); g_assert(pci_host); hole->begin = object_property_get_int(pci_host, PCI_HOST_PROP_PCI_HOLE_START, NULL); hole->end = object_property_get_int(pci_host, PCI_HOST_PROP_PCI_HOLE_END, NULL); hole64->begin = object_property_get_int(pci_host, PCI_HOST_PROP_PCI_HOLE64_START, NULL); hole64->end = object_property_get_int(pci_host, PCI_HOST_PROP_PCI_HOLE64_END, NULL); }


static int mmu_translate_region(CPUS390XState *env, target_ulong vaddr, uint64_t asc, uint64_t entry, int level, target_ulong *raddr, int *flags, int rw) { CPUState *cs = CPU(s390_env_get_cpu(env)); uint64_t origin, offs, new_entry; const int pchks[4] = { PGM_SEGMENT_TRANS, PGM_REG_THIRD_TRANS, PGM_REG_SEC_TRANS, PGM_REG_FIRST_TRANS }; PTE_DPRINTF("%s: 0x%" PRIx64 "\n", __func__, entry); origin = entry & _REGION_ENTRY_ORIGIN; offs = (vaddr >> (17 + 11 * level / 4)) & 0x3ff8; new_entry = ldq_phys(cs->as, origin + offs); PTE_DPRINTF("%s: 0x%" PRIx64 " + 0x%" PRIx64 " => 0x%016" PRIx64 "\n", __func__, origin, offs, new_entry); if ((new_entry & _REGION_ENTRY_INV) != 0) { /* XXX different regions have different faults */ DPRINTF("%s: invalid region\n", __func__); trigger_page_fault(env, vaddr, PGM_SEGMENT_TRANS, asc, rw); return -1; } if ((new_entry & _REGION_ENTRY_TYPE_MASK) != level) { trigger_page_fault(env, vaddr, PGM_TRANS_SPEC, asc, rw); return -1; } /* XXX region protection flags */ /* *flags &= ~PAGE_WRITE */ if (level == _ASCE_TYPE_SEGMENT) { return mmu_translate_segment(env, vaddr, asc, new_entry, raddr, flags, rw); } /* Check region table offset and length */ offs = (vaddr >> (28 + 11 * (level - 4) / 4)) & 3; if (offs < ((new_entry & _REGION_ENTRY_TF) >> 6) || offs > (new_entry & _REGION_ENTRY_LENGTH)) { DPRINTF("%s: invalid offset or len (%lx)\n", __func__, new_entry); trigger_page_fault(env, vaddr, pchks[level / 4 - 1], asc, rw); return -1; } /* yet another region */ return mmu_translate_region(env, vaddr, asc, new_entry, level - 4, raddr, flags, rw); }


int net_slirp_redir ( const char * redir_str ) {
 struct slirp_config_str * config ;
 if ( QTAILQ_EMPTY ( & slirp_stacks ) ) {
 config = g_malloc ( sizeof ( * config ) ) ;
 pstrcpy ( config -> str , sizeof ( config -> str ) , redir_str ) ;
 config -> flags = SLIRP_CFG_HOSTFWD | SLIRP_CFG_LEGACY ;
 config -> next = slirp_configs ;
 slirp_configs = config ;
 return 0 ;
 }
 return slirp_hostfwd ( QTAILQ_FIRST ( & slirp_stacks ) , redir_str , 1 ) ;
 }


byte* decode_base64(char* src,size_t ssize, size_t *ret_len)
{
  byte* outbuf;
  byte* retbuf;
  char* inb;
  int i;
  int l;
  int left;
  int pos;
  unsigned long triple;

  /* Exit on empty input */
  if (!ssize||src==NULL) {
    log_msg(LOG_LEVEL_DEBUG, "decode base64: empty string");
    return NULL;
  }

  /* Initialize working pointers */
  inb = src;
  outbuf = (byte *)checked_malloc(sizeof(byte)*B64_BUF);

  l = 0;
  triple = 0;
  pos=0;
  left = ssize;
  /*
   * Process entire inbuf.
   */
  while (left != 0)
    {
      left--;
      i = fromb64[(unsigned char)*inb];
      switch(i)
	{
	case FAIL:
	  log_msg(LOG_LEVEL_WARNING, "decode_base64: illegal character: '%c' in '%s'", *inb, src);
	  free(outbuf);
	  return NULL;
	  break;
	case SKIP:
	  break;
	default:
	  triple = triple<<6 | (0x3f & i);
	  l++;
	  break;
	}
      if (l == 4 || left == 0)
	{
	  switch(l)
	    {
	    case 2:
	      triple = triple>>4;
	      break;
	    case 3:
	      triple = triple>>2;
	      break;
	    default:
	      break;
	    }
	  for (l  -= 2; l >= 0; l--)
	    {
	      outbuf[pos]=( 0xff & (triple>>(l*8)));
	      pos++;
	    }
	  triple = 0;
	  l = 0;
	}
      inb++;
    }

  retbuf=(byte*)checked_malloc(sizeof(byte)*(pos+1));
  memcpy(retbuf,outbuf,pos);
  retbuf[pos]='\0';

  free(outbuf);

  if (ret_len) *ret_len = pos;

  return retbuf;
}


END_TEST START_TEST ( test_find_available_user_small_net ) {
 in_addr_t ip ;
 int i ;
 ip = inet_addr ( "127.0.0.1" ) ;
 init_users ( ip , 29 ) ;
 for ( i = 0 ;
 i < 5 ;
 i ++ ) {
 fail_unless ( find_available_user ( ) == i ) ;
 }
 for ( i = 0 ;
 i < USERS ;
 i ++ ) {
 fail_unless ( find_available_user ( ) == - 1 ) ;
 }
 users [ 3 ] . active = 0 ;
 fail_unless ( find_available_user ( ) == 3 ) ;
 fail_unless ( find_available_user ( ) == - 1 ) ;
 users [ 3 ] . last_pkt = 55 ;
 fail_unless ( find_available_user ( ) == 3 ) ;
 fail_unless ( find_available_user ( ) == - 1 ) ;
 }


static const unsigned char * seq_decode_op1 ( SeqVideoContext * seq , const unsigned char * src , const unsigned char * src_end , unsigned char * dst ) {
 const unsigned char * color_table ;
 int b , i , len , bits ;
 GetBitContext gb ;
 unsigned char block [ 8 * 8 ] ;
 if ( src_end - src < 1 ) return NULL ;
 len = * src ++ ;
 if ( len & 0x80 ) {
 switch ( len & 3 ) {
 case 1 : src = seq_unpack_rle_block ( src , src_end , block , sizeof ( block ) ) ;
 for ( b = 0 ;
 b < 8 ;
 b ++ ) {
 memcpy ( dst , & block [ b * 8 ] , 8 ) ;
 dst += seq -> frame . linesize [ 0 ] ;
 }
 break ;
 case 2 : src = seq_unpack_rle_block ( src , src_end , block , sizeof ( block ) ) ;
 for ( i = 0 ;
 i < 8 ;
 i ++ ) {
 for ( b = 0 ;
 b < 8 ;
 b ++ ) dst [ b * seq -> frame . linesize [ 0 ] ] = block [ i * 8 + b ] ;
 ++ dst ;
 }
 break ;
 }
 }
 else {
 if ( len <= 0 ) return NULL ;
 bits = ff_log2_tab [ len - 1 ] + 1 ;
 if ( src_end - src < len + 8 * bits ) return NULL ;
 color_table = src ;
 src += len ;
 init_get_bits ( & gb , src , bits * 8 * 8 ) ;
 src += bits * 8 ;
 for ( b = 0 ;
 b < 8 ;
 b ++ ) {
 for ( i = 0 ;
 i < 8 ;
 i ++ ) dst [ i ] = color_table [ get_bits ( & gb , bits ) ] ;
 dst += seq -> frame . linesize [ 0 ] ;
 }
 }
 return src ;
 }


static guint istr_hash ( gconstpointer key ) {
 const char * p ;
 guint h ;
 h = 0 ;
 for ( p = key ;
 * p != '\0' ;
 p ++ ) {
 h = ( h << 5 ) - h + g_ascii_tolower ( * p ) ;
 }
 return h ;
 }


static void virtio_blk_device_realize(DeviceState *dev, Error **errp) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOBlock *s = VIRTIO_BLK(dev); VirtIOBlkConf *conf = &s->conf; Error *err = NULL; static int virtio_blk_id; if (!conf->conf.bs) { error_setg(errp, "drive property not set"); return; } if (!bdrv_is_inserted(conf->conf.bs)) { error_setg(errp, "Device needs media, but drive is empty"); return; } blkconf_serial(&conf->conf, &conf->serial); s->original_wce = bdrv_enable_write_cache(conf->conf.bs); blkconf_geometry(&conf->conf, NULL, 65535, 255, 255, &err); if (err) { error_propagate(errp, err); return; } virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config)); s->bs = conf->conf.bs; s->rq = NULL; s->sector_mask = (s->conf.conf.logical_block_size / BDRV_SECTOR_SIZE) - 1; s->vq = virtio_add_queue(vdev, 128, virtio_blk_handle_output); s->complete_request = virtio_blk_complete_request; virtio_blk_data_plane_create(vdev, conf, &s->dataplane, &err); if (err != NULL) { error_propagate(errp, err); virtio_cleanup(vdev); return; } s->migration_state_notifier.notify = virtio_blk_migration_state_changed; add_migration_state_change_notifier(&s->migration_state_notifier); s->change = qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); register_savevm(dev, "virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); bdrv_set_dev_ops(s->bs, &virtio_block_ops, s); bdrv_set_guest_block_size(s->bs, s->conf.conf.logical_block_size); bdrv_iostatus_enable(s->bs); }


IN_PROC_BROWSER_TEST_F ( PrefsFunctionalTest , TestSessionRestoreShowBookmarkBar ) {
 EXPECT_FALSE ( browser ( ) -> profile ( ) -> GetPrefs ( ) -> GetBoolean ( bookmarks : : prefs : : kShowBookmarkBar ) ) ;
 browser ( ) -> profile ( ) -> GetPrefs ( ) -> SetBoolean ( bookmarks : : prefs : : kShowBookmarkBar , true ) ;
 EXPECT_TRUE ( browser ( ) -> profile ( ) -> GetPrefs ( ) -> GetBoolean ( bookmarks : : prefs : : kShowBookmarkBar ) ) ;
 EXPECT_TRUE ( browser ( ) -> profile ( ) -> GetPrefs ( ) -> GetBoolean ( bookmarks : : prefs : : kShowBookmarkBar ) ) ;
 EXPECT_EQ ( BookmarkBar : : SHOW , browser ( ) -> bookmark_bar_state ( ) ) ;
 }


static int check_oflag_copied(BlockDriverState *bs, BdrvCheckResult *res) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table = qemu_blockalign(bs, s->cluster_size); int ret; int refcount; int i, j; for (i = 0; i < s->l1_size; i++) { uint64_t l1_entry = s->l1_table[i]; uint64_t l2_offset = l1_entry & L1E_OFFSET_MASK; if (!l2_offset) { continue; } refcount = get_refcount(bs, l2_offset >> s->cluster_bits); if (refcount < 0) { /* don't print message nor increment check_errors */ continue; } if ((refcount == 1) != ((l1_entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED L2 cluster: l1_index=%d " "l1_entry=%" PRIx64 " refcount=%d\n", i, l1_entry, refcount); res->corruptions++; } ret = bdrv_pread(bs->file, l2_offset, l2_table, s->l2_size * sizeof(uint64_t)); if (ret < 0) { fprintf(stderr, "ERROR: Could not read L2 table: %s\n", strerror(-ret)); res->check_errors++; goto fail; } for (j = 0; j < s->l2_size; j++) { uint64_t l2_entry = be64_to_cpu(l2_table[j]); uint64_t data_offset = l2_entry & L2E_OFFSET_MASK; int cluster_type = qcow2_get_cluster_type(l2_entry); if ((cluster_type == QCOW2_CLUSTER_NORMAL) || ((cluster_type == QCOW2_CLUSTER_ZERO) && (data_offset != 0))) { refcount = get_refcount(bs, data_offset >> s->cluster_bits); if (refcount < 0) { /* don't print message nor increment check_errors */ continue; } if ((refcount == 1) != ((l2_entry & QCOW_OFLAG_COPIED) != 0)) { fprintf(stderr, "ERROR OFLAG_COPIED data cluster: " "l2_entry=%" PRIx64 " refcount=%d\n", l2_entry, refcount); res->corruptions++; } } } } ret = 0; fail: qemu_vfree(l2_table); return ret; }


void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs, int64_t speed, BlockDriverCompletionFunc *cb, void *opaque, Error **errp) { BlockJob *job; if (bs->job || bdrv_in_use(bs)) { error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs)); return NULL; } bdrv_ref(bs); bdrv_set_in_use(bs, 1); job = g_malloc0(driver->instance_size); job->driver = driver; job->bs = bs; job->cb = cb; job->opaque = opaque; job->busy = true; bs->job = job; /* Only set speed when necessary to avoid NotSupported error */ if (speed != 0) { Error *local_err = NULL; block_job_set_speed(job, speed, &local_err); if (local_err) { bs->job = NULL; g_free(job); bdrv_set_in_use(bs, 0); error_propagate(errp, local_err); return NULL; } } return job; }


static void unpack_alpha(GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits) { const int mask = (1 << num_bits) - 1; int i, idx, val, alpha_val; idx = 0; alpha_val = mask; do { do { if (get_bits1(gb)) val = get_bits(gb, num_bits); else { int sign; val = get_bits(gb, num_bits == 16 ? 7 : 4); sign = val & 1; val = (val + 2) >> 1; if (sign) val = -val; } alpha_val = (alpha_val + val) & mask; if (num_bits == 16) dst[idx++] = alpha_val >> 6; else dst[idx++] = (alpha_val << 2) | (alpha_val >> 6); if (idx == num_coeffs - 1) break; } while (get_bits1(gb)); val = get_bits(gb, 4); if (!val) val = get_bits(gb, 11); if (idx + val > num_coeffs) val = num_coeffs - idx; if (num_bits == 16) for (i = 0; i < val; i++) dst[idx++] = alpha_val >> 6; else for (i = 0; i < val; i++) dst[idx++] = (alpha_val << 2) | (alpha_val >> 6); } while (idx < num_coeffs); }


static bool migrate_params_check(MigrationParameters *params, Error **errp) { if (params->has_compress_level && (params->compress_level < 0 || params->compress_level > 9)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_level", "is invalid, it should be in the range of 0 to 9"); return false; } if (params->has_compress_threads && (params->compress_threads < 1 || params->compress_threads > 255)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "compress_threads", "is invalid, it should be in the range of 1 to 255"); return false; } if (params->has_decompress_threads && (params->decompress_threads < 1 || params->decompress_threads > 255)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "decompress_threads", "is invalid, it should be in the range of 1 to 255"); return false; } if (params->has_cpu_throttle_initial && (params->cpu_throttle_initial < 1 || params->cpu_throttle_initial > 99)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu_throttle_initial", "an integer in the range of 1 to 99"); return false; } if (params->has_cpu_throttle_increment && (params->cpu_throttle_increment < 1 || params->cpu_throttle_increment > 99)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cpu_throttle_increment", "an integer in the range of 1 to 99"); return false; } if (params->has_max_bandwidth && (params->max_bandwidth < 0 || params->max_bandwidth > SIZE_MAX)) { error_setg(errp, "Parameter 'max_bandwidth' expects an integer in the" " range of 0 to %zu bytes/second", SIZE_MAX); return false; } if (params->has_downtime_limit && (params->downtime_limit < 0 || params->downtime_limit > MAX_MIGRATE_DOWNTIME)) { error_setg(errp, "Parameter 'downtime_limit' expects an integer in " "the range of 0 to %d milliseconds", MAX_MIGRATE_DOWNTIME); return false; } if (params->has_x_checkpoint_delay && (params->x_checkpoint_delay < 0)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "x_checkpoint_delay", "is invalid, it should be positive"); return false; } if (params->has_x_multifd_channels && (params->x_multifd_channels < 1 || params->x_multifd_channels > 255)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_channels", "is invalid, it should be in the range of 1 to 255"); return false; } if (params->has_x_multifd_page_count && (params->x_multifd_page_count < 1 || params->x_multifd_page_count > 10000)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "multifd_page_count", "is invalid, it should be in the range of 1 to 10000"); return false; } if (params->has_xbzrle_cache_size && (params->xbzrle_cache_size < qemu_target_page_size() || !is_power_of_2(params->xbzrle_cache_size))) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "xbzrle_cache_size", "is invalid, it should be bigger than target page size" " and a power of two"); return false; } return true; }


static uint32_t pm_ioport_readw(void *opaque, uint32_t addr) { VT686PMState *s = opaque; uint32_t val; addr &= 0x0f; switch (addr) { case 0x00: val = acpi_pm1_evt_get_sts(&s->ar, s->ar.tmr.overflow_time); break; case 0x02: val = s->ar.pm1.evt.en; break; case 0x04: val = s->ar.pm1.cnt.cnt; break; default: val = 0; break; } DPRINTF("PM readw port=0x%04x val=0x%02x\n", addr, val); return val; }


file_asynch_zero (struct rw *rw, struct command *command,
                  nbd_completion_callback cb, bool allocate)
{
  int dummy = 0;

  if (!file_synch_zero (rw, command->offset, command->slice.len, allocate))
    return false;
  if (cb.callback (cb.user_data, &dummy) == -1) {
    perror (rw->name);
    exit (EXIT_FAILURE);
  }
  return true;
}


inline uint32_t mime_hdr_get_accelerator_slotnum ( MIMEHdrImpl * mh , int32_t slot_id ) {
 ink_assert ( ( slot_id != MIME_SLOTID_NONE ) && ( slot_id < 32 ) ) ;
 uint32_t word_index = slot_id / 8 ;
 uint32_t word = mh -> m_slot_accelerators [ word_index ] ;
 uint32_t nybble = slot_id % 8 ;
 uint32_t slot = ( ( word >> ( nybble * 4 ) ) & 15 ) ;
 return slot ;
 }


void *qemu_vmalloc(size_t size) { /* FIXME: this is not exactly optimal solution since VirtualAlloc has 64Kb granularity, but at least it guarantees us that the memory is page aligned. */ if (!size) { abort(); } return oom_check(VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE)); }


static int coroutine_fn raw_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { BLKDBG_EVENT(bs->file, BLKDBG_WRITE_AIO); return bdrv_co_writev(bs->file, sector_num, nb_sectors, qiov); }


int64_t qdict_get_try_int(const QDict *qdict, const char *key, int64_t def_value) { QObject *obj; obj = qdict_get(qdict, key); if (!obj || qobject_type(obj) != QTYPE_QINT) return def_value; return qint_get_int(qobject_to_qint(obj)); }


static char * list_digest_names ( void ) {
 char * list = NULL ;
 # ifdef OPENSSL # ifdef HAVE_EVP_MD_DO_ALL_SORTED struct hstate hstate = {
 NULL , NULL , K_PER_LINE + 1 }
 ;
 hstate . seen = ( const char * * ) emalloc_zero ( 1 * sizeof ( const char * ) ) ;
 INIT_SSL ( ) ;
 EVP_MD_do_all_sorted ( list_md_fn , & hstate ) ;
 list = hstate . list ;
 free ( hstate . seen ) ;
 # else list = ( char * ) emalloc ( sizeof ( "md5, others (upgrade to OpenSSL-1.0 for full list)" ) ) ;
 strcpy ( list , "md5, others (upgrade to OpenSSL-1.0 for full list)" ) ;
 # endif # else list = ( char * ) emalloc ( sizeof ( "md5" ) ) ;
 strcpy ( list , "md5" ) ;
 # endif return list ;
 }


void dsputil_init_armv4l(void) { // ff_idct = j_rev_dct_ARM; }


static void RENAME(resample_one)(DELEM *dst, const DELEM *src, int dst_size, int64_t index2, int64_t incr) { int dst_index; for (dst_index = 0; dst_index < dst_size; dst_index++) { dst[dst_index] = src[index2 >> 32]; index2 += incr; } }


static int selinux_task_setnice ( struct task_struct * p , int nice ) {
 return current_has_perm ( p , PROCESS__SETSCHED ) ;
 }


fz_colorspace * fz_new_icc_colorspace ( fz_context * ctx , const char * name , int num , fz_buffer * buf ) {
 # ifdef NO_ICC fz_throw ( ctx , FZ_ERROR_GENERIC , "ICC Profiles not supported in NO_ICC build" ) ;
 # else fz_colorspace * cs = NULL ;
 fz_iccprofile * profile ;
 int is_lab = 0 ;
 enum fz_colorspace_type type = FZ_COLORSPACE_NONE ;
 int flags = FZ_COLORSPACE_IS_ICC ;
 profile = fz_malloc_struct ( ctx , fz_iccprofile ) ;
 fz_try ( ctx ) {
 if ( buf == NULL ) {
 size_t size ;
 const unsigned char * data ;
 data = fz_lookup_icc ( ctx , name , & size ) ;
 profile -> buffer = fz_new_buffer_from_shared_data ( ctx , data , size ) ;
 is_lab = ( strcmp ( name , FZ_ICC_PROFILE_LAB ) == 0 ) ;
 profile -> bgr = ( strcmp ( name , FZ_ICC_PROFILE_BGR ) == 0 ) ;
 flags |= FZ_COLORSPACE_IS_DEVICE ;
 }
 else {
 profile -> buffer = fz_keep_buffer ( ctx , buf ) ;
 }
 fz_cmm_init_profile ( ctx , profile ) ;
 if ( num != 0 && num != profile -> num_devcomp ) {
 fz_drop_buffer ( ctx , profile -> buffer ) ;
 fz_cmm_fin_profile ( ctx , profile ) ;
 fz_free ( ctx , profile ) ;
 break ;
 }
 fz_md5_icc ( ctx , profile ) ;
 switch ( profile -> num_devcomp ) {
 default : type = FZ_COLORSPACE_SEPARATION ;
 break ;
 case 1 : type = FZ_COLORSPACE_GRAY ;
 break ;
 case 3 : if ( is_lab ) type = FZ_COLORSPACE_LAB ;
 else if ( profile -> bgr ) type = FZ_COLORSPACE_BGR ;
 else type = FZ_COLORSPACE_RGB ;
 break ;
 case 4 : type = FZ_COLORSPACE_CMYK ;
 break ;
 }
 cs = fz_new_colorspace ( ctx , name , type , flags , profile -> num_devcomp , NULL , NULL , NULL , is_lab ? clamp_lab_icc : clamp_default_icc , free_icc , profile , sizeof ( profile ) ) ;
 switch ( profile -> num_devcomp ) {
 case 1 : fz_colorspace_name_colorant ( ctx , cs , 0 , "Gray" ) ;
 break ;
 case 3 : if ( is_lab ) {
 fz_colorspace_name_colorant ( ctx , cs , 0 , "L*" ) ;
 fz_colorspace_name_colorant ( ctx , cs , 1 , "a*" ) ;
 fz_colorspace_name_colorant ( ctx , cs , 2 , "b*" ) ;
 }
 else {
 fz_colorspace_name_colorant ( ctx , cs , profile -> bgr ? 2 : 0 , "Red" ) ;
 fz_colorspace_name_colorant ( ctx , cs , 1 , "Green" ) ;
 fz_colorspace_name_colorant ( ctx , cs , profile -> bgr ? 0 : 2 , "Blue" ) ;
 }
 break ;
 case 4 : fz_colorspace_name_colorant ( ctx , cs , 0 , "Cyan" ) ;
 fz_colorspace_name_colorant ( ctx , cs , 1 , "Magenta" ) ;
 fz_colorspace_name_colorant ( ctx , cs , 2 , "Yellow" ) ;
 fz_colorspace_name_colorant ( ctx , cs , 3 , "Black" ) ;
 break ;
 }
 }
 fz_catch ( ctx ) {
 fz_drop_buffer ( ctx , profile -> buffer ) ;
 fz_cmm_fin_profile ( ctx , profile ) ;
 fz_free ( ctx , profile ) ;
 }
 return cs ;
 # endif }


int xps_count_font_encodings ( fz_font * font ) {
 FT_Face face = font -> ft_face ;
 return face -> num_charmaps ;
 }


static int evaluate_tpr_instruction ( VAPICROMState * s , CPUX86State * env , target_ulong * pip , TPRAccess access ) {
 const TPRInstruction * instr ;
 target_ulong ip = * pip ;
 uint8_t opcode [ 2 ] ;
 uint32_t real_tpr_addr ;
 int i ;
 if ( ( ip & 0xf0000000ULL ) != 0x80000000ULL && ( ip & 0xf0000000ULL ) != 0xe0000000ULL ) {
 return - 1 ;
 }
 if ( env -> regs [ R_ESP ] == 0 ) {
 return - 1 ;
 }
 if ( kvm_enabled ( ) && ! kvm_irqchip_in_kernel ( ) ) {
 for ( i = 0 ;
 i < ARRAY_SIZE ( tpr_instr ) ;
 i ++ ) {
 instr = & tpr_instr [ i ] ;
 if ( instr -> access != access ) {
 continue ;
 }
 if ( cpu_memory_rw_debug ( env , ip - instr -> length , opcode , sizeof ( opcode ) , 0 ) < 0 ) {
 return - 1 ;
 }
 if ( opcode_matches ( opcode , instr ) ) {
 ip -= instr -> length ;
 goto instruction_ok ;
 }
 }
 return - 1 ;
 }
 else {
 if ( cpu_memory_rw_debug ( env , ip , opcode , sizeof ( opcode ) , 0 ) < 0 ) {
 return - 1 ;
 }
 for ( i = 0 ;
 i < ARRAY_SIZE ( tpr_instr ) ;
 i ++ ) {
 instr = & tpr_instr [ i ] ;
 if ( opcode_matches ( opcode , instr ) ) {
 goto instruction_ok ;
 }
 }
 return - 1 ;
 }
 instruction_ok : if ( cpu_memory_rw_debug ( env , ip + instr -> addr_offset , ( void * ) & real_tpr_addr , sizeof ( real_tpr_addr ) , 0 ) < 0 ) {
 return - 1 ;
 }
 real_tpr_addr = le32_to_cpu ( real_tpr_addr ) ;
 if ( ( real_tpr_addr & 0xfff ) != 0x80 ) {
 return - 1 ;
 }
 s -> real_tpr_addr = real_tpr_addr ;
 update_guest_rom_state ( s ) ;
 * pip = ip ;
 return 0 ;
 }


ServerSecurityFeature::ServerSecurityFeature(
    application_features::ApplicationServer& server)
    : ApplicationFeature(server, "ServerSecurity"),
      _enableFoxxApi(true),
      _enableFoxxStore(true),
      _hardenedRestApi(false) {
  setOptional(false);
  startsAfter<application_features::GreetingsFeaturePhase>();
}


void *fw_cfg_modify_file(FWCfgState *s, const char *filename, void *data, size_t len) { int i, index; void *ptr = NULL; assert(s->files); index = be32_to_cpu(s->files->count); assert(index < fw_cfg_file_slots(s)); for (i = 0; i < index; i++) { if (strcmp(filename, s->files->f[i].name) == 0) { ptr = fw_cfg_modify_bytes_read(s, FW_CFG_FILE_FIRST + i, data, len); s->files->f[i].size = cpu_to_be32(len); return ptr; } } /* add new one */ fw_cfg_add_file_callback(s, filename, NULL, NULL, NULL, data, len, true); return NULL; }


static void srec_get_symbol_info ( bfd * ignore_abfd ATTRIBUTE_UNUSED , asymbol * symbol , symbol_info * ret ) {
 bfd_symbol_info ( symbol , ret ) ;
 }


static int64_t rd_pick_intra_sub_8x8_y_mode ( VP9_COMP * cpi , MACROBLOCK * mb , int * rate , int * rate_y , int64_t * distortion , int64_t best_rd ) {
 int i , j ;
 const MACROBLOCKD * const xd = & mb -> e_mbd ;
 MODE_INFO * const mic = xd -> mi [ 0 ] ;
 const MODE_INFO * above_mi = xd -> mi [ - xd -> mi_stride ] ;
 const MODE_INFO * left_mi = xd -> left_available ? xd -> mi [ - 1 ] : NULL ;
 const BLOCK_SIZE bsize = xd -> mi [ 0 ] -> mbmi . sb_type ;
 const int num_4x4_blocks_wide = num_4x4_blocks_wide_lookup [ bsize ] ;
 const int num_4x4_blocks_high = num_4x4_blocks_high_lookup [ bsize ] ;
 int idx , idy ;
 int cost = 0 ;
 int64_t total_distortion = 0 ;
 int tot_rate_y = 0 ;
 int64_t total_rd = 0 ;
 ENTROPY_CONTEXT t_above [ 4 ] , t_left [ 4 ] ;
 const int * bmode_costs = cpi -> mbmode_cost ;
 vpx_memcpy ( t_above , xd -> plane [ 0 ] . above_context , sizeof ( t_above ) ) ;
 vpx_memcpy ( t_left , xd -> plane [ 0 ] . left_context , sizeof ( t_left ) ) ;
 for ( idy = 0 ;
 idy < 2 ;
 idy += num_4x4_blocks_high ) {
 for ( idx = 0 ;
 idx < 2 ;
 idx += num_4x4_blocks_wide ) {
 PREDICTION_MODE best_mode = DC_PRED ;
 int r = INT_MAX , ry = INT_MAX ;
 int64_t d = INT64_MAX , this_rd = INT64_MAX ;
 i = idy * 2 + idx ;
 if ( cpi -> common . frame_type == KEY_FRAME ) {
 const PREDICTION_MODE A = vp9_above_block_mode ( mic , above_mi , i ) ;
 const PREDICTION_MODE L = vp9_left_block_mode ( mic , left_mi , i ) ;
 bmode_costs = cpi -> y_mode_costs [ A ] [ L ] ;
 }
 this_rd = rd_pick_intra4x4block ( cpi , mb , i , & best_mode , bmode_costs , t_above + idx , t_left + idy , & r , & ry , & d , bsize , best_rd - total_rd ) ;
 if ( this_rd >= best_rd - total_rd ) return INT64_MAX ;
 total_rd += this_rd ;
 cost += r ;
 total_distortion += d ;
 tot_rate_y += ry ;
 mic -> bmi [ i ] . as_mode = best_mode ;
 for ( j = 1 ;
 j < num_4x4_blocks_high ;
 ++ j ) mic -> bmi [ i + j * 2 ] . as_mode = best_mode ;
 for ( j = 1 ;
 j < num_4x4_blocks_wide ;
 ++ j ) mic -> bmi [ i + j ] . as_mode = best_mode ;
 if ( total_rd >= best_rd ) return INT64_MAX ;
 }
 }
 * rate = cost ;
 * rate_y = tot_rate_y ;
 * distortion = total_distortion ;
 mic -> mbmi . mode = mic -> bmi [ 3 ] . as_mode ;
 return RDCOST ( mb -> rdmult , mb -> rddiv , cost , total_distortion ) ;
 }


int cpu_watchpoint_remove(CPUState *env, target_ulong addr, target_ulong len, int flags) { target_ulong len_mask = ~(len - 1); CPUWatchpoint *wp; TAILQ_FOREACH(wp, &env->watchpoints, entry) { if (addr == wp->vaddr && len_mask == wp->len_mask && flags == (wp->flags & ~BP_WATCHPOINT_HIT)) { cpu_watchpoint_remove_by_ref(env, wp); return 0; } } return -ENOENT; }


build_model(XML_Parser parser) {
  DTD *const dtd = parser->m_dtd; /* save one level of indirection */
  XML_Content *ret;
  XML_Content *cpos;
  XML_Char *str;

  /* Detect and prevent integer overflow.
   * The preprocessor guard addresses the "always false" warning
   * from -Wtype-limits on platforms where
   * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
  if (dtd->scaffCount > (size_t)(-1) / sizeof(XML_Content)) {
    return NULL;
  }
  if (dtd->contentStringLen > (size_t)(-1) / sizeof(XML_Char)) {
    return NULL;
  }
#endif
  if (dtd->scaffCount * sizeof(XML_Content)
      > (size_t)(-1) - dtd->contentStringLen * sizeof(XML_Char)) {
    return NULL;
  }

  const size_t allocsize = (dtd->scaffCount * sizeof(XML_Content)
                            + (dtd->contentStringLen * sizeof(XML_Char)));

  ret = (XML_Content *)MALLOC(parser, allocsize);
  if (! ret)
    return NULL;

  str = (XML_Char *)(&ret[dtd->scaffCount]);
  cpos = &ret[1];

  build_node(parser, 0, ret, &cpos, &str);
  return ret;
}


static int mov_write_header(AVFormatContext *s) { AVIOContext *pb = s->pb; MOVMuxContext *mov = s->priv_data; AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 0); int i, ret, hint_track = 0, tmcd_track = 0; mov->fc = s; /* Default mode == MP4 */ mov->mode = MODE_MP4; if (s->oformat) { if (!strcmp("3gp", s->oformat->name)) mov->mode = MODE_3GP; else if (!strcmp("3g2", s->oformat->name)) mov->mode = MODE_3GP|MODE_3G2; else if (!strcmp("mov", s->oformat->name)) mov->mode = MODE_MOV; else if (!strcmp("psp", s->oformat->name)) mov->mode = MODE_PSP; else if (!strcmp("ipod",s->oformat->name)) mov->mode = MODE_IPOD; else if (!strcmp("ismv",s->oformat->name)) mov->mode = MODE_ISM; else if (!strcmp("f4v", s->oformat->name)) mov->mode = MODE_F4V; } if (s->flags & AVFMT_FLAG_BITEXACT) mov->exact = 1; if (mov->flags & FF_MOV_FLAG_DELAY_MOOV) mov->flags |= FF_MOV_FLAG_EMPTY_MOOV; /* Set the FRAGMENT flag if any of the fragmentation methods are * enabled. */ if (mov->max_fragment_duration || mov->max_fragment_size || mov->flags & (FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_FRAG_KEYFRAME | FF_MOV_FLAG_FRAG_CUSTOM)) mov->flags |= FF_MOV_FLAG_FRAGMENT; /* Set other implicit flags immediately */ if (mov->mode == MODE_ISM) mov->flags |= FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_SEPARATE_MOOF | FF_MOV_FLAG_FRAGMENT; if (mov->flags & FF_MOV_FLAG_DASH) mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV | FF_MOV_FLAG_DEFAULT_BASE_MOOF; if (mov->flags & FF_MOV_FLAG_FASTSTART) { mov->reserved_moov_size = -1; } if (mov->use_editlist < 0) { mov->use_editlist = 1; if (mov->flags & FF_MOV_FLAG_FRAGMENT && !(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) { // If we can avoid needing an edit list by shifting the // tracks, prefer that over (trying to) write edit lists // in fragmented output. if (s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) mov->use_editlist = 0; } } if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV && !(mov->flags & FF_MOV_FLAG_DELAY_MOOV) && mov->use_editlist) av_log(s, AV_LOG_WARNING, "No meaningful edit list will be written when using empty_moov without delay_moov\n"); if (!mov->use_editlist && s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_AUTO) s->avoid_negative_ts = AVFMT_AVOID_NEG_TS_MAKE_ZERO; /* Clear the omit_tfhd_offset flag if default_base_moof is set; * if the latter is set that's enough and omit_tfhd_offset doesn't * add anything extra on top of that. */ if (mov->flags & FF_MOV_FLAG_OMIT_TFHD_OFFSET && mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF) mov->flags &= ~FF_MOV_FLAG_OMIT_TFHD_OFFSET; if (mov->frag_interleave && mov->flags & (FF_MOV_FLAG_OMIT_TFHD_OFFSET | FF_MOV_FLAG_SEPARATE_MOOF)) { av_log(s, AV_LOG_ERROR, "Sample interleaving in fragments is mutually exclusive with " "omit_tfhd_offset and separate_moof\n"); return AVERROR(EINVAL); } /* Non-seekable output is ok if using fragmentation. If ism_lookahead * is enabled, we don't support non-seekable output at all. */ if (!s->pb->seekable && (!(mov->flags & FF_MOV_FLAG_FRAGMENT) || mov->ism_lookahead)) { av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); return AVERROR(EINVAL); } if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) { if ((ret = mov_write_identification(pb, s)) < 0) return ret; } mov->nb_streams = s->nb_streams; if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters) mov->chapter_track = mov->nb_streams++; if (mov->flags & FF_MOV_FLAG_RTP_HINT) { /* Add hint tracks for each audio and video stream */ hint_track = mov->nb_streams; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { mov->nb_streams++; } } } if (mov->mode == MODE_MOV) { tmcd_track = mov->nb_streams; /* +1 tmcd track for each video stream with a timecode */ for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (global_tcr || av_dict_get(st->metadata, "timecode", NULL, 0))) mov->nb_meta_tmcd++; } /* check if there is already a tmcd track to remux */ if (mov->nb_meta_tmcd) { for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_tag == MKTAG('t','m','c','d')) { av_log(s, AV_LOG_WARNING, "You requested a copy of the original timecode track " "so timecode metadata are now ignored\n"); mov->nb_meta_tmcd = 0; } } } mov->nb_streams += mov->nb_meta_tmcd; } // Reserve an extra stream for chapters for the case where chapters // are written in the trailer mov->tracks = av_mallocz_array((mov->nb_streams + 1), sizeof(*mov->tracks)); if (!mov->tracks) return AVERROR(ENOMEM); for (i = 0; i < s->nb_streams; i++) { AVStream *st= s->streams[i]; MOVTrack *track= &mov->tracks[i]; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0); track->st = st; track->enc = st->codec; track->language = ff_mov_iso639_to_lang(lang?lang->value:"und", mov->mode!=MODE_MOV); if (track->language < 0) track->language = 0; track->mode = mov->mode; track->tag = mov_find_codec_tag(s, track); if (!track->tag) { av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream #%d, " "codec not currently supported in container\n", avcodec_get_name(st->codec->codec_id), i); ret = AVERROR(EINVAL); goto error; } /* If hinting of this track is enabled by a later hint track, * this is updated. */ track->hint_track = -1; track->start_dts = AV_NOPTS_VALUE; track->start_cts = AV_NOPTS_VALUE; track->end_pts = AV_NOPTS_VALUE; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') || track->tag == MKTAG('m','x','4','p') || track->tag == MKTAG('m','x','4','n') || track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) { if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) { av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n"); ret = AVERROR(EINVAL); goto error; } track->height = track->tag >> 24 == 'n' ? 486 : 576; } if (mov->video_track_timescale) { track->timescale = mov->video_track_timescale; } else { track->timescale = st->time_base.den; while(track->timescale < 10000) track->timescale *= 2; } if (st->codec->width > 65535 || st->codec->height > 65535) { av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codec->width, st->codec->height); ret = AVERROR(EINVAL); goto error; } if (track->mode == MODE_MOV && track->timescale > 100000) av_log(s, AV_LOG_WARNING, "WARNING codec timebase is very high. If duration is too long,\n" "file may not be playable by quicktime. Specify a shorter timebase\n" "or choose different container.\n"); } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { track->timescale = st->codec->sample_rate; if (!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) { av_log(s, AV_LOG_WARNING, "track %d: codec frame size is not set\n", i); track->audio_vbr = 1; }else if (st->codec->codec_id == AV_CODEC_ID_ADPCM_MS || st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV || st->codec->codec_id == AV_CODEC_ID_ILBC){ if (!st->codec->block_align) { av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set for adpcm\n", i); ret = AVERROR(EINVAL); goto error; } track->sample_size = st->codec->block_align; }else if (st->codec->frame_size > 1){ /* assume compressed audio */ track->audio_vbr = 1; }else{ track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels; } if (st->codec->codec_id == AV_CODEC_ID_ILBC || st->codec->codec_id == AV_CODEC_ID_ADPCM_IMA_QT) { track->audio_vbr = 1; } if (track->mode != MODE_MOV && track->enc->codec_id == AV_CODEC_ID_MP3 && track->timescale < 16000) { if (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL) { av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not standard, to mux anyway set strict to -1\n", i, track->enc->sample_rate); ret = AVERROR(EINVAL); goto error; } else { av_log(s, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is not standard in MP4\n", i, track->enc->sample_rate); } } } else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { track->timescale = st->time_base.den; } else if (st->codec->codec_type == AVMEDIA_TYPE_DATA) { track->timescale = st->time_base.den; } else { track->timescale = MOV_TIMESCALE; } if (!track->height) track->height = st->codec->height; /* The ism specific timescale isn't mandatory, but is assumed by * some tools, such as mp4split. */ if (mov->mode == MODE_ISM) track->timescale = 10000000; avpriv_set_pts_info(st, 64, 1, track->timescale); /* copy extradata if it exists */ if (st->codec->extradata_size) { if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE) mov_create_dvd_sub_decoder_specific_info(track, st); else if (!TAG_IS_AVCI(track->tag) && st->codec->codec_id != AV_CODEC_ID_DNXHD) { track->vos_len = st->codec->extradata_size; track->vos_data = av_malloc(track->vos_len); if (!track->vos_data) { ret = AVERROR(ENOMEM); goto error; } memcpy(track->vos_data, st->codec->extradata, track->vos_len); } } } for (i = 0; i < s->nb_streams; i++) { int j; AVStream *st= s->streams[i]; MOVTrack *track= &mov->tracks[i]; if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || track->enc->channel_layout != AV_CH_LAYOUT_MONO) continue; for (j = 0; j < s->nb_streams; j++) { AVStream *stj= s->streams[j]; MOVTrack *trackj= &mov->tracks[j]; if (j == i) continue; if (stj->codec->codec_type != AVMEDIA_TYPE_AUDIO || trackj->enc->channel_layout != AV_CH_LAYOUT_MONO || trackj->language != track->language || trackj->tag != track->tag ) continue; track->multichannel_as_mono++; } } enable_tracks(s); if (mov->reserved_moov_size){ mov->reserved_moov_pos= avio_tell(pb); if (mov->reserved_moov_size > 0) avio_skip(pb, mov->reserved_moov_size); } if (mov->flags & FF_MOV_FLAG_FRAGMENT) { /* If no fragmentation options have been set, set a default. */ if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME | FF_MOV_FLAG_FRAG_CUSTOM)) && !mov->max_fragment_duration && !mov->max_fragment_size) mov->flags |= FF_MOV_FLAG_FRAG_KEYFRAME; } else { if (mov->flags & FF_MOV_FLAG_FASTSTART) mov->reserved_moov_pos = avio_tell(pb); mov_write_mdat_tag(pb, mov); } if (t = av_dict_get(s->metadata, "creation_time", NULL, 0)) mov->time = ff_iso8601_to_unix_time(t->value); if (mov->time) mov->time += 0x7C25B080; // 1970 based -> 1904 based if (mov->chapter_track) if ((ret = mov_create_chapter_track(s, mov->chapter_track)) < 0) goto error; if (mov->flags & FF_MOV_FLAG_RTP_HINT) { /* Initialize the hint tracks for each audio and video stream */ for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO || st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if ((ret = ff_mov_init_hinting(s, hint_track, i)) < 0) goto error; hint_track++; } } } if (mov->nb_meta_tmcd) { /* Initialize the tmcd tracks */ for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; t = global_tcr; if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (!t) t = av_dict_get(st->metadata, "timecode", NULL, 0); if (!t) continue; if ((ret = mov_create_timecode_track(s, tmcd_track, i, t->value)) < 0) goto error; tmcd_track++; } } } avio_flush(pb); if (mov->flags & FF_MOV_FLAG_ISML) mov_write_isml_manifest(pb, mov); if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV && !(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) { if ((ret = mov_write_moov_tag(pb, mov, s)) < 0) return ret; mov->moov_written = 1; if (mov->flags & FF_MOV_FLAG_FASTSTART) mov->reserved_moov_pos = avio_tell(pb); } return 0; error: mov_free(s); return ret; }


addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
           const XML_Char *uri, BINDING **bindingsPtr) {
  static const XML_Char xmlNamespace[]
      = {ASCII_h,      ASCII_t,     ASCII_t,     ASCII_p,      ASCII_COLON,
         ASCII_SLASH,  ASCII_SLASH, ASCII_w,     ASCII_w,      ASCII_w,
         ASCII_PERIOD, ASCII_w,     ASCII_3,     ASCII_PERIOD, ASCII_o,
         ASCII_r,      ASCII_g,     ASCII_SLASH, ASCII_X,      ASCII_M,
         ASCII_L,      ASCII_SLASH, ASCII_1,     ASCII_9,      ASCII_9,
         ASCII_8,      ASCII_SLASH, ASCII_n,     ASCII_a,      ASCII_m,
         ASCII_e,      ASCII_s,     ASCII_p,     ASCII_a,      ASCII_c,
         ASCII_e,      '\0'};
  static const int xmlLen = (int)sizeof(xmlNamespace) / sizeof(XML_Char) - 1;
  static const XML_Char xmlnsNamespace[]
      = {ASCII_h,     ASCII_t,      ASCII_t, ASCII_p, ASCII_COLON,  ASCII_SLASH,
         ASCII_SLASH, ASCII_w,      ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w,
         ASCII_3,     ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g,      ASCII_SLASH,
         ASCII_2,     ASCII_0,      ASCII_0, ASCII_0, ASCII_SLASH,  ASCII_x,
         ASCII_m,     ASCII_l,      ASCII_n, ASCII_s, ASCII_SLASH,  '\0'};
  static const int xmlnsLen
      = (int)sizeof(xmlnsNamespace) / sizeof(XML_Char) - 1;

  XML_Bool mustBeXML = XML_FALSE;
  XML_Bool isXML = XML_TRUE;
  XML_Bool isXMLNS = XML_TRUE;

  BINDING *b;
  int len;

  /* empty URI is only valid for default namespace per XML NS 1.0 (not 1.1) */
  if (*uri == XML_T('\0') && prefix->name)
    return XML_ERROR_UNDECLARING_PREFIX;

  if (prefix->name && prefix->name[0] == XML_T(ASCII_x)
      && prefix->name[1] == XML_T(ASCII_m)
      && prefix->name[2] == XML_T(ASCII_l)) {
    /* Not allowed to bind xmlns */
    if (prefix->name[3] == XML_T(ASCII_n) && prefix->name[4] == XML_T(ASCII_s)
        && prefix->name[5] == XML_T('\0'))
      return XML_ERROR_RESERVED_PREFIX_XMLNS;

    if (prefix->name[3] == XML_T('\0'))
      mustBeXML = XML_TRUE;
  }

  for (len = 0; uri[len]; len++) {
    if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len]))
      isXML = XML_FALSE;

    if (! mustBeXML && isXMLNS
        && (len > xmlnsLen || uri[len] != xmlnsNamespace[len]))
      isXMLNS = XML_FALSE;
  }
  isXML = isXML && len == xmlLen;
  isXMLNS = isXMLNS && len == xmlnsLen;

  if (mustBeXML != isXML)
    return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML
                     : XML_ERROR_RESERVED_NAMESPACE_URI;

  if (isXMLNS)
    return XML_ERROR_RESERVED_NAMESPACE_URI;

  if (parser->m_namespaceSeparator)
    len++;
  if (parser->m_freeBindingList) {
    b = parser->m_freeBindingList;
    if (len > b->uriAlloc) {
      /* Detect and prevent integer overflow */
      if (len > INT_MAX - EXPAND_SPARE) {
        return XML_ERROR_NO_MEMORY;
      }

      /* Detect and prevent integer overflow.
       * The preprocessor guard addresses the "always false" warning
       * from -Wtype-limits on platforms where
       * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
      if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) {
        return XML_ERROR_NO_MEMORY;
      }
#endif

      XML_Char *temp = (XML_Char *)REALLOC(
          parser, b->uri, sizeof(XML_Char) * (len + EXPAND_SPARE));
      if (temp == NULL)
        return XML_ERROR_NO_MEMORY;
      b->uri = temp;
      b->uriAlloc = len + EXPAND_SPARE;
    }
    parser->m_freeBindingList = b->nextTagBinding;
  } else {
    b = (BINDING *)MALLOC(parser, sizeof(BINDING));
    if (! b)
      return XML_ERROR_NO_MEMORY;

    /* Detect and prevent integer overflow */
    if (len > INT_MAX - EXPAND_SPARE) {
      return XML_ERROR_NO_MEMORY;
    }
    /* Detect and prevent integer overflow.
     * The preprocessor guard addresses the "always false" warning
     * from -Wtype-limits on platforms where
     * sizeof(unsigned int) < sizeof(size_t), e.g. on x86_64. */
#if UINT_MAX >= SIZE_MAX
    if ((unsigned)(len + EXPAND_SPARE) > (size_t)(-1) / sizeof(XML_Char)) {
      return XML_ERROR_NO_MEMORY;
    }
#endif

    b->uri
        = (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE));
    if (! b->uri) {
      FREE(parser, b);
      return XML_ERROR_NO_MEMORY;
    }
    b->uriAlloc = len + EXPAND_SPARE;
  }
  b->uriLen = len;
  memcpy(b->uri, uri, len * sizeof(XML_Char));
  if (parser->m_namespaceSeparator)
    b->uri[len - 1] = parser->m_namespaceSeparator;
  b->prefix = prefix;
  b->attId = attId;
  b->prevPrefixBinding = prefix->binding;
  /* NULL binding when default namespace undeclared */
  if (*uri == XML_T('\0') && prefix == &parser->m_dtd->defaultPrefix)
    prefix->binding = NULL;
  else
    prefix->binding = b;
  b->nextTagBinding = *bindingsPtr;
  *bindingsPtr = b;
  /* if attId == NULL then we are not starting a namespace scope */
  if (attId && parser->m_startNamespaceDeclHandler)
    parser->m_startNamespaceDeclHandler(parser->m_handlerArg, prefix->name,
                                        prefix->binding ? uri : 0);
  return XML_ERROR_NONE;
}


static void mkiss_close(struct tty_struct *tty)
{
	struct mkiss *ax;

	write_lock_irq(&disc_data_lock);
	ax = tty->disc_data;
	tty->disc_data = NULL;
	write_unlock_irq(&disc_data_lock);

	if (!ax)
		return;

	/*
	 * We have now ensured that nobody can start using ap from now on, but
	 * we have to wait for all existing users to finish.
	 */
	if (!refcount_dec_and_test(&ax->refcnt))
		wait_for_completion(&ax->dead);
	/*
	 * Halt the transmit queue so that a new transmit cannot scribble
	 * on our buffers
	 */
	netif_stop_queue(ax->dev);

	ax->tty = NULL;

	unregister_netdev(ax->dev);

	/* Free all AX25 frame buffers after unreg. */
	kfree(ax->rbuff);
	kfree(ax->xbuff);

	free_netdev(ax->dev);
}


void aio_context_set_poll_params(AioContext *ctx, int64_t max_ns, Error **errp) { error_setg(errp, "AioContext polling is not implemented on Windows"); }


static void host ( struct parse * pcmd , FILE * fp ) {
 int i ;
 if ( pcmd -> nargs == 0 ) {
 if ( havehost ) ( void ) fprintf ( fp , "current host is %s\n" , currenthost ) ;
 else ( void ) fprintf ( fp , "no current host\n" ) ;
 return ;
 }
 i = 0 ;
 ai_fam_templ = ai_fam_default ;
 if ( pcmd -> nargs == 2 ) {
 if ( ! strcmp ( "-4" , pcmd -> argval [ i ] . string ) ) ai_fam_templ = AF_INET ;
 else if ( ! strcmp ( "-6" , pcmd -> argval [ i ] . string ) ) ai_fam_templ = AF_INET6 ;
 else goto no_change ;
 i = 1 ;
 }
 if ( openhost ( pcmd -> argval [ i ] . string , ai_fam_templ ) ) {
 fprintf ( fp , "current host set to %s\n" , currenthost ) ;
 }
 else {
 no_change : if ( havehost ) fprintf ( fp , "current host remains %s\n" , currenthost ) ;
 else fprintf ( fp , "still no current host\n" ) ;
 }
 }


goto_tabpage_tp(
    tabpage_T	*tp,
    int		trigger_enter_autocmds,
    int		trigger_leave_autocmds)
{
    // Don't repeat a message in another tab page.
    set_keep_msg(NULL, 0);

    if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer,
					trigger_leave_autocmds) == OK)
    {
	if (valid_tabpage(tp))
	    enter_tabpage(tp, curbuf, trigger_enter_autocmds,
		    trigger_leave_autocmds);
	else
	    enter_tabpage(curtab, curbuf, trigger_enter_autocmds,
		    trigger_leave_autocmds);
    }
}


static int rscc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { RsccContext *ctx = avctx->priv_data; GetByteContext *gbc = &ctx->gbc; GetByteContext tiles_gbc; AVFrame *frame = data; const uint8_t *pixels, *raw; uint8_t *inflated_tiles = NULL; int tiles_nb, packed_size, pixel_size = 0; int i, ret = 0; bytestream2_init(gbc, avpkt->data, avpkt->size); /* Size check */ if (bytestream2_get_bytes_left(gbc) < 12) { av_log(avctx, AV_LOG_ERROR, "Packet too small (%d)\n", avpkt->size); return AVERROR_INVALIDDATA; } /* Read number of tiles, and allocate the array */ tiles_nb = bytestream2_get_le16(gbc); av_fast_malloc(&ctx->tiles, &ctx->tiles_size, tiles_nb * sizeof(*ctx->tiles)); if (!ctx->tiles) { ret = AVERROR(ENOMEM); goto end; } av_log(avctx, AV_LOG_DEBUG, "Frame with %d tiles.\n", tiles_nb); /* When there are more than 5 tiles, they are packed together with * a size header. When that size does not match the number of tiles * times the tile size, it means it needs to be inflated as well */ if (tiles_nb > 5) { uLongf packed_tiles_size; if (tiles_nb < 32) packed_tiles_size = bytestream2_get_byte(gbc); else packed_tiles_size = bytestream2_get_le16(gbc); ff_dlog(avctx, "packed tiles of size %lu.\n", packed_tiles_size); /* If necessary, uncompress tiles, and hijack the bytestream reader */ if (packed_tiles_size != tiles_nb * TILE_SIZE) { uLongf length = tiles_nb * TILE_SIZE; inflated_tiles = av_malloc(length); if (!inflated_tiles) { ret = AVERROR(ENOMEM); goto end; } ret = uncompress(inflated_tiles, &length, gbc->buffer, packed_tiles_size); if (ret) { av_log(avctx, AV_LOG_ERROR, "Tile deflate error %d.\n", ret); ret = AVERROR_UNKNOWN; goto end; } /* Skip the compressed tile section in the main byte reader, * and point it to read the newly uncompressed data */ bytestream2_skip(gbc, packed_tiles_size); bytestream2_init(&tiles_gbc, inflated_tiles, length); gbc = &tiles_gbc; } } /* Fill in array of tiles, keeping track of how many pixels are updated */ for (i = 0; i < tiles_nb; i++) { ctx->tiles[i].x = bytestream2_get_le16(gbc); ctx->tiles[i].w = bytestream2_get_le16(gbc); ctx->tiles[i].y = bytestream2_get_le16(gbc); ctx->tiles[i].h = bytestream2_get_le16(gbc); pixel_size += ctx->tiles[i].w * ctx->tiles[i].h * ctx->component_size; ff_dlog(avctx, "tile %d orig(%d,%d) %dx%d.\n", i, ctx->tiles[i].x, ctx->tiles[i].y, ctx->tiles[i].w, ctx->tiles[i].h); if (ctx->tiles[i].w == 0 || ctx->tiles[i].h == 0) { av_log(avctx, AV_LOG_ERROR, "invalid tile %d at (%d.%d) with size %dx%d.\n", i, ctx->tiles[i].x, ctx->tiles[i].y, ctx->tiles[i].w, ctx->tiles[i].h); ret = AVERROR_INVALIDDATA; goto end; } else if (ctx->tiles[i].x + ctx->tiles[i].w > avctx->width || ctx->tiles[i].y + ctx->tiles[i].h > avctx->height) { av_log(avctx, AV_LOG_ERROR, "out of bounds tile %d at (%d.%d) with size %dx%d.\n", i, ctx->tiles[i].x, ctx->tiles[i].y, ctx->tiles[i].w, ctx->tiles[i].h); ret = AVERROR_INVALIDDATA; goto end; } } /* Reset the reader in case it had been modified before */ gbc = &ctx->gbc; /* Extract how much pixel data the tiles contain */ if (pixel_size < 0x100) packed_size = bytestream2_get_byte(gbc); else if (pixel_size < 0x10000) packed_size = bytestream2_get_le16(gbc); else if (pixel_size < 0x1000000) packed_size = bytestream2_get_le24(gbc); else packed_size = bytestream2_get_le32(gbc); ff_dlog(avctx, "pixel_size %d packed_size %d.\n", pixel_size, packed_size); if (packed_size < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid tile size %d\n", packed_size); ret = AVERROR_INVALIDDATA; goto end; } /* Get pixels buffer, it may be deflated or just raw */ if (pixel_size == packed_size) { if (bytestream2_get_bytes_left(gbc) < pixel_size) { av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", pixel_size); ret = AVERROR_INVALIDDATA; goto end; } pixels = gbc->buffer; } else { uLongf len = ctx->inflated_size; if (bytestream2_get_bytes_left(gbc) < packed_size) { av_log(avctx, AV_LOG_ERROR, "Insufficient input for %d\n", packed_size); ret = AVERROR_INVALIDDATA; goto end; } ret = uncompress(ctx->inflated_buf, &len, gbc->buffer, packed_size); if (ret) { av_log(avctx, AV_LOG_ERROR, "Pixel deflate error %d.\n", ret); ret = AVERROR_UNKNOWN; goto end; } pixels = ctx->inflated_buf; } /* Allocate when needed */ ret = ff_reget_buffer(avctx, ctx->reference); if (ret < 0) goto end; /* Pointer to actual pixels, will be updated when data is consumed */ raw = pixels; for (i = 0; i < tiles_nb; i++) { uint8_t *dst = ctx->reference->data[0] + ctx->reference->linesize[0] * (avctx->height - ctx->tiles[i].y - 1) + ctx->tiles[i].x * ctx->component_size; av_image_copy_plane(dst, -1 * ctx->reference->linesize[0], raw, ctx->tiles[i].w * ctx->component_size, ctx->tiles[i].w * ctx->component_size, ctx->tiles[i].h); raw += ctx->tiles[i].w * ctx->component_size * ctx->tiles[i].h; } /* Frame is ready to be output */ ret = av_frame_ref(frame, ctx->reference); if (ret < 0) goto end; /* Keyframe when the number of pixels updated matches the whole surface */ if (pixel_size == ctx->inflated_size) { frame->pict_type = AV_PICTURE_TYPE_I; frame->key_frame = 1; } else { frame->pict_type = AV_PICTURE_TYPE_P; } if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); if (pal) { frame->palette_has_changed = 1; memcpy(ctx->pal, pal, AVPALETTE_SIZE); } memcpy (frame->data[1], ctx->pal, AVPALETTE_SIZE); } *got_frame = 1; end: av_free(inflated_tiles); return ret; }


static int add_doubles_metadata(const uint8_t **buf, int count, const char *name, const char *sep, TiffContext *s) { char *ap; int i; double *dp = av_malloc(count * sizeof(double)); if (!dp) return AVERROR(ENOMEM); for (i = 0; i < count; i++) dp[i] = tget_double(buf, s->le); ap = doubles2str(dp, count, sep); av_freep(&dp); if (!ap) return AVERROR(ENOMEM); av_dict_set(&s->picture.metadata, name, ap, AV_DICT_DONT_STRDUP_VAL); return 0; }


static void finishup ( SplineFont * sf , struct alltabs * at ) {
 int strlen , shlen , glen , enclen , csetlen , cstrlen , prvlen ;
 int base , eotop , strhead ;
 int output_enc = ( at -> format == ff_cff && ! isStdEncoding ( sf , at -> map ) ) ;
 storesid ( at , NULL ) ;
 strlen = ftell ( at -> sidf ) + ( shlen = ftell ( at -> sidh ) ) ;
 glen = sizeof ( short ) ;
 enclen = ftell ( at -> encoding ) ;
 csetlen = ftell ( at -> charset ) ;
 cstrlen = ftell ( at -> charstrings ) ;
 prvlen = ftell ( at -> private ) ;
 base = ftell ( at -> cfff ) ;
 if ( base + 6 * 3 + strlen + glen + enclen + csetlen + cstrlen + prvlen > 32767 ) {
 at -> cfflongoffset = true ;
 base += 5 * 5 + 4 ;
 }
 else base += 5 * 3 + 4 ;
 strhead = 2 + ( at -> sidcnt > 1 ) ;
 base += strhead ;
 dumpsizedint ( at -> cfff , at -> cfflongoffset , base + strlen + glen , 15 ) ;
 if ( output_enc ) dumpsizedint ( at -> cfff , at -> cfflongoffset , base + strlen + glen + csetlen , 16 ) ;
 else {
 dumpsizedint ( at -> cfff , at -> cfflongoffset , 0 , 16 ) ;
 enclen = 0 ;
 }
 dumpsizedint ( at -> cfff , at -> cfflongoffset , base + strlen + glen + csetlen + enclen , 17 ) ;
 dumpsizedint ( at -> cfff , at -> cfflongoffset , at -> privatelen , - 1 ) ;
 dumpsizedint ( at -> cfff , at -> cfflongoffset , base + strlen + glen + csetlen + enclen + cstrlen , 18 ) ;
 eotop = base - strhead - at -> lenpos - 1 ;
 if ( at -> cfflongoffset ) {
 fseek ( at -> cfff , 3 , SEEK_SET ) ;
 putc ( 4 , at -> cfff ) ;
 }
 fseek ( at -> cfff , at -> lenpos , SEEK_SET ) ;
 putshort ( at -> cfff , eotop ) ;
 fseek ( at -> cfff , 0 , SEEK_END ) ;
 putshort ( at -> cfff , at -> sidcnt - 1 ) ;
 if ( at -> sidcnt != 1 ) {
 putc ( at -> sidlongoffset ? 4 : 2 , at -> cfff ) ;
 if ( ! ttfcopyfile ( at -> cfff , at -> sidh , base , "CFF-StringBase" ) ) at -> error = true ;
 if ( ! ttfcopyfile ( at -> cfff , at -> sidf , base + shlen , "CFF-StringData" ) ) at -> error = true ;
 }
 putshort ( at -> cfff , 0 ) ;
 if ( ! ttfcopyfile ( at -> cfff , at -> charset , base + strlen + glen , "CFF-Charset" ) ) at -> error = true ;
 if ( ! ttfcopyfile ( at -> cfff , at -> encoding , base + strlen + glen + csetlen , "CFF-Encoding" ) ) at -> error = true ;
 if ( ! ttfcopyfile ( at -> cfff , at -> charstrings , base + strlen + glen + csetlen + enclen , "CFF-CharStrings" ) ) at -> error = true ;
 if ( ! ttfcopyfile ( at -> cfff , at -> private , base + strlen + glen + csetlen + enclen + cstrlen , "CFF-Private" ) ) at -> error = true ;
 }


static int kvm_inject_mce_oldstyle ( X86CPU * cpu ) {
 CPUX86State * env = & cpu -> env ;
 if ( ! kvm_has_vcpu_events ( ) && env -> exception_injected == EXCP12_MCHK ) {
 unsigned int bank , bank_num = env -> mcg_cap & 0xff ;
 struct kvm_x86_mce mce ;
 env -> exception_injected = - 1 ;
 for ( bank = 0 ;
 bank < bank_num ;
 bank ++ ) {
 if ( env -> mce_banks [ bank * 4 + 1 ] & MCI_STATUS_VAL ) {
 break ;
 }
 }
 assert ( bank < bank_num ) ;
 mce . bank = bank ;
 mce . status = env -> mce_banks [ bank * 4 + 1 ] ;
 mce . mcg_status = env -> mcg_status ;
 mce . addr = env -> mce_banks [ bank * 4 + 2 ] ;
 mce . misc = env -> mce_banks [ bank * 4 + 3 ] ;
 return kvm_vcpu_ioctl ( CPU ( cpu ) , KVM_X86_SET_MCE , & mce ) ;
 }
 return 0 ;
 }


int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; AVIOContext *pb = s->pb; MOVTrack *trk = &mov->tracks[pkt->stream_index]; AVCodecContext *enc = trk->enc; unsigned int samples_in_chunk = 0; int size = pkt->size, ret = 0; uint8_t *reformatted_data = NULL; if (trk->entry) { int64_t duration = pkt->dts - trk->cluster[trk->entry - 1].dts; if (duration < 0 || duration > INT_MAX) { av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / timestamp: %"PRId64" is out of range for mov/mp4 format\n", duration, pkt->dts ); pkt->dts = trk->cluster[trk->entry - 1].dts + 1; pkt->pts = AV_NOPTS_VALUE; } if (pkt->duration < 0) { av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" is invalid\n", pkt->duration); return AVERROR(EINVAL); } } if (mov->flags & FF_MOV_FLAG_FRAGMENT) { int ret; if (mov->moov_written || mov->flags & FF_MOV_FLAG_EMPTY_MOOV) { if (mov->frag_interleave && mov->fragments > 0) { if (trk->entry - trk->entries_flushed >= mov->frag_interleave) { if ((ret = mov_flush_fragment_interleaving(s, trk)) < 0) return ret; } } if (!trk->mdat_buf) { if ((ret = avio_open_dyn_buf(&trk->mdat_buf)) < 0) return ret; } pb = trk->mdat_buf; } else { if (!mov->mdat_buf) { if ((ret = avio_open_dyn_buf(&mov->mdat_buf)) < 0) return ret; } pb = mov->mdat_buf; } } if (enc->codec_id == AV_CODEC_ID_AMR_NB) { /* We must find out how many AMR blocks there are in one packet */ static const uint16_t packed_size[16] = {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1}; int len = 0; while (len < size && samples_in_chunk < 100) { len += packed_size[(pkt->data[len] >> 3) & 0x0F]; samples_in_chunk++; } if (samples_in_chunk > 1) { av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n"); return -1; } } else if (enc->codec_id == AV_CODEC_ID_ADPCM_MS || enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) { samples_in_chunk = enc->frame_size; } else if (trk->sample_size) samples_in_chunk = size / trk->sample_size; else samples_in_chunk = 1; /* copy extradata if it exists */ if (trk->vos_len == 0 && enc->extradata_size > 0 && !TAG_IS_AVCI(trk->tag) && (enc->codec_id != AV_CODEC_ID_DNXHD)) { trk->vos_len = enc->extradata_size; trk->vos_data = av_malloc(trk->vos_len); if (!trk->vos_data) { ret = AVERROR(ENOMEM); goto err; } memcpy(trk->vos_data, enc->extradata, trk->vos_len); } if (enc->codec_id == AV_CODEC_ID_AAC && pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { if (!s->streams[pkt->stream_index]->nb_frames) { av_log(s, AV_LOG_ERROR, "Malformed AAC bitstream detected: " "use the audio bitstream filter 'aac_adtstoasc' to fix it " "('-bsf:a aac_adtstoasc' option with ffmpeg)\n"); return -1; } av_log(s, AV_LOG_WARNING, "aac bitstream error\n"); } if (enc->codec_id == AV_CODEC_ID_H264 && trk->vos_len > 0 && *(uint8_t *)trk->vos_data != 1 && !TAG_IS_AVCI(trk->tag)) { /* from x264 or from bytestream h264 */ /* nal reformating needed */ if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) { ff_avc_parse_nal_units_buf(pkt->data, &reformatted_data, &size); avio_write(pb, reformatted_data, size); } else { if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) { size = ff_mov_cenc_avc_parse_nal_units(&trk->cenc, pb, pkt->data, size); if (size < 0) { ret = size; goto err; } } else { size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size); } } } else if (enc->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 && (AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) { /* extradata is Annex B, assume the bitstream is too and convert it */ if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) { ff_hevc_annexb2mp4_buf(pkt->data, &reformatted_data, &size, 0, NULL); avio_write(pb, reformatted_data, size); } else { size = ff_hevc_annexb2mp4(pb, pkt->data, pkt->size, 0, NULL); } #if CONFIG_AC3_PARSER } else if (enc->codec_id == AV_CODEC_ID_EAC3) { size = handle_eac3(mov, pkt, trk); if (size < 0) return size; else if (!size) goto end; avio_write(pb, pkt->data, size); #endif } else { if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) { if (enc->codec_id == AV_CODEC_ID_H264 && enc->extradata_size > 4) { int nal_size_length = (enc->extradata[4] & 0x3) + 1; ret = ff_mov_cenc_avc_write_nal_units(s, &trk->cenc, nal_size_length, pb, pkt->data, size); } else { ret = ff_mov_cenc_write_packet(&trk->cenc, pb, pkt->data, size); } if (ret) { goto err; } } else { avio_write(pb, pkt->data, size); } } if ((enc->codec_id == AV_CODEC_ID_DNXHD || enc->codec_id == AV_CODEC_ID_AC3) && !trk->vos_len) { /* copy frame to create needed atoms */ trk->vos_len = size; trk->vos_data = av_malloc(size); if (!trk->vos_data) { ret = AVERROR(ENOMEM); goto err; } memcpy(trk->vos_data, pkt->data, size); } if (trk->entry >= trk->cluster_capacity) { unsigned new_capacity = 2 * (trk->entry + MOV_INDEX_CLUSTER_SIZE); if (av_reallocp_array(&trk->cluster, new_capacity, sizeof(*trk->cluster))) { ret = AVERROR(ENOMEM); goto err; } trk->cluster_capacity = new_capacity; } trk->cluster[trk->entry].pos = avio_tell(pb) - size; trk->cluster[trk->entry].samples_in_chunk = samples_in_chunk; trk->cluster[trk->entry].chunkNum = 0; trk->cluster[trk->entry].size = size; trk->cluster[trk->entry].entries = samples_in_chunk; trk->cluster[trk->entry].dts = pkt->dts; if (!trk->entry && trk->start_dts != AV_NOPTS_VALUE) { if (!trk->frag_discont) { /* First packet of a new fragment. We already wrote the duration * of the last packet of the previous fragment based on track_duration, * which might not exactly match our dts. Therefore adjust the dts * of this packet to be what the previous packets duration implies. */ trk->cluster[trk->entry].dts = trk->start_dts + trk->track_duration; /* We also may have written the pts and the corresponding duration * in sidx/tfrf/tfxd tags; make sure the sidx pts and duration match up with * the next fragment. This means the cts of the first sample must * be the same in all fragments. */ if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) || mov->mode == MODE_ISM) pkt->pts = pkt->dts + trk->end_pts - trk->cluster[trk->entry].dts; } else { /* New fragment, but discontinuous from previous fragments. * Pretend the duration sum of the earlier fragments is * pkt->dts - trk->start_dts. */ trk->frag_start = pkt->dts - trk->start_dts; trk->end_pts = AV_NOPTS_VALUE; trk->frag_discont = 0; } } if (!trk->entry && trk->start_dts == AV_NOPTS_VALUE && !mov->use_editlist && s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO) { /* Not using edit lists and shifting the first track to start from zero. * If the other streams start from a later timestamp, we won't be able * to signal the difference in starting time without an edit list. * Thus move the timestamp for this first sample to 0, increasing * its duration instead. */ trk->cluster[trk->entry].dts = trk->start_dts = 0; } if (trk->start_dts == AV_NOPTS_VALUE) { trk->start_dts = pkt->dts; if (trk->frag_discont) { if (mov->use_editlist) { /* Pretend the whole stream started at pts=0, with earlier fragments * already written. If the stream started at pts=0, the duration sum * of earlier fragments would have been pkt->pts. */ trk->frag_start = pkt->pts; trk->start_dts = pkt->dts - pkt->pts; } else { /* Pretend the whole stream started at dts=0, with earlier fragments * already written, with a duration summing up to pkt->dts. */ trk->frag_start = pkt->dts; trk->start_dts = 0; } trk->frag_discont = 0; } else if (pkt->dts && mov->moov_written) av_log(s, AV_LOG_WARNING, "Track %d starts with a nonzero dts %"PRId64", while the moov " "already has been written. Set the delay_moov flag to handle " "this case.\n", pkt->stream_index, pkt->dts); } trk->track_duration = pkt->dts - trk->start_dts + pkt->duration; trk->last_sample_is_subtitle_end = 0; if (pkt->pts == AV_NOPTS_VALUE) { av_log(s, AV_LOG_WARNING, "pts has no value\n"); pkt->pts = pkt->dts; } if (pkt->dts != pkt->pts) trk->flags |= MOV_TRACK_CTTS; trk->cluster[trk->entry].cts = pkt->pts - pkt->dts; trk->cluster[trk->entry].flags = 0; if (trk->start_cts == AV_NOPTS_VALUE) trk->start_cts = pkt->pts - pkt->dts; if (trk->end_pts == AV_NOPTS_VALUE) trk->end_pts = trk->cluster[trk->entry].dts + trk->cluster[trk->entry].cts + pkt->duration; else trk->end_pts = FFMAX(trk->end_pts, trk->cluster[trk->entry].dts + trk->cluster[trk->entry].cts + pkt->duration); if (enc->codec_id == AV_CODEC_ID_VC1) { mov_parse_vc1_frame(pkt, trk); } else if (pkt->flags & AV_PKT_FLAG_KEY) { if (mov->mode == MODE_MOV && enc->codec_id == AV_CODEC_ID_MPEG2VIDEO && trk->entry > 0) { // force sync sample for the first key frame mov_parse_mpeg2_frame(pkt, &trk->cluster[trk->entry].flags); if (trk->cluster[trk->entry].flags & MOV_PARTIAL_SYNC_SAMPLE) trk->flags |= MOV_TRACK_STPS; } else { trk->cluster[trk->entry].flags = MOV_SYNC_SAMPLE; } if (trk->cluster[trk->entry].flags & MOV_SYNC_SAMPLE) trk->has_keyframes++; } trk->entry++; trk->sample_count += samples_in_chunk; mov->mdat_size += size; if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) ff_mov_add_hinted_packet(s, pkt, trk->hint_track, trk->entry, reformatted_data, size); end: err: av_free(reformatted_data); return ret; }


static ulmbcs_byte_t FindLMBCSLocale ( const char * LocaleID ) {
 const struct _LocaleLMBCSGrpMap * pTable = LocaleLMBCSGrpMap ;
 if ( ( ! LocaleID ) || ( ! * LocaleID ) ) {
 return 0 ;
 }
 while ( pTable -> LocaleID ) {
 if ( * pTable -> LocaleID == * LocaleID ) {
 if ( uprv_strncmp ( pTable -> LocaleID , LocaleID , strlen ( pTable -> LocaleID ) ) == 0 ) return pTable -> OptGroup ;
 }
 else if ( * pTable -> LocaleID > * LocaleID ) break ;
 pTable ++ ;
 }
 return ULMBCS_GRP_L1 ;
 }


static void func_decode_delayinminute ( gchar * s , guint16 value ) {
 if ( value == 0 ) {
 g_snprintf ( s , ITEM_LABEL_LENGTH , "%d minutes (Not permitted)" , value ) ;
 }
 else {
 g_snprintf ( s , ITEM_LABEL_LENGTH , "%d minutes" , value ) ;
 }
 }


static CharDriverState *net_vhost_parse_chardev(const NetdevVhostUserOptions *opts) { CharDriverState *chr = qemu_chr_find(opts->chardev); VhostUserChardevProps props; if (chr == NULL) { error_report("chardev \"%s\" not found", opts->chardev); return NULL; } /* inspect chardev opts */ memset(&props, 0, sizeof(props)); if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, NULL)) { return NULL; } if (!props.is_socket || !props.is_unix) { error_report("chardev \"%s\" is not a unix socket", opts->chardev); return NULL; } qemu_chr_fe_claim_no_fail(chr); return chr; }


void isis_notif_version_skew(const struct isis_circuit *circuit,
			     uint8_t version, const char *raw_pdu,
			     size_t raw_pdu_len)
{
	const char *xpath = "/frr-isisd:version-skew";
	struct list *arguments = yang_data_list_new();
	char xpath_arg[XPATH_MAXLEN];
	struct yang_data *data;
	struct isis_area *area = circuit->area;

	notif_prep_instance_hdr(xpath, area, "default", arguments);
	notif_prepr_iface_hdr(xpath, circuit, arguments);
	snprintf(xpath_arg, sizeof(xpath_arg), "%s/protocol-version", xpath);
	data = yang_data_new_uint8(xpath_arg, version);
	listnode_add(arguments, data);
	snprintf(xpath_arg, sizeof(xpath_arg), "%s/raw-pdu", xpath);
	data = yang_data_new(xpath_arg, raw_pdu);
	listnode_add(arguments, data);

	hook_call(isis_hook_version_skew, circuit, version, raw_pdu,
		  raw_pdu_len);

	nb_notification_send(xpath, arguments);
}