label
int64
0
1
func1
stringlengths
23
97k
id
int64
0
27.3k
0
static void sysctl_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { MilkymistSysctlState *s = opaque; trace_milkymist_sysctl_memory_write(addr, value); addr >>= 2; switch (addr) { case R_GPIO_OUT: case R_GPIO_INTEN: case R_TIMER0_COUNTER: case R_TIMER1_COUNTER: case R_DBG_SCRATCHPAD: s->regs[addr] = value; break; case R_TIMER0_COMPARE: ptimer_set_limit(s->ptimer0, value, 0); s->regs[addr] = value; break; case R_TIMER1_COMPARE: ptimer_set_limit(s->ptimer1, value, 0); s->regs[addr] = value; break; case R_TIMER0_CONTROL: s->regs[addr] = value; if (s->regs[R_TIMER0_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer0(); ptimer_set_count(s->ptimer0, s->regs[R_TIMER0_COMPARE] - s->regs[R_TIMER0_COUNTER]); ptimer_run(s->ptimer0, 0); } else { trace_milkymist_sysctl_stop_timer0(); ptimer_stop(s->ptimer0); } break; case R_TIMER1_CONTROL: s->regs[addr] = value; if (s->regs[R_TIMER1_CONTROL] & CTRL_ENABLE) { trace_milkymist_sysctl_start_timer1(); ptimer_set_count(s->ptimer1, s->regs[R_TIMER1_COMPARE] - s->regs[R_TIMER1_COUNTER]); ptimer_run(s->ptimer1, 0); } else { trace_milkymist_sysctl_stop_timer1(); ptimer_stop(s->ptimer1); } break; case R_ICAP: sysctl_icap_write(s, value); break; case R_DBG_WRITE_LOCK: s->regs[addr] = 1; break; case R_SYSTEM_ID: qemu_system_reset_request(); break; case R_GPIO_IN: case R_CLK_FREQUENCY: case R_CAPABILITIES: error_report("milkymist_sysctl: write to read-only register 0x" TARGET_FMT_plx, addr << 2); break; default: error_report("milkymist_sysctl: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } }
11,323
0
static void parallels_close(BlockDriverState *bs) { BDRVParallelsState *s = bs->opaque; g_free(s->catalog_bitmap); }
11,324
1
static int img_resize(int argc, char **argv) { Error *err = NULL; int c, ret, relative; const char *filename, *fmt, *size; int64_t n, total_size; bool quiet = false; BlockBackend *blk = NULL; QemuOpts *param; static QemuOptsList resize_options = { .name = "resize_options", .head = QTAILQ_HEAD_INITIALIZER(resize_options.head), .desc = { { .name = BLOCK_OPT_SIZE, .type = QEMU_OPT_SIZE, .help = "Virtual disk size" }, { /* end of list */ } }, }; bool image_opts = false; /* Remove size from argv manually so that negative numbers are not treated * as options by getopt. */ if (argc < 3) { error_exit("Not enough arguments"); return 1; } size = argv[--argc]; /* Parse getopt arguments */ fmt = NULL; for(;;) { static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"object", required_argument, 0, OPTION_OBJECT}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "f:hq", long_options, NULL); if (c == -1) { break; } switch(c) { case '?': case 'h': help(); break; case 'f': fmt = optarg; break; case 'q': quiet = true; break; case OPTION_OBJECT: { QemuOpts *opts; opts = qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); if (!opts) { return 1; } } break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != argc - 1) { error_exit("Expecting one image file name"); } filename = argv[optind++]; if (qemu_opts_foreach(&qemu_object_opts, user_creatable_add_opts_foreach, NULL, NULL)) { return 1; } /* Choose grow, shrink, or absolute resize mode */ switch (size[0]) { case '+': relative = 1; size++; break; case '-': relative = -1; size++; break; default: relative = 0; break; } /* Parse size */ param = qemu_opts_create(&resize_options, NULL, 0, &error_abort); qemu_opt_set(param, BLOCK_OPT_SIZE, size, &err); if (err) { error_report_err(err); ret = -1; qemu_opts_del(param); goto out; } n = qemu_opt_get_size(param, BLOCK_OPT_SIZE, 0); qemu_opts_del(param); blk = img_open(image_opts, filename, fmt, BDRV_O_RDWR | BDRV_O_RESIZE, false, quiet); if (!blk) { ret = -1; goto out; } if (relative) { total_size = blk_getlength(blk) + n * relative; } else { total_size = n; } if (total_size <= 0) { error_report("New image size must be positive"); ret = -1; goto out; } ret = blk_truncate(blk, total_size); switch (ret) { case 0: qprintf(quiet, "Image resized.\n"); break; case -ENOTSUP: error_report("This image does not support resize"); break; case -EACCES: error_report("Image is read-only"); break; default: error_report("Error resizing image: %s", strerror(-ret)); break; } out: blk_unref(blk); if (ret) { return 1; } return 0; }
11,325
1
static void qtrle_decode_24bpp(QtrleContext *s, int stream_ptr, int row_ptr, int lines_to_change) { int rle_code; int pixel_ptr; int row_inc = s->frame.linesize[0]; unsigned char r, g, b; unsigned char *rgb = s->frame.data[0]; int pixel_limit = s->frame.linesize[0] * s->avctx->height; while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 3; while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { /* there's another skip code in the stream */ CHECK_STREAM_PTR(1); pixel_ptr += (s->buf[stream_ptr++] - 1) * 3; } else if (rle_code < 0) { /* decode the run length code */ rle_code = -rle_code; CHECK_STREAM_PTR(3); r = s->buf[stream_ptr++]; g = s->buf[stream_ptr++]; b = s->buf[stream_ptr++]; CHECK_PIXEL_PTR(rle_code * 3); while (rle_code--) { rgb[pixel_ptr++] = r; rgb[pixel_ptr++] = g; rgb[pixel_ptr++] = b; } } else { CHECK_STREAM_PTR(rle_code * 3); CHECK_PIXEL_PTR(rle_code * 3); /* copy pixels directly to output */ while (rle_code--) { rgb[pixel_ptr++] = s->buf[stream_ptr++]; rgb[pixel_ptr++] = s->buf[stream_ptr++]; rgb[pixel_ptr++] = s->buf[stream_ptr++]; } } } row_ptr += row_inc; } }
11,327
1
static int xiph_parse_sdp_line(AVFormatContext *s, int st_index, PayloadContext *data, const char *line) { const char *p; char *value; char attr[25]; int value_size = strlen(line), attr_size = sizeof(attr), res = 0; AVCodecContext* codec = s->streams[st_index]->codec; assert(codec->id == CODEC_ID_THEORA); assert(data); if (!(value = av_malloc(value_size))) { av_log(codec, AV_LOG_ERROR, "Out of memory\n"); return AVERROR(ENOMEM); } if (av_strstart(line, "fmtp:", &p)) { // remove protocol identifier while (*p && *p == ' ') p++; // strip spaces while (*p && *p != ' ') p++; // eat protocol identifier while (*p && *p == ' ') p++; // strip trailing spaces while (ff_rtsp_next_attr_and_value(&p, attr, attr_size, value, value_size)) { res = xiph_parse_fmtp_pair(codec, data, attr, value); if (res < 0 && res != AVERROR_PATCHWELCOME) return res; } } av_free(value); return 0; }
11,329
1
static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags) { int start_partition, end_packet; int extended_bits, part_id; int pictureid_present = 0, tl0picidx_present = 0, tid_present = 0, keyidx_present = 0; int pictureid = -1, pictureid_mask = 0; int returned_old_frame = 0; uint32_t old_timestamp; if (!buf) { if (vp8->data) { int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) return ret; *timestamp = vp8->timestamp; if (vp8->sequence_dirty) pkt->flags |= AV_PKT_FLAG_CORRUPT; return 0; } return AVERROR(EAGAIN); } if (len < 1) return AVERROR_INVALIDDATA; extended_bits = buf[0] & 0x80; start_partition = buf[0] & 0x10; part_id = buf[0] & 0x0f; end_packet = flags & RTP_FLAG_MARKER; buf++; len--; if (extended_bits) { if (len < 1) return AVERROR_INVALIDDATA; pictureid_present = buf[0] & 0x80; tl0picidx_present = buf[0] & 0x40; tid_present = buf[0] & 0x20; keyidx_present = buf[0] & 0x10; buf++; len--; } if (pictureid_present) { if (len < 1) return AVERROR_INVALIDDATA; if (buf[0] & 0x80) { if (len < 2) return AVERROR_INVALIDDATA; pictureid = AV_RB16(buf) & 0x7fff; pictureid_mask = 0x7fff; buf += 2; len -= 2; } else { pictureid = buf[0] & 0x7f; pictureid_mask = 0x7f; buf++; len--; } } if (tl0picidx_present) { // Ignoring temporal level zero index buf++; len--; } if (tid_present || keyidx_present) { // Ignoring temporal layer index, layer sync bit and keyframe index buf++; len--; } if (len < 1) return AVERROR_INVALIDDATA; if (start_partition && part_id == 0 && len >= 3) { int res; int non_key = buf[0] & 0x01; if (!non_key) { vp8_free_buffer(vp8); // Keyframe, decoding ok again vp8->sequence_ok = 1; vp8->sequence_dirty = 0; vp8->got_keyframe = 1; } else { int can_continue = vp8->data && !vp8->is_keyframe && avio_tell(vp8->data) >= vp8->first_part_size; if (!vp8->sequence_ok) return AVERROR(EAGAIN); if (!vp8->got_keyframe) return vp8_broken_sequence(ctx, vp8, "Keyframe missing\n"); if (pictureid >= 0) { if (pictureid != ((vp8->prev_pictureid + 1) & pictureid_mask)) { return vp8_broken_sequence(ctx, vp8, "Missed a picture, sequence broken\n"); } else { if (vp8->data && !can_continue) return vp8_broken_sequence(ctx, vp8, "Missed a picture, sequence broken\n"); } } else { uint16_t expected_seq = vp8->prev_seq + 1; int16_t diff = seq - expected_seq; if (vp8->data) { // No picture id, so we can't know if missed packets // contained any new frames. If diff == 0, we did get // later packets from the same frame (matching timestamp), // so we know we didn't miss any frame. If diff == 1 and // we still have data (not flushed by the end of frame // marker), the single missed packet must have been part // of the same frame. if ((diff == 0 || diff == 1) && can_continue) { // Proceed with what we have } else { return vp8_broken_sequence(ctx, vp8, "Missed too much, sequence broken\n"); } } else { if (diff != 0) return vp8_broken_sequence(ctx, vp8, "Missed unknown data, sequence broken\n"); } } if (vp8->data) { vp8->sequence_dirty = 1; if (avio_tell(vp8->data) >= vp8->first_part_size) { int ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) return ret; pkt->flags |= AV_PKT_FLAG_CORRUPT; returned_old_frame = 1; old_timestamp = vp8->timestamp; } else { // Shouldn't happen vp8_free_buffer(vp8); } } } vp8->first_part_size = (AV_RL16(&buf[1]) << 3 | buf[0] >> 5) + 3; if ((res = avio_open_dyn_buf(&vp8->data)) < 0) return res; vp8->timestamp = *timestamp; vp8->broken_frame = 0; vp8->prev_pictureid = pictureid; vp8->is_keyframe = !non_key; } else { uint16_t expected_seq = vp8->prev_seq + 1; if (!vp8->sequence_ok) return AVERROR(EAGAIN); if (vp8->timestamp != *timestamp) { // Missed the start of the new frame, sequence broken return vp8_broken_sequence(ctx, vp8, "Received no start marker; dropping frame\n"); } if (seq != expected_seq) { if (vp8->is_keyframe) { return vp8_broken_sequence(ctx, vp8, "Missed part of a keyframe, sequence broken\n"); } else if (vp8->data && avio_tell(vp8->data) >= vp8->first_part_size) { vp8->broken_frame = 1; vp8->sequence_dirty = 1; } else { return vp8_broken_sequence(ctx, vp8, "Missed part of the first partition, sequence broken\n"); } } } if (!vp8->data) return vp8_broken_sequence(ctx, vp8, "Received no start marker\n"); vp8->prev_seq = seq; if (!vp8->broken_frame) avio_write(vp8->data, buf, len); if (returned_old_frame) { *timestamp = old_timestamp; return end_packet ? 1 : 0; } if (end_packet) { int ret; ret = ff_rtp_finalize_packet(pkt, &vp8->data, st->index); if (ret < 0) return ret; if (vp8->sequence_dirty) pkt->flags |= AV_PKT_FLAG_CORRUPT; return 0; } return AVERROR(EAGAIN); }
11,330
1
static int encode_picture_lossless(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ MpegEncContext * const s = avctx->priv_data; MJpegContext * const m = s->mjpeg_ctx; AVFrame *pict = data; const int width= s->width; const int height= s->height; AVFrame * const p= (AVFrame*)&s->current_picture; const int predictor= avctx->prediction_method+1; init_put_bits(&s->pb, buf, buf_size); *p = *pict; p->pict_type= FF_I_TYPE; p->key_frame= 1; mjpeg_picture_header(s); s->header_bits= put_bits_count(&s->pb); if(avctx->pix_fmt == PIX_FMT_RGBA32){ int x, y, i; const int linesize= p->linesize[0]; uint16_t buffer[2048][4]; int left[3], top[3], topleft[3]; for(i=0; i<3; i++){ buffer[0][i]= 1 << (9 - 1); } for(y = 0; y < height; y++) { const int modified_predictor= y ? predictor : 1; uint8_t *ptr = p->data[0] + (linesize * y); for(i=0; i<3; i++){ top[i]= left[i]= topleft[i]= buffer[0][i]; } for(x = 0; x < width; x++) { buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100; buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100; buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2; for(i=0;i<3;i++) { int pred, diff; PREDICT(pred, topleft[i], top[i], left[i], modified_predictor); topleft[i]= top[i]; top[i]= buffer[x+1][i]; left[i]= buffer[x][i]; diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100; if(i==0) mjpeg_encode_dc(s, diff, m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly else mjpeg_encode_dc(s, diff, m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ int mb_x, mb_y, i; const int mb_width = (width + s->mjpeg_hsample[0] - 1) / s->mjpeg_hsample[0]; const int mb_height = (height + s->mjpeg_vsample[0] - 1) / s->mjpeg_vsample[0]; for(mb_y = 0; mb_y < mb_height; mb_y++) { for(mb_x = 0; mb_x < mb_width; mb_x++) { if(mb_x==0 || mb_y==0){ for(i=0;i<3;i++) { uint8_t *ptr; int x, y, h, v, linesize; h = s->mjpeg_hsample[i]; v = s->mjpeg_vsample[i]; linesize= p->linesize[i]; for(y=0; y<v; y++){ for(x=0; x<h; x++){ int pred; ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap if(y==0 && mb_y==0){ if(x==0 && mb_x==0){ pred= 128; }else{ pred= ptr[-1]; } }else{ if(x==0 && mb_x==0){ pred= ptr[-linesize]; }else{ PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); } } if(i==0) mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly else mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } }else{ for(i=0;i<3;i++) { uint8_t *ptr; int x, y, h, v, linesize; h = s->mjpeg_hsample[i]; v = s->mjpeg_vsample[i]; linesize= p->linesize[i]; for(y=0; y<v; y++){ for(x=0; x<h; x++){ int pred; ptr = p->data[i] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap //printf("%d %d %d %d %8X\n", mb_x, mb_y, x, y, ptr); PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor); if(i==0) mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_luminance, m->huff_code_dc_luminance); //FIXME ugly else mjpeg_encode_dc(s, (int8_t)(*ptr - pred), m->huff_size_dc_chrominance, m->huff_code_dc_chrominance); } } } } } } } emms_c(); mjpeg_picture_trailer(s); s->picture_number++; flush_put_bits(&s->pb); return pbBufPtr(&s->pb) - s->pb.buf; // return (put_bits_count(&f->pb)+7)/8; }
11,331
1
static VFIOGroup *vfio_get_group(int groupid) { VFIOGroup *group; char path[32]; struct vfio_group_status status = { .argsz = sizeof(status) }; QLIST_FOREACH(group, &group_list, next) { if (group->groupid == groupid) { return group; } } group = g_malloc0(sizeof(*group)); snprintf(path, sizeof(path), "/dev/vfio/%d", groupid); group->fd = qemu_open(path, O_RDWR); if (group->fd < 0) { error_report("vfio: error opening %s: %m", path); goto free_group_exit; } if (ioctl(group->fd, VFIO_GROUP_GET_STATUS, &status)) { error_report("vfio: error getting group status: %m"); goto close_fd_exit; } if (!(status.flags & VFIO_GROUP_FLAGS_VIABLE)) { error_report("vfio: error, group %d is not viable, please ensure " "all devices within the iommu_group are bound to their " "vfio bus driver.", groupid); goto close_fd_exit; } group->groupid = groupid; QLIST_INIT(&group->device_list); if (vfio_connect_container(group)) { error_report("vfio: failed to setup container for group %d", groupid); goto close_fd_exit; } if (QLIST_EMPTY(&group_list)) { qemu_register_reset(vfio_pci_reset_handler, NULL); } QLIST_INSERT_HEAD(&group_list, group, next); vfio_kvm_device_add_group(group); return group; close_fd_exit: close(group->fd); free_group_exit: g_free(group); return NULL; }
11,332
1
static int webvtt_event_to_ass(AVBPrint *buf, const char *p) { int i, again, skip = 0; while (*p) { for (i = 0; i < FF_ARRAY_ELEMS(webvtt_tag_replace); i++) { const char *from = webvtt_tag_replace[i].from; const size_t len = strlen(from); if (!strncmp(p, from, len)) { av_bprintf(buf, "%s", webvtt_tag_replace[i].to); p += len; again = 1; break; } } if (!*p) break; if (again) { again = 0; skip = 0; continue; } if (*p == '<') skip = 1; else if (*p == '>') skip = 0; else if (p[0] == '\n' && p[1]) av_bprintf(buf, "\\N"); else if (!skip && *p != '\r') av_bprint_chars(buf, *p, 1); p++; } return 0; }
11,333
0
static int nuv_probe(AVProbeData *p) { if (p->buf_size < 12) return 0; if (!memcmp(p->buf, "NuppelVideo", 12)) return AVPROBE_SCORE_MAX; if (!memcmp(p->buf, "MythTVVideo", 12)) return AVPROBE_SCORE_MAX; return 0; }
11,335
1
void cache_fini(PageCache *cache) { int64_t i; g_assert(cache); g_assert(cache->page_cache); for (i = 0; i < cache->max_num_items; i++) { g_free(cache->page_cache[i].it_data); } g_free(cache->page_cache); cache->page_cache = NULL; }
11,336
1
int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc= &s->rc_context; int i; const char *error = NULL; static const char * const const_names[]={ "PI", "E", "iTex", "pTex", "tex", "mv", "fCode", "iCount", "mcVar", "var", "isI", "isP", "isB", "avgQP", "qComp", /* "lastIQP", "lastPQP", "lastBQP", "nextNonBQP",*/ "avgIITex", "avgPITex", "avgPPTex", "avgBPTex", "avgTex", NULL }; static double (*func1[])(void *, double)={ (void *)bits2qp, (void *)qp2bits, NULL }; static const char * const func1_names[]={ "bits2qp", "qp2bits", NULL }; emms_c(); rcc->rc_eq_eval = ff_parse(s->avctx->rc_eq, const_names, func1, func1_names, NULL, NULL, &error); if (!rcc->rc_eq_eval) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\": %s\n", s->avctx->rc_eq, error? error : ""); return -1; } for(i=0; i<5; i++){ rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0; rcc->pred[i].count= 1.0; rcc->pred[i].decay= 0.4; rcc->i_cplx_sum [i]= rcc->p_cplx_sum [i]= rcc->mv_bits_sum[i]= rcc->qscale_sum [i]= rcc->frame_count[i]= 1; // 1 is better because of 1/0 and such rcc->last_qscale_for[i]=FF_QP2LAMBDA * 5; } rcc->buffer_index= s->avctx->rc_initial_buffer_occupancy; if(s->flags&CODEC_FLAG_PASS2){ int i; char *p; /* find number of pics */ p= s->avctx->stats_in; for(i=-1; p; i++){ p= strchr(p+1, ';'); } i+= s->max_b_frames; if(i<=0 || i>=INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i*sizeof(RateControlEntry)); rcc->num_entries= i; /* init all to skipped p frames (with b frames we might have a not encoded frame at the end FIXME) */ for(i=0; i<rcc->num_entries; i++){ RateControlEntry *rce= &rcc->entry[i]; rce->pict_type= rce->new_pict_type=FF_P_TYPE; rce->qscale= rce->new_qscale=FF_QP2LAMBDA * 2; rce->misc_bits= s->mb_num + 10; rce->mb_var_sum= s->mb_num*100; } /* read stats */ p= s->avctx->stats_in; for(i=0; i<rcc->num_entries - s->max_b_frames; i++){ RateControlEntry *rce; int picture_number; int e; char *next; next= strchr(p, ';'); if(next){ (*next)=0; //sscanf in unbelievably slow on looong strings //FIXME copy / do not write next++; } e= sscanf(p, " in:%d ", &picture_number); assert(picture_number >= 0); assert(picture_number < rcc->num_entries); rce= &rcc->entry[picture_number]; e+=sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d", &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits); if(e!=14){ av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e); return -1; } p= next; } if(init_pass2(s) < 0) return -1; //FIXME maybe move to end if((s->flags&CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) { #ifdef CONFIG_LIBXVID return ff_xvid_rate_control_init(s); #else av_log(s->avctx, AV_LOG_ERROR, "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n"); return -1; #endif } } if(!(s->flags&CODEC_FLAG_PASS2)){ rcc->short_term_qsum=0.001; rcc->short_term_qcount=0.001; rcc->pass1_rc_eq_output_sum= 0.001; rcc->pass1_wanted_bits=0.001; if(s->avctx->qblur > 1.0){ av_log(s->avctx, AV_LOG_ERROR, "qblur too large\n"); return -1; } /* init stuff with the user specified complexity */ if(s->avctx->rc_initial_cplx){ for(i=0; i<60*30; i++){ double bits= s->avctx->rc_initial_cplx * (i/10000.0 + 1.0)*s->mb_num; RateControlEntry rce; double q; if (i%((s->gop_size+3)/4)==0) rce.pict_type= FF_I_TYPE; else if(i%(s->max_b_frames+1)) rce.pict_type= FF_B_TYPE; else rce.pict_type= FF_P_TYPE; rce.new_pict_type= rce.pict_type; rce.mc_mb_var_sum= bits*s->mb_num/100000; rce.mb_var_sum = s->mb_num; rce.qscale = FF_QP2LAMBDA * 2; rce.f_code = 2; rce.b_code = 1; rce.misc_bits= 1; if(s->pict_type== FF_I_TYPE){ rce.i_count = s->mb_num; rce.i_tex_bits= bits; rce.p_tex_bits= 0; rce.mv_bits= 0; }else{ rce.i_count = 0; //FIXME we do know this approx rce.i_tex_bits= 0; rce.p_tex_bits= bits*0.9; rce.mv_bits= bits*0.1; } rcc->i_cplx_sum [rce.pict_type] += rce.i_tex_bits*rce.qscale; rcc->p_cplx_sum [rce.pict_type] += rce.p_tex_bits*rce.qscale; rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits; rcc->frame_count[rce.pict_type] ++; bits= rce.i_tex_bits + rce.p_tex_bits; q= get_qscale(s, &rce, rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum, i); rcc->pass1_wanted_bits+= s->bit_rate/(1/av_q2d(s->avctx->time_base)); //FIXME misbehaves a little for variable fps } } } return 0; }
11,337
1
static int iec61883_read_header(AVFormatContext *context) { struct iec61883_data *dv = context->priv_data; struct raw1394_portinfo pinf[16]; rom1394_directory rom_dir; char *endptr; int inport; int nb_ports; int port = -1; int response; int i, j = 0; uint64_t guid = 0; dv->input_port = -1; dv->output_port = -1; dv->channel = -1; dv->raw1394 = raw1394_new_handle(); if (!dv->raw1394) { av_log(context, AV_LOG_ERROR, "Failed to open IEEE1394 interface.\n"); return AVERROR(EIO); } if ((nb_ports = raw1394_get_port_info(dv->raw1394, pinf, 16)) < 0) { av_log(context, AV_LOG_ERROR, "Failed to get number of IEEE1394 ports.\n"); goto fail; } inport = strtol(context->filename, &endptr, 10); if (endptr != context->filename && *endptr == '\0') { av_log(context, AV_LOG_INFO, "Selecting IEEE1394 port: %d\n", inport); j = inport; nb_ports = inport + 1; } else if (strcmp(context->filename, "auto")) { av_log(context, AV_LOG_ERROR, "Invalid input \"%s\", you should specify " "\"auto\" for auto-detection, or the port number.\n", context->filename); goto fail; } if (dv->device_guid) { if (sscanf(dv->device_guid, "%llx", (long long unsigned int *)&guid) != 1) { av_log(context, AV_LOG_INFO, "Invalid dvguid parameter: %s\n", dv->device_guid); goto fail; } } for (; j < nb_ports && port==-1; ++j) { raw1394_destroy_handle(dv->raw1394); if (!(dv->raw1394 = raw1394_new_handle_on_port(j))) { av_log(context, AV_LOG_ERROR, "Failed setting IEEE1394 port.\n"); goto fail; } for (i=0; i<raw1394_get_nodecount(dv->raw1394); ++i) { /* Select device explicitly by GUID */ if (guid > 1) { if (guid == rom1394_get_guid(dv->raw1394, i)) { dv->node = i; port = j; break; } } else { /* Select first AV/C tape recorder player node */ if (rom1394_get_directory(dv->raw1394, i, &rom_dir) < 0) continue; if (((rom1394_get_node_type(&rom_dir) == ROM1394_NODE_TYPE_AVC) && avc1394_check_subunit_type(dv->raw1394, i, AVC1394_SUBUNIT_TYPE_VCR)) || (rom_dir.unit_spec_id == MOTDCT_SPEC_ID)) { rom1394_free_directory(&rom_dir); dv->node = i; port = j; break; } rom1394_free_directory(&rom_dir); } } } if (port == -1) { av_log(context, AV_LOG_ERROR, "No AV/C devices found.\n"); goto fail; } /* Provide bus sanity for multiple connections */ iec61883_cmp_normalize_output(dv->raw1394, 0xffc0 | dv->node); /* Find out if device is DV or HDV */ if (dv->type == IEC61883_AUTO) { response = avc1394_transaction(dv->raw1394, dv->node, AVC1394_CTYPE_STATUS | AVC1394_SUBUNIT_TYPE_TAPE_RECORDER | AVC1394_SUBUNIT_ID_0 | AVC1394_VCR_COMMAND_OUTPUT_SIGNAL_MODE | 0xFF, 2); response = AVC1394_GET_OPERAND0(response); dv->type = (response == 0x10 || response == 0x90 || response == 0x1A || response == 0x9A) ? IEC61883_HDV : IEC61883_DV; } /* Connect to device, and do initialization */ dv->channel = iec61883_cmp_connect(dv->raw1394, dv->node, &dv->output_port, raw1394_get_local_id(dv->raw1394), &dv->input_port, &dv->bandwidth); if (dv->channel < 0) dv->channel = 63; if (!dv->max_packets) dv->max_packets = 100; if (CONFIG_MPEGTS_DEMUXER && dv->type == IEC61883_HDV) { /* Init HDV receive */ avformat_new_stream(context, NULL); dv->mpeg_demux = avpriv_mpegts_parse_open(context); if (!dv->mpeg_demux) goto fail; dv->parse_queue = iec61883_parse_queue_hdv; dv->iec61883_mpeg2 = iec61883_mpeg2_recv_init(dv->raw1394, (iec61883_mpeg2_recv_t)iec61883_callback, dv); dv->max_packets *= 766; } else { /* Init DV receive */ dv->dv_demux = avpriv_dv_init_demux(context); if (!dv->dv_demux) goto fail; dv->parse_queue = iec61883_parse_queue_dv; dv->iec61883_dv = iec61883_dv_fb_init(dv->raw1394, iec61883_callback, dv); } dv->raw1394_poll.fd = raw1394_get_fd(dv->raw1394); dv->raw1394_poll.events = POLLIN | POLLERR | POLLHUP | POLLPRI; /* Actually start receiving */ if (dv->type == IEC61883_HDV) iec61883_mpeg2_recv_start(dv->iec61883_mpeg2, dv->channel); else iec61883_dv_fb_start(dv->iec61883_dv, dv->channel); #if THREADS dv->thread_loop = 1; pthread_mutex_init(&dv->mutex, NULL); pthread_cond_init(&dv->cond, NULL); pthread_create(&dv->receive_task_thread, NULL, iec61883_receive_task, dv); #endif return 0; fail: raw1394_destroy_handle(dv->raw1394); return AVERROR(EIO); }
11,338
1
static int aio_flush_f(BlockBackend *blk, int argc, char **argv) { blk_drain_all(); return 0; }
11,339
1
static int idcin_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; IdcinContext *s = avctx->priv_data; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); s->buf = buf; s->size = buf_size; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); if (avctx->get_buffer(avctx, &s->frame)) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } idcin_decode_vlcs(s); if (pal) { s->frame.palette_has_changed = 1; memcpy(s->pal, pal, AVPALETTE_SIZE); } /* make the palette available on the way out */ memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; /* report that the buffer was completely consumed */ return buf_size; }
11,340
1
void vnc_display_open(DisplayState *ds, const char *display, Error **errp) { VncDisplay *vs = ds ? (VncDisplay *)ds->opaque : vnc_display; const char *options; int password = 0; int reverse = 0; #ifdef CONFIG_VNC_TLS int tls = 0, x509 = 0; #endif #ifdef CONFIG_VNC_SASL int sasl = 0; int saslErr; #endif #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) int acl = 0; #endif int lock_key_sync = 1; if (!vnc_display) { error_setg(errp, "VNC display not active"); return; } vnc_display_close(ds); if (strcmp(display, "none") == 0) return; vs->display = g_strdup(display); vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; options = display; while ((options = strchr(options, ','))) { options++; if (strncmp(options, "password", 8) == 0) { if (fips_get_state()) { error_setg(errp, "VNC password auth disabled due to FIPS mode, " "consider using the VeNCrypt or SASL authentication " "methods as an alternative"); goto fail; } password = 1; /* Require password auth */ } else if (strncmp(options, "reverse", 7) == 0) { reverse = 1; } else if (strncmp(options, "no-lock-key-sync", 16) == 0) { lock_key_sync = 0; #ifdef CONFIG_VNC_SASL } else if (strncmp(options, "sasl", 4) == 0) { sasl = 1; /* Require SASL auth */ #endif #ifdef CONFIG_VNC_WS } else if (strncmp(options, "websocket", 9) == 0) { char *start, *end; vs->websocket = 1; /* Check for 'websocket=<port>' */ start = strchr(options, '='); end = strchr(options, ','); if (start && (!end || (start < end))) { int len = end ? end-(start+1) : strlen(start+1); if (len < 6) { /* extract the host specification from display */ char *host = NULL, *port = NULL, *host_end = NULL; port = g_strndup(start + 1, len); /* ipv6 hosts have colons */ end = strchr(display, ','); host_end = g_strrstr_len(display, end - display, ":"); if (host_end) { host = g_strndup(display, host_end - display + 1); } else { host = g_strndup(":", 1); } vs->ws_display = g_strconcat(host, port, NULL); g_free(host); g_free(port); } } #endif /* CONFIG_VNC_WS */ #ifdef CONFIG_VNC_TLS } else if (strncmp(options, "tls", 3) == 0) { tls = 1; /* Require TLS */ } else if (strncmp(options, "x509", 4) == 0) { char *start, *end; x509 = 1; /* Require x509 certificates */ if (strncmp(options, "x509verify", 10) == 0) vs->tls.x509verify = 1; /* ...and verify client certs */ /* Now check for 'x509=/some/path' postfix * and use that to setup x509 certificate/key paths */ start = strchr(options, '='); end = strchr(options, ','); if (start && (!end || (start < end))) { int len = end ? end-(start+1) : strlen(start+1); char *path = g_strndup(start + 1, len); VNC_DEBUG("Trying certificate path '%s'\n", path); if (vnc_tls_set_x509_creds_dir(vs, path) < 0) { error_setg(errp, "Failed to find x509 certificates/keys in %s", path); g_free(path); goto fail; } g_free(path); } else { error_setg(errp, "No certificate path provided"); goto fail; } #endif #if defined(CONFIG_VNC_TLS) || defined(CONFIG_VNC_SASL) } else if (strncmp(options, "acl", 3) == 0) { acl = 1; #endif } else if (strncmp(options, "lossy", 5) == 0) { vs->lossy = true; } else if (strncmp(options, "non-adaptive", 12) == 0) { vs->non_adaptive = true; } else if (strncmp(options, "share=", 6) == 0) { if (strncmp(options+6, "ignore", 6) == 0) { vs->share_policy = VNC_SHARE_POLICY_IGNORE; } else if (strncmp(options+6, "allow-exclusive", 15) == 0) { vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE; } else if (strncmp(options+6, "force-shared", 12) == 0) { vs->share_policy = VNC_SHARE_POLICY_FORCE_SHARED; } else { error_setg(errp, "unknown vnc share= option"); goto fail; } } } #ifdef CONFIG_VNC_TLS if (acl && x509 && vs->tls.x509verify) { if (!(vs->tls.acl = qemu_acl_init("vnc.x509dname"))) { fprintf(stderr, "Failed to create x509 dname ACL\n"); exit(1); } } #endif #ifdef CONFIG_VNC_SASL if (acl && sasl) { if (!(vs->sasl.acl = qemu_acl_init("vnc.username"))) { fprintf(stderr, "Failed to create username ACL\n"); exit(1); } } #endif /* * Combinations we support here: * * - no-auth (clear text, no auth) * - password (clear text, weak auth) * - sasl (encrypt, good auth *IF* using Kerberos via GSSAPI) * - tls (encrypt, weak anonymous creds, no auth) * - tls + password (encrypt, weak anonymous creds, weak auth) * - tls + sasl (encrypt, weak anonymous creds, good auth) * - tls + x509 (encrypt, good x509 creds, no auth) * - tls + x509 + password (encrypt, good x509 creds, weak auth) * - tls + x509 + sasl (encrypt, good x509 creds, good auth) * * NB1. TLS is a stackable auth scheme. * NB2. the x509 schemes have option to validate a client cert dname */ if (password) { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509VNC; } else { VNC_DEBUG("Initializing VNC server with TLS password auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSVNC; } } else { #endif /* CONFIG_VNC_TLS */ VNC_DEBUG("Initializing VNC server with password auth\n"); vs->auth = VNC_AUTH_VNC; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif /* CONFIG_VNC_TLS */ #ifdef CONFIG_VNC_SASL } else if (sasl) { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509SASL; } else { VNC_DEBUG("Initializing VNC server with TLS SASL auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSSASL; } } else { #endif /* CONFIG_VNC_TLS */ VNC_DEBUG("Initializing VNC server with SASL auth\n"); vs->auth = VNC_AUTH_SASL; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif /* CONFIG_VNC_TLS */ #endif /* CONFIG_VNC_SASL */ } else { #ifdef CONFIG_VNC_TLS if (tls) { vs->auth = VNC_AUTH_VENCRYPT; if (x509) { VNC_DEBUG("Initializing VNC server with x509 no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_X509NONE; } else { VNC_DEBUG("Initializing VNC server with TLS no auth\n"); vs->subauth = VNC_AUTH_VENCRYPT_TLSNONE; } } else { #endif VNC_DEBUG("Initializing VNC server with no auth\n"); vs->auth = VNC_AUTH_NONE; #ifdef CONFIG_VNC_TLS vs->subauth = VNC_AUTH_INVALID; } #endif } #ifdef CONFIG_VNC_SASL if ((saslErr = sasl_server_init(NULL, "qemu")) != SASL_OK) { error_setg(errp, "Failed to initialize SASL auth: %s", sasl_errstring(saslErr, NULL, NULL)); goto fail; } #endif vs->lock_key_sync = lock_key_sync; if (reverse) { /* connect to viewer */ int csock; vs->lsock = -1; #ifdef CONFIG_VNC_WS vs->lwebsock = -1; #endif if (strncmp(display, "unix:", 5) == 0) { csock = unix_connect(display+5, errp); } else { csock = inet_connect(display, errp); } if (csock < 0) { goto fail; } vnc_connect(vs, csock, 0, 0); } else { /* listen for connects */ char *dpy; dpy = g_malloc(256); if (strncmp(display, "unix:", 5) == 0) { pstrcpy(dpy, 256, "unix:"); vs->lsock = unix_listen(display+5, dpy+5, 256-5, errp); } else { vs->lsock = inet_listen(display, dpy, 256, SOCK_STREAM, 5900, errp); if (vs->lsock < 0) { g_free(dpy); goto fail; } #ifdef CONFIG_VNC_WS if (vs->websocket) { if (vs->ws_display) { vs->lwebsock = inet_listen(vs->ws_display, NULL, 256, SOCK_STREAM, 0, errp); } else { vs->lwebsock = inet_listen(vs->display, NULL, 256, SOCK_STREAM, 5700, errp); } if (vs->lwebsock < 0) { if (vs->lsock) { close(vs->lsock); vs->lsock = -1; } g_free(dpy); goto fail; } } #endif /* CONFIG_VNC_WS */ } g_free(vs->display); vs->display = dpy; qemu_set_fd_handler2(vs->lsock, NULL, vnc_listen_regular_read, NULL, vs); #ifdef CONFIG_VNC_WS if (vs->websocket) { qemu_set_fd_handler2(vs->lwebsock, NULL, vnc_listen_websocket_read, NULL, vs); } #endif /* CONFIG_VNC_WS */ } return; fail: g_free(vs->display); vs->display = NULL; #ifdef CONFIG_VNC_WS g_free(vs->ws_display); vs->ws_display = NULL; #endif /* CONFIG_VNC_WS */ }
11,341
1
bdrv_rw_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos, bool is_read) { if (qemu_in_coroutine()) { return bdrv_co_rw_vmstate(bs, qiov, pos, is_read); } else { BdrvVmstateCo data = { .bs = bs, .qiov = qiov, .pos = pos, .is_read = is_read, .ret = -EINPROGRESS, }; Coroutine *co = qemu_coroutine_create(bdrv_co_rw_vmstate_entry, &data); qemu_coroutine_enter(co); while (data.ret == -EINPROGRESS) { aio_poll(bdrv_get_aio_context(bs), true); } return data.ret; } }
11,342
1
static void exit_program(void) { int i, j; for (i = 0; i < nb_filtergraphs; i++) { avfilter_graph_free(&filtergraphs[i]->graph); for (j = 0; j < filtergraphs[i]->nb_inputs; j++) { av_freep(&filtergraphs[i]->inputs[j]->name); av_freep(&filtergraphs[i]->inputs[j]); } av_freep(&filtergraphs[i]->inputs); for (j = 0; j < filtergraphs[i]->nb_outputs; j++) { av_freep(&filtergraphs[i]->outputs[j]->name); av_freep(&filtergraphs[i]->outputs[j]); } av_freep(&filtergraphs[i]->outputs); av_freep(&filtergraphs[i]->graph_desc); av_freep(&filtergraphs[i]); } av_freep(&filtergraphs); /* close files */ for (i = 0; i < nb_output_files; i++) { AVFormatContext *s = output_files[i]->ctx; if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE) && s->pb) avio_close(s->pb); avformat_free_context(s); av_dict_free(&output_files[i]->opts); av_freep(&output_files[i]); } for (i = 0; i < nb_output_streams; i++) { AVBitStreamFilterContext *bsfc = output_streams[i]->bitstream_filters; while (bsfc) { AVBitStreamFilterContext *next = bsfc->next; av_bitstream_filter_close(bsfc); bsfc = next; } output_streams[i]->bitstream_filters = NULL; avcodec_free_frame(&output_streams[i]->filtered_frame); av_freep(&output_streams[i]->forced_keyframes); av_freep(&output_streams[i]->avfilter); av_freep(&output_streams[i]->logfile_prefix); av_freep(&output_streams[i]); } for (i = 0; i < nb_input_files; i++) { avformat_close_input(&input_files[i]->ctx); av_freep(&input_files[i]); } for (i = 0; i < nb_input_streams; i++) { av_frame_free(&input_streams[i]->decoded_frame); av_frame_free(&input_streams[i]->filter_frame); av_dict_free(&input_streams[i]->opts); av_freep(&input_streams[i]->filters); av_freep(&input_streams[i]); } if (vstats_file) fclose(vstats_file); av_free(vstats_filename); av_freep(&input_streams); av_freep(&input_files); av_freep(&output_streams); av_freep(&output_files); uninit_opts(); avformat_network_deinit(); if (received_sigterm) { av_log(NULL, AV_LOG_INFO, "Received signal %d: terminating.\n", (int) received_sigterm); exit (255); } }
11,344
1
static bool scsi_target_emulate_report_luns(SCSITargetReq *r) { BusChild *kid; int i, len, n; int channel, id; bool found_lun0; if (r->req.cmd.xfer < 16) { return false; } if (r->req.cmd.buf[2] > 2) { return false; } channel = r->req.dev->channel; id = r->req.dev->id; found_lun0 = false; n = 0; QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { DeviceState *qdev = kid->child; SCSIDevice *dev = SCSI_DEVICE(qdev); if (dev->channel == channel && dev->id == id) { if (dev->lun == 0) { found_lun0 = true; } n += 8; } } if (!found_lun0) { n += 8; } len = MIN(n + 8, r->req.cmd.xfer & ~7); if (len > sizeof(r->buf)) { /* TODO: > 256 LUNs? */ return false; } memset(r->buf, 0, len); stl_be_p(&r->buf, n); i = found_lun0 ? 8 : 16; QTAILQ_FOREACH(kid, &r->req.bus->qbus.children, sibling) { DeviceState *qdev = kid->child; SCSIDevice *dev = SCSI_DEVICE(qdev); if (dev->channel == channel && dev->id == id) { store_lun(&r->buf[i], dev->lun); i += 8; } } assert(i == n + 8); r->len = len; return true; }
11,345
1
static int check_directory_consistency(BDRVVVFATState *s, int cluster_num, const char* path) { int ret = 0; unsigned char* cluster = qemu_malloc(s->cluster_size); direntry_t* direntries = (direntry_t*)cluster; mapping_t* mapping = find_mapping_for_cluster(s, cluster_num); long_file_name lfn; int path_len = strlen(path); char path2[PATH_MAX]; assert(path_len < PATH_MAX); /* len was tested before! */ pstrcpy(path2, sizeof(path2), path); path2[path_len] = '/'; path2[path_len + 1] = '\0'; if (mapping) { const char* basename = get_basename(mapping->path); const char* basename2 = get_basename(path); assert(mapping->mode & MODE_DIRECTORY); assert(mapping->mode & MODE_DELETED); mapping->mode &= ~MODE_DELETED; if (strcmp(basename, basename2)) schedule_rename(s, cluster_num, strdup(path)); } else /* new directory */ schedule_mkdir(s, cluster_num, strdup(path)); lfn_init(&lfn); do { int i; int subret = 0; ret++; if (s->used_clusters[cluster_num] & USED_ANY) { fprintf(stderr, "cluster %d used more than once\n", (int)cluster_num); return 0; } s->used_clusters[cluster_num] = USED_DIRECTORY; DLOG(fprintf(stderr, "read cluster %d (sector %d)\n", (int)cluster_num, (int)cluster2sector(s, cluster_num))); subret = vvfat_read(s->bs, cluster2sector(s, cluster_num), cluster, s->sectors_per_cluster); if (subret) { fprintf(stderr, "Error fetching direntries\n"); fail: free(cluster); return 0; } for (i = 0; i < 0x10 * s->sectors_per_cluster; i++) { int cluster_count = 0; DLOG(fprintf(stderr, "check direntry %d: \n", i); print_direntry(direntries + i)); if (is_volume_label(direntries + i) || is_dot(direntries + i) || is_free(direntries + i)) continue; subret = parse_long_name(&lfn, direntries + i); if (subret < 0) { fprintf(stderr, "Error in long name\n"); goto fail; } if (subret == 0 || is_free(direntries + i)) continue; if (fat_chksum(direntries+i) != lfn.checksum) { subret = parse_short_name(s, &lfn, direntries + i); if (subret < 0) { fprintf(stderr, "Error in short name (%d)\n", subret); goto fail; } if (subret > 0 || !strcmp((char*)lfn.name, ".") || !strcmp((char*)lfn.name, "..")) continue; } lfn.checksum = 0x100; /* cannot use long name twice */ if (path_len + 1 + lfn.len >= PATH_MAX) { fprintf(stderr, "Name too long: %s/%s\n", path, lfn.name); goto fail; } pstrcpy(path2 + path_len + 1, sizeof(path2) - path_len - 1, (char*)lfn.name); if (is_directory(direntries + i)) { if (begin_of_direntry(direntries + i) == 0) { DLOG(fprintf(stderr, "invalid begin for directory: %s\n", path2); print_direntry(direntries + i)); goto fail; } cluster_count = check_directory_consistency(s, begin_of_direntry(direntries + i), path2); if (cluster_count == 0) { DLOG(fprintf(stderr, "problem in directory %s:\n", path2); print_direntry(direntries + i)); goto fail; } } else if (is_file(direntries + i)) { /* check file size with FAT */ cluster_count = get_cluster_count_for_direntry(s, direntries + i, path2); if (cluster_count != (le32_to_cpu(direntries[i].size) + s->cluster_size - 1) / s->cluster_size) { DLOG(fprintf(stderr, "Cluster count mismatch\n")); goto fail; } } else assert(0); /* cluster_count = 0; */ ret += cluster_count; } cluster_num = modified_fat_get(s, cluster_num); } while(!fat_eof(s, cluster_num)); free(cluster); return ret; }
11,346
1
static int rpl_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; RPLContext *rpl = s->priv_data; AVStream *vst = NULL, *ast = NULL; int total_audio_size; int error = 0; uint32_t i; int32_t audio_format, chunk_catalog_offset, number_of_chunks; AVRational fps; char line[RPL_LINE_LENGTH]; // The header for RPL/ARMovie files is 21 lines of text // containing the various header fields. The fields are always // in the same order, and other text besides the first // number usually isn't important. // (The spec says that there exists some significance // for the text in a few cases; samples needed.) error |= read_line(pb, line, sizeof(line)); // ARMovie error |= read_line(pb, line, sizeof(line)); // movie name av_dict_set(&s->metadata, "title" , line, 0); error |= read_line(pb, line, sizeof(line)); // date/copyright av_dict_set(&s->metadata, "copyright", line, 0); error |= read_line(pb, line, sizeof(line)); // author and other av_dict_set(&s->metadata, "author" , line, 0); // video headers vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_tag = read_line_and_int(pb, &error); // video format vst->codec->width = read_line_and_int(pb, &error); // video width vst->codec->height = read_line_and_int(pb, &error); // video height vst->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // video bits per sample error |= read_line(pb, line, sizeof(line)); // video frames per second fps = read_fps(line, &error); avpriv_set_pts_info(vst, 32, fps.den, fps.num); // Figure out the video codec switch (vst->codec->codec_tag) { #if 0 case 122: vst->codec->codec_id = AV_CODEC_ID_ESCAPE122; break; #endif case 124: vst->codec->codec_id = AV_CODEC_ID_ESCAPE124; // The header is wrong here, at least sometimes vst->codec->bits_per_coded_sample = 16; break; case 130: vst->codec->codec_id = AV_CODEC_ID_ESCAPE130; break; default: avpriv_report_missing_feature(s, "Video format %i", vst->codec->codec_tag); vst->codec->codec_id = AV_CODEC_ID_NONE; } // Audio headers // ARMovie supports multiple audio tracks; I don't have any // samples, though. This code will ignore additional tracks. audio_format = read_line_and_int(pb, &error); // audio format ID if (audio_format) { ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_tag = audio_format; ast->codec->sample_rate = read_line_and_int(pb, &error); // audio bitrate ast->codec->channels = read_line_and_int(pb, &error); // number of audio channels ast->codec->bits_per_coded_sample = read_line_and_int(pb, &error); // audio bits per sample // At least one sample uses 0 for ADPCM, which is really 4 bits // per sample. if (ast->codec->bits_per_coded_sample == 0) ast->codec->bits_per_coded_sample = 4; ast->codec->bit_rate = ast->codec->sample_rate * ast->codec->bits_per_coded_sample * ast->codec->channels; ast->codec->codec_id = AV_CODEC_ID_NONE; switch (audio_format) { case 1: if (ast->codec->bits_per_coded_sample == 16) { // 16-bit audio is always signed ast->codec->codec_id = AV_CODEC_ID_PCM_S16LE; break; } // There are some other formats listed as legal per the spec; // samples needed. break; case 101: if (ast->codec->bits_per_coded_sample == 8) { // The samples with this kind of audio that I have // are all unsigned. ast->codec->codec_id = AV_CODEC_ID_PCM_U8; break; } else if (ast->codec->bits_per_coded_sample == 4) { ast->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_EA_SEAD; break; } break; } if (ast->codec->codec_id == AV_CODEC_ID_NONE) avpriv_request_sample(s, "Audio format %i", audio_format); avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate); } else { for (i = 0; i < 3; i++) error |= read_line(pb, line, sizeof(line)); } rpl->frames_per_chunk = read_line_and_int(pb, &error); // video frames per chunk if (rpl->frames_per_chunk > 1 && vst->codec->codec_tag != 124) av_log(s, AV_LOG_WARNING, "Don't know how to split frames for video format %i. " "Video stream will be broken!\n", vst->codec->codec_tag); number_of_chunks = read_line_and_int(pb, &error); // number of chunks in the file // The number in the header is actually the index of the last chunk. number_of_chunks++; error |= read_line(pb, line, sizeof(line)); // "even" chunk size in bytes error |= read_line(pb, line, sizeof(line)); // "odd" chunk size in bytes chunk_catalog_offset = // offset of the "chunk catalog" read_line_and_int(pb, &error); // (file index) error |= read_line(pb, line, sizeof(line)); // offset to "helpful" sprite error |= read_line(pb, line, sizeof(line)); // size of "helpful" sprite error |= read_line(pb, line, sizeof(line)); // offset to key frame list // Read the index avio_seek(pb, chunk_catalog_offset, SEEK_SET); total_audio_size = 0; for (i = 0; !error && i < number_of_chunks; i++) { int64_t offset, video_size, audio_size; error |= read_line(pb, line, sizeof(line)); if (3 != sscanf(line, "%"SCNd64" , %"SCNd64" ; %"SCNd64, &offset, &video_size, &audio_size)) error = -1; av_add_index_entry(vst, offset, i * rpl->frames_per_chunk, video_size, rpl->frames_per_chunk, 0); if (ast) av_add_index_entry(ast, offset + video_size, total_audio_size, audio_size, audio_size * 8, 0); total_audio_size += audio_size * 8; } if (error) return AVERROR(EIO); return 0; }
11,347
1
static void h264_free_context(PayloadContext *data) { #ifdef DEBUG int ii; for (ii = 0; ii < 32; ii++) { if (data->packet_types_received[ii]) av_log(NULL, AV_LOG_DEBUG, "Received %d packets of type %d\n", data->packet_types_received[ii], ii); } #endif assert(data); assert(data->cookie == MAGIC_COOKIE); // avoid stale pointers (assert) data->cookie = DEAD_COOKIE; // and clear out this... av_free(data); }
11,348
1
static void mirror_iteration_done(MirrorOp *op, int ret) { MirrorBlockJob *s = op->s; struct iovec *iov; int64_t chunk_num; int i, nb_chunks, sectors_per_chunk; trace_mirror_iteration_done(s, op->sector_num, op->nb_sectors, ret); s->in_flight--; s->sectors_in_flight -= op->nb_sectors; iov = op->qiov.iov; for (i = 0; i < op->qiov.niov; i++) { MirrorBuffer *buf = (MirrorBuffer *) iov[i].iov_base; QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); s->buf_free_count++; } sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS; chunk_num = op->sector_num / sectors_per_chunk; nb_chunks = DIV_ROUND_UP(op->nb_sectors, sectors_per_chunk); bitmap_clear(s->in_flight_bitmap, chunk_num, nb_chunks); if (ret >= 0) { if (s->cow_bitmap) { bitmap_set(s->cow_bitmap, chunk_num, nb_chunks); } s->common.offset += (uint64_t)op->nb_sectors * BDRV_SECTOR_SIZE; } qemu_iovec_destroy(&op->qiov); g_free(op); if (s->waiting_for_io) { qemu_coroutine_enter(s->common.co, NULL); } }
11,350
1
static int find_image_range(int *pfirst_index, int *plast_index, const char *path, int start_index) { char buf[1024]; int range, last_index, range1, first_index; /* find the first image */ for (first_index = start_index; first_index < start_index + 5; first_index++) { if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){ *pfirst_index = *plast_index = 1; if (avio_check(buf, AVIO_FLAG_READ) > 0) return 0; return -1; } if (avio_check(buf, AVIO_FLAG_READ) > 0) break; } if (first_index == 5) goto fail; /* find the last image */ last_index = first_index; for(;;) { range = 0; for(;;) { if (!range) range1 = 1; else range1 = 2 * range; if (av_get_frame_filename(buf, sizeof(buf), path, last_index + range1) < 0) goto fail; if (avio_check(buf, AVIO_FLAG_READ) <= 0) break; range = range1; /* just in case... */ if (range >= (1 << 30)) goto fail; } /* we are sure than image last_index + range exists */ if (!range) break; last_index += range; } *pfirst_index = first_index; *plast_index = last_index; return 0; fail: return -1; }
11,351
0
av_cold int ff_cavs_init(AVCodecContext *avctx) { AVSContext *h = avctx->priv_data; ff_blockdsp_init(&h->bdsp, avctx); ff_h264chroma_init(&h->h264chroma, 8); ff_idctdsp_init(&h->idsp, avctx); ff_videodsp_init(&h->vdsp, 8); ff_cavsdsp_init(&h->cdsp, avctx); ff_init_scantable_permutation(h->idsp.idct_permutation, h->cdsp.idct_perm); ff_init_scantable(h->idsp.idct_permutation, &h->scantable, ff_zigzag_direct); h->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_YUV420P; h->cur.f = av_frame_alloc(); h->DPB[0].f = av_frame_alloc(); h->DPB[1].f = av_frame_alloc(); if (!h->cur.f || !h->DPB[0].f || !h->DPB[1].f) { ff_cavs_end(avctx); return AVERROR(ENOMEM); } h->luma_scan[0] = 0; h->luma_scan[1] = 8; h->intra_pred_l[INTRA_L_VERT] = intra_pred_vert; h->intra_pred_l[INTRA_L_HORIZ] = intra_pred_horiz; h->intra_pred_l[INTRA_L_LP] = intra_pred_lp; h->intra_pred_l[INTRA_L_DOWN_LEFT] = intra_pred_down_left; h->intra_pred_l[INTRA_L_DOWN_RIGHT] = intra_pred_down_right; h->intra_pred_l[INTRA_L_LP_LEFT] = intra_pred_lp_left; h->intra_pred_l[INTRA_L_LP_TOP] = intra_pred_lp_top; h->intra_pred_l[INTRA_L_DC_128] = intra_pred_dc_128; h->intra_pred_c[INTRA_C_LP] = intra_pred_lp; h->intra_pred_c[INTRA_C_HORIZ] = intra_pred_horiz; h->intra_pred_c[INTRA_C_VERT] = intra_pred_vert; h->intra_pred_c[INTRA_C_PLANE] = intra_pred_plane; h->intra_pred_c[INTRA_C_LP_LEFT] = intra_pred_lp_left; h->intra_pred_c[INTRA_C_LP_TOP] = intra_pred_lp_top; h->intra_pred_c[INTRA_C_DC_128] = intra_pred_dc_128; h->mv[7] = un_mv; h->mv[19] = un_mv; return 0; }
11,352
0
static int filter_packet(void *log_ctx, AVPacket *pkt, AVFormatContext *fmt_ctx, AVBitStreamFilterContext *bsf_ctx) { AVCodecContext *enc_ctx = fmt_ctx->streams[pkt->stream_index]->codec; int ret = 0; while (bsf_ctx) { AVPacket new_pkt = *pkt; ret = av_bitstream_filter_filter(bsf_ctx, enc_ctx, NULL, &new_pkt.data, &new_pkt.size, pkt->data, pkt->size, pkt->flags & AV_PKT_FLAG_KEY); if (ret == 0 && new_pkt.data != pkt->data && new_pkt.destruct) { if ((ret = av_copy_packet(&new_pkt, pkt)) < 0) break; ret = 1; } if (ret > 0) { av_free_packet(pkt); new_pkt.buf = av_buffer_create(new_pkt.data, new_pkt.size, av_buffer_default_free, NULL, 0); if (!new_pkt.buf) break; } if (ret < 0) { av_log(log_ctx, AV_LOG_ERROR, "Failed to filter bitstream with filter %s for stream %d in file '%s' with codec %s\n", bsf_ctx->filter->name, pkt->stream_index, fmt_ctx->filename, avcodec_get_name(enc_ctx->codec_id)); } *pkt = new_pkt; bsf_ctx = bsf_ctx->next; } return ret; }
11,353
1
static void nbd_client_close(NBDClient *client) { qemu_set_fd_handler2(client->sock, NULL, NULL, NULL, NULL); close(client->sock); client->sock = -1; if (client->close) { client->close(client); } nbd_client_put(client); }
11,355
0
int avio_close(AVIOContext *s) { AVIOInternal *internal; URLContext *h; if (!s) return 0; avio_flush(s); internal = s->opaque; h = internal->h; av_opt_free(internal); av_freep(&internal->protocols); av_freep(&s->opaque); av_freep(&s->buffer); av_free(s); return ffurl_close(h); }
11,356
1
int ff_jni_init_jfields(JNIEnv *env, void *jfields, const struct FFJniField *jfields_mapping, int global, void *log_ctx) { int i, ret = 0; jclass last_clazz = NULL; for (i = 0; jfields_mapping[i].name; i++) { int mandatory = jfields_mapping[i].mandatory; enum FFJniFieldType type = jfields_mapping[i].type; if (type == FF_JNI_CLASS) { jclass clazz; last_clazz = NULL; clazz = (*env)->FindClass(env, jfields_mapping[i].name); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; last_clazz = *(jclass*)((uint8_t*)jfields + jfields_mapping[i].offset) = global ? (*env)->NewGlobalRef(env, clazz) : clazz; } else { if (!last_clazz) { ret = AVERROR_EXTERNAL; break; switch(type) { case FF_JNI_FIELD: { jfieldID field_id = (*env)->GetFieldID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jfieldID*)((uint8_t*)jfields + jfields_mapping[i].offset) = field_id; break; case FF_JNI_STATIC_FIELD: { jfieldID field_id = (*env)->GetStaticFieldID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jfieldID*)((uint8_t*)jfields + jfields_mapping[i].offset) = field_id; break; case FF_JNI_METHOD: { jmethodID method_id = (*env)->GetMethodID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jmethodID*)((uint8_t*)jfields + jfields_mapping[i].offset) = method_id; break; case FF_JNI_STATIC_METHOD: { jmethodID method_id = (*env)->GetStaticMethodID(env, last_clazz, jfields_mapping[i].method, jfields_mapping[i].signature); if ((ret = ff_jni_exception_check(env, mandatory, log_ctx)) < 0 && mandatory) { goto done; *(jmethodID*)((uint8_t*)jfields + jfields_mapping[i].offset) = method_id; break; default: av_log(log_ctx, AV_LOG_ERROR, "Unknown JNI field type\n"); ret = AVERROR(EINVAL); goto done; ret = 0; done: if (ret < 0) { /* reset jfields in case of failure so it does not leak references */ ff_jni_reset_jfields(env, jfields, jfields_mapping, global, log_ctx); return ret;
11,358
1
static int coroutine_fn bdrv_co_do_copy_on_readv(BdrvChild *child, int64_t offset, unsigned int bytes, QEMUIOVector *qiov) { BlockDriverState *bs = child->bs; /* Perform I/O through a temporary buffer so that users who scribble over * their read buffer while the operation is in progress do not end up * modifying the image file. This is critical for zero-copy guest I/O * where anything might happen inside guest memory. */ void *bounce_buffer; BlockDriver *drv = bs->drv; struct iovec iov; QEMUIOVector bounce_qiov; int64_t cluster_offset; unsigned int cluster_bytes; size_t skip_bytes; int ret; assert(child->perm & (BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE)); /* Cover entire cluster so no additional backing file I/O is required when * allocating cluster in the image file. */ bdrv_round_to_clusters(bs, offset, bytes, &cluster_offset, &cluster_bytes); trace_bdrv_co_do_copy_on_readv(bs, offset, bytes, cluster_offset, cluster_bytes); iov.iov_len = cluster_bytes; iov.iov_base = bounce_buffer = qemu_try_blockalign(bs, iov.iov_len); if (bounce_buffer == NULL) { ret = -ENOMEM; goto err; } qemu_iovec_init_external(&bounce_qiov, &iov, 1); ret = bdrv_driver_preadv(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); if (ret < 0) { goto err; } if (drv->bdrv_co_pwrite_zeroes && buffer_is_zero(bounce_buffer, iov.iov_len)) { /* FIXME: Should we (perhaps conditionally) be setting * BDRV_REQ_MAY_UNMAP, if it will allow for a sparser copy * that still correctly reads as zero? */ ret = bdrv_co_do_pwrite_zeroes(bs, cluster_offset, cluster_bytes, 0); } else { /* This does not change the data on the disk, it is not necessary * to flush even in cache=writethrough mode. */ ret = bdrv_driver_pwritev(bs, cluster_offset, cluster_bytes, &bounce_qiov, 0); } if (ret < 0) { /* It might be okay to ignore write errors for guest requests. If this * is a deliberate copy-on-read then we don't want to ignore the error. * Simply report it in all cases. */ goto err; } skip_bytes = offset - cluster_offset; qemu_iovec_from_buf(qiov, 0, bounce_buffer + skip_bytes, bytes); err: qemu_vfree(bounce_buffer); return ret; }
11,360
1
static int img_bench(int argc, char **argv) { int c, ret = 0; const char *fmt = NULL, *filename; bool quiet = false; bool image_opts = false; bool is_write = false; int count = 75000; int depth = 64; int64_t offset = 0; size_t bufsize = 4096; int pattern = 0; size_t step = 0; int flush_interval = 0; bool drain_on_flush = true; int64_t image_size; BlockBackend *blk = NULL; BenchData data = {}; int flags = 0; bool writethrough = false; struct timeval t1, t2; int i; for (;;) { static const struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"flush-interval", required_argument, 0, OPTION_FLUSH_INTERVAL}, {"image-opts", no_argument, 0, OPTION_IMAGE_OPTS}, {"pattern", required_argument, 0, OPTION_PATTERN}, {"no-drain", no_argument, 0, OPTION_NO_DRAIN}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "hc:d:f:no:qs:S:t:w", long_options, NULL); if (c == -1) { break; } switch (c) { case 'h': case '?': help(); break; case 'c': { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { error_report("Invalid request count specified"); return 1; } count = res; break; } case 'd': { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { error_report("Invalid queue depth specified"); return 1; } depth = res; break; } case 'f': fmt = optarg; break; case 'n': flags |= BDRV_O_NATIVE_AIO; break; case 'o': { offset = cvtnum(optarg); if (offset < 0) { error_report("Invalid offset specified"); return 1; } break; } break; case 'q': quiet = true; break; case 's': { int64_t sval; sval = cvtnum(optarg); if (sval < 0 || sval > INT_MAX) { error_report("Invalid buffer size specified"); return 1; } bufsize = sval; break; } case 'S': { int64_t sval; sval = cvtnum(optarg); if (sval < 0 || sval > INT_MAX) { error_report("Invalid step size specified"); return 1; } step = sval; break; } case 't': ret = bdrv_parse_cache_mode(optarg, &flags, &writethrough); if (ret < 0) { error_report("Invalid cache mode"); ret = -1; goto out; } break; case 'w': flags |= BDRV_O_RDWR; is_write = true; break; case OPTION_PATTERN: { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > 0xff) { error_report("Invalid pattern byte specified"); return 1; } pattern = res; break; } case OPTION_FLUSH_INTERVAL: { unsigned long res; if (qemu_strtoul(optarg, NULL, 0, &res) < 0 || res > INT_MAX) { error_report("Invalid flush interval specified"); return 1; } flush_interval = res; break; } case OPTION_NO_DRAIN: drain_on_flush = false; break; case OPTION_IMAGE_OPTS: image_opts = true; break; } } if (optind != argc - 1) { error_exit("Expecting one image file name"); } filename = argv[argc - 1]; if (!is_write && flush_interval) { error_report("--flush-interval is only available in write tests"); ret = -1; goto out; } if (flush_interval && flush_interval < depth) { error_report("Flush interval can't be smaller than depth"); ret = -1; goto out; } blk = img_open(image_opts, filename, fmt, flags, writethrough, quiet); if (!blk) { ret = -1; goto out; } image_size = blk_getlength(blk); if (image_size < 0) { ret = image_size; goto out; } data = (BenchData) { .blk = blk, .image_size = image_size, .bufsize = bufsize, .step = step ?: bufsize, .nrreq = depth, .n = count, .offset = offset, .write = is_write, .flush_interval = flush_interval, .drain_on_flush = drain_on_flush, }; printf("Sending %d %s requests, %d bytes each, %d in parallel " "(starting at offset %" PRId64 ", step size %d)\n", data.n, data.write ? "write" : "read", data.bufsize, data.nrreq, data.offset, data.step); if (flush_interval) { printf("Sending flush every %d requests\n", flush_interval); } data.buf = blk_blockalign(blk, data.nrreq * data.bufsize); memset(data.buf, pattern, data.nrreq * data.bufsize); data.qiov = g_new(QEMUIOVector, data.nrreq); for (i = 0; i < data.nrreq; i++) { qemu_iovec_init(&data.qiov[i], 1); qemu_iovec_add(&data.qiov[i], data.buf + i * data.bufsize, data.bufsize); } gettimeofday(&t1, NULL); bench_cb(&data, 0); while (data.n > 0) { main_loop_wait(false); } gettimeofday(&t2, NULL); printf("Run completed in %3.3f seconds.\n", (t2.tv_sec - t1.tv_sec) + ((double)(t2.tv_usec - t1.tv_usec) / 1000000)); out: qemu_vfree(data.buf); blk_unref(blk); if (ret) { return 1; } return 0; }
11,362
1
void object_property_add_link(Object *obj, const char *name, const char *type, Object **child, Error **errp) { gchar *full_type; full_type = g_strdup_printf("link<%s>", type); object_property_add(obj, name, full_type, object_get_link_property, object_set_link_property, NULL, child, errp); g_free(full_type); }
11,363
1
static void process_event(JSONMessageParser *parser, QList *tokens) { GAState *s = container_of(parser, GAState, parser); QObject *obj; QDict *qdict; Error *err = NULL; int ret; g_assert(s && parser); g_debug("process_event: called"); obj = json_parser_parse_err(tokens, NULL, &err); if (err || !obj || qobject_type(obj) != QTYPE_QDICT) { qobject_decref(obj); qdict = qdict_new(); if (!err) { g_warning("failed to parse event: unknown error"); error_setg(&err, QERR_JSON_PARSING); } else { g_warning("failed to parse event: %s", error_get_pretty(err)); } qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); } else { qdict = qobject_to_qdict(obj); } g_assert(qdict); /* handle host->guest commands */ if (qdict_haskey(qdict, "execute")) { process_command(s, qdict); } else { if (!qdict_haskey(qdict, "error")) { QDECREF(qdict); qdict = qdict_new(); g_warning("unrecognized payload format"); error_setg(&err, QERR_UNSUPPORTED); qdict_put_obj(qdict, "error", qmp_build_error_object(err)); error_free(err); } ret = send_response(s, QOBJECT(qdict)); if (ret < 0) { g_warning("error sending error response: %s", strerror(-ret)); } } QDECREF(qdict); }
11,364
1
static inline void RENAME(rgb32tobgr24)(const uint8_t *src, uint8_t *dst, int src_size) { uint8_t *dest = dst; const uint8_t *s = src; const uint8_t *end; const uint8_t *mm_end; end = s + src_size; __asm__ volatile(PREFETCH" %0"::"m"(*s):"memory"); mm_end = end - 31; while (s < mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm1 \n\t" "movq 16%1, %%mm4 \n\t" "movq 24%1, %%mm5 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "movq %%mm4, %%mm6 \n\t" "movq %%mm5, %%mm7 \n\t" STORE_BGR24_MMX :"=m"(*dest) :"m"(*s) :"memory"); dest += 24; s += 32; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); while (s < end) { *dest++ = *s++; *dest++ = *s++; *dest++ = *s++; s++; } }
11,365
1
static void slice_thread_park_workers(ThreadContext *c) { pthread_cond_wait(&c->last_job_cond, &c->current_job_lock); pthread_mutex_unlock(&c->current_job_lock); }
11,366
0
static av_cold int ljpeg_encode_init(AVCodecContext *avctx) { LJpegEncContext *s = avctx->priv_data; int chroma_v_shift, chroma_h_shift; if ((avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUV444P) && avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { av_log(avctx, AV_LOG_ERROR, "Limited range YUV is non-standard, set strict_std_compliance to " "at least unofficial to use it.\n"); return AVERROR(EINVAL); } avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; s->scratch = av_malloc_array(avctx->width + 1, sizeof(*s->scratch)); ff_dsputil_init(&s->dsp, avctx); ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct); av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &chroma_h_shift, &chroma_v_shift); if (avctx->pix_fmt == AV_PIX_FMT_BGR24) { s->vsample[0] = s->hsample[0] = s->vsample[1] = s->hsample[1] = s->vsample[2] = s->hsample[2] = 1; } else { s->vsample[0] = 2; s->vsample[1] = 2 >> chroma_v_shift; s->vsample[2] = 2 >> chroma_v_shift; s->hsample[0] = 2; s->hsample[1] = 2 >> chroma_h_shift; s->hsample[2] = 2 >> chroma_h_shift; } ff_mjpeg_build_huffman_codes(s->huff_size_dc_luminance, s->huff_code_dc_luminance, avpriv_mjpeg_bits_dc_luminance, avpriv_mjpeg_val_dc); ff_mjpeg_build_huffman_codes(s->huff_size_dc_chrominance, s->huff_code_dc_chrominance, avpriv_mjpeg_bits_dc_chrominance, avpriv_mjpeg_val_dc); return 0; }
11,367
1
static PCIDevice *do_pci_register_device(PCIDevice *pci_dev, PCIBus *bus, const char *name, int devfn, Error **errp) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); PCIConfigReadFunc *config_read = pc->config_read; PCIConfigWriteFunc *config_write = pc->config_write; Error *local_err = NULL; AddressSpace *dma_as; DeviceState *dev = DEVICE(pci_dev); pci_dev->bus = bus; /* Only pci bridges can be attached to extra PCI root buses */ if (pci_bus_is_root(bus) && bus->parent_dev && !pc->is_bridge) { error_setg(errp, "PCI: Only PCI/PCIe bridges can be plugged into %s", bus->parent_dev->name); return NULL; } if (devfn < 0) { for(devfn = bus->devfn_min ; devfn < ARRAY_SIZE(bus->devices); devfn += PCI_FUNC_MAX) { if (!bus->devices[devfn]) goto found; } error_setg(errp, "PCI: no slot/function available for %s, all in use", name); return NULL; found: ; } else if (bus->devices[devfn]) { error_setg(errp, "PCI: slot %d function %d not available for %s," " in use by %s", PCI_SLOT(devfn), PCI_FUNC(devfn), name, bus->devices[devfn]->name); return NULL; } else if (dev->hotplugged && pci_get_function_0(pci_dev)) { error_setg(errp, "PCI: slot %d function 0 already ocuppied by %s," " new func %s cannot be exposed to guest.", PCI_SLOT(devfn), bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name, name); return NULL; } pci_dev->devfn = devfn; dma_as = pci_device_iommu_address_space(pci_dev); memory_region_init_alias(&pci_dev->bus_master_enable_region, OBJECT(pci_dev), "bus master", dma_as->root, 0, memory_region_size(dma_as->root)); memory_region_set_enabled(&pci_dev->bus_master_enable_region, false); address_space_init(&pci_dev->bus_master_as, &pci_dev->bus_master_enable_region, name); pstrcpy(pci_dev->name, sizeof(pci_dev->name), name); pci_dev->irq_state = 0; pci_config_alloc(pci_dev); pci_config_set_vendor_id(pci_dev->config, pc->vendor_id); pci_config_set_device_id(pci_dev->config, pc->device_id); pci_config_set_revision(pci_dev->config, pc->revision); pci_config_set_class(pci_dev->config, pc->class_id); if (!pc->is_bridge) { if (pc->subsystem_vendor_id || pc->subsystem_id) { pci_set_word(pci_dev->config + PCI_SUBSYSTEM_VENDOR_ID, pc->subsystem_vendor_id); pci_set_word(pci_dev->config + PCI_SUBSYSTEM_ID, pc->subsystem_id); } else { pci_set_default_subsystem_id(pci_dev); } } else { /* subsystem_vendor_id/subsystem_id are only for header type 0 */ assert(!pc->subsystem_vendor_id); assert(!pc->subsystem_id); } pci_init_cmask(pci_dev); pci_init_wmask(pci_dev); pci_init_w1cmask(pci_dev); if (pc->is_bridge) { pci_init_mask_bridge(pci_dev); } pci_init_multifunction(bus, pci_dev, &local_err); if (local_err) { error_propagate(errp, local_err); do_pci_unregister_device(pci_dev); return NULL; } if (!config_read) config_read = pci_default_read_config; if (!config_write) config_write = pci_default_write_config; pci_dev->config_read = config_read; pci_dev->config_write = config_write; bus->devices[devfn] = pci_dev; pci_dev->version_id = 2; /* Current pci device vmstate version */ return pci_dev; }
11,369
1
static void multiwrite_cb(void *opaque, int ret) { MultiwriteCB *mcb = opaque; if (ret < 0) { mcb->error = ret; multiwrite_user_cb(mcb); } mcb->num_requests--; if (mcb->num_requests == 0) { if (mcb->error == 0) { multiwrite_user_cb(mcb); } qemu_free(mcb); } }
11,370
1
qemu_irq *pl190_init(uint32_t base, qemu_irq irq, qemu_irq fiq) { pl190_state *s; qemu_irq *qi; int iomemtype; s = (pl190_state *)qemu_mallocz(sizeof(pl190_state)); iomemtype = cpu_register_io_memory(0, pl190_readfn, pl190_writefn, s); cpu_register_physical_memory(base, 0x00000fff, iomemtype); qi = qemu_allocate_irqs(pl190_set_irq, s, 32); s->base = base; s->irq = irq; s->fiq = fiq; pl190_reset(s); /* ??? Save/restore. */ return qi; }
11,371
1
static void pci_reg_write4(void *opaque, target_phys_addr_t addr, uint32_t value) { PPCE500PCIState *pci = opaque; unsigned long win; win = addr & 0xfe0; pci_debug("%s: value:%x -> win:%lx(addr:" TARGET_FMT_plx ")\n", __func__, value, win, addr); switch (win) { case PPCE500_PCI_OW1: case PPCE500_PCI_OW2: case PPCE500_PCI_OW3: case PPCE500_PCI_OW4: switch (addr & 0xC) { case PCI_POTAR: pci->pob[(addr >> 5) & 0x7].potar = value; break; case PCI_POTEAR: pci->pob[(addr >> 5) & 0x7].potear = value; break; case PCI_POWBAR: pci->pob[(addr >> 5) & 0x7].powbar = value; break; case PCI_POWAR: pci->pob[(addr >> 5) & 0x7].powar = value; break; default: break; }; break; case PPCE500_PCI_IW3: case PPCE500_PCI_IW2: case PPCE500_PCI_IW1: switch (addr & 0xC) { case PCI_PITAR: pci->pib[(addr >> 5) & 0x3].pitar = value; break; case PCI_PIWBAR: pci->pib[(addr >> 5) & 0x3].piwbar = value; break; case PCI_PIWBEAR: pci->pib[(addr >> 5) & 0x3].piwbear = value; break; case PCI_PIWAR: pci->pib[(addr >> 5) & 0x3].piwar = value; break; default: break; }; break; case PPCE500_PCI_GASKET_TIMR: pci->gasket_time = value; break; default: break; }; }
11,372
1
static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid, uint64_t pictx, bool bsr) { XHCISlot *slot; USBPort *uport; USBDevice *dev; dma_addr_t ictx, octx, dcbaap; uint64_t poctx; uint32_t ictl_ctx[2]; uint32_t slot_ctx[4]; uint32_t ep0_ctx[5]; int i; TRBCCode res; assert(slotid >= 1 && slotid <= xhci->numslots); dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high); poctx = ldq_le_pci_dma(PCI_DEVICE(xhci), dcbaap + 8 * slotid); ictx = xhci_mask64(pictx); octx = xhci_mask64(poctx); DPRINTF("xhci: input context at "DMA_ADDR_FMT"\n", ictx); DPRINTF("xhci: output context at "DMA_ADDR_FMT"\n", octx); xhci_dma_read_u32s(xhci, ictx, ictl_ctx, sizeof(ictl_ctx)); if (ictl_ctx[0] != 0x0 || ictl_ctx[1] != 0x3) { fprintf(stderr, "xhci: invalid input context control %08x %08x\n", ictl_ctx[0], ictl_ctx[1]); return CC_TRB_ERROR; } xhci_dma_read_u32s(xhci, ictx+32, slot_ctx, sizeof(slot_ctx)); xhci_dma_read_u32s(xhci, ictx+64, ep0_ctx, sizeof(ep0_ctx)); DPRINTF("xhci: input slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: input ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); uport = xhci_lookup_uport(xhci, slot_ctx); if (uport == NULL) { fprintf(stderr, "xhci: port not found\n"); return CC_TRB_ERROR; } trace_usb_xhci_slot_address(slotid, uport->path); dev = uport->dev; if (!dev) { fprintf(stderr, "xhci: port %s not connected\n", uport->path); return CC_USB_TRANSACTION_ERROR; } for (i = 0; i < xhci->numslots; i++) { if (i == slotid-1) { continue; } if (xhci->slots[i].uport == uport) { fprintf(stderr, "xhci: port %s already assigned to slot %d\n", uport->path, i+1); return CC_TRB_ERROR; } } slot = &xhci->slots[slotid-1]; slot->uport = uport; slot->ctx = octx; if (bsr) { slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT; } else { USBPacket p; uint8_t buf[1]; slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slotid; usb_device_reset(dev); memset(&p, 0, sizeof(p)); usb_packet_addbuf(&p, buf, sizeof(buf)); usb_packet_setup(&p, USB_TOKEN_OUT, usb_ep_get(dev, USB_TOKEN_OUT, 0), 0, 0, false, false); usb_device_handle_control(dev, &p, DeviceOutRequest | USB_REQ_SET_ADDRESS, slotid, 0, 0, NULL); assert(p.status != USB_RET_ASYNC); } res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx); DPRINTF("xhci: output slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: output ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); xhci_dma_write_u32s(xhci, octx, slot_ctx, sizeof(slot_ctx)); xhci_dma_write_u32s(xhci, octx+32, ep0_ctx, sizeof(ep0_ctx)); xhci->slots[slotid-1].addressed = 1; return res; }
11,374
1
static void encode_frame(MpegAudioContext *s, unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT], int padding) { int i, j, k, l, bit_alloc_bits, b, ch; unsigned char *sf; int q[3]; PutBitContext *p = &s->pb; /* header */ put_bits(p, 12, 0xfff); put_bits(p, 1, 1 - s->lsf); /* 1 = mpeg1 ID, 0 = mpeg2 lsf ID */ put_bits(p, 2, 4-2); /* layer 2 */ put_bits(p, 1, 1); /* no error protection */ put_bits(p, 4, s->bitrate_index); put_bits(p, 2, s->freq_index); put_bits(p, 1, s->do_padding); /* use padding */ put_bits(p, 1, 0); /* private_bit */ put_bits(p, 2, s->nb_channels == 2 ? MPA_STEREO : MPA_MONO); put_bits(p, 2, 0); /* mode_ext */ put_bits(p, 1, 0); /* no copyright */ put_bits(p, 1, 1); /* original */ put_bits(p, 2, 0); /* no emphasis */ /* bit allocation */ j = 0; for(i=0;i<s->sblimit;i++) { bit_alloc_bits = s->alloc_table[j]; for(ch=0;ch<s->nb_channels;ch++) { put_bits(p, bit_alloc_bits, bit_alloc[ch][i]); } j += 1 << bit_alloc_bits; } /* scale codes */ for(i=0;i<s->sblimit;i++) { for(ch=0;ch<s->nb_channels;ch++) { if (bit_alloc[ch][i]) put_bits(p, 2, s->scale_code[ch][i]); } } /* scale factors */ for(i=0;i<s->sblimit;i++) { for(ch=0;ch<s->nb_channels;ch++) { if (bit_alloc[ch][i]) { sf = &s->scale_factors[ch][i][0]; switch(s->scale_code[ch][i]) { case 0: put_bits(p, 6, sf[0]); put_bits(p, 6, sf[1]); put_bits(p, 6, sf[2]); break; case 3: case 1: put_bits(p, 6, sf[0]); put_bits(p, 6, sf[2]); break; case 2: put_bits(p, 6, sf[0]); break; } } } } /* quantization & write sub band samples */ for(k=0;k<3;k++) { for(l=0;l<12;l+=3) { j = 0; for(i=0;i<s->sblimit;i++) { bit_alloc_bits = s->alloc_table[j]; for(ch=0;ch<s->nb_channels;ch++) { b = bit_alloc[ch][i]; if (b) { int qindex, steps, m, sample, bits; /* we encode 3 sub band samples of the same sub band at a time */ qindex = s->alloc_table[j+b]; steps = ff_mpa_quant_steps[qindex]; for(m=0;m<3;m++) { sample = s->sb_samples[ch][k][l + m][i]; /* divide by scale factor */ #if USE_FLOATS { float a; a = (float)sample * s->scale_factor_inv_table[s->scale_factors[ch][i][k]]; q[m] = (int)((a + 1.0) * steps * 0.5); } #else { int q1, e, shift, mult; e = s->scale_factors[ch][i][k]; shift = s->scale_factor_shift[e]; mult = s->scale_factor_mult[e]; /* normalize to P bits */ if (shift < 0) q1 = sample << (-shift); else q1 = sample >> shift; q1 = (q1 * mult) >> P; q1 += 1 << P; if (q1 < 0) q1 = 0; q[m] = (unsigned)(q1 * steps) >> (P + 1); } #endif if (q[m] >= steps) q[m] = steps - 1; av_assert2(q[m] >= 0 && q[m] < steps); } bits = ff_mpa_quant_bits[qindex]; if (bits < 0) { /* group the 3 values to save bits */ put_bits(p, -bits, q[0] + steps * (q[1] + steps * q[2])); } else { put_bits(p, bits, q[0]); put_bits(p, bits, q[1]); put_bits(p, bits, q[2]); } } } /* next subband in alloc table */ j += 1 << bit_alloc_bits; } } } /* padding */ for(i=0;i<padding;i++) put_bits(p, 1, 0); /* flush */ flush_put_bits(p); }
11,375
0
static int quantize_coefs(double *coef, int *idx, float *lpc, int order) { int i; uint8_t u_coef; const float *quant_arr = tns_tmp2_map[TNS_Q_BITS == 4]; const double iqfac_p = ((1 << (TNS_Q_BITS-1)) - 0.5)/(M_PI/2.0); const double iqfac_m = ((1 << (TNS_Q_BITS-1)) + 0.5)/(M_PI/2.0); for (i = 0; i < order; i++) { idx[i] = ceilf(asin(coef[i])*((coef[i] >= 0) ? iqfac_p : iqfac_m)); u_coef = (idx[i])&(~(~0<<TNS_Q_BITS)); lpc[i] = quant_arr[u_coef]; } return order; }
11,376
1
static int get_int16(QEMUFile *f, void *pv, size_t size) { int16_t *v = pv; qemu_get_sbe16s(f, v); return 0; }
11,377
1
static void compress_to_network(RDMACompress *comp) { comp->value = htonl(comp->value); comp->block_idx = htonl(comp->block_idx); comp->offset = htonll(comp->offset); comp->length = htonll(comp->length); }
11,378
1
int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter) { graph->filters = av_realloc(graph->filters, sizeof(AVFilterContext*) * ++graph->filter_count); if (!graph->filters) return AVERROR(ENOMEM); graph->filters[graph->filter_count - 1] = filter; return 0; }
11,379
1
av_cold int ff_rate_control_init(MpegEncContext *s) { RateControlContext *rcc = &s->rc_context; int i, res; static const char * const const_names[] = { "PI", "E", "iTex", "pTex", "tex", "mv", "fCode", "iCount", "mcVar", "var", "isI", "isP", "isB", "avgQP", "qComp", #if 0 "lastIQP", "lastPQP", "lastBQP", "nextNonBQP", #endif "avgIITex", "avgPITex", "avgPPTex", "avgBPTex", "avgTex", NULL }; static double (* const func1[])(void *, double) = { (void *)bits2qp, (void *)qp2bits, NULL }; static const char * const func1_names[] = { "bits2qp", "qp2bits", NULL }; emms_c(); if (!s->avctx->rc_max_available_vbv_use && s->avctx->rc_buffer_size) { if (s->avctx->rc_max_rate) { s->avctx->rc_max_available_vbv_use = av_clipf(s->avctx->rc_max_rate/(s->avctx->rc_buffer_size*get_fps(s->avctx)), 1.0/3, 1.0); } else s->avctx->rc_max_available_vbv_use = 1.0; } res = av_expr_parse(&rcc->rc_eq_eval, s->rc_eq ? s->rc_eq : "tex^qComp", const_names, func1_names, func1, NULL, NULL, 0, s->avctx); if (res < 0) { av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\"\n", s->rc_eq); return res; } for (i = 0; i < 5; i++) { rcc->pred[i].coeff = FF_QP2LAMBDA * 7.0; rcc->pred[i].count = 1.0; rcc->pred[i].decay = 0.4; rcc->i_cplx_sum [i] = rcc->p_cplx_sum [i] = rcc->mv_bits_sum[i] = rcc->qscale_sum [i] = rcc->frame_count[i] = 1; // 1 is better because of 1/0 and such rcc->last_qscale_for[i] = FF_QP2LAMBDA * 5; } rcc->buffer_index = s->avctx->rc_initial_buffer_occupancy; if (!rcc->buffer_index) rcc->buffer_index = s->avctx->rc_buffer_size * 3 / 4; if (s->flags & CODEC_FLAG_PASS2) { int i; char *p; /* find number of pics */ p = s->avctx->stats_in; for (i = -1; p; i++) p = strchr(p + 1, ';'); i += s->max_b_frames; if (i <= 0 || i >= INT_MAX / sizeof(RateControlEntry)) return -1; rcc->entry = av_mallocz(i * sizeof(RateControlEntry)); rcc->num_entries = i; /* init all to skipped p frames * (with b frames we might have a not encoded frame at the end FIXME) */ for (i = 0; i < rcc->num_entries; i++) { RateControlEntry *rce = &rcc->entry[i]; rce->pict_type = rce->new_pict_type = AV_PICTURE_TYPE_P; rce->qscale = rce->new_qscale = FF_QP2LAMBDA * 2; rce->misc_bits = s->mb_num + 10; rce->mb_var_sum = s->mb_num * 100; } /* read stats */ p = s->avctx->stats_in; for (i = 0; i < rcc->num_entries - s->max_b_frames; i++) { RateControlEntry *rce; int picture_number; int e; char *next; next = strchr(p, ';'); if (next) { (*next) = 0; // sscanf in unbelievably slow on looong strings // FIXME copy / do not write next++; } e = sscanf(p, " in:%d ", &picture_number); assert(picture_number >= 0); assert(picture_number < rcc->num_entries); rce = &rcc->entry[picture_number]; e += sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%"SCNd64" var:%"SCNd64" icount:%d skipcount:%d hbits:%d", &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits); if (e != 14) { av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e); return -1; } p = next; } if (init_pass2(s) < 0) return -1; // FIXME maybe move to end if ((s->flags & CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) { #if CONFIG_LIBXVID return ff_xvid_rate_control_init(s); #else av_log(s->avctx, AV_LOG_ERROR, "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n"); return -1; #endif } } if (!(s->flags & CODEC_FLAG_PASS2)) { rcc->short_term_qsum = 0.001; rcc->short_term_qcount = 0.001; rcc->pass1_rc_eq_output_sum = 0.001; rcc->pass1_wanted_bits = 0.001; if (s->avctx->qblur > 1.0) { av_log(s->avctx, AV_LOG_ERROR, "qblur too large\n"); return -1; } /* init stuff with the user specified complexity */ if (s->rc_initial_cplx) { for (i = 0; i < 60 * 30; i++) { double bits = s->rc_initial_cplx * (i / 10000.0 + 1.0) * s->mb_num; RateControlEntry rce; if (i % ((s->gop_size + 3) / 4) == 0) rce.pict_type = AV_PICTURE_TYPE_I; else if (i % (s->max_b_frames + 1)) rce.pict_type = AV_PICTURE_TYPE_B; else rce.pict_type = AV_PICTURE_TYPE_P; rce.new_pict_type = rce.pict_type; rce.mc_mb_var_sum = bits * s->mb_num / 100000; rce.mb_var_sum = s->mb_num; rce.qscale = FF_QP2LAMBDA * 2; rce.f_code = 2; rce.b_code = 1; rce.misc_bits = 1; if (s->pict_type == AV_PICTURE_TYPE_I) { rce.i_count = s->mb_num; rce.i_tex_bits = bits; rce.p_tex_bits = 0; rce.mv_bits = 0; } else { rce.i_count = 0; // FIXME we do know this approx rce.i_tex_bits = 0; rce.p_tex_bits = bits * 0.9; rce.mv_bits = bits * 0.1; } rcc->i_cplx_sum[rce.pict_type] += rce.i_tex_bits * rce.qscale; rcc->p_cplx_sum[rce.pict_type] += rce.p_tex_bits * rce.qscale; rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits; rcc->frame_count[rce.pict_type]++; get_qscale(s, &rce, rcc->pass1_wanted_bits / rcc->pass1_rc_eq_output_sum, i); // FIXME misbehaves a little for variable fps rcc->pass1_wanted_bits += s->bit_rate / get_fps(s->avctx); } } } return 0; }
11,380
1
void trace_event_set_vcpu_state_dynamic(CPUState *vcpu, TraceEvent *ev, bool state) { TraceEventVCPUID vcpu_id; bool state_pre; assert(trace_event_get_state_static(ev)); assert(trace_event_is_vcpu(ev)); vcpu_id = trace_event_get_vcpu_id(ev); state_pre = test_bit(vcpu_id, vcpu->trace_dstate); if (state_pre != state) { if (state) { trace_events_enabled_count++; set_bit(vcpu_id, vcpu->trace_dstate); (*ev->dstate)++; } else { trace_events_enabled_count--; clear_bit(vcpu_id, vcpu->trace_dstate); (*ev->dstate)--; } } }
11,382
1
static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) { struct vmsvga_state_s *s = opaque; if (s->index >= SVGA_SCRATCH_BASE) { trace_vmware_scratch_write(s->index, value); } else if (s->index >= SVGA_PALETTE_BASE) { trace_vmware_palette_write(s->index, value); } else { trace_vmware_value_write(s->index, value); } switch (s->index) { case SVGA_REG_ID: if (value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0) { s->svgaid = value; } break; case SVGA_REG_ENABLE: s->enable = !!value; s->invalidated = 1; s->vga.hw_ops->invalidate(&s->vga); if (s->enable && s->config) { vga_dirty_log_stop(&s->vga); } else { vga_dirty_log_start(&s->vga); } break; case SVGA_REG_WIDTH: if (value <= SVGA_MAX_WIDTH) { s->new_width = value; s->invalidated = 1; } else { printf("%s: Bad width: %i\n", __func__, value); } break; case SVGA_REG_HEIGHT: if (value <= SVGA_MAX_HEIGHT) { s->new_height = value; s->invalidated = 1; } else { printf("%s: Bad height: %i\n", __func__, value); } break; case SVGA_REG_BITS_PER_PIXEL: if (value != 32) { printf("%s: Bad bits per pixel: %i bits\n", __func__, value); s->config = 0; s->invalidated = 1; } break; case SVGA_REG_CONFIG_DONE: if (value) { s->fifo = (uint32_t *) s->fifo_ptr; /* Check range and alignment. */ if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) { break; } if (CMD(min) < (uint8_t *) s->cmd->fifo - (uint8_t *) s->fifo) { break; } if (CMD(max) > SVGA_FIFO_SIZE) { break; } if (CMD(max) < CMD(min) + 10 * 1024) { break; } vga_dirty_log_stop(&s->vga); } s->config = !!value; break; case SVGA_REG_SYNC: s->syncing = 1; vmsvga_fifo_run(s); /* Or should we just wait for update_display? */ break; case SVGA_REG_GUEST_ID: s->guest = value; #ifdef VERBOSE if (value >= GUEST_OS_BASE && value < GUEST_OS_BASE + ARRAY_SIZE(vmsvga_guest_id)) { printf("%s: guest runs %s.\n", __func__, vmsvga_guest_id[value - GUEST_OS_BASE]); } #endif break; case SVGA_REG_CURSOR_ID: s->cursor.id = value; break; case SVGA_REG_CURSOR_X: s->cursor.x = value; break; case SVGA_REG_CURSOR_Y: s->cursor.y = value; break; case SVGA_REG_CURSOR_ON: s->cursor.on |= (value == SVGA_CURSOR_ON_SHOW); s->cursor.on &= (value != SVGA_CURSOR_ON_HIDE); #ifdef HW_MOUSE_ACCEL if (value <= SVGA_CURSOR_ON_SHOW) { dpy_mouse_set(s->vga.con, s->cursor.x, s->cursor.y, s->cursor.on); } #endif break; case SVGA_REG_DEPTH: case SVGA_REG_MEM_REGS: case SVGA_REG_NUM_DISPLAYS: case SVGA_REG_PITCHLOCK: case SVGA_PALETTE_BASE ... SVGA_PALETTE_END: break; default: if (s->index >= SVGA_SCRATCH_BASE && s->index < SVGA_SCRATCH_BASE + s->scratch_size) { s->scratch[s->index - SVGA_SCRATCH_BASE] = value; break; } printf("%s: Bad register %02x\n", __func__, s->index); } }
11,385
1
int main (int argc, char **argv) { int ret = 0, got_frame; if (argc != 4) { fprintf(stderr, "usage: %s input_file video_output_file audio_output_file\n" "API example program to show how to read frames from an input file.\n" "This program reads frames from a file, decodes them, and writes decoded\n" "video frames to a rawvideo file named video_output_file, and decoded\n" "audio frames to a rawaudio file named audio_output_file.\n" "\n", argv[0]); exit(1); } src_filename = argv[1]; video_dst_filename = argv[2]; audio_dst_filename = argv[3]; /* register all formats and codecs */ av_register_all(); /* open input file, and allocate format context */ if (avformat_open_input(&fmt_ctx, src_filename, NULL, NULL) < 0) { fprintf(stderr, "Could not open source file %s\n", src_filename); exit(1); } /* retrieve stream information */ if (avformat_find_stream_info(fmt_ctx, NULL) < 0) { fprintf(stderr, "Could not find stream information\n"); exit(1); } if (open_codec_context(&video_stream_idx, fmt_ctx, AVMEDIA_TYPE_VIDEO) >= 0) { video_stream = fmt_ctx->streams[video_stream_idx]; video_dec_ctx = video_stream->codec; video_dst_file = fopen(video_dst_filename, "wb"); if (!video_dst_file) { fprintf(stderr, "Could not open destination file %s\n", video_dst_filename); ret = 1; goto end; } /* allocate image where the decoded image will be put */ ret = av_image_alloc(video_dst_data, video_dst_linesize, video_dec_ctx->width, video_dec_ctx->height, video_dec_ctx->pix_fmt, 1); if (ret < 0) { fprintf(stderr, "Could not allocate raw video buffer\n"); goto end; } video_dst_bufsize = ret; } if (open_codec_context(&audio_stream_idx, fmt_ctx, AVMEDIA_TYPE_AUDIO) >= 0) { int nb_planes; audio_stream = fmt_ctx->streams[audio_stream_idx]; audio_dec_ctx = audio_stream->codec; audio_dst_file = fopen(audio_dst_filename, "wb"); if (!audio_dst_file) { fprintf(stderr, "Could not open destination file %s\n", video_dst_filename); ret = 1; goto end; } nb_planes = av_sample_fmt_is_planar(audio_dec_ctx->sample_fmt) ? audio_dec_ctx->channels : 1; audio_dst_data = av_mallocz(sizeof(uint8_t *) * nb_planes); if (!audio_dst_data) { fprintf(stderr, "Could not allocate audio data buffers\n"); ret = AVERROR(ENOMEM); goto end; } } /* dump input information to stderr */ av_dump_format(fmt_ctx, 0, src_filename, 0); if (!audio_stream && !video_stream) { fprintf(stderr, "Could not find audio or video stream in the input, aborting\n"); ret = 1; goto end; } frame = avcodec_alloc_frame(); if (!frame) { fprintf(stderr, "Could not allocate frame\n"); ret = AVERROR(ENOMEM); goto end; } /* initialize packet, set data to NULL, let the demuxer fill it */ av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; if (video_stream) printf("Demuxing video from file '%s' into '%s'\n", src_filename, video_dst_filename); if (audio_stream) printf("Demuxing audio from file '%s' into '%s'\n", src_filename, audio_dst_filename); /* read frames from the file */ while (av_read_frame(fmt_ctx, &pkt) >= 0) decode_packet(&got_frame, 0); /* flush cached frames */ pkt.data = NULL; pkt.size = 0; do { decode_packet(&got_frame, 1); } while (got_frame); printf("Demuxing succeeded.\n"); if (video_stream) { printf("Play the output video file with the command:\n" "ffplay -f rawvideo -pix_fmt %s -video_size %dx%d %s\n", av_get_pix_fmt_name(video_dec_ctx->pix_fmt), video_dec_ctx->width, video_dec_ctx->height, video_dst_filename); } if (audio_stream) { const char *fmt; if ((ret = get_format_from_sample_fmt(&fmt, audio_dec_ctx->sample_fmt)) < 0) goto end; printf("Play the output audio file with the command:\n" "ffplay -f %s -ac %d -ar %d %s\n", fmt, audio_dec_ctx->channels, audio_dec_ctx->sample_rate, audio_dst_filename); } end: if (video_dec_ctx) avcodec_close(video_dec_ctx); if (audio_dec_ctx) avcodec_close(audio_dec_ctx); avformat_close_input(&fmt_ctx); if (video_dst_file) fclose(video_dst_file); if (audio_dst_file) fclose(audio_dst_file); av_free(frame); av_free(video_dst_data[0]); av_free(audio_dst_data); return ret < 0; }
11,386
0
static av_cold int truemotion1_decode_init(AVCodecContext *avctx) { TrueMotion1Context *s = avctx->priv_data; s->avctx = avctx; // FIXME: it may change ? // if (avctx->bits_per_sample == 24) // avctx->pix_fmt = AV_PIX_FMT_RGB24; // else // avctx->pix_fmt = AV_PIX_FMT_RGB555; s->frame.data[0] = NULL; /* there is a vertical predictor for each pixel in a line; each vertical * predictor is 0 to start with */ av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int)); return 0; }
11,387
0
static int h264_export_frame_props(H264Context *h) { const SPS *sps = h->ps.sps; H264Picture *cur = h->cur_pic_ptr; cur->f->interlaced_frame = 0; cur->f->repeat_pict = 0; /* Signal interlacing information externally. */ /* Prioritize picture timing SEI information over used * decoding process if it exists. */ if (sps->pic_struct_present_flag) { H264SEIPictureTiming *pt = &h->sei.picture_timing; switch (pt->pic_struct) { case SEI_PIC_STRUCT_FRAME: break; case SEI_PIC_STRUCT_TOP_FIELD: case SEI_PIC_STRUCT_BOTTOM_FIELD: cur->f->interlaced_frame = 1; break; case SEI_PIC_STRUCT_TOP_BOTTOM: case SEI_PIC_STRUCT_BOTTOM_TOP: if (FIELD_OR_MBAFF_PICTURE(h)) cur->f->interlaced_frame = 1; else // try to flag soft telecine progressive cur->f->interlaced_frame = h->prev_interlaced_frame; break; case SEI_PIC_STRUCT_TOP_BOTTOM_TOP: case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM: /* Signal the possibility of telecined film externally * (pic_struct 5,6). From these hints, let the applications * decide if they apply deinterlacing. */ cur->f->repeat_pict = 1; break; case SEI_PIC_STRUCT_FRAME_DOUBLING: cur->f->repeat_pict = 2; break; case SEI_PIC_STRUCT_FRAME_TRIPLING: cur->f->repeat_pict = 4; break; } if ((pt->ct_type & 3) && pt->pic_struct <= SEI_PIC_STRUCT_BOTTOM_TOP) cur->f->interlaced_frame = (pt->ct_type & (1 << 1)) != 0; } else { /* Derive interlacing flag from used decoding process. */ cur->f->interlaced_frame = FIELD_OR_MBAFF_PICTURE(h); } h->prev_interlaced_frame = cur->f->interlaced_frame; if (cur->field_poc[0] != cur->field_poc[1]) { /* Derive top_field_first from field pocs. */ cur->f->top_field_first = cur->field_poc[0] < cur->field_poc[1]; } else { if (cur->f->interlaced_frame || sps->pic_struct_present_flag) { /* Use picture timing SEI information. Even if it is a * information of a past frame, better than nothing. */ if (h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM || h->sei.picture_timing.pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP) cur->f->top_field_first = 1; else cur->f->top_field_first = 0; } else { /* Most likely progressive */ cur->f->top_field_first = 0; } } if (h->sei.frame_packing.present && h->sei.frame_packing.arrangement_type >= 0 && h->sei.frame_packing.arrangement_type <= 6 && h->sei.frame_packing.content_interpretation_type > 0 && h->sei.frame_packing.content_interpretation_type < 3) { H264SEIFramePacking *fp = &h->sei.frame_packing; AVStereo3D *stereo = av_stereo3d_create_side_data(cur->f); if (!stereo) return AVERROR(ENOMEM); switch (fp->arrangement_type) { case 0: stereo->type = AV_STEREO3D_CHECKERBOARD; break; case 1: stereo->type = AV_STEREO3D_COLUMNS; break; case 2: stereo->type = AV_STEREO3D_LINES; break; case 3: if (fp->quincunx_subsampling) stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX; else stereo->type = AV_STEREO3D_SIDEBYSIDE; break; case 4: stereo->type = AV_STEREO3D_TOPBOTTOM; break; case 5: stereo->type = AV_STEREO3D_FRAMESEQUENCE; break; case 6: stereo->type = AV_STEREO3D_2D; break; } if (fp->content_interpretation_type == 2) stereo->flags = AV_STEREO3D_FLAG_INVERT; } if (h->sei.display_orientation.present && (h->sei.display_orientation.anticlockwise_rotation || h->sei.display_orientation.hflip || h->sei.display_orientation.vflip)) { H264SEIDisplayOrientation *o = &h->sei.display_orientation; double angle = o->anticlockwise_rotation * 360 / (double) (1 << 16); AVFrameSideData *rotation = av_frame_new_side_data(cur->f, AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); if (!rotation) return AVERROR(ENOMEM); av_display_rotation_set((int32_t *)rotation->data, angle); av_display_matrix_flip((int32_t *)rotation->data, o->hflip, o->vflip); } if (h->sei.afd.present) { AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_AFD, sizeof(uint8_t)); if (!sd) return AVERROR(ENOMEM); *sd->data = h->sei.afd.active_format_description; h->sei.afd.present = 0; } if (h->sei.a53_caption.a53_caption) { H264SEIA53Caption *a53 = &h->sei.a53_caption; AVFrameSideData *sd = av_frame_new_side_data(cur->f, AV_FRAME_DATA_A53_CC, a53->a53_caption_size); if (!sd) return AVERROR(ENOMEM); memcpy(sd->data, a53->a53_caption, a53->a53_caption_size); av_freep(&a53->a53_caption); a53->a53_caption_size = 0; } return 0; }
11,389
1
static int colo_packet_compare_icmp(Packet *spkt, Packet *ppkt) { int network_header_length = ppkt->ip->ip_hl * 4; trace_colo_compare_main("compare icmp"); /* * Because of ppkt and spkt are both in the same connection, * The ppkt's src ip, dst ip, src port, dst port, ip_proto all are * same with spkt. In addition, IP header's Identification is a random * field, we can handle it in IP fragmentation function later. * COLO just concern the response net packet payload from primary guest * and secondary guest are same or not, So we ignored all IP header include * other field like TOS,TTL,IP Checksum. we only need to compare * the ip payload here. */ if (colo_packet_compare_common(ppkt, spkt, network_header_length + ETH_HLEN)) { trace_colo_compare_icmp_miscompare("primary pkt size", ppkt->size); trace_colo_compare_icmp_miscompare("Secondary pkt size", spkt->size); if (trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPARE)) { qemu_hexdump((char *)ppkt->data, stderr, "colo-compare pri pkt", ppkt->size); qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt", spkt->size); } return -1; } else { return 0; } }
11,390
1
static int caca_write_header(AVFormatContext *s) { CACAContext *c = s->priv_data; AVStream *st = s->streams[0]; AVCodecContext *encctx = st->codec; int ret, bpp; c->ctx = s; if (c->list_drivers) { list_drivers(c); return AVERROR_EXIT; } if (c->list_dither) { if (!strcmp(c->list_dither, "colors")) { list_dither_color(c); } else if (!strcmp(c->list_dither, "charsets")) { list_dither_charset(c); } else if (!strcmp(c->list_dither, "algorithms")) { list_dither_algorithm(c); } else if (!strcmp(c->list_dither, "antialiases")) { list_dither_antialias(c); } else { av_log(s, AV_LOG_ERROR, "Invalid argument '%s', for 'list_dither' option\n" "Argument must be one of 'algorithms, 'antialiases', 'charsets', 'colors'\n", c->list_dither); return AVERROR(EINVAL); } return AVERROR_EXIT; } if ( s->nb_streams > 1 || encctx->codec_type != AVMEDIA_TYPE_VIDEO || encctx->codec_id != CODEC_ID_RAWVIDEO) { av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n"); return AVERROR(EINVAL); } if (encctx->pix_fmt != PIX_FMT_RGB24) { av_log(s, AV_LOG_ERROR, "Unsupported pixel format '%s', choose rgb24\n", av_get_pix_fmt_name(encctx->pix_fmt)); return AVERROR(EINVAL); } c->canvas = caca_create_canvas(c->window_width, c->window_height); if (!c->canvas) { av_log(s, AV_LOG_ERROR, "Failed to create canvas\n"); return AVERROR(errno); } c->display = caca_create_display_with_driver(c->canvas, c->driver); if (!c->display) { av_log(s, AV_LOG_ERROR, "Failed to create display\n"); list_drivers(c); caca_free_canvas(c->canvas); return AVERROR(errno); } if (!c->window_width || !c->window_height) { c->window_width = caca_get_canvas_width(c->canvas); c->window_height = caca_get_canvas_height(c->canvas); } bpp = av_get_bits_per_pixel(&av_pix_fmt_descriptors[encctx->pix_fmt]); c->dither = caca_create_dither(bpp, encctx->width, encctx->height, bpp / 8 * encctx->width, 0x0000ff, 0x00ff00, 0xff0000, 0); if (!c->dither) { av_log(s, AV_LOG_ERROR, "Failed to create dither\n"); ret = AVERROR(errno); goto fail; } #define CHECK_DITHER_OPT(opt) \ if (caca_set_dither_##opt(c->dither, c->opt) < 0) { \ ret = AVERROR(errno); \ av_log(s, AV_LOG_ERROR, "Failed to set value '%s' for option '%s'\n", \ c->opt, #opt); \ goto fail; \ } CHECK_DITHER_OPT(algorithm); CHECK_DITHER_OPT(antialias); CHECK_DITHER_OPT(charset); CHECK_DITHER_OPT(color); if (!c->window_title) c->window_title = av_strdup(s->filename); caca_set_display_title(c->display, c->window_title); caca_set_display_time(c->display, av_rescale_q(1, st->codec->time_base, AV_TIME_BASE_Q)); return 0; fail: caca_write_trailer(s); return ret; }
11,391
1
static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment) { int i, length; segment->nb_index_entries = avio_rb32(pb); length = avio_rb32(pb); if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) || !(segment->flag_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) || !(segment->stream_offset_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) { av_freep(&segment->temporal_offset_entries); av_freep(&segment->flag_entries); return AVERROR(ENOMEM); } for (i = 0; i < segment->nb_index_entries; i++) { if(avio_feof(pb)) segment->temporal_offset_entries[i] = avio_r8(pb); avio_r8(pb); /* KeyFrameOffset */ segment->flag_entries[i] = avio_r8(pb); segment->stream_offset_entries[i] = avio_rb64(pb); avio_skip(pb, length - 11); } return 0; }
11,392
1
uint64_t hbitmap_serialization_granularity(const HBitmap *hb) { /* Must hold true so that the shift below is defined * (ld(64) == 6, i.e. 1 << 6 == 64) */ assert(hb->granularity < 64 - 6); /* Require at least 64 bit granularity to be safe on both 64 bit and 32 bit * hosts. */ return UINT64_C(64) << hb->granularity; }
11,393
1
void helper_store_sdr1(CPUPPCState *env, target_ulong val) { ppc_store_sdr1(env, val); }
11,394
0
static int vp7_decode_frame_header(VP8Context *s, const uint8_t *buf, int buf_size) { VP56RangeCoder *c = &s->c; int part1_size, hscale, vscale, i, j, ret; int width = s->avctx->width; int height = s->avctx->height; s->profile = (buf[0] >> 1) & 7; if (s->profile > 1) { avpriv_request_sample(s->avctx, "Unknown profile %d", s->profile); return AVERROR_INVALIDDATA; } s->keyframe = !(buf[0] & 1); s->invisible = 0; part1_size = AV_RL24(buf) >> 4; buf += 4 - s->profile; buf_size -= 4 - s->profile; memcpy(s->put_pixels_tab, s->vp8dsp.put_vp8_epel_pixels_tab, sizeof(s->put_pixels_tab)); ff_vp56_init_range_decoder(c, buf, part1_size); buf += part1_size; buf_size -= part1_size; /* A. Dimension information (keyframes only) */ if (s->keyframe) { width = vp8_rac_get_uint(c, 12); height = vp8_rac_get_uint(c, 12); hscale = vp8_rac_get_uint(c, 2); vscale = vp8_rac_get_uint(c, 2); if (hscale || vscale) avpriv_request_sample(s->avctx, "Upscaling"); s->update_golden = s->update_altref = VP56_FRAME_CURRENT; vp78_reset_probability_tables(s); memcpy(s->prob->pred16x16, vp8_pred16x16_prob_inter, sizeof(s->prob->pred16x16)); memcpy(s->prob->pred8x8c, vp8_pred8x8c_prob_inter, sizeof(s->prob->pred8x8c)); for (i = 0; i < 2; i++) memcpy(s->prob->mvc[i], vp7_mv_default_prob[i], sizeof(vp7_mv_default_prob[i])); memset(&s->segmentation, 0, sizeof(s->segmentation)); memset(&s->lf_delta, 0, sizeof(s->lf_delta)); memcpy(s->prob[0].scan, zigzag_scan, sizeof(s->prob[0].scan)); } if (s->keyframe || s->profile > 0) memset(s->inter_dc_pred, 0 , sizeof(s->inter_dc_pred)); /* B. Decoding information for all four macroblock-level features */ for (i = 0; i < 4; i++) { s->feature_enabled[i] = vp8_rac_get(c); if (s->feature_enabled[i]) { s->feature_present_prob[i] = vp8_rac_get_uint(c, 8); for (j = 0; j < 3; j++) s->feature_index_prob[i][j] = vp8_rac_get(c) ? vp8_rac_get_uint(c, 8) : 255; if (vp7_feature_value_size[i]) for (j = 0; j < 4; j++) s->feature_value[i][j] = vp8_rac_get(c) ? vp8_rac_get_uint(c, vp7_feature_value_size[s->profile][i]) : 0; } } s->segmentation.enabled = 0; s->segmentation.update_map = 0; s->lf_delta.enabled = 0; s->num_coeff_partitions = 1; ff_vp56_init_range_decoder(&s->coeff_partition[0], buf, buf_size); if (!s->macroblocks_base || /* first frame */ width != s->avctx->width || height != s->avctx->height || (width + 15) / 16 != s->mb_width || (height + 15) / 16 != s->mb_height) { if ((ret = vp7_update_dimensions(s, width, height)) < 0) return ret; } /* C. Dequantization indices */ vp7_get_quants(s); /* D. Golden frame update flag (a Flag) for interframes only */ if (!s->keyframe) { s->update_golden = vp8_rac_get(c) ? VP56_FRAME_CURRENT : VP56_FRAME_NONE; s->sign_bias[VP56_FRAME_GOLDEN] = 0; } s->update_last = 1; s->update_probabilities = 1; s->fade_present = 1; if (s->profile > 0) { s->update_probabilities = vp8_rac_get(c); if (!s->update_probabilities) s->prob[1] = s->prob[0]; if (!s->keyframe) s->fade_present = vp8_rac_get(c); } /* E. Fading information for previous frame */ if (s->fade_present && vp8_rac_get(c)) { if ((ret = vp7_fade_frame(s ,c)) < 0) return ret; } /* F. Loop filter type */ if (!s->profile) s->filter.simple = vp8_rac_get(c); /* G. DCT coefficient ordering specification */ if (vp8_rac_get(c)) for (i = 1; i < 16; i++) s->prob[0].scan[i] = zigzag_scan[vp8_rac_get_uint(c, 4)]; /* H. Loop filter levels */ if (s->profile > 0) s->filter.simple = vp8_rac_get(c); s->filter.level = vp8_rac_get_uint(c, 6); s->filter.sharpness = vp8_rac_get_uint(c, 3); /* I. DCT coefficient probability update; 13.3 Token Probability Updates */ vp78_update_probability_tables(s); s->mbskip_enabled = 0; /* J. The remaining frame header data occurs ONLY FOR INTERFRAMES */ if (!s->keyframe) { s->prob->intra = vp8_rac_get_uint(c, 8); s->prob->last = vp8_rac_get_uint(c, 8); vp78_update_pred16x16_pred8x8_mvc_probabilities(s, VP7_MVC_SIZE); } return 0; }
11,395
1
static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int chroma_height, int delta, int list, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, int src_x_offset, int src_y_offset, qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op){ MpegEncContext * const s = &h->s; const int mx= h->mv_cache[list][ scan8[n] ][0] + src_x_offset*8; const int my= h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8; const int luma_xy= (mx&3) + ((my&3)<<2); uint8_t * src_y = pic->data[0] + (mx>>2) + (my>>2)*s->linesize; uint8_t * src_cb= pic->data[1] + (mx>>3) + (my>>3)*s->uvlinesize; uint8_t * src_cr= pic->data[2] + (mx>>3) + (my>>3)*s->uvlinesize; int extra_width= (s->flags&CODEC_FLAG_EMU_EDGE) ? 0 : 16; //FIXME increase edge?, IMHO not worth it int extra_height= extra_width; int emu=0; const int full_mx= mx>>2; const int full_my= my>>2; const int pic_width = 16*s->mb_width; const int pic_height = 16*s->mb_height; assert(pic->data[0]); if(mx&7) extra_width -= 3; if(my&7) extra_height -= 3; if( full_mx < 0-extra_width || full_my < 0-extra_height || full_mx + 16/*FIXME*/ > pic_width + extra_width || full_my + 16/*FIXME*/ > pic_height + extra_height){ ff_emulated_edge_mc(s->edge_emu_buffer, src_y - 2 - 2*s->linesize, s->linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height); src_y= s->edge_emu_buffer + 2 + 2*s->linesize; emu=1; } qpix_op[luma_xy](dest_y, src_y, s->linesize); //FIXME try variable height perhaps? if(!square){ qpix_op[luma_xy](dest_y + delta, src_y + delta, s->linesize); } if(s->flags&CODEC_FLAG_GRAY) return; if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cb, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); src_cb= s->edge_emu_buffer; } chroma_op(dest_cb, src_cb, s->uvlinesize, chroma_height, mx&7, my&7); if(emu){ ff_emulated_edge_mc(s->edge_emu_buffer, src_cr, s->uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); src_cr= s->edge_emu_buffer; } chroma_op(dest_cr, src_cr, s->uvlinesize, chroma_height, mx&7, my&7); }
11,396
1
static int encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data) { AVFrame *pic = data; int i, j; int aligned_width = FFALIGN(avctx->width, 64); uint8_t *src_line; uint8_t *dst = buf; if (buf_size < 4 * aligned_width * avctx->height) { av_log(avctx, AV_LOG_ERROR, "output buffer too small\n"); return AVERROR(ENOMEM); } avctx->coded_frame->reference = 0; avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; src_line = pic->data[0]; for (i = 0; i < avctx->height; i++) { uint16_t *src = (uint16_t *)src_line; for (j = 0; j < avctx->width; j++) { uint32_t pixel; uint16_t r = *src++ >> 6; uint16_t g = *src++ >> 6; uint16_t b = *src++ >> 4; if (avctx->codec_id == CODEC_ID_R210) pixel = (r << 20) | (g << 10) | b >> 2; else pixel = (r << 22) | (g << 12) | b; if (avctx->codec_id == CODEC_ID_AVRP) bytestream_put_le32(&dst, pixel); else bytestream_put_be32(&dst, pixel); } dst += (aligned_width - avctx->width) * 4; src_line += pic->linesize[0]; } return 4 * aligned_width * avctx->height; }
11,397
1
static inline void gen_st32(TCGv val, TCGv addr, int index) { tcg_gen_qemu_st32(val, addr, index); dead_tmp(val); }
11,398
0
int uuid_is_null(const uuid_t uu) { uuid_t null_uuid = { 0 }; return memcmp(uu, null_uuid, sizeof(uuid_t)) == 0; }
11,399
0
static int e1000_post_load(void *opaque, int version_id) { E1000State *s = opaque; NetClientState *nc = qemu_get_queue(s->nic); if (!(s->compat_flags & E1000_FLAG_MIT)) { s->mac_reg[ITR] = s->mac_reg[RDTR] = s->mac_reg[RADV] = s->mac_reg[TADV] = 0; s->mit_irq_level = false; } s->mit_ide = 0; s->mit_timer_on = false; /* nc.link_down can't be migrated, so infer link_down according * to link status bit in mac_reg[STATUS]. * Alternatively, restart link negotiation if it was in progress. */ nc->link_down = (s->mac_reg[STATUS] & E1000_STATUS_LU) == 0; if (s->compat_flags & E1000_FLAG_AUTONEG && s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN && s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG && !(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) { nc->link_down = false; timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500); } return 0; }
11,401
0
int qemu_opts_do_parse(QemuOpts *opts, const char *params, const char *firstname) { Error *err = NULL; opts_do_parse(opts, params, firstname, false, &err); if (err) { qerror_report_err(err); error_free(err); return -1; } return 0; }
11,403
0
static int cris_mmu_enabled(uint32_t rw_gc_cfg) { return (rw_gc_cfg & 12) != 0; }
11,404
0
static int nut_read_packet(AVFormatContext *s, AVPacket *pkt) { NUTContext *nut = s->priv_data; StreamContext *stream; ByteIOContext *bc = &s->pb; int size, frame_code, flags, size_mul, size_lsb, stream_id; int key_frame = 0; int frame_type= 0; int64_t pts = 0; const int64_t frame_start= url_ftell(bc); if (url_feof(bc)) return -1; frame_code = get_byte(bc); if(frame_code == 'N'){ uint64_t tmp= frame_code; tmp<<=8 ; tmp |= get_byte(bc); tmp<<=16; tmp |= get_be16(bc); tmp<<=32; tmp |= get_be32(bc); if (tmp == KEYFRAME_STARTCODE) { frame_code = get_byte(bc); frame_type = 2; } else av_log(s, AV_LOG_ERROR, "error in zero bit / startcode %LX\n", tmp); } flags= nut->frame_code[frame_code].flags; size_mul= nut->frame_code[frame_code].size_mul; size_lsb= nut->frame_code[frame_code].size_lsb; stream_id= nut->frame_code[frame_code].stream_id_plus1 - 1; if(flags & FLAG_FRAME_TYPE){ reset(s); if(frame_type==2){ get_packetheader(nut, bc, 8+1, 0); }else{ get_packetheader(nut, bc, 1, 0); frame_type= 1; } } if(stream_id==-1) stream_id= get_v(bc); if(stream_id >= s->nb_streams){ av_log(s, AV_LOG_ERROR, "illegal stream_id\n"); return -1; } stream= &nut->stream[stream_id]; if(flags & FLAG_PRED_KEY_FRAME){ if(flags & FLAG_KEY_FRAME) key_frame= !stream->last_key_frame; else key_frame= stream->last_key_frame; }else{ key_frame= !!(flags & FLAG_KEY_FRAME); } if(flags & FLAG_PTS){ if(flags & FLAG_FULL_PTS){ pts= get_v(bc); }else{ int64_t mask = (1<<stream->msb_timestamp_shift)-1; int64_t delta= stream->last_pts - mask/2; pts= ((get_v(bc) - delta)&mask) + delta; } }else{ pts= stream->last_pts + stream->lru_pts_delta[(flags&12)>>2]; } if(size_mul <= size_lsb){ size= stream->lru_size[size_lsb - size_mul]; }else{ if(flags & FLAG_DATA_SIZE) size= size_mul*get_v(bc) + size_lsb; else size= size_lsb; } //av_log(s, AV_LOG_DEBUG, "fs:%lld fc:%d ft:%d kf:%d pts:%lld\n", frame_start, frame_code, frame_type, key_frame, pts); av_new_packet(pkt, size); get_buffer(bc, pkt->data, size); pkt->stream_index = stream_id; if (key_frame) pkt->flags |= PKT_FLAG_KEY; pkt->pts = pts * AV_TIME_BASE * stream->rate_den / stream->rate_num; update(nut, stream_id, frame_start, frame_type, frame_code, key_frame, size, pts); return 0; }
11,405
0
void block_job_user_resume(BlockJob *job) { if (job && job->user_paused && job->pause_count > 0) { job->user_paused = false; block_job_iostatus_reset(job); block_job_resume(job); } }
11,406
0
static void pc_cpu_reset(void *opaque) { X86CPU *cpu = opaque; CPUX86State *env = &cpu->env; cpu_reset(CPU(cpu)); env->halted = !cpu_is_bsp(env); }
11,407
0
static pflash_t *ve_pflash_cfi01_register(hwaddr base, const char *name, DriveInfo *di) { DeviceState *dev = qdev_create(NULL, "cfi.pflash01"); if (di && qdev_prop_set_drive(dev, "drive", blk_bs(blk_by_legacy_dinfo(di)))) { abort(); } qdev_prop_set_uint32(dev, "num-blocks", VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE); qdev_prop_set_uint64(dev, "sector-length", VEXPRESS_FLASH_SECT_SIZE); qdev_prop_set_uint8(dev, "width", 4); qdev_prop_set_uint8(dev, "device-width", 2); qdev_prop_set_uint8(dev, "big-endian", 0); qdev_prop_set_uint16(dev, "id0", 0x89); qdev_prop_set_uint16(dev, "id1", 0x18); qdev_prop_set_uint16(dev, "id2", 0x00); qdev_prop_set_uint16(dev, "id3", 0x00); qdev_prop_set_string(dev, "name", name); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); }
11,408
0
static bool virtio_queue_host_notifier_aio_poll(void *opaque) { EventNotifier *n = opaque; VirtQueue *vq = container_of(n, VirtQueue, host_notifier); bool progress; if (virtio_queue_empty(vq)) { return false; } progress = virtio_queue_notify_aio_vq(vq); /* In case the handler function re-enabled notifications */ virtio_queue_set_notification(vq, 0); return progress; }
11,409
0
static void qvirtio_9p_stop(void) { qtest_end(); rmdir(test_share); g_free(test_share); }
11,410
0
do_kernel_trap(CPUARMState *env) { uint32_t addr; uint32_t cpsr; uint32_t val; switch (env->regs[15]) { case 0xffff0fa0: /* __kernel_memory_barrier */ /* ??? No-op. Will need to do better for SMP. */ break; case 0xffff0fc0: /* __kernel_cmpxchg */ /* XXX: This only works between threads, not between processes. It's probably possible to implement this with native host operations. However things like ldrex/strex are much harder so there's not much point trying. */ start_exclusive(); cpsr = cpsr_read(env); addr = env->regs[2]; /* FIXME: This should SEGV if the access fails. */ if (get_user_u32(val, addr)) val = ~env->regs[0]; if (val == env->regs[0]) { val = env->regs[1]; /* FIXME: Check for segfaults. */ put_user_u32(val, addr); env->regs[0] = 0; cpsr |= CPSR_C; } else { env->regs[0] = -1; cpsr &= ~CPSR_C; } cpsr_write(env, cpsr, CPSR_C); end_exclusive(); break; case 0xffff0fe0: /* __kernel_get_tls */ env->regs[0] = env->cp15.tpidrro_el0; break; case 0xffff0f60: /* __kernel_cmpxchg64 */ arm_kernel_cmpxchg64_helper(env); break; default: return 1; } /* Jump back to the caller. */ addr = env->regs[14]; if (addr & 1) { env->thumb = 1; addr &= ~1; } env->regs[15] = addr; return 0; }
11,411
0
static void event_notifier_dummy_cb(EventNotifier *e) { }
11,412
0
uint16_t cpu_inw(CPUState *env, pio_addr_t addr) { uint16_t val; val = ioport_read(1, addr); LOG_IOPORT("inw : %04"FMT_pioaddr" %04"PRIx16"\n", addr, val); #ifdef CONFIG_KQEMU if (env) env->last_io_time = cpu_get_time_fast(); #endif return val; }
11,413
0
static NVDIMMDevice *nvdimm_get_device_by_handle(uint32_t handle) { NVDIMMDevice *nvdimm = NULL; GSList *list, *device_list = nvdimm_get_plugged_device_list(); for (list = device_list; list; list = list->next) { NVDIMMDevice *nvd = list->data; int slot = object_property_get_int(OBJECT(nvd), PC_DIMM_SLOT_PROP, NULL); if (nvdimm_slot_to_handle(slot) == handle) { nvdimm = nvd; break; } } g_slist_free(device_list); return nvdimm; }
11,415
0
int avio_check(const char *url, int flags) { URLContext *h; int ret = ffurl_alloc(&h, url, flags, NULL); if (ret) return ret; if (h->prot->url_check) { ret = h->prot->url_check(h, flags); } else { ret = ffurl_connect(h, NULL); if (ret >= 0) ret = flags; } ffurl_close(h); return ret; }
11,416
0
int x86_cpu_handle_mmu_fault(CPUState *cs, vaddr addr, int is_write1, int mmu_idx) { X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; uint64_t ptep, pte; target_ulong pde_addr, pte_addr; int error_code = 0; int is_dirty, prot, page_size, is_write, is_user; hwaddr paddr; uint64_t rsvd_mask = PG_HI_RSVD_MASK; uint32_t page_offset; target_ulong vaddr; is_user = mmu_idx == MMU_USER_IDX; #if defined(DEBUG_MMU) printf("MMU fault: addr=%" VADDR_PRIx " w=%d u=%d eip=" TARGET_FMT_lx "\n", addr, is_write1, is_user, env->eip); #endif is_write = is_write1 & 1; if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; #ifdef TARGET_X86_64 if (!(env->hflags & HF_LMA_MASK)) { /* Without long mode we can only address 32bits in real mode */ pte = (uint32_t)pte; } #endif prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; page_size = 4096; goto do_mapping; } if (env->cr[4] & CR4_PAE_MASK) { uint64_t pde, pdpe; target_ulong pdpe_addr; #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { uint64_t pml4e_addr, pml4e; int32_t sext; /* test virtual address sign extension */ sext = (int64_t)addr >> 47; if (sext != 0 && sext != -1) { env->error_code = 0; cs->exception_index = EXCP0D_GPF; return 1; } pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) & env->a20_mask; pml4e = ldq_phys(cs->as, pml4e_addr); if (!(pml4e & PG_PRESENT_MASK)) { goto do_fault; } if (pml4e & (rsvd_mask | PG_PSE_MASK)) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) { goto do_fault_rsvd; } if (!(pml4e & PG_ACCESSED_MASK)) { pml4e |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pml4e_addr, pml4e); } ptep = pml4e ^ PG_NX_MASK; pdpe_addr = ((pml4e & PG_ADDRESS_MASK) + (((addr >> 30) & 0x1ff) << 3)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } if (pdpe & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pdpe ^ PG_NX_MASK; if (!(pdpe & PG_ACCESSED_MASK)) { pdpe |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pdpe_addr, pdpe); } if (pdpe & PG_PSE_MASK) { /* 1 GB page */ page_size = 1024 * 1024 * 1024; pte_addr = pdpe_addr; pte = pdpe; goto do_check_protect; } } else #endif { /* XXX: load them when cr3 is loaded ? */ pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) & env->a20_mask; pdpe = ldq_phys(cs->as, pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { goto do_fault; } rsvd_mask |= PG_HI_USER_MASK | PG_NX_MASK; if (pdpe & rsvd_mask) { goto do_fault_rsvd; } ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK; } pde_addr = ((pdpe & PG_ADDRESS_MASK) + (((addr >> 21) & 0x1ff) << 3)) & env->a20_mask; pde = ldq_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } if (pde & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) { goto do_fault_rsvd; } ptep &= pde ^ PG_NX_MASK; if (pde & PG_PSE_MASK) { /* 2 MB page */ page_size = 2048 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } /* 4 KB page */ if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } pte_addr = ((pde & PG_ADDRESS_MASK) + (((addr >> 12) & 0x1ff) << 3)) & env->a20_mask; pte = ldq_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } if (pte & rsvd_mask) { goto do_fault_rsvd; } if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) { goto do_fault_rsvd; } /* combine pde and pte nx, user and rw protections */ ptep &= pte ^ PG_NX_MASK; page_size = 4096; } else { uint32_t pde; /* page directory entry */ pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask; pde = ldl_phys(cs->as, pde_addr); if (!(pde & PG_PRESENT_MASK)) { goto do_fault; } ptep = pde | PG_NX_MASK; /* if PSE bit is set, then we use a 4MB page */ if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { page_size = 4096 * 1024; pte_addr = pde_addr; pte = pde; goto do_check_protect; } if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(cs->as, pde_addr, pde); } /* page directory entry */ pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask; pte = ldl_phys(cs->as, pte_addr); if (!(pte & PG_PRESENT_MASK)) { goto do_fault; } /* combine pde and pte user and rw protections */ ptep &= pte | PG_NX_MASK; page_size = 4096; rsvd_mask = 0; } do_check_protect: if (pte & rsvd_mask) { goto do_fault_rsvd; } ptep ^= PG_NX_MASK; if ((ptep & PG_NX_MASK) && is_write1 == 2) { goto do_fault_protect; } switch (mmu_idx) { case MMU_USER_IDX: if (!(ptep & PG_USER_MASK)) { goto do_fault_protect; } if (is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; case MMU_KSMAP_IDX: if (is_write1 != 2 && (ptep & PG_USER_MASK)) { goto do_fault_protect; } /* fall through */ case MMU_KNOSMAP_IDX: if (is_write1 == 2 && (env->cr[4] & CR4_SMEP_MASK) && (ptep & PG_USER_MASK)) { goto do_fault_protect; } if ((env->cr[0] & CR0_WP_MASK) && is_write && !(ptep & PG_RW_MASK)) { goto do_fault_protect; } break; default: /* cannot happen */ break; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) { pte |= PG_DIRTY_MASK; } stl_phys_notdirty(cs->as, pte_addr, pte); } /* the page can be put in the TLB */ prot = PAGE_READ; if (!(ptep & PG_NX_MASK)) prot |= PAGE_EXEC; if (pte & PG_DIRTY_MASK) { /* only set write access if already dirty... otherwise wait for dirty access */ if (is_user) { if (ptep & PG_RW_MASK) prot |= PAGE_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || (ptep & PG_RW_MASK)) prot |= PAGE_WRITE; } } do_mapping: pte = pte & env->a20_mask; /* align to page_size */ pte &= PG_ADDRESS_MASK & ~(page_size - 1); /* Even if 4MB pages, we map only one 4KB page in the cache to avoid filling it too fast */ vaddr = addr & TARGET_PAGE_MASK; page_offset = vaddr & (page_size - 1); paddr = pte + page_offset; tlb_set_page(cs, vaddr, paddr, prot, mmu_idx, page_size); return 0; do_fault_rsvd: error_code |= PG_ERROR_RSVD_MASK; do_fault_protect: error_code |= PG_ERROR_P_MASK; do_fault: error_code |= (is_write << PG_ERROR_W_BIT); if (is_user) error_code |= PG_ERROR_U_MASK; if (is_write1 == 2 && (((env->efer & MSR_EFER_NXE) && (env->cr[4] & CR4_PAE_MASK)) || (env->cr[4] & CR4_SMEP_MASK))) error_code |= PG_ERROR_I_D_MASK; if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) { /* cr2 is not modified in case of exceptions */ stq_phys(cs->as, env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), addr); } else { env->cr[2] = addr; } env->error_code = error_code; cs->exception_index = EXCP0E_PAGE; return 1; }
11,417
0
int kvmppc_reset_htab(int shift_hint) { uint32_t shift = shift_hint; if (!kvm_enabled()) { /* Full emulation, tell caller to allocate htab itself */ return 0; } if (kvm_check_extension(kvm_state, KVM_CAP_PPC_ALLOC_HTAB)) { int ret; ret = kvm_vm_ioctl(kvm_state, KVM_PPC_ALLOCATE_HTAB, &shift); if (ret == -ENOTTY) { /* At least some versions of PR KVM advertise the * capability, but don't implement the ioctl(). Oops. * Return 0 so that we allocate the htab in qemu, as is * correct for PR. */ return 0; } else if (ret < 0) { return ret; } return shift; } /* We have a kernel that predates the htab reset calls. For PR * KVM, we need to allocate the htab ourselves, for an HV KVM of * this era, it has allocated a 16MB fixed size hash table * already. Kernels of this era have the GET_PVINFO capability * only on PR, so we use this hack to determine the right * answer */ if (kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_PVINFO)) { /* PR - tell caller to allocate htab */ return 0; } else { /* HV - assume 16MB kernel allocated htab */ return 24; } }
11,418
0
static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; st = av_new_stream(c->fc, c->fc->nb_streams); if (!st) return AVERROR(ENOMEM); sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = CODEC_TYPE_DATA; sc->ffindex = st->index; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; /* sanity checks */ if(sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))){ av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); sc->sample_count = 0; //ignore track return 0; } if(!sc->time_rate) sc->time_rate=1; if(!sc->time_scale) sc->time_scale= c->time_scale; av_set_pts_info(st, 64, sc->time_rate, sc->time_scale); if (st->codec->codec_type == CODEC_TYPE_AUDIO && !st->codec->frame_size && sc->stts_count == 1) { st->codec->frame_size = av_rescale(sc->stts_data[0].duration, st->codec->sample_rate, sc->time_scale); dprintf(c->fc, "frame size %d\n", st->codec->frame_size); } if(st->duration != AV_NOPTS_VALUE){ assert(st->duration % sc->time_rate == 0); st->duration /= sc->time_rate; } mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { if (url_fopen(&sc->pb, sc->drefs[sc->dref_id-1].path, URL_RDONLY) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening file %s: %s\n", st->index, sc->drefs[sc->dref_id-1].path, strerror(errno)); } else sc->pb = c->fc->pb; switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case CODEC_ID_MPEG4: #endif st->codec->width= 0; /* let decoder init width/height */ st->codec->height= 0; break; } /* Do not need those anymore. */ av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); return 0; }
11,419
0
static void FUNCC(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset, const int16_t *block, ptrdiff_t stride) { int i; for(i=0; i<4; i++) FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride); }
11,420
0
void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum){ s->update_checksum= update_checksum; s->checksum= s->update_checksum(checksum, NULL, 0); s->checksum_ptr= s->buf_ptr; }
11,421
0
static av_cold int hap_init(AVCodecContext *avctx) { HapContext *ctx = avctx->priv_data; int ratio; int corrected_chunk_count; int ret = av_image_check_size(avctx->width, avctx->height, 0, avctx); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid video size %dx%d.\n", avctx->width, avctx->height); return ret; } if (avctx->width % 4 || avctx->height % 4) { av_log(avctx, AV_LOG_ERROR, "Video size %dx%d is not multiple of 4.\n", avctx->width, avctx->height); return AVERROR_INVALIDDATA; } ff_texturedspenc_init(&ctx->dxtc); switch (ctx->opt_tex_fmt) { case HAP_FMT_RGBDXT1: ratio = 8; avctx->codec_tag = MKTAG('H', 'a', 'p', '1'); avctx->bits_per_coded_sample = 24; ctx->tex_fun = ctx->dxtc.dxt1_block; break; case HAP_FMT_RGBADXT5: ratio = 4; avctx->codec_tag = MKTAG('H', 'a', 'p', '5'); avctx->bits_per_coded_sample = 32; ctx->tex_fun = ctx->dxtc.dxt5_block; break; case HAP_FMT_YCOCGDXT5: ratio = 4; avctx->codec_tag = MKTAG('H', 'a', 'p', 'Y'); avctx->bits_per_coded_sample = 24; ctx->tex_fun = ctx->dxtc.dxt5ys_block; break; default: av_log(avctx, AV_LOG_ERROR, "Invalid format %02X\n", ctx->opt_tex_fmt); return AVERROR_INVALIDDATA; } /* Texture compression ratio is constant, so can we computer * beforehand the final size of the uncompressed buffer. */ ctx->tex_size = FFALIGN(avctx->width, TEXTURE_BLOCK_W) * FFALIGN(avctx->height, TEXTURE_BLOCK_H) * 4 / ratio; /* Round the chunk count to divide evenly on DXT block edges */ corrected_chunk_count = av_clip(ctx->opt_chunk_count, 1, HAP_MAX_CHUNKS); while ((ctx->tex_size / (64 / ratio)) % corrected_chunk_count != 0) { corrected_chunk_count--; } if (corrected_chunk_count != ctx->opt_chunk_count) { av_log(avctx, AV_LOG_INFO, "%d chunks requested but %d used.\n", ctx->opt_chunk_count, corrected_chunk_count); } ret = ff_hap_set_chunk_count(ctx, corrected_chunk_count, 1); if (ret != 0) return ret; ctx->max_snappy = snappy_max_compressed_length(ctx->tex_size / corrected_chunk_count); ctx->tex_buf = av_malloc(ctx->tex_size); if (!ctx->tex_buf) return AVERROR(ENOMEM); return 0; }
11,422
0
static int mpeg_mux_write_packet(AVFormatContext *ctx, int stream_index, const uint8_t *buf, int size, int64_t pts) { MpegMuxContext *s = ctx->priv_data; AVStream *st = ctx->streams[stream_index]; StreamInfo *stream = st->priv_data; int len; while (size > 0) { /* set pts */ if (stream->start_pts == -1) { stream->start_pts = pts; } len = s->packet_data_max_size - stream->buffer_ptr; if (len > size) len = size; memcpy(stream->buffer + stream->buffer_ptr, buf, len); stream->buffer_ptr += len; buf += len; size -= len; while (stream->buffer_ptr >= s->packet_data_max_size) { /* output the packet */ if (stream->start_pts == -1) stream->start_pts = pts; flush_packet(ctx, stream_index, 0); } } return 0; }
11,424
0
static int decode_i_block(FourXContext *f, int16_t *block) { int code, i, j, level, val; if (get_bits_left(&f->gb) < 2){ av_log(f->avctx, AV_LOG_ERROR, "%d bits left before decode_i_block()\n", get_bits_left(&f->gb)); return -1; } /* DC coef */ val = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); if (val >> 4) av_log(f->avctx, AV_LOG_ERROR, "error dc run != 0\n"); if (val) val = get_xbits(&f->gb, val); val = val * dequant_table[0] + f->last_dc; f->last_dc = block[0] = val; /* AC coefs */ i = 1; for (;;) { code = get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3); /* EOB */ if (code == 0) break; if (code == 0xf0) { i += 16; } else { level = get_xbits(&f->gb, code & 0xf); i += code >> 4; if (i >= 64) { av_log(f->avctx, AV_LOG_ERROR, "run %d oveflow\n", i); return 0; } j = ff_zigzag_direct[i]; block[j] = level * dequant_table[j]; i++; if (i >= 64) break; } } return 0; }
11,425
0
static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, const uint8_t **buf, int buf_size) { MpegEncContext *s = &s1->mpeg_enc_ctx; AVCodecContext *avctx= s->avctx; const int field_pic= s->picture_structure != PICT_FRAME; const int lowres= s->avctx->lowres; s->resync_mb_x= s->resync_mb_y= -1; if (mb_y >= s->mb_height){ av_log(s->avctx, AV_LOG_ERROR, "slice below image (%d >= %d)\n", mb_y, s->mb_height); return -1; } init_get_bits(&s->gb, *buf, buf_size*8); ff_mpeg1_clean_buffers(s); s->interlaced_dct = 0; s->qscale = get_qscale(s); if(s->qscale == 0){ av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n"); return -1; } /* extra slice info */ while (get_bits1(&s->gb) != 0) { skip_bits(&s->gb, 8); } s->mb_x=0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_x += 33; } /* otherwise, stuffing, nothing to do */ } else { s->mb_x += code; break; } } if(s->mb_x >= (unsigned)s->mb_width){ av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n"); return -1; } if (avctx->hwaccel) { const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */ int start_code = -1; buf_end = ff_find_start_code(buf_start + 2, *buf + buf_size, &start_code); if (buf_end < *buf + buf_size) buf_end -= 4; s->mb_y = mb_y; if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_end - buf_start) < 0) return DECODE_SLICE_ERROR; *buf = buf_end; return DECODE_SLICE_OK; } s->resync_mb_x= s->mb_x; s->resync_mb_y= s->mb_y= mb_y; s->mb_skip_run= 0; ff_init_block_index(s); if (s->mb_y==0 && s->mb_x==0 && (s->first_field || s->picture_structure==PICT_FRAME)) { if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n", s->qscale, s->mpeg_f_code[0][0],s->mpeg_f_code[0][1],s->mpeg_f_code[1][0],s->mpeg_f_code[1][1], s->pict_type == FF_I_TYPE ? "I" : (s->pict_type == FF_P_TYPE ? "P" : (s->pict_type == FF_B_TYPE ? "B" : "S")), s->progressive_sequence ? "ps" :"", s->progressive_frame ? "pf" : "", s->alternate_scan ? "alt" :"", s->top_field_first ? "top" :"", s->intra_dc_precision, s->picture_structure, s->frame_pred_frame_dct, s->concealment_motion_vectors, s->q_scale_type, s->intra_vlc_format, s->repeat_first_field, s->chroma_420_type ? "420" :""); } } for(;;) { //If 1, we memcpy blocks in xvmcvideo. if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1) ff_xvmc_init_block(s);//set s->block if(mpeg_decode_mb(s, s->block) < 0) return -1; if(s->current_picture.motion_val[0] && !s->encoding){ //note motion_val is normally NULL unless we want to extract the MVs const int wrap = s->b8_stride; int xy = s->mb_x*2 + s->mb_y*2*wrap; int motion_x, motion_y, dir, i; for(i=0; i<2; i++){ for(dir=0; dir<2; dir++){ if (s->mb_intra || (dir==1 && s->pict_type != FF_B_TYPE)) { motion_x = motion_y = 0; }else if (s->mv_type == MV_TYPE_16X16 || (s->mv_type == MV_TYPE_FIELD && field_pic)){ motion_x = s->mv[dir][0][0]; motion_y = s->mv[dir][0][1]; } else /*if ((s->mv_type == MV_TYPE_FIELD) || (s->mv_type == MV_TYPE_16X8))*/ { motion_x = s->mv[dir][i][0]; motion_y = s->mv[dir][i][1]; } s->current_picture.motion_val[dir][xy ][0] = motion_x; s->current_picture.motion_val[dir][xy ][1] = motion_y; s->current_picture.motion_val[dir][xy + 1][0] = motion_x; s->current_picture.motion_val[dir][xy + 1][1] = motion_y; s->current_picture.ref_index [dir][xy ]= s->current_picture.ref_index [dir][xy + 1]= s->field_select[dir][i]; assert(s->field_select[dir][i]==0 || s->field_select[dir][i]==1); } xy += wrap; } } s->dest[0] += 16 >> lowres; s->dest[1] +=(16 >> lowres) >> s->chroma_x_shift; s->dest[2] +=(16 >> lowres) >> s->chroma_x_shift; MPV_decode_mb(s, s->block); if (++s->mb_x >= s->mb_width) { const int mb_size= 16>>s->avctx->lowres; ff_draw_horiz_band(s, mb_size*(s->mb_y>>field_pic), mb_size); s->mb_x = 0; s->mb_y += 1<<field_pic; if(s->mb_y >= s->mb_height){ int left= get_bits_left(&s->gb); int is_d10= s->chroma_format==2 && s->pict_type==FF_I_TYPE && avctx->profile==0 && avctx->level==5 && s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0 && s->progressive_frame == 0 /* vbv_delay == 0xBBB || 0xE10*/; if(left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) || (avctx->error_recognition >= FF_ER_AGGRESSIVE && left>8)){ av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n", left, show_bits(&s->gb, FFMIN(left, 23))); return -1; }else goto eos; } ff_init_block_index(s); } /* skip mb handling */ if (s->mb_skip_run == -1) { /* read increment again */ s->mb_skip_run = 0; for(;;) { int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n"); return -1; } if (code >= 33) { if (code == 33) { s->mb_skip_run += 33; }else if(code == 35){ if(s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0){ av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n"); return -1; } goto eos; /* end of slice */ } /* otherwise, stuffing, nothing to do */ } else { s->mb_skip_run += code; break; } } if(s->mb_skip_run){ int i; if(s->pict_type == FF_I_TYPE){ av_log(s->avctx, AV_LOG_ERROR, "skipped MB in I frame at %d %d\n", s->mb_x, s->mb_y); return -1; } /* skip mb */ s->mb_intra = 0; for(i=0;i<12;i++) s->block_last_index[i] = -1; if(s->picture_structure == PICT_FRAME) s->mv_type = MV_TYPE_16X16; else s->mv_type = MV_TYPE_FIELD; if (s->pict_type == FF_P_TYPE) { /* if P type, zero motion vector is implied */ s->mv_dir = MV_DIR_FORWARD; s->mv[0][0][0] = s->mv[0][0][1] = 0; s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0; s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0; s->field_select[0][0]= (s->picture_structure - 1) & 1; } else { /* if B type, reuse previous vectors and directions */ s->mv[0][0][0] = s->last_mv[0][0][0]; s->mv[0][0][1] = s->last_mv[0][0][1]; s->mv[1][0][0] = s->last_mv[1][0][0]; s->mv[1][0][1] = s->last_mv[1][0][1]; } } } } eos: // end of slice *buf += (get_bits_count(&s->gb)-1)/8; //printf("y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y); return 0; }
11,426
0
static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, long width, long height, long lumStride, long chromStride, long srcStride) { long y; const long chromWidth= width>>1; #ifdef HAVE_MMX for(y=0; y<height-2; y+=2) { long i; for(i=0; i<2; i++) { asm volatile( "mov %2, %%"REG_a" \n\t" "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd 3(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 6(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 15(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 18(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm4 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm2, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "packuswb %%mm4, %%mm0 \n\t" "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" MOVNTQ" %%mm0, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+width*3), "r" (ydst+width), "g" (-width) : "%"REG_a, "%"REG_b ); ydst += lumStride; src += srcStride; } src -= srcStride*2; asm volatile( "mov %4, %%"REG_a" \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" "add %%"REG_b", %%"REG_b" \n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" PREFETCH" 64(%1, %%"REG_b") \n\t" #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) "movq (%0, %%"REG_b"), %%mm0 \n\t" "movq (%1, %%"REG_b"), %%mm1 \n\t" "movq 6(%0, %%"REG_b"), %%mm2 \n\t" "movq 6(%1, %%"REG_b"), %%mm3 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm0 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm0 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd (%1, %%"REG_b"), %%mm1 \n\t" "movd 3(%0, %%"REG_b"), %%mm2 \n\t" "movd 3(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm0 \n\t" "movd 6(%0, %%"REG_b"), %%mm4 \n\t" "movd 6(%1, %%"REG_b"), %%mm1 \n\t" "movd 9(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm4, %%mm2 \n\t" "psrlw $2, %%mm0 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm0, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm0 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "packssdw %%mm1, %%mm0 \n\t" // V1 V0 U1 U0 "psraw $7, %%mm0 \n\t" #if defined (HAVE_MMX2) || defined (HAVE_3DNOW) "movq 12(%0, %%"REG_b"), %%mm4 \n\t" "movq 12(%1, %%"REG_b"), %%mm1 \n\t" "movq 18(%0, %%"REG_b"), %%mm2 \n\t" "movq 18(%1, %%"REG_b"), %%mm3 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "movq %%mm4, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $24, %%mm4 \n\t" "psrlq $24, %%mm2 \n\t" PAVGB" %%mm1, %%mm4 \n\t" PAVGB" %%mm3, %%mm2 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" #else "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 12(%1, %%"REG_b"), %%mm1 \n\t" "movd 15(%0, %%"REG_b"), %%mm2 \n\t" "movd 15(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm4 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm2, %%mm4 \n\t" "movd 18(%0, %%"REG_b"), %%mm5 \n\t" "movd 18(%1, %%"REG_b"), %%mm1 \n\t" "movd 21(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%1, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm5 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "paddw %%mm1, %%mm5 \n\t" "paddw %%mm3, %%mm2 \n\t" "paddw %%mm5, %%mm2 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "psrlw $2, %%mm4 \n\t" "psrlw $2, %%mm2 \n\t" #endif "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" "pmaddwd %%mm4, %%mm1 \n\t" "pmaddwd %%mm2, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm2, %%mm4 \n\t" "packssdw %%mm3, %%mm1 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm1 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm1, %%mm4 \n\t" // V3 V2 U3 U2 "psraw $7, %%mm4 \n\t" "movq %%mm0, %%mm1 \n\t" "punpckldq %%mm4, %%mm0 \n\t" "punpckhdq %%mm4, %%mm1 \n\t" "packsswb %%mm1, %%mm0 \n\t" "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" "movd %%mm0, (%2, %%"REG_a") \n\t" "punpckhdq %%mm0, %%mm0 \n\t" "movd %%mm0, (%3, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+chromWidth*6), "r" (src+srcStride+chromWidth*6), "r" (udst+chromWidth), "r" (vdst+chromWidth), "g" (-chromWidth) : "%"REG_a, "%"REG_b ); udst += chromStride; vdst += chromStride; src += srcStride*2; } asm volatile( EMMS" \n\t" SFENCE" \n\t" :::"memory"); #else y=0; #endif for(; y<height; y+=2) { long i; for(i=0; i<chromWidth; i++) { unsigned int b= src[6*i+0]; unsigned int g= src[6*i+1]; unsigned int r= src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; unsigned int V = ((RV*r + GV*g + BV*b)>>RGB2YUV_SHIFT) + 128; unsigned int U = ((RU*r + GU*g + BU*b)>>RGB2YUV_SHIFT) + 128; udst[i] = U; vdst[i] = V; ydst[2*i] = Y; b= src[6*i+3]; g= src[6*i+4]; r= src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } ydst += lumStride; src += srcStride; for(i=0; i<chromWidth; i++) { unsigned int b= src[6*i+0]; unsigned int g= src[6*i+1]; unsigned int r= src[6*i+2]; unsigned int Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i] = Y; b= src[6*i+3]; g= src[6*i+4]; r= src[6*i+5]; Y = ((RY*r + GY*g + BY*b)>>RGB2YUV_SHIFT) + 16; ydst[2*i+1] = Y; } udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } }
11,429
0
static int paf_vid_decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt) { PAFVideoDecContext *c = avctx->priv_data; uint8_t code, *dst, *src, *end; int i, frame, ret; c->pic.reference = 3; if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0) return ret; bytestream2_init(&c->gb, pkt->data, pkt->size); code = bytestream2_get_byte(&c->gb); if (code & 0x20) { for (i = 0; i < 4; i++) memset(c->frame[i], 0, c->frame_size); memset(c->pic.data[1], 0, AVPALETTE_SIZE); c->current_frame = 0; c->pic.key_frame = 1; c->pic.pict_type = AV_PICTURE_TYPE_I; } else { c->pic.key_frame = 0; c->pic.pict_type = AV_PICTURE_TYPE_P; } if (code & 0x40) { uint32_t *out = (uint32_t *)c->pic.data[1]; int index, count; index = bytestream2_get_byte(&c->gb); count = bytestream2_get_byte(&c->gb) + 1; if (index + count > AVPALETTE_SIZE) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&c->gb) < 3 * AVPALETTE_SIZE) return AVERROR_INVALIDDATA; out += index; for (i = 0; i < count; i++) { unsigned r, g, b; r = bytestream2_get_byteu(&c->gb); r = r << 2 | r >> 4; g = bytestream2_get_byteu(&c->gb); g = g << 2 | g >> 4; b = bytestream2_get_byteu(&c->gb); b = b << 2 | b >> 4; *out++ = 0xFFU << 24 | r << 16 | g << 8 | b; } c->pic.palette_has_changed = 1; } switch (code & 0x0F) { case 0: if ((ret = decode_0(avctx, code, pkt->data)) < 0) return ret; break; case 1: dst = c->frame[c->current_frame]; bytestream2_skip(&c->gb, 2); if (bytestream2_get_bytes_left(&c->gb) < c->video_size) return AVERROR_INVALIDDATA; bytestream2_get_bufferu(&c->gb, dst, c->video_size); break; case 2: frame = bytestream2_get_byte(&c->gb); if (frame > 3) return AVERROR_INVALIDDATA; if (frame != c->current_frame) memcpy(c->frame[c->current_frame], c->frame[frame], c->frame_size); break; case 4: dst = c->frame[c->current_frame]; end = dst + c->video_size; bytestream2_skip(&c->gb, 2); while (dst < end) { int8_t code; int count; if (bytestream2_get_bytes_left(&c->gb) < 2) return AVERROR_INVALIDDATA; code = bytestream2_get_byteu(&c->gb); count = FFABS(code) + 1; if (dst + count > end) return AVERROR_INVALIDDATA; if (code < 0) memset(dst, bytestream2_get_byteu(&c->gb), count); else bytestream2_get_buffer(&c->gb, dst, count); dst += count; } break; default: av_log_ask_for_sample(avctx, "unknown/invalid code\n"); return AVERROR_INVALIDDATA; } dst = c->pic.data[0]; src = c->frame[c->current_frame]; for (i = 0; i < avctx->height; i++) { memcpy(dst, src, avctx->width); dst += c->pic.linesize[0]; src += avctx->width; } c->current_frame = (c->current_frame + 1) & 3; *data_size = sizeof(AVFrame); *(AVFrame *)data = c->pic; return pkt->size; }
11,430
0
static int file_read(URLContext *h, unsigned char *buf, int size) { FileContext *c = h->priv_data; int r = read(c->fd, buf, size); return (-1 == r)?AVERROR(errno):r; }
11,431
1
static void realview_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env; ram_addr_t ram_offset; DeviceState *dev; qemu_irq *irqp; qemu_irq pic[64]; PCIBus *pci_bus; NICInfo *nd; int n; int done_smc = 0; qemu_irq cpu_irq[4]; int ncpu; if (!cpu_model) cpu_model = "arm926"; /* FIXME: obey smp_cpus. */ if (strcmp(cpu_model, "arm11mpcore") == 0) { ncpu = 4; } else { ncpu = 1; } for (n = 0; n < ncpu; n++) { env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } irqp = arm_pic_init_cpu(env); cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; if (n > 0) { /* Set entry point for secondary CPUs. This assumes we're using the init code from arm_boot.c. Real hardware resets all CPUs the same. */ env->regs[15] = 0x80000000; } } ram_offset = qemu_ram_alloc(ram_size); /* ??? RAM should repeat to fill physical memory space. */ /* SDRAM at address zero. */ cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM); arm_sysctl_init(0x10000000, 0xc1400400); if (ncpu == 1) { /* ??? The documentation says GIC1 is nFIQ and either GIC2 or GIC3 is nIRQ (there are inconsistencies). However Linux 2.6.17 expects GIC1 to be nIRQ and ignores all the others, so do that for now. */ dev = sysbus_create_simple("realview_gic", 0x10040000, cpu_irq[0]); } else { dev = sysbus_create_varargs("realview_mpcore", -1, cpu_irq[0], cpu_irq[1], cpu_irq[2], cpu_irq[3], NULL); } for (n = 0; n < 64; n++) { pic[n] = qdev_get_gpio_in(dev, n); } sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]); sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]); sysbus_create_simple("pl011", 0x10009000, pic[12]); sysbus_create_simple("pl011", 0x1000a000, pic[13]); sysbus_create_simple("pl011", 0x1000b000, pic[14]); sysbus_create_simple("pl011", 0x1000c000, pic[15]); /* DMA controller is optional, apparently. */ sysbus_create_simple("pl081", 0x10030000, pic[24]); sysbus_create_simple("sp804", 0x10011000, pic[4]); sysbus_create_simple("sp804", 0x10012000, pic[5]); sysbus_create_simple("pl110_versatile", 0x10020000, pic[23]); sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL); sysbus_create_simple("pl031", 0x10017000, pic[10]); dev = sysbus_create_varargs("realview_pci", 0x60000000, pic[48], pic[49], pic[50], pic[51], NULL); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); if (usb_enabled) { usb_ohci_init_pci(pci_bus, -1); } n = drive_get_max_bus(IF_SCSI); while (n >= 0) { pci_create_simple(pci_bus, -1, "lsi53c895a"); n--; } for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) { smc91c111_init(nd, 0x4e000000, pic[28]); done_smc = 1; } else { pci_nic_init(nd, "rtl8139", NULL); } } /* Memory map for RealView Emulation Baseboard: */ /* 0x10000000 System registers. */ /* 0x10001000 System controller. */ /* 0x10002000 Two-Wire Serial Bus. */ /* 0x10003000 Reserved. */ /* 0x10004000 AACI. */ /* 0x10005000 MCI. */ /* 0x10006000 KMI0. */ /* 0x10007000 KMI1. */ /* 0x10008000 Character LCD. */ /* 0x10009000 UART0. */ /* 0x1000a000 UART1. */ /* 0x1000b000 UART2. */ /* 0x1000c000 UART3. */ /* 0x1000d000 SSPI. */ /* 0x1000e000 SCI. */ /* 0x1000f000 Reserved. */ /* 0x10010000 Watchdog. */ /* 0x10011000 Timer 0+1. */ /* 0x10012000 Timer 2+3. */ /* 0x10013000 GPIO 0. */ /* 0x10014000 GPIO 1. */ /* 0x10015000 GPIO 2. */ /* 0x10016000 Reserved. */ /* 0x10017000 RTC. */ /* 0x10018000 DMC. */ /* 0x10019000 PCI controller config. */ /* 0x10020000 CLCD. */ /* 0x10030000 DMA Controller. */ /* 0x10040000 GIC1. */ /* 0x10050000 GIC2. */ /* 0x10060000 GIC3. */ /* 0x10070000 GIC4. */ /* 0x10080000 SMC. */ /* 0x40000000 NOR flash. */ /* 0x44000000 DoC flash. */ /* 0x48000000 SRAM. */ /* 0x4c000000 Configuration flash. */ /* 0x4e000000 Ethernet. */ /* 0x4f000000 USB. */ /* 0x50000000 PISMO. */ /* 0x54000000 PISMO. */ /* 0x58000000 PISMO. */ /* 0x5c000000 PISMO. */ /* 0x60000000 PCI. */ /* 0x61000000 PCI Self Config. */ /* 0x62000000 PCI Config. */ /* 0x63000000 PCI IO. */ /* 0x64000000 PCI mem 0. */ /* 0x68000000 PCI mem 1. */ /* 0x6c000000 PCI mem 2. */ /* ??? Hack to map an additional page of ram for the secondary CPU startup code. I guess this works on real hardware because the BootROM happens to be in ROM/flash or in memory that isn't clobbered until after Linux boots the secondary CPUs. */ ram_offset = qemu_ram_alloc(0x1000); cpu_register_physical_memory(0x80000000, 0x1000, ram_offset | IO_MEM_RAM); realview_binfo.ram_size = ram_size; realview_binfo.kernel_filename = kernel_filename; realview_binfo.kernel_cmdline = kernel_cmdline; realview_binfo.initrd_filename = initrd_filename; realview_binfo.nb_cpus = ncpu; arm_load_kernel(first_cpu, &realview_binfo); }
11,432
1
int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len) { int len1; len1 = len; ts->pkt = pkt; ts->stop_parse = 0; for(;;) { if (ts->stop_parse>0) break; if (len < TS_PACKET_SIZE) return -1; if (buf[0] != 0x47) { buf++; len--; } else { handle_packet(ts, buf); buf += TS_PACKET_SIZE; len -= TS_PACKET_SIZE; } } return len1 - len; }
11,434
1
static int mszh_decomp(unsigned char * srcptr, int srclen, unsigned char * destptr) { unsigned char *destptr_bak = destptr; unsigned char mask = 0; unsigned char maskbit = 0; unsigned int ofs, cnt; while (srclen > 0) { if (maskbit == 0) { mask = *(srcptr++); maskbit = 8; srclen--; continue; } if ((mask & (1 << (--maskbit))) == 0) { *(int*)destptr = *(int*)srcptr; 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; for (; cnt > 0; cnt--) { *(destptr) = *(destptr - ofs); destptr++; } } } return (destptr - destptr_bak); }
11,435
1
int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, int first_header_size, uint8_t *header_start[3], int header_len[3]) { int i, j; if (AV_RB16(extradata) == first_header_size) { for (i=0; i<3; i++) { header_len[i] = AV_RB16(extradata); extradata += 2; header_start[i] = extradata; extradata += header_len[i]; } } else if (extradata[0] == 2) { for (i=0,j=1; i<2; i++,j++) { header_len[i] = 0; for (; j<extradata_size && extradata[j]==0xff; j++) { header_len[i] += 0xff; } if (j >= extradata_size) return -1; header_len[i] += extradata[j]; } header_len[2] = extradata_size - header_len[0] - header_len[1] - j; extradata += j; header_start[0] = extradata; header_start[1] = header_start[0] + header_len[0]; header_start[2] = header_start[1] + header_len[1]; } else { return -1; } return 0; }
11,436
1
static int vp3_decode_init(AVCodecContext *avctx) { Vp3DecodeContext *s = avctx->priv_data; int i; s->avctx = avctx; s->width = avctx->width; s->height = avctx->height; avctx->pix_fmt = PIX_FMT_YUV420P; avctx->has_b_frames = 0; dsputil_init(&s->dsp, avctx); /* initialize to an impossible value which will force a recalculation * in the first frame decode */ s->quality_index = -1; s->superblock_width = (s->width + 31) / 32; s->superblock_height = (s->height + 31) / 32; s->superblock_count = s->superblock_width * s->superblock_height * 3 / 2; s->u_superblock_start = s->superblock_width * s->superblock_height; s->v_superblock_start = s->superblock_width * s->superblock_height * 5 / 4; s->superblock_coding = av_malloc(s->superblock_count); s->macroblock_width = (s->width + 15) / 16; s->macroblock_height = (s->height + 15) / 16; s->macroblock_count = s->macroblock_width * s->macroblock_height; s->fragment_width = s->width / FRAGMENT_PIXELS; s->fragment_height = s->height / FRAGMENT_PIXELS; /* fragment count covers all 8x8 blocks for all 3 planes */ s->fragment_count = s->fragment_width * s->fragment_height * 3 / 2; s->u_fragment_start = s->fragment_width * s->fragment_height; s->v_fragment_start = s->fragment_width * s->fragment_height * 5 / 4; debug_init(" width: %d x %d\n", s->width, s->height); debug_init(" superblocks: %d x %d, %d total\n", s->superblock_width, s->superblock_height, s->superblock_count); debug_init(" macroblocks: %d x %d, %d total\n", s->macroblock_width, s->macroblock_height, s->macroblock_count); debug_init(" %d fragments, %d x %d, u starts @ %d, v starts @ %d\n", s->fragment_count, s->fragment_width, s->fragment_height, s->u_fragment_start, s->v_fragment_start); s->all_fragments = av_malloc(s->fragment_count * sizeof(Vp3Fragment)); s->coded_fragment_list = av_malloc(s->fragment_count * sizeof(int)); s->pixel_addresses_inited = 0; /* init VLC tables */ for (i = 0; i < 16; i++) { /* Dc histograms */ init_vlc(&s->dc_vlc[i], 5, 32, &dc_bias[i][0][1], 4, 2, &dc_bias[i][0][0], 4, 2); /* level 1 AC histograms */ init_vlc(&s->ac_vlc_1[i], 5, 32, &ac_bias_0[i][0][1], 4, 2, &ac_bias_0[i][0][0], 4, 2); /* level 2 AC histograms */ init_vlc(&s->ac_vlc_2[i], 5, 32, &ac_bias_1[i][0][1], 4, 2, &ac_bias_1[i][0][0], 4, 2); /* level 3 AC histograms */ init_vlc(&s->ac_vlc_3[i], 5, 32, &ac_bias_2[i][0][1], 4, 2, &ac_bias_2[i][0][0], 4, 2); /* level 4 AC histograms */ init_vlc(&s->ac_vlc_4[i], 5, 32, &ac_bias_3[i][0][1], 4, 2, &ac_bias_3[i][0][0], 4, 2); } /* build quantization table */ for (i = 0; i < 64; i++) quant_index[dequant_index[i]] = i; /* work out the block mapping tables */ s->superblock_fragments = av_malloc(s->superblock_count * 16 * sizeof(int)); s->superblock_macroblocks = av_malloc(s->superblock_count * 4 * sizeof(int)); s->macroblock_fragments = av_malloc(s->macroblock_count * 6 * sizeof(int)); s->macroblock_coded = av_malloc(s->macroblock_count + 1); init_block_mapping(s); /* make sure that frames are available to be freed on the first decode */ if(avctx->get_buffer(avctx, &s->golden_frame) < 0) { printf("vp3: get_buffer() failed\n"); return -1; } return 0; }
11,437
1
uint16_t qpci_io_readw(QPCIDevice *dev, void *data) { uintptr_t addr = (uintptr_t)data; if (addr < QPCI_PIO_LIMIT) { return dev->bus->pio_readw(dev->bus, addr); } else { uint16_t val; dev->bus->memread(dev->bus, addr, &val, sizeof(val)); return le16_to_cpu(val); } }
11,438
0
int avfilter_config_links(AVFilterContext *filter) { int (*config_link)(AVFilterLink *); unsigned i; int ret; for (i = 0; i < filter->nb_inputs; i ++) { AVFilterLink *link = filter->inputs[i]; AVFilterLink *inlink = link->src->nb_inputs ? link->src->inputs[0] : NULL; if (!link) continue; link->current_pts = AV_NOPTS_VALUE; switch (link->init_state) { case AVLINK_INIT: continue; case AVLINK_STARTINIT: av_log(filter, AV_LOG_INFO, "circular filter chain detected\n"); return 0; case AVLINK_UNINIT: link->init_state = AVLINK_STARTINIT; if ((ret = avfilter_config_links(link->src)) < 0) return ret; if (!(config_link = link->srcpad->config_props)) { if (link->src->nb_inputs != 1) { av_log(link->src, AV_LOG_ERROR, "Source filters and filters " "with more than one input " "must set config_props() " "callbacks on all outputs\n"); return AVERROR(EINVAL); } } else if ((ret = config_link(link)) < 0) { av_log(link->src, AV_LOG_ERROR, "Failed to configure output pad on %s\n", link->src->name); return ret; } switch (link->type) { case AVMEDIA_TYPE_VIDEO: if (!link->time_base.num && !link->time_base.den) link->time_base = inlink ? inlink->time_base : AV_TIME_BASE_Q; if (!link->sample_aspect_ratio.num && !link->sample_aspect_ratio.den) link->sample_aspect_ratio = inlink ? inlink->sample_aspect_ratio : (AVRational){1,1}; if (inlink && !link->frame_rate.num && !link->frame_rate.den) link->frame_rate = inlink->frame_rate; if (inlink) { if (!link->w) link->w = inlink->w; if (!link->h) link->h = inlink->h; } else if (!link->w || !link->h) { av_log(link->src, AV_LOG_ERROR, "Video source filters must set their output link's " "width and height\n"); return AVERROR(EINVAL); } break; case AVMEDIA_TYPE_AUDIO: if (inlink) { if (!link->sample_rate) link->sample_rate = inlink->sample_rate; if (!link->time_base.num && !link->time_base.den) link->time_base = inlink->time_base; if (!link->channel_layout) link->channel_layout = inlink->channel_layout; } else if (!link->sample_rate) { av_log(link->src, AV_LOG_ERROR, "Audio source filters must set their output link's " "sample_rate\n"); return AVERROR(EINVAL); } if (!link->time_base.num && !link->time_base.den) link->time_base = (AVRational) {1, link->sample_rate}; } if ((config_link = link->dstpad->config_props)) if ((ret = config_link(link)) < 0) { av_log(link->src, AV_LOG_ERROR, "Failed to configure input pad on %s\n", link->dst->name); return ret; } link->init_state = AVLINK_INIT; } } return 0; }
11,440
0
static inline void RENAME(bgr24ToY)(uint8_t *dst, uint8_t *src, long width) { #ifdef HAVE_MMX asm volatile( "mov %2, %%"REG_a" \n\t" "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" "movq "MANGLE(w1111)", %%mm5 \n\t" "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_b"\n\t" ASMALIGN16 "1: \n\t" PREFETCH" 64(%0, %%"REG_b") \n\t" "movd (%0, %%"REG_b"), %%mm0 \n\t" "movd 3(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 6(%0, %%"REG_b"), %%mm2 \n\t" "movd 9(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm0 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm0 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm0 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "packssdw %%mm2, %%mm0 \n\t" "psraw $7, %%mm0 \n\t" "movd 12(%0, %%"REG_b"), %%mm4 \n\t" "movd 15(%0, %%"REG_b"), %%mm1 \n\t" "punpcklbw %%mm7, %%mm4 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movd 18(%0, %%"REG_b"), %%mm2 \n\t" "movd 21(%0, %%"REG_b"), %%mm3 \n\t" "punpcklbw %%mm7, %%mm2 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "pmaddwd %%mm6, %%mm4 \n\t" "pmaddwd %%mm6, %%mm1 \n\t" "pmaddwd %%mm6, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" #ifndef FAST_BGR2YV12 "psrad $8, %%mm4 \n\t" "psrad $8, %%mm1 \n\t" "psrad $8, %%mm2 \n\t" "psrad $8, %%mm3 \n\t" #endif "packssdw %%mm1, %%mm4 \n\t" "packssdw %%mm3, %%mm2 \n\t" "pmaddwd %%mm5, %%mm4 \n\t" "pmaddwd %%mm5, %%mm2 \n\t" "add $24, %%"REG_b" \n\t" "packssdw %%mm2, %%mm4 \n\t" "psraw $7, %%mm4 \n\t" "packuswb %%mm4, %%mm0 \n\t" "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" "movq %%mm0, (%1, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "r" (src+width*3), "r" (dst+width), "g" (-width) : "%"REG_a, "%"REG_b ); #else int i; for(i=0; i<width; i++) { int b= src[i*3+0]; int g= src[i*3+1]; int r= src[i*3+2]; dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); } #endif }
11,441
0
static inline int decode_subframe(FLACContext *s, int channel) { int type, wasted = 0; int i, tmp; s->curr_bps = s->bps; if (channel == 0) { if (s->decorrelation == RIGHT_SIDE) s->curr_bps++; } else { if (s->decorrelation == LEFT_SIDE || s->decorrelation == MID_SIDE) s->curr_bps++; } if (s->curr_bps > 32) { ff_log_missing_feature(s->avctx, "decorrelated bit depth > 32", 0); return -1; } if (get_bits1(&s->gb)) { av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n"); return -1; } type = get_bits(&s->gb, 6); if (get_bits1(&s->gb)) { wasted = 1; while (!get_bits1(&s->gb)) wasted++; s->curr_bps -= wasted; } //FIXME use av_log2 for types if (type == 0) { tmp = get_sbits_long(&s->gb, s->curr_bps); for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] = tmp; } else if (type == 1) { for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] = get_sbits_long(&s->gb, s->curr_bps); } else if ((type >= 8) && (type <= 12)) { if (decode_subframe_fixed(s, channel, type & ~0x8) < 0) return -1; } else if (type >= 32) { if (decode_subframe_lpc(s, channel, (type & ~0x20)+1) < 0) return -1; } else { av_log(s->avctx, AV_LOG_ERROR, "invalid coding type\n"); return -1; } if (wasted) { int i; for (i = 0; i < s->blocksize; i++) s->decoded[channel][i] <<= wasted; } return 0; }
11,442
0
static void unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) { int bit = 0; int current_superblock = 0; int current_run = 0; int decode_fully_flags = 0; int decode_partial_blocks = 0; int i, j; int current_fragment; debug_vp3(" vp3: unpacking superblock coding\n"); if (s->keyframe) { debug_vp3(" keyframe-- all superblocks are fully coded\n"); memset(s->superblock_coding, SB_FULLY_CODED, s->superblock_count); } else { /* unpack the list of partially-coded superblocks */ bit = get_bits(gb, 1); /* toggle the bit because as soon as the first run length is * fetched the bit will be toggled again */ bit ^= 1; while (current_superblock < s->superblock_count) { if (current_run == 0) { bit ^= 1; current_run = get_superblock_run_length(gb); debug_block_coding(" setting superblocks %d..%d to %s\n", current_superblock, current_superblock + current_run - 1, (bit) ? "partially coded" : "not coded"); /* if any of the superblocks are not partially coded, flag * a boolean to decode the list of fully-coded superblocks */ if (bit == 0) decode_fully_flags = 1; } else { /* make a note of the fact that there are partially coded * superblocks */ decode_partial_blocks = 1; } s->superblock_coding[current_superblock++] = (bit) ? SB_PARTIALLY_CODED : SB_NOT_CODED; current_run--; } /* unpack the list of fully coded superblocks if any of the blocks were * not marked as partially coded in the previous step */ if (decode_fully_flags) { current_superblock = 0; current_run = 0; bit = get_bits(gb, 1); /* toggle the bit because as soon as the first run length is * fetched the bit will be toggled again */ bit ^= 1; while (current_superblock < s->superblock_count) { /* skip any superblocks already marked as partially coded */ if (s->superblock_coding[current_superblock] == SB_NOT_CODED) { if (current_run == 0) { bit ^= 1; current_run = get_superblock_run_length(gb); } debug_block_coding(" setting superblock %d to %s\n", current_superblock, (bit) ? "fully coded" : "not coded"); s->superblock_coding[current_superblock] = (bit) ? SB_FULLY_CODED : SB_NOT_CODED; current_run--; } current_superblock++; } } /* if there were partial blocks, initialize bitstream for * unpacking fragment codings */ if (decode_partial_blocks) { current_run = 0; bit = get_bits(gb, 1); /* toggle the bit because as soon as the first run length is * fetched the bit will be toggled again */ bit ^= 1; } } /* figure out which fragments are coded; iterate through each * superblock (all planes) */ s->coded_fragment_list_index = 0; s->first_coded_y_fragment = s->first_coded_c_fragment = 0; s->last_coded_y_fragment = s->last_coded_c_fragment = -1; memset(s->macroblock_coded, 0, s->macroblock_count); for (i = 0; i < s->superblock_count; i++) { /* iterate through all 16 fragments in a superblock */ for (j = 0; j < 16; j++) { /* if the fragment is in bounds, check its coding status */ current_fragment = s->superblock_fragments[i * 16 + j]; if (current_fragment != -1) { if (s->superblock_coding[i] == SB_NOT_CODED) { /* copy all the fragments from the prior frame */ s->all_fragments[current_fragment].coding_method = MODE_COPY; } else if (s->superblock_coding[i] == SB_PARTIALLY_CODED) { /* fragment may or may not be coded; this is the case * that cares about the fragment coding runs */ if (current_run == 0) { bit ^= 1; current_run = get_fragment_run_length(gb); } if (bit) { /* mode will be decoded in the next phase */ s->all_fragments[current_fragment].coding_method = MODE_INTER_NO_MV; s->coded_fragment_list[s->coded_fragment_list_index] = current_fragment; if ((current_fragment >= s->u_fragment_start) && (s->last_coded_y_fragment == -1)) { s->first_coded_c_fragment = s->coded_fragment_list_index; s->last_coded_y_fragment = s->first_coded_c_fragment - 1; } s->coded_fragment_list_index++; s->macroblock_coded[s->all_fragments[current_fragment].macroblock] = 1; debug_block_coding(" superblock %d is partially coded, fragment %d is coded\n", i, current_fragment); } else { /* not coded; copy this fragment from the prior frame */ s->all_fragments[current_fragment].coding_method = MODE_COPY; debug_block_coding(" superblock %d is partially coded, fragment %d is not coded\n", i, current_fragment); } current_run--; } else { /* fragments are fully coded in this superblock; actual * coding will be determined in next step */ s->all_fragments[current_fragment].coding_method = MODE_INTER_NO_MV; s->coded_fragment_list[s->coded_fragment_list_index] = current_fragment; if ((current_fragment >= s->u_fragment_start) && (s->last_coded_y_fragment == -1)) { s->first_coded_c_fragment = s->coded_fragment_list_index; s->last_coded_y_fragment = s->first_coded_c_fragment - 1; } s->coded_fragment_list_index++; s->macroblock_coded[s->all_fragments[current_fragment].macroblock] = 1; debug_block_coding(" superblock %d is fully coded, fragment %d is coded\n", i, current_fragment); } } } } if (s->first_coded_c_fragment == 0) /* no C fragments coded */ s->last_coded_y_fragment = s->coded_fragment_list_index - 1; else s->last_coded_c_fragment = s->coded_fragment_list_index - 1; debug_block_coding(" %d total coded fragments, y: %d -> %d, c: %d -> %d\n", s->coded_fragment_list_index, s->first_coded_y_fragment, s->last_coded_y_fragment, s->first_coded_c_fragment, s->last_coded_c_fragment); }
11,443
0
static int svq1_decode_delta_block(MpegEncContext *s, GetBitContext *bitbuf, uint8_t *current, uint8_t *previous, int pitch, svq1_pmv *motion, int x, int y) { uint32_t block_type; int result = 0; /* get block type */ block_type = get_vlc2(bitbuf, svq1_block_type.table, 2, 2); /* reset motion vectors */ if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) { motion[0].x = motion[0].y = motion[x / 8 + 2].x = motion[x / 8 + 2].y = motion[x / 8 + 3].x = motion[x / 8 + 3].y = 0; } switch (block_type) { case SVQ1_BLOCK_SKIP: svq1_skip_block(current, previous, pitch, x, y); break; case SVQ1_BLOCK_INTER: result = svq1_motion_inter_block(s, bitbuf, current, previous, pitch, motion, x, y); if (result != 0) { av_dlog(s->avctx, "Error in svq1_motion_inter_block %i\n", result); break; } result = svq1_decode_block_non_intra(bitbuf, current, pitch); break; case SVQ1_BLOCK_INTER_4V: result = svq1_motion_inter_4v_block(s, bitbuf, current, previous, pitch, motion, x, y); if (result != 0) { av_dlog(s->avctx, "Error in svq1_motion_inter_4v_block %i\n", result); break; } result = svq1_decode_block_non_intra(bitbuf, current, pitch); break; case SVQ1_BLOCK_INTRA: result = svq1_decode_block_intra(bitbuf, current, pitch); break; } return result; }
11,445
0
int ff_h263_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) { int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant; INT16 *mot_val; static INT8 quant_tab[4] = { -1, -2, 1, 2 }; s->error_status_table[s->mb_x + s->mb_y*s->mb_width]= 0; if(s->mb_x==0) PRINT_MB_TYPE("\n"); if (s->pict_type == P_TYPE || s->pict_type==S_TYPE) { if (get_bits1(&s->gb)) { /* skip mb */ s->mb_intra = 0; for(i=0;i<6;i++) s->block_last_index[i] = -1; s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE){ PRINT_MB_TYPE("G"); s->mcsel=1; s->mv[0][0][0]= get_amv(s, 0); s->mv[0][0][1]= get_amv(s, 1); s->mb_skiped = 0; }else{ PRINT_MB_TYPE("S"); s->mcsel=0; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mb_skiped = 1; } goto end; } cbpc = get_vlc2(&s->gb, inter_MCBPC_vlc.table, INTER_MCBPC_VLC_BITS, 2); //fprintf(stderr, "\tCBPC: %d", cbpc); if (cbpc < 0) return -1; if (cbpc > 20) cbpc+=3; else if (cbpc == 20) fprintf(stderr, "Stuffing !"); dquant = cbpc & 8; s->mb_intra = ((cbpc & 4) != 0); if (s->mb_intra) goto intra; if(s->pict_type==S_TYPE && s->vol_sprite_usage==GMC_SPRITE && (cbpc & 16) == 0) s->mcsel= get_bits1(&s->gb); else s->mcsel= 0; cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); cbp = (cbpc & 3) | ((cbpy ^ 0xf) << 2); if (dquant) { change_qscale(s, quant_tab[get_bits(&s->gb, 2)]); } if((!s->progressive_sequence) && (cbp || (s->workaround_bugs&FF_BUG_XVID_ILACE))) s->interlaced_dct= get_bits1(&s->gb); s->mv_dir = MV_DIR_FORWARD; if ((cbpc & 16) == 0) { if(s->mcsel){ PRINT_MB_TYPE("G"); /* 16x16 global motion prediction */ s->mv_type = MV_TYPE_16X16; mx= get_amv(s, 0); my= get_amv(s, 1); s->mv[0][0][0] = mx; s->mv[0][0][1] = my; }else if((!s->progressive_sequence) && get_bits1(&s->gb)){ PRINT_MB_TYPE("f"); /* 16x8 field motion prediction */ s->mv_type= MV_TYPE_FIELD; s->field_select[0][0]= get_bits1(&s->gb); s->field_select[0][1]= get_bits1(&s->gb); h263_pred_motion(s, 0, &pred_x, &pred_y); for(i=0; i<2; i++){ mx = h263_decode_motion(s, pred_x, s->f_code); if (mx >= 0xffff) return -1; my = h263_decode_motion(s, pred_y/2, s->f_code); if (my >= 0xffff) return -1; s->mv[0][i][0] = mx; s->mv[0][i][1] = my; } }else{ PRINT_MB_TYPE("P"); /* 16x16 motion prediction */ s->mv_type = MV_TYPE_16X16; h263_pred_motion(s, 0, &pred_x, &pred_y); if (s->umvplus_dec) mx = h263p_decode_umotion(s, pred_x); else mx = h263_decode_motion(s, pred_x, s->f_code); if (mx >= 0xffff) return -1; if (s->umvplus_dec) my = h263p_decode_umotion(s, pred_y); else my = h263_decode_motion(s, pred_y, s->f_code); if (my >= 0xffff) return -1; s->mv[0][0][0] = mx; s->mv[0][0][1] = my; if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1) skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */ } } else { PRINT_MB_TYPE("4"); s->mv_type = MV_TYPE_8X8; for(i=0;i<4;i++) { mot_val = h263_pred_motion(s, i, &pred_x, &pred_y); if (s->umvplus_dec) mx = h263p_decode_umotion(s, pred_x); else mx = h263_decode_motion(s, pred_x, s->f_code); if (mx >= 0xffff) return -1; if (s->umvplus_dec) my = h263p_decode_umotion(s, pred_y); else my = h263_decode_motion(s, pred_y, s->f_code); if (my >= 0xffff) return -1; s->mv[0][i][0] = mx; s->mv[0][i][1] = my; if (s->umvplus_dec && (mx - pred_x) == 1 && (my - pred_y) == 1) skip_bits1(&s->gb); /* Bit stuffing to prevent PSC */ mot_val[0] = mx; mot_val[1] = my; } } } else if(s->pict_type==B_TYPE) { int modb1; // first bit of modb int modb2; // second bit of modb int mb_type; int xy; s->mb_intra = 0; //B-frames never contain intra blocks s->mcsel=0; // ... true gmc blocks if(s->mb_x==0){ for(i=0; i<2; i++){ s->last_mv[i][0][0]= s->last_mv[i][0][1]= s->last_mv[i][1][0]= s->last_mv[i][1][1]= 0; } } /* if we skipped it in the future P Frame than skip it now too */ s->mb_skiped= s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x]; // Note, skiptab=0 if last was GMC if(s->mb_skiped){ /* skip mb */ for(i=0;i<6;i++) s->block_last_index[i] = -1; s->mv_dir = MV_DIR_FORWARD; s->mv_type = MV_TYPE_16X16; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->mv[1][0][0] = 0; s->mv[1][0][1] = 0; PRINT_MB_TYPE("s"); goto end; } modb1= get_bits1(&s->gb); if(modb1){ mb_type=4; //like MB_TYPE_B_DIRECT but no vectors coded cbp=0; }else{ int field_mv; modb2= get_bits1(&s->gb); mb_type= get_vlc2(&s->gb, mb_type_b_vlc.table, MB_TYPE_B_VLC_BITS, 1); if(modb2) cbp= 0; else cbp= get_bits(&s->gb, 6); if (mb_type!=MB_TYPE_B_DIRECT && cbp) { if(get_bits1(&s->gb)){ change_qscale(s, get_bits1(&s->gb)*4 - 2); } } field_mv=0; if(!s->progressive_sequence){ if(cbp) s->interlaced_dct= get_bits1(&s->gb); if(mb_type!=MB_TYPE_B_DIRECT && get_bits1(&s->gb)){ field_mv=1; if(mb_type!=MB_TYPE_B_BACKW){ s->field_select[0][0]= get_bits1(&s->gb); s->field_select[0][1]= get_bits1(&s->gb); } if(mb_type!=MB_TYPE_B_FORW){ s->field_select[1][0]= get_bits1(&s->gb); s->field_select[1][1]= get_bits1(&s->gb); } } } s->mv_dir = 0; if(mb_type!=MB_TYPE_B_DIRECT && !field_mv){ s->mv_type= MV_TYPE_16X16; if(mb_type!=MB_TYPE_B_BACKW){ s->mv_dir = MV_DIR_FORWARD; mx = h263_decode_motion(s, s->last_mv[0][0][0], s->f_code); my = h263_decode_motion(s, s->last_mv[0][0][1], s->f_code); s->last_mv[0][1][0]= s->last_mv[0][0][0]= s->mv[0][0][0] = mx; s->last_mv[0][1][1]= s->last_mv[0][0][1]= s->mv[0][0][1] = my; } if(mb_type!=MB_TYPE_B_FORW){ s->mv_dir |= MV_DIR_BACKWARD; mx = h263_decode_motion(s, s->last_mv[1][0][0], s->b_code); my = h263_decode_motion(s, s->last_mv[1][0][1], s->b_code); s->last_mv[1][1][0]= s->last_mv[1][0][0]= s->mv[1][0][0] = mx; s->last_mv[1][1][1]= s->last_mv[1][0][1]= s->mv[1][0][1] = my; } if(mb_type!=MB_TYPE_B_DIRECT) PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "F" : (mb_type==MB_TYPE_B_BACKW ? "B" : "T")); }else if(mb_type!=MB_TYPE_B_DIRECT){ s->mv_type= MV_TYPE_FIELD; if(mb_type!=MB_TYPE_B_BACKW){ s->mv_dir = MV_DIR_FORWARD; for(i=0; i<2; i++){ mx = h263_decode_motion(s, s->last_mv[0][i][0] , s->f_code); my = h263_decode_motion(s, s->last_mv[0][i][1]/2, s->f_code); s->last_mv[0][i][0]= s->mv[0][i][0] = mx; s->last_mv[0][i][1]= (s->mv[0][i][1] = my)*2; } } if(mb_type!=MB_TYPE_B_FORW){ s->mv_dir |= MV_DIR_BACKWARD; for(i=0; i<2; i++){ mx = h263_decode_motion(s, s->last_mv[1][i][0] , s->b_code); my = h263_decode_motion(s, s->last_mv[1][i][1]/2, s->b_code); s->last_mv[1][i][0]= s->mv[1][i][0] = mx; s->last_mv[1][i][1]= (s->mv[1][i][1] = my)*2; } } if(mb_type!=MB_TYPE_B_DIRECT) PRINT_MB_TYPE(mb_type==MB_TYPE_B_FORW ? "f" : (mb_type==MB_TYPE_B_BACKW ? "b" : "t")); } } if(mb_type==4 || mb_type==MB_TYPE_B_DIRECT){ if(mb_type==4) mx=my=0; else{ mx = h263_decode_motion(s, 0, 1); my = h263_decode_motion(s, 0, 1); } s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; ff_mpeg4_set_direct_mv(s, mx, my); } if(mb_type<0 || mb_type>4){ printf("illegal MB_type\n"); return -1; } } else { /* I-Frame */ cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 1); if (cbpc < 0) return -1; dquant = cbpc & 4; s->mb_intra = 1; intra: s->ac_pred = 0; if (s->h263_pred || s->h263_aic) { s->ac_pred = get_bits1(&s->gb); if (s->ac_pred && s->h263_aic) s->h263_aic_dir = get_bits1(&s->gb); } PRINT_MB_TYPE(s->ac_pred ? "A" : "I"); cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1); if(cbpy<0) return -1; cbp = (cbpc & 3) | (cbpy << 2); if (dquant) { change_qscale(s, quant_tab[get_bits(&s->gb, 2)]); } if(!s->progressive_sequence) s->interlaced_dct= get_bits1(&s->gb); /* decode each block */ if (s->h263_pred) { for (i = 0; i < 6; i++) { if (mpeg4_decode_block(s, block[i], i, cbp&32, 1) < 0) return -1; cbp+=cbp; } } else { for (i = 0; i < 6; i++) { if (h263_decode_block(s, block[i], i, cbp&32) < 0) return -1; cbp+=cbp; } } goto end; } /* decode each block */ if (s->h263_pred) { for (i = 0; i < 6; i++) { if (mpeg4_decode_block(s, block[i], i, cbp&32, 0) < 0) return -1; cbp+=cbp; } } else { for (i = 0; i < 6; i++) { if (h263_decode_block(s, block[i], i, cbp&32) < 0) return -1; cbp+=cbp; } } end: /* per-MB end of slice check */ if(s->codec_id==CODEC_ID_MPEG4){ if(mpeg4_is_resync(s)){ if(s->pict_type==B_TYPE && s->next_picture.mbskip_table[s->mb_y * s->mb_width + s->mb_x+1]) return SLICE_OK; return SLICE_END; } }else{ int v= show_bits(&s->gb, 16); if(get_bits_count(&s->gb) + 16 > s->gb.size*8){ v>>= get_bits_count(&s->gb) + 16 - s->gb.size*8; } if(v==0) return SLICE_END; } return SLICE_OK; }
11,447