label
int64
0
1
func1
stringlengths
23
97k
id
int64
0
27.3k
0
static void implicit_weight_table(H264Context *h){ MpegEncContext * const s = &h->s; int ref0, ref1, i; int cur_poc = s->current_picture_ptr->poc; if( h->ref_count[0] == 1 && h->ref_count[1] == 1 && h->ref_list[0][0].poc + h->ref_list[1][0].poc == 2*cur_poc){ h->use_weight= 0; h->use_weight_chroma= 0; return; } h->use_weight= 2; h->use_weight_chroma= 2; h->luma_log2_weight_denom= 5; h->chroma_log2_weight_denom= 5; for (i = 0; i < 2; i++) { h->luma_weight_flag[i] = 0; h->chroma_weight_flag[i] = 0; } for(ref0=0; ref0 < h->ref_count[0]; ref0++){ int poc0 = h->ref_list[0][ref0].poc; for(ref1=0; ref1 < h->ref_count[1]; ref1++){ int poc1 = h->ref_list[1][ref1].poc; int td = av_clip(poc1 - poc0, -128, 127); if(td){ int tb = av_clip(cur_poc - poc0, -128, 127); int tx = (16384 + (FFABS(td) >> 1)) / td; int dist_scale_factor = av_clip((tb*tx + 32) >> 6, -1024, 1023) >> 2; if(dist_scale_factor < -64 || dist_scale_factor > 128) h->implicit_weight[ref0][ref1] = 32; else h->implicit_weight[ref0][ref1] = 64 - dist_scale_factor; }else h->implicit_weight[ref0][ref1] = 32; } } }
17,852
0
static av_cold int ra144_encode_init(AVCodecContext * avctx) { RA144Context *ractx; int ret; if (avctx->channels != 1) { av_log(avctx, AV_LOG_ERROR, "invalid number of channels: %d\n", avctx->channels); return -1; } avctx->frame_size = NBLOCKS * BLOCKSIZE; avctx->delay = avctx->frame_size; avctx->bit_rate = 8000; ractx = avctx->priv_data; ractx->lpc_coef[0] = ractx->lpc_tables[0]; ractx->lpc_coef[1] = ractx->lpc_tables[1]; ractx->avctx = avctx; ret = ff_lpc_init(&ractx->lpc_ctx, avctx->frame_size, LPC_ORDER, FF_LPC_TYPE_LEVINSON); if (ret < 0) goto error; ff_af_queue_init(avctx, &ractx->afq); return 0; error: ra144_encode_close(avctx); return ret; }
17,853
1
static int mxf_read_generic_descriptor(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset) { MXFDescriptor *descriptor = arg; descriptor->pix_fmt = AV_PIX_FMT_NONE; switch(tag) { case 0x3F01: descriptor->sub_descriptors_count = avio_rb32(pb); if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID)) return AVERROR_INVALIDDATA; descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID)); if (!descriptor->sub_descriptors_refs) return AVERROR(ENOMEM); avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */ avio_read(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID)); break; case 0x3004: avio_read(pb, descriptor->essence_container_ul, 16); break; case 0x3006: descriptor->linked_track_id = avio_rb32(pb); break; case 0x3201: /* PictureEssenceCoding */ avio_read(pb, descriptor->essence_codec_ul, 16); break; case 0x3203: descriptor->width = avio_rb32(pb); break; case 0x3202: descriptor->height = avio_rb32(pb); break; case 0x320C: descriptor->frame_layout = avio_r8(pb); break; case 0x320E: descriptor->aspect_ratio.num = avio_rb32(pb); descriptor->aspect_ratio.den = avio_rb32(pb); break; case 0x3301: descriptor->component_depth = avio_rb32(pb); break; case 0x3302: descriptor->horiz_subsampling = avio_rb32(pb); break; case 0x3308: descriptor->vert_subsampling = avio_rb32(pb); break; case 0x3D03: descriptor->sample_rate.num = avio_rb32(pb); descriptor->sample_rate.den = avio_rb32(pb); break; case 0x3D06: /* SoundEssenceCompression */ avio_read(pb, descriptor->essence_codec_ul, 16); break; case 0x3D07: descriptor->channels = avio_rb32(pb); break; case 0x3D01: descriptor->bits_per_sample = avio_rb32(pb); break; case 0x3401: mxf_read_pixel_layout(pb, descriptor); break; default: /* Private uid used by SONY C0023S01.mxf */ if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) { descriptor->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!descriptor->extradata) return AVERROR(ENOMEM); descriptor->extradata_size = size; avio_read(pb, descriptor->extradata, size); } break; } return 0; }
17,854
1
int pt_removexattr(FsContext *ctx, const char *path, const char *name) { char *buffer; int ret; buffer = rpath(ctx, path); ret = lremovexattr(path, name); g_free(buffer); return ret; }
17,855
1
int64_t ff_ape_parse_tag(AVFormatContext *s) { AVIOContext *pb = s->pb; int file_size = avio_size(pb); uint32_t val, fields, tag_bytes; uint8_t buf[8]; int64_t tag_start; int i; if (file_size < APE_TAG_FOOTER_BYTES) return 0; avio_seek(pb, file_size - APE_TAG_FOOTER_BYTES, SEEK_SET); avio_read(pb, buf, 8); /* APETAGEX */ if (strncmp(buf, "APETAGEX", 8)) { return 0; } val = avio_rl32(pb); /* APE tag version */ if (val > APE_TAG_VERSION) { av_log(s, AV_LOG_ERROR, "Unsupported tag version. (>=%d)\n", APE_TAG_VERSION); return 0; } tag_bytes = avio_rl32(pb); /* tag size */ if (tag_bytes - APE_TAG_FOOTER_BYTES > (1024 * 1024 * 16)) { av_log(s, AV_LOG_ERROR, "Tag size is way too big\n"); return 0; } tag_start = file_size - tag_bytes - APE_TAG_FOOTER_BYTES; if (tag_start < 0) { av_log(s, AV_LOG_ERROR, "Invalid tag size %u.\n", tag_bytes); return 0; } fields = avio_rl32(pb); /* number of fields */ if (fields > 65536) { av_log(s, AV_LOG_ERROR, "Too many tag fields (%d)\n", fields); return 0; } val = avio_rl32(pb); /* flags */ if (val & APE_TAG_FLAG_IS_HEADER) { av_log(s, AV_LOG_ERROR, "APE Tag is a header\n"); return 0; } avio_seek(pb, file_size - tag_bytes, SEEK_SET); for (i=0; i<fields; i++) if (ape_tag_read_field(s) < 0) break; return tag_start; }
17,856
1
static void* attribute_align_arg worker(void *v) { ThreadContext *c = v; int our_job = c->nb_jobs; int nb_threads = c->nb_threads; unsigned int last_execute = 0; int self_id; pthread_mutex_lock(&c->current_job_lock); self_id = c->current_job++; for (;;) { while (our_job >= c->nb_jobs) { if (c->current_job == nb_threads + c->nb_jobs) pthread_cond_signal(&c->last_job_cond); while (last_execute == c->current_execute && !c->done) pthread_cond_wait(&c->current_job_cond, &c->current_job_lock); last_execute = c->current_execute; our_job = self_id; if (c->done) { pthread_mutex_unlock(&c->current_job_lock); return NULL; } } pthread_mutex_unlock(&c->current_job_lock); c->rets[our_job % c->nb_rets] = c->func(c->ctx, c->arg, our_job, c->nb_jobs); pthread_mutex_lock(&c->current_job_lock); our_job = c->current_job++; } }
17,857
1
static void pc87312_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); dc->realize = pc87312_realize; dc->reset = pc87312_reset; dc->vmsd = &vmstate_pc87312; dc->props = pc87312_properties; }
17,859
1
static int mkv_field_order(MatroskaDemuxContext *matroska, int64_t field_order) { int major, minor, micro, bttb = 0; /* workaround a bug in our Matroska muxer, introduced in version 57.36 alongside * this function, and fixed in 57.52 */ if (sscanf(matroska->muxingapp, "Lavf%d.%d.%d", &major, &minor, &micro) == 3) bttb = (major == 57 && minor >= 36 && minor <= 51 && micro >= 100); switch (field_order) { case MATROSKA_VIDEO_FIELDORDER_PROGRESSIVE: return AV_FIELD_PROGRESSIVE; case MATROSKA_VIDEO_FIELDORDER_UNDETERMINED: return AV_FIELD_UNKNOWN; case MATROSKA_VIDEO_FIELDORDER_TT: return AV_FIELD_TT; case MATROSKA_VIDEO_FIELDORDER_BB: return AV_FIELD_BB; case MATROSKA_VIDEO_FIELDORDER_BT: return bttb ? AV_FIELD_TB : AV_FIELD_BT; case MATROSKA_VIDEO_FIELDORDER_TB: return bttb ? AV_FIELD_BT : AV_FIELD_TB; default: return AV_FIELD_UNKNOWN; } }
17,860
1
av_cold void ff_fft_init_arm(FFTContext *s) { int cpu_flags = av_get_cpu_flags(); if (have_vfp(cpu_flags) && !have_vfpv3(cpu_flags)) { s->fft_calc = ff_fft_calc_vfp; #if CONFIG_MDCT s->imdct_half = ff_imdct_half_vfp; #endif } if (have_neon(cpu_flags)) { s->fft_permute = ff_fft_permute_neon; s->fft_calc = ff_fft_calc_neon; #if CONFIG_MDCT s->imdct_calc = ff_imdct_calc_neon; s->imdct_half = ff_imdct_half_neon; s->mdct_calc = ff_mdct_calc_neon; s->mdct_permutation = FF_MDCT_PERM_INTERLEAVE; #endif } }
17,861
1
unsigned long find_next_bit(const unsigned long *addr, unsigned long size, unsigned long offset) { const unsigned long *p = addr + BITOP_WORD(offset); unsigned long result = offset & ~(BITS_PER_LONG-1); unsigned long tmp; if (offset >= size) { return size; } size -= result; offset %= BITS_PER_LONG; if (offset) { tmp = *(p++); tmp &= (~0UL << offset); if (size < BITS_PER_LONG) { goto found_first; } if (tmp) { goto found_middle; } size -= BITS_PER_LONG; result += BITS_PER_LONG; } while (size & ~(BITS_PER_LONG-1)) { if ((tmp = *(p++))) { goto found_middle; } result += BITS_PER_LONG; size -= BITS_PER_LONG; } if (!size) { return result; } tmp = *p; found_first: tmp &= (~0UL >> (BITS_PER_LONG - size)); if (tmp == 0UL) { /* Are any bits set? */ return result + size; /* Nope. */ } found_middle: return result + bitops_ffsl(tmp); }
17,862
1
void migration_set_outgoing_channel(MigrationState *s, QIOChannel *ioc) { QEMUFile *f = qemu_fopen_channel_output(ioc); s->to_dst_file = f; migrate_fd_connect(s); }
17,863
1
static void qemu_wait_io_event_common(CPUState *cpu) { if (cpu->stop) { cpu->stop = false; cpu->stopped = true; qemu_cond_broadcast(&qemu_pause_cond); } process_queued_cpu_work(cpu); cpu->thread_kicked = false; }
17,864
1
static void ahci_test_identify(AHCIQState *ahci) { uint16_t buff[256]; unsigned px; int rc; uint16_t sect_size; const size_t buffsize = 512; g_assert(ahci != NULL); /** * This serves as a bit of a tutorial on AHCI device programming: * * (1) Create a data buffer for the IDENTIFY response to be sent to * (2) Create a Command Table buffer, where we will store the * command and PRDT (Physical Region Descriptor Table) * (3) Construct an FIS host-to-device command structure, and write it to * the top of the Command Table buffer. * (4) Create one or more Physical Region Descriptors (PRDs) that describe * a location in memory where data may be stored/retrieved. * (5) Write these PRDTs to the bottom (offset 0x80) of the Command Table. * (6) Each AHCI port has up to 32 command slots. Each slot contains a * header that points to a Command Table buffer. Pick an unused slot * and update it to point to the Command Table we have built. * (7) Now: Command #n points to our Command Table, and our Command Table * contains the FIS (that describes our command) and the PRDTL, which * describes our buffer. * (8) We inform the HBA via PxCI (Command Issue) that the command in slot * #n is ready for processing. */ /* Pick the first implemented and running port */ px = ahci_port_select(ahci); g_test_message("Selected port %u for test", px); /* Clear out the FIS Receive area and any pending interrupts. */ ahci_port_clear(ahci, px); /* "Read" 512 bytes using CMD_IDENTIFY into the host buffer. */ ahci_io(ahci, px, CMD_IDENTIFY, &buff, buffsize); /* Check serial number/version in the buffer */ /* NB: IDENTIFY strings are packed in 16bit little endian chunks. * Since we copy byte-for-byte in ahci-test, on both LE and BE, we need to * unchunk this data. By contrast, ide-test copies 2 bytes at a time, and * as a consequence, only needs to unchunk the data on LE machines. */ string_bswap16(&buff[10], 20); rc = memcmp(&buff[10], "testdisk ", 20); g_assert_cmphex(rc, ==, 0); string_bswap16(&buff[23], 8); rc = memcmp(&buff[23], "version ", 8); g_assert_cmphex(rc, ==, 0); }
17,865
1
static void rc4030_realize(DeviceState *dev, Error **errp) { rc4030State *s = RC4030(dev); Object *o = OBJECT(dev); int i; s->periodic_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, rc4030_periodic_timer, s); memory_region_init_io(&s->iomem_chipset, NULL, &rc4030_ops, s, "rc4030.chipset", 0x300); memory_region_init_io(&s->iomem_jazzio, NULL, &jazzio_ops, s, "rc4030.jazzio", 0x00001000); memory_region_init_rom_device(&s->dma_tt, o, &rc4030_dma_tt_ops, s, "dma-table", MAX_TL_ENTRIES * sizeof(dma_pagetable_entry), NULL); memory_region_init(&s->dma_tt_alias, o, "dma-table-alias", 0); memory_region_init(&s->dma_mr, o, "dma", INT32_MAX); for (i = 0; i < MAX_TL_ENTRIES; ++i) { memory_region_init_alias(&s->dma_mrs[i], o, "dma-alias", get_system_memory(), 0, DMA_PAGESIZE); memory_region_set_enabled(&s->dma_mrs[i], false); memory_region_add_subregion(&s->dma_mr, i * DMA_PAGESIZE, &s->dma_mrs[i]); } address_space_init(&s->dma_as, &s->dma_mr, "rc4030-dma"); }
17,867
1
static int fourxm_probe(AVProbeData *p) { if ((AV_RL32(&p->buf[0]) != RIFF_TAG) || (AV_RL32(&p->buf[8]) != _4XMV_TAG)) return 0; return AVPROBE_SCORE_MAX; }
17,868
1
void monitor_disas(Monitor *mon, CPUState *cpu, target_ulong pc, int nb_insn, int is_physical) { CPUClass *cc = CPU_GET_CLASS(cpu); int count, i; CPUDebug s; INIT_DISASSEMBLE_INFO(s.info, (FILE *)mon, monitor_fprintf); s.cpu = cpu; monitor_disas_is_physical = is_physical; s.info.read_memory_func = monitor_read_memory; s.info.print_address_func = generic_print_address; s.info.buffer_vma = pc; s.info.cap_arch = -1; s.info.cap_mode = 0; #ifdef TARGET_WORDS_BIGENDIAN s.info.endian = BFD_ENDIAN_BIG; #else s.info.endian = BFD_ENDIAN_LITTLE; #endif if (cc->disas_set_info) { cc->disas_set_info(cpu, &s.info); } if (s.info.cap_arch >= 0 && cap_disas_monitor(&s.info, pc, nb_insn)) { return; } if (!s.info.print_insn) { monitor_printf(mon, "0x" TARGET_FMT_lx ": Asm output not supported on this arch\n", pc); return; } for(i = 0; i < nb_insn; i++) { monitor_printf(mon, "0x" TARGET_FMT_lx ": ", pc); count = s.info.print_insn(pc, &s.info); monitor_printf(mon, "\n"); if (count < 0) break; pc += count; } }
17,869
1
static struct omap_pwl_s *omap_pwl_init(MemoryRegion *system_memory, hwaddr base, omap_clk clk) { struct omap_pwl_s *s = g_malloc0(sizeof(*s)); omap_pwl_reset(s); memory_region_init_io(&s->iomem, NULL, &omap_pwl_ops, s, "omap-pwl", 0x800); memory_region_add_subregion(system_memory, base, &s->iomem); omap_clk_adduser(clk, qemu_allocate_irqs(omap_pwl_clk_update, s, 1)[0]); return s; }
17,870
0
static int amr_nb_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t * buf, int buf_size) { AMRContext *s = avctx->priv_data; uint8_t*amrData=buf; int offset=0; UWord8 toc, q, ft; Word16 serial[SERIAL_FRAMESIZE]; /* coded bits */ Word16 *synth; UWord8 *packed_bits; static Word16 packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0}; int i; //printf("amr_decode_frame data_size=%i buf=0x%X buf_size=%d frameCount=%d!!\n",*data_size,buf,buf_size,s->frameCount); synth=data; // while(offset<buf_size) { toc=amrData[offset]; /* read rest of the frame based on ToC byte */ q = (toc >> 2) & 0x01; ft = (toc >> 3) & 0x0F; //printf("offset=%d, packet_size=%d amrData= 0x%X %X %X %X\n",offset,packed_size[ft],amrData[offset],amrData[offset+1],amrData[offset+2],amrData[offset+3]); offset++; packed_bits=amrData+offset; offset+=packed_size[ft]; //Unsort and unpack bits s->rx_type = UnpackBits(q, ft, packed_bits, &s->mode, &serial[1]); //We have a new frame s->frameCount++; if (s->rx_type == RX_NO_DATA) { s->mode = s->speech_decoder_state->prev_mode; } else { s->speech_decoder_state->prev_mode = s->mode; } /* if homed: check if this frame is another homing frame */ if (s->reset_flag_old == 1) { /* only check until end of first subframe */ s->reset_flag = decoder_homing_frame_test_first(&serial[1], s->mode); } /* produce encoder homing frame if homed & input=decoder homing frame */ if ((s->reset_flag != 0) && (s->reset_flag_old != 0)) { for (i = 0; i < L_FRAME; i++) { synth[i] = EHF_MASK; } } else { /* decode frame */ Speech_Decode_Frame(s->speech_decoder_state, s->mode, &serial[1], s->rx_type, synth); } //Each AMR-frame results in 160 16-bit samples *data_size+=160*2; synth+=160; /* if not homed: check whether current frame is a homing frame */ if (s->reset_flag_old == 0) { /* check whole frame */ s->reset_flag = decoder_homing_frame_test(&serial[1], s->mode); } /* reset decoder if current frame is a homing frame */ if (s->reset_flag != 0) { Speech_Decode_Frame_reset(s->speech_decoder_state); } s->reset_flag_old = s->reset_flag; } return offset; }
17,872
0
static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { int64_t pos = avio_tell(pb); int ret; avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "stbl"); mov_write_stsd_tag(s, pb, mov, track); mov_write_stts_tag(pb, track); if ((track->par->codec_type == AVMEDIA_TYPE_VIDEO || track->par->codec_tag == MKTAG('r','t','p',' ')) && track->has_keyframes && track->has_keyframes < track->entry) mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE); if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS) mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE); if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && track->flags & MOV_TRACK_CTTS && track->entry) { if ((ret = mov_write_ctts_tag(pb, track)) < 0) return ret; } mov_write_stsc_tag(pb, track); mov_write_stsz_tag(pb, track); mov_write_stco_tag(pb, track); if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) { ff_mov_cenc_write_stbl_atoms(&track->cenc, pb); } if (track->par->codec_id == AV_CODEC_ID_OPUS) { mov_preroll_write_stbl_atoms(pb, track); } return update_size(pb, pos); }
17,873
1
static av_cold void h264dsp_init_neon(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { if (bit_depth == 8) { c->h264_v_loop_filter_luma = ff_h264_v_loop_filter_luma_neon; c->h264_h_loop_filter_luma = ff_h264_h_loop_filter_luma_neon; c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon; c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon; c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon; c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon; c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon; c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon; c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon; c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon; c->h264_idct_add = ff_h264_idct_add_neon; c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; c->h264_idct_add16 = ff_h264_idct_add16_neon; c->h264_idct_add16intra = ff_h264_idct_add16intra_neon; if (chroma_format_idc == 1) c->h264_idct_add8 = ff_h264_idct_add8_neon; c->h264_idct8_add = ff_h264_idct8_add_neon; c->h264_idct8_dc_add = ff_h264_idct8_dc_add_neon; c->h264_idct8_add4 = ff_h264_idct8_add4_neon; } }
17,874
1
ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, int iovcnt) { VLANState *vlan = vc1->vlan; VLANClientState *vc; ssize_t max_len = 0; if (vc1->link_down) return calc_iov_length(iov, iovcnt); for (vc = vlan->first_client; vc != NULL; vc = vc->next) { ssize_t len = 0; if (vc == vc1) continue; if (vc->link_down) len = calc_iov_length(iov, iovcnt); else if (vc->fd_readv) len = vc->fd_readv(vc->opaque, iov, iovcnt); else if (vc->fd_read) len = vc_sendv_compat(vc, iov, iovcnt); max_len = MAX(max_len, len); } return max_len; }
17,875
1
static bool blit_region_is_unsafe(struct CirrusVGAState *s, int32_t pitch, int32_t addr) { if (pitch < 0) { int64_t min = addr + ((int64_t)s->cirrus_blt_height-1) * pitch; int32_t max = addr + s->cirrus_blt_width; if (min < 0 || max >= s->vga.vram_size) { return true; } } else { int64_t max = addr + ((int64_t)s->cirrus_blt_height-1) * pitch + s->cirrus_blt_width; if (max >= s->vga.vram_size) { return true; } } return false; }
17,876
1
static int rv10_decode_picture_header(MpegEncContext *s) { int mb_count, pb_frame, marker, h, full_frame; /* skip packet header */ h = get_bits(&s->gb, 8); if ((h & 0xc0) == 0xc0) { int len, pos; full_frame = 1; len = get_num(&s->gb); pos = get_num(&s->gb); } else { int seq, frame_size, pos; full_frame = 0; seq = get_bits(&s->gb, 8); frame_size = get_num(&s->gb); pos = get_num(&s->gb); } /* picture number */ get_bits(&s->gb, 8); marker = get_bits(&s->gb, 1); if (get_bits(&s->gb, 1)) s->pict_type = P_TYPE; else s->pict_type = I_TYPE; pb_frame = get_bits(&s->gb, 1); #ifdef DEBUG printf("pict_type=%d pb_frame=%d\n", s->pict_type, pb_frame); #endif if (pb_frame) return -1; s->qscale = get_bits(&s->gb, 5); if (s->pict_type == I_TYPE) { if (s->rv10_version == 3) { /* specific MPEG like DC coding not used */ s->last_dc[0] = get_bits(&s->gb, 8); s->last_dc[1] = get_bits(&s->gb, 8); s->last_dc[2] = get_bits(&s->gb, 8); #ifdef DEBUG printf("DC:%d %d %d\n", s->last_dc[0], s->last_dc[1], s->last_dc[2]); #endif } } /* if multiple packets per frame are sent, the position at which to display the macro blocks is coded here */ if (!full_frame) { s->mb_x = get_bits(&s->gb, 6); /* mb_x */ s->mb_y = get_bits(&s->gb, 6); /* mb_y */ mb_count = get_bits(&s->gb, 12); } else { s->mb_x = 0; s->mb_y = 0; mb_count = s->mb_width * s->mb_height; } get_bits(&s->gb, 3); /* ignored */ s->f_code = 1; s->unrestricted_mv = 1; #if 0 s->h263_long_vectors = 1; #endif return mb_count; }
17,879
1
host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { HostMemoryBackend *backend = MEMORY_BACKEND(obj); uint16List *host_nodes = NULL; uint16List **node = &host_nodes; unsigned long value; value = find_first_bit(backend->host_nodes, MAX_NODES); node = host_memory_append_node(node, value); if (value == MAX_NODES) { goto out; } do { value = find_next_bit(backend->host_nodes, MAX_NODES, value + 1); if (value == MAX_NODES) { break; } node = host_memory_append_node(node, value); } while (true); out: visit_type_uint16List(v, name, &host_nodes, errp); }
17,880
1
static int v4l2_read_header(AVFormatContext *s1) { struct video_data *s = s1->priv_data; AVStream *st; int res = 0; uint32_t desired_format; enum AVCodecID codec_id = AV_CODEC_ID_NONE; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; struct v4l2_input input = { 0 }; st = avformat_new_stream(s1, NULL); if (!st) return AVERROR(ENOMEM); #if CONFIG_LIBV4L2 /* silence libv4l2 logging. if fopen() fails v4l2_log_file will be NULL and errors will get sent to stderr */ v4l2_log_file = fopen("/dev/null", "w"); #endif s->fd = device_open(s1); if (s->fd < 0) return s->fd; if (s->channel != -1) { /* set video input */ av_log(s1, AV_LOG_DEBUG, "Selecting input_channel: %d\n", s->channel); if (v4l2_ioctl(s->fd, VIDIOC_S_INPUT, &s->channel) < 0) { res = AVERROR(errno); av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_S_INPUT): %s\n", av_err2str(res)); return res; } } else { /* get current video input */ if (v4l2_ioctl(s->fd, VIDIOC_G_INPUT, &s->channel) < 0) { res = AVERROR(errno); av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_INPUT): %s\n", av_err2str(res)); return res; } } /* enum input */ input.index = s->channel; if (v4l2_ioctl(s->fd, VIDIOC_ENUMINPUT, &input) < 0) { res = AVERROR(errno); av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMINPUT): %s\n", av_err2str(res)); return res; } s->std_id = input.std; av_log(s1, AV_LOG_DEBUG, "Current input_channel: %d, input_name: %s\n", s->channel, input.name); if (s->list_format) { list_formats(s1, s->fd, s->list_format); return AVERROR_EXIT; } if (s->list_standard) { list_standards(s1); return AVERROR_EXIT; } avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ if (s->pixel_format) { AVCodec *codec = avcodec_find_decoder_by_name(s->pixel_format); if (codec) s1->video_codec_id = codec->id; pix_fmt = av_get_pix_fmt(s->pixel_format); if (pix_fmt == AV_PIX_FMT_NONE && !codec) { av_log(s1, AV_LOG_ERROR, "No such input format: %s.\n", s->pixel_format); return AVERROR(EINVAL); } } if (!s->width && !s->height) { struct v4l2_format fmt; av_log(s1, AV_LOG_VERBOSE, "Querying the device for the current frame size\n"); fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; if (v4l2_ioctl(s->fd, VIDIOC_G_FMT, &fmt) < 0) { res = AVERROR(errno); av_log(s1, AV_LOG_ERROR, "ioctl(VIDIOC_G_FMT): %s\n", av_err2str(res)); return res; } s->width = fmt.fmt.pix.width; s->height = fmt.fmt.pix.height; av_log(s1, AV_LOG_VERBOSE, "Setting frame size to %dx%d\n", s->width, s->height); } res = device_try_init(s1, pix_fmt, &s->width, &s->height, &desired_format, &codec_id); if (res < 0) { v4l2_close(s->fd); return res; } /* If no pixel_format was specified, the codec_id was not known up * until now. Set video_codec_id in the context, as codec_id will * not be available outside this function */ if (codec_id != AV_CODEC_ID_NONE && s1->video_codec_id == AV_CODEC_ID_NONE) s1->video_codec_id = codec_id; if ((res = av_image_check_size(s->width, s->height, 0, s1)) < 0) return res; s->frame_format = desired_format; if ((res = v4l2_set_parameters(s1)) < 0) return res; st->codec->pix_fmt = fmt_v4l2ff(desired_format, codec_id); s->frame_size = avpicture_get_size(st->codec->pix_fmt, s->width, s->height); if ((res = mmap_init(s1)) || (res = mmap_start(s1)) < 0) { v4l2_close(s->fd); return res; } s->top_field_first = first_field(s->fd); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = codec_id; if (codec_id == AV_CODEC_ID_RAWVIDEO) st->codec->codec_tag = avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); if (desired_format == V4L2_PIX_FMT_YVU420) st->codec->codec_tag = MKTAG('Y', 'V', '1', '2'); else if (desired_format == V4L2_PIX_FMT_YVU410) st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9'); st->codec->width = s->width; st->codec->height = s->height; st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8; return 0; }
17,881
0
avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int perms, int w, int h, enum PixelFormat format) { AVFilterBuffer *pic = av_mallocz(sizeof(AVFilterBuffer)); AVFilterBufferRef *picref = av_mallocz(sizeof(AVFilterBufferRef)); if (!pic || !picref) goto fail; picref->buf = pic; picref->buf->free = ff_avfilter_default_free_buffer; if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps)))) goto fail; picref->video->w = w; picref->video->h = h; /* make sure the buffer gets read permission or it's useless for output */ picref->perms = perms | AV_PERM_READ; pic->refcount = 1; picref->type = AVMEDIA_TYPE_VIDEO; picref->format = format; memcpy(pic->data, data, sizeof(pic->data)); memcpy(pic->linesize, linesize, sizeof(pic->linesize)); memcpy(picref->data, pic->data, sizeof(picref->data)); memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize)); return picref; fail: if (picref && picref->video) av_free(picref->video); av_free(picref); av_free(pic); return NULL; }
17,882
1
static int dca_decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int i; int16_t *samples = data; DCAContext *s = avctx->priv_data; int channels; s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE); if (s->dca_buffer_size == -1) { av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); } init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); if (dca_parse_frame_header(s) < 0) { //seems like the frame is corrupt, try with the next one *data_size=0; return buf_size; } //set AVCodec values with parsed data avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate; channels = s->prim_channels + !!s->lfe; if (s->amode<16) { avctx->channel_layout = dca_core_channel_layout[s->amode]; if (s->lfe) { avctx->channel_layout |= CH_LOW_FREQUENCY; s->channel_order_tab = dca_channel_reorder_lfe[s->amode]; } else s->channel_order_tab = dca_channel_reorder_nolfe[s->amode]; if(avctx->request_channels == 2 && s->prim_channels > 2) { channels = 2; s->output = DCA_STEREO; avctx->channel_layout = CH_LAYOUT_STEREO; } } else { av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n",s->amode); } /* There is nothing that prevents a dts frame to change channel configuration but FFmpeg doesn't support that so only set the channels if it is previously unset. Ideally during the first probe for channels the crc should be checked and only set avctx->channels when the crc is ok. Right now the decoder could set the channels based on a broken first frame.*/ if (!avctx->channels) avctx->channels = channels; if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) *data_size = 256 / 8 * s->sample_blocks * sizeof(int16_t) * channels; for (i = 0; i < (s->sample_blocks / 8); i++) { dca_decode_block(s); s->dsp.float_to_int16_interleave(samples, s->samples_chanptr, 256, channels); samples += 256 * channels; } return buf_size; }
17,884
1
static void dmg_close(BlockDriverState *bs) { BDRVDMGState *s = bs->opaque; g_free(s->types); g_free(s->offsets); g_free(s->lengths); g_free(s->sectors); g_free(s->sectorcounts); g_free(s->compressed_chunk); g_free(s->uncompressed_chunk); inflateEnd(&s->zstream); }
17,886
1
int gdbserver_start(const char *device) { GDBState *s; char gdbstub_device_name[128]; CharDriverState *chr = NULL; CharDriverState *mon_chr; if (!device) return -1; if (strcmp(device, "none") != 0) { if (strstart(device, "tcp:", NULL)) { /* enforce required TCP attributes */ snprintf(gdbstub_device_name, sizeof(gdbstub_device_name), "%s,nowait,nodelay,server", device); device = gdbstub_device_name; } #ifndef _WIN32 else if (strcmp(device, "stdio") == 0) { struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = gdb_sigterm_handler; sigaction(SIGINT, &act, NULL); } #endif chr = qemu_chr_new("gdb", device, NULL); if (!chr) return -1; qemu_chr_add_handlers(chr, gdb_chr_can_receive, gdb_chr_receive, gdb_chr_event, NULL); } s = gdbserver_state; if (!s) { s = g_malloc0(sizeof(GDBState)); gdbserver_state = s; qemu_add_vm_change_state_handler(gdb_vm_state_change, NULL); /* Initialize a monitor terminal for gdb */ mon_chr = g_malloc0(sizeof(*mon_chr)); mon_chr->chr_write = gdb_monitor_write; monitor_init(mon_chr, 0); } else { if (s->chr) qemu_chr_delete(s->chr); mon_chr = s->mon_chr; memset(s, 0, sizeof(GDBState)); } s->c_cpu = first_cpu; s->g_cpu = first_cpu; s->chr = chr; s->state = chr ? RS_IDLE : RS_INACTIVE; s->mon_chr = mon_chr; s->current_syscall_cb = NULL; return 0; }
17,887
1
static int opus_packet(AVFormatContext *avf, int idx) { struct ogg *ogg = avf->priv_data; struct ogg_stream *os = &ogg->streams[idx]; AVStream *st = avf->streams[idx]; struct oggopus_private *priv = os->private; uint8_t *packet = os->buf + os->pstart; int ret; if (!os->psize) return AVERROR_INVALIDDATA; if (os->granule > INT64_MAX - UINT32_MAX) { av_log(avf, AV_LOG_ERROR, "Unsupported huge granule pos %"PRId64 "\n", os->granule); return AVERROR_INVALIDDATA; } if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) { int seg, d; int duration; uint8_t *last_pkt = os->buf + os->pstart; uint8_t *next_pkt = last_pkt; duration = 0; seg = os->segp; d = opus_duration(last_pkt, os->psize); if (d < 0) { os->pflags |= AV_PKT_FLAG_CORRUPT; return 0; } duration += d; last_pkt = next_pkt = next_pkt + os->psize; for (; seg < os->nsegs; seg++) { next_pkt += os->segments[seg]; if (os->segments[seg] < 255 && next_pkt != last_pkt) { int d = opus_duration(last_pkt, next_pkt - last_pkt); if (d > 0) duration += d; last_pkt = next_pkt; } } os->lastpts = os->lastdts = os->granule - duration; } if ((ret = opus_duration(packet, os->psize)) < 0) return ret; os->pduration = ret; if (os->lastpts != AV_NOPTS_VALUE) { if (st->start_time == AV_NOPTS_VALUE) st->start_time = os->lastpts; priv->cur_dts = os->lastdts = os->lastpts -= priv->pre_skip; } priv->cur_dts += os->pduration; if ((os->flags & OGG_FLAG_EOS)) { int64_t skip = priv->cur_dts - os->granule + priv->pre_skip; skip = FFMIN(skip, os->pduration); if (skip > 0) { os->pduration = skip < os->pduration ? os->pduration - skip : 1; os->end_trimming = skip; av_log(avf, AV_LOG_DEBUG, "Last packet was truncated to %d due to end trimming.\n", os->pduration); } } return 0; }
17,888
1
static unsigned int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize) { unsigned char *destptr_bak = destptr; unsigned char *destptr_end = destptr + destsize; unsigned char mask = 0; unsigned char maskbit = 0; unsigned int ofs, cnt; while (srclen > 0 && destptr < destptr_end) { if (maskbit == 0) { mask = *srcptr++; maskbit = 8; srclen--; continue; } if ((mask & (1 << (--maskbit))) == 0) { if (destptr + 4 > destptr_end) break; memcpy(destptr, srcptr, 4); srclen -= 4; destptr += 4; srcptr += 4; } else { ofs = *srcptr++; cnt = *srcptr++; ofs += cnt * 256; cnt = ((cnt >> 3) & 0x1f) + 1; ofs &= 0x7ff; srclen -= 2; cnt *= 4; if (destptr + cnt > destptr_end) { cnt = destptr_end - destptr; } for (; cnt > 0; cnt--) { *destptr = *(destptr - ofs); destptr++; } } } return destptr - destptr_bak; }
17,890
1
static int decode_codestream(Jpeg2000DecoderContext *s) { Jpeg2000CodingStyle *codsty = s->codsty; Jpeg2000QuantStyle *qntsty = s->qntsty; uint8_t *properties = s->properties; for (;;){ int oldpos, marker, len, ret = 0; if (bytestream2_get_bytes_left(&s->g) < 2) { av_log(s->avctx, AV_LOG_ERROR, "Missing EOC\n"); break; } marker = bytestream2_get_be16u(&s->g); av_dlog(s->avctx, "marker 0x%.4X at pos 0x%x\n", marker, bytestream2_tell(&s->g) - 4); oldpos = bytestream2_tell(&s->g); if (marker == JPEG2000_SOD){ Jpeg2000Tile *tile = s->tile + s->curtileno; if (ret = init_tile(s, s->curtileno)) { av_log(s->avctx, AV_LOG_ERROR, "tile initialization failed\n"); return ret; } if (ret = jpeg2000_decode_packets(s, tile)) { av_log(s->avctx, AV_LOG_ERROR, "packets decoding failed\n"); return ret; } continue; } if (marker == JPEG2000_EOC) break; if (bytestream2_get_bytes_left(&s->g) < 2) return AVERROR(EINVAL); len = bytestream2_get_be16u(&s->g); switch (marker){ case JPEG2000_SIZ: ret = get_siz(s); break; case JPEG2000_COC: ret = get_coc(s, codsty, properties); break; case JPEG2000_COD: ret = get_cod(s, codsty, properties); break; case JPEG2000_QCC: ret = get_qcc(s, len, qntsty, properties); break; case JPEG2000_QCD: ret = get_qcd(s, len, qntsty, properties); break; case JPEG2000_SOT: if (!(ret = get_sot(s))){ codsty = s->tile[s->curtileno].codsty; qntsty = s->tile[s->curtileno].qntsty; properties = s->tile[s->curtileno].properties; } break; case JPEG2000_COM: // the comment is ignored bytestream2_skip(&s->g, len - 2); break; default: av_log(s->avctx, AV_LOG_ERROR, "unsupported marker 0x%.4X at pos 0x%x\n", marker, bytestream2_tell(&s->g) - 4); bytestream2_skip(&s->g, len - 2); break; } if (bytestream2_tell(&s->g) - oldpos != len || ret){ av_log(s->avctx, AV_LOG_ERROR, "error during processing marker segment %.4x\n", marker); return ret ? ret : -1; } } return 0; }
17,891
1
void do_mulldo (void) { int64_t th; uint64_t tl; muls64(&tl, &th, T0, T1); if (likely(th == 0)) { xer_ov = 0; } else { xer_ov = 1; xer_so = 1; } T0 = (int64_t)tl; }
17,895
0
static int decode_unit(SCPRContext *s, PixelModel *pixel, unsigned step, unsigned *rval) { GetByteContext *gb = &s->gb; RangeCoder *rc = &s->rc; unsigned totfr = pixel->total_freq; unsigned value, x = 0, cumfr = 0, cnt_x = 0; int i, j, ret, c, cnt_c; if ((ret = s->get_freq(rc, totfr, &value)) < 0) return ret; while (x < 16) { cnt_x = pixel->lookup[x]; if (value >= cumfr + cnt_x) cumfr += cnt_x; else break; x++; } c = x * 16; cnt_c = 0; while (c < 256) { cnt_c = pixel->freq[c]; if (value >= cumfr + cnt_c) cumfr += cnt_c; else break; c++; } s->decode(gb, rc, cumfr, cnt_c, totfr); pixel->freq[c] = cnt_c + step; pixel->lookup[x] = cnt_x + step; totfr += step; if (totfr > BOT) { totfr = 0; for (i = 0; i < 256; i++) { unsigned nc = (pixel->freq[i] >> 1) + 1; pixel->freq[i] = nc; totfr += nc; } for (i = 0; i < 16; i++) { unsigned sum = 0; unsigned i16_17 = i << 4; for (j = 0; j < 16; j++) sum += pixel->freq[i16_17 + j]; pixel->lookup[i] = sum; } } pixel->total_freq = totfr; *rval = c & s->cbits; return 0; }
17,896
0
static void sbr_env_estimate(float (*e_curr)[48], float X_high[64][40][2], SpectralBandReplication *sbr, SBRData *ch_data) { int e, i, m; if (sbr->bs_interpol_freq) { for (e = 0; e < ch_data->bs_num_env; e++) { const float recip_env_size = 0.5f / (ch_data->t_env[e + 1] - ch_data->t_env[e]); int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; for (m = 0; m < sbr->m[1]; m++) { float sum = 0.0f; for (i = ilb; i < iub; i++) { sum += X_high[m + sbr->kx[1]][i][0] * X_high[m + sbr->kx[1]][i][0] + X_high[m + sbr->kx[1]][i][1] * X_high[m + sbr->kx[1]][i][1]; } e_curr[e][m] = sum * recip_env_size; } } } else { int k, p; for (e = 0; e < ch_data->bs_num_env; e++) { const int env_size = 2 * (ch_data->t_env[e + 1] - ch_data->t_env[e]); int ilb = ch_data->t_env[e] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; int iub = ch_data->t_env[e + 1] * 2 + ENVELOPE_ADJUSTMENT_OFFSET; const uint16_t *table = ch_data->bs_freq_res[e + 1] ? sbr->f_tablehigh : sbr->f_tablelow; for (p = 0; p < sbr->n[ch_data->bs_freq_res[e + 1]]; p++) { float sum = 0.0f; const int den = env_size * (table[p + 1] - table[p]); for (k = table[p]; k < table[p + 1]; k++) { for (i = ilb; i < iub; i++) { sum += X_high[k][i][0] * X_high[k][i][0] + X_high[k][i][1] * X_high[k][i][1]; } } sum /= den; for (k = table[p]; k < table[p + 1]; k++) { e_curr[e][k - sbr->kx[1]] = sum; } } } } }
17,897
0
static int test_scalarproduct_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, const float *v1, const float *v2) { float cprod, oprod; int ret; cprod = cdsp->scalarproduct_float(v1, v2, LEN); oprod = fdsp->scalarproduct_float(v1, v2, LEN); if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST)) av_log(NULL, AV_LOG_ERROR, "scalarproduct_float failed\n"); return ret; }
17,898
0
static int mov_read_pasp(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { const int num = get_be32(pb); const int den = get_be32(pb); AVStream * const st = c->fc->streams[c->fc->nb_streams-1]; if (den != 0) { if ((st->sample_aspect_ratio.den != 1 || st->sample_aspect_ratio.num) && // default (den != st->sample_aspect_ratio.den || num != st->sample_aspect_ratio.num)) av_log(c->fc, AV_LOG_WARNING, "sample aspect ratio already set to %d:%d, overriding by 'pasp' atom\n", st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); st->sample_aspect_ratio.num = num; st->sample_aspect_ratio.den = den; } return 0; }
17,899
0
static void MPV_encode_defaults(MpegEncContext *s){ static int done=0; MPV_common_defaults(s); if(!done){ int i; done=1; for(i=-16; i<16; i++){ default_fcode_tab[i + MAX_MV]= 1; } } s->me.mv_penalty= default_mv_penalty; s->fcode_tab= default_fcode_tab; }
17,900
0
int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt, int has_alpha) { const PixFmtInfo *pf, *ps; int loss; ps = &pix_fmt_info[src_pix_fmt]; pf = &pix_fmt_info[dst_pix_fmt]; /* compute loss */ loss = 0; pf = &pix_fmt_info[dst_pix_fmt]; if (pf->depth < ps->depth) loss |= FF_LOSS_DEPTH; if (pf->x_chroma_shift >= ps->x_chroma_shift || pf->y_chroma_shift >= ps->y_chroma_shift) loss |= FF_LOSS_RESOLUTION; switch(pf->color_type) { case FF_COLOR_RGB: if (ps->color_type != FF_COLOR_RGB && ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_COLORSPACE; break; case FF_COLOR_GRAY: if (ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_COLORSPACE; break; case FF_COLOR_YUV: if (ps->color_type != FF_COLOR_YUV) loss |= FF_LOSS_COLORSPACE; break; case FF_COLOR_YUV_JPEG: if (ps->color_type != FF_COLOR_YUV_JPEG && ps->color_type != FF_COLOR_YUV) loss |= FF_LOSS_COLORSPACE; break; default: /* fail safe test */ if (ps->color_type != pf->color_type) loss |= FF_LOSS_COLORSPACE; break; } if (pf->color_type == FF_COLOR_GRAY && ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_CHROMA; if (!pf->is_alpha && (ps->is_alpha && has_alpha)) loss |= FF_LOSS_ALPHA; if (pf->is_paletted && (!ps->is_paletted && ps->color_type != FF_COLOR_GRAY)) loss |= FF_LOSS_COLORQUANT; return loss; }
17,901
0
static int ftp_get_file_handle(URLContext *h) { FTPContext *s = h->priv_data; av_dlog(h, "ftp protocol get_file_handle\n"); if (s->conn_data) return ffurl_get_file_handle(s->conn_data); return AVERROR(EIO); }
17,902
0
static void sdp_write_header(char *buff, int size, struct sdp_session_level *s) { av_strlcatf(buff, size, "v=%d\r\n" "o=- %d %d IN IPV4 %s\r\n" "t=%d %d\r\n" "s=%s\r\n" "a=tool:libavformat " AV_STRINGIFY(LIBAVFORMAT_VERSION) "\r\n", s->sdp_version, s->id, s->version, s->src_addr, s->start_time, s->end_time, s->name[0] ? s->name : "No Name"); dest_write(buff, size, s->dst_addr, s->ttl); }
17,903
1
static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) { int ret, i; AVFormatContext *dev = NULL; AVDeviceInfoList *device_list = NULL; AVDictionary *tmp_opts = NULL; if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category)) return AVERROR(EINVAL); printf("Audo-detected sources for %s:\n", fmt->name); if (!fmt->get_device_list) { ret = AVERROR(ENOSYS); printf("Cannot list sources. Not implemented.\n"); goto fail; } /* TODO: avformat_open_input calls read_header callback which is not necessary. Function like avformat_alloc_output_context2 for input could be helpful here. */ av_dict_copy(&tmp_opts, opts, 0); if ((ret = avformat_open_input(&dev, NULL, fmt, &tmp_opts)) < 0) { printf("Cannot open device: %s.\n", fmt->name); goto fail; } if ((ret = avdevice_list_devices(dev, &device_list)) < 0) { printf("Cannot list sources.\n"); goto fail; } for (i = 0; i < device_list->nb_devices; i++) { printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", device_list->devices[i]->device_name, device_list->devices[i]->device_description); } fail: av_dict_free(&tmp_opts); avdevice_free_list_devices(&device_list); avformat_close_input(&dev); return ret; }
17,905
1
static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, uint8_t *dest, int dstW, int dstY) { int dummy=0; switch(c->dstFormat) { #ifdef HAVE_MMX case IMGFMT_BGR32: { asm volatile( YSCALEYUV2RGBX WRITEBGR32(%4, %5, %%REGa) :: "r" (&c->redDither), "m" (dummy), "m" (dummy), "m" (dummy), "r" (dest), "m" (dstW) : "%"REG_a, "%"REG_d, "%"REG_S ); } break; case IMGFMT_BGR24: { asm volatile( YSCALEYUV2RGBX "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" //FIXME optimize "add %4, %%"REG_b" \n\t" WRITEBGR24(%%REGb, %5, %%REGa) :: "r" (&c->redDither), "m" (dummy), "m" (dummy), "m" (dummy), "r" (dest), "m" (dstW) : "%"REG_a, "%"REG_b, "%"REG_d, "%"REG_S //FIXME ebx ); } break; case IMGFMT_BGR15: { asm volatile( YSCALEYUV2RGBX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ #ifdef DITHER1XBPP "paddusb "MANGLE(b5Dither)", %%mm2\n\t" "paddusb "MANGLE(g5Dither)", %%mm4\n\t" "paddusb "MANGLE(r5Dither)", %%mm5\n\t" #endif WRITEBGR15(%4, %5, %%REGa) :: "r" (&c->redDither), "m" (dummy), "m" (dummy), "m" (dummy), "r" (dest), "m" (dstW) : "%"REG_a, "%"REG_d, "%"REG_S ); } break; case IMGFMT_BGR16: { asm volatile( YSCALEYUV2RGBX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ #ifdef DITHER1XBPP "paddusb "MANGLE(b5Dither)", %%mm2\n\t" "paddusb "MANGLE(g6Dither)", %%mm4\n\t" "paddusb "MANGLE(r5Dither)", %%mm5\n\t" #endif WRITEBGR16(%4, %5, %%REGa) :: "r" (&c->redDither), "m" (dummy), "m" (dummy), "m" (dummy), "r" (dest), "m" (dstW) : "%"REG_a, "%"REG_d, "%"REG_S ); } break; case IMGFMT_YUY2: { asm volatile( YSCALEYUV2PACKEDX /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */ "psraw $3, %%mm3 \n\t" "psraw $3, %%mm4 \n\t" "psraw $3, %%mm1 \n\t" "psraw $3, %%mm7 \n\t" WRITEYUY2(%4, %5, %%REGa) :: "r" (&c->redDither), "m" (dummy), "m" (dummy), "m" (dummy), "r" (dest), "m" (dstW) : "%"REG_a, "%"REG_d, "%"REG_S ); } break; #endif default: #ifdef HAVE_ALTIVEC /* The following list of supported dstFormat values should match what's found in the body of altivec_yuv2packedX() */ if(c->dstFormat==IMGFMT_ABGR || c->dstFormat==IMGFMT_BGRA || c->dstFormat==IMGFMT_BGR24 || c->dstFormat==IMGFMT_RGB24 || c->dstFormat==IMGFMT_RGBA || c->dstFormat==IMGFMT_ARGB) altivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize, chrFilter, chrSrc, chrFilterSize, dest, dstW, dstY); else #endif yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize, chrFilter, chrSrc, chrFilterSize, dest, dstW, dstY); break; } }
17,906
1
static int multiple_resample(ResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed){ int i, ret= -1; int av_unused mm_flags = av_get_cpu_flags(); int need_emms= 0; if (c->compensation_distance) dst_size = FFMIN(dst_size, c->compensation_distance); for(i=0; i<dst->ch_count; i++){ #if HAVE_MMXEXT_INLINE #if HAVE_SSE2_INLINE if(c->format == AV_SAMPLE_FMT_S16P && (mm_flags&AV_CPU_FLAG_SSE2)) ret= swri_resample_int16_sse2 (c, (int16_t*)dst->ch[i], (const int16_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); else #endif if(c->format == AV_SAMPLE_FMT_S16P && (mm_flags&AV_CPU_FLAG_MMX2 )){ ret= swri_resample_int16_mmx2 (c, (int16_t*)dst->ch[i], (const int16_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); need_emms= 1; } else #endif if(c->format == AV_SAMPLE_FMT_S16P) ret= swri_resample_int16(c, (int16_t*)dst->ch[i], (const int16_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); else if(c->format == AV_SAMPLE_FMT_S32P) ret= swri_resample_int32(c, (int32_t*)dst->ch[i], (const int32_t*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #if HAVE_AVX_INLINE else if(c->format == AV_SAMPLE_FMT_FLTP && (mm_flags&AV_CPU_FLAG_AVX)) ret= swri_resample_float_avx (c, (float*)dst->ch[i], (const float*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #endif #if HAVE_SSE_INLINE else if(c->format == AV_SAMPLE_FMT_FLTP && (mm_flags&AV_CPU_FLAG_SSE)) ret= swri_resample_float_sse (c, (float*)dst->ch[i], (const float*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #endif else if(c->format == AV_SAMPLE_FMT_FLTP) ret= swri_resample_float(c, (float *)dst->ch[i], (const float *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #if HAVE_SSE2_INLINE else if(c->format == AV_SAMPLE_FMT_DBLP && (mm_flags&AV_CPU_FLAG_SSE2)) ret= swri_resample_double_sse2(c,(double *)dst->ch[i], (const double *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); #endif else if(c->format == AV_SAMPLE_FMT_DBLP) ret= swri_resample_double(c,(double *)dst->ch[i], (const double *)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); if(need_emms) emms_c(); return ret;
17,907
1
static void mpegts_write_pes(AVFormatContext *s, AVStream *st, const uint8_t *payload, int payload_size, int64_t pts, int64_t dts, int key, int stream_id) { MpegTSWriteStream *ts_st = st->priv_data; MpegTSWrite *ts = s->priv_data; uint8_t buf[TS_PACKET_SIZE]; uint8_t *q; int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, is_dvb_teletext, flags; int afc_len, stuffing_len; int64_t pcr = -1; /* avoid warning */ int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE); int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key; av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO); if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { force_pat = 1; is_start = 1; while (payload_size > 0) { retransmit_si_info(s, force_pat, dts); force_pat = 0; write_pcr = 0; if (ts_st->pid == ts_st->service->pcr_pid) { if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on frames ts_st->service->pcr_packet_count++; if (ts_st->service->pcr_packet_count >= ts_st->service->pcr_packet_period) { ts_st->service->pcr_packet_count = 0; write_pcr = 1; if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE && (dts - get_pcr(ts, s->pb) / 300) > delay) { /* pcr insert gets priority over null packet insert */ if (write_pcr) mpegts_insert_pcr_only(s, st); else mpegts_insert_null_packet(s); /* recalculate write_pcr and possibly retransmit si_info */ continue; /* prepare packet header */ q = buf; *q++ = 0x47; val = ts_st->pid >> 8; if (is_start) val |= 0x40; *q++ = val; *q++ = ts_st->pid; ts_st->cc = ts_st->cc + 1 & 0xf; *q++ = 0x10 | ts_st->cc; // payload indicator + CC if (key && is_start && pts != AV_NOPTS_VALUE) { // set Random Access for key frames if (ts_st->pid == ts_st->service->pcr_pid) write_pcr = 1; set_af_flag(buf, 0x40); if (write_pcr) { set_af_flag(buf, 0x10); // add 11, pcr references the last byte of program clock reference base if (ts->mux_rate > 1) pcr = get_pcr(ts, s->pb); else pcr = (dts - delay) * 300; if (dts != AV_NOPTS_VALUE && dts < pcr / 300) av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n"); extend_af(buf, write_pcr_bits(q, pcr)); if (is_start) { int pes_extension = 0; int pes_header_stuffing_bytes = 0; /* write PES header */ *q++ = 0x00; *q++ = 0x00; *q++ = 0x01; is_dvb_subtitle = 0; is_dvb_teletext = 0; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { if (st->codecpar->codec_id == AV_CODEC_ID_DIRAC) *q++ = 0xfd; else *q++ = 0xe0; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && (st->codecpar->codec_id == AV_CODEC_ID_MP2 || st->codecpar->codec_id == AV_CODEC_ID_MP3 || st->codecpar->codec_id == AV_CODEC_ID_AAC)) { *q++ = 0xc0; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->codec_id == AV_CODEC_ID_AC3 && ts->m2ts_mode) { *q++ = 0xfd; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA && st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) { *q++ = 0xbd; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { *q++ = stream_id != -1 ? stream_id : 0xfc; if (stream_id == 0xbd) /* asynchronous KLV */ pts = dts = AV_NOPTS_VALUE; } else { *q++ = 0xbd; if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) { is_dvb_subtitle = 1; } else if (st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT) { is_dvb_teletext = 1; header_len = 0; flags = 0; if (pts != AV_NOPTS_VALUE) { header_len += 5; flags |= 0x80; if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) { header_len += 5; flags |= 0x40; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->codecpar->codec_id == AV_CODEC_ID_DIRAC) { /* set PES_extension_flag */ pes_extension = 1; flags |= 0x01; /* One byte for PES2 extension flag + * one byte for extension length + * one byte for extension id */ header_len += 3; /* for Blu-ray AC3 Audio the PES Extension flag should be as follow * otherwise it will not play sound on blu-ray */ if (ts->m2ts_mode && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->codec_id == AV_CODEC_ID_AC3) { /* set PES_extension_flag */ pes_extension = 1; flags |= 0x01; header_len += 3; if (is_dvb_teletext) { pes_header_stuffing_bytes = 0x24 - header_len; header_len = 0x24; len = payload_size + header_len + 3; /* 3 extra bytes should be added to DVB subtitle payload: 0x20 0x00 at the beginning and trailing 0xff */ if (is_dvb_subtitle) { len += 3; payload_size++; if (len > 0xffff) len = 0; if (ts->omit_video_pes_length && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { len = 0; *q++ = len >> 8; *q++ = len; val = 0x80; /* data alignment indicator is required for subtitle and data streams */ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA) val |= 0x04; *q++ = val; *q++ = flags; *q++ = header_len; if (pts != AV_NOPTS_VALUE) { write_pts(q, flags >> 6, pts); q += 5; if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) { write_pts(q, 1, dts); q += 5; if (pes_extension && st->codecpar->codec_id == AV_CODEC_ID_DIRAC) { flags = 0x01; /* set PES_extension_flag_2 */ *q++ = flags; *q++ = 0x80 | 0x01; /* marker bit + extension length */ /* Set the stream ID extension flag bit to 0 and * write the extended stream ID. */ *q++ = 0x00 | 0x60; /* For Blu-ray AC3 Audio Setting extended flags */ if (ts->m2ts_mode && pes_extension && st->codecpar->codec_id == AV_CODEC_ID_AC3) { flags = 0x01; /* set PES_extension_flag_2 */ *q++ = flags; *q++ = 0x80 | 0x01; /* marker bit + extension length */ *q++ = 0x00 | 0x71; /* for AC3 Audio (specifically on blue-rays) */ if (is_dvb_subtitle) { /* First two fields of DVB subtitles PES data: * data_identifier: for DVB subtitle streams shall be coded with the value 0x20 * subtitle_stream_id: for DVB subtitle stream shall be identified by the value 0x00 */ *q++ = 0x20; *q++ = 0x00; if (is_dvb_teletext) { memset(q, 0xff, pes_header_stuffing_bytes); q += pes_header_stuffing_bytes; is_start = 0; /* header size */ header_len = q - buf; /* data len */ len = TS_PACKET_SIZE - header_len; if (len > payload_size) len = payload_size; stuffing_len = TS_PACKET_SIZE - header_len - len; if (stuffing_len > 0) { /* add stuffing with AFC */ if (buf[3] & 0x20) { /* stuffing already present: increase its size */ afc_len = buf[4] + 1; memmove(buf + 4 + afc_len + stuffing_len, buf + 4 + afc_len, header_len - (4 + afc_len)); buf[4] += stuffing_len; memset(buf + 4 + afc_len, 0xff, stuffing_len); } else { /* add stuffing */ memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4); buf[3] |= 0x20; buf[4] = stuffing_len - 1; if (stuffing_len >= 2) { buf[5] = 0x00; memset(buf + 6, 0xff, stuffing_len - 2); if (is_dvb_subtitle && payload_size == len) { memcpy(buf + TS_PACKET_SIZE - len, payload, len - 1); buf[TS_PACKET_SIZE - 1] = 0xff; /* end_of_PES_data_field_marker: an 8-bit field with fixed contents 0xff for DVB subtitle */ } else { memcpy(buf + TS_PACKET_SIZE - len, payload, len); payload += len; payload_size -= len; mpegts_prefix_m2ts_header(s); avio_write(s->pb, buf, TS_PACKET_SIZE); ts_st->prev_payload_key = key;
17,910
0
void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end, int snr_offset, int floor, const uint8_t *bap_tab, uint8_t *bap) { int i, j, end1, v, address; /* special case, if snr offset is -960, set all bap's to zero */ if (snr_offset == -960) { memset(bap, 0, 256); return; } i = start; j = bin_to_band_tab[start]; do { v = (FFMAX(mask[j] - snr_offset - floor, 0) & 0x1FE0) + floor; end1 = FFMIN(band_start_tab[j] + ff_ac3_critical_band_size_tab[j], end); for (; i < end1; i++) { address = av_clip((psd[i] - v) >> 5, 0, 63); bap[i] = bap_tab[address]; } } while (end > band_start_tab[j++]); }
17,911
1
static int check_refcounts_l2(BlockDriverState *bs, BdrvCheckResult *res, uint16_t **refcount_table, int64_t *refcount_table_size, int64_t l2_offset, int flags) { BDRVQcowState *s = bs->opaque; uint64_t *l2_table, l2_entry; uint64_t next_contiguous_offset = 0; int i, l2_size, nb_csectors, ret; /* Read L2 table from disk */ l2_size = s->l2_size * sizeof(uint64_t); l2_table = g_malloc(l2_size); ret = bdrv_pread(bs->file, l2_offset, l2_table, l2_size); if (ret < 0) { fprintf(stderr, "ERROR: I/O error in check_refcounts_l2\n"); res->check_errors++; goto fail; } /* Do the actual checks */ for(i = 0; i < s->l2_size; i++) { l2_entry = be64_to_cpu(l2_table[i]); switch (qcow2_get_cluster_type(l2_entry)) { case QCOW2_CLUSTER_COMPRESSED: /* Compressed clusters don't have QCOW_OFLAG_COPIED */ if (l2_entry & QCOW_OFLAG_COPIED) { fprintf(stderr, "ERROR: cluster %" PRId64 ": " "copied flag must never be set for compressed " "clusters\n", l2_entry >> s->cluster_bits); l2_entry &= ~QCOW_OFLAG_COPIED; res->corruptions++; } /* Mark cluster as used */ nb_csectors = ((l2_entry >> s->csize_shift) & s->csize_mask) + 1; l2_entry &= s->cluster_offset_mask; ret = inc_refcounts(bs, res, refcount_table, refcount_table_size, l2_entry & ~511, nb_csectors * 512); if (ret < 0) { goto fail; } if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; res->bfi.compressed_clusters++; /* Compressed clusters are fragmented by nature. Since they * take up sub-sector space but we only have sector granularity * I/O we need to re-read the same sectors even for adjacent * compressed clusters. */ res->bfi.fragmented_clusters++; } break; case QCOW2_CLUSTER_ZERO: if ((l2_entry & L2E_OFFSET_MASK) == 0) { break; } /* fall through */ case QCOW2_CLUSTER_NORMAL: { uint64_t offset = l2_entry & L2E_OFFSET_MASK; if (flags & CHECK_FRAG_INFO) { res->bfi.allocated_clusters++; if (next_contiguous_offset && offset != next_contiguous_offset) { res->bfi.fragmented_clusters++; } next_contiguous_offset = offset + s->cluster_size; } /* Mark cluster as used */ ret = inc_refcounts(bs, res, refcount_table, refcount_table_size, offset, s->cluster_size); if (ret < 0) { goto fail; } /* Correct offsets are cluster aligned */ if (offset_into_cluster(s, offset)) { fprintf(stderr, "ERROR offset=%" PRIx64 ": Cluster is not " "properly aligned; L2 entry corrupted.\n", offset); res->corruptions++; } break; } case QCOW2_CLUSTER_UNALLOCATED: break; default: abort(); } } g_free(l2_table); return 0; fail: g_free(l2_table); return ret; }
17,912
0
static inline void mix_3f_to_mono(AC3DecodeContext *ctx) { int i; float (*output)[256] = ctx->audio_block.block_output; for (i = 0; i < 256; i++) output[1][i] += (output[2][i] + output[3][i]); memset(output[2], 0, sizeof(output[2])); memset(output[3], 0, sizeof(output[3])); }
17,914
0
int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) { int pqindex, lowquant; int status; int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only for debugging */ int scale, shift, i; /* for initializing LUT for intensity compensation */ v->numref=0; v->p_frame_skipped = 0; if (v->second_field) { if(v->fcm!=2 || v->field_mode!=1) return -1; v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; if (v->fptype & 4) v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; v->s.current_picture_ptr->f.pict_type = v->s.pict_type; if (!v->pic_header_flag) goto parse_common_info; } v->field_mode = 0; if (v->interlace) { v->fcm = decode012(gb); if (v->fcm) { if (v->fcm == ILACE_FIELD) v->field_mode = 1; if (!v->warn_interlaced++) av_log(v->s.avctx, AV_LOG_ERROR, "Interlaced frames/fields support is incomplete\n"); } } else { v->fcm = PROGRESSIVE; } if (v->field_mode) { v->fptype = get_bits(gb, 3); v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; if (v->fptype & 4) // B-picture v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; } else { switch (get_unary(gb, 0, 4)) { case 0: v->s.pict_type = AV_PICTURE_TYPE_P; break; case 1: v->s.pict_type = AV_PICTURE_TYPE_B; break; case 2: v->s.pict_type = AV_PICTURE_TYPE_I; break; case 3: v->s.pict_type = AV_PICTURE_TYPE_BI; break; case 4: v->s.pict_type = AV_PICTURE_TYPE_P; // skipped pic v->p_frame_skipped = 1; break; } } if (v->tfcntrflag) skip_bits(gb, 8); if (v->broadcast) { if (!v->interlace || v->psf) { v->rptfrm = get_bits(gb, 2); } else { v->tff = get_bits1(gb); v->rff = get_bits1(gb); } } if (v->panscanflag) { av_log_missing_feature(v->s.avctx, "Pan-scan", 0); //... } if (v->p_frame_skipped) { return 0; } v->rnd = get_bits1(gb); if (v->interlace) v->uvsamp = get_bits1(gb); if(!ff_vc1_bfraction_vlc.table) return 0; //parsing only, vlc tables havnt been allocated if (v->field_mode) { if (!v->refdist_flag) v->refdist = 0; else if ((v->s.pict_type != AV_PICTURE_TYPE_B) && (v->s.pict_type != AV_PICTURE_TYPE_BI)) { v->refdist = get_bits(gb, 2); if (v->refdist == 3) v->refdist += get_unary(gb, 0, 16); } if ((v->s.pict_type == AV_PICTURE_TYPE_B) || (v->s.pict_type == AV_PICTURE_TYPE_BI)) { v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; v->frfd = (v->bfraction * v->refdist) >> 8; v->brfd = v->refdist - v->frfd - 1; if (v->brfd < 0) v->brfd = 0; } goto parse_common_info; } if (v->fcm == PROGRESSIVE) { if (v->finterpflag) v->interpfrm = get_bits1(gb); if (v->s.pict_type == AV_PICTURE_TYPE_B) { v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; if (v->bfraction == 0) { v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */ } } } parse_common_info: if (v->field_mode) v->cur_field_type = !(v->tff ^ v->second_field); pqindex = get_bits(gb, 5); if (!pqindex) return -1; v->pqindex = pqindex; if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) v->pq = ff_vc1_pquant_table[0][pqindex]; else v->pq = ff_vc1_pquant_table[1][pqindex]; v->pquantizer = 1; if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) v->pquantizer = pqindex < 9; if (v->quantizer_mode == QUANT_NON_UNIFORM) v->pquantizer = 0; v->pqindex = pqindex; if (pqindex < 9) v->halfpq = get_bits1(gb); else v->halfpq = 0; if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) v->pquantizer = get_bits1(gb); if (v->postprocflag) v->postproc = get_bits(gb, 2); if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_P) v->use_ic = 0; if (v->parse_only) return 0; switch (v->s.pict_type) { case AV_PICTURE_TYPE_I: case AV_PICTURE_TYPE_BI: if (v->fcm == ILACE_FRAME) { //interlace frame picture status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "FIELDTX plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->condover = CONDOVER_NONE; if (v->overlap && v->pq <= 8) { v->condover = decode012(gb); if (v->condover == CONDOVER_SELECT) { status = bitplane_decoding(v->over_flags_plane, &v->overflg_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } } break; case AV_PICTURE_TYPE_P: if (v->field_mode) { v->numref = get_bits1(gb); if (!v->numref) { v->reffield = get_bits1(gb); v->ref_field_type[0] = v->reffield ^ !v->cur_field_type; } } if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3); else v->mvrange = 0; if (v->interlace) { if (v->extended_dmv) v->dmvrange = get_unary(gb, 0, 3); else v->dmvrange = 0; if (v->fcm == ILACE_FRAME) { // interlaced frame picture v->fourmvswitch = get_bits1(gb); v->intcomp = get_bits1(gb); if (v->intcomp) { v->lumscale = get_bits(gb, 6); v->lumshift = get_bits(gb, 6); INIT_LUT(v->lumscale, v->lumshift, v->luty, v->lutuv); } status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); av_log(v->s.avctx, AV_LOG_DEBUG, "SKIPMB plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); mbmodetab = get_bits(gb, 2); if (v->fourmvswitch) v->mbmode_vlc = &ff_vc1_intfr_4mv_mbmode_vlc[mbmodetab]; else v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab]; imvtab = get_bits(gb, 2); v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab]; // interlaced p-picture cbpcy range is [1, 63] icbptab = get_bits(gb, 3); v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; twomvbptab = get_bits(gb, 2); v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab]; if (v->fourmvswitch) { fourmvbptab = get_bits(gb, 2); v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; } } } v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13 v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11 v->range_x = 1 << (v->k_x - 1); v->range_y = 1 << (v->k_y - 1); if (v->pq < 5) v->tt_index = 0; else if (v->pq < 13) v->tt_index = 1; else v->tt_index = 2; if (v->fcm != ILACE_FRAME) { int mvmode; mvmode = get_unary(gb, 1, 4); lowquant = (v->pq > 12) ? 0 : 1; v->mv_mode = ff_vc1_mv_pmode_table[lowquant][mvmode]; if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int mvmode2; mvmode2 = get_unary(gb, 1, 3); v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][mvmode2]; if (v->field_mode) v->intcompfield = decode210(gb); v->lumscale = get_bits(gb, 6); v->lumshift = get_bits(gb, 6); INIT_LUT(v->lumscale, v->lumshift, v->luty, v->lutuv); if ((v->field_mode) && !v->intcompfield) { v->lumscale2 = get_bits(gb, 6); v->lumshift2 = get_bits(gb, 6); INIT_LUT(v->lumscale2, v->lumshift2, v->luty2, v->lutuv2); } v->use_ic = 1; } v->qs_last = v->s.quarter_sample; if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) v->s.quarter_sample = 0; else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN) v->s.quarter_sample = 0; else v->s.quarter_sample = 1; } else v->s.quarter_sample = 1; v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)); } if (v->fcm == PROGRESSIVE) { // progressive if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) { status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } else { v->mv_type_is_raw = 0; memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height); } status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); /* Hopefully this is correct for P frames */ v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; } else if (v->fcm == ILACE_FRAME) { // frame interlaced v->qs_last = v->s.quarter_sample; v->s.quarter_sample = 1; v->s.mspel = 1; } else { // field interlaced mbmodetab = get_bits(gb, 3); imvtab = get_bits(gb, 2 + v->numref); if (!v->numref) v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab]; else v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab]; icbptab = get_bits(gb, 3); v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) { fourmvbptab = get_bits(gb, 2); v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab]; } else { v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab]; } } if (v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->ttfrm = 0; //FIXME Is that so ? if (v->vstransform) { v->ttmbf = get_bits1(gb); if (v->ttmbf) { v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; } } else { v->ttmbf = 1; v->ttfrm = TT_8X8; } break; case AV_PICTURE_TYPE_B: if (v->fcm == ILACE_FRAME) { v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; if (v->bfraction == 0) { return -1; } } if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3); else v->mvrange = 0; v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13 v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11 v->range_x = 1 << (v->k_x - 1); v->range_y = 1 << (v->k_y - 1); if (v->pq < 5) v->tt_index = 0; else if (v->pq < 13) v->tt_index = 1; else v->tt_index = 2; if (v->field_mode) { int mvmode; av_log(v->s.avctx, AV_LOG_DEBUG, "B Fields\n"); if (v->extended_dmv) v->dmvrange = get_unary(gb, 0, 3); mvmode = get_unary(gb, 1, 3); lowquant = (v->pq > 12) ? 0 : 1; v->mv_mode = ff_vc1_mv_pmode_table2[lowquant][mvmode]; v->qs_last = v->s.quarter_sample; v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV); v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || v->mv_mode == MV_PMODE_1MV_HPEL); status = bitplane_decoding(v->forward_mb_plane, &v->fmb_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Forward Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); mbmodetab = get_bits(gb, 3); if (v->mv_mode == MV_PMODE_MIXED_MV) v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab]; else v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab]; imvtab = get_bits(gb, 3); v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab]; icbptab = get_bits(gb, 3); v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; if (v->mv_mode == MV_PMODE_MIXED_MV) { fourmvbptab = get_bits(gb, 2); v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; } v->numref = 1; // interlaced field B pictures are always 2-ref } else if (v->fcm == ILACE_FRAME) { if (v->extended_dmv) v->dmvrange = get_unary(gb, 0, 3); get_bits1(gb); /* intcomp - present but shall always be 0 */ v->intcomp = 0; v->mv_mode = MV_PMODE_1MV; v->fourmvswitch = 0; v->qs_last = v->s.quarter_sample; v->s.quarter_sample = 1; v->s.mspel = 1; status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); mbmodetab = get_bits(gb, 2); v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab]; imvtab = get_bits(gb, 2); v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab]; // interlaced p/b-picture cbpcy range is [1, 63] icbptab = get_bits(gb, 3); v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; twomvbptab = get_bits(gb, 2); v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab]; fourmvbptab = get_bits(gb, 2); v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; } else { v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; v->qs_last = v->s.quarter_sample; v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV); v->s.mspel = v->s.quarter_sample; status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->s.mv_table_index = get_bits(gb, 2); v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; } if (v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->ttfrm = 0; if (v->vstransform) { v->ttmbf = get_bits1(gb); if (v->ttmbf) { v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; } } else { v->ttmbf = 1; v->ttfrm = TT_8X8; } break; } if (v->fcm != PROGRESSIVE && !v->s.quarter_sample) { v->range_x <<= 1; v->range_y <<= 1; } /* AC Syntax */ v->c_ac_table_index = decode012(gb); if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) { v->y_ac_table_index = decode012(gb); } /* DC Syntax */ v->s.dc_table_index = get_bits1(gb); if ((v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) && v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->bi_type = 0; if (v->s.pict_type == AV_PICTURE_TYPE_BI) { v->s.pict_type = AV_PICTURE_TYPE_B; v->bi_type = 1; } return 0; }
17,915
0
static int vivo_probe(AVProbeData *p) { const unsigned char *buf = p->buf; unsigned c, length = 0; // stream must start with packet of type 0 and sequence number 0 if (*buf++ != 0) return 0; // read at most 2 bytes of coded length c = *buf++; length = c & 0x7F; if (c & 0x80) { c = *buf++; length = (length << 7) | (c & 0x7F); } if (c & 0x80 || length > 1024 || length < 21) return 0; if (memcmp(buf, "\r\nVersion:Vivo/", 15)) return 0; buf += 15; if (*buf < '0' && *buf > '2') return 0; return AVPROBE_SCORE_MAX; }
17,916
0
static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time) { char buf[1024]; AVBPrint buf_script; OutputStream *ost; AVFormatContext *oc; int64_t total_size; AVCodecContext *enc; int frame_number, vid, i; double bitrate; int64_t pts = INT64_MIN; static int64_t last_time = -1; static int qp_histogram[52]; int hours, mins, secs, us; if (!print_stats && !is_last_report && !progress_avio) return; if (!is_last_report) { if (last_time == -1) { last_time = cur_time; return; } if ((cur_time - last_time) < 500000) return; last_time = cur_time; } oc = output_files[0]->ctx; total_size = avio_size(oc->pb); if (total_size <= 0) // FIXME improve avio_size() so it works with non seekable output too total_size = avio_tell(oc->pb); buf[0] = '\0'; vid = 0; av_bprint_init(&buf_script, 0, 1); for (i = 0; i < nb_output_streams; i++) { float q = -1; ost = output_streams[i]; enc = ost->enc_ctx; if (!ost->stream_copy && enc->coded_frame) q = enc->coded_frame->quality / (float)FF_QP2LAMBDA; if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q); av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", ost->file_index, ost->index, q); } if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { float fps, t = (cur_time-timer_start) / 1000000.0; frame_number = ost->frame_number; fps = t > 1 ? frame_number / t : 0; snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3.*f q=%3.1f ", frame_number, fps < 9.95, fps, q); av_bprintf(&buf_script, "frame=%d\n", frame_number); av_bprintf(&buf_script, "fps=%.1f\n", fps); av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", ost->file_index, ost->index, q); if (is_last_report) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L"); if (qp_hist) { int j; int qp = lrintf(q); if (qp >= 0 && qp < FF_ARRAY_ELEMS(qp_histogram)) qp_histogram[qp]++; for (j = 0; j < 32; j++) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log2(qp_histogram[j] + 1))); } if ((enc->flags&CODEC_FLAG_PSNR) && (enc->coded_frame || is_last_report)) { int j; double error, error_sum = 0; double scale, scale_sum = 0; double p; char type[3] = { 'Y','U','V' }; snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR="); for (j = 0; j < 3; j++) { if (is_last_report) { error = enc->error[j]; scale = enc->width * enc->height * 255.0 * 255.0 * frame_number; } else { error = enc->coded_frame->error[j]; scale = enc->width * enc->height * 255.0 * 255.0; } if (j) scale /= 4; error_sum += error; scale_sum += scale; p = psnr(error / scale); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], p); av_bprintf(&buf_script, "stream_%d_%d_psnr_%c=%2.2f\n", ost->file_index, ost->index, type[j] | 32, p); } p = psnr(error_sum / scale_sum); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum / scale_sum)); av_bprintf(&buf_script, "stream_%d_%d_psnr_all=%2.2f\n", ost->file_index, ost->index, p); } vid = 1; } /* compute min output value */ if (av_stream_get_end_pts(ost->st) != AV_NOPTS_VALUE) pts = FFMAX(pts, av_rescale_q(av_stream_get_end_pts(ost->st), ost->st->time_base, AV_TIME_BASE_Q)); if (is_last_report) nb_frames_drop += ost->last_droped; } secs = pts / AV_TIME_BASE; us = pts % AV_TIME_BASE; mins = secs / 60; secs %= 60; hours = mins / 60; mins %= 60; bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1; if (total_size < 0) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "size=N/A time="); else snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "size=%8.0fkB time=", total_size / 1024.0); snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%02d:%02d:%02d.%02d ", hours, mins, secs, (100 * us) / AV_TIME_BASE); if (bitrate < 0) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),"bitrate=N/A"); av_bprintf(&buf_script, "bitrate=N/A\n"); }else{ snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),"bitrate=%6.1fkbits/s", bitrate); av_bprintf(&buf_script, "bitrate=%6.1fkbits/s\n", bitrate); } if (total_size < 0) av_bprintf(&buf_script, "total_size=N/A\n"); else av_bprintf(&buf_script, "total_size=%"PRId64"\n", total_size); av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts); av_bprintf(&buf_script, "out_time=%02d:%02d:%02d.%06d\n", hours, mins, secs, us); if (nb_frames_dup || nb_frames_drop) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d", nb_frames_dup, nb_frames_drop); av_bprintf(&buf_script, "dup_frames=%d\n", nb_frames_dup); av_bprintf(&buf_script, "drop_frames=%d\n", nb_frames_drop); if (print_stats || is_last_report) { const char end = is_last_report ? '\n' : '\r'; if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) { fprintf(stderr, "%s %c", buf, end); } else av_log(NULL, AV_LOG_INFO, "%s %c", buf, end); fflush(stderr); } if (progress_avio) { av_bprintf(&buf_script, "progress=%s\n", is_last_report ? "end" : "continue"); avio_write(progress_avio, buf_script.str, FFMIN(buf_script.len, buf_script.size - 1)); avio_flush(progress_avio); av_bprint_finalize(&buf_script, NULL); if (is_last_report) { avio_closep(&progress_avio); } } if (is_last_report) print_final_stats(total_size); }
17,917
0
static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size) { put_flush_packet(bc); nut->last_packet_start= nut->packet_start; nut->packet_start+= nut->written_packet_size; nut->packet_size_pos = url_ftell(bc); nut->written_packet_size = max_size; /* packet header */ put_v(bc, nut->written_packet_size); /* forward ptr */ put_v(bc, nut->packet_start - nut->last_packet_start); /* backward ptr */ return 0; }
17,918
0
static int decode_mb_cavlc(H264Context *h){ MpegEncContext * const s = &h->s; int mb_xy; int partition_count; unsigned int mb_type, cbp; int dct8x8_allowed= h->pps.transform_8x8_mode; mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride; s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong? tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); cbp = 0; /* avoid warning. FIXME: find a solution without slowing down the code */ if(h->slice_type_nos != FF_I_TYPE){ if(s->mb_skip_run==-1) s->mb_skip_run= get_ue_golomb(&s->gb); if (s->mb_skip_run--) { if(FRAME_MBAFF && (s->mb_y&1) == 0){ if(s->mb_skip_run==0) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb); else predict_field_decoding_flag(h); } decode_mb_skip(h); return 0; } } if(FRAME_MBAFF){ if( (s->mb_y&1) == 0 ) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb); }else h->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME); h->prev_mb_skipped= 0; mb_type= get_ue_golomb(&s->gb); if(h->slice_type_nos == FF_B_TYPE){ if(mb_type < 23){ partition_count= b_mb_type_info[mb_type].partition_count; mb_type= b_mb_type_info[mb_type].type; }else{ mb_type -= 23; goto decode_intra_mb; } }else if(h->slice_type_nos == FF_P_TYPE){ if(mb_type < 5){ partition_count= p_mb_type_info[mb_type].partition_count; mb_type= p_mb_type_info[mb_type].type; }else{ mb_type -= 5; goto decode_intra_mb; } }else{ assert(h->slice_type_nos == FF_I_TYPE); if(h->slice_type == FF_SI_TYPE && mb_type) mb_type--; decode_intra_mb: if(mb_type > 25){ av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y); return -1; } partition_count=0; cbp= i_mb_type_info[mb_type].cbp; h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode; mb_type= i_mb_type_info[mb_type].type; } if(MB_FIELD) mb_type |= MB_TYPE_INTERLACED; h->slice_table[ mb_xy ]= h->slice_num; if(IS_INTRA_PCM(mb_type)){ unsigned int x, y; // We assume these blocks are very rare so we do not optimize it. align_get_bits(&s->gb); // The pixels are stored in the same order as levels in h->mb array. for(y=0; y<16; y++){ const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3); for(x=0; x<16; x++){ tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= get_bits(&s->gb, 8); } } for(y=0; y<8; y++){ const int index= 256 + 4*(y&3) + 32*(y>>2); for(x=0; x<8; x++){ tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8); } } for(y=0; y<8; y++){ const int index= 256 + 64 + 4*(y&3) + 32*(y>>2); for(x=0; x<8; x++){ tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8); } } // In deblocking, the quantizer is 0 s->current_picture.qscale_table[mb_xy]= 0; // All coeffs are present memset(h->non_zero_count[mb_xy], 16, 16); s->current_picture.mb_type[mb_xy]= mb_type; return 0; } if(MB_MBAFF){ h->ref_count[0] <<= 1; h->ref_count[1] <<= 1; } fill_caches(h, mb_type, 0); //mb_pred if(IS_INTRA(mb_type)){ int pred_mode; // init_top_left_availability(h); if(IS_INTRA4x4(mb_type)){ int i; int di = 1; if(dct8x8_allowed && get_bits1(&s->gb)){ mb_type |= MB_TYPE_8x8DCT; di = 4; } // fill_intra4x4_pred_table(h); for(i=0; i<16; i+=di){ int mode= pred_intra_mode(h, i); if(!get_bits1(&s->gb)){ const int rem_mode= get_bits(&s->gb, 3); mode = rem_mode + (rem_mode >= mode); } if(di==4) fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 ); else h->intra4x4_pred_mode_cache[ scan8[i] ] = mode; } write_back_intra_pred_mode(h); if( check_intra4x4_pred_mode(h) < 0) return -1; }else{ h->intra16x16_pred_mode= check_intra_pred_mode(h, h->intra16x16_pred_mode); if(h->intra16x16_pred_mode < 0) return -1; } pred_mode= check_intra_pred_mode(h, get_ue_golomb(&s->gb)); if(pred_mode < 0) return -1; h->chroma_pred_mode= pred_mode; }else if(partition_count==4){ int i, j, sub_partition_count[4], list, ref[2][4]; if(h->slice_type_nos == FF_B_TYPE){ for(i=0; i<4; i++){ h->sub_mb_type[i]= get_ue_golomb(&s->gb); if(h->sub_mb_type[i] >=13){ av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); return -1; } sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type; } if( IS_DIRECT(h->sub_mb_type[0]) || IS_DIRECT(h->sub_mb_type[1]) || IS_DIRECT(h->sub_mb_type[2]) || IS_DIRECT(h->sub_mb_type[3])) { pred_direct_motion(h, &mb_type); h->ref_cache[0][scan8[4]] = h->ref_cache[1][scan8[4]] = h->ref_cache[0][scan8[12]] = h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE; } }else{ assert(h->slice_type_nos == FF_P_TYPE); //FIXME SP correct ? for(i=0; i<4; i++){ h->sub_mb_type[i]= get_ue_golomb(&s->gb); if(h->sub_mb_type[i] >=4){ av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); return -1; } sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type; } } for(list=0; list<h->list_count; list++){ int ref_count= IS_REF0(mb_type) ? 1 : h->ref_count[list]; for(i=0; i<4; i++){ if(IS_DIRECT(h->sub_mb_type[i])) continue; if(IS_DIR(h->sub_mb_type[i], 0, list)){ unsigned int tmp = get_te0_golomb(&s->gb, ref_count); //FIXME init to 0 before and skip? if(tmp>=ref_count){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp); return -1; } ref[list][i]= tmp; }else{ //FIXME ref[list][i] = -1; } } } if(dct8x8_allowed) dct8x8_allowed = get_dct8x8_allowed(h); for(list=0; list<h->list_count; list++){ for(i=0; i<4; i++){ if(IS_DIRECT(h->sub_mb_type[i])) { h->ref_cache[list][ scan8[4*i] ] = h->ref_cache[list][ scan8[4*i]+1 ]; continue; } h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ]= h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i]; if(IS_DIR(h->sub_mb_type[i], 0, list)){ const int sub_mb_type= h->sub_mb_type[i]; const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1; for(j=0; j<sub_partition_count[i]; j++){ int mx, my; const int index= 4*i + block_width*j; int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ]; pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); if(IS_SUB_8X8(sub_mb_type)){ mv_cache[ 1 ][0]= mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx; mv_cache[ 1 ][1]= mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my; }else if(IS_SUB_8X4(sub_mb_type)){ mv_cache[ 1 ][0]= mx; mv_cache[ 1 ][1]= my; }else if(IS_SUB_4X8(sub_mb_type)){ mv_cache[ 8 ][0]= mx; mv_cache[ 8 ][1]= my; } mv_cache[ 0 ][0]= mx; mv_cache[ 0 ][1]= my; } }else{ uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0]; p[0] = p[1]= p[8] = p[9]= 0; } } } }else if(IS_DIRECT(mb_type)){ pred_direct_motion(h, &mb_type); dct8x8_allowed &= h->sps.direct_8x8_inference_flag; }else{ int list, mx, my, i; //FIXME we should set ref_idx_l? to 0 if we use that later ... if(IS_16X16(mb_type)){ for(list=0; list<h->list_count; list++){ unsigned int val; if(IS_DIR(mb_type, 0, list)){ val= get_te0_golomb(&s->gb, h->ref_count[list]); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1); } for(list=0; list<h->list_count; list++){ unsigned int val; if(IS_DIR(mb_type, 0, list)){ pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, val, 4); } } else if(IS_16X8(mb_type)){ for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ val= get_te0_golomb(&s->gb, h->ref_count[list]); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1); } } for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 4); } } }else{ assert(IS_8X16(mb_type)); for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ //FIXME optimize val= get_te0_golomb(&s->gb, h->ref_count[list]); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1); } } for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 4); } } } } if(IS_INTER(mb_type)) write_back_motion(h, mb_type); if(!IS_INTRA16x16(mb_type)){ cbp= get_ue_golomb(&s->gb); if(cbp > 47){ av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, s->mb_x, s->mb_y); return -1; } if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp[cbp]; else cbp= golomb_to_inter_cbp[cbp]; } h->cbp = cbp; if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){ if(get_bits1(&s->gb)) mb_type |= MB_TYPE_8x8DCT; } s->current_picture.mb_type[mb_xy]= mb_type; if(cbp || IS_INTRA16x16(mb_type)){ int i8x8, i4x4, chroma_idx; int dquant; GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr; const uint8_t *scan, *scan8x8, *dc_scan; // fill_non_zero_count_cache(h); if(IS_INTERLACED(mb_type)){ scan8x8= s->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0; scan= s->qscale ? h->field_scan : h->field_scan_q0; dc_scan= luma_dc_field_scan; }else{ scan8x8= s->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0; scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0; dc_scan= luma_dc_zigzag_scan; } dquant= get_se_golomb(&s->gb); if( dquant > 25 || dquant < -26 ){ av_log(h->s.avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y); return -1; } s->qscale += dquant; if(((unsigned)s->qscale) > 51){ if(s->qscale<0) s->qscale+= 52; else s->qscale-= 52; } h->chroma_qp[0]= get_chroma_qp(h, 0, s->qscale); h->chroma_qp[1]= get_chroma_qp(h, 1, s->qscale); if(IS_INTRA16x16(mb_type)){ if( decode_residual(h, h->intra_gb_ptr, h->mb, LUMA_DC_BLOCK_INDEX, dc_scan, h->dequant4_coeff[0][s->qscale], 16) < 0){ return -1; //FIXME continue if partitioned and other return -1 too } assert((cbp&15) == 0 || (cbp&15) == 15); if(cbp&15){ for(i8x8=0; i8x8<4; i8x8++){ for(i4x4=0; i4x4<4; i4x4++){ const int index= i4x4 + 4*i8x8; if( decode_residual(h, h->intra_gb_ptr, h->mb + 16*index, index, scan + 1, h->dequant4_coeff[0][s->qscale], 15) < 0 ){ return -1; } } } }else{ fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1); } }else{ for(i8x8=0; i8x8<4; i8x8++){ if(cbp & (1<<i8x8)){ if(IS_8x8DCT(mb_type)){ DCTELEM *buf = &h->mb[64*i8x8]; uint8_t *nnz; for(i4x4=0; i4x4<4; i4x4++){ if( decode_residual(h, gb, buf, i4x4+4*i8x8, scan8x8+16*i4x4, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 16) <0 ) return -1; } nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; nnz[0] += nnz[1] + nnz[8] + nnz[9]; }else{ for(i4x4=0; i4x4<4; i4x4++){ const int index= i4x4 + 4*i8x8; if( decode_residual(h, gb, h->mb + 16*index, index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16) <0 ){ return -1; } } } }else{ uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0; } } } if(cbp&0x30){ for(chroma_idx=0; chroma_idx<2; chroma_idx++) if( decode_residual(h, gb, h->mb + 256 + 16*4*chroma_idx, CHROMA_DC_BLOCK_INDEX, chroma_dc_scan, NULL, 4) < 0){ return -1; } } if(cbp&0x20){ for(chroma_idx=0; chroma_idx<2; chroma_idx++){ const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]]; for(i4x4=0; i4x4<4; i4x4++){ const int index= 16 + 4*chroma_idx + i4x4; if( decode_residual(h, gb, h->mb + 16*index, index, scan + 1, qmul, 15) < 0){ return -1; } } } }else{ uint8_t * const nnz= &h->non_zero_count_cache[0]; nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0; } }else{ uint8_t * const nnz= &h->non_zero_count_cache[0]; fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1); nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0; } s->current_picture.qscale_table[mb_xy]= s->qscale; write_back_non_zero_count(h); if(MB_MBAFF){ h->ref_count[0] >>= 1; h->ref_count[1] >>= 1; } return 0; }
17,919
0
static int read_dct_coeffs(GetBitContext *gb, int32_t block[64], const uint8_t *scan, const int32_t quant_matrices[16][64], int q) { int coef_list[128]; int mode_list[128]; int i, t, mask, bits, ccoef, mode, sign; int list_start = 64, list_end = 64, list_pos; int coef_count = 0; int coef_idx[64]; int quant_idx; const int32_t *quant; coef_list[list_end] = 4; mode_list[list_end++] = 0; coef_list[list_end] = 24; mode_list[list_end++] = 0; coef_list[list_end] = 44; mode_list[list_end++] = 0; coef_list[list_end] = 1; mode_list[list_end++] = 3; coef_list[list_end] = 2; mode_list[list_end++] = 3; coef_list[list_end] = 3; mode_list[list_end++] = 3; bits = get_bits(gb, 4) - 1; for (mask = 1 << bits; bits >= 0; mask >>= 1, bits--) { list_pos = list_start; while (list_pos < list_end) { if (!(mode_list[list_pos] | coef_list[list_pos]) || !get_bits1(gb)) { list_pos++; continue; } ccoef = coef_list[list_pos]; mode = mode_list[list_pos]; switch (mode) { case 0: coef_list[list_pos] = ccoef + 4; mode_list[list_pos] = 1; case 2: if (mode == 2) { coef_list[list_pos] = 0; mode_list[list_pos++] = 0; } for (i = 0; i < 4; i++, ccoef++) { if (get_bits1(gb)) { coef_list[--list_start] = ccoef; mode_list[ list_start] = 3; } else { if (!bits) { t = 1 - (get_bits1(gb) << 1); } else { t = get_bits(gb, bits) | mask; sign = -get_bits1(gb); t = (t ^ sign) - sign; } block[scan[ccoef]] = t; coef_idx[coef_count++] = ccoef; } } break; case 1: mode_list[list_pos] = 2; for (i = 0; i < 3; i++) { ccoef += 4; coef_list[list_end] = ccoef; mode_list[list_end++] = 2; } break; case 3: if (!bits) { t = 1 - (get_bits1(gb) << 1); } else { t = get_bits(gb, bits) | mask; sign = -get_bits1(gb); t = (t ^ sign) - sign; } block[scan[ccoef]] = t; coef_idx[coef_count++] = ccoef; coef_list[list_pos] = 0; mode_list[list_pos++] = 0; break; } } } if (q == -1) { quant_idx = get_bits(gb, 4); } else { quant_idx = q; } quant = quant_matrices[quant_idx]; block[0] = (block[0] * quant[0]) >> 11; for (i = 0; i < coef_count; i++) { int idx = coef_idx[i]; block[scan[idx]] = (block[scan[idx]] * quant[idx]) >> 11; } return 0; }
17,920
0
static int decode_rle(CamtasiaContext *c) { unsigned char *src = c->decomp_buf; unsigned char *output; int p1, p2, line=c->height, pos=0, i; output = c->pic.data[0] + (c->height - 1) * c->pic.linesize[0]; while(src < c->decomp_buf + c->decomp_size) { p1 = *src++; if(p1 == 0) { //Escape code p2 = *src++; if(p2 == 0) { //End-of-line output = c->pic.data[0] + (--line) * c->pic.linesize[0]; pos = 0; continue; } else if(p2 == 1) { //End-of-picture return 0; } else if(p2 == 2) { //Skip p1 = *src++; p2 = *src++; line -= p2; pos += p1; output = c->pic.data[0] + line * c->pic.linesize[0] + pos * (c->bpp / 8); continue; } // Copy data for(i = 0; i < p2 * (c->bpp / 8); i++) { *output++ = *src++; } // RLE8 copy is actually padded - and runs are not! if(c->bpp == 8 && (p2 & 1)) { src++; } pos += p2; } else { //Run of pixels int pix[3]; //original pixel switch(c->bpp){ case 8: pix[0] = *src++; break; case 16: pix[0] = *src++; pix[1] = *src++; break; case 24: pix[0] = *src++; pix[1] = *src++; pix[2] = *src++; break; } for(i = 0; i < p1; i++) { switch(c->bpp){ case 8: *output++ = pix[0]; break; case 16: *output++ = pix[0]; *output++ = pix[1]; break; case 24: *output++ = pix[0]; *output++ = pix[1]; *output++ = pix[2]; break; } } pos += p1; } } av_log(c->avctx, AV_LOG_ERROR, "Camtasia warning: no End-of-picture code\n"); return 1; }
17,921
0
decode_cabac_residual_internal(H264Context *h, int16_t *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff, int is_dc, int chroma422) { static const int significant_coeff_flag_offset[2][14] = { { 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718 }, { 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733 } }; static const int last_coeff_flag_offset[2][14] = { { 166+0, 166+15, 166+29, 166+44, 166+47, 417, 572+0, 572+15, 572+29, 690, 616+0, 616+15, 616+29, 748 }, { 338+0, 338+15, 338+29, 338+44, 338+47, 451, 864+0, 864+15, 864+29, 699, 908+0, 908+15, 908+29, 757 } }; static const int coeff_abs_level_m1_offset[14] = { 227+0, 227+10, 227+20, 227+30, 227+39, 426, 952+0, 952+10, 952+20, 708, 982+0, 982+10, 982+20, 766 }; static const uint8_t significant_coeff_flag_offset_8x8[2][63] = { { 0, 1, 2, 3, 4, 5, 5, 4, 4, 3, 3, 4, 4, 4, 5, 5, 4, 4, 4, 4, 3, 3, 6, 7, 7, 7, 8, 9,10, 9, 8, 7, 7, 6,11,12,13,11, 6, 7, 8, 9,14,10, 9, 8, 6,11, 12,13,11, 6, 9,14,10, 9,11,12,13,11,14,10,12 }, { 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 7, 7, 8, 4, 5, 6, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,11,12,11, 9, 9,10,10, 8,13,13, 9, 9,10,10, 8,13,13, 9, 9,10,10,14,14,14,14,14 } }; static const uint8_t sig_coeff_offset_dc[7] = { 0, 0, 1, 1, 2, 2, 2 }; /* node ctx: 0..3: abslevel1 (with abslevelgt1 == 0). * 4..7: abslevelgt1 + 3 (and abslevel1 doesn't matter). * map node ctx => cabac ctx for level=1 */ static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 }; /* map node ctx => cabac ctx for level>1 */ static const uint8_t coeff_abs_levelgt1_ctx[2][8] = { { 5, 5, 5, 5, 6, 7, 8, 9 }, { 5, 5, 5, 5, 6, 7, 8, 8 }, // 422/dc case }; static const uint8_t coeff_abs_level_transition[2][8] = { /* update node ctx after decoding a level=1 */ { 1, 2, 3, 3, 4, 5, 6, 7 }, /* update node ctx after decoding a level>1 */ { 4, 4, 4, 4, 5, 6, 7, 7 } }; int index[64]; int av_unused last; int coeff_count = 0; int node_ctx = 0; uint8_t *significant_coeff_ctx_base; uint8_t *last_coeff_ctx_base; uint8_t *abs_level_m1_ctx_base; #if !ARCH_X86 #define CABAC_ON_STACK #endif #ifdef CABAC_ON_STACK #define CC &cc CABACContext cc; cc.range = h->cabac.range; cc.low = h->cabac.low; cc.bytestream= h->cabac.bytestream; #else #define CC &h->cabac #endif significant_coeff_ctx_base = h->cabac_state + significant_coeff_flag_offset[MB_FIELD][cat]; last_coeff_ctx_base = h->cabac_state + last_coeff_flag_offset[MB_FIELD][cat]; abs_level_m1_ctx_base = h->cabac_state + coeff_abs_level_m1_offset[cat]; if( !is_dc && max_coeff == 64 ) { #define DECODE_SIGNIFICANCE( coefs, sig_off, last_off ) \ for(last= 0; last < coefs; last++) { \ uint8_t *sig_ctx = significant_coeff_ctx_base + sig_off; \ if( get_cabac( CC, sig_ctx )) { \ uint8_t *last_ctx = last_coeff_ctx_base + last_off; \ index[coeff_count++] = last; \ if( get_cabac( CC, last_ctx ) ) { \ last= max_coeff; \ break; \ } \ } \ }\ if( last == max_coeff -1 ) {\ index[coeff_count++] = last;\ } const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD]; #ifdef decode_significance coeff_count = decode_significance_8x8(CC, significant_coeff_ctx_base, index, last_coeff_ctx_base, sig_off); } else { if (is_dc && chroma422) { // dc 422 DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]); } else { coeff_count = decode_significance(CC, max_coeff, significant_coeff_ctx_base, index, last_coeff_ctx_base-significant_coeff_ctx_base); } #else DECODE_SIGNIFICANCE( 63, sig_off[last], ff_h264_last_coeff_flag_offset_8x8[last] ); } else { if (is_dc && chroma422) { // dc 422 DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]); } else { DECODE_SIGNIFICANCE(max_coeff - 1, last, last); } #endif } av_assert2(coeff_count > 0); if( is_dc ) { if( cat == 3 ) h->cbp_table[h->mb_xy] |= 0x40 << (n - CHROMA_DC_BLOCK_INDEX); else h->cbp_table[h->mb_xy] |= 0x100 << (n - LUMA_DC_BLOCK_INDEX); h->non_zero_count_cache[scan8[n]] = coeff_count; } else { if( max_coeff == 64 ) fill_rectangle(&h->non_zero_count_cache[scan8[n]], 2, 2, 8, coeff_count, 1); else { av_assert2( cat == 1 || cat == 2 || cat == 4 || cat == 7 || cat == 8 || cat == 11 || cat == 12 ); h->non_zero_count_cache[scan8[n]] = coeff_count; } } #define STORE_BLOCK(type) \ do { \ uint8_t *ctx = coeff_abs_level1_ctx[node_ctx] + abs_level_m1_ctx_base; \ \ int j= scantable[index[--coeff_count]]; \ \ if( get_cabac( CC, ctx ) == 0 ) { \ node_ctx = coeff_abs_level_transition[0][node_ctx]; \ if( is_dc ) { \ ((type*)block)[j] = get_cabac_bypass_sign( CC, -1); \ }else{ \ ((type*)block)[j] = (get_cabac_bypass_sign( CC, -qmul[j]) + 32) >> 6; \ } \ } else { \ int coeff_abs = 2; \ ctx = coeff_abs_levelgt1_ctx[is_dc && chroma422][node_ctx] + abs_level_m1_ctx_base; \ node_ctx = coeff_abs_level_transition[1][node_ctx]; \ \ while( coeff_abs < 15 && get_cabac( CC, ctx ) ) { \ coeff_abs++; \ } \ \ if( coeff_abs >= 15 ) { \ int j = 0; \ while( get_cabac_bypass( CC ) ) { \ j++; \ } \ \ coeff_abs=1; \ while( j-- ) { \ coeff_abs += coeff_abs + get_cabac_bypass( CC ); \ } \ coeff_abs+= 14; \ } \ \ if( is_dc ) { \ ((type*)block)[j] = get_cabac_bypass_sign( CC, -coeff_abs ); \ }else{ \ ((type*)block)[j] = ((int)(get_cabac_bypass_sign( CC, -coeff_abs ) * qmul[j] + 32)) >> 6; \ } \ } \ } while ( coeff_count ); if (h->pixel_shift) { STORE_BLOCK(int32_t) } else { STORE_BLOCK(int16_t) } #ifdef CABAC_ON_STACK h->cabac.range = cc.range ; h->cabac.low = cc.low ; h->cabac.bytestream= cc.bytestream; #endif }
17,922
1
static void gen_pool32axf (CPUMIPSState *env, DisasContext *ctx, int rt, int rs, int *is_branch) { int extension = (ctx->opcode >> 6) & 0x3f; int minor = (ctx->opcode >> 12) & 0xf; uint32_t mips32_op; switch (extension) { case TEQ: mips32_op = OPC_TEQ; goto do_trap; case TGE: mips32_op = OPC_TGE; goto do_trap; case TGEU: mips32_op = OPC_TGEU; goto do_trap; case TLT: mips32_op = OPC_TLT; goto do_trap; case TLTU: mips32_op = OPC_TLTU; goto do_trap; case TNE: mips32_op = OPC_TNE; do_trap: gen_trap(ctx, mips32_op, rs, rt, -1); break; #ifndef CONFIG_USER_ONLY case MFC0: case MFC0 + 32: check_cp0_enabled(ctx); if (rt == 0) { /* Treat as NOP. */ break; } gen_mfc0(ctx, cpu_gpr[rt], rs, (ctx->opcode >> 11) & 0x7); break; case MTC0: case MTC0 + 32: check_cp0_enabled(ctx); { TCGv t0 = tcg_temp_new(); gen_load_gpr(t0, rt); gen_mtc0(ctx, t0, rs, (ctx->opcode >> 11) & 0x7); tcg_temp_free(t0); } break; #endif case 0x2c: switch (minor) { case SEB: gen_bshfl(ctx, OPC_SEB, rs, rt); break; case SEH: gen_bshfl(ctx, OPC_SEH, rs, rt); break; case CLO: mips32_op = OPC_CLO; goto do_cl; case CLZ: mips32_op = OPC_CLZ; do_cl: check_insn(ctx, ISA_MIPS32); gen_cl(ctx, mips32_op, rt, rs); break; case RDHWR: gen_rdhwr(ctx, rt, rs); break; case WSBH: gen_bshfl(ctx, OPC_WSBH, rs, rt); break; case MULT: mips32_op = OPC_MULT; goto do_mul; case MULTU: mips32_op = OPC_MULTU; goto do_mul; case DIV: mips32_op = OPC_DIV; goto do_div; case DIVU: mips32_op = OPC_DIVU; goto do_div; do_div: check_insn(ctx, ISA_MIPS32); gen_muldiv(ctx, mips32_op, 0, rs, rt); break; case MADD: mips32_op = OPC_MADD; goto do_mul; case MADDU: mips32_op = OPC_MADDU; goto do_mul; case MSUB: mips32_op = OPC_MSUB; goto do_mul; case MSUBU: mips32_op = OPC_MSUBU; do_mul: check_insn(ctx, ISA_MIPS32); gen_muldiv(ctx, mips32_op, (ctx->opcode >> 14) & 3, rs, rt); break; default: goto pool32axf_invalid; } break; case 0x34: switch (minor) { case MFC2: case MTC2: case MFHC2: case MTHC2: case CFC2: case CTC2: generate_exception_err(ctx, EXCP_CpU, 2); break; default: goto pool32axf_invalid; } break; case 0x3c: switch (minor) { case JALR: case JALR_HB: gen_compute_branch (ctx, OPC_JALR, 4, rs, rt, 0); *is_branch = 1; break; case JALRS: case JALRS_HB: gen_compute_branch (ctx, OPC_JALRS, 4, rs, rt, 0); *is_branch = 1; break; default: goto pool32axf_invalid; } break; case 0x05: switch (minor) { case RDPGPR: check_cp0_enabled(ctx); check_insn(ctx, ISA_MIPS32R2); gen_load_srsgpr(rt, rs); break; case WRPGPR: check_cp0_enabled(ctx); check_insn(ctx, ISA_MIPS32R2); gen_store_srsgpr(rt, rs); break; default: goto pool32axf_invalid; } break; #ifndef CONFIG_USER_ONLY case 0x0d: switch (minor) { case TLBP: mips32_op = OPC_TLBP; goto do_cp0; case TLBR: mips32_op = OPC_TLBR; goto do_cp0; case TLBWI: mips32_op = OPC_TLBWI; goto do_cp0; case TLBWR: mips32_op = OPC_TLBWR; goto do_cp0; case WAIT: mips32_op = OPC_WAIT; goto do_cp0; case DERET: mips32_op = OPC_DERET; goto do_cp0; case ERET: mips32_op = OPC_ERET; do_cp0: gen_cp0(env, ctx, mips32_op, rt, rs); break; default: goto pool32axf_invalid; } break; case 0x1d: switch (minor) { case DI: check_cp0_enabled(ctx); { TCGv t0 = tcg_temp_new(); save_cpu_state(ctx, 1); gen_helper_di(t0, cpu_env); gen_store_gpr(t0, rs); /* Stop translation as we may have switched the execution mode */ ctx->bstate = BS_STOP; tcg_temp_free(t0); } break; case EI: check_cp0_enabled(ctx); { TCGv t0 = tcg_temp_new(); save_cpu_state(ctx, 1); gen_helper_ei(t0, cpu_env); gen_store_gpr(t0, rs); /* Stop translation as we may have switched the execution mode */ ctx->bstate = BS_STOP; tcg_temp_free(t0); } break; default: goto pool32axf_invalid; } break; #endif case 0x2d: switch (minor) { case SYNC: /* NOP */ break; case SYSCALL: generate_exception(ctx, EXCP_SYSCALL); ctx->bstate = BS_STOP; break; case SDBBP: check_insn(ctx, ISA_MIPS32); if (!(ctx->hflags & MIPS_HFLAG_DM)) { generate_exception(ctx, EXCP_DBp); } else { generate_exception(ctx, EXCP_DBp); } break; default: goto pool32axf_invalid; } break; case 0x35: switch (minor & 3) { case MFHI32: gen_HILO(ctx, OPC_MFHI, minor >> 2, rs); break; case MFLO32: gen_HILO(ctx, OPC_MFLO, minor >> 2, rs); break; case MTHI32: gen_HILO(ctx, OPC_MTHI, minor >> 2, rs); break; case MTLO32: gen_HILO(ctx, OPC_MTLO, minor >> 2, rs); break; default: goto pool32axf_invalid; } break; default: pool32axf_invalid: MIPS_INVAL("pool32axf"); generate_exception(ctx, EXCP_RI); break; } }
17,923
1
static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) { MpegTSWrite *ts = s->priv_data; uint8_t data[SECTION_LENGTH], *q, *desc_length_ptr, *program_info_length_ptr; int val, stream_type, i, err = 0; q = data; put16(&q, 0xe000 | service->pcr_pid); program_info_length_ptr = q; q += 2; /* patched after */ /* put program info here */ val = 0xf000 | (q - program_info_length_ptr - 2); program_info_length_ptr[0] = val >> 8; program_info_length_ptr[1] = val; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MpegTSWriteStream *ts_st = st->priv_data; AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); if (q - data > SECTION_LENGTH - 32) { err = 1; break; } switch (st->codec->codec_id) { case AV_CODEC_ID_MPEG1VIDEO: case AV_CODEC_ID_MPEG2VIDEO: stream_type = STREAM_TYPE_VIDEO_MPEG2; break; case AV_CODEC_ID_MPEG4: stream_type = STREAM_TYPE_VIDEO_MPEG4; break; case AV_CODEC_ID_H264: stream_type = STREAM_TYPE_VIDEO_H264; break; case AV_CODEC_ID_HEVC: stream_type = STREAM_TYPE_VIDEO_HEVC; break; case AV_CODEC_ID_CAVS: stream_type = STREAM_TYPE_VIDEO_CAVS; break; case AV_CODEC_ID_DIRAC: stream_type = STREAM_TYPE_VIDEO_DIRAC; break; case AV_CODEC_ID_VC1: stream_type = STREAM_TYPE_VIDEO_VC1; break; case AV_CODEC_ID_MP2: case AV_CODEC_ID_MP3: stream_type = STREAM_TYPE_AUDIO_MPEG1; break; case AV_CODEC_ID_AAC: stream_type = (ts->flags & MPEGTS_FLAG_AAC_LATM) ? STREAM_TYPE_AUDIO_AAC_LATM : STREAM_TYPE_AUDIO_AAC; break; case AV_CODEC_ID_AAC_LATM: stream_type = STREAM_TYPE_AUDIO_AAC_LATM; break; case AV_CODEC_ID_AC3: stream_type = STREAM_TYPE_AUDIO_AC3; break; case AV_CODEC_ID_DTS: stream_type = STREAM_TYPE_AUDIO_DTS; break; case AV_CODEC_ID_TRUEHD: stream_type = STREAM_TYPE_AUDIO_TRUEHD; break; case AV_CODEC_ID_OPUS: stream_type = STREAM_TYPE_PRIVATE_DATA; break; default: stream_type = STREAM_TYPE_PRIVATE_DATA; break; } *q++ = stream_type; put16(&q, 0xe000 | ts_st->pid); desc_length_ptr = q; q += 2; /* patched after */ /* write optional descriptors here */ switch (st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if (st->codec->codec_id==AV_CODEC_ID_EAC3) { *q++=0x7a; // EAC3 descriptor see A038 DVB SI *q++=1; // 1 byte, all flags sets to 0 *q++=0; // omit all fields... } if (st->codec->codec_id==AV_CODEC_ID_S302M) { *q++ = 0x05; /* MPEG-2 registration descriptor*/ *q++ = 4; *q++ = 'B'; *q++ = 'S'; *q++ = 'S'; *q++ = 'D'; } if (st->codec->codec_id==AV_CODEC_ID_OPUS) { /* 6 bytes registration descriptor, 4 bytes Opus audio descriptor */ if (q - data > SECTION_LENGTH - 6 - 4) { err = 1; break; } *q++ = 0x05; /* MPEG-2 registration descriptor*/ *q++ = 4; *q++ = 'O'; *q++ = 'p'; *q++ = 'u'; *q++ = 's'; *q++ = 0x7f; /* DVB extension descriptor */ *q++ = 2; *q++ = 0x80; if (st->codec->extradata && st->codec->extradata_size >= 19) { if (st->codec->extradata[18] == 0 && st->codec->channels <= 2) { /* RTP mapping family */ *q++ = st->codec->channels; } else if (st->codec->extradata[18] == 1 && st->codec->channels <= 8 && st->codec->extradata_size >= 21 + st->codec->channels) { static const uint8_t coupled_stream_counts[9] = { 1, 0, 1, 1, 2, 2, 2, 3, 3 }; static const uint8_t channel_map_a[8][8] = { {0}, {0, 1}, {0, 2, 1}, {0, 1, 2, 3}, {0, 4, 1, 2, 3}, {0, 4, 1, 2, 3, 5}, {0, 4, 1, 2, 3, 5, 6}, {0, 6, 1, 2, 3, 4, 5, 7}, }; static const uint8_t channel_map_b[8][8] = { {0}, {0, 1}, {0, 1, 2}, {0, 1, 2, 3}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 4, 5, 6}, {0, 1, 2, 3, 4, 5, 6, 7}, }; /* Vorbis mapping family */ if (st->codec->extradata[19] == st->codec->channels - coupled_stream_counts[st->codec->channels] && st->codec->extradata[20] == coupled_stream_counts[st->codec->channels] && memcmp(&st->codec->extradata[21], channel_map_a[st->codec->channels], st->codec->channels) == 0) { *q++ = st->codec->channels; } else if (st->codec->channels >= 2 && st->codec->extradata[19] == st->codec->channels && st->codec->extradata[20] == 0 && memcmp(&st->codec->extradata[21], channel_map_b[st->codec->channels], st->codec->channels) == 0) { *q++ = st->codec->channels | 0x80; } else { /* Unsupported, could write an extended descriptor here */ av_log(s, AV_LOG_ERROR, "Unsupported Opus Vorbis-style channel mapping"); *q++ = 0xff; } } else { /* Unsupported */ av_log(s, AV_LOG_ERROR, "Unsupported Opus channel mapping for family %d", st->codec->extradata[18]); *q++ = 0xff; } } else if (st->codec->channels <= 2) { /* Assume RTP mapping family */ *q++ = st->codec->channels; } else { /* Unsupported */ av_log(s, AV_LOG_ERROR, "Unsupported Opus channel mapping"); *q++ = 0xff; } } if (lang) { char *p; char *next = lang->value; uint8_t *len_ptr; *q++ = 0x0a; /* ISO 639 language descriptor */ len_ptr = q++; *len_ptr = 0; for (p = lang->value; next && *len_ptr < 255 / 4 * 4; p = next + 1) { if (q - data > SECTION_LENGTH - 4) { err = 1; break; } next = strchr(p, ','); if (strlen(p) != 3 && (!next || next != p + 3)) continue; /* not a 3-letter code */ *q++ = *p++; *q++ = *p++; *q++ = *p++; if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS) *q++ = 0x01; else if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) *q++ = 0x02; else if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED) *q++ = 0x03; else *q++ = 0; /* undefined type */ *len_ptr += 4; } if (*len_ptr == 0) q -= 2; /* no language codes were written */ } break; case AVMEDIA_TYPE_SUBTITLE: { const char default_language[] = "und"; const char *language = lang && strlen(lang->value) >= 3 ? lang->value : default_language; if (st->codec->codec_id == AV_CODEC_ID_DVB_SUBTITLE) { uint8_t *len_ptr; int extradata_copied = 0; *q++ = 0x59; /* subtitling_descriptor */ len_ptr = q++; while (strlen(language) >= 3) { if (sizeof(data) - (q - data) < 8) { /* 8 bytes per DVB subtitle substream data */ err = 1; break; } *q++ = *language++; *q++ = *language++; *q++ = *language++; /* Skip comma */ if (*language != '\0') language++; if (st->codec->extradata_size - extradata_copied >= 5) { *q++ = st->codec->extradata[extradata_copied + 4]; /* subtitling_type */ memcpy(q, st->codec->extradata + extradata_copied, 4); /* composition_page_id and ancillary_page_id */ extradata_copied += 5; q += 4; } else { /* subtitling_type: * 0x10 - normal with no monitor aspect ratio criticality * 0x20 - for the hard of hearing with no monitor aspect ratio criticality */ *q++ = (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED) ? 0x20 : 0x10; if ((st->codec->extradata_size == 4) && (extradata_copied == 0)) { /* support of old 4-byte extradata format */ memcpy(q, st->codec->extradata, 4); /* composition_page_id and ancillary_page_id */ extradata_copied += 4; q += 4; } else { put16(&q, 1); /* composition_page_id */ put16(&q, 1); /* ancillary_page_id */ } } } *len_ptr = q - len_ptr - 1; } else if (st->codec->codec_id == AV_CODEC_ID_DVB_TELETEXT) { uint8_t *len_ptr = NULL; int extradata_copied = 0; /* The descriptor tag. teletext_descriptor */ *q++ = 0x56; len_ptr = q++; while (strlen(language) >= 3 && q - data < sizeof(data) - 6) { *q++ = *language++; *q++ = *language++; *q++ = *language++; /* Skip comma */ if (*language != '\0') language++; if (st->codec->extradata_size - 1 > extradata_copied) { memcpy(q, st->codec->extradata + extradata_copied, 2); extradata_copied += 2; q += 2; } else { /* The Teletext descriptor: * teletext_type: This 5-bit field indicates the type of Teletext page indicated. (0x01 Initial Teletext page) * teletext_magazine_number: This is a 3-bit field which identifies the magazine number. * teletext_page_number: This is an 8-bit field giving two 4-bit hex digits identifying the page number. */ *q++ = 0x08; *q++ = 0x00; } } *len_ptr = q - len_ptr - 1; } } break; case AVMEDIA_TYPE_VIDEO: if (stream_type == STREAM_TYPE_VIDEO_DIRAC) { *q++ = 0x05; /*MPEG-2 registration descriptor*/ *q++ = 4; *q++ = 'd'; *q++ = 'r'; *q++ = 'a'; *q++ = 'c'; } else if (stream_type == STREAM_TYPE_VIDEO_VC1) { *q++ = 0x05; /*MPEG-2 registration descriptor*/ *q++ = 4; *q++ = 'V'; *q++ = 'C'; *q++ = '-'; *q++ = '1'; } break; case AVMEDIA_TYPE_DATA: if (st->codec->codec_id == AV_CODEC_ID_SMPTE_KLV) { *q++ = 0x05; /* MPEG-2 registration descriptor */ *q++ = 4; *q++ = 'K'; *q++ = 'L'; *q++ = 'V'; *q++ = 'A'; } break; } val = 0xf000 | (q - desc_length_ptr - 2); desc_length_ptr[0] = val >> 8; desc_length_ptr[1] = val; } if (err) av_log(s, AV_LOG_ERROR, "The PMT section cannot fit stream %d and all following streams.\n" "Try reducing the number of languages in the audio streams " "or the total number of streams.\n", i); mpegts_write_section1(&service->pmt, PMT_TID, service->sid, ts->tables_version, 0, 0, data, q - data); return 0; }
17,924
1
static void ahci_reset_port(AHCIState *s, int port) { AHCIDevice *d = &s->dev[port]; AHCIPortRegs *pr = &d->port_regs; IDEState *ide_state = &d->port.ifs[0]; int i; DPRINTF(port, "reset port\n"); ide_bus_reset(&d->port); ide_state->ncq_queues = AHCI_MAX_CMDS; pr->scr_stat = 0; pr->scr_err = 0; pr->scr_act = 0; d->busy_slot = -1; d->init_d2h_sent = 0; ide_state = &s->dev[port].port.ifs[0]; if (!ide_state->bs) { return; /* reset ncq queue */ for (i = 0; i < AHCI_MAX_CMDS; i++) { NCQTransferState *ncq_tfs = &s->dev[port].ncq_tfs[i]; if (ncq_tfs->aiocb) { bdrv_aio_cancel(ncq_tfs->aiocb); ncq_tfs->aiocb = NULL; qemu_sglist_destroy(&ncq_tfs->sglist); ncq_tfs->used = 0; s->dev[port].port_state = STATE_RUN; if (!ide_state->bs) { s->dev[port].port_regs.sig = 0; ide_state->status = SEEK_STAT | WRERR_STAT; } else if (ide_state->drive_kind == IDE_CD) { s->dev[port].port_regs.sig = SATA_SIGNATURE_CDROM; ide_state->lcyl = 0x14; ide_state->hcyl = 0xeb; DPRINTF(port, "set lcyl = %d\n", ide_state->lcyl); ide_state->status = SEEK_STAT | WRERR_STAT | READY_STAT; } else { s->dev[port].port_regs.sig = SATA_SIGNATURE_DISK; ide_state->status = SEEK_STAT | WRERR_STAT; ide_state->error = 1; ahci_init_d2h(d);
17,926
1
int mjpeg_init(MpegEncContext *s) { MJpegContext *m; m = malloc(sizeof(MJpegContext)); if (!m) return -1; /* build all the huffman tables */ build_huffman_codes(m->huff_size_dc_luminance, m->huff_code_dc_luminance, bits_dc_luminance, val_dc_luminance); build_huffman_codes(m->huff_size_dc_chrominance, m->huff_code_dc_chrominance, bits_dc_chrominance, val_dc_chrominance); build_huffman_codes(m->huff_size_ac_luminance, m->huff_code_ac_luminance, bits_ac_luminance, val_ac_luminance); build_huffman_codes(m->huff_size_ac_chrominance, m->huff_code_ac_chrominance, bits_ac_chrominance, val_ac_chrominance); s->mjpeg_ctx = m; return 0; }
17,927
1
static void *bochs_bios_init(void) { void *fw_cfg; uint8_t *smbios_table; size_t smbios_len; uint64_t *numa_fw_cfg; int i, j; fw_cfg = fw_cfg_init(BIOS_CFG_IOPORT, BIOS_CFG_IOPORT + 1, 0, 0); fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1); fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_ACPI_TABLES, (uint8_t *)acpi_tables, acpi_tables_len); fw_cfg_add_i32(fw_cfg, FW_CFG_IRQ0_OVERRIDE, kvm_allows_irq0_override()); smbios_table = smbios_get_table(&smbios_len); if (smbios_table) fw_cfg_add_bytes(fw_cfg, FW_CFG_SMBIOS_ENTRIES, smbios_table, smbios_len); fw_cfg_add_bytes(fw_cfg, FW_CFG_E820_TABLE, (uint8_t *)&e820_table, sizeof(e820_table)); fw_cfg_add_bytes(fw_cfg, FW_CFG_HPET, (uint8_t *)&hpet_cfg, sizeof(struct hpet_fw_config)); /* allocate memory for the NUMA channel: one (64bit) word for the number * of nodes, one word for each VCPU->node and one word for each node to * hold the amount of memory. */ numa_fw_cfg = g_new0(uint64_t, 1 + max_cpus + nb_numa_nodes); numa_fw_cfg[0] = cpu_to_le64(nb_numa_nodes); for (i = 0; i < max_cpus; i++) { for (j = 0; j < nb_numa_nodes; j++) { if (test_bit(i, node_cpumask[j])) { numa_fw_cfg[i + 1] = cpu_to_le64(j); break; } } } for (i = 0; i < nb_numa_nodes; i++) { numa_fw_cfg[max_cpus + 1 + i] = cpu_to_le64(node_mem[i]); } fw_cfg_add_bytes(fw_cfg, FW_CFG_NUMA, (uint8_t *)numa_fw_cfg, (1 + max_cpus + nb_numa_nodes) * sizeof(*numa_fw_cfg)); return fw_cfg; }
17,928
1
static CharDriverState *gd_vc_handler(ChardevVC *vc, Error **errp) { ChardevCommon *common = qapi_ChardevVC_base(vc); CharDriverState *chr; chr = qemu_chr_alloc(common, errp); if (!chr) { chr->chr_write = gd_vc_chr_write; chr->chr_set_echo = gd_vc_chr_set_echo; /* Temporary, until gd_vc_vte_init runs. */ chr->opaque = g_new0(VirtualConsole, 1); vcs[nb_vcs++] = chr; return chr;
17,930
1
int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx) { if (!strcasecmp(color_string, "random") || !strcasecmp(color_string, "bikeshed")) { int rgba = ff_random_get_seed(); rgba_color[0] = rgba >> 24; rgba_color[1] = rgba >> 16; rgba_color[2] = rgba >> 8; rgba_color[3] = rgba; } else if (!strncmp(color_string, "0x", 2)) { char *tail; int len = strlen(color_string); int rgba = strtol(color_string, &tail, 16); if (*tail || (len != 8 && len != 10)) { av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string); return -1; } if (len == 10) { rgba_color[3] = rgba; rgba >>= 8; } rgba_color[0] = rgba >> 16; rgba_color[1] = rgba >> 8; rgba_color[2] = rgba; } else { const ColorEntry *entry = bsearch(color_string, color_table, FF_ARRAY_ELEMS(color_table), sizeof(ColorEntry), color_table_compare); if (!entry) { av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string); return -1; } memcpy(rgba_color, entry->rgba_color, 4); } return 0; }
17,931
1
static av_cold int aac_encode_init(AVCodecContext *avctx) { AACEncContext *s = avctx->priv_data; int i; const uint8_t *sizes[2]; uint8_t grouping[AAC_MAX_CHANNELS]; int lengths[2]; avctx->frame_size = 1024; for (i = 0; i < 16; i++) if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[i]) break; if (i == 16) { av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", avctx->sample_rate); return -1; } if (avctx->channels > AAC_MAX_CHANNELS) { av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n", avctx->channels); return -1; } if (avctx->profile != FF_PROFILE_UNKNOWN && avctx->profile != FF_PROFILE_AAC_LOW) { av_log(avctx, AV_LOG_ERROR, "Unsupported profile %d\n", avctx->profile); return -1; } if (1024.0 * avctx->bit_rate / avctx->sample_rate > 6144 * avctx->channels) { av_log(avctx, AV_LOG_ERROR, "Too many bits per frame requested\n"); return -1; } s->samplerate_index = i; dsputil_init(&s->dsp, avctx); ff_mdct_init(&s->mdct1024, 11, 0, 1.0); ff_mdct_init(&s->mdct128, 8, 0, 1.0); // window init ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128); ff_init_ff_sine_windows(10); ff_init_ff_sine_windows(7); s->chan_map = aac_chan_configs[avctx->channels-1]; s->samples = av_malloc(2 * 1024 * avctx->channels * sizeof(s->samples[0])); s->cpe = av_mallocz(sizeof(ChannelElement) * s->chan_map[0]); avctx->extradata = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE); avctx->extradata_size = 5; put_audio_specific_config(avctx); sizes[0] = swb_size_1024[i]; sizes[1] = swb_size_128[i]; lengths[0] = ff_aac_num_swb_1024[i]; lengths[1] = ff_aac_num_swb_128[i]; for (i = 0; i < s->chan_map[0]; i++) grouping[i] = s->chan_map[i + 1] == TYPE_CPE; ff_psy_init(&s->psy, avctx, 2, sizes, lengths, s->chan_map[0], grouping); s->psypp = ff_psy_preprocess_init(avctx); s->coder = &ff_aac_coders[2]; s->lambda = avctx->global_quality ? avctx->global_quality : 120; ff_aac_tableinit(); return 0; }
17,934
1
static int of_dpa_cmd_flow_add(OfDpa *of_dpa, uint64_t cookie, RockerTlv **flow_tlvs) { OfDpaFlow *flow = of_dpa_flow_find(of_dpa, cookie); int err = ROCKER_OK; if (flow) { return -ROCKER_EEXIST; } flow = of_dpa_flow_alloc(cookie); if (!flow) { return -ROCKER_ENOMEM; } err = of_dpa_cmd_flow_add_mod(of_dpa, flow, flow_tlvs); if (err) { g_free(flow); return err; } return of_dpa_flow_add(of_dpa, flow); }
17,935
1
static int epaf_read_header(AVFormatContext *s) { int le, sample_rate, codec, channels; AVStream *st; avio_skip(s->pb, 4); if (avio_rl32(s->pb)) return AVERROR_INVALIDDATA; le = avio_rl32(s->pb); if (le && le != 1) return AVERROR_INVALIDDATA; if (le) { sample_rate = avio_rl32(s->pb); codec = avio_rl32(s->pb); channels = avio_rl32(s->pb); } else { sample_rate = avio_rb32(s->pb); codec = avio_rb32(s->pb); channels = avio_rb32(s->pb); } if (!channels || !sample_rate) 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; switch (codec) { case 0: st->codecpar->codec_id = le ? AV_CODEC_ID_PCM_S16LE : AV_CODEC_ID_PCM_S16BE; break; case 2: st->codecpar->codec_id = AV_CODEC_ID_PCM_S8; break; case 1: avpriv_request_sample(s, "24-bit Paris PCM format"); default: return AVERROR_INVALIDDATA; } st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id); st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8; avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); if (avio_skip(s->pb, 2024) < 0) return AVERROR_INVALIDDATA; return 0; }
17,936
1
static void audio_init (void) { size_t i; int done = 0; const char *drvname; VMChangeStateEntry *e; AudioState *s = &glob_audio_state; if (s->drv) { return; } QLIST_INIT (&s->hw_head_out); QLIST_INIT (&s->hw_head_in); QLIST_INIT (&s->cap_head); atexit (audio_atexit); s->ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); if (!s->ts) { hw_error("Could not create audio timer\n"); } audio_process_options ("AUDIO", audio_options); s->nb_hw_voices_out = conf.fixed_out.nb_voices; s->nb_hw_voices_in = conf.fixed_in.nb_voices; if (s->nb_hw_voices_out <= 0) { dolog ("Bogus number of playback voices %d, setting to 1\n", s->nb_hw_voices_out); s->nb_hw_voices_out = 1; } if (s->nb_hw_voices_in <= 0) { dolog ("Bogus number of capture voices %d, setting to 0\n", s->nb_hw_voices_in); s->nb_hw_voices_in = 0; } { int def; drvname = audio_get_conf_str ("QEMU_AUDIO_DRV", NULL, &def); } if (drvname) { int found = 0; for (i = 0; i < ARRAY_SIZE (drvtab); i++) { if (!strcmp (drvname, drvtab[i]->name)) { done = !audio_driver_init (s, drvtab[i]); found = 1; break; } } if (!found) { dolog ("Unknown audio driver `%s'\n", drvname); dolog ("Run with -audio-help to list available drivers\n"); } } if (!done) { for (i = 0; !done && i < ARRAY_SIZE (drvtab); i++) { if (drvtab[i]->can_be_default) { done = !audio_driver_init (s, drvtab[i]); } } } if (!done) { done = !audio_driver_init (s, &no_audio_driver); if (!done) { hw_error("Could not initialize audio subsystem\n"); } else { dolog ("warning: Using timer based audio emulation\n"); } } if (conf.period.hertz <= 0) { if (conf.period.hertz < 0) { dolog ("warning: Timer period is negative - %d " "treating as zero\n", conf.period.hertz); } conf.period.ticks = 1; } else { conf.period.ticks = muldiv64 (1, get_ticks_per_sec (), conf.period.hertz); } e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); if (!e) { dolog ("warning: Could not register change state handler\n" "(Audio can continue looping even after stopping the VM)\n"); } QLIST_INIT (&s->card_head); vmstate_register (NULL, 0, &vmstate_audio, s); }
17,937
1
static void taihu_405ep_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *kernel_filename = machine->kernel_filename; const char *initrd_filename = machine->initrd_filename; char *filename; qemu_irq *pic; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *bios; MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories)); hwaddr ram_bases[2], ram_sizes[2]; long bios_size; target_ulong kernel_base, initrd_base; long kernel_size, initrd_size; int linux_boot; int fl_idx, fl_sectors; DriveInfo *dinfo; /* RAM is soldered to the board so the size cannot be changed */ memory_region_allocate_system_memory(&ram_memories[0], NULL, "taihu_405ep.ram-0", 0x04000000); ram_bases[0] = 0; ram_sizes[0] = 0x04000000; memory_region_allocate_system_memory(&ram_memories[1], NULL, "taihu_405ep.ram-1", 0x04000000); ram_bases[1] = 0x04000000; ram_sizes[1] = 0x04000000; ram_size = 0x08000000; #ifdef DEBUG_BOARD_INIT printf("%s: register cpu\n", __func__); #endif ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, 33333333, &pic, kernel_filename == NULL ? 0 : 1); /* allocate and load BIOS */ #ifdef DEBUG_BOARD_INIT printf("%s: register BIOS\n", __func__); #endif fl_idx = 0; #if defined(USE_FLASH_BIOS) dinfo = drive_get(IF_PFLASH, 0, fl_idx); if (dinfo) { bios_size = bdrv_getlength(dinfo->bdrv); /* XXX: should check that size is 2MB */ // bios_size = 2 * 1024 * 1024; fl_sectors = (bios_size + 65535) >> 16; #ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size %lx" " at addr %lx '%s' %d\n", fl_idx, bios_size, -bios_size, bdrv_get_device_name(dinfo->bdrv), fl_sectors); #endif pflash_cfi02_register((uint32_t)(-bios_size), NULL, "taihu_405ep.bios", bios_size, dinfo->bdrv, 65536, fl_sectors, 1, 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, 1); fl_idx++; } else #endif { #ifdef DEBUG_BOARD_INIT printf("Load BIOS from file\n"); #endif if (bios_name == NULL) bios_name = BIOS_FILENAME; bios = g_new(MemoryRegion, 1); memory_region_allocate_system_memory(bios, NULL, "taihu_405ep.bios", BIOS_SIZE); filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); g_free(filename); if (bios_size < 0 || bios_size > BIOS_SIZE) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } bios_size = (bios_size + 0xfff) & ~0xfff; memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios); } else if (!qtest_enabled()) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } memory_region_set_readonly(bios, true); } /* Register Linux flash */ dinfo = drive_get(IF_PFLASH, 0, fl_idx); if (dinfo) { bios_size = bdrv_getlength(dinfo->bdrv); /* XXX: should check that size is 32MB */ bios_size = 32 * 1024 * 1024; fl_sectors = (bios_size + 65535) >> 16; #ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size %lx" " at addr " TARGET_FMT_lx " '%s'\n", fl_idx, bios_size, (target_ulong)0xfc000000, bdrv_get_device_name(dinfo->bdrv)); #endif pflash_cfi02_register(0xfc000000, NULL, "taihu_405ep.flash", bios_size, dinfo->bdrv, 65536, fl_sectors, 1, 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, 1); fl_idx++; } /* Register CLPD & LCD display */ #ifdef DEBUG_BOARD_INIT printf("%s: register CPLD\n", __func__); #endif taihu_cpld_init(sysmem, 0x50100000); /* Load kernel */ linux_boot = (kernel_filename != NULL); if (linux_boot) { #ifdef DEBUG_BOARD_INIT printf("%s: load kernel\n", __func__); #endif kernel_base = KERNEL_LOAD_ADDR; /* now we can load the kernel */ kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } /* load initrd */ if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; } #ifdef DEBUG_BOARD_INIT printf("%s: Done\n", __func__); #endif }
17,939
1
static void qmp_input_type_any(Visitor *v, const char *name, QObject **obj, Error **errp) { QmpInputVisitor *qiv = to_qiv(v); QObject *qobj = qmp_input_get_object(qiv, name, true); qobject_incref(qobj); *obj = qobj;
17,940
1
PPC_OP(clear_xer_cr) { xer_so = 0; xer_ov = 0; xer_ca = 0; RETURN(); }
17,941
1
static void flush_encoders(void) { int i, ret; for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; AVCodecContext *enc = ost->enc_ctx; OutputFile *of = output_files[ost->file_index]; if (!ost->encoding_needed) continue; // Try to enable encoding with no input frames. // Maybe we should just let encoding fail instead. if (!ost->initialized) { FilterGraph *fg = ost->filter->graph; char error[1024]; av_log(NULL, AV_LOG_WARNING, "Finishing stream %d:%d without any data written to it.\n", ost->file_index, ost->st->index); if (ost->filter && !fg->graph) { int x; for (x = 0; x < fg->nb_inputs; x++) { InputFilter *ifilter = fg->inputs[x]; if (ifilter->format < 0) { AVCodecParameters *par = ifilter->ist->st->codecpar; // We never got any input. Set a fake format, which will // come from libavformat. ifilter->format = par->format; ifilter->sample_rate = par->sample_rate; ifilter->channels = par->channels; ifilter->channel_layout = par->channel_layout; ifilter->width = par->width; ifilter->height = par->height; ifilter->sample_aspect_ratio = par->sample_aspect_ratio; } } if (!ifilter_has_all_input_formats(fg)) continue; ret = configure_filtergraph(fg); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error configuring filter graph\n"); exit_program(1); } finish_output_stream(ost); } ret = init_output_stream(ost, error, sizeof(error)); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n", ost->file_index, ost->index, error); exit_program(1); } } if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1) continue; #if FF_API_LAVF_FMT_RAWPICTURE if (enc->codec_type == AVMEDIA_TYPE_VIDEO && (of->ctx->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == AV_CODEC_ID_RAWVIDEO) continue; #endif if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO) continue; avcodec_send_frame(enc, NULL); for (;;) { const char *desc = NULL; AVPacket pkt; int pkt_size; switch (enc->codec_type) { case AVMEDIA_TYPE_AUDIO: desc = "audio"; break; case AVMEDIA_TYPE_VIDEO: desc = "video"; break; default: av_assert0(0); } av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; update_benchmark(NULL); ret = avcodec_receive_packet(enc, &pkt); update_benchmark("flush_%s %d.%d", desc, ost->file_index, ost->index); if (ret < 0 && ret != AVERROR_EOF) { av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n", desc, av_err2str(ret)); exit_program(1); } if (ost->logfile && enc->stats_out) { fprintf(ost->logfile, "%s", enc->stats_out); } if (ret == AVERROR_EOF) { break; } if (ost->finished & MUXER_FINISHED) { av_packet_unref(&pkt); continue; } av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase); pkt_size = pkt.size; output_packet(of, &pkt, ost); if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) { do_video_stats(ost, pkt_size); } } } }
17,942
1
int fw_cfg_add_i32(FWCfgState *s, uint16_t key, uint32_t value) { uint32_t *copy; copy = g_malloc(sizeof(value)); *copy = cpu_to_le32(value); return fw_cfg_add_bytes(s, key, (uint8_t *)copy, sizeof(value)); }
17,944
1
static void use_normal_update_speed(WmallDecodeCtx *s, int ich) { int ilms, recent, icoef; s->update_speed[ich] = 8; for (ilms = s->cdlms_ttl[ich]; ilms >= 0; ilms--) { recent = s->cdlms[ich][ilms].recent; if (s->bV3RTM) { for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++) s->cdlms[ich][ilms].lms_updates[icoef + recent] /= 2; } else { for (icoef = 0; icoef < s->cdlms[ich][ilms].order; icoef++) s->cdlms[ich][ilms].lms_updates[icoef] /= 2; } } }
17,945
1
static int ram_save_target_page(RAMState *rs, PageSearchStatus *pss, bool last_stage, ram_addr_t dirty_ram_abs) { int res = 0; /* Check the pages is dirty and if it is send it */ if (migration_bitmap_clear_dirty(rs, dirty_ram_abs)) { unsigned long *unsentmap; /* * If xbzrle is on, stop using the data compression after first * round of migration even if compression is enabled. In theory, * xbzrle can do better than compression. */ if (migrate_use_compression() && (rs->ram_bulk_stage || !migrate_use_xbzrle())) { res = ram_save_compressed_page(rs, pss, last_stage); } else { res = ram_save_page(rs, pss, last_stage); } if (res < 0) { return res; } unsentmap = atomic_rcu_read(&rs->ram_bitmap)->unsentmap; if (unsentmap) { clear_bit(dirty_ram_abs >> TARGET_PAGE_BITS, unsentmap); } } return res; }
17,946
1
static int vmdk_parent_open(BlockDriverState *bs, const char * filename) { BDRVVmdkState *s = bs->opaque; char *p_name; char desc[DESC_SIZE]; char parent_img_name[1024]; /* the descriptor offset = 0x200 */ if (bdrv_pread(s->hd, 0x200, desc, DESC_SIZE) != DESC_SIZE) return -1; if ((p_name = strstr(desc,"parentFileNameHint")) != 0) { char *end_name; struct stat file_buf; p_name += sizeof("parentFileNameHint") + 1; if ((end_name = strchr(p_name,'\"')) == 0) return -1; strncpy(s->hd->backing_file, p_name, end_name - p_name); if (stat(s->hd->backing_file, &file_buf) != 0) { path_combine(parent_img_name, sizeof(parent_img_name), filename, s->hd->backing_file); } else { strcpy(parent_img_name, s->hd->backing_file); } s->hd->backing_hd = bdrv_new(""); if (!s->hd->backing_hd) { failure: bdrv_close(s->hd); return -1; } if (bdrv_open(s->hd->backing_hd, parent_img_name, 0) < 0) goto failure; } return 0; }
17,947
1
static int sd_snapshot_list(BlockDriverState *bs, QEMUSnapshotInfo **psn_tab) { Error *local_err = NULL; BDRVSheepdogState *s = bs->opaque; SheepdogReq req; int fd, nr = 1024, ret, max = BITS_TO_LONGS(SD_NR_VDIS) * sizeof(long); QEMUSnapshotInfo *sn_tab = NULL; unsigned wlen, rlen; int found = 0; static SheepdogInode inode; unsigned long *vdi_inuse; unsigned int start_nr; uint64_t hval; uint32_t vid; vdi_inuse = g_malloc(max); fd = connect_to_sdog(s, &local_err); if (fd < 0) { error_report("%s", error_get_pretty(local_err));; error_free(local_err); ret = fd; goto out; } rlen = max; wlen = 0; memset(&req, 0, sizeof(req)); req.opcode = SD_OP_READ_VDIS; req.data_length = max; ret = do_req(fd, s->aio_context, (SheepdogReq *)&req, vdi_inuse, &wlen, &rlen); closesocket(fd); if (ret) { goto out; } sn_tab = g_malloc0(nr * sizeof(*sn_tab)); /* calculate a vdi id with hash function */ hval = fnv_64a_buf(s->name, strlen(s->name), FNV1A_64_INIT); start_nr = hval & (SD_NR_VDIS - 1); fd = connect_to_sdog(s, &local_err); if (fd < 0) { error_report("%s", error_get_pretty(local_err));; error_free(local_err); ret = fd; goto out; } for (vid = start_nr; found < nr; vid = (vid + 1) % SD_NR_VDIS) { if (!test_bit(vid, vdi_inuse)) { break; } /* we don't need to read entire object */ ret = read_object(fd, s->aio_context, (char *)&inode, vid_to_vdi_oid(vid), 0, SD_INODE_SIZE - sizeof(inode.data_vdi_id), 0, s->cache_flags); if (ret) { continue; } if (!strcmp(inode.name, s->name) && is_snapshot(&inode)) { sn_tab[found].date_sec = inode.snap_ctime >> 32; sn_tab[found].date_nsec = inode.snap_ctime & 0xffffffff; sn_tab[found].vm_state_size = inode.vm_state_size; sn_tab[found].vm_clock_nsec = inode.vm_clock_nsec; snprintf(sn_tab[found].id_str, sizeof(sn_tab[found].id_str), "%" PRIu32, inode.snap_id); pstrcpy(sn_tab[found].name, MIN(sizeof(sn_tab[found].name), sizeof(inode.tag)), inode.tag); found++; } } closesocket(fd); out: *psn_tab = sn_tab; g_free(vdi_inuse); if (ret < 0) { return ret; } return found; }
17,948
1
static void config_parse(GAConfig *config, int argc, char **argv) { const char *sopt = "hVvdm:p:l:f:F::b:s:t:D"; int opt_ind = 0, ch; const struct option lopt[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "dump-conf", 0, NULL, 'D' }, { "logfile", 1, NULL, 'l' }, { "pidfile", 1, NULL, 'f' }, #ifdef CONFIG_FSFREEZE { "fsfreeze-hook", 2, NULL, 'F' }, #endif { "verbose", 0, NULL, 'v' }, { "method", 1, NULL, 'm' }, { "path", 1, NULL, 'p' }, { "daemonize", 0, NULL, 'd' }, { "blacklist", 1, NULL, 'b' }, #ifdef _WIN32 { "service", 1, NULL, 's' }, #endif { "statedir", 1, NULL, 't' }, { NULL, 0, NULL, 0 } }; config->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL; while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) { switch (ch) { case 'm': g_free(config->method); config->method = g_strdup(optarg); break; case 'p': g_free(config->channel_path); config->channel_path = g_strdup(optarg); break; case 'l': g_free(config->log_filepath); config->log_filepath = g_strdup(optarg); break; case 'f': g_free(config->pid_filepath); config->pid_filepath = g_strdup(optarg); break; #ifdef CONFIG_FSFREEZE case 'F': g_free(config->fsfreeze_hook); config->fsfreeze_hook = g_strdup(optarg ?: QGA_FSFREEZE_HOOK_DEFAULT); break; #endif case 't': g_free(config->state_dir); config->state_dir = g_strdup(optarg); break; case 'v': /* enable all log levels */ config->log_level = G_LOG_LEVEL_MASK; break; case 'V': printf("QEMU Guest Agent %s\n", QEMU_VERSION); exit(EXIT_SUCCESS); case 'd': config->daemonize = 1; break; case 'D': config->dumpconf = 1; break; case 'b': { if (is_help_option(optarg)) { qmp_for_each_command(ga_print_cmd, NULL); exit(EXIT_SUCCESS); } config->blacklist = g_list_concat(config->blacklist, split_list(optarg, ",")); break; } #ifdef _WIN32 case 's': config->service = optarg; if (strcmp(config->service, "install") == 0) { if (ga_install_vss_provider()) { exit(EXIT_FAILURE); } if (ga_install_service(config->channel_path, config->log_filepath, config->state_dir)) { exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } else if (strcmp(config->service, "uninstall") == 0) { ga_uninstall_vss_provider(); exit(ga_uninstall_service()); } else if (strcmp(config->service, "vss-install") == 0) { if (ga_install_vss_provider()) { exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } else if (strcmp(config->service, "vss-uninstall") == 0) { ga_uninstall_vss_provider(); exit(EXIT_SUCCESS); } else { printf("Unknown service command.\n"); exit(EXIT_FAILURE); } break; #endif case 'h': usage(argv[0]); exit(EXIT_SUCCESS); case '?': g_print("Unknown option, try '%s --help' for more information.\n", argv[0]); exit(EXIT_FAILURE); } } }
17,949
0
static void gen_abs(DisasContext *ctx) { int l1 = gen_new_label(); int l2 = gen_new_label(); tcg_gen_brcondi_tl(TCG_COND_GE, cpu_gpr[rA(ctx->opcode)], 0, l1); tcg_gen_neg_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_mov_tl(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]); gen_set_label(l2); if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); }
17,950
0
static void ga_channel_client_close(GAChannel *c) { g_assert(c->client_channel); g_io_channel_shutdown(c->client_channel, true, NULL); g_io_channel_unref(c->client_channel); c->client_channel = NULL; if (c->method == GA_CHANNEL_UNIX_LISTEN && c->listen_channel) { ga_channel_listen_add(c, 0, false); } }
17,951
0
static int omap_validate_tipb_addr(struct omap_mpu_state_s *s, target_phys_addr_t addr) { return range_covers_byte(0xfffb0000, 0xffff0000 - 0xfffb0000, addr); }
17,952
0
static int is_allocated_sectors(const uint8_t *buf, int n, int *pnum) { int v, i; if (n <= 0) { *pnum = 0; return 0; } v = is_not_zero(buf, 512); for(i = 1; i < n; i++) { buf += 512; if (v != is_not_zero(buf, 512)) break; } *pnum = i; return v; }
17,955
0
static void s390_virtio_blk_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass); k->init = s390_virtio_blk_init; dc->props = s390_virtio_blk_properties; dc->alias = "virtio-blk"; }
17,956
0
void do_info_vnc(Monitor *mon, QObject **ret_data) { if (vnc_display == NULL || vnc_display->display == NULL) { *ret_data = qobject_from_jsonf("{ 'enabled': false }"); } else { QDict *qdict; QList *clist; clist = qlist_new(); if (vnc_display->clients) { VncState *client = vnc_display->clients; while (client) { qdict = do_info_vnc_client(mon, client); if (qdict) qlist_append(clist, qdict); client = client->next; } } *ret_data = qobject_from_jsonf("{ 'enabled': true, 'clients': %p }", QOBJECT(clist)); assert(*ret_data != NULL); if (vnc_server_info_put(qobject_to_qdict(*ret_data)) < 0) { qobject_decref(*ret_data); *ret_data = NULL; } } }
17,957
0
static void breakpoint_invalidate(CPUArchState *env, target_ulong pc) { target_phys_addr_t addr; ram_addr_t ram_addr; MemoryRegionSection *section; addr = cpu_get_phys_page_debug(env, pc); section = phys_page_find(addr >> TARGET_PAGE_BITS); if (!(memory_region_is_ram(section->mr) || (section->mr->rom_device && section->mr->readable))) { return; } ram_addr = (memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK) + section_addr(section, addr); tb_invalidate_phys_page_range(ram_addr, ram_addr + 1, 0); }
17,959
0
static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp) { CharDriverState *chr; const char *chardev; const char *mode; int flags; mode = qemu_opt_get(opts, "mode"); if (mode == NULL) { mode = "readline"; } if (strcmp(mode, "readline") == 0) { flags = MONITOR_USE_READLINE; } else if (strcmp(mode, "control") == 0) { flags = MONITOR_USE_CONTROL; } else { fprintf(stderr, "unknown monitor mode \"%s\"\n", mode); exit(1); } if (qemu_opt_get_bool(opts, "pretty", 0)) flags |= MONITOR_USE_PRETTY; if (qemu_opt_get_bool(opts, "default", 0)) flags |= MONITOR_IS_DEFAULT; chardev = qemu_opt_get(opts, "chardev"); chr = qemu_chr_find(chardev); if (chr == NULL) { fprintf(stderr, "chardev \"%s\" not found\n", chardev); exit(1); } qemu_chr_fe_claim_no_fail(chr); monitor_init(chr, flags); return 0; }
17,960
0
static void show_parts(const char *device) { if (fork() == 0) { int nbd; /* linux just needs an open() to trigger * the partition table update * but remember to load the module with max_part != 0 : * modprobe nbd max_part=63 */ nbd = open(device, O_RDWR); if (nbd != -1) close(nbd); exit(0); } }
17,961
0
static void isa_mmio_writel(void *opaque, target_phys_addr_t addr, uint32_t val) { cpu_outl(addr & IOPORTS_MASK, val); }
17,962
0
static inline void t_gen_subx_carry(DisasContext *dc, TCGv d) { if (dc->flagx_known) { if (dc->flags_x) { TCGv c; c = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(c, PR_CCS); /* C flag is already at bit 0. */ tcg_gen_andi_tl(c, c, C_FLAG); tcg_gen_sub_tl(d, d, c); tcg_temp_free(c); } } else { TCGv x, c; x = tcg_temp_new(TCG_TYPE_TL); c = tcg_temp_new(TCG_TYPE_TL); t_gen_mov_TN_preg(x, PR_CCS); tcg_gen_mov_tl(c, x); /* Propagate carry into d if X is set. Branch free. */ tcg_gen_andi_tl(c, c, C_FLAG); tcg_gen_andi_tl(x, x, X_FLAG); tcg_gen_shri_tl(x, x, 4); tcg_gen_and_tl(x, x, c); tcg_gen_sub_tl(d, d, x); tcg_temp_free(x); tcg_temp_free(c); } }
17,963
0
SwsContext *getSwsContext(int srcW, int srcH, int srcFormat, int dstW, int dstH, int dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter){ SwsContext *c; int i; SwsFilter dummyFilter= {NULL, NULL, NULL, NULL}; #ifdef ARCH_X86 if(gCpuCaps.hasMMX) asm volatile("emms\n\t"::: "memory"); #endif if(swScale==NULL) globalInit(); /* sanity check */ if(srcW<4 || srcH<1 || dstW<8 || dstH<1) return NULL; //FIXME check if these are enough and try to lowwer them after fixing the relevant parts of the code // if(!isSupportedIn(srcFormat)) return NULL; // if(!isSupportedOut(dstFormat)) return NULL; if(!dstFilter) dstFilter= &dummyFilter; if(!srcFilter) srcFilter= &dummyFilter; c= memalign(64, sizeof(SwsContext)); memset(c, 0, sizeof(SwsContext)); c->srcW= srcW; c->srcH= srcH; c->dstW= dstW; c->dstH= dstH; c->lumXInc= ((srcW<<16) + (dstW>>1))/dstW; c->lumYInc= ((srcH<<16) + (dstH>>1))/dstH; c->flags= flags; c->dstFormat= dstFormat; c->srcFormat= srcFormat; if(cpuCaps.hasMMX2) { c->canMMX2BeUsed= (dstW >=srcW && (dstW&31)==0 && (srcW&15)==0) ? 1 : 0; if(!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR)) { if(flags&SWS_PRINT_INFO) fprintf(stderr, "SwScaler: output Width is not a multiple of 32 -> no MMX2 scaler\n"); } } else c->canMMX2BeUsed=0; /* dont use full vertical UV input/internaly if the source doesnt even have it */ if(isHalfChrV(srcFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_V); /* dont use full horizontal UV input if the source doesnt even have it */ if(isHalfChrH(srcFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_H_INP); /* dont use full horizontal UV internally if the destination doesnt even have it */ if(isHalfChrH(dstFormat)) c->flags= flags= flags&(~SWS_FULL_CHR_H_INT); if(flags&SWS_FULL_CHR_H_INP) c->chrSrcW= srcW; else c->chrSrcW= (srcW+1)>>1; if(flags&SWS_FULL_CHR_H_INT) c->chrDstW= dstW; else c->chrDstW= (dstW+1)>>1; if(flags&SWS_FULL_CHR_V) c->chrSrcH= srcH; else c->chrSrcH= (srcH+1)>>1; if(isHalfChrV(dstFormat)) c->chrDstH= (dstH+1)>>1; else c->chrDstH= dstH; c->chrXInc= ((c->chrSrcW<<16) + (c->chrDstW>>1))/c->chrDstW; c->chrYInc= ((c->chrSrcH<<16) + (c->chrDstH>>1))/c->chrDstH; // match pixel 0 of the src to pixel 0 of dst and match pixel n-2 of src to pixel n-2 of dst // but only for the FAST_BILINEAR mode otherwise do correct scaling // n-2 is the last chrominance sample available // this is not perfect, but noone shuld notice the difference, the more correct variant // would be like the vertical one, but that would require some special code for the // first and last pixel if(flags&SWS_FAST_BILINEAR) { if(c->canMMX2BeUsed) { c->lumXInc+= 20; c->chrXInc+= 20; } //we dont use the x86asm scaler if mmx is available else if(cpuCaps.hasMMX) { c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20; c->chrXInc = ((c->chrSrcW-2)<<16)/(c->chrDstW-2) - 20; } } /* precalculate horizontal scaler filter coefficients */ { const int filterAlign= cpuCaps.hasMMX ? 4 : 1; initFilter(&c->hLumFilter, &c->hLumFilterPos, &c->hLumFilterSize, c->lumXInc, srcW , dstW, filterAlign, 1<<14, flags, srcFilter->lumH, dstFilter->lumH); initFilter(&c->hChrFilter, &c->hChrFilterPos, &c->hChrFilterSize, c->chrXInc, (srcW+1)>>1, c->chrDstW, filterAlign, 1<<14, flags, srcFilter->chrH, dstFilter->chrH); #ifdef ARCH_X86 // cant downscale !!! if(c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR)) { initMMX2HScaler( dstW, c->lumXInc, c->funnyYCode); initMMX2HScaler(c->chrDstW, c->chrXInc, c->funnyUVCode); } #endif } // Init Horizontal stuff /* precalculate vertical scaler filter coefficients */ initFilter(&c->vLumFilter, &c->vLumFilterPos, &c->vLumFilterSize, c->lumYInc, srcH , dstH, 1, (1<<12)-4, flags, srcFilter->lumV, dstFilter->lumV); initFilter(&c->vChrFilter, &c->vChrFilterPos, &c->vChrFilterSize, c->chrYInc, (srcH+1)>>1, c->chrDstH, 1, (1<<12)-4, flags, srcFilter->chrV, dstFilter->chrV); // Calculate Buffer Sizes so that they wont run out while handling these damn slices c->vLumBufSize= c->vLumFilterSize; c->vChrBufSize= c->vChrFilterSize; for(i=0; i<dstH; i++) { int chrI= i*c->chrDstH / dstH; int nextSlice= MAX(c->vLumFilterPos[i ] + c->vLumFilterSize - 1, ((c->vChrFilterPos[chrI] + c->vChrFilterSize - 1)<<1)); nextSlice&= ~1; // Slices start at even boundaries if(c->vLumFilterPos[i ] + c->vLumBufSize < nextSlice) c->vLumBufSize= nextSlice - c->vLumFilterPos[i ]; if(c->vChrFilterPos[chrI] + c->vChrBufSize < (nextSlice>>1)) c->vChrBufSize= (nextSlice>>1) - c->vChrFilterPos[chrI]; } // allocate pixbufs (we use dynamic allocation because otherwise we would need to c->lumPixBuf= (int16_t**)memalign(4, c->vLumBufSize*2*sizeof(int16_t*)); c->chrPixBuf= (int16_t**)memalign(4, c->vChrBufSize*2*sizeof(int16_t*)); //Note we need at least one pixel more at the end because of the mmx code (just in case someone wanna replace the 4000/8000) for(i=0; i<c->vLumBufSize; i++) c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= (uint16_t*)memalign(8, 4000); for(i=0; i<c->vChrBufSize; i++) c->chrPixBuf[i]= c->chrPixBuf[i+c->vChrBufSize]= (uint16_t*)memalign(8, 8000); //try to avoid drawing green stuff between the right end and the stride end for(i=0; i<c->vLumBufSize; i++) memset(c->lumPixBuf[i], 0, 4000); for(i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, 8000); ASSERT(c->chrDstH <= dstH) // pack filter data for mmx code if(cpuCaps.hasMMX) { c->lumMmxFilter= (int16_t*)memalign(8, c->vLumFilterSize* dstH*4*sizeof(int16_t)); c->chrMmxFilter= (int16_t*)memalign(8, c->vChrFilterSize*c->chrDstH*4*sizeof(int16_t)); for(i=0; i<c->vLumFilterSize*dstH; i++) c->lumMmxFilter[4*i]=c->lumMmxFilter[4*i+1]=c->lumMmxFilter[4*i+2]=c->lumMmxFilter[4*i+3]= c->vLumFilter[i]; for(i=0; i<c->vChrFilterSize*c->chrDstH; i++) c->chrMmxFilter[4*i]=c->chrMmxFilter[4*i+1]=c->chrMmxFilter[4*i+2]=c->chrMmxFilter[4*i+3]= c->vChrFilter[i]; } if(flags&SWS_PRINT_INFO) { #ifdef DITHER1XBPP char *dither= " dithered"; #else char *dither= ""; #endif if(flags&SWS_FAST_BILINEAR) fprintf(stderr, "\nSwScaler: FAST_BILINEAR scaler, "); else if(flags&SWS_BILINEAR) fprintf(stderr, "\nSwScaler: BILINEAR scaler, "); else if(flags&SWS_BICUBIC) fprintf(stderr, "\nSwScaler: BICUBIC scaler, "); else if(flags&SWS_X) fprintf(stderr, "\nSwScaler: Experimental scaler, "); else if(flags&SWS_POINT) fprintf(stderr, "\nSwScaler: Nearest Neighbor / POINT scaler, "); else if(flags&SWS_AREA) fprintf(stderr, "\nSwScaler: Area Averageing scaler, "); else fprintf(stderr, "\nSwScaler: ehh flags invalid?! "); if(dstFormat==IMGFMT_BGR15 || dstFormat==IMGFMT_BGR16) fprintf(stderr, "from %s to%s %s ", vo_format_name(srcFormat), dither, vo_format_name(dstFormat)); else fprintf(stderr, "from %s to %s ", vo_format_name(srcFormat), vo_format_name(dstFormat)); if(cpuCaps.hasMMX2) fprintf(stderr, "using MMX2\n"); else if(cpuCaps.has3DNow) fprintf(stderr, "using 3DNOW\n"); else if(cpuCaps.hasMMX) fprintf(stderr, "using MMX\n"); else fprintf(stderr, "using C\n"); } if((flags & SWS_PRINT_INFO) && verbose) { if(cpuCaps.hasMMX) { if(c->canMMX2BeUsed && (flags&SWS_FAST_BILINEAR)) printf("SwScaler: using FAST_BILINEAR MMX2 scaler for horizontal scaling\n"); else { if(c->hLumFilterSize==4) printf("SwScaler: using 4-tap MMX scaler for horizontal luminance scaling\n"); else if(c->hLumFilterSize==8) printf("SwScaler: using 8-tap MMX scaler for horizontal luminance scaling\n"); else printf("SwScaler: using n-tap MMX scaler for horizontal luminance scaling\n"); if(c->hChrFilterSize==4) printf("SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling\n"); else if(c->hChrFilterSize==8) printf("SwScaler: using 8-tap MMX scaler for horizontal chrominance scaling\n"); else printf("SwScaler: using n-tap MMX scaler for horizontal chrominance scaling\n"); } } else { #ifdef ARCH_X86 printf("SwScaler: using X86-Asm scaler for horizontal scaling\n"); #else if(flags & SWS_FAST_BILINEAR) printf("SwScaler: using FAST_BILINEAR C scaler for horizontal scaling\n"); else printf("SwScaler: using C scaler for horizontal scaling\n"); #endif } if(isPlanarYUV(dstFormat)) { if(c->vLumFilterSize==1) printf("SwScaler: using 1-tap %s \"scaler\" for vertical scaling (YV12 like)\n", cpuCaps.hasMMX ? "MMX" : "C"); else printf("SwScaler: using n-tap %s scaler for vertical scaling (YV12 like)\n", cpuCaps.hasMMX ? "MMX" : "C"); } else { if(c->vLumFilterSize==1 && c->vChrFilterSize==2) printf("SwScaler: using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n" "SwScaler: 2-tap scaler for vertical chrominance scaling (BGR)\n",cpuCaps.hasMMX ? "MMX" : "C"); else if(c->vLumFilterSize==2 && c->vChrFilterSize==2) printf("SwScaler: using 2-tap linear %s scaler for vertical scaling (BGR)\n", cpuCaps.hasMMX ? "MMX" : "C"); else printf("SwScaler: using n-tap %s scaler for vertical scaling (BGR)\n", cpuCaps.hasMMX ? "MMX" : "C"); } if(dstFormat==IMGFMT_BGR24) printf("SwScaler: using %s YV12->BGR24 Converter\n", cpuCaps.hasMMX2 ? "MMX2" : (cpuCaps.hasMMX ? "MMX" : "C")); else if(dstFormat==IMGFMT_BGR32) printf("SwScaler: using %s YV12->BGR32 Converter\n", cpuCaps.hasMMX ? "MMX" : "C"); else if(dstFormat==IMGFMT_BGR16) printf("SwScaler: using %s YV12->BGR16 Converter\n", cpuCaps.hasMMX ? "MMX" : "C"); else if(dstFormat==IMGFMT_BGR15) printf("SwScaler: using %s YV12->BGR15 Converter\n", cpuCaps.hasMMX ? "MMX" : "C"); printf("SwScaler: %dx%d -> %dx%d\n", srcW, srcH, dstW, dstH); } if((flags & SWS_PRINT_INFO) && verbose>1) { printf("SwScaler:Lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc); printf("SwScaler:Chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc); } return c; }
17,965
0
struct pxa2xx_state_s *pxa270_init(unsigned int sdram_size, DisplayState *ds, const char *revision) { struct pxa2xx_state_s *s; struct pxa2xx_ssp_s *ssp; int iomemtype, i; s = (struct pxa2xx_state_s *) qemu_mallocz(sizeof(struct pxa2xx_state_s)); if (revision && strncmp(revision, "pxa27", 5)) { fprintf(stderr, "Machine requires a PXA27x processor.\n"); exit(1); } s->env = cpu_init(); cpu_arm_set_model(s->env, revision ?: "pxa270"); register_savevm("cpu", 0, 0, cpu_save, cpu_load, s->env); /* SDRAM & Internal Memory Storage */ cpu_register_physical_memory(PXA2XX_SDRAM_BASE, sdram_size, qemu_ram_alloc(sdram_size) | IO_MEM_RAM); cpu_register_physical_memory(PXA2XX_INTERNAL_BASE, 0x40000, qemu_ram_alloc(0x40000) | IO_MEM_RAM); s->pic = pxa2xx_pic_init(0x40d00000, s->env); s->dma = pxa27x_dma_init(0x40000000, s->pic[PXA2XX_PIC_DMA]); pxa27x_timer_init(0x40a00000, &s->pic[PXA2XX_PIC_OST_0], s->pic[PXA27X_PIC_OST_4_11]); s->gpio = pxa2xx_gpio_init(0x40e00000, s->env, s->pic, 121); s->mmc = pxa2xx_mmci_init(0x41100000, s->pic[PXA2XX_PIC_MMC], s->dma); for (i = 0; pxa270_serial[i].io_base; i ++) if (serial_hds[i]) serial_mm_init(pxa270_serial[i].io_base, 2, s->pic[pxa270_serial[i].irqn], serial_hds[i], 1); else break; if (serial_hds[i]) s->fir = pxa2xx_fir_init(0x40800000, s->pic[PXA2XX_PIC_ICP], s->dma, serial_hds[i]); if (ds) s->lcd = pxa2xx_lcdc_init(0x44000000, s->pic[PXA2XX_PIC_LCD], ds); s->cm_base = 0x41300000; s->cm_regs[CCCR >> 4] = 0x02000210; /* 416.0 MHz */ s->clkcfg = 0x00000009; /* Turbo mode active */ iomemtype = cpu_register_io_memory(0, pxa2xx_cm_readfn, pxa2xx_cm_writefn, s); cpu_register_physical_memory(s->cm_base, 0xfff, iomemtype); register_savevm("pxa2xx_cm", 0, 0, pxa2xx_cm_save, pxa2xx_cm_load, s); cpu_arm_set_cp_io(s->env, 14, pxa2xx_cp14_read, pxa2xx_cp14_write, s); s->mm_base = 0x48000000; s->mm_regs[MDMRS >> 2] = 0x00020002; s->mm_regs[MDREFR >> 2] = 0x03ca4000; s->mm_regs[MECR >> 2] = 0x00000001; /* Two PC Card sockets */ iomemtype = cpu_register_io_memory(0, pxa2xx_mm_readfn, pxa2xx_mm_writefn, s); cpu_register_physical_memory(s->mm_base, 0xfff, iomemtype); register_savevm("pxa2xx_mm", 0, 0, pxa2xx_mm_save, pxa2xx_mm_load, s); for (i = 0; pxa27x_ssp[i].io_base; i ++); s->ssp = (struct pxa2xx_ssp_s **) qemu_mallocz(sizeof(struct pxa2xx_ssp_s *) * i); ssp = (struct pxa2xx_ssp_s *) qemu_mallocz(sizeof(struct pxa2xx_ssp_s) * i); for (i = 0; pxa27x_ssp[i].io_base; i ++) { s->ssp[i] = &ssp[i]; ssp[i].base = pxa27x_ssp[i].io_base; ssp[i].irq = s->pic[pxa27x_ssp[i].irqn]; iomemtype = cpu_register_io_memory(0, pxa2xx_ssp_readfn, pxa2xx_ssp_writefn, &ssp[i]); cpu_register_physical_memory(ssp[i].base, 0xfff, iomemtype); register_savevm("pxa2xx_ssp", i, 0, pxa2xx_ssp_save, pxa2xx_ssp_load, s); } if (usb_enabled) { usb_ohci_init_pxa(0x4c000000, 3, -1, s->pic[PXA2XX_PIC_USBH1]); } s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000); s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000); s->rtc_base = 0x40900000; iomemtype = cpu_register_io_memory(0, pxa2xx_rtc_readfn, pxa2xx_rtc_writefn, s); cpu_register_physical_memory(s->rtc_base, 0xfff, iomemtype); pxa2xx_rtc_init(s); register_savevm("pxa2xx_rtc", 0, 0, pxa2xx_rtc_save, pxa2xx_rtc_load, s); /* Note that PM registers are in the same page with PWRI2C registers. * As a workaround we don't map PWRI2C into memory and we expect * PM handlers to call PWRI2C handlers when appropriate. */ s->i2c[0] = pxa2xx_i2c_init(0x40301600, s->pic[PXA2XX_PIC_I2C], 1); s->i2c[1] = pxa2xx_i2c_init(0x40f00100, s->pic[PXA2XX_PIC_PWRI2C], 0); s->pm_base = 0x40f00000; iomemtype = cpu_register_io_memory(0, pxa2xx_pm_readfn, pxa2xx_pm_writefn, s); cpu_register_physical_memory(s->pm_base, 0xfff, iomemtype); register_savevm("pxa2xx_pm", 0, 0, pxa2xx_pm_save, pxa2xx_pm_load, s); s->i2s = pxa2xx_i2s_init(0x40400000, s->pic[PXA2XX_PIC_I2S], s->dma); /* GPIO1 resets the processor */ /* The handler can be overriden by board-specific code */ pxa2xx_gpio_handler_set(s->gpio, 1, pxa2xx_reset, s); return s; }
17,966
0
static int qemu_rbd_snap_rollback(BlockDriverState *bs, const char *snapshot_name) { BDRVRBDState *s = bs->opaque; int r; r = rbd_snap_rollback(s->image, snapshot_name); return r; }
17,967
0
static void test_visitor_out_empty(TestOutputVisitorData *data, const void *unused) { QObject *arg; arg = qmp_output_get_qobject(data->qov); g_assert(qobject_type(arg) == QTYPE_QNULL); /* Check that qnull reference counting is sane */ g_assert(arg->refcnt == 2); qobject_decref(arg); }
17,968
0
void qio_dns_resolver_lookup_result(QIODNSResolver *resolver, QIOTask *task, size_t *naddrs, SocketAddressLegacy ***addrs) { struct QIODNSResolverLookupData *data = qio_task_get_result_pointer(task); size_t i; *naddrs = 0; *addrs = NULL; if (!data) { return; } *naddrs = data->naddrs; *addrs = g_new0(SocketAddressLegacy *, data->naddrs); for (i = 0; i < data->naddrs; i++) { (*addrs)[i] = QAPI_CLONE(SocketAddressLegacy, data->addrs[i]); } }
17,969
0
iscsi_co_generic_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { struct IscsiTask *iTask = opaque; struct scsi_task *task = command_data; iTask->status = status; iTask->do_retry = 0; iTask->task = task; if (status != SCSI_STATUS_GOOD) { if (iTask->retries++ < ISCSI_CMD_RETRIES) { if (status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION) { error_report("iSCSI CheckCondition: %s", iscsi_get_error(iscsi)); iTask->do_retry = 1; goto out; } if (status == SCSI_STATUS_BUSY || status == SCSI_STATUS_TIMEOUT || status == SCSI_STATUS_TASK_SET_FULL) { unsigned retry_time = exp_random(iscsi_retry_times[iTask->retries - 1]); if (status == SCSI_STATUS_TIMEOUT) { /* make sure the request is rescheduled AFTER the * reconnect is initiated */ retry_time = EVENT_INTERVAL * 2; iTask->iscsilun->request_timed_out = true; } error_report("iSCSI Busy/TaskSetFull/TimeOut" " (retry #%u in %u ms): %s", iTask->retries, retry_time, iscsi_get_error(iscsi)); aio_timer_init(iTask->iscsilun->aio_context, &iTask->retry_timer, QEMU_CLOCK_REALTIME, SCALE_MS, iscsi_retry_timer_expired, iTask); timer_mod(&iTask->retry_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time); iTask->do_retry = 1; return; } } iTask->err_code = iscsi_translate_sense(&task->sense); error_report("iSCSI Failure: %s", iscsi_get_error(iscsi)); } else { iTask->iscsilun->force_next_flush |= iTask->force_next_flush; } out: if (iTask->co) { iTask->bh = aio_bh_new(iTask->iscsilun->aio_context, iscsi_co_generic_bh_cb, iTask); qemu_bh_schedule(iTask->bh); } else { iTask->complete = 1; } }
17,970
0
void cpu_exec_exit(CPUState *cpu) { if (cpu->cpu_index == -1) { /* cpu_index was never allocated by this @cpu or was already freed. */ return; } bitmap_clear(cpu_index_map, cpu->cpu_index, 1); cpu->cpu_index = -1; }
17,971
0
build_header(GArray *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev, const char *oem_id, const char *oem_table_id) { memcpy(&h->signature, sig, 4); h->length = cpu_to_le32(len); h->revision = rev; if (oem_id) { strncpy((char *)h->oem_id, oem_id, sizeof h->oem_id); } else { memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6); } if (oem_table_id) { strncpy((char *)h->oem_table_id, oem_table_id, sizeof(h->oem_table_id)); } else { memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4); memcpy(h->oem_table_id + 4, sig, 4); } h->oem_revision = cpu_to_le32(1); memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4); h->asl_compiler_revision = cpu_to_le32(1); h->checksum = 0; /* Checksum to be filled in by Guest linker */ bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, table_data, h, len, &h->checksum); }
17,973
0
static int kvm_has_msr_hsave_pa(CPUState *env) { kvm_supported_msrs(env); return has_msr_hsave_pa; }
17,974
0
static void sd_cardchange(void *opaque, bool load) { SDState *sd = opaque; qemu_set_irq(sd->inserted_cb, blk_is_inserted(sd->blk)); if (blk_is_inserted(sd->blk)) { sd_reset(DEVICE(sd)); qemu_set_irq(sd->readonly_cb, sd->wp_switch); } }
17,975
0
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *pkt) { GetBitContext gb; VimaContext *vima = avctx->priv_data; int16_t pcm_data[2]; uint32_t samples; int8_t channel_hint[2]; int ret, chan, channels = 1; init_get_bits(&gb, pkt->data, pkt->size * 8); if (pkt->size < 13) return AVERROR_INVALIDDATA; samples = get_bits_long(&gb, 32); if (samples == 0xffffffff) { skip_bits_long(&gb, 32); samples = get_bits_long(&gb, 32); } if (samples > pkt->size * 2) return AVERROR_INVALIDDATA; channel_hint[0] = get_sbits(&gb, 8); if (channel_hint[0] & 0x80) { channel_hint[0] = ~channel_hint[0]; channels = 2; } avctx->channels = channels; avctx->channel_layout = (channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; pcm_data[0] = get_sbits(&gb, 16); if (channels > 1) { channel_hint[1] = get_sbits(&gb, 8); pcm_data[1] = get_sbits(&gb, 16); } vima->frame.nb_samples = samples; if ((ret = avctx->get_buffer(avctx, &vima->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } for (chan = 0; chan < channels; chan++) { uint16_t *dest = (uint16_t*)vima->frame.data[0] + chan; int step_index = channel_hint[chan]; int output = pcm_data[chan]; int sample; for (sample = 0; sample < samples; sample++) { int lookup_size, lookup, highbit, lowbits; step_index = av_clip(step_index, 0, 88); lookup_size = size_table[step_index]; lookup = get_bits(&gb, lookup_size); highbit = 1 << (lookup_size - 1); lowbits = highbit - 1; if (lookup & highbit) lookup ^= highbit; else highbit = 0; if (lookup == lowbits) { output = get_sbits(&gb, 16); } else { int predict_index, diff; predict_index = (lookup << (7 - lookup_size)) | (step_index << 6); predict_index = av_clip(predict_index, 0, 5785); diff = vima->predict_table[predict_index]; if (lookup) diff += ff_adpcm_step_table[step_index] >> (lookup_size - 1); if (highbit) diff = -diff; output = av_clip_int16(output + diff); } *dest = output; dest += channels; step_index += step_index_tables[lookup_size - 2][lookup]; } } *got_frame_ptr = 1; *(AVFrame *)data = vima->frame; return pkt->size; }
17,976
0
sPAPRTCETable *spapr_tce_find_by_liobn(uint32_t liobn) { sPAPRTCETable *tcet; if (liobn & 0xFFFFFFFF00000000ULL) { hcall_dprintf("Request for out-of-bounds LIOBN 0x" TARGET_FMT_lx "\n", liobn); return NULL; } QLIST_FOREACH(tcet, &spapr_tce_tables, list) { if (tcet->liobn == liobn) { return tcet; } } return NULL; }
17,977