project
stringclasses 2
values | commit_id
stringlengths 40
40
| target
int64 0
1
| func
stringlengths 26
142k
| idx
int64 0
27.3k
|
---|---|---|---|---|
qemu | b3db211f3c80bb996a704d665fe275619f728bd4 | 0 | static void test_visitor_in_wrong_type(TestInputVisitorData *data,
const void *unused)
{
TestStruct *p = NULL;
Visitor *v;
strList *q = NULL;
int64_t i;
Error *err = NULL;
/* Make sure arrays and structs cannot be confused */
v = visitor_input_test_init(data, "[]");
visit_type_TestStruct(v, NULL, &p, &err);
error_free_or_abort(&err);
g_assert(!p);
v = visitor_input_test_init(data, "{}");
visit_type_strList(v, NULL, &q, &err);
error_free_or_abort(&err);
assert(!q);
/* Make sure primitives and struct cannot be confused */
v = visitor_input_test_init(data, "1");
visit_type_TestStruct(v, NULL, &p, &err);
error_free_or_abort(&err);
g_assert(!p);
v = visitor_input_test_init(data, "{}");
visit_type_int(v, NULL, &i, &err);
error_free_or_abort(&err);
/* Make sure primitives and arrays cannot be confused */
v = visitor_input_test_init(data, "1");
visit_type_strList(v, NULL, &q, &err);
error_free_or_abort(&err);
assert(!q);
v = visitor_input_test_init(data, "[]");
visit_type_int(v, NULL, &i, &err);
error_free_or_abort(&err);
}
| 23,231 |
qemu | a3fa1d78cbae2259491b17689812edcb643a3b30 | 0 | static int buffered_close(void *opaque)
{
MigrationState *s = opaque;
DPRINTF("closing\n");
s->xfer_limit = INT_MAX;
while (!qemu_file_get_error(s->file) && s->buffer_size) {
buffered_flush(s);
}
return migrate_fd_close(s);
}
| 23,232 |
qemu | 539de1246d355d3b8aa33fb7cde732352d8827c7 | 0 | static int blk_mig_save_bulked_block(Monitor *mon, QEMUFile *f)
{
int64_t completed_sector_sum = 0;
BlkMigDevState *bmds;
int progress;
int ret = 0;
QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {
if (bmds->bulk_completed == 0) {
if (mig_save_device_bulk(mon, f, bmds) == 1) {
/* completed bulk section for this device */
bmds->bulk_completed = 1;
}
completed_sector_sum += bmds->completed_sectors;
ret = 1;
break;
} else {
completed_sector_sum += bmds->completed_sectors;
}
}
if (block_mig_state.total_sector_sum != 0) {
progress = completed_sector_sum * 100 /
block_mig_state.total_sector_sum;
} else {
progress = 100;
}
if (progress != block_mig_state.prev_progress) {
block_mig_state.prev_progress = progress;
qemu_put_be64(f, (progress << BDRV_SECTOR_BITS)
| BLK_MIG_FLAG_PROGRESS);
monitor_printf(mon, "Completed %d %%\r", progress);
monitor_flush(mon);
}
return ret;
}
| 23,233 |
qemu | 46746dbaa8c2c421b9bda78193caad57d7fb1136 | 0 | static void vfio_msi_enable(VFIOPCIDevice *vdev)
{
int ret, i;
vfio_disable_interrupts(vdev);
vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
retry:
vdev->msi_vectors = g_malloc0(vdev->nr_vectors * sizeof(VFIOMSIVector));
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
MSIMessage msg = msi_get_message(&vdev->pdev, i);
vector->vdev = vdev;
vector->virq = -1;
vector->use = true;
if (event_notifier_init(&vector->interrupt, 0)) {
error_report("vfio: Error: event_notifier_init failed");
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
vfio_msi_interrupt, NULL, vector);
/*
* Attempt to enable route through KVM irqchip,
* default to userspace handling if unavailable.
*/
vfio_add_kvm_msi_virq(vector, &msg, false);
}
/* Set interrupt type prior to possible interrupts */
vdev->interrupt = VFIO_INT_MSI;
ret = vfio_enable_vectors(vdev, false);
if (ret) {
if (ret < 0) {
error_report("vfio: Error: Failed to setup MSI fds: %m");
} else if (ret != vdev->nr_vectors) {
error_report("vfio: Error: Failed to enable %d "
"MSI vectors, retry with %d", vdev->nr_vectors, ret);
}
for (i = 0; i < vdev->nr_vectors; i++) {
VFIOMSIVector *vector = &vdev->msi_vectors[i];
if (vector->virq >= 0) {
vfio_remove_kvm_msi_virq(vector);
}
qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt),
NULL, NULL, NULL);
event_notifier_cleanup(&vector->interrupt);
}
g_free(vdev->msi_vectors);
if (ret > 0 && ret != vdev->nr_vectors) {
vdev->nr_vectors = ret;
goto retry;
}
vdev->nr_vectors = 0;
/*
* Failing to setup MSI doesn't really fall within any specification.
* Let's try leaving interrupts disabled and hope the guest figures
* out to fall back to INTx for this device.
*/
error_report("vfio: Error: Failed to enable MSI");
vdev->interrupt = VFIO_INT_NONE;
return;
}
trace_vfio_msi_enable(vdev->vbasedev.name, vdev->nr_vectors);
}
| 23,234 |
qemu | 0e9b9edae7bebfd31fdbead4ccbbce03876a7edd | 0 | build_madt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
{
int madt_start = table_data->len;
const MemMapEntry *memmap = guest_info->memmap;
const int *irqmap = guest_info->irqmap;
AcpiMultipleApicTable *madt;
AcpiMadtGenericDistributor *gicd;
AcpiMadtGenericMsiFrame *gic_msi;
int i;
madt = acpi_data_push(table_data, sizeof *madt);
gicd = acpi_data_push(table_data, sizeof *gicd);
gicd->type = ACPI_APIC_GENERIC_DISTRIBUTOR;
gicd->length = sizeof(*gicd);
gicd->base_address = memmap[VIRT_GIC_DIST].base;
for (i = 0; i < guest_info->smp_cpus; i++) {
AcpiMadtGenericInterrupt *gicc = acpi_data_push(table_data,
sizeof *gicc);
ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i));
gicc->type = ACPI_APIC_GENERIC_INTERRUPT;
gicc->length = sizeof(*gicc);
if (guest_info->gic_version == 2) {
gicc->base_address = memmap[VIRT_GIC_CPU].base;
}
gicc->cpu_interface_number = i;
gicc->arm_mpidr = armcpu->mp_affinity;
gicc->uid = i;
gicc->flags = cpu_to_le32(ACPI_GICC_ENABLED);
}
if (guest_info->gic_version == 3) {
AcpiMadtGenericRedistributor *gicr = acpi_data_push(table_data,
sizeof *gicr);
gicr->type = ACPI_APIC_GENERIC_REDISTRIBUTOR;
gicr->length = sizeof(*gicr);
gicr->base_address = cpu_to_le64(memmap[VIRT_GIC_REDIST].base);
gicr->range_length = cpu_to_le32(memmap[VIRT_GIC_REDIST].size);
} else {
gic_msi = acpi_data_push(table_data, sizeof *gic_msi);
gic_msi->type = ACPI_APIC_GENERIC_MSI_FRAME;
gic_msi->length = sizeof(*gic_msi);
gic_msi->gic_msi_frame_id = 0;
gic_msi->base_address = cpu_to_le64(memmap[VIRT_GIC_V2M].base);
gic_msi->flags = cpu_to_le32(1);
gic_msi->spi_count = cpu_to_le16(NUM_GICV2M_SPIS);
gic_msi->spi_base = cpu_to_le16(irqmap[VIRT_GIC_V2M] + ARM_SPI_BASE);
}
build_header(linker, table_data,
(void *)(table_data->data + madt_start), "APIC",
table_data->len - madt_start, 3, NULL, NULL);
}
| 23,235 |
qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | 0 | void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val)
{
uint8_t *ptr;
MemoryRegionSection *section;
section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS);
if (!memory_region_is_ram(section->mr) || section->readonly) {
addr = memory_region_section_addr(section, addr);
if (memory_region_is_ram(section->mr)) {
section = &phys_sections[phys_section_rom];
}
io_mem_write(section->mr, addr, val, 4);
} else {
unsigned long addr1 = (memory_region_get_ram_addr(section->mr)
& TARGET_PAGE_MASK)
+ memory_region_section_addr(section, addr);
ptr = qemu_get_ram_ptr(addr1);
stl_p(ptr, val);
if (unlikely(in_migration)) {
if (!cpu_physical_memory_is_dirty(addr1)) {
/* invalidate code */
tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
/* set dirty bit */
cpu_physical_memory_set_dirty_flags(
addr1, (0xff & ~CODE_DIRTY_FLAG));
}
}
}
}
| 23,236 |
qemu | 8ec14402029d783720f4312ed8a925548e1dad61 | 0 | static void compare_pri_rs_finalize(SocketReadState *pri_rs)
{
CompareState *s = container_of(pri_rs, CompareState, pri_rs);
if (packet_enqueue(s, PRIMARY_IN)) {
trace_colo_compare_main("primary: unsupported packet in");
compare_chr_send(s,
pri_rs->buf,
pri_rs->packet_len,
pri_rs->vnet_hdr_len);
} else {
/* compare connection */
g_queue_foreach(&s->conn_list, colo_compare_connection, s);
}
}
| 23,238 |
FFmpeg | 3438d82d4b3bd987304975961e2a42e82767107d | 0 | static int opt_default(const char *opt, const char *arg){
int type;
const AVOption *o= NULL;
int opt_types[]={AV_OPT_FLAG_VIDEO_PARAM, AV_OPT_FLAG_AUDIO_PARAM, 0, AV_OPT_FLAG_SUBTITLE_PARAM, 0};
for(type=0; type<CODEC_TYPE_NB; type++){
const AVOption *o2 = av_find_opt(avctx_opts[0], opt, NULL, opt_types[type], opt_types[type]);
if(o2)
o = av_set_string(avctx_opts[type], opt, arg);
}
if(!o)
o = av_set_string(avformat_opts, opt, arg);
if(!o)
o = av_set_string(sws_opts, opt, arg);
if(!o){
if(opt[0] == 'a')
o = av_set_string(avctx_opts[CODEC_TYPE_AUDIO], opt+1, arg);
else if(opt[0] == 'v')
o = av_set_string(avctx_opts[CODEC_TYPE_VIDEO], opt+1, arg);
else if(opt[0] == 's')
o = av_set_string(avctx_opts[CODEC_TYPE_SUBTITLE], opt+1, arg);
}
if(!o)
return -1;
// av_log(NULL, AV_LOG_ERROR, "%s:%s: %f 0x%0X\n", opt, arg, av_get_double(avctx_opts, opt, NULL), (int)av_get_int(avctx_opts, opt, NULL));
//FIXME we should always use avctx_opts, ... for storing options so there wont be any need to keep track of whats set over this
opt_names= av_realloc(opt_names, sizeof(void*)*(opt_name_count+1));
opt_names[opt_name_count++]= o->name;
#ifdef CONFIG_FFM_MUXER
/* disable generate of real time pts in ffm (need to be supressed anyway) */
if(avctx_opts[0]->flags & CODEC_FLAG_BITEXACT)
ffm_nopts = 1;
#endif
if(avctx_opts[0]->debug)
av_log_set_level(AV_LOG_DEBUG);
return 0;
}
| 23,239 |
qemu | bc7c08a2c375acb7ae4d433054415588b176d34c | 0 | static void test_qemu_strtoul_overflow(void)
{
const char *str = "99999999999999999999999999999999999999999999";
char f = 'X';
const char *endptr = &f;
unsigned long res = 999;
int err;
err = qemu_strtoul(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, -ERANGE);
g_assert_cmpint(res, ==, ULONG_MAX);
g_assert(endptr == str + strlen(str));
}
| 23,240 |
qemu | 036f7166c73a9e0cc1b2f10c03763e61894a1033 | 0 | int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
{
Property *prop;
int ret;
prop = qdev_prop_find(dev, name);
if (!prop) {
fprintf(stderr, "property \"%s.%s\" not found\n",
dev->info->name, name);
return -1;
}
if (!prop->info->parse) {
fprintf(stderr, "property \"%s.%s\" has no parser\n",
dev->info->name, name);
return -1;
}
ret = prop->info->parse(dev, prop, value);
if (ret < 0) {
switch (ret) {
case -EEXIST:
fprintf(stderr, "property \"%s.%s\": \"%s\" is already in use\n",
dev->info->name, name, value);
break;
default:
case -EINVAL:
fprintf(stderr, "property \"%s.%s\": failed to parse \"%s\"\n",
dev->info->name, name, value);
break;
case -ENOENT:
fprintf(stderr, "property \"%s.%s\": could not find \"%s\"\n",
dev->info->name, name, value);
break;
}
return -1;
}
return 0;
}
| 23,241 |
qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | 0 | uint32_t ldub_phys(target_phys_addr_t addr)
{
uint8_t val;
cpu_physical_memory_read(addr, &val, 1);
return val;
}
| 23,242 |
qemu | b8e9fc0625c49404d63b4391f6dc5cf27be8b45b | 0 | static int get_physical_address_data(CPUState *env,
target_phys_addr_t *physical, int *prot,
target_ulong address, int rw, int mmu_idx)
{
unsigned int i;
uint64_t context;
int is_user = (mmu_idx == MMU_USER_IDX ||
mmu_idx == MMU_USER_SECONDARY_IDX);
if ((env->lsu & DMMU_E) == 0) { /* DMMU disabled */
*physical = ultrasparc_truncate_physical(address);
*prot = PAGE_READ | PAGE_WRITE;
return 0;
}
switch(mmu_idx) {
case MMU_USER_IDX:
case MMU_KERNEL_IDX:
context = env->dmmu.mmu_primary_context & 0x1fff;
break;
case MMU_USER_SECONDARY_IDX:
case MMU_KERNEL_SECONDARY_IDX:
context = env->dmmu.mmu_secondary_context & 0x1fff;
break;
case MMU_NUCLEUS_IDX:
default:
context = 0;
break;
}
for (i = 0; i < 64; i++) {
// ctx match, vaddr match, valid?
if (ultrasparc_tag_match(&env->dtlb[i],
address, context, physical)) {
// access ok?
if (((env->dtlb[i].tte & 0x4) && is_user) ||
(!(env->dtlb[i].tte & 0x2) && (rw == 1))) {
uint8_t fault_type = 0;
if ((env->dtlb[i].tte & 0x4) && is_user) {
fault_type |= 1; /* privilege violation */
}
if (env->dmmu.sfsr & 1) /* Fault status register */
env->dmmu.sfsr = 2; /* overflow (not read before
another fault) */
env->dmmu.sfsr |= (is_user << 3) | ((rw == 1) << 2) | 1;
env->dmmu.sfsr |= (fault_type << 7);
env->dmmu.sfar = address; /* Fault address register */
env->exception_index = TT_DFAULT;
#ifdef DEBUG_MMU
printf("DFAULT at 0x%" PRIx64 "\n", address);
#endif
return 1;
}
*prot = PAGE_READ;
if (env->dtlb[i].tte & 0x2)
*prot |= PAGE_WRITE;
TTE_SET_USED(env->dtlb[i].tte);
return 0;
}
}
#ifdef DEBUG_MMU
printf("DMISS at 0x%" PRIx64 "\n", address);
#endif
env->dmmu.tag_access = (address & ~0x1fffULL) | context;
env->exception_index = TT_DMISS;
return 1;
}
| 23,243 |
qemu | 5834a83f4803de88949162346e6dfa2060d3fca6 | 0 | static void vfio_pci_reset(DeviceState *dev)
{
PCIDevice *pdev = DO_UPCAST(PCIDevice, qdev, dev);
VFIODevice *vdev = DO_UPCAST(VFIODevice, pdev, pdev);
if (!vdev->reset_works) {
return;
}
if (ioctl(vdev->fd, VFIO_DEVICE_RESET)) {
error_report("vfio: Error unable to reset physical device "
"(%04x:%02x:%02x.%x): %m\n", vdev->host.domain,
vdev->host.bus, vdev->host.slot, vdev->host.function);
}
}
| 23,246 |
qemu | 3468b59e18b179bc63c7ce934de912dfa9596122 | 0 | void tcg_profile_snapshot(TCGProfile *prof, bool counters, bool table)
{
unsigned int i;
for (i = 0; i < n_tcg_ctxs; i++) {
const TCGProfile *orig = &tcg_ctxs[i]->prof;
if (counters) {
PROF_ADD(prof, orig, tb_count1);
PROF_ADD(prof, orig, tb_count);
PROF_ADD(prof, orig, op_count);
PROF_MAX(prof, orig, op_count_max);
PROF_ADD(prof, orig, temp_count);
PROF_MAX(prof, orig, temp_count_max);
PROF_ADD(prof, orig, del_op_count);
PROF_ADD(prof, orig, code_in_len);
PROF_ADD(prof, orig, code_out_len);
PROF_ADD(prof, orig, search_out_len);
PROF_ADD(prof, orig, interm_time);
PROF_ADD(prof, orig, code_time);
PROF_ADD(prof, orig, la_time);
PROF_ADD(prof, orig, opt_time);
PROF_ADD(prof, orig, restore_count);
PROF_ADD(prof, orig, restore_time);
}
if (table) {
int i;
for (i = 0; i < NB_OPS; i++) {
PROF_ADD(prof, orig, table_op_count[i]);
}
}
}
}
| 23,248 |
FFmpeg | bd31c61cf94d01dbe1051cf65874e7b2c0ac5454 | 0 | static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
{
char *pix_fmts;
OutputStream *ost = ofilter->ost;
OutputFile *of = output_files[ost->file_index];
AVFilterContext *last_filter = out->filter_ctx;
int pad_idx = out->pad_idx;
int ret;
char name[255];
snprintf(name, sizeof(name), "output stream %d:%d", ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&ofilter->filter,
avfilter_get_by_name("buffersink"),
name, NULL, NULL, fg->graph);
if (ret < 0)
return ret;
if (!hw_device_ctx && (ofilter->width || ofilter->height)) {
char args[255];
AVFilterContext *filter;
snprintf(args, sizeof(args), "%d:%d:0x%X",
ofilter->width, ofilter->height,
(unsigned)ost->sws_flags);
snprintf(name, sizeof(name), "scaler for output stream %d:%d",
ost->file_index, ost->index);
if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
name, args, NULL, fg->graph)) < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
return ret;
last_filter = filter;
pad_idx = 0;
}
if ((pix_fmts = choose_pix_fmts(ofilter))) {
AVFilterContext *filter;
snprintf(name, sizeof(name), "pixel format for output stream %d:%d",
ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&filter,
avfilter_get_by_name("format"),
"format", pix_fmts, NULL, fg->graph);
av_freep(&pix_fmts);
if (ret < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
return ret;
last_filter = filter;
pad_idx = 0;
}
if (ost->frame_rate.num) {
AVFilterContext *fps;
char args[255];
snprintf(args, sizeof(args), "fps=%d/%d", ost->frame_rate.num,
ost->frame_rate.den);
snprintf(name, sizeof(name), "fps for output stream %d:%d",
ost->file_index, ost->index);
ret = avfilter_graph_create_filter(&fps, avfilter_get_by_name("fps"),
name, args, NULL, fg->graph);
if (ret < 0)
return ret;
ret = avfilter_link(last_filter, pad_idx, fps, 0);
if (ret < 0)
return ret;
last_filter = fps;
pad_idx = 0;
}
snprintf(name, sizeof(name), "trim for output stream %d:%d",
ost->file_index, ost->index);
ret = insert_trim(of->start_time, of->recording_time,
&last_filter, &pad_idx, name);
if (ret < 0)
return ret;
if ((ret = avfilter_link(last_filter, pad_idx, ofilter->filter, 0)) < 0)
return ret;
return 0;
}
| 23,252 |
qemu | 77a10d04d033484a913a5ee76eed31a9acc57bae | 1 | static void vfio_exitfn(PCIDevice *pdev)
{
VFIOPCIDevice *vdev = DO_UPCAST(VFIOPCIDevice, pdev, pdev);
VFIOGroup *group = vdev->vbasedev.group;
vfio_unregister_err_notifier(vdev);
pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
vfio_disable_interrupts(vdev);
if (vdev->intx.mmap_timer) {
timer_free(vdev->intx.mmap_timer);
}
vfio_teardown_msi(vdev);
vfio_unmap_bars(vdev);
g_free(vdev->emulated_config_bits);
g_free(vdev->rom);
vfio_put_device(vdev);
vfio_put_group(group);
}
| 23,253 |
FFmpeg | 2caf19e90f270abe1e80a3e85acaf0eb5c9d0aac | 1 | static void FUNCC(pred4x4_left_dc)(uint8_t *_src, const uint8_t *topright, int _stride){
pixel *src = (pixel*)_src;
int stride = _stride/sizeof(pixel);
const int dc= ( src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;
((pixel4*)(src+0*stride))[0]=
((pixel4*)(src+1*stride))[0]=
((pixel4*)(src+2*stride))[0]=
((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);
}
| 23,254 |
FFmpeg | 5183fac92fc5c574a053dd06b84e735a1ec1cfa6 | 1 | static void decode_nal_sei_decoded_picture_hash(HEVCContext *s)
{
int cIdx, i;
uint8_t hash_type;
//uint16_t picture_crc;
//uint32_t picture_checksum;
GetBitContext *gb = &s->HEVClc->gb;
hash_type = get_bits(gb, 8);
for (cIdx = 0; cIdx < 3/*((s->sps->chroma_format_idc == 0) ? 1 : 3)*/; cIdx++) {
if (hash_type == 0) {
s->is_md5 = 1;
for (i = 0; i < 16; i++)
s->md5[cIdx][i] = get_bits(gb, 8);
} else if (hash_type == 1) {
// picture_crc = get_bits(gb, 16);
skip_bits(gb, 16);
} else if (hash_type == 2) {
// picture_checksum = get_bits(gb, 32);
skip_bits(gb, 32);
}
}
}
| 23,255 |
FFmpeg | 801dbf0269b1bb5bc70c550e971491e0aea9eb70 | 0 | static av_cold void dcadec_flush(AVCodecContext *avctx)
{
DCAContext *s = avctx->priv_data;
ff_dca_core_flush(&s->core);
ff_dca_xll_flush(&s->xll);
ff_dca_lbr_flush(&s->lbr);
s->core_residual_valid = 0;
}
| 23,257 |
FFmpeg | 93c04e095dc37ebdab22174e88cfa91e24940866 | 0 | static int amf_parse_object(AVFormatContext *s, AVStream *astream,
AVStream *vstream, const char *key,
int64_t max_pos, int depth)
{
AVCodecContext *acodec, *vcodec;
FLVContext *flv = s->priv_data;
AVIOContext *ioc;
AMFDataType amf_type;
char str_val[256];
double num_val;
num_val = 0;
ioc = s->pb;
amf_type = avio_r8(ioc);
switch (amf_type) {
case AMF_DATA_TYPE_NUMBER:
num_val = av_int2double(avio_rb64(ioc));
break;
case AMF_DATA_TYPE_BOOL:
num_val = avio_r8(ioc);
break;
case AMF_DATA_TYPE_STRING:
if (amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
return -1;
break;
case AMF_DATA_TYPE_OBJECT:
if ((vstream || astream) && key &&
!strcmp(KEYFRAMES_TAG, key) && depth == 1)
if (parse_keyframes_index(s, ioc, vstream ? vstream : astream,
max_pos) < 0)
return -1;
while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
if (amf_parse_object(s, astream, vstream, str_val, max_pos,
depth + 1) < 0)
return -1; // if we couldn't skip, bomb out.
if (avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_NULL:
case AMF_DATA_TYPE_UNDEFINED:
case AMF_DATA_TYPE_UNSUPPORTED:
break; // these take up no additional space
case AMF_DATA_TYPE_MIXEDARRAY:
avio_skip(ioc, 4); // skip 32-bit max array index
while (avio_tell(ioc) < max_pos - 2 &&
amf_get_string(ioc, str_val, sizeof(str_val)) > 0)
// this is the only case in which we would want a nested
// parse to not skip over the object
if (amf_parse_object(s, astream, vstream, str_val, max_pos,
depth + 1) < 0)
return -1;
if (avio_r8(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY:
{
unsigned int arraylen, i;
arraylen = avio_rb32(ioc);
for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++)
if (amf_parse_object(s, NULL, NULL, NULL, max_pos,
depth + 1) < 0)
return -1; // if we couldn't skip, bomb out.
}
break;
case AMF_DATA_TYPE_DATE:
avio_skip(ioc, 8 + 2); // timestamp (double) and UTC offset (int16)
break;
default: // unsupported type, we couldn't skip
return -1;
}
// only look for metadata values when we are not nested and key != NULL
if (depth == 1 && key) {
acodec = astream ? astream->codec : NULL;
vcodec = vstream ? vstream->codec : NULL;
if (amf_type == AMF_DATA_TYPE_NUMBER ||
amf_type == AMF_DATA_TYPE_BOOL) {
if (!strcmp(key, "duration"))
s->duration = num_val * AV_TIME_BASE;
else if (!strcmp(key, "videodatarate") && vcodec &&
0 <= (int)(num_val * 1024.0))
vcodec->bit_rate = num_val * 1024.0;
else if (!strcmp(key, "audiodatarate") && acodec &&
0 <= (int)(num_val * 1024.0))
acodec->bit_rate = num_val * 1024.0;
else if (!strcmp(key, "datastream")) {
AVStream *st = create_stream(s, AVMEDIA_TYPE_DATA);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_TEXT;
} else if (flv->trust_metadata) {
if (!strcmp(key, "videocodecid") && vcodec) {
flv_set_video_codec(s, vstream, num_val, 0);
} else if (!strcmp(key, "audiocodecid") && acodec) {
int id = ((int)num_val) << FLV_AUDIO_CODECID_OFFSET;
flv_set_audio_codec(s, astream, acodec, id);
} else if (!strcmp(key, "audiosamplerate") && acodec) {
acodec->sample_rate = num_val;
} else if (!strcmp(key, "audiosamplesize") && acodec) {
acodec->bits_per_coded_sample = num_val;
} else if (!strcmp(key, "stereo") && acodec) {
acodec->channels = num_val + 1;
acodec->channel_layout = acodec->channels == 2 ?
AV_CH_LAYOUT_STEREO :
AV_CH_LAYOUT_MONO;
} else if (!strcmp(key, "width") && vcodec) {
vcodec->width = num_val;
} else if (!strcmp(key, "height") && vcodec) {
vcodec->height = num_val;
}
}
}
if (!strcmp(key, "duration") ||
!strcmp(key, "filesize") ||
!strcmp(key, "width") ||
!strcmp(key, "height") ||
!strcmp(key, "videodatarate") ||
!strcmp(key, "framerate") ||
!strcmp(key, "videocodecid") ||
!strcmp(key, "audiodatarate") ||
!strcmp(key, "audiosamplerate") ||
!strcmp(key, "audiosamplesize") ||
!strcmp(key, "stereo") ||
!strcmp(key, "audiocodecid") ||
!strcmp(key, "datastream"))
return 0;
if (amf_type == AMF_DATA_TYPE_BOOL) {
av_strlcpy(str_val, num_val > 0 ? "true" : "false",
sizeof(str_val));
av_dict_set(&s->metadata, key, str_val, 0);
} else if (amf_type == AMF_DATA_TYPE_NUMBER) {
snprintf(str_val, sizeof(str_val), "%.f", num_val);
av_dict_set(&s->metadata, key, str_val, 0);
} else if (amf_type == AMF_DATA_TYPE_STRING)
av_dict_set(&s->metadata, key, str_val, 0);
}
return 0;
}
| 23,258 |
FFmpeg | 955aec3c7c7be39b659197e1ec379a09f2b7c41c | 0 | static int check(AVIOContext *pb, int64_t pos, int64_t *out_pos)
{
MPADecodeHeader mh = { 0 };
int i;
uint32_t header;
int64_t off = 0;
for (i = 0; i < SEEK_PACKETS; i++) {
off = avio_seek(pb, pos + mh.frame_size, SEEK_SET);
if (off < 0)
break;
header = avio_rb32(pb);
if (ff_mpa_check_header(header) < 0 ||
avpriv_mpegaudio_decode_header(&mh, header))
break;
out_pos[i] = off;
}
return i;
}
| 23,261 |
FFmpeg | fd2982a0a01942091b2f08e17486ff4562f675a6 | 0 | int av_read_play(AVFormatContext *s)
{
if (s->iformat->read_play)
return s->iformat->read_play(s);
if (s->pb && s->pb->read_pause)
return av_url_read_fpause(s->pb, 0);
return AVERROR(ENOSYS);
}
| 23,262 |
FFmpeg | 4791a910c0dc3dd5861d38202457c9fb9bf1154c | 0 | int ff_hevc_extract_rbsp(HEVCContext *s, const uint8_t *src, int length,
HEVCNAL *nal)
{
int i, si, di;
uint8_t *dst;
if (s)
nal->skipped_bytes = 0;
#define STARTCODE_TEST \
if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
if (src[i + 2] != 3) { \
/* startcode, so we must be past the end */ \
length = i; \
} \
break; \
}
#if HAVE_FAST_UNALIGNED
#define FIND_FIRST_ZERO \
if (i > 0 && !src[i]) \
i--; \
while (src[i]) \
i++
#if HAVE_FAST_64BIT
for (i = 0; i + 1 < length; i += 9) {
if (!((~AV_RN64A(src + i) &
(AV_RN64A(src + i) - 0x0100010001000101ULL)) &
0x8000800080008080ULL))
continue;
FIND_FIRST_ZERO;
STARTCODE_TEST;
i -= 7;
}
#else
for (i = 0; i + 1 < length; i += 5) {
if (!((~AV_RN32A(src + i) &
(AV_RN32A(src + i) - 0x01000101U)) &
0x80008080U))
continue;
FIND_FIRST_ZERO;
STARTCODE_TEST;
i -= 3;
}
#endif /* HAVE_FAST_64BIT */
#else
for (i = 0; i + 1 < length; i += 2) {
if (src[i])
continue;
if (i > 0 && src[i - 1] == 0)
i--;
STARTCODE_TEST;
}
#endif /* HAVE_FAST_UNALIGNED */
if (i >= length - 1) { // no escaped 0
nal->data =
nal->raw_data = src;
nal->size =
nal->raw_size = length;
return length;
}
av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size,
length + AV_INPUT_BUFFER_PADDING_SIZE);
if (!nal->rbsp_buffer)
return AVERROR(ENOMEM);
dst = nal->rbsp_buffer;
memcpy(dst, src, i);
si = di = i;
while (si + 2 < length) {
// remove escapes (very rare 1:2^22)
if (src[si + 2] > 3) {
dst[di++] = src[si++];
dst[di++] = src[si++];
} else if (src[si] == 0 && src[si + 1] == 0) {
if (src[si + 2] == 3) { // escape
dst[di++] = 0;
dst[di++] = 0;
si += 3;
if (s && nal->skipped_bytes_pos) {
nal->skipped_bytes++;
if (nal->skipped_bytes_pos_size < nal->skipped_bytes) {
nal->skipped_bytes_pos_size *= 2;
av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes);
av_reallocp_array(&nal->skipped_bytes_pos,
nal->skipped_bytes_pos_size,
sizeof(*nal->skipped_bytes_pos));
if (!nal->skipped_bytes_pos) {
nal->skipped_bytes_pos_size = 0;
return AVERROR(ENOMEM);
}
}
if (nal->skipped_bytes_pos)
nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1;
}
continue;
} else // next start code
goto nsc;
}
dst[di++] = src[si++];
}
while (si < length)
dst[di++] = src[si++];
nsc:
memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE);
nal->data = dst;
nal->size = di;
nal->raw_data = src;
nal->raw_size = si;
return si;
}
| 23,264 |
FFmpeg | 1ec83d9a9e472f485897ac92bad9631d551a8c5b | 0 | static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
const uint8_t *buf, const uint8_t *end_buf)
{
unsigned tag, type, count, off, value = 0;
int i, j;
int ret;
uint32_t *pal;
const uint8_t *rp, *gp, *bp;
double *dp;
if (end_buf - buf < 12)
return -1;
tag = tget_short(&buf, s->le);
type = tget_short(&buf, s->le);
count = tget_long(&buf, s->le);
off = tget_long(&buf, s->le);
if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",
type);
return 0;
}
if (count == 1) {
switch (type) {
case TIFF_BYTE:
case TIFF_SHORT:
buf -= 4;
value = tget(&buf, type, s->le);
buf = NULL;
break;
case TIFF_LONG:
value = off;
buf = NULL;
break;
case TIFF_STRING:
if (count <= 4) {
buf -= 4;
break;
}
default:
value = UINT_MAX;
buf = start + off;
}
} else {
if (count <= 4 && type_sizes[type] * count <= 4) {
buf -= 4;
} else {
buf = start + off;
}
}
if (buf && (buf < start || buf > end_buf)) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
switch (tag) {
case TIFF_WIDTH:
s->width = value;
break;
case TIFF_HEIGHT:
s->height = value;
break;
case TIFF_BPP:
s->bppcount = count;
if (count > 4) {
av_log(s->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
s->bpp, count);
return -1;
}
if (count == 1)
s->bpp = value;
else {
switch (type) {
case TIFF_BYTE:
s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +
((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
s->bpp = 0;
for (i = 0; i < count && buf < end_buf; i++)
s->bpp += tget(&buf, type, s->le);
break;
default:
s->bpp = -1;
}
}
break;
case TIFF_SAMPLES_PER_PIXEL:
if (count != 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single value, many provided\n");
return AVERROR_INVALIDDATA;
}
if (s->bppcount == 1)
s->bpp *= value;
s->bppcount = value;
break;
case TIFF_COMPR:
s->compr = value;
s->predictor = 0;
switch (s->compr) {
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
s->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return -1;
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
av_log(s->avctx, AV_LOG_ERROR,
"JPEG compression is not supported\n");
return -1;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",
s->compr);
return -1;
}
break;
case TIFF_ROWSPERSTRIP:
if (type == TIFF_LONG && value == UINT_MAX)
value = s->avctx->height;
if (value < 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Incorrect value of rows per strip\n");
return -1;
}
s->rps = value;
break;
case TIFF_STRIP_OFFS:
if (count == 1) {
s->stripdata = NULL;
s->stripoff = value;
} else
s->stripdata = start + off;
s->strips = count;
if (s->strips == 1)
s->rps = s->height;
s->sot = type;
if (s->stripdata > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_STRIP_SIZE:
if (count == 1) {
s->stripsizes = NULL;
s->stripsize = value;
s->strips = 1;
} else {
s->stripsizes = start + off;
}
s->strips = count;
s->sstype = type;
if (s->stripsizes > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return -1;
}
break;
case TIFF_TILE_BYTE_COUNTS:
case TIFF_TILE_LENGTH:
case TIFF_TILE_OFFSETS:
case TIFF_TILE_WIDTH:
av_log(s->avctx, AV_LOG_ERROR, "Tiled images are not supported\n");
return AVERROR_PATCHWELCOME;
break;
case TIFF_PREDICTOR:
s->predictor = value;
break;
case TIFF_INVERT:
switch (value) {
case 0:
s->invert = 1;
break;
case 1:
s->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
value);
return -1;
}
break;
case TIFF_FILL_ORDER:
if (value < 1 || value > 2) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown FillOrder value %d, trying default one\n", value);
value = 1;
}
s->fill_order = value - 1;
break;
case TIFF_PAL:
pal = (uint32_t *) s->palette;
off = type_sizes[type];
if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)
return -1;
rp = buf;
gp = buf + count / 3 * off;
bp = buf + count / 3 * off * 2;
off = (type_sizes[type] - 1) << 3;
for (i = 0; i < count / 3; i++) {
j = 0xff << 24;
j |= (tget(&rp, type, s->le) >> off) << 16;
j |= (tget(&gp, type, s->le) >> off) << 8;
j |= tget(&bp, type, s->le) >> off;
pal[i] = j;
}
s->palette_is_set = 1;
break;
case TIFF_PLANAR:
if (value == 2) {
av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n");
return -1;
}
break;
case TIFF_T4OPTIONS:
if (s->compr == TIFF_G3)
s->fax_opts = value;
break;
case TIFF_T6OPTIONS:
if (s->compr == TIFF_G4)
s->fax_opts = value;
break;
#define ADD_METADATA(count, name, sep)\
if (ret = add_metadata(&buf, count, type, name, sep, s) < 0) {\
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");\
return ret;\
}
case TIFF_MODEL_PIXEL_SCALE:
ADD_METADATA(count, "ModelPixelScaleTag", NULL);
break;
case TIFF_MODEL_TRANSFORMATION:
ADD_METADATA(count, "ModelTransformationTag", NULL);
break;
case TIFF_MODEL_TIEPOINT:
ADD_METADATA(count, "ModelTiepointTag", NULL);
break;
case TIFF_GEO_KEY_DIRECTORY:
ADD_METADATA(1, "GeoTIFF_Version", NULL);
ADD_METADATA(2, "GeoTIFF_Key_Revision", ".");
s->geotag_count = tget_short(&buf, s->le);
if (s->geotag_count > count / 4 - 1) {
s->geotag_count = count / 4 - 1;
av_log(s->avctx, AV_LOG_WARNING, "GeoTIFF key directory buffer shorter than specified\n");
}
s->geotags = av_mallocz(sizeof(TiffGeoTag) * s->geotag_count);
if (!s->geotags) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < s->geotag_count; i++) {
s->geotags[i].key = tget_short(&buf, s->le);
s->geotags[i].type = tget_short(&buf, s->le);
s->geotags[i].count = tget_short(&buf, s->le);
if (!s->geotags[i].type)
s->geotags[i].val = get_geokey_val(s->geotags[i].key, tget_short(&buf, s->le));
else
s->geotags[i].offset = tget_short(&buf, s->le);
}
break;
case TIFF_GEO_DOUBLE_PARAMS:
dp = av_malloc(count * sizeof(double));
if (!dp) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
for (i = 0; i < count; i++)
dp[i] = tget_double(&buf, s->le);
for (i = 0; i < s->geotag_count; i++) {
if (s->geotags[i].type == TIFF_GEO_DOUBLE_PARAMS) {
if (s->geotags[i].count == 0
|| s->geotags[i].offset + s->geotags[i].count > count) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);
} else {
char *ap = doubles2str(&dp[s->geotags[i].offset], s->geotags[i].count, ", ");
if (!ap) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
av_freep(&dp);
return AVERROR(ENOMEM);
}
s->geotags[i].val = ap;
}
}
}
av_freep(&dp);
break;
case TIFF_GEO_ASCII_PARAMS:
for (i = 0; i < s->geotag_count; i++) {
if (s->geotags[i].type == TIFF_GEO_ASCII_PARAMS) {
if (s->geotags[i].count == 0
|| s->geotags[i].offset + s->geotags[i].count > count) {
av_log(s->avctx, AV_LOG_WARNING, "Invalid GeoTIFF key %d\n", s->geotags[i].key);
} else {
char *ap = av_malloc(s->geotags[i].count);
if (!ap) {
av_log(s->avctx, AV_LOG_ERROR, "Error allocating temporary buffer\n");
return AVERROR(ENOMEM);
}
memcpy(ap, &buf[s->geotags[i].offset], s->geotags[i].count);
ap[s->geotags[i].count - 1] = '\0'; //replace the "|" delimiter with a 0 byte
s->geotags[i].val = ap;
}
}
}
break;
default:
av_log(s->avctx, AV_LOG_DEBUG, "Unknown or unsupported tag %d/0X%0X\n",
tag, tag);
}
return 0;
}
| 23,265 |
FFmpeg | 3e0c78bac63c213649c3e8c2fa49e9f3c9848d5a | 0 | static int bit_allocation(IMCContext *q, IMCChannel *chctx,
int stream_format_code, int freebits, int flag)
{
int i, j;
const float limit = -1.e20;
float highest = 0.0;
int indx;
int t1 = 0;
int t2 = 1;
float summa = 0.0;
int iacc = 0;
int summer = 0;
int rres, cwlen;
float lowest = 1.e10;
int low_indx = 0;
float workT[32];
int flg;
int found_indx = 0;
for (i = 0; i < BANDS; i++)
highest = FFMAX(highest, chctx->flcoeffs1[i]);
for (i = 0; i < BANDS - 1; i++)
chctx->flcoeffs4[i] = chctx->flcoeffs3[i] - log2f(chctx->flcoeffs5[i]);
chctx->flcoeffs4[BANDS - 1] = limit;
highest = highest * 0.25;
for (i = 0; i < BANDS; i++) {
indx = -1;
if ((band_tab[i + 1] - band_tab[i]) == chctx->bandWidthT[i])
indx = 0;
if ((band_tab[i + 1] - band_tab[i]) > chctx->bandWidthT[i])
indx = 1;
if (((band_tab[i + 1] - band_tab[i]) / 2) >= chctx->bandWidthT[i])
indx = 2;
if (indx == -1)
return AVERROR_INVALIDDATA;
chctx->flcoeffs4[i] += xTab[(indx * 2 + (chctx->flcoeffs1[i] < highest)) * 2 + flag];
}
if (stream_format_code & 0x2) {
chctx->flcoeffs4[0] = limit;
chctx->flcoeffs4[1] = limit;
chctx->flcoeffs4[2] = limit;
chctx->flcoeffs4[3] = limit;
}
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS - 1; i++) {
iacc += chctx->bandWidthT[i];
summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i];
}
if (!iacc)
return AVERROR_INVALIDDATA;
chctx->bandWidthT[BANDS - 1] = 0;
summa = (summa * 0.5 - freebits) / iacc;
for (i = 0; i < BANDS / 2; i++) {
rres = summer - freebits;
if ((rres >= -8) && (rres <= 8))
break;
summer = 0;
iacc = 0;
for (j = (stream_format_code & 0x2) ? 4 : 0; j < BANDS; j++) {
cwlen = av_clipf(((chctx->flcoeffs4[j] * 0.5) - summa + 0.5), 0, 6);
chctx->bitsBandT[j] = cwlen;
summer += chctx->bandWidthT[j] * cwlen;
if (cwlen > 0)
iacc += chctx->bandWidthT[j];
}
flg = t2;
t2 = 1;
if (freebits < summer)
t2 = -1;
if (i == 0)
flg = t2;
if (flg != t2)
t1++;
summa = (float)(summer - freebits) / ((t1 + 1) * iacc) + summa;
}
for (i = (stream_format_code & 0x2) ? 4 : 0; i < BANDS; i++) {
for (j = band_tab[i]; j < band_tab[i + 1]; j++)
chctx->CWlengthT[j] = chctx->bitsBandT[i];
}
if (freebits > summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = (chctx->bitsBandT[i] == 6) ? -1.e20
: (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] - 0.415);
}
highest = 0.0;
do {
if (highest <= -1.e20)
break;
found_indx = 0;
highest = -1.e20;
for (i = 0; i < BANDS; i++) {
if (workT[i] > highest) {
highest = workT[i];
found_indx = i;
}
}
if (highest > -1.e20) {
workT[found_indx] -= 2.0;
if (++chctx->bitsBandT[found_indx] == 6)
workT[found_indx] = -1.e20;
for (j = band_tab[found_indx]; j < band_tab[found_indx + 1] && (freebits > summer); j++) {
chctx->CWlengthT[j]++;
summer++;
}
}
} while (freebits > summer);
}
if (freebits < summer) {
for (i = 0; i < BANDS; i++) {
workT[i] = chctx->bitsBandT[i] ? (chctx->bitsBandT[i] * -2 + chctx->flcoeffs4[i] + 1.585)
: 1.e20;
}
if (stream_format_code & 0x2) {
workT[0] = 1.e20;
workT[1] = 1.e20;
workT[2] = 1.e20;
workT[3] = 1.e20;
}
while (freebits < summer) {
lowest = 1.e10;
low_indx = 0;
for (i = 0; i < BANDS; i++) {
if (workT[i] < lowest) {
lowest = workT[i];
low_indx = i;
}
}
// if (lowest >= 1.e10)
// break;
workT[low_indx] = lowest + 2.0;
if (!--chctx->bitsBandT[low_indx])
workT[low_indx] = 1.e20;
for (j = band_tab[low_indx]; j < band_tab[low_indx+1] && (freebits < summer); j++) {
if (chctx->CWlengthT[j] > 0) {
chctx->CWlengthT[j]--;
summer--;
}
}
}
}
return 0;
}
| 23,266 |
FFmpeg | ec2694d25905c217e5815947cda896aa25398388 | 0 | static av_cold int g722_decode_init(AVCodecContext * avctx)
{
G722Context *c = avctx->priv_data;
if (avctx->channels != 1) {
av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n");
return AVERROR_INVALIDDATA;
}
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
c->band[0].scale_factor = 8;
c->band[1].scale_factor = 2;
c->prev_samples_pos = 22;
avcodec_get_frame_defaults(&c->frame);
avctx->coded_frame = &c->frame;
return 0;
}
| 23,267 |
FFmpeg | b3f9f7a33337e9b64e6044b0010e2722fa0b2f9c | 0 | static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
{
AVFormatContext *s = ts->stream;
MpegTSFilter *tss;
int len, pid, cc, cc_ok, afc, is_start;
const uint8_t *p, *p_end;
int64_t pos;
pid = AV_RB16(packet + 1) & 0x1fff;
if(pid && discard_pid(ts, pid))
return 0;
is_start = packet[1] & 0x40;
tss = ts->pids[pid];
if (ts->auto_guess && tss == NULL && is_start) {
add_pes_stream(ts, pid, -1, 0);
tss = ts->pids[pid];
}
if (!tss)
return 0;
/* continuity check (currently not used) */
cc = (packet[3] & 0xf);
cc_ok = (tss->last_cc < 0) || ((((tss->last_cc + 1) & 0x0f) == cc));
tss->last_cc = cc;
/* skip adaptation field */
afc = (packet[3] >> 4) & 3;
p = packet + 4;
if (afc == 0) /* reserved value */
return 0;
if (afc == 2) /* adaptation field only */
return 0;
if (afc == 3) {
/* skip adapation field */
p += p[0] + 1;
}
/* if past the end of packet, ignore */
p_end = packet + TS_PACKET_SIZE;
if (p >= p_end)
return 0;
pos = url_ftell(ts->stream->pb);
ts->pos47= pos % ts->raw_packet_size;
if (tss->type == MPEGTS_SECTION) {
if (is_start) {
/* pointer field present */
len = *p++;
if (p + len > p_end)
return 0;
if (len && cc_ok) {
/* write remaining section bytes */
write_section_data(s, tss,
p, len, 0);
/* check whether filter has been closed */
if (!ts->pids[pid])
return 0;
}
p += len;
if (p < p_end) {
write_section_data(s, tss,
p, p_end - p, 1);
}
} else {
if (cc_ok) {
write_section_data(s, tss,
p, p_end - p, 0);
}
}
} else {
int ret;
// Note: The position here points actually behind the current packet.
if ((ret = tss->u.pes_filter.pes_cb(tss, p, p_end - p, is_start,
pos - ts->raw_packet_size)) < 0)
return ret;
}
return 0;
}
| 23,268 |
FFmpeg | 03cef34aa66662e2ab3681d290e7c5a6634f4058 | 0 | static void buffer_release(void *opaque, uint8_t *data)
{
*(uint8_t*)opaque = 0;
}
| 23,269 |
FFmpeg | 63b737d4f9c118853a4f8d9af641335629bdf3ab | 0 | static void float_to_int16_3dnow(int16_t *dst, const float *src, int len){
// not bit-exact: pf2id uses different rounding than C and SSE
int i;
for(i=0; i<len; i+=4) {
asm volatile(
"pf2id %1, %%mm0 \n\t"
"pf2id %2, %%mm1 \n\t"
"packssdw %%mm1, %%mm0 \n\t"
"movq %%mm0, %0 \n\t"
:"=m"(dst[i])
:"m"(src[i]), "m"(src[i+2])
);
}
asm volatile("femms");
}
| 23,270 |
FFmpeg | 1ec83d9a9e472f485897ac92bad9631d551a8c5b | 0 | static int add_shorts_metadata(const uint8_t **buf, int count, const char *name,
const char *sep, TiffContext *s)
{
char *ap;
int i;
int *sp = av_malloc(count * sizeof(int));
if (!sp)
return AVERROR(ENOMEM);
for (i = 0; i < count; i++)
sp[i] = tget_short(buf, s->le);
ap = shorts2str(sp, count, sep);
av_freep(&sp);
if (!ap)
return AVERROR(ENOMEM);
av_dict_set(&s->picture.metadata, name, ap, AV_DICT_DONT_STRDUP_VAL);
return 0;
}
| 23,271 |
FFmpeg | 15b219fae9da1691dfb264f51637805e1ca63d1a | 0 | int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
const uint8_t *mb_bitmask, const AVFrame *reference)
{
int len, nb_components, i, h, v, predictor, point_transform;
int index, id;
const int block_size= s->lossless ? 1 : 8;
int ilv, prev_shift;
/* XXX: verify len field validity */
len = get_bits(&s->gb, 16);
nb_components = get_bits(&s->gb, 8);
if (nb_components == 0 || nb_components > MAX_COMPONENTS){
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: nb_components (%d) unsupported\n", nb_components);
return -1;
}
if (len != 6+2*nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: invalid len (%d)\n", len);
return -1;
}
for(i=0;i<nb_components;i++) {
id = get_bits(&s->gb, 8) - 1;
av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id);
/* find component index */
for(index=0;index<s->nb_components;index++)
if (id == s->component_id[index])
break;
if (index == s->nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: index(%d) out of components\n", index);
return -1;
}
/* Metasoft MJPEG codec has Cb and Cr swapped */
if (s->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J')
&& nb_components == 3 && s->nb_components == 3 && i)
index = 3 - i;
if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == PIX_FMT_GBR24P)
index = (i+2)%3;
s->comp_index[i] = index;
s->nb_blocks[i] = s->h_count[index] * s->v_count[index];
s->h_scount[i] = s->h_count[index];
s->v_scount[i] = s->v_count[index];
s->dc_index[i] = get_bits(&s->gb, 4);
s->ac_index[i] = get_bits(&s->gb, 4);
if (s->dc_index[i] < 0 || s->ac_index[i] < 0 ||
s->dc_index[i] >= 4 || s->ac_index[i] >= 4)
goto out_of_range;
if (!s->vlcs[0][s->dc_index[i]].table || !s->vlcs[1][s->ac_index[i]].table)
goto out_of_range;
}
predictor= get_bits(&s->gb, 8); /* JPEG Ss / lossless JPEG predictor /JPEG-LS NEAR */
ilv= get_bits(&s->gb, 8); /* JPEG Se / JPEG-LS ILV */
if(s->avctx->codec_tag != AV_RL32("CJPG")){
prev_shift = get_bits(&s->gb, 4); /* Ah */
point_transform= get_bits(&s->gb, 4); /* Al */
}else
prev_shift= point_transform= 0;
for(i=0;i<nb_components;i++)
s->last_dc[i] = 1024;
if (nb_components > 1) {
/* interleaved stream */
s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size);
s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size);
} else if(!s->ls) { /* skip this for JPEG-LS */
h = s->h_max / s->h_scount[0];
v = s->v_max / s->v_scount[0];
s->mb_width = (s->width + h * block_size - 1) / (h * block_size);
s->mb_height = (s->height + v * block_size - 1) / (v * block_size);
s->nb_blocks[0] = 1;
s->h_scount[0] = 1;
s->v_scount[0] = 1;
}
if(s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d ilv:%d bits:%d skip:%d %s comp:%d\n", s->lossless ? "lossless" : "sequential DCT", s->rgb ? "RGB" : "",
predictor, point_transform, ilv, s->bits, s->mjpb_skiptosod,
s->pegasus_rct ? "PRCT" : (s->rct ? "RCT" : ""), nb_components);
/* mjpeg-b can have padding bytes between sos and image data, skip them */
for (i = s->mjpb_skiptosod; i > 0; i--)
skip_bits(&s->gb, 8);
if(s->lossless){
av_assert0(s->picture_ptr == &s->picture);
if(CONFIG_JPEGLS_DECODER && s->ls){
// for(){
// reset_ls_coding_parameters(s, 0);
if(ff_jpegls_decode_picture(s, predictor, point_transform, ilv) < 0)
return -1;
}else{
if(s->rgb){
if(ljpeg_decode_rgb_scan(s, nb_components, predictor, point_transform) < 0)
return -1;
}else{
if(ljpeg_decode_yuv_scan(s, predictor, point_transform) < 0)
return -1;
}
}
}else{
if(s->progressive && predictor) {
av_assert0(s->picture_ptr == &s->picture);
if(mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform) < 0)
return -1;
} else {
if(mjpeg_decode_scan(s, nb_components, prev_shift, point_transform,
mb_bitmask, reference) < 0)
return -1;
}
}
if (s->yuv421) {
uint8_t *line = s->picture_ptr->data[2];
for (i = 0; i < s->height / 2; i++) {
for (index = s->width - 1; index; index--)
line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
line += s->linesize[2];
}
} else if (s->yuv442) {
uint8_t *dst = &((uint8_t *)s->picture_ptr->data[2])[(s->height - 1) * s->linesize[2]];
for (i = s->height - 1; i; i--) {
uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[2])[i / 2 * s->linesize[2]];
uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[2])[(i + 1) / 2 * s->linesize[2]];
if (src1 == src2) {
memcpy(dst, src1, s->width);
} else {
for (index = 0; index < s->width; index++)
dst[index] = (src1[index] + src2[index]) >> 1;
}
dst -= s->linesize[2];
}
}
emms_c();
return 0;
out_of_range:
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: ac/dc index out of range\n");
return -1;
}
| 23,272 |
FFmpeg | e1d5bbeb39501a3271c6422390d13bf9391872d1 | 0 | static int is_intra_more_likely(MpegEncContext *s){
int is_intra_likely, i, j, undamaged_count, skip_amount, mb_x, mb_y;
if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) return 1; //no previous frame available -> use spatial prediction
undamaged_count=0;
for(i=0; i<s->mb_num; i++){
const int mb_xy= s->mb_index2xy[i];
const int error= s->error_status_table[mb_xy];
if(!((error&DC_ERROR) && (error&MV_ERROR)))
undamaged_count++;
}
if(s->codec_id == CODEC_ID_H264){
H264Context *h= (void*)s;
if (h->ref_count[0] <= 0 || !h->ref_list[0][0].f.data[0])
return 1;
}
if(undamaged_count < 5) return 0; //almost all MBs damaged -> use temporal prediction
//prevent dsp.sad() check, that requires access to the image
if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration && s->pict_type == AV_PICTURE_TYPE_I)
return 1;
skip_amount= FFMAX(undamaged_count/50, 1); //check only upto 50 MBs
is_intra_likely=0;
j=0;
for(mb_y= 0; mb_y<s->mb_height-1; mb_y++){
for(mb_x= 0; mb_x<s->mb_width; mb_x++){
int error;
const int mb_xy= mb_x + mb_y*s->mb_stride;
error= s->error_status_table[mb_xy];
if((error&DC_ERROR) && (error&MV_ERROR))
continue; //skip damaged
j++;
if((j%skip_amount) != 0) continue; //skip a few to speed things up
if(s->pict_type==AV_PICTURE_TYPE_I){
uint8_t *mb_ptr = s->current_picture.f.data[0] + mb_x*16 + mb_y*16*s->linesize;
uint8_t *last_mb_ptr= s->last_picture.f.data [0] + mb_x*16 + mb_y*16*s->linesize;
if (s->avctx->codec_id == CODEC_ID_H264) {
// FIXME
} else {
ff_thread_await_progress((AVFrame *) s->last_picture_ptr,
mb_y, 0);
}
is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16);
// FIXME need await_progress() here
is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16);
}else{
if (IS_INTRA(s->current_picture.f.mb_type[mb_xy]))
is_intra_likely++;
else
is_intra_likely--;
}
}
}
//printf("is_intra_likely: %d type:%d\n", is_intra_likely, s->pict_type);
return is_intra_likely > 0;
}
| 23,273 |
qemu | d0bce760e04b1658a3b4ac95be2839ae20fd86db | 1 | I2CAdapter *omap_i2c_create(uint64_t addr)
{
OMAPI2C *s = g_malloc0(sizeof(*s));
I2CAdapter *i2c = (I2CAdapter *)s;
uint16_t data;
s->addr = addr;
i2c->send = omap_i2c_send;
i2c->recv = omap_i2c_recv;
/* verify the mmio address by looking for a known signature */
memread(addr + OMAP_I2C_REV, &data, 2);
g_assert_cmphex(data, ==, 0x34);
return i2c;
}
| 23,275 |
FFmpeg | 84bc45880ae14277cb804569401ddd34274f4764 | 1 | void ff_hevc_luma_mv_mvp_mode(HEVCContext *s, int x0, int y0, int nPbW,
int nPbH, int log2_cb_size, int part_idx,
int merge_idx, MvField *mv,
int mvp_lx_flag, int LX)
{
HEVCLocalContext *lc = s->HEVClc;
MvField *tab_mvf = s->ref->tab_mvf;
int isScaledFlag_L0 = 0;
int availableFlagLXA0 = 1;
int availableFlagLXB0 = 1;
int numMVPCandLX = 0;
int min_pu_width = s->sps->min_pu_width;
int xA0, yA0;
int is_available_a0;
int xA1, yA1;
int is_available_a1;
int xB0, yB0;
int is_available_b0;
int xB1, yB1;
int is_available_b1;
int xB2, yB2;
int is_available_b2;
Mv mvpcand_list[2] = { { 0 } };
Mv mxA;
Mv mxB;
int ref_idx_curr = 0;
int ref_idx = 0;
int pred_flag_index_l0;
int pred_flag_index_l1;
const int cand_bottom_left = lc->na.cand_bottom_left;
const int cand_left = lc->na.cand_left;
const int cand_up_left = lc->na.cand_up_left;
const int cand_up = lc->na.cand_up;
const int cand_up_right = lc->na.cand_up_right_sap;
ref_idx_curr = LX;
ref_idx = mv->ref_idx[LX];
pred_flag_index_l0 = LX;
pred_flag_index_l1 = !LX;
// left bottom spatial candidate
xA0 = x0 - 1;
yA0 = y0 + nPbH;
is_available_a0 = AVAILABLE(cand_bottom_left, A0) &&
yA0 < s->sps->height &&
PRED_BLOCK_AVAILABLE(A0);
//left spatial merge candidate
xA1 = x0 - 1;
yA1 = y0 + nPbH - 1;
is_available_a1 = AVAILABLE(cand_left, A1);
if (is_available_a0 || is_available_a1)
isScaledFlag_L0 = 1;
if (is_available_a0) {
if (MP_MX(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a0) {
if (MP_MX_LT(A0, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A0, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
if (is_available_a1) {
if (MP_MX_LT(A1, pred_flag_index_l0, mxA)) {
goto b_candidates;
}
if (MP_MX_LT(A1, pred_flag_index_l1, mxA)) {
goto b_candidates;
}
}
availableFlagLXA0 = 0;
b_candidates:
// B candidates
// above right spatial merge candidate
xB0 = x0 + nPbW;
yB0 = y0 - 1;
is_available_b0 = AVAILABLE(cand_up_right, B0) &&
xB0 < s->sps->width &&
PRED_BLOCK_AVAILABLE(B0);
if (is_available_b0) {
if (MP_MX(B0, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B0, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
// above spatial merge candidate
xB1 = x0 + nPbW - 1;
yB1 = y0 - 1;
is_available_b1 = AVAILABLE(cand_up, B1);
if (is_available_b1) {
if (MP_MX(B1, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B1, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
// above left spatial merge candidate
xB2 = x0 - 1;
yB2 = y0 - 1;
is_available_b2 = AVAILABLE(cand_up_left, B2);
if (is_available_b2) {
if (MP_MX(B2, pred_flag_index_l0, mxB)) {
goto scalef;
}
if (MP_MX(B2, pred_flag_index_l1, mxB)) {
goto scalef;
}
}
availableFlagLXB0 = 0;
scalef:
if (!isScaledFlag_L0) {
if (availableFlagLXB0) {
availableFlagLXA0 = 1;
mxA = mxB;
}
availableFlagLXB0 = 0;
// XB0 and L1
if (is_available_b0) {
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B0, pred_flag_index_l1, mxB);
}
if (is_available_b1 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B1, pred_flag_index_l1, mxB);
}
if (is_available_b2 && !availableFlagLXB0) {
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l0, mxB);
if (!availableFlagLXB0)
availableFlagLXB0 = MP_MX_LT(B2, pred_flag_index_l1, mxB);
}
}
if (availableFlagLXA0)
mvpcand_list[numMVPCandLX++] = mxA;
if (availableFlagLXB0 && (!availableFlagLXA0 || mxA.x != mxB.x || mxA.y != mxB.y))
mvpcand_list[numMVPCandLX++] = mxB;
//temporal motion vector prediction candidate
if (numMVPCandLX < 2 && s->sh.slice_temporal_mvp_enabled_flag &&
mvp_lx_flag == numMVPCandLX) {
Mv mv_col;
int available_col = temporal_luma_motion_vector(s, x0, y0, nPbW,
nPbH, ref_idx,
&mv_col, LX);
if (available_col)
mvpcand_list[numMVPCandLX++] = mv_col;
}
mv->mv[LX] = mvpcand_list[mvp_lx_flag];
}
| 23,276 |
qemu | 9745807191a81c45970f780166f44a7f93b18653 | 1 | static void gen_ove_cyov(DisasContext *dc, TCGv cy, TCGv ov)
{
if (dc->tb_flags & SR_OVE) {
TCGv t0 = tcg_temp_new();
tcg_gen_or_tl(t0, cy, ov);
gen_helper_ove(cpu_env, t0);
tcg_temp_free(t0);
}
}
| 23,278 |
qemu | 60fe637bf0e4d7989e21e50f52526444765c63b4 | 1 | static void put_uint16(QEMUFile *f, void *pv, size_t size)
{
uint16_t *v = pv;
qemu_put_be16s(f, v);
}
| 23,280 |
FFmpeg | b12d92efd6c0d48665383a9baecc13e7ebbd8a22 | 1 | static int vqa_decode_chunk(VqaContext *s)
{
unsigned int chunk_type;
unsigned int chunk_size;
int byte_skip;
unsigned int index = 0;
int i;
unsigned char r, g, b;
int index_shift;
int res;
int cbf0_chunk = -1;
int cbfz_chunk = -1;
int cbp0_chunk = -1;
int cbpz_chunk = -1;
int cpl0_chunk = -1;
int cplz_chunk = -1;
int vptz_chunk = -1;
int x, y;
int lines = 0;
int pixel_ptr;
int vector_index = 0;
int lobyte = 0;
int hibyte = 0;
int lobytes = 0;
int hibytes = s->decode_buffer_size / 2;
/* first, traverse through the frame and find the subchunks */
while (bytestream2_get_bytes_left(&s->gb) >= 8) {
chunk_type = bytestream2_get_be32u(&s->gb);
index = bytestream2_tell(&s->gb);
chunk_size = bytestream2_get_be32u(&s->gb);
switch (chunk_type) {
case CBF0_TAG:
cbf0_chunk = index;
break;
case CBFZ_TAG:
cbfz_chunk = index;
break;
case CBP0_TAG:
cbp0_chunk = index;
break;
case CBPZ_TAG:
cbpz_chunk = index;
break;
case CPL0_TAG:
cpl0_chunk = index;
break;
case CPLZ_TAG:
cplz_chunk = index;
break;
case VPTZ_TAG:
vptz_chunk = index;
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Found unknown chunk type: %c%c%c%c (%08X)\n",
(chunk_type >> 24) & 0xFF,
(chunk_type >> 16) & 0xFF,
(chunk_type >> 8) & 0xFF,
(chunk_type >> 0) & 0xFF,
chunk_type);
break;
}
byte_skip = chunk_size & 0x01;
bytestream2_skip(&s->gb, chunk_size + byte_skip);
}
/* next, deal with the palette */
if ((cpl0_chunk != -1) && (cplz_chunk != -1)) {
/* a chunk should not have both chunk types */
av_log(s->avctx, AV_LOG_ERROR, "problem: found both CPL0 and CPLZ chunks\n");
return AVERROR_INVALIDDATA;
}
/* decompress the palette chunk */
if (cplz_chunk != -1) {
/* yet to be handled */
}
/* convert the RGB palette into the machine's endian format */
if (cpl0_chunk != -1) {
bytestream2_seek(&s->gb, cpl0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
/* sanity check the palette size */
if (chunk_size / 3 > 256 || chunk_size > bytestream2_get_bytes_left(&s->gb)) {
av_log(s->avctx, AV_LOG_ERROR, "problem: found a palette chunk with %d colors\n",
chunk_size / 3);
return AVERROR_INVALIDDATA;
}
for (i = 0; i < chunk_size / 3; i++) {
/* scale by 4 to transform 6-bit palette -> 8-bit */
r = bytestream2_get_byteu(&s->gb) * 4;
g = bytestream2_get_byteu(&s->gb) * 4;
b = bytestream2_get_byteu(&s->gb) * 4;
s->palette[i] = 0xFF << 24 | r << 16 | g << 8 | b;
s->palette[i] |= s->palette[i] >> 6 & 0x30303;
}
}
/* next, look for a full codebook */
if ((cbf0_chunk != -1) && (cbfz_chunk != -1)) {
/* a chunk should not have both chunk types */
av_log(s->avctx, AV_LOG_ERROR, "problem: found both CBF0 and CBFZ chunks\n");
return AVERROR_INVALIDDATA;
}
/* decompress the full codebook chunk */
if (cbfz_chunk != -1) {
bytestream2_seek(&s->gb, cbfz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if ((res = decode_format80(s, chunk_size, s->codebook,
s->codebook_size, 0)) < 0)
return res;
}
/* copy a full codebook */
if (cbf0_chunk != -1) {
bytestream2_seek(&s->gb, cbf0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
/* sanity check the full codebook size */
if (chunk_size > MAX_CODEBOOK_SIZE) {
av_log(s->avctx, AV_LOG_ERROR, "problem: CBF0 chunk too large (0x%X bytes)\n",
chunk_size);
return AVERROR_INVALIDDATA;
}
bytestream2_get_buffer(&s->gb, s->codebook, chunk_size);
}
/* decode the frame */
if (vptz_chunk == -1) {
/* something is wrong if there is no VPTZ chunk */
av_log(s->avctx, AV_LOG_ERROR, "problem: no VPTZ chunk found\n");
return AVERROR_INVALIDDATA;
}
bytestream2_seek(&s->gb, vptz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if ((res = decode_format80(s, chunk_size,
s->decode_buffer, s->decode_buffer_size, 1)) < 0)
return res;
/* render the final PAL8 frame */
if (s->vector_height == 4)
index_shift = 4;
else
index_shift = 3;
for (y = 0; y < s->height; y += s->vector_height) {
for (x = 0; x < s->width; x += 4, lobytes++, hibytes++) {
pixel_ptr = y * s->frame.linesize[0] + x;
/* get the vector index, the method for which varies according to
* VQA file version */
switch (s->vqa_version) {
case 1:
lobyte = s->decode_buffer[lobytes * 2];
hibyte = s->decode_buffer[(lobytes * 2) + 1];
vector_index = ((hibyte << 8) | lobyte) >> 3;
vector_index <<= index_shift;
lines = s->vector_height;
/* uniform color fill - a quick hack */
if (hibyte == 0xFF) {
while (lines--) {
s->frame.data[0][pixel_ptr + 0] = 255 - lobyte;
s->frame.data[0][pixel_ptr + 1] = 255 - lobyte;
s->frame.data[0][pixel_ptr + 2] = 255 - lobyte;
s->frame.data[0][pixel_ptr + 3] = 255 - lobyte;
pixel_ptr += s->frame.linesize[0];
}
lines=0;
}
break;
case 2:
lobyte = s->decode_buffer[lobytes];
hibyte = s->decode_buffer[hibytes];
vector_index = (hibyte << 8) | lobyte;
vector_index <<= index_shift;
lines = s->vector_height;
break;
case 3:
/* not implemented yet */
lines = 0;
break;
}
while (lines--) {
s->frame.data[0][pixel_ptr + 0] = s->codebook[vector_index++];
s->frame.data[0][pixel_ptr + 1] = s->codebook[vector_index++];
s->frame.data[0][pixel_ptr + 2] = s->codebook[vector_index++];
s->frame.data[0][pixel_ptr + 3] = s->codebook[vector_index++];
pixel_ptr += s->frame.linesize[0];
}
}
}
/* handle partial codebook */
if ((cbp0_chunk != -1) && (cbpz_chunk != -1)) {
/* a chunk should not have both chunk types */
av_log(s->avctx, AV_LOG_ERROR, "problem: found both CBP0 and CBPZ chunks\n");
return AVERROR_INVALIDDATA;
}
if (cbp0_chunk != -1) {
bytestream2_seek(&s->gb, cbp0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
/* accumulate partial codebook */
bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index],
chunk_size);
s->next_codebook_buffer_index += chunk_size;
s->partial_countdown--;
if (s->partial_countdown <= 0) {
/* time to replace codebook */
memcpy(s->codebook, s->next_codebook_buffer,
s->next_codebook_buffer_index);
/* reset accounting */
s->next_codebook_buffer_index = 0;
s->partial_countdown = s->partial_count;
}
}
if (cbpz_chunk != -1) {
bytestream2_seek(&s->gb, cbpz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
/* accumulate partial codebook */
bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index],
chunk_size);
s->next_codebook_buffer_index += chunk_size;
s->partial_countdown--;
if (s->partial_countdown <= 0) {
GetByteContext gb;
bytestream2_init(&gb, s->next_codebook_buffer, s->next_codebook_buffer_index);
/* decompress codebook */
if ((res = decode_format80(s, s->next_codebook_buffer_index,
s->codebook, s->codebook_size, 0)) < 0)
return res;
/* reset accounting */
s->next_codebook_buffer_index = 0;
s->partial_countdown = s->partial_count;
}
}
return 0;
}
| 23,281 |
FFmpeg | 8fb8d539a4c594a58df226bc1bd7a4d149f39424 | 1 | static int hls_read(URLContext *h, uint8_t *buf, int size)
{
HLSContext *s = h->priv_data;
const char *url;
int ret;
int64_t reload_interval;
start:
if (s->seg_hd) {
ret = ffurl_read(s->seg_hd, buf, size);
if (ret > 0)
return ret;
}
if (s->seg_hd) {
ffurl_close(s->seg_hd);
s->seg_hd = NULL;
s->cur_seq_no++;
}
reload_interval = s->n_segments > 0 ?
s->segments[s->n_segments - 1]->duration :
s->target_duration;
reload_interval *= 1000000;
retry:
if (!s->finished) {
int64_t now = av_gettime();
if (now - s->last_load_time >= reload_interval) {
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
return ret;
/* If we need to reload the playlist again below (if
* there's still no more segments), switch to a reload
* interval of half the target duration. */
reload_interval = s->target_duration * 500000;
}
}
if (s->cur_seq_no < s->start_seq_no) {
av_log(h, AV_LOG_WARNING,
"skipping %d segments ahead, expired from playlist\n",
s->start_seq_no - s->cur_seq_no);
s->cur_seq_no = s->start_seq_no;
}
if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {
if (s->finished)
return AVERROR_EOF;
while (av_gettime() - s->last_load_time < reload_interval) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_usleep(100*1000);
}
goto retry;
}
url = s->segments[s->cur_seq_no - s->start_seq_no]->url,
av_log(h, AV_LOG_DEBUG, "opening %s\n", url);
ret = ffurl_open(&s->seg_hd, url, AVIO_FLAG_READ,
&h->interrupt_callback, NULL);
if (ret < 0) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_log(h, AV_LOG_WARNING, "Unable to open %s\n", url);
s->cur_seq_no++;
goto retry;
}
goto start;
}
| 23,282 |
FFmpeg | cec939597722663f322941b4c12e00a583e63504 | 1 | static inline void ff_h264_biweight_WxH_mmx2(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offsetd, int offsets, int w, int h)
{
int x, y;
int offset = ((offsets + offsetd + 1) | 1) << log2_denom;
asm volatile(
"movd %0, %%mm3 \n\t"
"movd %1, %%mm4 \n\t"
"movd %2, %%mm5 \n\t"
"movd %3, %%mm6 \n\t"
"pshufw $0, %%mm3, %%mm3 \n\t"
"pshufw $0, %%mm4, %%mm4 \n\t"
"pshufw $0, %%mm5, %%mm5 \n\t"
"pxor %%mm7, %%mm7 \n\t"
:: "g"(weightd), "g"(weights), "g"(offset), "g"(log2_denom+1)
);
for(y=0; y<h; y++){
for(x=0; x<w; x+=4){
asm volatile(
"movd %0, %%mm0 \n\t"
"movd %1, %%mm1 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm1 \n\t"
"pmullw %%mm3, %%mm0 \n\t"
"pmullw %%mm4, %%mm1 \n\t"
"paddw %%mm5, %%mm0 \n\t"
"paddw %%mm1, %%mm0 \n\t"
"psraw %%mm6, %%mm0 \n\t"
"packuswb %%mm0, %%mm0 \n\t"
"movd %%mm0, %0 \n\t"
: "+m"(*(uint32_t*)(dst+x))
: "m"(*(uint32_t*)(src+x))
);
}
src += stride;
dst += stride;
}
}
| 23,283 |
FFmpeg | 41ee459e88093a0b7ae13b8539ed9ccd0ebd0f0b | 1 | static int dpx_probe(AVProbeData *p)
{
const uint8_t *b = p->buf;
if (AV_RN32(b) == AV_RN32("SDPX") || AV_RN32(b) == AV_RN32("XPDS"))
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| 23,284 |
FFmpeg | b69c2e0e6dab87bb90fece1d0de47c28394aa8e6 | 1 | static int yop_read_seek(AVFormatContext *s, int stream_index,
int64_t timestamp, int flags)
{
YopDecContext *yop = s->priv_data;
int64_t frame_pos, pos_min, pos_max;
int frame_count;
av_free_packet(&yop->video_packet);
if (!stream_index)
return -1;
pos_min = s->data_offset;
pos_max = avio_size(s->pb) - yop->frame_size;
frame_count = (pos_max - pos_min) / yop->frame_size;
timestamp = FFMAX(0, FFMIN(frame_count, timestamp));
frame_pos = timestamp * yop->frame_size + pos_min;
yop->odd_frame = timestamp & 1;
avio_seek(s->pb, frame_pos, SEEK_SET);
return 0;
}
| 23,285 |
FFmpeg | ded5957d75def70d2f1fc1c1eae079230004974b | 0 | static int film_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
FilmDemuxContext *film = s->priv_data;
AVIOContext *pb = s->pb;
film_sample *sample;
int ret = 0;
int i;
int left, right;
if (film->current_sample >= film->sample_count)
return AVERROR(EIO);
sample = &film->sample_table[film->current_sample];
/* position the stream (will probably be there anyway) */
avio_seek(pb, sample->sample_offset, SEEK_SET);
/* do a special song and dance when loading FILM Cinepak chunks */
if ((sample->stream == film->video_stream_index) &&
(film->video_type == AV_CODEC_ID_CINEPAK)) {
pkt->pos= avio_tell(pb);
if (av_new_packet(pkt, sample->sample_size))
return AVERROR(ENOMEM);
avio_read(pb, pkt->data, sample->sample_size);
} else if ((sample->stream == film->audio_stream_index) &&
(film->audio_channels == 2) &&
(film->audio_type != AV_CODEC_ID_ADPCM_ADX)) {
/* stereo PCM needs to be interleaved */
if (av_new_packet(pkt, sample->sample_size))
return AVERROR(ENOMEM);
/* make sure the interleave buffer is large enough */
if (sample->sample_size > film->stereo_buffer_size) {
av_free(film->stereo_buffer);
film->stereo_buffer_size = sample->sample_size;
film->stereo_buffer = av_malloc(film->stereo_buffer_size);
if (!film->stereo_buffer) {
film->stereo_buffer_size = 0;
return AVERROR(ENOMEM);
}
}
pkt->pos= avio_tell(pb);
ret = avio_read(pb, film->stereo_buffer, sample->sample_size);
if (ret != sample->sample_size)
ret = AVERROR(EIO);
left = 0;
right = sample->sample_size / 2;
for (i = 0; i < sample->sample_size; ) {
if (film->audio_bits == 8) {
pkt->data[i++] = film->stereo_buffer[left++];
pkt->data[i++] = film->stereo_buffer[right++];
} else {
pkt->data[i++] = film->stereo_buffer[left++];
pkt->data[i++] = film->stereo_buffer[left++];
pkt->data[i++] = film->stereo_buffer[right++];
pkt->data[i++] = film->stereo_buffer[right++];
}
}
} else {
ret= av_get_packet(pb, pkt, sample->sample_size);
if (ret != sample->sample_size)
ret = AVERROR(EIO);
}
pkt->stream_index = sample->stream;
pkt->pts = sample->pts;
film->current_sample++;
return ret;
}
| 23,287 |
qemu | 071d4054770205ddb8a58a9e2735069d8fe52af1 | 1 | void qdist_init(struct qdist *dist)
{
dist->entries = g_malloc(sizeof(*dist->entries));
dist->size = 1;
dist->n = 0;
}
| 23,288 |
qemu | d3392718e1fcf0859fb7c0774a8e946bacb8419c | 1 | void arm_v7m_cpu_do_interrupt(CPUState *cs)
{
ARMCPU *cpu = ARM_CPU(cs);
CPUARMState *env = &cpu->env;
uint32_t lr;
arm_log_exception(cs->exception_index);
/* For exceptions we just mark as pending on the NVIC, and let that
handle it. */
switch (cs->exception_index) {
case EXCP_UDEF:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK;
break;
case EXCP_NOCP:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK;
break;
case EXCP_INVSTATE:
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure);
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK;
break;
case EXCP_SWI:
/* The PC already points to the next instruction. */
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure);
break;
case EXCP_PREFETCH_ABORT:
case EXCP_DATA_ABORT:
/* Note that for M profile we don't have a guest facing FSR, but
* the env->exception.fsr will be populated by the code that
* raises the fault, in the A profile short-descriptor format.
*/
switch (env->exception.fsr & 0xf) {
case 0x8: /* External Abort */
switch (cs->exception_index) {
case EXCP_PREFETCH_ABORT:
env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK;
qemu_log_mask(CPU_LOG_INT, "...with CFSR.IBUSERR\n");
break;
case EXCP_DATA_ABORT:
env->v7m.cfsr[M_REG_NS] |=
(R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK);
env->v7m.bfar = env->exception.vaddress;
qemu_log_mask(CPU_LOG_INT,
"...with CFSR.PRECISERR and BFAR 0x%x\n",
env->v7m.bfar);
break;
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false);
break;
default:
/* All other FSR values are either MPU faults or "can't happen
* for M profile" cases.
*/
switch (cs->exception_index) {
case EXCP_PREFETCH_ABORT:
env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK;
qemu_log_mask(CPU_LOG_INT, "...with CFSR.IACCVIOL\n");
break;
case EXCP_DATA_ABORT:
env->v7m.cfsr[env->v7m.secure] |=
(R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK);
env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress;
qemu_log_mask(CPU_LOG_INT,
"...with CFSR.DACCVIOL and MMFAR 0x%x\n",
env->v7m.mmfar[env->v7m.secure]);
break;
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM,
env->v7m.secure);
break;
}
break;
case EXCP_BKPT:
if (semihosting_enabled()) {
int nr;
nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff;
if (nr == 0xab) {
env->regs[15] += 2;
qemu_log_mask(CPU_LOG_INT,
"...handling as semihosting call 0x%x\n",
env->regs[0]);
env->regs[0] = do_arm_semihosting(env);
return;
}
}
armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false);
break;
case EXCP_IRQ:
break;
case EXCP_EXCEPTION_EXIT:
do_v7m_exception_exit(cpu);
return;
default:
cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
return; /* Never happens. Keep compiler happy. */
}
lr = R_V7M_EXCRET_RES1_MASK |
R_V7M_EXCRET_S_MASK |
R_V7M_EXCRET_DCRS_MASK |
R_V7M_EXCRET_FTYPE_MASK |
R_V7M_EXCRET_ES_MASK;
if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) {
lr |= R_V7M_EXCRET_SPSEL_MASK;
}
if (!arm_v7m_is_handler_mode(env)) {
lr |= R_V7M_EXCRET_MODE_MASK;
}
v7m_push_stack(cpu);
v7m_exception_taken(cpu, lr);
qemu_log_mask(CPU_LOG_INT, "... as %d\n", env->v7m.exception);
}
| 23,289 |
qemu | 563890c7c7e977842e2a35afe7a24d06d2103242 | 1 | static void socket_sendf(int fd, const char *fmt, va_list ap)
{
gchar *str;
size_t size, offset;
str = g_strdup_vprintf(fmt, ap);
size = strlen(str);
offset = 0;
while (offset < size) {
ssize_t len;
len = write(fd, str + offset, size - offset);
if (len == -1 && errno == EINTR) {
continue;
}
g_assert_no_errno(len);
g_assert_cmpint(len, >, 0);
offset += len;
}
}
| 23,290 |
qemu | 04097f7c5957273c578f72b9bd603ba6b1d69e33 | 1 | int vhost_dev_init(struct vhost_dev *hdev, int devfd, bool force)
{
uint64_t features;
int r;
if (devfd >= 0) {
hdev->control = devfd;
} else {
hdev->control = open("/dev/vhost-net", O_RDWR);
if (hdev->control < 0) {
return -errno;
}
}
r = ioctl(hdev->control, VHOST_SET_OWNER, NULL);
if (r < 0) {
goto fail;
}
r = ioctl(hdev->control, VHOST_GET_FEATURES, &features);
if (r < 0) {
goto fail;
}
hdev->features = features;
hdev->client.set_memory = vhost_client_set_memory;
hdev->client.sync_dirty_bitmap = vhost_client_sync_dirty_bitmap;
hdev->client.migration_log = vhost_client_migration_log;
hdev->client.log_start = NULL;
hdev->client.log_stop = NULL;
hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions));
hdev->log = NULL;
hdev->log_size = 0;
hdev->log_enabled = false;
hdev->started = false;
cpu_register_phys_memory_client(&hdev->client);
hdev->force = force;
return 0;
fail:
r = -errno;
close(hdev->control);
return r;
}
| 23,291 |
FFmpeg | c3ab0004ae4dffc32494ae84dd15cfaa909a7884 | 1 | static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->chrMmx2FilterCode;
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %6 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t" // i
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
"xor %%"REG_a", %%"REG_a" \n\t" // i
"mov %5, %%"REG_c" \n\t" // src
"mov %1, %%"REG_D" \n\t" // buf1
"add $"AV_STRINGIFY(VOF)", %%"REG_D" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %6, %%"REG_b" \n\t"
#endif
:: "m" (src1), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode), "m" (src2)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
//printf("%d %d %d\n", dstWidth, i, srcW);
dst[i] = src1[srcW-1]*128;
dst[i+VOFW] = src2[srcW-1]*128;
}
} else {
#endif /* COMPILE_TEMPLATE_MMX2 */
x86_reg dstWidth_reg = dstWidth;
x86_reg xInc_shr16 = (x86_reg) (xInc >> 16);
uint16_t xInc_mask = xInc & 0xffff;
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t" // i
"xor %%"REG_d", %%"REG_d" \n\t" // xx
"xorl %%ecx, %%ecx \n\t" // xalpha
ASMALIGN(4)
"1: \n\t"
"mov %0, %%"REG_S" \n\t"
"movzbl (%%"REG_S", %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%%"REG_S", %%"REG_d"), %%esi \n\t" //src[xx+1]
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"movzbl (%5, %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%5, %%"REG_d"), %%esi \n\t" //src[xx+1]
FAST_BILINEAR_X86
"movw %%si, "AV_STRINGIFY(VOF)"(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t" //xalpha += xInc&0xFFFF
"adc %3, %%"REG_d" \n\t" //xx+= xInc>>16 + carry
"add $1, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
/* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here,
which is needed to support GCC 4.0. */
#if ARCH_X86_64 && AV_GCC_VERSION_AT_LEAST(3,4)
:: "m" (src1), "m" (dst), "g" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#else
:: "m" (src1), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask),
#endif
"r" (src2)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
} //if MMX2 can't be used
#endif
#else
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]=(src1[xx]*(xalpha^127)+src1[xx+1]*xalpha);
dst[i+VOFW]=(src2[xx]*(xalpha^127)+src2[xx+1]*xalpha);
/* slower
dst[i]= (src1[xx]<<7) + (src1[xx+1] - src1[xx])*xalpha;
dst[i+VOFW]=(src2[xx]<<7) + (src2[xx+1] - src2[xx])*xalpha;
*/
xpos+=xInc;
}
#endif /* ARCH_X86 */
}
| 23,293 |
FFmpeg | 2d09cdbaf2f449ba23d54e97e94bd97ca22208c6 | 1 | static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
IVITile *tile, AVCodecContext *avctx)
{
int x, y, mv_x, mv_y, mv_delta, offs, mb_offset,
mv_scale, blks_per_mb;
IVIMbInfo *mb, *ref_mb;
int row_offset = band->mb_size * band->pitch;
mb = tile->mbs;
ref_mb = tile->ref_mbs;
offs = tile->ypos * band->pitch + tile->xpos;
if (!ref_mb &&
((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv))
/* scale factor for motion vectors */
mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
mv_x = mv_y = 0;
for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) {
mb_offset = offs;
for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) {
mb->xpos = x;
mb->ypos = y;
mb->buf_offs = mb_offset;
if (get_bits1(&ctx->gb)) {
if (ctx->frame_type == FRAMETYPE_INTRA) {
av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n");
return -1;
mb->type = 1; /* empty macroblocks are always INTER */
mb->cbp = 0; /* all blocks are empty */
mb->q_delta = 0;
if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
mb->mv_x = mb->mv_y = 0; /* no motion vector coded */
if (band->inherit_mv){
/* motion vector inheritance */
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
} else {
if (band->inherit_mv) {
mb->type = ref_mb->type; /* copy mb_type from corresponding reference mb */
} else if (ctx->frame_type == FRAMETYPE_INTRA) {
mb->type = 0; /* mb_type is always INTRA for intra-frames */
} else {
mb->type = get_bits1(&ctx->gb);
blks_per_mb = band->mb_size != band->blk_size ? 4 : 1;
mb->cbp = get_bits(&ctx->gb, blks_per_mb);
mb->q_delta = 0;
if (band->qdelta_present) {
if (band->inherit_qdelta) {
if (ref_mb) mb->q_delta = ref_mb->q_delta;
} else if (mb->cbp || (!band->plane && !band->band_num &&
(ctx->frame_flags & 8))) {
mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mb->q_delta = IVI_TOSIGNED(mb->q_delta);
if (!mb->type) {
mb->mv_x = mb->mv_y = 0; /* there is no motion vector in intra-macroblocks */
} else {
if (band->inherit_mv){
/* motion vector inheritance */
if (mv_scale) {
mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale);
mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale);
} else {
mb->mv_x = ref_mb->mv_x;
mb->mv_y = ref_mb->mv_y;
} else {
/* decode motion vector deltas */
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_y += IVI_TOSIGNED(mv_delta);
mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
IVI_VLC_BITS, 1);
mv_x += IVI_TOSIGNED(mv_delta);
mb->mv_x = mv_x;
mb->mv_y = mv_y;
mb++;
if (ref_mb)
ref_mb++;
mb_offset += band->mb_size;
offs += row_offset;
align_get_bits(&ctx->gb);
return 0; | 23,294 |
FFmpeg | 180a0b1bcb522dab0ad828d8efb9673a6531d534 | 1 | static void decode_nal_sei_frame_packing_arrangement(HEVCContext *s)
{
GetBitContext *gb = &s->HEVClc->gb;
int cancel, type, quincunx, content;
get_ue_golomb(gb); // frame_packing_arrangement_id
cancel = get_bits1(gb); // frame_packing_cancel_flag
if (cancel == 0) {
type = get_bits(gb, 7); // frame_packing_arrangement_type
quincunx = get_bits1(gb); // quincunx_sampling_flag
content = get_bits(gb, 6); // content_interpretation_type
// the following skips spatial_flipping_flag frame0_flipped_flag
// field_views_flag current_frame_is_frame0_flag
// frame0_self_contained_flag frame1_self_contained_flag
skip_bits(gb, 6);
if (quincunx == 0 && type != 5)
skip_bits(gb, 16); // frame[01]_grid_position_[xy]
skip_bits(gb, 8); // frame_packing_arrangement_reserved_byte
skip_bits1(gb); // frame_packing_arrangement_persistance_flag
}
skip_bits1(gb); // upsampled_aspect_ratio_flag
s->sei_frame_packing_present = (cancel == 0);
s->frame_packing_arrangement_type = type;
s->content_interpretation_type = content;
s->quincunx_subsampling = quincunx;
}
| 23,295 |
qemu | 70976a7926b42d87e0c575412b85a8f5c1e48fad | 1 | static int gdb_get_spe_reg(CPUState *env, uint8_t *mem_buf, int n)
{
if (n < 32) {
#if defined(TARGET_PPC64)
stl_p(mem_buf, env->gpr[n] >> 32);
#else
stl_p(mem_buf, env->gprh[n]);
#endif
return 4;
}
if (n == 33) {
stq_p(mem_buf, env->spe_acc);
return 8;
}
if (n == 34) {
/* SPEFSCR not implemented */
memset(mem_buf, 0, 4);
return 4;
}
return 0;
}
| 23,296 |
qemu | 8b81bb3b069d4007bc44c8d5888d630b7f0b42ff | 1 | static void virtio_pci_device_unplugged(DeviceState *d)
{
PCIDevice *pci_dev = PCI_DEVICE(d);
VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
virtio_pci_stop_ioeventfd(proxy);
msix_uninit_exclusive_bar(pci_dev);
}
| 23,297 |
qemu | b36e391441906c36ed0856b69de84001860402bf | 1 | static int virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
{
int n;
if (!proxy->ioeventfd_started) {
return 0;
}
for (n = 0; n < VIRTIO_PCI_QUEUE_MAX; n++) {
if (!virtio_queue_get_num(proxy->vdev, n)) {
continue;
}
virtio_pci_set_host_notifier_fd_handler(proxy, n, false);
virtio_pci_set_host_notifier_internal(proxy, n, false);
}
proxy->ioeventfd_started = false;
return 0;
}
| 23,300 |
qemu | 94fb0909645de18481cc726ee0ec9b5afa861394 | 1 | static int ram_decompress_buf(RamDecompressState *s, uint8_t *buf, int len)
{
int ret, clen;
s->zstream.avail_out = len;
s->zstream.next_out = buf;
while (s->zstream.avail_out > 0) {
if (s->zstream.avail_in == 0) {
if (qemu_get_be16(s->f) != RAM_CBLOCK_MAGIC)
return -1;
clen = qemu_get_be16(s->f);
if (clen > IOBUF_SIZE)
return -1;
qemu_get_buffer(s->f, s->buf, clen);
s->zstream.avail_in = clen;
s->zstream.next_in = s->buf;
}
ret = inflate(&s->zstream, Z_PARTIAL_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END) {
return -1;
}
}
return 0;
}
| 23,301 |
FFmpeg | e977ca2645cc6b23589ddf97ab08861064ba8792 | 1 | void avfilter_free(AVFilterContext *filter)
{
int i;
AVFilterLink *link;
if (filter->filter->uninit)
filter->filter->uninit(filter);
for (i = 0; i < filter->input_count; i++) {
if ((link = filter->inputs[i])) {
if (link->src)
link->src->outputs[link->srcpad - link->src->output_pads] = NULL;
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
av_freep(&link);
}
for (i = 0; i < filter->output_count; i++) {
if ((link = filter->outputs[i])) {
if (link->dst)
link->dst->inputs[link->dstpad - link->dst->input_pads] = NULL;
avfilter_formats_unref(&link->in_formats);
avfilter_formats_unref(&link->out_formats);
}
av_freep(&link);
}
av_freep(&filter->name);
av_freep(&filter->input_pads);
av_freep(&filter->output_pads);
av_freep(&filter->inputs);
av_freep(&filter->outputs);
av_freep(&filter->priv);
av_free(filter);
}
| 23,302 |
qemu | 21ef45d71221b4577330fe3aacfb06afad91ad46 | 1 | void gtk_display_init(DisplayState *ds)
{
GtkDisplayState *s = g_malloc0(sizeof(*s));
gtk_init(NULL, NULL);
ds->opaque = s;
s->ds = ds;
s->dcl.ops = &dcl_ops;
s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(3, 2, 0)
s->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
#else
s->vbox = gtk_vbox_new(FALSE, 0);
#endif
s->notebook = gtk_notebook_new();
s->drawing_area = gtk_drawing_area_new();
s->menu_bar = gtk_menu_bar_new();
s->scale_x = 1.0;
s->scale_y = 1.0;
s->free_scale = FALSE;
setlocale(LC_ALL, "");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
qemu_add_vm_change_state_handler(gd_change_runstate, s);
gtk_notebook_append_page(GTK_NOTEBOOK(s->notebook), s->drawing_area, gtk_label_new("VGA"));
gd_create_menus(s);
gd_connect_signals(s);
gtk_widget_add_events(s->drawing_area,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
GDK_SCROLL_MASK |
GDK_KEY_PRESS_MASK);
gtk_widget_set_double_buffered(s->drawing_area, FALSE);
gtk_widget_set_can_focus(s->drawing_area, TRUE);
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(s->notebook), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(s->notebook), FALSE);
gd_update_caption(s);
gtk_box_pack_start(GTK_BOX(s->vbox), s->menu_bar, FALSE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(s->vbox), s->notebook, TRUE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(s->window), s->vbox);
gtk_widget_show_all(s->window);
register_displaychangelistener(ds, &s->dcl);
global_state = s;
}
| 23,303 |
qemu | 21ef45d71221b4577330fe3aacfb06afad91ad46 | 1 | void vnc_display_init(DisplayState *ds)
{
VncDisplay *vs = g_malloc0(sizeof(*vs));
dcl = g_malloc0(sizeof(DisplayChangeListener));
ds->opaque = vs;
dcl->idle = 1;
vnc_display = vs;
vs->lsock = -1;
#ifdef CONFIG_VNC_WS
vs->lwebsock = -1;
#endif
vs->ds = ds;
QTAILQ_INIT(&vs->clients);
vs->expires = TIME_MAX;
if (keyboard_layout)
vs->kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
else
vs->kbd_layout = init_keyboard_layout(name2keysym, "en-us");
if (!vs->kbd_layout)
exit(1);
qemu_mutex_init(&vs->mutex);
vnc_start_worker_thread();
dcl->ops = &dcl_ops;
register_displaychangelistener(ds, dcl);
}
| 23,304 |
FFmpeg | 078d43e23a7a3d64aafee8a58b380d3e139b3020 | 1 | static int mpegts_handle_packet(AVFormatContext *ctx, PayloadContext *data,
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
const uint8_t *buf, int len, uint16_t seq,
int flags)
{
int ret;
// We don't want to use the RTP timestamps at all. If the mpegts demuxer
// doesn't set any pts/dts, the generic rtpdec code shouldn't try to
// fill it in either, since the mpegts and RTP timestamps are in totally
// different ranges.
*timestamp = RTP_NOTS_VALUE;
if (!data->ts)
return AVERROR(EINVAL);
if (!buf) {
if (data->read_buf_index >= data->read_buf_size)
return AVERROR(EAGAIN);
ret = ff_mpegts_parse_packet(data->ts, pkt, data->buf + data->read_buf_index,
data->read_buf_size - data->read_buf_index);
if (ret < 0)
return AVERROR(EAGAIN);
data->read_buf_index += ret;
if (data->read_buf_index < data->read_buf_size)
return 1;
else
return 0;
}
ret = ff_mpegts_parse_packet(data->ts, pkt, buf, len);
/* The only error that can be returned from ff_mpegts_parse_packet
* is "no more data to return from the provided buffer", so return
* AVERROR(EAGAIN) for all errors */
if (ret < 0)
return AVERROR(EAGAIN);
if (ret < len) {
data->read_buf_size = FFMIN(len - ret, sizeof(data->buf));
memcpy(data->buf, buf + ret, data->read_buf_size);
data->read_buf_index = 0;
return 1;
}
return 0;
}
| 23,305 |
qemu | b3dd1b8c295636e64ceb14cdc4db6420d7319e38 | 1 | static int monitor_fdset_dup_fd_find_remove(int dup_fd, bool remove)
{
MonFdset *mon_fdset;
MonFdsetFd *mon_fdset_fd_dup;
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
QLIST_FOREACH(mon_fdset_fd_dup, &mon_fdset->dup_fds, next) {
if (mon_fdset_fd_dup->fd == dup_fd) {
if (remove) {
QLIST_REMOVE(mon_fdset_fd_dup, next);
if (QLIST_EMPTY(&mon_fdset->dup_fds)) {
monitor_fdset_cleanup(mon_fdset);
}
}
return mon_fdset->id;
}
}
}
return -1;
}
| 23,306 |
qemu | 6f2d8978728c48ca46f5c01835438508aace5c64 | 1 | static always_inline void powerpc_excp (CPUState *env,
int excp_model, int excp)
{
target_ulong msr, new_msr, vector;
int srr0, srr1, asrr0, asrr1;
#if defined(TARGET_PPC64H)
int lpes0, lpes1, lev;
lpes0 = (env->spr[SPR_LPCR] >> 1) & 1;
lpes1 = (env->spr[SPR_LPCR] >> 2) & 1;
#endif
if (loglevel & CPU_LOG_INT) {
fprintf(logfile, "Raise exception at 0x" ADDRX " => 0x%08x (%02x)\n",
env->nip, excp, env->error_code);
}
msr = env->msr;
new_msr = msr;
srr0 = SPR_SRR0;
srr1 = SPR_SRR1;
asrr0 = -1;
asrr1 = -1;
msr &= ~((target_ulong)0x783F0000);
switch (excp) {
case POWERPC_EXCP_NONE:
/* Should never happen */
return;
case POWERPC_EXCP_CRITICAL: /* Critical input */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
switch (excp_model) {
case POWERPC_EXCP_40x:
srr0 = SPR_40x_SRR2;
srr1 = SPR_40x_SRR3;
break;
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_CSRR0;
srr1 = SPR_BOOKE_CSRR1;
break;
case POWERPC_EXCP_G2:
break;
default:
goto excp_invalid;
}
goto store_next;
case POWERPC_EXCP_MCHECK: /* Machine check exception */
if (msr_me == 0) {
/* Machine check exception is not enabled.
* Enter checkstop state.
*/
if (loglevel != 0) {
fprintf(logfile, "Machine check while not allowed. "
"Entering checkstop state\n");
} else {
fprintf(stderr, "Machine check while not allowed. "
"Entering checkstop state\n");
}
env->halted = 1;
env->interrupt_request |= CPU_INTERRUPT_EXITTB;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
new_msr &= ~((target_ulong)1 << MSR_ME);
#if defined(TARGET_PPC64H)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
/* XXX: should also have something loaded in DAR / DSISR */
switch (excp_model) {
case POWERPC_EXCP_40x:
srr0 = SPR_40x_SRR2;
srr1 = SPR_40x_SRR3;
break;
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_MCSRR0;
srr1 = SPR_BOOKE_MCSRR1;
asrr0 = SPR_BOOKE_CSRR0;
asrr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
goto store_next;
case POWERPC_EXCP_DSI: /* Data storage exception */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "DSI exception: DSISR=0x" ADDRX" DAR=0x" ADDRX
"\n", env->spr[SPR_DSISR], env->spr[SPR_DAR]);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ISI: /* Instruction storage exception */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "ISI exception: msr=0x" ADDRX ", nip=0x" ADDRX
"\n", msr, env->nip);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= env->error_code;
goto store_next;
case POWERPC_EXCP_EXTERNAL: /* External input */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes0 == 1)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ALIGN: /* Alignment exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
/* XXX: this is false */
/* Get rS/rD and rA from faulting opcode */
env->spr[SPR_DSISR] |= (ldl_code((env->nip - 4)) & 0x03FF0000) >> 16;
goto store_current;
case POWERPC_EXCP_PROGRAM: /* Program exception */
switch (env->error_code & ~0xF) {
case POWERPC_EXCP_FP:
if ((msr_fe0 == 0 && msr_fe1 == 0) || msr_fp == 0) {
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "Ignore floating point exception\n");
}
#endif
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
return;
}
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00100000;
if (msr_fe0 == msr_fe1)
goto store_next;
msr |= 0x00010000;
break;
case POWERPC_EXCP_INVAL:
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0) {
fprintf(logfile, "Invalid instruction at 0x" ADDRX "\n",
env->nip);
}
#endif
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00080000;
break;
case POWERPC_EXCP_PRIV:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00040000;
break;
case POWERPC_EXCP_TRAP:
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
msr |= 0x00020000;
break;
default:
/* Should never occur */
cpu_abort(env, "Invalid program exception %d. Aborting\n",
env->error_code);
break;
}
goto store_current;
case POWERPC_EXCP_FPU: /* Floating-point unavailable exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_current;
case POWERPC_EXCP_SYSCALL: /* System call exception */
/* NOTE: this is a temporary hack to support graphics OSI
calls from the MOL driver */
/* XXX: To be removed */
if (env->gpr[3] == 0x113724fa && env->gpr[4] == 0x77810f9b &&
env->osi_call) {
if (env->osi_call(env) != 0) {
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
return;
}
}
if (loglevel & CPU_LOG_INT) {
dump_syscall(env);
}
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
lev = env->error_code;
if (lev == 1 || (lpes0 == 0 && lpes1 == 0))
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_APU: /* Auxiliary processor unavailable */
new_msr &= ~((target_ulong)1 << MSR_RI);
goto store_current;
case POWERPC_EXCP_DECR: /* Decrementer exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_FIT: /* Fixed-interval timer interrupt */
/* FIT on 4xx */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "FIT exception\n");
#endif
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_WDT: /* Watchdog timer interrupt */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "WDT exception\n");
#endif
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_CSRR0;
srr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_DTLB: /* Data TLB error */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_ITLB: /* Instruction TLB error */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_DEBUG: /* Debug interrupt */
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_DSRR0;
srr1 = SPR_BOOKE_DSRR1;
asrr0 = SPR_BOOKE_CSRR0;
asrr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
/* XXX: TODO */
cpu_abort(env, "Debug exception is not implemented yet !\n");
goto store_next;
#if defined(TARGET_PPCEMB)
case POWERPC_EXCP_SPEU: /* SPE/embedded floating-point unavailable */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_current;
case POWERPC_EXCP_EFPDI: /* Embedded floating-point data interrupt */
/* XXX: TODO */
cpu_abort(env, "Embedded floating point data exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EFPRI: /* Embedded floating-point round interrupt */
/* XXX: TODO */
cpu_abort(env, "Embedded floating point round exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EPERFM: /* Embedded performance monitor interrupt */
new_msr &= ~((target_ulong)1 << MSR_RI);
/* XXX: TODO */
cpu_abort(env,
"Performance counter exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_DOORI: /* Embedded doorbell interrupt */
/* XXX: TODO */
cpu_abort(env,
"Embedded doorbell interrupt is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_DOORCI: /* Embedded doorbell critical interrupt */
switch (excp_model) {
case POWERPC_EXCP_BOOKE:
srr0 = SPR_BOOKE_CSRR0;
srr1 = SPR_BOOKE_CSRR1;
break;
default:
break;
}
/* XXX: TODO */
cpu_abort(env, "Embedded doorbell critical interrupt "
"is not implemented yet !\n");
goto store_next;
#endif /* defined(TARGET_PPCEMB) */
case POWERPC_EXCP_RESET: /* System reset exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#if defined(TARGET_PPC64)
case POWERPC_EXCP_DSEG: /* Data segment exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
case POWERPC_EXCP_ISEG: /* Instruction segment exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#endif /* defined(TARGET_PPC64) */
#if defined(TARGET_PPC64H)
case POWERPC_EXCP_HDECR: /* Hypervisor decrementer exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
#endif
case POWERPC_EXCP_TRACE: /* Trace exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_next;
#if defined(TARGET_PPC64H)
case POWERPC_EXCP_HDSI: /* Hypervisor data storage exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HISI: /* Hypervisor instruction storage exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HDSEG: /* Hypervisor data segment exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
case POWERPC_EXCP_HISEG: /* Hypervisor instruction segment exception */
srr0 = SPR_HSRR0;
srr1 = SPR_HSRR1;
new_msr |= (target_ulong)1 << MSR_HV;
goto store_next;
#endif /* defined(TARGET_PPC64H) */
case POWERPC_EXCP_VPU: /* Vector unavailable exception */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
goto store_current;
case POWERPC_EXCP_PIT: /* Programmable interval timer interrupt */
#if defined (DEBUG_EXCEPTIONS)
if (loglevel != 0)
fprintf(logfile, "PIT exception\n");
#endif
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
goto store_next;
case POWERPC_EXCP_IO: /* IO error exception */
/* XXX: TODO */
cpu_abort(env, "601 IO error exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_RUNM: /* Run mode exception */
/* XXX: TODO */
cpu_abort(env, "601 run mode exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_EMUL: /* Emulation trap exception */
/* XXX: TODO */
cpu_abort(env, "602 emulation trap exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_IFTLB: /* Instruction fetch TLB error */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
#if defined(TARGET_PPC64H) /* XXX: check this */
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
goto tlb_miss_tgpr;
case POWERPC_EXCP_7x5:
goto tlb_miss;
case POWERPC_EXCP_74xx:
goto tlb_miss_74xx;
default:
cpu_abort(env, "Invalid instruction TLB miss exception\n");
break;
}
break;
case POWERPC_EXCP_DLTLB: /* Data load TLB miss */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
#if defined(TARGET_PPC64H) /* XXX: check this */
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
goto tlb_miss_tgpr;
case POWERPC_EXCP_7x5:
goto tlb_miss;
case POWERPC_EXCP_74xx:
goto tlb_miss_74xx;
default:
cpu_abort(env, "Invalid data load TLB miss exception\n");
break;
}
break;
case POWERPC_EXCP_DSTLB: /* Data store TLB miss */
new_msr &= ~((target_ulong)1 << MSR_RI); /* XXX: check this */
#if defined(TARGET_PPC64H) /* XXX: check this */
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
switch (excp_model) {
case POWERPC_EXCP_602:
case POWERPC_EXCP_603:
case POWERPC_EXCP_603E:
case POWERPC_EXCP_G2:
tlb_miss_tgpr:
/* Swap temporary saved registers with GPRs */
if (!(new_msr & ((target_ulong)1 << MSR_TGPR))) {
new_msr |= (target_ulong)1 << MSR_TGPR;
hreg_swap_gpr_tgpr(env);
}
goto tlb_miss;
case POWERPC_EXCP_7x5:
tlb_miss:
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
const unsigned char *es;
target_ulong *miss, *cmp;
int en;
if (excp == POWERPC_EXCP_IFTLB) {
es = "I";
en = 'I';
miss = &env->spr[SPR_IMISS];
cmp = &env->spr[SPR_ICMP];
} else {
if (excp == POWERPC_EXCP_DLTLB)
es = "DL";
else
es = "DS";
en = 'D';
miss = &env->spr[SPR_DMISS];
cmp = &env->spr[SPR_DCMP];
}
fprintf(logfile, "6xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
" H1 " ADDRX " H2 " ADDRX " %08x\n",
es, en, *miss, en, *cmp,
env->spr[SPR_HASH1], env->spr[SPR_HASH2],
env->error_code);
}
#endif
msr |= env->crf[0] << 28;
msr |= env->error_code; /* key, D/I, S/L bits */
/* Set way using a LRU mechanism */
msr |= ((env->last_way + 1) & (env->nb_ways - 1)) << 17;
break;
case POWERPC_EXCP_74xx:
tlb_miss_74xx:
#if defined (DEBUG_SOFTWARE_TLB)
if (loglevel != 0) {
const unsigned char *es;
target_ulong *miss, *cmp;
int en;
if (excp == POWERPC_EXCP_IFTLB) {
es = "I";
en = 'I';
miss = &env->spr[SPR_TLBMISS];
cmp = &env->spr[SPR_PTEHI];
} else {
if (excp == POWERPC_EXCP_DLTLB)
es = "DL";
else
es = "DS";
en = 'D';
miss = &env->spr[SPR_TLBMISS];
cmp = &env->spr[SPR_PTEHI];
}
fprintf(logfile, "74xx %sTLB miss: %cM " ADDRX " %cC " ADDRX
" %08x\n",
es, en, *miss, en, *cmp, env->error_code);
}
#endif
msr |= env->error_code; /* key bit */
break;
default:
cpu_abort(env, "Invalid data store TLB miss exception\n");
break;
}
goto store_next;
case POWERPC_EXCP_FPA: /* Floating-point assist exception */
/* XXX: TODO */
cpu_abort(env, "Floating point assist exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_IABR: /* Instruction address breakpoint */
/* XXX: TODO */
cpu_abort(env, "IABR exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_SMI: /* System management interrupt */
/* XXX: TODO */
cpu_abort(env, "SMI exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_THERM: /* Thermal interrupt */
/* XXX: TODO */
cpu_abort(env, "Thermal management exception "
"is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_PERFM: /* Embedded performance monitor interrupt */
new_msr &= ~((target_ulong)1 << MSR_RI);
#if defined(TARGET_PPC64H)
if (lpes1 == 0)
new_msr |= (target_ulong)1 << MSR_HV;
#endif
/* XXX: TODO */
cpu_abort(env,
"Performance counter exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_VPUA: /* Vector assist exception */
/* XXX: TODO */
cpu_abort(env, "VPU assist exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_SOFTP: /* Soft patch exception */
/* XXX: TODO */
cpu_abort(env,
"970 soft-patch exception is not implemented yet !\n");
goto store_next;
case POWERPC_EXCP_MAINT: /* Maintenance exception */
/* XXX: TODO */
cpu_abort(env,
"970 maintenance exception is not implemented yet !\n");
goto store_next;
default:
excp_invalid:
cpu_abort(env, "Invalid PowerPC exception %d. Aborting\n", excp);
break;
store_current:
/* save current instruction location */
env->spr[srr0] = env->nip - 4;
break;
store_next:
/* save next instruction location */
env->spr[srr0] = env->nip;
break;
}
/* Save MSR */
env->spr[srr1] = msr;
/* If any alternate SRR register are defined, duplicate saved values */
if (asrr0 != -1)
env->spr[asrr0] = env->spr[srr0];
if (asrr1 != -1)
env->spr[asrr1] = env->spr[srr1];
/* If we disactivated any translation, flush TLBs */
if (new_msr & ((1 << MSR_IR) | (1 << MSR_DR)))
tlb_flush(env, 1);
/* reload MSR with correct bits */
new_msr &= ~((target_ulong)1 << MSR_EE);
new_msr &= ~((target_ulong)1 << MSR_PR);
new_msr &= ~((target_ulong)1 << MSR_FP);
new_msr &= ~((target_ulong)1 << MSR_FE0);
new_msr &= ~((target_ulong)1 << MSR_SE);
new_msr &= ~((target_ulong)1 << MSR_BE);
new_msr &= ~((target_ulong)1 << MSR_FE1);
new_msr &= ~((target_ulong)1 << MSR_IR);
new_msr &= ~((target_ulong)1 << MSR_DR);
#if 0 /* Fix this: not on all targets */
new_msr &= ~((target_ulong)1 << MSR_PMM);
#endif
new_msr &= ~((target_ulong)1 << MSR_LE);
if (msr_ile)
new_msr |= (target_ulong)1 << MSR_LE;
else
new_msr &= ~((target_ulong)1 << MSR_LE);
/* Jump to handler */
vector = env->excp_vectors[excp];
if (vector == (target_ulong)-1) {
cpu_abort(env, "Raised an exception without defined vector %d\n",
excp);
}
vector |= env->excp_prefix;
#if defined(TARGET_PPC64)
if (excp_model == POWERPC_EXCP_BOOKE) {
if (!msr_icm) {
new_msr &= ~((target_ulong)1 << MSR_CM);
vector = (uint32_t)vector;
} else {
new_msr |= (target_ulong)1 << MSR_CM;
}
} else {
if (!msr_isf) {
new_msr &= ~((target_ulong)1 << MSR_SF);
vector = (uint32_t)vector;
} else {
new_msr |= (target_ulong)1 << MSR_SF;
}
}
#endif
/* XXX: we don't use hreg_store_msr here as already have treated
* any special case that could occur. Just store MSR and update hflags
*/
env->msr = new_msr;
env->hflags_nmsr = 0x00000000;
hreg_compute_hflags(env);
env->nip = vector;
/* Reset exception state */
env->exception_index = POWERPC_EXCP_NONE;
env->error_code = 0;
}
| 23,310 |
FFmpeg | c82b8ef0e4f226423ddd644bfe37e6a15d070924 | 1 | static void compute_default_clut(AVSubtitleRect *rect, int w, int h)
{
uint8_t list[256] = {0};
uint8_t list_inv[256];
int counttab[256] = {0};
int count, i, x, y;
#define V(x,y) rect->data[0][(x) + (y)*rect->linesize[0]]
for (y = 0; y<h; y++) {
for (x = 0; x<w; x++) {
int v = V(x,y) + 1;
int vl = x ? V(x-1,y) + 1 : 0;
int vr = x+1<w ? V(x+1,y) + 1 : 0;
int vt = y ? V(x,y-1) + 1 : 0;
int vb = y+1<h ? V(x,y+1) + 1 : 0;
counttab[v-1] += !!((v!=vl) + (v!=vr) + (v!=vt) + (v!=vb));
}
}
#define L(x,y) list[ rect->data[0][(x) + (y)*rect->linesize[0]] ]
for (i = 0; i<256; i++) {
int scoretab[256] = {0};
int bestscore = 0;
int bestv = 0;
for (y = 0; y<h; y++) {
for (x = 0; x<w; x++) {
int v = rect->data[0][x + y*rect->linesize[0]];
int l_m = list[v];
int l_l = x ? L(x-1, y) : 1;
int l_r = x+1<w ? L(x+1, y) : 1;
int l_t = y ? L(x, y-1) : 1;
int l_b = y+1<h ? L(x, y+1) : 1;
int score;
if (l_m)
continue;
scoretab[v] += l_l + l_r + l_t + l_b;
score = 1024LL*scoretab[v] / counttab[v];
if (score > bestscore) {
bestscore = score;
bestv = v;
}
}
}
if (!bestscore)
break;
list [ bestv ] = 1;
list_inv[ i ] = bestv;
}
count = i - 1;
for (i--; i>=0; i--) {
int v = i*255/count;
AV_WN32(rect->data[1] + 4*list_inv[i], RGBA(v/2,v,v/2,v));
}
}
| 23,311 |
qemu | 0df93305f21712e975ab5df260cc5a91e5daafca | 1 | static void qcow_close(BlockDriverState *bs)
{
BDRVQcowState *s = bs->opaque;
g_free(s->l1_table);
g_free(s->l2_cache);
g_free(s->cluster_cache);
g_free(s->cluster_data);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
}
| 23,312 |
FFmpeg | 169c1cfa928040b83f2ac8386333ec5e5cff3df7 | 1 | static int pvf_read_header(AVFormatContext *s)
{
char buffer[32];
AVStream *st;
int bps, channels, sample_rate;
avio_skip(s->pb, 5);
ff_get_line(s->pb, buffer, sizeof(buffer));
if (sscanf(buffer, "%d %d %d",
&channels,
&sample_rate,
&bps) != 3)
return AVERROR_INVALIDDATA;
if (channels <= 0 || bps <= 0 || sample_rate <= 0)
return AVERROR_INVALIDDATA;
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->channels = channels;
st->codecpar->sample_rate = sample_rate;
st->codecpar->codec_id = ff_get_pcm_codec_id(bps, 0, 1, 0xFFFF);
st->codecpar->bits_per_coded_sample = bps;
st->codecpar->block_align = bps * st->codecpar->channels / 8;
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
| 23,313 |
qemu | b20909195745c34a819aed14ae996b60ab0f591f | 1 | iscsi_readv_writev_bh_cb(void *p)
{
IscsiAIOCB *acb = p;
qemu_bh_delete(acb->bh);
if (!acb->canceled) {
acb->common.cb(acb->common.opaque, acb->status);
}
qemu_aio_release(acb);
if (acb->canceled) {
return;
}
scsi_free_scsi_task(acb->task);
acb->task = NULL;
}
| 23,315 |
qemu | 069ab0eb8a46bc4ff6f4d4d81bf037d3441347da | 1 | static void vmmouse_reset(DeviceState *d)
{
VMMouseState *s = container_of(d, VMMouseState, dev.qdev);
s->status = 0xffff;
s->queue_size = VMMOUSE_QUEUE_SIZE;
} | 23,317 |
FFmpeg | fac1ccbda1bb8441c7329a3ac18fbf04886da983 | 1 | static int doTest(uint8_t *ref[4], int refStride[4], int w, int h,
enum AVPixelFormat srcFormat, enum AVPixelFormat dstFormat,
int srcW, int srcH, int dstW, int dstH, int flags,
struct Results *r)
{
static enum AVPixelFormat cur_srcFormat;
static int cur_srcW, cur_srcH;
static uint8_t *src[4];
static int srcStride[4];
uint8_t *dst[4] = { 0 };
uint8_t *out[4] = { 0 };
int dstStride[4];
int i;
uint64_t ssdY, ssdU = 0, ssdV = 0, ssdA = 0;
struct SwsContext *dstContext = NULL, *outContext = NULL;
uint32_t crc = 0;
int res = 0;
if (cur_srcFormat != srcFormat || cur_srcW != srcW || cur_srcH != srcH) {
struct SwsContext *srcContext = NULL;
int p;
for (p = 0; p < 4; p++)
av_freep(&src[p]);
av_image_fill_linesizes(srcStride, srcFormat, srcW);
for (p = 0; p < 4; p++) {
srcStride[p] = FFALIGN(srcStride[p], 16);
if (srcStride[p])
src[p] = av_mallocz(srcStride[p] * srcH + 16);
if (srcStride[p] && !src[p]) {
perror("Malloc");
res = -1;
goto end;
}
}
srcContext = sws_getContext(w, h, AV_PIX_FMT_YUVA420P, srcW, srcH,
srcFormat, SWS_BILINEAR, NULL, NULL, NULL);
if (!srcContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name,
av_pix_fmt_descriptors[srcFormat].name);
res = -1;
goto end;
}
sws_scale(srcContext, ref, refStride, 0, h, src, srcStride);
sws_freeContext(srcContext);
cur_srcFormat = srcFormat;
cur_srcW = srcW;
cur_srcH = srcH;
}
av_image_fill_linesizes(dstStride, dstFormat, dstW);
for (i = 0; i < 4; i++) {
/* Image buffers passed into libswscale can be allocated any way you
* prefer, as long as they're aligned enough for the architecture, and
* they're freed appropriately (such as using av_free for buffers
* allocated with av_malloc). */
/* An extra 16 bytes is being allocated because some scalers may write
* out of bounds. */
dstStride[i] = FFALIGN(dstStride[i], 16);
if (dstStride[i])
dst[i] = av_mallocz(dstStride[i] * dstH + 16);
if (dstStride[i] && !dst[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
dstContext = sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat,
flags, NULL, NULL, NULL);
if (!dstContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[srcFormat].name,
av_pix_fmt_descriptors[dstFormat].name);
res = -1;
goto end;
}
printf(" %s %dx%d -> %s %3dx%3d flags=%2d",
av_pix_fmt_descriptors[srcFormat].name, srcW, srcH,
av_pix_fmt_descriptors[dstFormat].name, dstW, dstH,
flags);
fflush(stdout);
sws_scale(dstContext, src, srcStride, 0, srcH, dst, dstStride);
for (i = 0; i < 4 && dstStride[i]; i++)
crc = av_crc(av_crc_get_table(AV_CRC_32_IEEE), crc, dst[i],
dstStride[i] * dstH);
if (r && crc == r->crc) {
ssdY = r->ssdY;
ssdU = r->ssdU;
ssdV = r->ssdV;
ssdA = r->ssdA;
} else {
for (i = 0; i < 4; i++) {
refStride[i] = FFALIGN(refStride[i], 16);
if (refStride[i])
out[i] = av_mallocz(refStride[i] * h);
if (refStride[i] && !out[i]) {
perror("Malloc");
res = -1;
goto end;
}
}
outContext = sws_getContext(dstW, dstH, dstFormat, w, h,
AV_PIX_FMT_YUVA420P, SWS_BILINEAR,
NULL, NULL, NULL);
if (!outContext) {
fprintf(stderr, "Failed to get %s ---> %s\n",
av_pix_fmt_descriptors[dstFormat].name,
av_pix_fmt_descriptors[AV_PIX_FMT_YUVA420P].name);
res = -1;
goto end;
}
sws_scale(outContext, dst, dstStride, 0, dstH, out, refStride);
ssdY = getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
if (hasChroma(srcFormat) && hasChroma(dstFormat)) {
//FIXME check that output is really gray
ssdU = getSSD(ref[1], out[1], refStride[1], refStride[1],
(w + 1) >> 1, (h + 1) >> 1);
ssdV = getSSD(ref[2], out[2], refStride[2], refStride[2],
(w + 1) >> 1, (h + 1) >> 1);
}
if (isALPHA(srcFormat) && isALPHA(dstFormat))
ssdA = getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
ssdY /= w * h;
ssdU /= w * h / 4;
ssdV /= w * h / 4;
ssdA /= w * h;
sws_freeContext(outContext);
for (i = 0; i < 4; i++)
if (refStride[i])
av_free(out[i]);
}
printf(" CRC=%08x SSD=%5"PRId64 ",%5"PRId64 ",%5"PRId64 ",%5"PRId64 "\n",
crc, ssdY, ssdU, ssdV, ssdA);
end:
sws_freeContext(dstContext);
for (i = 0; i < 4; i++)
if (dstStride[i])
av_free(dst[i]);
return res;
}
| 23,318 |
qemu | 560f19f162529d691619ac69ed032321c7f5f1fb | 1 | char *object_property_get_str(Object *obj, const char *name,
Error **errp)
{
QObject *ret = object_property_get_qobject(obj, name, errp);
QString *qstring;
char *retval;
if (!ret) {
return NULL;
}
qstring = qobject_to_qstring(ret);
if (!qstring) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string");
retval = NULL;
} else {
retval = g_strdup(qstring_get_str(qstring));
}
QDECREF(qstring);
return retval;
}
| 23,319 |
qemu | 99787f69cdd8147d0be67d71ec3058cce21e2444 | 1 | ip_input(struct mbuf *m)
{
Slirp *slirp = m->slirp;
register struct ip *ip;
int hlen;
DEBUG_CALL("ip_input");
DEBUG_ARG("m = %p", m);
DEBUG_ARG("m_len = %d", m->m_len);
if (m->m_len < sizeof (struct ip)) {
return;
}
ip = mtod(m, struct ip *);
if (ip->ip_v != IPVERSION) {
goto bad;
}
hlen = ip->ip_hl << 2;
if (hlen<sizeof(struct ip ) || hlen>m->m_len) {/* min header length */
goto bad; /* or packet too short */
}
/* keep ip header intact for ICMP reply
* ip->ip_sum = cksum(m, hlen);
* if (ip->ip_sum) {
*/
if(cksum(m,hlen)) {
goto bad;
}
/*
* Convert fields to host representation.
*/
NTOHS(ip->ip_len);
if (ip->ip_len < hlen) {
goto bad;
}
NTOHS(ip->ip_id);
NTOHS(ip->ip_off);
/*
* Check that the amount of data in the buffers
* is as at least much as the IP header would have us expect.
* Trim mbufs if longer than we expect.
* Drop packet if shorter than we expect.
*/
if (m->m_len < ip->ip_len) {
goto bad;
}
/* Should drop packet if mbuf too long? hmmm... */
if (m->m_len > ip->ip_len)
m_adj(m, ip->ip_len - m->m_len);
/* check ip_ttl for a correct ICMP reply */
if (ip->ip_ttl == 0) {
icmp_send_error(m, ICMP_TIMXCEED, ICMP_TIMXCEED_INTRANS, 0, "ttl");
goto bad;
}
/*
* If offset or IP_MF are set, must reassemble.
* Otherwise, nothing need be done.
* (We could look in the reassembly queue to see
* if the packet was previously fragmented,
* but it's not worth the time; just let them time out.)
*
* XXX This should fail, don't fragment yet
*/
if (ip->ip_off &~ IP_DF) {
register struct ipq *fp;
struct qlink *l;
/*
* Look for queue of fragments
* of this datagram.
*/
for (l = slirp->ipq.ip_link.next; l != &slirp->ipq.ip_link;
l = l->next) {
fp = container_of(l, struct ipq, ip_link);
if (ip->ip_id == fp->ipq_id &&
ip->ip_src.s_addr == fp->ipq_src.s_addr &&
ip->ip_dst.s_addr == fp->ipq_dst.s_addr &&
ip->ip_p == fp->ipq_p)
goto found;
}
fp = NULL;
found:
/*
* Adjust ip_len to not reflect header,
* set ip_mff if more fragments are expected,
* convert offset of this to bytes.
*/
ip->ip_len -= hlen;
if (ip->ip_off & IP_MF)
ip->ip_tos |= 1;
else
ip->ip_tos &= ~1;
ip->ip_off <<= 3;
/*
* If datagram marked as having more fragments
* or if this is not the first fragment,
* attempt reassembly; if it succeeds, proceed.
*/
if (ip->ip_tos & 1 || ip->ip_off) {
ip = ip_reass(slirp, ip, fp);
if (ip == NULL)
return;
m = dtom(slirp, ip);
} else
if (fp)
ip_freef(slirp, fp);
} else
ip->ip_len -= hlen;
/*
* Switch out to protocol's input routine.
*/
switch (ip->ip_p) {
case IPPROTO_TCP:
tcp_input(m, hlen, (struct socket *)NULL, AF_INET);
break;
case IPPROTO_UDP:
udp_input(m, hlen);
break;
case IPPROTO_ICMP:
icmp_input(m, hlen);
break;
default:
m_free(m);
}
return;
bad:
m_free(m);
}
| 23,320 |
FFmpeg | 7f526efd17973ec6d2204f7a47b6923e2be31363 | 1 | static inline void RENAME(yuv2yuv1)(int16_t *lumSrc, int16_t *chrSrc,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
#ifdef HAVE_MMX
if(uDest != NULL)
{
asm volatile(
YSCALEYUV2YV121
:: "r" (chrSrc + chrDstW), "r" (uDest + chrDstW),
"g" ((long)-chrDstW)
: "%"REG_a
);
asm volatile(
YSCALEYUV2YV121
:: "r" (chrSrc + 2048 + chrDstW), "r" (vDest + chrDstW),
"g" ((long)-chrDstW)
: "%"REG_a
);
}
asm volatile(
YSCALEYUV2YV121
:: "r" (lumSrc + dstW), "r" (dest + dstW),
"g" ((long)-dstW)
: "%"REG_a
);
#else
int i;
for(i=0; i<dstW; i++)
{
int val= lumSrc[i]>>7;
if(val&256){
if(val<0) val=0;
else val=255;
}
dest[i]= val;
}
if(uDest != NULL)
for(i=0; i<chrDstW; i++)
{
int u=chrSrc[i]>>7;
int v=chrSrc[i + 2048]>>7;
if((u|v)&256){
if(u<0) u=0;
else if (u>255) u=255;
if(v<0) v=0;
else if (v>255) v=255;
}
uDest[i]= u;
vDest[i]= v;
}
#endif
}
| 23,321 |
FFmpeg | 138902dfb60fbb87fb65a8c4800f8ac661394b72 | 1 | static int read_dialogue(ASSContext *ass, AVBPrint *dst, const uint8_t *p,
int64_t *start, int *duration)
{
int pos;
int64_t end;
int hh1, mm1, ss1, ms1;
int hh2, mm2, ss2, ms2;
if (sscanf(p, "Dialogue: %*[^,],%d:%d:%d%*c%d,%d:%d:%d%*c%d,%n",
&hh1, &mm1, &ss1, &ms1,
&hh2, &mm2, &ss2, &ms2, &pos) >= 8) {
/* This is not part of the sscanf itself in order to handle an actual
* number (which would be the Layer) or the form "Marked=N" (which is
* the old SSA field, now replaced by Layer, and will be lead to Layer
* being 0 here). */
const int layer = atoi(p + 10);
end = (hh2*3600LL + mm2*60LL + ss2) * 100LL + ms2;
*start = (hh1*3600LL + mm1*60LL + ss1) * 100LL + ms1;
*duration = end - *start;
av_bprint_clear(dst);
av_bprintf(dst, "%u,%d,%s", ass->readorder++, layer, p + pos);
/* right strip the buffer */
while (dst->len > 0 &&
dst->str[dst->len - 1] == '\r' ||
dst->str[dst->len - 1] == '\n')
dst->str[--dst->len] = 0;
return 0;
}
return -1;
}
| 23,322 |
FFmpeg | 932e6a5a4c78250e3cab4f65215214fb0dbf51f7 | 1 | static void quantize_bands(int (*out)[2], const float *in, const float *scaled,
int size, float Q34, int is_signed, int maxval)
{
int i;
double qc;
for (i = 0; i < size; i++) {
qc = scaled[i] * Q34;
out[i][0] = (int)FFMIN((int)qc, maxval);
out[i][1] = (int)FFMIN((int)(qc + 0.4054), maxval);
if (is_signed && in[i] < 0.0f) {
out[i][0] = -out[i][0];
out[i][1] = -out[i][1];
}
}
}
| 23,324 |
FFmpeg | df3b17eba47e635a694acb18b74e389194355f45 | 1 | av_cold int vaapi_device_init(const char *device)
{
int err;
err = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI,
device, NULL, 0);
if (err < 0) {
av_log(&vaapi_log, AV_LOG_ERROR, "Failed to create a VAAPI device\n");
return err;
}
return 0;
} | 23,325 |
qemu | a4e26048526d8d5b181f9a0a7d4f82b8441c5dfd | 1 | static int qemu_chr_open_pty(QemuOpts *opts, CharDriverState **_chr)
{
CharDriverState *chr;
PtyCharDriver *s;
struct termios tty;
int slave_fd, len;
#if defined(__OpenBSD__) || defined(__DragonFly__)
char pty_name[PATH_MAX];
#define q_ptsname(x) pty_name
#else
char *pty_name = NULL;
#define q_ptsname(x) ptsname(x)
#endif
chr = g_malloc0(sizeof(CharDriverState));
s = g_malloc0(sizeof(PtyCharDriver));
if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) {
return -errno;
}
/* Set raw attributes on the pty. */
tcgetattr(slave_fd, &tty);
cfmakeraw(&tty);
tcsetattr(slave_fd, TCSAFLUSH, &tty);
close(slave_fd);
len = strlen(q_ptsname(s->fd)) + 5;
chr->filename = g_malloc(len);
snprintf(chr->filename, len, "pty:%s", q_ptsname(s->fd));
qemu_opt_set(opts, "path", q_ptsname(s->fd));
fprintf(stderr, "char device redirected to %s\n", q_ptsname(s->fd));
chr->opaque = s;
chr->chr_write = pty_chr_write;
chr->chr_update_read_handler = pty_chr_update_read_handler;
chr->chr_close = pty_chr_close;
s->timer = qemu_new_timer_ms(rt_clock, pty_chr_timer, chr);
*_chr = chr;
return 0;
}
| 23,326 |
FFmpeg | df037fe107ccfae4b26ee0e46b638b052f6e49f8 | 1 | static int smvjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt)
{
const AVPixFmtDescriptor *desc;
SMVJpegDecodeContext *s = avctx->priv_data;
AVFrame* mjpeg_data = s->picture[0];
int i, cur_frame = 0, ret = 0;
cur_frame = avpkt->pts % s->frames_per_jpeg;
/* Are we at the start of a block? */
if (!cur_frame) {
av_frame_unref(mjpeg_data);
ret = avcodec_decode_video2(s->avctx, mjpeg_data, &s->mjpeg_data_size, avpkt);
if (ret < 0) {
s->mjpeg_data_size = 0;
return ret;
}
} else if (!s->mjpeg_data_size)
return AVERROR(EINVAL);
desc = av_pix_fmt_desc_get(s->avctx->pix_fmt);
if (desc && mjpeg_data->height % (s->frames_per_jpeg << desc->log2_chroma_h)) {
av_log(avctx, AV_LOG_ERROR, "Invalid height\n");
return AVERROR_INVALIDDATA;
}
/*use the last lot... */
*data_size = s->mjpeg_data_size;
avctx->pix_fmt = s->avctx->pix_fmt;
/* We shouldn't get here if frames_per_jpeg <= 0 because this was rejected
in init */
ret = ff_set_dimensions(avctx, mjpeg_data->width, mjpeg_data->height / s->frames_per_jpeg);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Failed to set dimensions\n");
return ret;
}
if (*data_size) {
s->picture[1]->extended_data = NULL;
s->picture[1]->width = avctx->width;
s->picture[1]->height = avctx->height;
s->picture[1]->format = avctx->pix_fmt;
/* ff_init_buffer_info(avctx, &s->picture[1]); */
smv_img_pnt(s->picture[1]->data, mjpeg_data->data, mjpeg_data->linesize,
avctx->pix_fmt, avctx->width, avctx->height, cur_frame);
for (i = 0; i < AV_NUM_DATA_POINTERS; i++)
s->picture[1]->linesize[i] = mjpeg_data->linesize[i];
ret = av_frame_ref(data, s->picture[1]);
}
return ret;
}
| 23,327 |
qemu | a9a72aeefbd3ef8bcbbeeccaf174ee10db2978ac | 1 | static void tpm_display_backend_drivers(void)
{
int i;
fprintf(stderr, "Supported TPM types (choose only one):\n");
for (i = 0; i < TPM_MAX_DRIVERS && be_drivers[i] != NULL; i++) {
fprintf(stderr, "%12s %s\n",
TpmType_lookup[be_drivers[i]->type], be_drivers[i]->desc());
}
fprintf(stderr, "\n");
}
| 23,328 |
FFmpeg | 907783f221ad9594a528681e30777705f11bf0b5 | 0 | static void rtsp_parse_rtp_info(RTSPState *rt, const char *p)
{
int read = 0;
char key[20], value[1024], url[1024] = "";
uint32_t seq = 0, rtptime = 0;
for (;;) {
p += strspn(p, SPACE_CHARS);
if (!*p)
break;
get_word_sep(key, sizeof(key), "=", &p);
if (*p != '=')
break;
p++;
get_word_sep(value, sizeof(value), ";, ", &p);
read++;
if (!strcmp(key, "url"))
av_strlcpy(url, value, sizeof(url));
else if (!strcmp(key, "seq"))
seq = strtol(value, NULL, 10);
else if (!strcmp(key, "rtptime"))
rtptime = strtol(value, NULL, 10);
if (*p == ',') {
handle_rtp_info(rt, url, seq, rtptime);
url[0] = '\0';
seq = rtptime = 0;
read = 0;
}
if (*p)
p++;
}
if (read > 0)
handle_rtp_info(rt, url, seq, rtptime);
}
| 23,329 |
FFmpeg | fd92dafaff8844b5fedf94679b93d953939a7f7b | 0 | static int bink_decode_plane(BinkContext *c, AVFrame *frame, BitstreamContext *bc,
int plane_idx, int is_chroma)
{
int blk, ret;
int i, j, bx, by;
uint8_t *dst, *prev, *ref_start, *ref_end;
int v, col[2];
const uint8_t *scan;
LOCAL_ALIGNED_16(int16_t, block, [64]);
LOCAL_ALIGNED_16(uint8_t, ublock, [64]);
LOCAL_ALIGNED_16(int32_t, dctblock, [64]);
int coordmap[64];
const int stride = frame->linesize[plane_idx];
int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3;
int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3;
int width = c->avctx->width >> is_chroma;
init_lengths(c, FFMAX(width, 8), bw);
for (i = 0; i < BINK_NB_SRC; i++)
read_bundle(bc, c, i);
ref_start = c->last->data[plane_idx] ? c->last->data[plane_idx]
: frame->data[plane_idx];
ref_end = ref_start
+ (bw - 1 + c->last->linesize[plane_idx] * (bh - 1)) * 8;
for (i = 0; i < 64; i++)
coordmap[i] = (i & 7) + (i >> 3) * stride;
for (by = 0; by < bh; by++) {
if ((ret = read_block_types(c->avctx, bc, &c->bundle[BINK_SRC_BLOCK_TYPES])) < 0)
return ret;
if ((ret = read_block_types(c->avctx, bc, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0)
return ret;
if ((ret = read_colors(bc, &c->bundle[BINK_SRC_COLORS], c)) < 0)
return ret;
if ((ret = read_patterns(c->avctx, bc, &c->bundle[BINK_SRC_PATTERN])) < 0)
return ret;
if ((ret = read_motion_values(c->avctx, bc, &c->bundle[BINK_SRC_X_OFF])) < 0)
return ret;
if ((ret = read_motion_values(c->avctx, bc, &c->bundle[BINK_SRC_Y_OFF])) < 0)
return ret;
if ((ret = read_dcs(c->avctx, bc, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0)
return ret;
if ((ret = read_dcs(c->avctx, bc, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1)) < 0)
return ret;
if ((ret = read_runs(c->avctx, bc, &c->bundle[BINK_SRC_RUN])) < 0)
return ret;
if (by == bh)
break;
dst = frame->data[plane_idx] + 8*by*stride;
prev = (c->last->data[plane_idx] ? c->last->data[plane_idx]
: frame->data[plane_idx]) + 8*by*stride;
for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) {
blk = get_value(c, BINK_SRC_BLOCK_TYPES);
// 16x16 block type on odd line means part of the already decoded block, so skip it
if ((by & 1) && blk == SCALED_BLOCK) {
bx++;
dst += 8;
prev += 8;
continue;
}
switch (blk) {
case SKIP_BLOCK:
c->hdsp.put_pixels_tab[1][0](dst, prev, stride, 8);
break;
case SCALED_BLOCK:
blk = get_value(c, BINK_SRC_SUB_BLOCK_TYPES);
switch (blk) {
case RUN_BLOCK:
scan = bink_patterns[bitstream_read(bc, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return AVERROR_INVALIDDATA;
}
if (bitstream_read_bit(bc)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
ublock[*scan++] = v;
} else {
for (j = 0; j < run; j++)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
ublock[*scan++] = get_value(c, BINK_SRC_COLORS);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(bc, dctblock, bink_scan, bink_intra_quant, -1);
c->binkdsp.idct_put(ublock, 8, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->bdsp.fill_block_tab[0](dst, v, stride, 16);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < 8; j++) {
v = get_value(c, BINK_SRC_PATTERN);
for (i = 0; i < 8; i++, v >>= 1)
ublock[i + j*8] = col[v & 1];
}
break;
case RAW_BLOCK:
for (j = 0; j < 8; j++)
for (i = 0; i < 8; i++)
ublock[i + j*8] = get_value(c, BINK_SRC_COLORS);
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk);
return AVERROR_INVALIDDATA;
}
if (blk != FILL_BLOCK)
c->binkdsp.scale_block(ublock, dst, stride);
bx++;
dst += 8;
prev += 8;
break;
case MOTION_BLOCK:
ret = bink_put_pixels(c, dst, prev, stride,
ref_start, ref_end);
if (ret < 0)
return ret;
break;
case RUN_BLOCK:
scan = bink_patterns[bitstream_read(bc, 4)];
i = 0;
do {
int run = get_value(c, BINK_SRC_RUN) + 1;
i += run;
if (i > 64) {
av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n");
return AVERROR_INVALIDDATA;
}
if (bitstream_read_bit(bc)) {
v = get_value(c, BINK_SRC_COLORS);
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = v;
} else {
for (j = 0; j < run; j++)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
}
} while (i < 63);
if (i == 63)
dst[coordmap[*scan++]] = get_value(c, BINK_SRC_COLORS);
break;
case RESIDUE_BLOCK:
ret = bink_put_pixels(c, dst, prev, stride,
ref_start, ref_end);
if (ret < 0)
return ret;
c->bdsp.clear_block(block);
v = bitstream_read(bc, 7);
read_residue(bc, block, v);
c->binkdsp.add_pixels8(dst, block, stride);
break;
case INTRA_BLOCK:
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTRA_DC);
read_dct_coeffs(bc, dctblock, bink_scan, bink_intra_quant, -1);
c->binkdsp.idct_put(dst, stride, dctblock);
break;
case FILL_BLOCK:
v = get_value(c, BINK_SRC_COLORS);
c->bdsp.fill_block_tab[1](dst, v, stride, 8);
break;
case INTER_BLOCK:
ret = bink_put_pixels(c, dst, prev, stride,
ref_start, ref_end);
if (ret < 0)
return ret;
memset(dctblock, 0, sizeof(*dctblock) * 64);
dctblock[0] = get_value(c, BINK_SRC_INTER_DC);
read_dct_coeffs(bc, dctblock, bink_scan, bink_inter_quant, -1);
c->binkdsp.idct_add(dst, stride, dctblock);
break;
case PATTERN_BLOCK:
for (i = 0; i < 2; i++)
col[i] = get_value(c, BINK_SRC_COLORS);
for (i = 0; i < 8; i++) {
v = get_value(c, BINK_SRC_PATTERN);
for (j = 0; j < 8; j++, v >>= 1)
dst[i*stride + j] = col[v & 1];
}
break;
case RAW_BLOCK:
for (i = 0; i < 8; i++)
memcpy(dst + i*stride, c->bundle[BINK_SRC_COLORS].cur_ptr + i*8, 8);
c->bundle[BINK_SRC_COLORS].cur_ptr += 64;
break;
default:
av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk);
return AVERROR_INVALIDDATA;
}
}
}
if (bitstream_tell(bc) & 0x1F) // next plane data starts at 32-bit boundary
bitstream_skip(bc, 32 - (bitstream_tell(bc) & 0x1F));
return 0;
}
| 23,330 |
FFmpeg | 0c22311b56e66115675c4a96e4c78547886a4171 | 0 | static void opt_frame_pad_right(const char *arg)
{
frame_padright = atoi(arg);
if (frame_padright < 0) {
fprintf(stderr, "Incorrect right pad size\n");
av_exit(1);
}
}
| 23,331 |
FFmpeg | d1f558b3628d3ab99fd93a98b5758ef1be45a5da | 0 | static int dcadec_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
DCAContext *s = avctx->priv_data;
AVFrame *frame = data;
uint8_t *input = avpkt->data;
int input_size = avpkt->size;
int i, ret, prev_packet = s->packet;
if (input_size < MIN_PACKET_SIZE || input_size > MAX_PACKET_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Invalid packet size\n");
return AVERROR_INVALIDDATA;
}
av_fast_malloc(&s->buffer, &s->buffer_size,
FFALIGN(input_size, 4096) + DCA_BUFFER_PADDING_SIZE);
if (!s->buffer)
return AVERROR(ENOMEM);
for (i = 0, ret = AVERROR_INVALIDDATA; i < input_size - MIN_PACKET_SIZE + 1 && ret < 0; i++)
ret = convert_bitstream(input + i, input_size - i, s->buffer, s->buffer_size);
if (ret < 0) {
av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n");
return ret;
}
input = s->buffer;
input_size = ret;
s->packet = 0;
// Parse backward compatible core sub-stream
if (AV_RB32(input) == DCA_SYNCWORD_CORE_BE) {
int frame_size;
if ((ret = ff_dca_core_parse(&s->core, input, input_size)) < 0)
return ret;
s->packet |= DCA_PACKET_CORE;
// EXXS data must be aligned on 4-byte boundary
frame_size = FFALIGN(s->core.frame_size, 4);
if (input_size - 4 > frame_size) {
input += frame_size;
input_size -= frame_size;
}
}
if (!s->core_only) {
DCAExssAsset *asset = NULL;
// Parse extension sub-stream (EXSS)
if (AV_RB32(input) == DCA_SYNCWORD_SUBSTREAM) {
if ((ret = ff_dca_exss_parse(&s->exss, input, input_size)) < 0) {
if (avctx->err_recognition & AV_EF_EXPLODE)
return ret;
} else {
s->packet |= DCA_PACKET_EXSS;
asset = &s->exss.assets[0];
}
}
// Parse XLL component in EXSS
if (asset && (asset->extension_mask & DCA_EXSS_XLL)) {
if ((ret = ff_dca_xll_parse(&s->xll, input, asset)) < 0) {
// Conceal XLL synchronization error
if (ret == AVERROR(EAGAIN)
&& (prev_packet & DCA_PACKET_XLL)
&& (s->packet & DCA_PACKET_CORE))
s->packet |= DCA_PACKET_XLL | DCA_PACKET_RECOVERY;
else if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
} else {
s->packet |= DCA_PACKET_XLL;
}
}
// Parse LBR component in EXSS
if (asset && (asset->extension_mask & DCA_EXSS_LBR)) {
if ((ret = ff_dca_lbr_parse(&s->lbr, input, asset)) < 0) {
if (ret == AVERROR(ENOMEM) || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
} else {
s->packet |= DCA_PACKET_LBR;
}
}
// Parse core extensions in EXSS or backward compatible core sub-stream
if ((s->packet & DCA_PACKET_CORE)
&& (ret = ff_dca_core_parse_exss(&s->core, input, asset)) < 0)
return ret;
}
// Filter the frame
if (s->packet & DCA_PACKET_LBR) {
if ((ret = ff_dca_lbr_filter_frame(&s->lbr, frame)) < 0)
return ret;
} else if (s->packet & DCA_PACKET_XLL) {
if (s->packet & DCA_PACKET_CORE) {
int x96_synth = -1;
// Enable X96 synthesis if needed
if (s->xll.chset[0].freq == 96000 && s->core.sample_rate == 48000)
x96_synth = 1;
if ((ret = ff_dca_core_filter_fixed(&s->core, x96_synth)) < 0)
return ret;
// Force lossy downmixed output on the first core frame filtered.
// This prevents audible clicks when seeking and is consistent with
// what reference decoder does when there are multiple channel sets.
if (!(prev_packet & DCA_PACKET_RESIDUAL) && s->xll.nreschsets > 0
&& s->xll.nchsets > 1) {
av_log(avctx, AV_LOG_VERBOSE, "Forcing XLL recovery mode\n");
s->packet |= DCA_PACKET_RECOVERY;
}
// Set 'residual ok' flag for the next frame
s->packet |= DCA_PACKET_RESIDUAL;
}
if ((ret = ff_dca_xll_filter_frame(&s->xll, frame)) < 0) {
// Fall back to core unless hard error
if (!(s->packet & DCA_PACKET_CORE))
return ret;
if (ret != AVERROR_INVALIDDATA || (avctx->err_recognition & AV_EF_EXPLODE))
return ret;
if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0)
return ret;
}
} else if (s->packet & DCA_PACKET_CORE) {
if ((ret = ff_dca_core_filter_frame(&s->core, frame)) < 0)
return ret;
if (s->core.filter_mode & DCA_FILTER_MODE_FIXED)
s->packet |= DCA_PACKET_RESIDUAL;
} else {
av_log(avctx, AV_LOG_ERROR, "No valid DCA sub-stream found\n");
if (s->core_only)
av_log(avctx, AV_LOG_WARNING, "Consider disabling 'core_only' option\n");
return AVERROR_INVALIDDATA;
}
*got_frame_ptr = 1;
return avpkt->size;
}
| 23,332 |
FFmpeg | 69e456d7fbc5fff88acf747d135bf15c8e511c59 | 0 | static int iszero(const int16_t *c, int sz)
{
int n;
for (n = 0; n < sz; n += 4)
if (AV_RN32A(&c[n]))
return 0;
return 1;
}
| 23,333 |
FFmpeg | 121d3875b692c83866928e271c4b6d20d680d1a6 | 0 | void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits,
unsigned int pts_num, unsigned int pts_den)
{
AVRational new_tb;
if(av_reduce(&new_tb.num, &new_tb.den, pts_num, pts_den, INT_MAX)){
if(new_tb.num != pts_num)
av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", s->index, pts_num/new_tb.num);
}else
av_log(NULL, AV_LOG_WARNING, "st:%d has too large timebase, reducing\n", s->index);
if(new_tb.num <= 0 || new_tb.den <= 0) {
av_log(NULL, AV_LOG_ERROR, "Ignoring attempt to set invalid timebase for st:%d\n", s->index);
return;
}
s->time_base = new_tb;
s->pts_wrap_bits = pts_wrap_bits;
}
| 23,334 |
qemu | b308c82cbda44e138ef990af64d44a5613c16092 | 1 | static void pci_bridge_region_init(PCIBridge *br)
{
PCIBus *parent = br->dev.bus;
uint16_t cmd = pci_get_word(br->dev.config + PCI_COMMAND);
pci_bridge_init_alias(br, &br->alias_pref_mem,
PCI_BASE_ADDRESS_MEM_PREFETCH,
"pci_bridge_pref_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &br->alias_mem,
PCI_BASE_ADDRESS_SPACE_MEMORY,
"pci_bridge_mem",
&br->address_space_mem,
parent->address_space_mem,
cmd & PCI_COMMAND_MEMORY);
pci_bridge_init_alias(br, &br->alias_io,
PCI_BASE_ADDRESS_SPACE_IO,
"pci_bridge_io",
&br->address_space_io,
parent->address_space_io,
cmd & PCI_COMMAND_IO);
/* TODO: optinal VGA and VGA palette snooping support. */
}
| 23,335 |
qemu | 8f2ad0a3fc5e3569183d44bf1c7fcb95294be4c0 | 1 | static void ecc_reset(void *opaque)
{
ECCState *s = opaque;
int i;
s->regs[ECC_MER] &= (ECC_MER_VER | ECC_MER_IMPL);
s->regs[ECC_MER] |= ECC_MER_MRR;
s->regs[ECC_MDR] = 0x20;
s->regs[ECC_MFSR] = 0;
s->regs[ECC_VCR] = 0;
s->regs[ECC_MFAR0] = 0x07c00000;
s->regs[ECC_MFAR1] = 0;
s->regs[ECC_DR] = 0;
s->regs[ECC_ECR0] = 0;
s->regs[ECC_ECR1] = 0;
for (i = 1; i < ECC_NREGS; i++)
s->regs[i] = 0;
}
| 23,336 |
qemu | 20c334a797bf46a4ee59a6e42be6d5e7c3cda585 | 1 | static inline int16_t mipsdsp_add_i16(int16_t a, int16_t b, CPUMIPSState *env)
{
int16_t tempI;
tempI = a + b;
if (MIPSDSP_OVERFLOW(a, b, tempI, 0x8000)) {
set_DSPControl_overflow_flag(1, 20, env);
}
return tempI;
}
| 23,337 |
qemu | d7dce494769e47c9a1eec6f55578d3acdfab888b | 1 | void cpu_loop(CPUMBState *env)
{
int trapnr, ret;
target_siginfo_t info;
while (1) {
trapnr = cpu_mb_exec (env);
switch (trapnr) {
case 0xaa:
{
info.si_signo = SIGSEGV;
info.si_errno = 0;
/* XXX: check env->error_code */
info.si_code = TARGET_SEGV_MAPERR;
info._sifields._sigfault._addr = 0;
queue_signal(env, info.si_signo, &info);
}
break;
case EXCP_INTERRUPT:
/* just indicate that signals should be handled asap */
break;
case EXCP_BREAK:
/* Return address is 4 bytes after the call. */
env->regs[14] += 4;
ret = do_syscall(env,
env->regs[12],
env->regs[5],
env->regs[6],
env->regs[7],
env->regs[8],
env->regs[9],
env->regs[10],
0, 0);
env->regs[3] = ret;
env->sregs[SR_PC] = env->regs[14];
break;
case EXCP_HW_EXCP:
env->regs[17] = env->sregs[SR_PC] + 4;
if (env->iflags & D_FLAG) {
env->sregs[SR_ESR] |= 1 << 12;
env->sregs[SR_PC] -= 4;
/* FIXME: if branch was immed, replay the imm as well. */
}
env->iflags &= ~(IMM_FLAG | D_FLAG);
switch (env->sregs[SR_ESR] & 31) {
case ESR_EC_DIVZERO:
info.si_signo = SIGFPE;
info.si_errno = 0;
info.si_code = TARGET_FPE_FLTDIV;
info._sifields._sigfault._addr = 0;
queue_signal(env, info.si_signo, &info);
break;
case ESR_EC_FPU:
info.si_signo = SIGFPE;
info.si_errno = 0;
if (env->sregs[SR_FSR] & FSR_IO) {
info.si_code = TARGET_FPE_FLTINV;
}
if (env->sregs[SR_FSR] & FSR_DZ) {
info.si_code = TARGET_FPE_FLTDIV;
}
info._sifields._sigfault._addr = 0;
queue_signal(env, info.si_signo, &info);
break;
default:
printf ("Unhandled hw-exception: 0x%x\n",
env->sregs[SR_ESR] & ESR_EC_MASK);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
break;
}
break;
case EXCP_DEBUG:
{
int sig;
sig = gdb_handlesig (env, TARGET_SIGTRAP);
if (sig)
{
info.si_signo = sig;
info.si_errno = 0;
info.si_code = TARGET_TRAP_BRKPT;
queue_signal(env, info.si_signo, &info);
}
}
break;
default:
printf ("Unhandled trap: 0x%x\n", trapnr);
cpu_dump_state(env, stderr, fprintf, 0);
exit (1);
}
process_pending_signals (env);
}
}
| 23,338 |
FFmpeg | 80bfce35ccd11458e97f68f417fc094c5347070c | 1 | static void RENAME(interleaveBytes)(const uint8_t *src1, const uint8_t *src2, uint8_t *dest,
int width, int height, int src1Stride,
int src2Stride, int dstStride)
{
int h;
for (h=0; h < height; h++) {
int w;
if (width >= 16)
#if COMPILE_TEMPLATE_SSE2
__asm__(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movdqa (%1, %%"REG_a"), %%xmm0 \n\t"
"movdqa (%1, %%"REG_a"), %%xmm1 \n\t"
"movdqa (%2, %%"REG_a"), %%xmm2 \n\t"
"punpcklbw %%xmm2, %%xmm0 \n\t"
"punpckhbw %%xmm2, %%xmm1 \n\t"
"movntdq %%xmm0, (%0, %%"REG_a", 2) \n\t"
"movntdq %%xmm1, 16(%0, %%"REG_a", 2) \n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
: "memory", XMM_CLOBBERS("xmm0", "xmm1", "xmm2",) "%"REG_a
);
#else
__asm__(
"xor %%"REG_a", %%"REG_a" \n\t"
"1: \n\t"
PREFETCH" 64(%1, %%"REG_a") \n\t"
PREFETCH" 64(%2, %%"REG_a") \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 8(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq (%2, %%"REG_a"), %%mm4 \n\t"
"movq 8(%2, %%"REG_a"), %%mm5 \n\t"
"punpcklbw %%mm4, %%mm0 \n\t"
"punpckhbw %%mm4, %%mm1 \n\t"
"punpcklbw %%mm5, %%mm2 \n\t"
"punpckhbw %%mm5, %%mm3 \n\t"
MOVNTQ" %%mm0, (%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm1, 8(%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm2, 16(%0, %%"REG_a", 2) \n\t"
MOVNTQ" %%mm3, 24(%0, %%"REG_a", 2) \n\t"
"add $16, %%"REG_a" \n\t"
"cmp %3, %%"REG_a" \n\t"
" jb 1b \n\t"
::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
: "memory", "%"REG_a
);
#endif
for (w= (width&(~15)); w < width; w++) {
dest[2*w+0] = src1[w];
dest[2*w+1] = src2[w];
}
dest += dstStride;
src1 += src1Stride;
src2 += src2Stride;
}
__asm__(
#if !COMPILE_TEMPLATE_SSE2
EMMS" \n\t"
#endif
SFENCE" \n\t"
::: "memory"
);
}
| 23,340 |
FFmpeg | 7c10068da10aa288195f5eb5d7e34eb2d8ff7447 | 1 | static int dvbsub_parse_page_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size, AVSubtitle *sub, int *got_output)
{
DVBSubContext *ctx = avctx->priv_data;
DVBSubRegionDisplay *display;
DVBSubRegionDisplay *tmp_display_list, **tmp_ptr;
const uint8_t *buf_end = buf + buf_size;
int region_id;
int page_state;
int timeout;
int version;
if (buf_size < 1)
return AVERROR_INVALIDDATA;
timeout = *buf++;
version = ((*buf)>>4) & 15;
page_state = ((*buf++) >> 2) & 3;
if (ctx->version == version) {
return 0;
ctx->time_out = timeout;
ctx->version = version;
ff_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
if(ctx->compute_edt == 1)
save_subtitle_set(avctx, sub, got_output);
if (page_state == 1 || page_state == 2) {
delete_regions(ctx);
delete_objects(ctx);
delete_cluts(ctx);
tmp_display_list = ctx->display_list;
ctx->display_list = NULL;
while (buf + 5 < buf_end) {
region_id = *buf++;
buf += 1;
display = tmp_display_list;
tmp_ptr = &tmp_display_list;
tmp_ptr = &display->next;
if (!display) {
display = av_mallocz(sizeof(DVBSubRegionDisplay));
if (!display)
return AVERROR(ENOMEM);
display->region_id = region_id;
display->x_pos = AV_RB16(buf);
buf += 2;
display->y_pos = AV_RB16(buf);
buf += 2;
*tmp_ptr = display->next;
display->next = ctx->display_list;
ctx->display_list = display;
ff_dlog(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos);
while (tmp_display_list) {
display = tmp_display_list;
tmp_display_list = display->next;
av_freep(&display);
return 0; | 23,341 |
FFmpeg | f80224ed19a4c012549fd460d529c7c04e68cf21 | 1 | static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s,
void *last, void *dst, int last2, int w,
int stride, int comp, int bits)
{
int i, x = 0;
int Ra, Rb, Rc, Rd;
int D0, D1, D2;
while (x < w) {
int err, pred;
/* compute gradients */
Ra = x ? R(dst, x - stride) : R(last, x);
Rb = R(last, x);
Rc = x ? R(last, x - stride) : last2;
Rd = (x >= w - stride) ? R(last, x) : R(last, x + stride);
D0 = Rd - Rb;
D1 = Rb - Rc;
D2 = Rc - Ra;
/* run mode */
if ((FFABS(D0) <= state->near) &&
(FFABS(D1) <= state->near) &&
(FFABS(D2) <= state->near)) {
int r;
int RItype;
/* decode full runs while available */
while (get_bits1(&s->gb)) {
int r;
r = 1 << ff_log2_run[state->run_index[comp]];
if (x + r * stride > w)
r = (w - x) / stride;
for (i = 0; i < r; i++) {
W(dst, x, Ra);
x += stride;
}
/* if EOL reached, we stop decoding */
if (r != 1 << ff_log2_run[state->run_index[comp]])
if (state->run_index[comp] < 31)
state->run_index[comp]++;
if (x + stride > w)
}
/* decode aborted run */
r = ff_log2_run[state->run_index[comp]];
if (r)
r = get_bits_long(&s->gb, r);
if (x + r * stride > w) {
r = (w - x) / stride;
}
for (i = 0; i < r; i++) {
W(dst, x, Ra);
x += stride;
}
if (x >= w) {
av_log(NULL, AV_LOG_ERROR, "run overflow\n");
av_assert0(x <= w);
}
/* decode run termination value */
Rb = R(last, x);
RItype = (FFABS(Ra - Rb) <= state->near) ? 1 : 0;
err = ls_get_code_runterm(&s->gb, state, RItype,
ff_log2_run[state->run_index[comp]]);
if (state->run_index[comp])
state->run_index[comp]--;
if (state->near && RItype) {
pred = Ra + err;
} else {
if (Rb < Ra)
pred = Rb - err;
else
pred = Rb + err;
}
} else { /* regular mode */
int context, sign;
context = ff_jpegls_quantize(state, D0) * 81 +
ff_jpegls_quantize(state, D1) * 9 +
ff_jpegls_quantize(state, D2);
pred = mid_pred(Ra, Ra + Rb - Rc, Rb);
if (context < 0) {
context = -context;
sign = 1;
} else {
sign = 0;
}
if (sign) {
pred = av_clip(pred - state->C[context], 0, state->maxval);
err = -ls_get_code_regular(&s->gb, state, context);
} else {
pred = av_clip(pred + state->C[context], 0, state->maxval);
err = ls_get_code_regular(&s->gb, state, context);
}
/* we have to do something more for near-lossless coding */
pred += err;
}
if (state->near) {
if (pred < -state->near)
pred += state->range * state->twonear;
else if (pred > state->maxval + state->near)
pred -= state->range * state->twonear;
pred = av_clip(pred, 0, state->maxval);
}
pred &= state->maxval;
W(dst, x, pred);
x += stride;
}
} | 23,342 |
FFmpeg | 5484170ac729d739b2747979408f47bd9aa31c7c | 1 | static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
int got_picture = 0;
ff_er_frame_end(s);
ff_MPV_frame_end(s);
if (HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME))
ff_thread_report_progress(&s->current_picture_ptr->f, INT_MAX, 0);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
*pict = s->current_picture_ptr->f;
got_picture = 1;
} else if (s->last_picture_ptr != NULL) {
*pict = s->last_picture_ptr->f;
got_picture = 1;
}
if (got_picture)
ff_print_debug_info(s, pict);
return got_picture;
} | 23,343 |
FFmpeg | 6029b8a6bbc8bbf7799108582e71078ec0bde1cf | 0 | static int s337m_probe(AVProbeData *p)
{
uint64_t state = 0;
int markers[3] = { 0 };
int i, sum, max, data_type, data_size, offset;
uint8_t *buf;
for (buf = p->buf; buf < p->buf + p->buf_size; buf++) {
state = (state << 8) | *buf;
if (!IS_LE_MARKER(state))
continue;
if (IS_16LE_MARKER(state)) {
data_type = AV_RL16(buf + 1);
data_size = AV_RL16(buf + 3);
buf += 4;
} else {
data_type = AV_RL24(buf + 1);
data_size = AV_RL24(buf + 4);
buf += 6;
}
if (s337m_get_offset_and_codec(NULL, state, data_type, data_size, &offset, NULL))
continue;
i = IS_16LE_MARKER(state) ? 0 : IS_20LE_MARKER(state) ? 1 : 2;
markers[i]++;
buf += offset;
state = 0;
}
sum = max = 0;
for (i = 0; i < FF_ARRAY_ELEMS(markers); i++) {
sum += markers[i];
if (markers[max] < markers[i])
max = i;
}
if (markers[max] > 3 && markers[max] * 4 > sum * 3)
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
}
| 23,345 |
FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | 0 | static inline void RENAME(yuv2nv12X)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize,
const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, enum PixelFormat dstFormat)
{
yuv2nv12XinC(lumFilter, lumSrc, lumFilterSize,
chrFilter, chrSrc, chrFilterSize,
dest, uDest, dstW, chrDstW, dstFormat);
}
| 23,346 |
qemu | 4f4321c11ff6e98583846bfd6f0e81954924b003 | 1 | static int usb_bt_handle_control(USBDevice *dev, USBPacket *p,
int request, int value, int index, int length, uint8_t *data)
{
struct USBBtState *s = (struct USBBtState *) dev->opaque;
int ret;
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
if (ret >= 0) {
switch (request) {
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
s->config = 0;
break;
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
s->config = 1;
usb_bt_fifo_reset(&s->evt);
usb_bt_fifo_reset(&s->acl);
usb_bt_fifo_reset(&s->sco);
break;
}
return ret;
}
ret = 0;
switch (request) {
case InterfaceRequest | USB_REQ_GET_STATUS:
case EndpointRequest | USB_REQ_GET_STATUS:
data[0] = 0x00;
data[1] = 0x00;
ret = 2;
break;
case InterfaceOutRequest | USB_REQ_CLEAR_FEATURE:
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
goto fail;
case InterfaceOutRequest | USB_REQ_SET_FEATURE:
case EndpointOutRequest | USB_REQ_SET_FEATURE:
goto fail;
break;
case InterfaceRequest | USB_REQ_GET_INTERFACE:
if (value != 0 || (index & ~1) || length != 1)
goto fail;
if (index == 1)
data[0] = s->altsetting;
else
data[0] = 0;
ret = 1;
break;
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
if ((index & ~1) || length != 0 ||
(index == 1 && (value < 0 || value > 4)) ||
(index == 0 && value != 0)) {
printf("%s: Wrong SET_INTERFACE request (%i, %i)\n",
__FUNCTION__, index, value);
goto fail;
}
s->altsetting = value;
ret = 0;
break;
case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_DEVICE) << 8):
if (s->config)
usb_bt_fifo_out_enqueue(s, &s->outcmd, s->hci->cmd_send,
usb_bt_hci_cmd_complete, data, length);
break;
default:
fail:
ret = USB_RET_STALL;
break;
}
return ret;
}
| 23,347 |
FFmpeg | 0d65e0f8cb0f924be95650f50f3d05d0b223aceb | 1 | int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
AVFilterBufferRef **picref_ptr, AVRational *tb)
{
int ret;
AVFilterBufferRef *picref;
if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0)
return ret;
if (!(picref = ctx->inputs[0]->cur_buf))
return AVERROR(ENOENT);
*picref_ptr = picref;
ctx->inputs[0]->cur_buf = NULL;
*tb = ctx->inputs[0]->time_base;
memcpy(frame->data, picref->data, sizeof(frame->data));
memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
frame->pkt_pos = picref->pos;
frame->interlaced_frame = picref->video->interlaced;
frame->top_field_first = picref->video->top_field_first;
frame->key_frame = picref->video->key_frame;
frame->pict_type = picref->video->pict_type;
frame->sample_aspect_ratio = picref->video->sample_aspect_ratio;
return 1;
} | 23,348 |
qemu | 3c99afc779c2c78718a565ad8c5e98de7c2c7484 | 1 | static int vmxnet3_post_load(void *opaque, int version_id)
{
VMXNET3State *s = opaque;
PCIDevice *d = PCI_DEVICE(s);
vmxnet_tx_pkt_init(&s->tx_pkt, s->max_tx_frags, s->peer_has_vhdr);
vmxnet_rx_pkt_init(&s->rx_pkt, s->peer_has_vhdr);
if (s->msix_used) {
if (!vmxnet3_use_msix_vectors(s, VMXNET3_MAX_INTRS)) {
VMW_WRPRN("Failed to re-use MSI-X vectors");
msix_uninit(d, &s->msix_bar, &s->msix_bar);
s->msix_used = false;
return -1;
}
}
return 0;
} | 23,349 |
FFmpeg | 3d9cb583c8f005a260d255853ef5f1c21e8599a0 | 1 | static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64],
int qsel, int is_chroma, int is_hqa)
{
const int32_t *q;
int val, pos = 1;
memset(block, 0, 64 * sizeof(*block));
if (!is_hqa) {
block[0] = get_sbits(gb, 9) * 64;
q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
} else {
q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)];
block[0] = get_sbits(gb, 9) * 64;
}
for (;;) {
val = get_vlc2(gb, c->hq_ac_vlc.table, 9, 2);
if (val < 0)
return AVERROR_INVALIDDATA;
pos += ff_hq_ac_skips[val];
if (pos >= 64)
break;
block[ff_zigzag_direct[pos]] = (ff_hq_ac_syms[val] * q[pos]) >> 12;
pos++;
}
return 0;
}
| 23,350 |
FFmpeg | af19f78f2fe2b969104d4419efd25fdee90a2814 | 0 | void dsputil_init_alpha(void)
{
put_pixels_tab[0][0] = put_pixels16_axp_asm;
put_pixels_tab[0][1] = put_pixels16_x2_axp;
put_pixels_tab[0][2] = put_pixels16_y2_axp;
put_pixels_tab[0][3] = put_pixels16_xy2_axp;
put_no_rnd_pixels_tab[0][0] = put_pixels16_axp_asm;
put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_axp;
put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_axp;
put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_axp;
avg_pixels_tab[0][0] = avg_pixels16_axp;
avg_pixels_tab[0][1] = avg_pixels16_x2_axp;
avg_pixels_tab[0][2] = avg_pixels16_y2_axp;
avg_pixels_tab[0][3] = avg_pixels16_xy2_axp;
avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_axp;
avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_axp;
avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_axp;
avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_axp;
put_pixels_tab[1][0] = put_pixels_axp_asm;
put_pixels_tab[1][1] = put_pixels_x2_axp;
put_pixels_tab[1][2] = put_pixels_y2_axp;
put_pixels_tab[1][3] = put_pixels_xy2_axp;
put_no_rnd_pixels_tab[1][0] = put_pixels_axp_asm;
put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels_x2_axp;
put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels_y2_axp;
put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels_xy2_axp;
avg_pixels_tab[1][0] = avg_pixels_axp;
avg_pixels_tab[1][1] = avg_pixels_x2_axp;
avg_pixels_tab[1][2] = avg_pixels_y2_axp;
avg_pixels_tab[1][3] = avg_pixels_xy2_axp;
avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels_axp;
avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels_x2_axp;
avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels_y2_axp;
avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels_xy2_axp;
clear_blocks = clear_blocks_axp;
/* amask clears all bits that correspond to present features. */
if (amask(AMASK_MVI) == 0) {
put_pixels_clamped = put_pixels_clamped_mvi_asm;
add_pixels_clamped = add_pixels_clamped_mvi_asm;
get_pixels = get_pixels_mvi;
diff_pixels = diff_pixels_mvi;
pix_abs8x8 = pix_abs8x8_mvi;
pix_abs16x16 = pix_abs16x16_mvi_asm;
pix_abs16x16_x2 = pix_abs16x16_x2_mvi;
pix_abs16x16_y2 = pix_abs16x16_y2_mvi;
pix_abs16x16_xy2 = pix_abs16x16_xy2_mvi;
}
}
| 23,351 |
qemu | f35e44e7645edbb08e35b111c10c2fc57e2905c7 | 1 | address_space_translate_for_iotlb(CPUState *cpu, int asidx, hwaddr addr,
hwaddr *xlat, hwaddr *plen)
{
MemoryRegionSection *section;
AddressSpaceDispatch *d = cpu->cpu_ases[asidx].memory_dispatch;
section = address_space_translate_internal(d, addr, xlat, plen, false);
assert(!section->mr->iommu_ops);
return section;
}
| 23,352 |
qemu | 187337f8b0ec0813dd3876d1efe37d415fb81c2e | 1 | static struct pxa2xx_fir_s *pxa2xx_fir_init(target_phys_addr_t base,
qemu_irq irq, struct pxa2xx_dma_state_s *dma,
CharDriverState *chr)
{
int iomemtype;
struct pxa2xx_fir_s *s = (struct pxa2xx_fir_s *)
qemu_mallocz(sizeof(struct pxa2xx_fir_s));
s->base = base;
s->irq = irq;
s->dma = dma;
s->chr = chr;
pxa2xx_fir_reset(s);
iomemtype = cpu_register_io_memory(0, pxa2xx_fir_readfn,
pxa2xx_fir_writefn, s);
cpu_register_physical_memory(s->base, 0xfff, iomemtype);
if (chr)
qemu_chr_add_handlers(chr, pxa2xx_fir_is_empty,
pxa2xx_fir_rx, pxa2xx_fir_event, s);
register_savevm("pxa2xx_fir", 0, 0, pxa2xx_fir_save, pxa2xx_fir_load, s);
return s;
}
| 23,353 |
qemu | 7fe7b68b32ba609faeeee03556aac0eb1b187c91 | 1 | static ssize_t nbd_co_receive_request(NBDRequest *req, struct nbd_request *request)
{
NBDClient *client = req->client;
int csock = client->sock;
ssize_t rc;
client->recv_coroutine = qemu_coroutine_self();
if (nbd_receive_request(csock, request) < 0) {
rc = -EIO;
goto out;
}
if (request->len > NBD_BUFFER_SIZE) {
LOG("len (%u) is larger than max len (%u)",
request->len, NBD_BUFFER_SIZE);
rc = -EINVAL;
goto out;
}
if ((request->from + request->len) < request->from) {
LOG("integer overflow detected! "
"you're probably being attacked");
rc = -EINVAL;
goto out;
}
TRACE("Decoding type");
if ((request->type & NBD_CMD_MASK_COMMAND) == NBD_CMD_WRITE) {
TRACE("Reading %u byte(s)", request->len);
if (qemu_co_recv(csock, req->data, request->len) != request->len) {
LOG("reading from socket failed");
rc = -EIO;
goto out;
}
}
rc = 0;
out:
client->recv_coroutine = NULL;
return rc;
}
| 23,355 |
qemu | 06b106889a09277617fc8c542397a9f595ee605a | 1 | ram_addr_t migration_bitmap_find_dirty(RAMState *rs, RAMBlock *rb,
ram_addr_t start,
ram_addr_t *ram_addr_abs)
{
unsigned long base = rb->offset >> TARGET_PAGE_BITS;
unsigned long nr = base + (start >> TARGET_PAGE_BITS);
uint64_t rb_size = rb->used_length;
unsigned long size = base + (rb_size >> TARGET_PAGE_BITS);
unsigned long *bitmap;
unsigned long next;
bitmap = atomic_rcu_read(&rs->ram_bitmap)->bmap;
if (rs->ram_bulk_stage && nr > base) {
next = nr + 1;
} else {
next = find_next_bit(bitmap, size, nr);
}
*ram_addr_abs = next << TARGET_PAGE_BITS;
return (next - base) << TARGET_PAGE_BITS;
}
| 23,356 |
FFmpeg | fc3a03fcf9cd7eafe7342e2508e6128888efa0bb | 1 | AVFrame *ff_framequeue_take(FFFrameQueue *fq)
{
FFFrameBucket *b;
check_consistency(fq);
av_assert1(fq->queued);
b = bucket(fq, 0);
fq->queued--;
fq->tail++;
fq->tail &= fq->allocated - 1;
fq->total_frames_tail++;
fq->total_samples_tail += b->frame->nb_samples;
check_consistency(fq);
return b->frame;
} | 23,357 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.