label
int64
0
1
func1
stringlengths
23
97k
id
int64
0
27.3k
1
static void test_validate_fail_struct(TestInputVisitorData *data, const void *unused) { TestStruct *p = NULL; Error *err = NULL; Visitor *v; v = validate_test_init(data, "{ 'integer': -42, 'boolean': true, 'string': 'foo', 'extra': 42 }"); visit_type_TestStruct(v, &p, NULL, &err); g_assert(err); error_free(err); if (p) { g_free(p->string); } g_free(p); }
17,333
1
static int dv_read_header(AVFormatContext *s, AVFormatParameters *ap) { unsigned state; RawDVContext *c = s->priv_data; c->dv_demux = dv_init_demux(s); if (!c->dv_demux) return -1; state = get_be32(s->pb); while ((state & 0xffffff7f) != 0x1f07003f) { if (url_feof(s->pb)) { av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n"); return -1; } state = (state << 8) | get_byte(s->pb); } AV_WB32(c->buf, state); if (get_buffer(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 || url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) return AVERROR(EIO); c->dv_demux->sys = dv_frame_profile(c->buf); if (!c->dv_demux->sys) { av_log(s, AV_LOG_ERROR, "Can't determine profile of DV input stream.\n"); return -1; } s->bit_rate = av_rescale_q(c->dv_demux->sys->frame_size, (AVRational){8,1}, c->dv_demux->sys->time_base); return 0; }
17,334
1
int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MJpegDecodeContext *s = avctx->priv_data; const uint8_t *buf_end, *buf_ptr; int start_code; AVFrame *picture = data; s->got_picture = 0; // picture from previous image can not be reused buf_ptr = buf; buf_end = buf + buf_size; while (buf_ptr < buf_end) { /* find start next marker */ start_code = find_marker(&buf_ptr, buf_end); { /* EOF */ if (start_code < 0) { goto the_end; } else { av_log(avctx, AV_LOG_DEBUG, "marker=%x avail_size_in_buf=%td\n", start_code, buf_end - buf_ptr); if ((buf_end - buf_ptr) > s->buffer_size) { av_free(s->buffer); s->buffer_size = buf_end-buf_ptr; s->buffer = av_malloc(s->buffer_size + FF_INPUT_BUFFER_PADDING_SIZE); av_log(avctx, AV_LOG_DEBUG, "buffer too small, expanding to %d bytes\n", s->buffer_size); /* unescape buffer of SOS, use special treatment for JPEG-LS */ if (start_code == SOS && !s->ls) { const uint8_t *src = buf_ptr; uint8_t *dst = s->buffer; while (src<buf_end) { uint8_t x = *(src++); *(dst++) = x; if (avctx->codec_id != CODEC_ID_THP) { if (x == 0xff) { while (src < buf_end && x == 0xff) x = *(src++); if (x >= 0xd0 && x <= 0xd7) *(dst++) = x; else if (x) init_get_bits(&s->gb, s->buffer, (dst - s->buffer)*8); av_log(avctx, AV_LOG_DEBUG, "escaping removed %td bytes\n", (buf_end - buf_ptr) - (dst - s->buffer)); else if(start_code == SOS && s->ls){ const uint8_t *src = buf_ptr; uint8_t *dst = s->buffer; int bit_count = 0; int t = 0, b = 0; PutBitContext pb; s->cur_scan++; /* find marker */ while (src + t < buf_end){ uint8_t x = src[t++]; if (x == 0xff){ while((src + t < buf_end) && x == 0xff) x = src[t++]; if (x & 0x80) { t -= 2; bit_count = t * 8; init_put_bits(&pb, dst, t); /* unescape bitstream */ while(b < t){ uint8_t x = src[b++]; put_bits(&pb, 8, x); if(x == 0xFF){ x = src[b++]; put_bits(&pb, 7, x); bit_count--; flush_put_bits(&pb); init_get_bits(&s->gb, dst, bit_count); else init_get_bits(&s->gb, buf_ptr, (buf_end - buf_ptr)*8); s->start_code = start_code; if(s->avctx->debug & FF_DEBUG_STARTCODE){ av_log(avctx, AV_LOG_DEBUG, "startcode: %X\n", start_code); /* process markers */ if (start_code >= 0xd0 && start_code <= 0xd7) { av_log(avctx, AV_LOG_DEBUG, "restart marker: %d\n", start_code&0x0f); /* APP fields */ } else if (start_code >= APP0 && start_code <= APP15) { mjpeg_decode_app(s); /* Comment */ } else if (start_code == COM){ mjpeg_decode_com(s); switch(start_code) { case SOI: s->restart_interval = 0; s->restart_count = 0; /* nothing to do on SOI */ case DQT: ff_mjpeg_decode_dqt(s); case DHT: if(ff_mjpeg_decode_dht(s) < 0){ av_log(avctx, AV_LOG_ERROR, "huffman table decode error\n"); return -1; case SOF0: s->lossless=0; s->ls=0; s->progressive=0; if (ff_mjpeg_decode_sof(s) < 0) return -1; case SOF2: s->lossless=0; s->ls=0; s->progressive=1; if (ff_mjpeg_decode_sof(s) < 0) return -1; case SOF3: s->lossless=1; s->ls=0; s->progressive=0; if (ff_mjpeg_decode_sof(s) < 0) return -1; case SOF48: s->lossless=1; s->ls=1; s->progressive=0; if (ff_mjpeg_decode_sof(s) < 0) return -1; case LSE: if (!CONFIG_JPEGLS_DECODER || ff_jpegls_decode_lse(s) < 0) return -1; case EOI: s->cur_scan = 0; if ((s->buggy_avid && !s->interlaced) || s->restart_interval) eoi_parser: av_log(avctx, AV_LOG_WARNING, "Found EOI before any SOF, ignoring\n"); { if (s->interlaced) { s->bottom_field ^= 1; /* if not bottom field, do not output image yet */ if (s->bottom_field == !s->interlace_polarity) goto not_the_end; *picture = s->picture; *data_size = sizeof(AVFrame); if(!s->lossless){ picture->quality= FFMAX3(s->qscale[0], s->qscale[1], s->qscale[2]); picture->qstride= 0; picture->qscale_table= s->qscale_table; memset(picture->qscale_table, picture->quality, (s->width+15)/16); if(avctx->debug & FF_DEBUG_QP) av_log(avctx, AV_LOG_DEBUG, "QP: %d\n", picture->quality); picture->quality*= FF_QP2LAMBDA; goto the_end; case SOS: ff_mjpeg_decode_sos(s); /* buggy avid puts EOI every 10-20th frame */ /* if restart period is over process EOI */ if ((s->buggy_avid && !s->interlaced) || s->restart_interval) goto eoi_parser; case DRI: mjpeg_decode_dri(s); case SOF1: case SOF5: case SOF6: case SOF7: case SOF9: case SOF10: case SOF11: case SOF13: case SOF14: case SOF15: case JPG: av_log(avctx, AV_LOG_ERROR, "mjpeg: unsupported coding type (%x)\n", start_code); // default: // printf("mjpeg: unsupported marker (%x)\n", start_code); // break; not_the_end: /* eof process start code */ buf_ptr += (get_bits_count(&s->gb)+7)/8; av_log(avctx, AV_LOG_DEBUG, "marker parser used %d bytes (%d bits)\n", (get_bits_count(&s->gb)+7)/8, get_bits_count(&s->gb)); the_end: av_log(avctx, AV_LOG_DEBUG, "mjpeg decode frame unused %td bytes\n", buf_end - buf_ptr); // return buf_end - buf_ptr; return buf_ptr - buf;
17,335
1
static int raw_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { if (check_write_unsafe(bs, sector_num, buf, nb_sectors)) { int ret; ret = raw_write_scrubbed_bootsect(bs, buf); if (ret < 0) { return ret; } ret = bdrv_write(bs->file, 1, buf + 512, nb_sectors - 1); if (ret < 0) { return ret; } return ret + 512; } return bdrv_write(bs->file, sector_num, buf, nb_sectors); }
17,339
1
void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component) { AVComponentDescriptor comp= desc->comp[c]; int plane= comp.plane; int depth= comp.depth_minus1+1; int mask = (1<<depth)-1; int shift= comp.shift; int step = comp.step_minus1+1; int flags= desc->flags; if (flags & PIX_FMT_BITSTREAM){ int skip = x*step + comp.offset_plus1-1; const uint8_t *p = data[plane] + y*linesize[plane] + (skip>>3); int shift = 8 - depth - (skip&7); while(w--){ int val = (*p >> shift) & mask; if(read_pal_component) val= data[1][4*val + c]; shift -= step; p -= shift>>3; shift &= 7; *dst++= val; } } else { const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1; while(w--){ int val = flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p); val = (val>>shift) & mask; if(read_pal_component) val= data[1][4*val + c]; p+= step; *dst++= val; } } }
17,340
1
void set_system_io_map(MemoryRegion *mr) { memory_region_transaction_begin(); address_space_io.root = mr; memory_region_transaction_commit(); }
17,342
0
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags) { BufferSinkContext *buf = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; int ret; AVFrame *cur_frame; /* no picref available, fetch it from the filterchain */ if (!av_fifo_size(buf->fifo)) { if (inlink->closed) return AVERROR_EOF; if (flags & AV_BUFFERSINK_FLAG_NO_REQUEST) return AVERROR(EAGAIN); if ((ret = ff_request_frame(inlink)) < 0) return ret; } if (!av_fifo_size(buf->fifo)) return AVERROR(EINVAL); if (flags & AV_BUFFERSINK_FLAG_PEEK) { cur_frame = *((AVFrame **)av_fifo_peek2(buf->fifo, 0)); if ((ret = av_frame_ref(frame, cur_frame)) < 0) return ret; } else { av_fifo_generic_read(buf->fifo, &cur_frame, sizeof(cur_frame), NULL); av_frame_move_ref(frame, cur_frame); av_frame_free(&cur_frame); } return 0; }
17,343
1
static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) { union { float f; uint32_t u; } value; int sign; int exp = s->float_max_exp; if (s->got_extra_bits) { const int max_bits = 1 + 23 + 8 + 1; const int left_bits = get_bits_left(&s->gb_extra_bits); if (left_bits + 8 * FF_INPUT_BUFFER_PADDING_SIZE < max_bits) return 0.0; } if (S) { S <<= s->float_shift; sign = S < 0; if (sign) S = -S; if (S >= 0x1000000) { if (s->got_extra_bits && get_bits1(&s->gb_extra_bits)) S = get_bits(&s->gb_extra_bits, 23); else S = 0; exp = 255; } else if (exp) { int shift = 23 - av_log2(S); exp = s->float_max_exp; if (exp <= shift) shift = --exp; exp -= shift; if (shift) { S <<= shift; if ((s->float_flag & WV_FLT_SHIFT_ONES) || (s->got_extra_bits && (s->float_flag & WV_FLT_SHIFT_SAME) && get_bits1(&s->gb_extra_bits))) { S |= (1 << shift) - 1; } else if (s->got_extra_bits && (s->float_flag & WV_FLT_SHIFT_SENT)) { S |= get_bits(&s->gb_extra_bits, shift); } } } else { exp = s->float_max_exp; } S &= 0x7fffff; } else { sign = 0; exp = 0; if (s->got_extra_bits && (s->float_flag & WV_FLT_ZERO_SENT)) { if (get_bits1(&s->gb_extra_bits)) { S = get_bits(&s->gb_extra_bits, 23); if (s->float_max_exp >= 25) exp = get_bits(&s->gb_extra_bits, 8); sign = get_bits1(&s->gb_extra_bits); } else { if (s->float_flag & WV_FLT_ZERO_SIGN) sign = get_bits1(&s->gb_extra_bits); } } } *crc = *crc * 27 + S * 9 + exp * 3 + sign; value.u = (sign << 31) | (exp << 23) | S; return value.f; }
17,344
1
static gboolean ga_channel_open(GAChannel *c, const gchar *path, GAChannelMethod method) { int ret; c->method = method; switch (c->method) { case GA_CHANNEL_VIRTIO_SERIAL: { int fd = qemu_open(path, O_RDWR | O_NONBLOCK #ifndef CONFIG_SOLARIS | O_ASYNC #endif ); if (fd == -1) { g_critical("error opening channel: %s", strerror(errno)); exit(EXIT_FAILURE); } #ifdef CONFIG_SOLARIS ret = ioctl(fd, I_SETSIG, S_OUTPUT | S_INPUT | S_HIPRI); if (ret == -1) { g_critical("error setting event mask for channel: %s", strerror(errno)); exit(EXIT_FAILURE); } #endif ret = ga_channel_client_add(c, fd); if (ret) { g_critical("error adding channel to main loop"); return false; } break; } case GA_CHANNEL_ISA_SERIAL: { struct termios tio; int fd = qemu_open(path, O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd == -1) { g_critical("error opening channel: %s", strerror(errno)); exit(EXIT_FAILURE); } tcgetattr(fd, &tio); /* set up serial port for non-canonical, dumb byte streaming */ tio.c_iflag &= ~(IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK | ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXOFF | IXANY | IMAXBEL); tio.c_oflag = 0; tio.c_lflag = 0; tio.c_cflag |= GA_CHANNEL_BAUDRATE_DEFAULT; /* 1 available byte min or reads will block (we'll set non-blocking * elsewhere, else we have to deal with read()=0 instead) */ tio.c_cc[VMIN] = 1; tio.c_cc[VTIME] = 0; /* flush everything waiting for read/xmit, it's garbage at this point */ tcflush(fd, TCIFLUSH); tcsetattr(fd, TCSANOW, &tio); ret = ga_channel_client_add(c, fd); if (ret) { g_error("error adding channel to main loop"); } break; } case GA_CHANNEL_UNIX_LISTEN: { Error *local_err = NULL; int fd = unix_listen(path, NULL, strlen(path), &local_err); if (local_err != NULL) { g_critical("%s", error_get_pretty(local_err)); error_free(local_err); return false; } ga_channel_listen_add(c, fd, true); break; } default: g_critical("error binding/listening to specified socket"); return false; } return true; }
17,345
1
static void init_qxl_rom(PCIQXLDevice *d) { QXLRom *rom = memory_region_get_ram_ptr(&d->rom_bar); QXLModes *modes = (QXLModes *)(rom + 1); uint32_t ram_header_size; uint32_t surface0_area_size; uint32_t num_pages; uint32_t fb, maxfb = 0; int i; memset(rom, 0, d->rom_size); rom->magic = cpu_to_le32(QXL_ROM_MAGIC); rom->id = cpu_to_le32(d->id); rom->log_level = cpu_to_le32(d->guestdebug); rom->modes_offset = cpu_to_le32(sizeof(QXLRom)); rom->slot_gen_bits = MEMSLOT_GENERATION_BITS; rom->slot_id_bits = MEMSLOT_SLOT_BITS; rom->slots_start = 1; rom->slots_end = NUM_MEMSLOTS - 1; rom->n_surfaces = cpu_to_le32(NUM_SURFACES); modes->n_modes = cpu_to_le32(ARRAY_SIZE(qxl_modes)); for (i = 0; i < modes->n_modes; i++) { fb = qxl_modes[i].y_res * qxl_modes[i].stride; if (maxfb < fb) { maxfb = fb; } modes->modes[i].id = cpu_to_le32(i); modes->modes[i].x_res = cpu_to_le32(qxl_modes[i].x_res); modes->modes[i].y_res = cpu_to_le32(qxl_modes[i].y_res); modes->modes[i].bits = cpu_to_le32(qxl_modes[i].bits); modes->modes[i].stride = cpu_to_le32(qxl_modes[i].stride); modes->modes[i].x_mili = cpu_to_le32(qxl_modes[i].x_mili); modes->modes[i].y_mili = cpu_to_le32(qxl_modes[i].y_mili); modes->modes[i].orientation = cpu_to_le32(qxl_modes[i].orientation); } if (maxfb < VGA_RAM_SIZE && d->id == 0) maxfb = VGA_RAM_SIZE; ram_header_size = ALIGN(sizeof(QXLRam), 4096); surface0_area_size = ALIGN(maxfb, 4096); num_pages = d->vga.vram_size; num_pages -= ram_header_size; num_pages -= surface0_area_size; num_pages = num_pages / TARGET_PAGE_SIZE; rom->draw_area_offset = cpu_to_le32(0); rom->surface0_area_size = cpu_to_le32(surface0_area_size); rom->pages_offset = cpu_to_le32(surface0_area_size); rom->num_pages = cpu_to_le32(num_pages); rom->ram_header_offset = cpu_to_le32(d->vga.vram_size - ram_header_size); d->shadow_rom = *rom; d->rom = rom; d->modes = modes; }
17,346
1
roundAndPackFloat128( flag zSign, int32 zExp, uint64_t zSig0, uint64_t zSig1, uint64_t zSig2 STATUS_PARAM) { int8 roundingMode; flag roundNearestEven, increment, isTiny; roundingMode = STATUS(float_rounding_mode); roundNearestEven = ( roundingMode == float_round_nearest_even ); increment = ( (int64_t) zSig2 < 0 ); if ( ! roundNearestEven ) { if ( roundingMode == float_round_to_zero ) { increment = 0; } else { if ( zSign ) { increment = ( roundingMode == float_round_down ) && zSig2; } else { increment = ( roundingMode == float_round_up ) && zSig2; } } } if ( 0x7FFD <= (uint32_t) zExp ) { if ( ( 0x7FFD < zExp ) || ( ( zExp == 0x7FFD ) && eq128( LIT64( 0x0001FFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFFFF ), zSig0, zSig1 ) && increment ) ) { float_raise( float_flag_overflow | float_flag_inexact STATUS_VAR); if ( ( roundingMode == float_round_to_zero ) || ( zSign && ( roundingMode == float_round_up ) ) || ( ! zSign && ( roundingMode == float_round_down ) ) ) { return packFloat128( zSign, 0x7FFE, LIT64( 0x0000FFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFFFF ) ); } return packFloat128( zSign, 0x7FFF, 0, 0 ); } if ( zExp < 0 ) { if ( STATUS(flush_to_zero) ) return packFloat128( zSign, 0, 0, 0 ); isTiny = ( STATUS(float_detect_tininess) == float_tininess_before_rounding ) || ( zExp < -1 ) || ! increment || lt128( zSig0, zSig1, LIT64( 0x0001FFFFFFFFFFFF ), LIT64( 0xFFFFFFFFFFFFFFFF ) ); shift128ExtraRightJamming( zSig0, zSig1, zSig2, - zExp, &zSig0, &zSig1, &zSig2 ); zExp = 0; if ( isTiny && zSig2 ) float_raise( float_flag_underflow STATUS_VAR); if ( roundNearestEven ) { increment = ( (int64_t) zSig2 < 0 ); } else { if ( zSign ) { increment = ( roundingMode == float_round_down ) && zSig2; } else { increment = ( roundingMode == float_round_up ) && zSig2; } } } } if ( zSig2 ) STATUS(float_exception_flags) |= float_flag_inexact; if ( increment ) { add128( zSig0, zSig1, 0, 1, &zSig0, &zSig1 ); zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven ); } else { if ( ( zSig0 | zSig1 ) == 0 ) zExp = 0; } return packFloat128( zSign, zExp, zSig0, zSig1 ); }
17,347
1
static inline void RENAME(yvu9toyv12)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned int width, unsigned int height, int lumStride, int chromStride) { /* Y Plane */ memcpy(ydst, ysrc, width*height); /* XXX: implement upscaling for U,V */ }
17,348
1
int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block, int n, int coded, const uint8_t *scan_table) { int level, i, last, run, run_diff; int dc_pred_dir; RLTable *rl; RL_VLC_ELEM *rl_vlc; int qmul, qadd; if (s->mb_intra) { qmul=1; qadd=0; /* DC coef */ level = msmpeg4_decode_dc(s, n, &dc_pred_dir); if (level < 0){ av_log(s->avctx, AV_LOG_ERROR, "dc overflow- block: %d qscale: %d//\n", n, s->qscale); if(s->inter_intra_pred) level=0; else return -1; } if (n < 4) { rl = &rl_table[s->rl_table_index]; if(level > 256*s->y_dc_scale){ av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ L qscale: %d//\n", s->qscale); if(!s->inter_intra_pred) return -1; } } else { rl = &rl_table[3 + s->rl_chroma_table_index]; if(level > 256*s->c_dc_scale){ av_log(s->avctx, AV_LOG_ERROR, "dc overflow+ C qscale: %d//\n", s->qscale); if(!s->inter_intra_pred) return -1; } } block[0] = level; run_diff = s->msmpeg4_version >= 4; i = 0; if (!coded) { goto not_coded; } if (s->ac_pred) { if (dc_pred_dir == 0) scan_table = s->intra_v_scantable.permutated; /* left */ else scan_table = s->intra_h_scantable.permutated; /* top */ } else { scan_table = s->intra_scantable.permutated; } rl_vlc= rl->rl_vlc[0]; } else { qmul = s->qscale << 1; qadd = (s->qscale - 1) | 1; i = -1; rl = &rl_table[3 + s->rl_table_index]; if(s->msmpeg4_version==2) run_diff = 0; else run_diff = 1; if (!coded) { s->block_last_index[n] = i; return 0; } if(!scan_table) scan_table = s->inter_scantable.permutated; rl_vlc= rl->rl_vlc[s->qscale]; } { OPEN_READER(re, &s->gb); for(;;) { UPDATE_CACHE(re, &s->gb); GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 0); if (level==0) { int cache; cache= GET_CACHE(re, &s->gb); /* escape */ if (s->msmpeg4_version==1 || (cache&0x80000000)==0) { if (s->msmpeg4_version==1 || (cache&0x40000000)==0) { /* third escape */ if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); if(s->msmpeg4_version<=3){ last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1); run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6); level= SHOW_SBITS(re, &s->gb, 8); LAST_SKIP_CACHE(re, &s->gb, 8); SKIP_COUNTER(re, &s->gb, 1+6+8); }else{ int sign; last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1); if(!s->esc3_level_length){ int ll; //printf("ESC-3 %X at %d %d\n", show_bits(&s->gb, 24), s->mb_x, s->mb_y); if(s->qscale<8){ ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3); if(ll==0){ if(SHOW_UBITS(re, &s->gb, 1)) av_log(s->avctx, AV_LOG_ERROR, "cool a new vlc code ,contact the ffmpeg developers and upload the file\n"); SKIP_BITS(re, &s->gb, 1); ll=8; } }else{ ll=2; while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){ ll++; SKIP_BITS(re, &s->gb, 1); } if(ll<8) SKIP_BITS(re, &s->gb, 1); } s->esc3_level_length= ll; s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2); //printf("level length:%d, run length: %d\n", ll, s->esc3_run_length); UPDATE_CACHE(re, &s->gb); } run= SHOW_UBITS(re, &s->gb, s->esc3_run_length); SKIP_BITS(re, &s->gb, s->esc3_run_length); sign= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1); level= SHOW_UBITS(re, &s->gb, s->esc3_level_length); SKIP_BITS(re, &s->gb, s->esc3_level_length); if(sign) level= -level; } //printf("level: %d, run: %d at %d %d\n", level, run, s->mb_x, s->mb_y); #if 0 // waste of time / this will detect very few errors { const int abs_level= FFABS(level); const int run1= run - rl->max_run[last][abs_level] - run_diff; if(abs_level<=MAX_LEVEL && run<=MAX_RUN){ if(abs_level <= rl->max_level[last][run]){ av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, vlc encoding possible\n"); return DECODING_AC_LOST; } if(abs_level <= rl->max_level[last][run]*2){ av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 1 encoding possible\n"); return DECODING_AC_LOST; } if(run1>=0 && abs_level <= rl->max_level[last][run1]){ av_log(s->avctx, AV_LOG_ERROR, "illegal 3. esc, esc 2 encoding possible\n"); return DECODING_AC_LOST; } } } #endif //level = level * qmul + (level>0) * qadd - (level<=0) * qadd ; if (level>0) level= level * qmul + qadd; else level= level * qmul - qadd; #if 0 // waste of time too :( if(level>2048 || level<-2048){ av_log(s->avctx, AV_LOG_ERROR, "|level| overflow in 3. esc\n"); return DECODING_AC_LOST; } #endif i+= run + 1; if(last) i+=192; #ifdef ERROR_DETAILS if(run==66) av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC3 level=%d\n", level); else if((i>62 && i<192) || i>192+63) av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level); #endif } else { /* second escape */ #if MIN_CACHE_BITS < 23 LAST_SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); #else SKIP_BITS(re, &s->gb, 2); #endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1); i+= run + rl->max_run[run>>7][level/qmul] + run_diff; //FIXME opt indexing level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); #ifdef ERROR_DETAILS if(run==66) av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC2 level=%d\n", level); else if((i>62 && i<192) || i>192+63) av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level); #endif } } else { /* first escape */ #if MIN_CACHE_BITS < 22 LAST_SKIP_BITS(re, &s->gb, 1); UPDATE_CACHE(re, &s->gb); #else SKIP_BITS(re, &s->gb, 1); #endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2, 1); i+= run; level = level + rl->max_level[run>>7][(run-1)&63] * qmul;//FIXME opt indexing level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); #ifdef ERROR_DETAILS if(run==66) av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code in ESC1 level=%d\n", level); else if((i>62 && i<192) || i>192+63) av_log(s->avctx, AV_LOG_ERROR, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level); #endif } } else { i+= run; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); #ifdef ERROR_DETAILS if(run==66) av_log(s->avctx, AV_LOG_ERROR, "illegal vlc code level=%d\n", level); else if((i>62 && i<192) || i>192+63) av_log(s->avctx, AV_LOG_ERROR, "run overflow i=%d run=%d level=%d\n", i, run, level); #endif } if (i > 62){ i-= 192; if(i&(~63)){ const int left= s->gb.size_in_bits - get_bits_count(&s->gb); if(((i+192 == 64 && level/qmul==-1) || s->error_recognition<=1) && left>=0){ av_log(s->avctx, AV_LOG_ERROR, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y); break; }else{ av_log(s->avctx, AV_LOG_ERROR, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y); return -1; } } block[scan_table[i]] = level; break; } block[scan_table[i]] = level; } CLOSE_READER(re, &s->gb); } not_coded: if (s->mb_intra) { mpeg4_pred_ac(s, block, n, dc_pred_dir); if (s->ac_pred) { i = 63; /* XXX: not optimal */ } } if(s->msmpeg4_version>=4 && i>0) i=63; //FIXME/XXX optimize s->block_last_index[n] = i; return 0; }
17,349
1
static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, AVSubtitleRect *r) { uint32_t *pal, *dst2; uint8_t *src, *src2; int x, y; if (r->type != SUBTITLE_BITMAP) { av_log(NULL, AV_LOG_WARNING, "sub2video: non-bitmap subtitle\n"); return; } if (r->x < 0 || r->x + r->w > w || r->y < 0 || r->y + r->h > h) { av_log(NULL, AV_LOG_WARNING, "sub2video: rectangle overflowing\n"); return; } dst += r->y * dst_linesize + r->x * 4; src = r->pict.data[0]; pal = (uint32_t *)r->pict.data[1]; for (y = 0; y < r->h; y++) { dst2 = (uint32_t *)dst; src2 = src; for (x = 0; x < r->w; x++) *(dst2++) = pal[*(src2++)]; dst += dst_linesize; src += r->pict.linesize[0]; } }
17,351
1
SchroVideoFormatEnum ff_get_schro_video_format_preset(AVCodecContext *avctx) { unsigned int num_formats = sizeof(ff_schro_video_formats) / sizeof(ff_schro_video_formats[0]); unsigned int idx = get_video_format_idx(avctx); return (idx < num_formats) ? ff_schro_video_formats[idx] : SCHRO_VIDEO_FORMAT_CUSTOM; }
17,352
1
void qemu_console_copy(QemuConsole *con, int src_x, int src_y, int dst_x, int dst_y, int w, int h) { assert(con->console_type == GRAPHIC_CONSOLE); dpy_gfx_copy(con, src_x, src_y, dst_x, dst_y, w, h); }
17,354
0
static int aac_adtstoasc_init(AVBSFContext *ctx) { av_freep(&ctx->par_out->extradata); ctx->par_out->extradata_size = 0; return 0; }
17,356
1
static int dmg_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVDMGState *s = bs->opaque; uint64_t info_begin, info_end, last_in_offset, last_out_offset; uint32_t count, tmp; uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i; int64_t offset; int ret; bs->read_only = 1; s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; /* read offset of info blocks */ offset = bdrv_getlength(bs->file); if (offset < 0) { ret = offset; goto fail; } offset -= 0x1d8; ret = read_uint64(bs, offset, &info_begin); if (ret < 0) { goto fail; } else if (info_begin == 0) { ret = -EINVAL; goto fail; } ret = read_uint32(bs, info_begin, &tmp); if (ret < 0) { goto fail; } else if (tmp != 0x100) { ret = -EINVAL; goto fail; } ret = read_uint32(bs, info_begin + 4, &count); if (ret < 0) { goto fail; } else if (count == 0) { ret = -EINVAL; goto fail; } info_end = info_begin + count; offset = info_begin + 0x100; /* read offsets */ last_in_offset = last_out_offset = 0; while (offset < info_end) { uint32_t type; ret = read_uint32(bs, offset, &count); if (ret < 0) { goto fail; } else if (count == 0) { ret = -EINVAL; goto fail; } offset += 4; ret = read_uint32(bs, offset, &type); if (ret < 0) { goto fail; } if (type == 0x6d697368 && count >= 244) { size_t new_size; uint32_t chunk_count; offset += 4; offset += 200; chunk_count = (count - 204) / 40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); s->types = g_realloc(s->types, new_size / 2); s->offsets = g_realloc(s->offsets, new_size); s->lengths = g_realloc(s->lengths, new_size); s->sectors = g_realloc(s->sectors, new_size); s->sectorcounts = g_realloc(s->sectorcounts, new_size); for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) { ret = read_uint32(bs, offset, &s->types[i]); if (ret < 0) { goto fail; } offset += 4; if (s->types[i] != 0x80000005 && s->types[i] != 1 && s->types[i] != 2) { if (s->types[i] == 0xffffffff && i > 0) { last_in_offset = s->offsets[i - 1] + s->lengths[i - 1]; last_out_offset = s->sectors[i - 1] + s->sectorcounts[i - 1]; } chunk_count--; i--; offset += 36; continue; } offset += 4; ret = read_uint64(bs, offset, &s->sectors[i]); if (ret < 0) { goto fail; } s->sectors[i] += last_out_offset; offset += 8; ret = read_uint64(bs, offset, &s->sectorcounts[i]); if (ret < 0) { goto fail; } offset += 8; if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { error_report("sector count %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); ret = -EINVAL; goto fail; } ret = read_uint64(bs, offset, &s->offsets[i]); if (ret < 0) { goto fail; } s->offsets[i] += last_in_offset; offset += 8; ret = read_uint64(bs, offset, &s->lengths[i]); if (ret < 0) { goto fail; } offset += 8; if (s->lengths[i] > DMG_LENGTHS_MAX) { error_report("length %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->lengths[i], i, DMG_LENGTHS_MAX); ret = -EINVAL; goto fail; } update_max_chunk_size(s, i, &max_compressed_size, &max_sectors_per_chunk); } s->n_chunks += chunk_count; } } /* initialize zlib engine */ s->compressed_chunk = qemu_try_blockalign(bs->file, max_compressed_size + 1); s->uncompressed_chunk = qemu_try_blockalign(bs->file, 512 * max_sectors_per_chunk); if (s->compressed_chunk == NULL || s->uncompressed_chunk == NULL) { ret = -ENOMEM; goto fail; } if (inflateInit(&s->zstream) != Z_OK) { ret = -EINVAL; goto fail; } s->current_chunk = s->n_chunks; qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->types); g_free(s->offsets); g_free(s->lengths); g_free(s->sectors); g_free(s->sectorcounts); qemu_vfree(s->compressed_chunk); qemu_vfree(s->uncompressed_chunk); return ret; }
17,359
1
static int ea_read_header(AVFormatContext *s) { EaDemuxContext *ea = s->priv_data; AVStream *st; if (process_ea_header(s)<=0) return AVERROR(EIO); if (init_video_stream(s, &ea->video) || init_video_stream(s, &ea->alpha)) return AVERROR(ENOMEM); if (ea->audio_codec) { if (ea->num_channels <= 0 || ea->num_channels > 2) { av_log(s, AV_LOG_WARNING, "Unsupported number of channels: %d\n", ea->num_channels); ea->audio_codec = 0; return 1; } if (ea->sample_rate <= 0) { av_log(s, AV_LOG_ERROR, "Unsupported sample rate: %d\n", ea->sample_rate); ea->audio_codec = 0; return 1; } if (ea->bytes <= 0) { av_log(s, AV_LOG_ERROR, "Invalid number of bytes per sample: %d\n", ea->bytes); ea->audio_codec = AV_CODEC_ID_NONE; return 1; } /* initialize the audio decoder stream */ st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 33, 1, ea->sample_rate); st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_id = ea->audio_codec; st->codecpar->codec_tag = 0; /* no tag */ st->codecpar->channels = ea->num_channels; st->codecpar->sample_rate = ea->sample_rate; st->codecpar->bits_per_coded_sample = ea->bytes * 8; st->codecpar->bit_rate = (int64_t)st->codecpar->channels * st->codecpar->sample_rate * st->codecpar->bits_per_coded_sample / 4; st->codecpar->block_align = st->codecpar->channels * st->codecpar->bits_per_coded_sample; ea->audio_stream_index = st->index; st->start_time = 0; } return 1; }
17,360
1
static void armv7m_bitband_init(void) { DeviceState *dev; dev = qdev_create(NULL, "ARM,bitband-memory"); qdev_prop_set_uint32(dev, "base", 0x20000000); qdev_init(dev); sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0x22000000); dev = qdev_create(NULL, "ARM,bitband-memory"); qdev_prop_set_uint32(dev, "base", 0x40000000); qdev_init(dev); sysbus_mmio_map(sysbus_from_qdev(dev), 0, 0x42000000); }
17,361
1
static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len) { unsigned int crc; unsigned char packet[TS_PACKET_SIZE]; const unsigned char *buf_ptr; unsigned char *q; int first, b, len1, left; crc = av_bswap32(av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, buf, len - 4)); buf[len - 4] = (crc >> 24) & 0xff; buf[len - 3] = (crc >> 16) & 0xff; buf[len - 2] = (crc >> 8) & 0xff; buf[len - 1] = crc & 0xff; /* send each packet */ buf_ptr = buf; while (len > 0) { first = buf == buf_ptr; q = packet; *q++ = 0x47; b = s->pid >> 8; if (first) b |= 0x40; *q++ = b; *q++ = s->pid; s->cc = s->cc + 1 & 0xf; *q++ = 0x10 | s->cc; if (first) *q++ = 0; /* 0 offset */ len1 = TS_PACKET_SIZE - (q - packet); if (len1 > len) len1 = len; memcpy(q, buf_ptr, len1); q += len1; /* add known padding data */ left = TS_PACKET_SIZE - (q - packet); if (left > 0) memset(q, 0xff, left); s->write_packet(s, packet); buf_ptr += len1; len -= len1;
17,363
1
void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name) { memory_region_transaction_begin(); as->root = root; as->current_map = g_new(FlatView, 1); flatview_init(as->current_map); as->ioeventfd_nb = 0; as->ioeventfds = NULL; QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link); as->name = g_strdup(name ? name : "anonymous"); address_space_init_dispatch(as); memory_region_update_pending |= root->enabled; memory_region_transaction_commit(); }
17,364
1
static gboolean fd_trampoline(GIOChannel *chan, GIOCondition cond, gpointer opaque) { IOTrampoline *tramp = opaque; if (tramp->opaque == NULL) { return FALSE; } if ((cond & G_IO_IN) && tramp->fd_read) { tramp->fd_read(tramp->opaque); } if ((cond & G_IO_OUT) && tramp->fd_write) { tramp->fd_write(tramp->opaque); } return TRUE; }
17,365
1
static void test_flush_event_notifier(void) { EventNotifierTestData data = { .n = 0, .active = 10, .auto_set = true }; event_notifier_init(&data.e, false); aio_set_event_notifier(ctx, &data.e, event_ready_cb, event_active_cb); g_assert(aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 0); g_assert_cmpint(data.active, ==, 10); event_notifier_set(&data.e); g_assert(aio_poll(ctx, false)); g_assert_cmpint(data.n, ==, 1); g_assert_cmpint(data.active, ==, 9); g_assert(aio_poll(ctx, false)); wait_for_aio(); g_assert_cmpint(data.n, ==, 10); g_assert_cmpint(data.active, ==, 0); g_assert(!aio_poll(ctx, false)); aio_set_event_notifier(ctx, &data.e, NULL, NULL); g_assert(!aio_poll(ctx, false)); event_notifier_cleanup(&data.e); }
17,366
1
static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t *data, size_t len) { char *mechname = malloc(len + 1); if (!mechname) { VNC_DEBUG("Out of memory reading mechname\n"); vnc_client_error(vs); } strncpy(mechname, (char*)data, len); mechname[len] = '\0'; VNC_DEBUG("Got client mechname '%s' check against '%s'\n", mechname, vs->sasl.mechlist); if (strncmp(vs->sasl.mechlist, mechname, len) == 0) { if (vs->sasl.mechlist[len] != '\0' && vs->sasl.mechlist[len] != ',') { VNC_DEBUG("One %d", vs->sasl.mechlist[len]); vnc_client_error(vs); return -1; } } else { char *offset = strstr(vs->sasl.mechlist, mechname); VNC_DEBUG("Two %p\n", offset); if (!offset) { vnc_client_error(vs); return -1; } VNC_DEBUG("Two '%s'\n", offset); if (offset[-1] != ',' || (offset[len] != '\0'&& offset[len] != ',')) { vnc_client_error(vs); return -1; } } free(vs->sasl.mechlist); vs->sasl.mechlist = mechname; VNC_DEBUG("Validated mechname '%s'\n", mechname); vnc_read_when(vs, protocol_client_auth_sasl_start_len, 4); return 0; }
17,368
1
static void qxl_send_events(PCIQXLDevice *d, uint32_t events) { uint32_t old_pending; uint32_t le_events = cpu_to_le32(events); trace_qxl_send_events(d->id, events); assert(qemu_spice_display_is_running(&d->ssd)); old_pending = __sync_fetch_and_or(&d->ram->int_pending, le_events); if ((old_pending & le_events) == le_events) { return; } if (qemu_thread_is_self(&d->main)) { qxl_update_irq(d); } else { if (write(d->pipe[1], d, 1) != 1) { dprint(d, 1, "%s: write to pipe failed\n", __func__); } } }
17,369
1
static void decode_blocks(SnowContext *s){ int x, y; int w= s->b_width; int h= s->b_height; for(y=0; y<h; y++){ for(x=0; x<w; x++){ decode_q_branch(s, 0, x, y); } } }
17,371
1
static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) { VideoData *s = s1->priv_data; int ret, first_index, last_index; char buf[1024]; ByteIOContext pb1, *f = &pb1; AVStream *st; st = av_new_stream(s1, 0); if (!st) { av_free(s); return -ENOMEM; } if (ap->image_format) s->img_fmt = ap->image_format; pstrcpy(s->path, sizeof(s->path), s1->filename); s->img_number = 0; s->img_count = 0; /* find format */ if (s1->iformat->flags & AVFMT_NOFILE) s->is_pipe = 0; else s->is_pipe = 1; if (!ap->time_base.num) { st->codec->time_base= (AVRational){1,25}; } else { st->codec->time_base= ap->time_base; } if (!s->is_pipe) { if (find_image_range(&first_index, &last_index, s->path) < 0) goto fail; s->img_first = first_index; s->img_last = last_index; s->img_number = first_index; /* compute duration */ st->start_time = 0; st->duration = last_index - first_index + 1; if (get_frame_filename(buf, sizeof(buf), s->path, s->img_number) < 0) goto fail; if (url_fopen(f, buf, URL_RDONLY) < 0) goto fail; } else { f = &s1->pb; } ret = av_read_image(f, s1->filename, s->img_fmt, read_header_alloc_cb, s); if (ret < 0) goto fail1; if (!s->is_pipe) { url_fclose(f); } else { url_fseek(f, 0, SEEK_SET); } st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO; st->codec->width = s->width; st->codec->height = s->height; st->codec->pix_fmt = s->pix_fmt; s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15)); return 0; fail1: if (!s->is_pipe) url_fclose(f); fail: av_free(s); return AVERROR_IO; }
17,372
1
static void mpeg4_encode_gop_header(MpegEncContext *s) { int hours, minutes, seconds; int64_t time; put_bits(&s->pb, 16, 0); put_bits(&s->pb, 16, GOP_STARTCODE); time = s->current_picture_ptr->f.pts; if (s->reordered_input_picture[1]) time = FFMIN(time, s->reordered_input_picture[1]->f.pts); time = time * s->avctx->time_base.num; seconds = time / s->avctx->time_base.den; minutes = seconds / 60; seconds %= 60; hours = minutes / 60; minutes %= 60; hours %= 24; put_bits(&s->pb, 5, hours); put_bits(&s->pb, 6, minutes); put_bits(&s->pb, 1, 1); put_bits(&s->pb, 6, seconds); put_bits(&s->pb, 1, !!(s->flags & CODEC_FLAG_CLOSED_GOP)); put_bits(&s->pb, 1, 0); // broken link == NO s->last_time_base = time / s->avctx->time_base.den; ff_mpeg4_stuffing(&s->pb); }
17,373
0
static int av_encode(AVFormatContext **output_files, int nb_output_files, AVFormatContext **input_files, int nb_input_files, AVStreamMap *stream_maps, int nb_stream_maps) { int ret, i, j, k, n, nb_istreams = 0, nb_ostreams = 0; AVFormatContext *is, *os; AVCodecContext *codec, *icodec; AVOutputStream *ost, **ost_table = NULL; AVInputStream *ist, **ist_table = NULL; AVInputFile *file_table; AVFormatContext *stream_no_data; int key; file_table= (AVInputFile*) av_mallocz(nb_input_files * sizeof(AVInputFile)); if (!file_table) goto fail; /* input stream init */ j = 0; for(i=0;i<nb_input_files;i++) { is = input_files[i]; file_table[i].ist_index = j; file_table[i].nb_streams = is->nb_streams; j += is->nb_streams; } nb_istreams = j; ist_table = av_mallocz(nb_istreams * sizeof(AVInputStream *)); if (!ist_table) goto fail; for(i=0;i<nb_istreams;i++) { ist = av_mallocz(sizeof(AVInputStream)); if (!ist) goto fail; ist_table[i] = ist; } j = 0; for(i=0;i<nb_input_files;i++) { is = input_files[i]; for(k=0;k<is->nb_streams;k++) { ist = ist_table[j++]; ist->st = is->streams[k]; ist->file_index = i; ist->index = k; ist->discard = 1; /* the stream is discarded by default (changed later) */ if (ist->st->codec.rate_emu) { ist->start = av_gettime(); ist->frame = 0; } } } /* output stream init */ nb_ostreams = 0; for(i=0;i<nb_output_files;i++) { os = output_files[i]; nb_ostreams += os->nb_streams; } if (nb_stream_maps > 0 && nb_stream_maps != nb_ostreams) { fprintf(stderr, "Number of stream maps must match number of output streams\n"); exit(1); } /* Sanity check the mapping args -- do the input files & streams exist? */ for(i=0;i<nb_stream_maps;i++) { int fi = stream_maps[i].file_index; int si = stream_maps[i].stream_index; if (fi < 0 || fi > nb_input_files - 1 || si < 0 || si > file_table[fi].nb_streams - 1) { fprintf(stderr,"Could not find input stream #%d.%d\n", fi, si); exit(1); } } ost_table = av_mallocz(sizeof(AVOutputStream *) * nb_ostreams); if (!ost_table) goto fail; for(i=0;i<nb_ostreams;i++) { ost = av_mallocz(sizeof(AVOutputStream)); if (!ost) goto fail; ost_table[i] = ost; } n = 0; for(k=0;k<nb_output_files;k++) { os = output_files[k]; for(i=0;i<os->nb_streams;i++) { int found; ost = ost_table[n++]; ost->file_index = k; ost->index = i; ost->st = os->streams[i]; if (nb_stream_maps > 0) { ost->source_index = file_table[stream_maps[n-1].file_index].ist_index + stream_maps[n-1].stream_index; /* Sanity check that the stream types match */ if (ist_table[ost->source_index]->st->codec.codec_type != ost->st->codec.codec_type) { fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n", stream_maps[n-1].file_index, stream_maps[n-1].stream_index, ost->file_index, ost->index); exit(1); } } else { /* get corresponding input stream index : we select the first one with the right type */ found = 0; for(j=0;j<nb_istreams;j++) { ist = ist_table[j]; if (ist->discard && ist->st->codec.codec_type == ost->st->codec.codec_type) { ost->source_index = j; found = 1; } } if (!found) { /* try again and reuse existing stream */ for(j=0;j<nb_istreams;j++) { ist = ist_table[j]; if (ist->st->codec.codec_type == ost->st->codec.codec_type) { ost->source_index = j; found = 1; } } if (!found) { fprintf(stderr, "Could not find input stream matching output stream #%d.%d\n", ost->file_index, ost->index); exit(1); } } } ist = ist_table[ost->source_index]; ist->discard = 0; } } /* for each output stream, we compute the right encoding parameters */ for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; ist = ist_table[ost->source_index]; codec = &ost->st->codec; icodec = &ist->st->codec; if (ost->st->stream_copy) { /* if stream_copy is selected, no need to decode or encode */ codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; codec->codec_tag = icodec->codec_tag; codec->bit_rate = icodec->bit_rate; switch(codec->codec_type) { case CODEC_TYPE_AUDIO: codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; break; case CODEC_TYPE_VIDEO: codec->frame_rate = icodec->frame_rate; codec->frame_rate_base = icodec->frame_rate_base; codec->width = icodec->width; codec->height = icodec->height; break; default: av_abort(); } } else { switch(codec->codec_type) { case CODEC_TYPE_AUDIO: if (fifo_init(&ost->fifo, 2 * MAX_AUDIO_PACKET_SIZE)) goto fail; if (codec->channels == icodec->channels && codec->sample_rate == icodec->sample_rate) { ost->audio_resample = 0; } else { if (codec->channels != icodec->channels && icodec->codec_id == CODEC_ID_AC3) { /* Special case for 5:1 AC3 input */ /* and mono or stereo output */ /* Request specific number of channels */ icodec->channels = codec->channels; if (codec->sample_rate == icodec->sample_rate) ost->audio_resample = 0; else { ost->audio_resample = 1; ost->resample = audio_resample_init(codec->channels, icodec->channels, codec->sample_rate, icodec->sample_rate); if(!ost->resample) { printf("Can't resample. Aborting.\n"); av_abort(); } } /* Request specific number of channels */ icodec->channels = codec->channels; } else { ost->audio_resample = 1; ost->resample = audio_resample_init(codec->channels, icodec->channels, codec->sample_rate, icodec->sample_rate); if(!ost->resample) { printf("Can't resample. Aborting.\n"); av_abort(); } } } ist->decoding_needed = 1; ost->encoding_needed = 1; break; case CODEC_TYPE_VIDEO: if (codec->width == icodec->width && codec->height == icodec->height && frame_topBand == 0 && frame_bottomBand == 0 && frame_leftBand == 0 && frame_rightBand == 0) { ost->video_resample = 0; ost->video_crop = 0; } else if ((codec->width == icodec->width - (frame_leftBand + frame_rightBand)) && (codec->height == icodec->height - (frame_topBand + frame_bottomBand))) { ost->video_resample = 0; ost->video_crop = 1; ost->topBand = frame_topBand; ost->leftBand = frame_leftBand; } else { ost->video_resample = 1; ost->video_crop = 0; // cropping is handled as part of resample if( avpicture_alloc( &ost->pict_tmp, PIX_FMT_YUV420P, codec->width, codec->height ) ) goto fail; ost->img_resample_ctx = img_resample_full_init( ost->st->codec.width, ost->st->codec.height, ist->st->codec.width, ist->st->codec.height, frame_topBand, frame_bottomBand, frame_leftBand, frame_rightBand); } ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: av_abort(); } /* two pass mode */ if (ost->encoding_needed && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; int size; char *logbuffer; snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename ? pass_logfilename : DEFAULT_PASS_LOGFILENAME, i); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "w"); if (!f) { perror(logfilename); exit(1); } ost->logfile = f; } else { /* read the log file */ f = fopen(logfilename, "r"); if (!f) { perror(logfilename); exit(1); } fseek(f, 0, SEEK_END); size = ftell(f); fseek(f, 0, SEEK_SET); logbuffer = av_malloc(size + 1); if (!logbuffer) { fprintf(stderr, "Could not allocate log buffer\n"); exit(1); } size = fread(logbuffer, 1, size, f); fclose(f); logbuffer[size] = '\0'; codec->stats_in = logbuffer; } } } } /* dump the file output parameters - cannot be done before in case of stream copy */ for(i=0;i<nb_output_files;i++) { dump_format(output_files[i], i, output_files[i]->filename, 1); } /* dump the stream mapping */ fprintf(stderr, "Stream mapping:\n"); for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; fprintf(stderr, " Stream #%d.%d -> #%d.%d\n", ist_table[ost->source_index]->file_index, ist_table[ost->source_index]->index, ost->file_index, ost->index); } /* open each encoder */ for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { AVCodec *codec; codec = avcodec_find_encoder(ost->st->codec.codec_id); if (!codec) { fprintf(stderr, "Unsupported codec for output stream #%d.%d\n", ost->file_index, ost->index); exit(1); } if (avcodec_open(&ost->st->codec, codec) < 0) { fprintf(stderr, "Error while opening codec for stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\n", ost->file_index, ost->index); exit(1); } } } /* open each decoder */ for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { AVCodec *codec; codec = avcodec_find_decoder(ist->st->codec.codec_id); if (!codec) { fprintf(stderr, "Unsupported codec (id=%d) for input stream #%d.%d\n", ist->st->codec.codec_id, ist->file_index, ist->index); exit(1); } if (avcodec_open(&ist->st->codec, codec) < 0) { fprintf(stderr, "Error while opening codec for input stream #%d.%d\n", ist->file_index, ist->index); exit(1); } //if (ist->st->codec.codec_type == CODEC_TYPE_VIDEO) // ist->st->codec.flags |= CODEC_FLAG_REPEAT_FIELD; } } /* init pts */ for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; is = input_files[ist->file_index]; ist->pts = 0; ist->next_pts = 0; } /* compute buffer size max (should use a complete heuristic) */ for(i=0;i<nb_input_files;i++) { file_table[i].buffer_size_max = 2048; } /* open files and write file headers */ for(i=0;i<nb_output_files;i++) { os = output_files[i]; if (av_write_header(os) < 0) { fprintf(stderr, "Could not write header for output file #%d (incorrect codec paramters ?)\n", i); ret = -EINVAL; goto fail; } } #ifndef CONFIG_WIN32 if ( !using_stdin ) fprintf(stderr, "Press [q] to stop encoding\n"); #endif term_init(); stream_no_data = 0; key = -1; for(; received_sigterm == 0;) { int file_index, ist_index; AVPacket pkt; double pts_min; redo: /* if 'q' pressed, exits */ if (!using_stdin) { /* read_key() returns 0 on EOF */ key = read_key(); if (key == 'q') break; } /* select the stream that we must read now by looking at the smallest output pts */ file_index = -1; pts_min = 1e10; for(i=0;i<nb_ostreams;i++) { double pts; ost = ost_table[i]; os = output_files[ost->file_index]; ist = ist_table[ost->source_index]; pts = (double)ost->st->pts.val * os->pts_num / os->pts_den; if (!file_table[ist->file_index].eof_reached && pts < pts_min) { pts_min = pts; file_index = ist->file_index; } } /* if none, if is finished */ if (file_index < 0) { break; } /* finish if recording time exhausted */ if (recording_time > 0 && pts_min >= (recording_time / 1000000.0)) break; /* read a frame from it and output it in the fifo */ is = input_files[file_index]; if (av_read_frame(is, &pkt) < 0) { file_table[file_index].eof_reached = 1; continue; } if (!pkt.size) { stream_no_data = is; } else { stream_no_data = 0; } if (do_pkt_dump) { av_pkt_dump(stdout, &pkt, do_hex_dump); } /* the following test is needed in case new streams appear dynamically in stream : we ignore them */ if (pkt.stream_index >= file_table[file_index].nb_streams) goto discard_packet; ist_index = file_table[file_index].ist_index + pkt.stream_index; ist = ist_table[ist_index]; if (ist->discard) goto discard_packet; //fprintf(stderr,"read #%d.%d size=%d\n", ist->file_index, ist->index, pkt.size); if (output_packet(ist, ist_index, ost_table, nb_ostreams, &pkt) < 0) { fprintf(stderr, "Error while decoding stream #%d.%d\n", ist->file_index, ist->index); av_free_packet(&pkt); goto redo; } discard_packet: av_free_packet(&pkt); /* dump report by using the output first video and audio streams */ print_report(output_files, ost_table, nb_ostreams, 0); } /* at the end of stream, we must flush the decoder buffers */ for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { output_packet(ist, i, ost_table, nb_ostreams, NULL); } } term_exit(); /* dump report by using the first video and audio streams */ print_report(output_files, ost_table, nb_ostreams, 1); /* write the trailer if needed and close file */ for(i=0;i<nb_output_files;i++) { os = output_files[i]; av_write_trailer(os); } /* close each encoder */ for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { av_freep(&ost->st->codec.stats_in); avcodec_close(&ost->st->codec); } } /* close each decoder */ for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; if (ist->decoding_needed) { avcodec_close(&ist->st->codec); } } /* finished ! */ ret = 0; fail1: av_free(file_table); if (ist_table) { for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; av_free(ist); } av_free(ist_table); } if (ost_table) { for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost) { if (ost->logfile) { fclose(ost->logfile); ost->logfile = NULL; } fifo_free(&ost->fifo); /* works even if fifo is not initialized but set to zero */ av_free(ost->pict_tmp.data[0]); if (ost->video_resample) img_resample_close(ost->img_resample_ctx); if (ost->audio_resample) audio_resample_close(ost->resample); av_free(ost); } } av_free(ost_table); } return ret; fail: ret = -ENOMEM; goto fail1; }
17,374
1
static void vm_change_state_handler(void *opaque, int running, RunState state) { GICv3ITSState *s = (GICv3ITSState *)opaque; Error *err = NULL; int ret; if (running) { return; } ret = kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL, KVM_DEV_ARM_ITS_SAVE_TABLES, NULL, true, &err); if (err) { error_report_err(err); } if (ret < 0 && ret != -EFAULT) { abort(); } }
17,377
1
static uint8_t usb_linux_get_alt_setting(USBHostDevice *s, uint8_t configuration, uint8_t interface) { char device_name[64], line[1024]; int alt_setting; sprintf(device_name, "%d-%s:%d.%d", s->bus_num, s->port, (int)configuration, (int)interface); if (!usb_host_read_file(line, sizeof(line), "bAlternateSetting", device_name)) { /* Assume alt 0 on error */ return 0; } if (sscanf(line, "%d", &alt_setting) != 1) { /* Assume alt 0 on error */ return 0; } return alt_setting; }
17,379
1
static int append_extradata(APNGDemuxContext *ctx, AVIOContext *pb, int len) { int previous_size = ctx->extra_data_size; int new_size, ret; uint8_t *new_extradata; if (previous_size > INT_MAX - len) return AVERROR_INVALIDDATA; new_size = previous_size + len; new_extradata = av_realloc(ctx->extra_data, new_size + AV_INPUT_BUFFER_PADDING_SIZE); if (!new_extradata) return AVERROR(ENOMEM); ctx->extra_data = new_extradata; ctx->extra_data_size = new_size; if ((ret = avio_read(pb, ctx->extra_data + previous_size, len)) < 0) return ret; return previous_size; }
17,380
1
void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y) { const int bs = ctx->block_width_l2; const int bw = 1 << bs; int dct_y_offset = ctx->dct_y_offset; int dct_uv_offset = ctx->dct_uv_offset; int linesize = ctx->m.linesize; int uvlinesize = ctx->m.uvlinesize; const uint8_t *ptr_y = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize) + (mb_x << bs + 1); const uint8_t *ptr_u = ctx->thread[0]->src[1] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs + ctx->is_444); const uint8_t *ptr_v = ctx->thread[0]->src[2] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs + ctx->is_444); PixblockDSPContext *pdsp = &ctx->m.pdsp; VideoDSPContext *vdsp = &ctx->m.vdsp; if (ctx->bit_depth != 10 && vdsp->emulated_edge_mc && ((mb_x << 4) + 16 > ctx->m.avctx->width || (mb_y << 4) + 16 > ctx->m.avctx->height)) { int y_w = ctx->m.avctx->width - (mb_x << 4); int y_h = ctx->m.avctx->height - (mb_y << 4); int uv_w = (y_w + 1) / 2; int uv_h = y_h; linesize = 16; uvlinesize = 8; vdsp->emulated_edge_mc(&ctx->edge_buf_y[0], ptr_y, linesize, ctx->m.linesize, linesize, 16, 0, 0, y_w, y_h); vdsp->emulated_edge_mc(&ctx->edge_buf_uv[0][0], ptr_u, uvlinesize, ctx->m.uvlinesize, uvlinesize, 16, 0, 0, uv_w, uv_h); vdsp->emulated_edge_mc(&ctx->edge_buf_uv[1][0], ptr_v, uvlinesize, ctx->m.uvlinesize, uvlinesize, 16, 0, 0, uv_w, uv_h); dct_y_offset = bw * linesize; dct_uv_offset = bw * uvlinesize; ptr_y = &ctx->edge_buf_y[0]; ptr_u = &ctx->edge_buf_uv[0][0]; ptr_v = &ctx->edge_buf_uv[1][0]; } else if (ctx->bit_depth == 10 && vdsp->emulated_edge_mc && ((mb_x << 3) + 8 > ctx->m.avctx->width || (mb_y << 3) + 8 > ctx->m.avctx->height)) { int y_w = ctx->m.avctx->width - (mb_x << 3); int y_h = ctx->m.avctx->height - (mb_y << 3); int uv_w = ctx->is_444 ? y_w : (y_w + 1) / 2; int uv_h = y_h; linesize = 16; uvlinesize = 8 + 8 * ctx->is_444; vdsp->emulated_edge_mc(&ctx->edge_buf_y[0], ptr_y, linesize, ctx->m.linesize, linesize / 2, 16, 0, 0, y_w, y_h); vdsp->emulated_edge_mc(&ctx->edge_buf_uv[0][0], ptr_u, uvlinesize, ctx->m.uvlinesize, uvlinesize / 2, 16, 0, 0, uv_w, uv_h); vdsp->emulated_edge_mc(&ctx->edge_buf_uv[1][0], ptr_v, uvlinesize, ctx->m.uvlinesize, uvlinesize / 2, 16, 0, 0, uv_w, uv_h); dct_y_offset = bw * linesize; dct_uv_offset = bw * uvlinesize; ptr_y = &ctx->edge_buf_y[0]; ptr_u = &ctx->edge_buf_uv[0][0]; ptr_v = &ctx->edge_buf_uv[1][0]; } if (!ctx->is_444) { pdsp->get_pixels(ctx->blocks[0], ptr_y, linesize); pdsp->get_pixels(ctx->blocks[1], ptr_y + bw, linesize); pdsp->get_pixels(ctx->blocks[2], ptr_u, uvlinesize); pdsp->get_pixels(ctx->blocks[3], ptr_v, uvlinesize); if (mb_y + 1 == ctx->m.mb_height && ctx->m.avctx->height == 1080) { if (ctx->interlaced) { ctx->get_pixels_8x4_sym(ctx->blocks[4], ptr_y + dct_y_offset, linesize); ctx->get_pixels_8x4_sym(ctx->blocks[5], ptr_y + dct_y_offset + bw, linesize); ctx->get_pixels_8x4_sym(ctx->blocks[6], ptr_u + dct_uv_offset, uvlinesize); ctx->get_pixels_8x4_sym(ctx->blocks[7], ptr_v + dct_uv_offset, uvlinesize); } else { ctx->bdsp.clear_block(ctx->blocks[4]); ctx->bdsp.clear_block(ctx->blocks[5]); ctx->bdsp.clear_block(ctx->blocks[6]); ctx->bdsp.clear_block(ctx->blocks[7]); } } else { pdsp->get_pixels(ctx->blocks[4], ptr_y + dct_y_offset, linesize); pdsp->get_pixels(ctx->blocks[5], ptr_y + dct_y_offset + bw, linesize); pdsp->get_pixels(ctx->blocks[6], ptr_u + dct_uv_offset, uvlinesize); pdsp->get_pixels(ctx->blocks[7], ptr_v + dct_uv_offset, uvlinesize); } } else { pdsp->get_pixels(ctx->blocks[0], ptr_y, linesize); pdsp->get_pixels(ctx->blocks[1], ptr_y + bw, linesize); pdsp->get_pixels(ctx->blocks[6], ptr_y + dct_y_offset, linesize); pdsp->get_pixels(ctx->blocks[7], ptr_y + dct_y_offset + bw, linesize); pdsp->get_pixels(ctx->blocks[2], ptr_u, uvlinesize); pdsp->get_pixels(ctx->blocks[3], ptr_u + bw, uvlinesize); pdsp->get_pixels(ctx->blocks[8], ptr_u + dct_uv_offset, uvlinesize); pdsp->get_pixels(ctx->blocks[9], ptr_u + dct_uv_offset + bw, uvlinesize); pdsp->get_pixels(ctx->blocks[4], ptr_v, uvlinesize); pdsp->get_pixels(ctx->blocks[5], ptr_v + bw, uvlinesize); pdsp->get_pixels(ctx->blocks[10], ptr_v + dct_uv_offset, uvlinesize); pdsp->get_pixels(ctx->blocks[11], ptr_v + dct_uv_offset + bw, uvlinesize); } }
17,382
1
bool virtio_scsi_handle_event_vq(VirtIOSCSI *s, VirtQueue *vq) { virtio_scsi_acquire(s); if (s->events_dropped) { virtio_scsi_push_event(s, NULL, VIRTIO_SCSI_T_NO_EVENT, 0); virtio_scsi_release(s); return true; } virtio_scsi_release(s); return false; }
17,383
1
static attribute_align_arg void *frame_worker_thread(void *arg) { PerThreadContext *p = arg; FrameThreadContext *fctx = p->parent; AVCodecContext *avctx = p->avctx; AVCodec *codec = avctx->codec; while (1) { int i; if (p->state == STATE_INPUT_READY && !fctx->die) { pthread_mutex_lock(&p->mutex); while (p->state == STATE_INPUT_READY && !fctx->die) pthread_cond_wait(&p->input_cond, &p->mutex); pthread_mutex_unlock(&p->mutex); } if (fctx->die) break; if (!codec->update_thread_context && (avctx->thread_safe_callbacks || avctx->get_buffer == avcodec_default_get_buffer)) ff_thread_finish_setup(avctx); pthread_mutex_lock(&p->mutex); avcodec_get_frame_defaults(&p->frame); p->got_frame = 0; p->result = codec->decode(avctx, &p->frame, &p->got_frame, &p->avpkt); if (p->state == STATE_SETTING_UP) ff_thread_finish_setup(avctx); pthread_mutex_lock(&p->progress_mutex); for (i = 0; i < MAX_BUFFERS; i++) if (p->progress_used[i]) { p->progress[i][0] = INT_MAX; p->progress[i][1] = INT_MAX; } p->state = STATE_INPUT_READY; pthread_cond_broadcast(&p->progress_cond); pthread_cond_signal(&p->output_cond); pthread_mutex_unlock(&p->progress_mutex); pthread_mutex_unlock(&p->mutex); } return NULL; }
17,384
1
static void gen_spr_970_pmu_sup(CPUPPCState *env) { spr_register(env, SPR_970_PMC7, "PMC7", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_970_PMC8, "PMC8", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); }
17,385
1
static av_cold int hevc_sdp_parse_fmtp_config(AVFormatContext *s, AVStream *stream, PayloadContext *hevc_data, char *attr, char *value) { /* profile-space: 0-3 */ /* profile-id: 0-31 */ if (!strcmp(attr, "profile-id")) { hevc_data->profile_id = atoi(value); av_dlog(s, "SDP: found profile-id: %d\n", hevc_data->profile_id); } /* tier-flag: 0-1 */ /* level-id: 0-255 */ /* interop-constraints: [base16] */ /* profile-compatibility-indicator: [base16] */ /* sprop-sub-layer-id: 0-6, defines highest possible value for TID, default: 6 */ /* recv-sub-layer-id: 0-6 */ /* max-recv-level-id: 0-255 */ /* tx-mode: MSM,SSM */ /* sprop-vps: [base64] */ /* sprop-sps: [base64] */ /* sprop-pps: [base64] */ /* sprop-sei: [base64] */ if (!strcmp(attr, "sprop-vps") || !strcmp(attr, "sprop-sps") || !strcmp(attr, "sprop-pps") || !strcmp(attr, "sprop-sei")) { uint8_t **data_ptr; int *size_ptr; if (!strcmp(attr, "sprop-vps")) { data_ptr = &hevc_data->vps; size_ptr = &hevc_data->vps_size; } else if (!strcmp(attr, "sprop-sps")) { data_ptr = &hevc_data->sps; size_ptr = &hevc_data->sps_size; } else if (!strcmp(attr, "sprop-pps")) { data_ptr = &hevc_data->pps; size_ptr = &hevc_data->pps_size; } else if (!strcmp(attr, "sprop-sei")) { data_ptr = &hevc_data->sei; size_ptr = &hevc_data->sei_size; } while (*value) { char base64packet[1024]; uint8_t decoded_packet[1024]; int decoded_packet_size; char *dst = base64packet; while (*value && *value != ',' && (dst - base64packet) < sizeof(base64packet) - 1) { *dst++ = *value++; } *dst++ = '\0'; if (*value == ',') value++; decoded_packet_size = av_base64_decode(decoded_packet, base64packet, sizeof(decoded_packet)); if (decoded_packet_size > 0) { uint8_t *tmp = av_realloc(*data_ptr, decoded_packet_size + sizeof(start_sequence) + *size_ptr); if (!tmp) { av_log(s, AV_LOG_ERROR, "Unable to allocate memory for extradata!\n"); return AVERROR(ENOMEM); } *data_ptr = tmp; memcpy(*data_ptr + *size_ptr, start_sequence, sizeof(start_sequence)); memcpy(*data_ptr + *size_ptr + sizeof(start_sequence), decoded_packet, decoded_packet_size); *size_ptr += sizeof(start_sequence) + decoded_packet_size; } } } /* max-lsr, max-lps, max-cpb, max-dpb, max-br, max-tr, max-tc */ /* max-fps */ /* sprop-max-don-diff: 0-32767 When the RTP stream depends on one or more other RTP streams (in this case tx-mode MUST be equal to "MSM" and MSM is in use), this parameter MUST be present and the value MUST be greater than 0. */ if (!strcmp(attr, "sprop-max-don-diff")) { if (atoi(value) > 0) hevc_data->using_donl_field = 1; av_dlog(s, "Found sprop-max-don-diff in SDP, DON field usage is: %d\n", hevc_data->using_donl_field); } /* sprop-depack-buf-nalus: 0-32767 */ if (!strcmp(attr, "sprop-depack-buf-nalus")) { if (atoi(value) > 0) hevc_data->using_donl_field = 1; av_dlog(s, "Found sprop-depack-buf-nalus in SDP, DON field usage is: %d\n", hevc_data->using_donl_field); } /* sprop-depack-buf-bytes: 0-4294967295 */ /* depack-buf-cap */ /* sprop-segmentation-id: 0-3 */ /* sprop-spatial-segmentation-idc: [base16] */ /* dec-parallel-ca: */ /* include-dph */ return 0; }
17,387
1
static int svq3_decode_frame (AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { MpegEncContext *const s = avctx->priv_data; H264Context *const h = avctx->priv_data; int m, mb_type; unsigned char *extradata; unsigned int size; s->flags = avctx->flags; s->flags2 = avctx->flags2; s->unrestricted_mv = 1; if (!s->context_initialized) { s->width = avctx->width; s->height = avctx->height; h->pred4x4[DIAG_DOWN_LEFT_PRED] = pred4x4_down_left_svq3_c; h->pred16x16[PLANE_PRED8x8] = pred16x16_plane_svq3_c; h->halfpel_flag = 1; h->thirdpel_flag = 1; h->unknown_svq3_flag = 0; h->chroma_qp = 4; if (MPV_common_init (s) < 0) return -1; h->b_stride = 4*s->mb_width; alloc_tables (h); /* prowl for the "SEQH" marker in the extradata */ extradata = (unsigned char *)avctx->extradata; for (m = 0; m < avctx->extradata_size; m++) { if (!memcmp (extradata, "SEQH", 4)) break; extradata++; } /* if a match was found, parse the extra data */ if (!memcmp (extradata, "SEQH", 4)) { GetBitContext gb; size = BE_32(&extradata[4]); init_get_bits (&gb, extradata + 8, size); /* 'frame size code' and optional 'width, height' */ if (get_bits (&gb, 3) == 7) { get_bits (&gb, 12); get_bits (&gb, 12); } h->halfpel_flag = get_bits1 (&gb); h->thirdpel_flag = get_bits1 (&gb); /* unknown fields */ get_bits1 (&gb); get_bits1 (&gb); get_bits1 (&gb); get_bits1 (&gb); s->low_delay = get_bits1 (&gb); /* unknown field */ get_bits1 (&gb); while (get_bits1 (&gb)) { get_bits (&gb, 8); } h->unknown_svq3_flag = get_bits1 (&gb); avctx->has_b_frames = !s->low_delay; } } /* special case for last picture */ if (buf_size == 0) { if (s->next_picture_ptr && !s->low_delay) { *(AVFrame *) data = *(AVFrame *) &s->next_picture; *data_size = sizeof(AVFrame); } return 0; } init_get_bits (&s->gb, buf, 8*buf_size); s->mb_x = s->mb_y = 0; if (svq3_decode_slice_header (h)) return -1; s->pict_type = h->slice_type; s->picture_number = h->slice_num; if(avctx->debug&FF_DEBUG_PICT_INFO){ av_log(h->s.avctx, AV_LOG_DEBUG, "%c hpel:%d, tpel:%d aqp:%d qp:%d\n", av_get_pict_type_char(s->pict_type), h->halfpel_flag, h->thirdpel_flag, s->adaptive_quant, s->qscale ); } /* for hurry_up==5 */ s->current_picture.pict_type = s->pict_type; s->current_picture.key_frame = (s->pict_type == I_TYPE); /* skip b frames if we dont have reference frames */ if (s->last_picture_ptr == NULL && s->pict_type == B_TYPE) return 0; /* skip b frames if we are in a hurry */ if (avctx->hurry_up && s->pict_type == B_TYPE) return 0; /* skip everything if we are in a hurry >= 5 */ if (avctx->hurry_up >= 5) return 0; if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) || avctx->skip_frame >= AVDISCARD_ALL) return 0; if (s->next_p_frame_damaged) { if (s->pict_type == B_TYPE) return 0; else s->next_p_frame_damaged = 0; } frame_start (h); if (s->pict_type == B_TYPE) { h->frame_num_offset = (h->slice_num - h->prev_frame_num); if (h->frame_num_offset < 0) { h->frame_num_offset += 256; } if (h->frame_num_offset == 0 || h->frame_num_offset >= h->prev_frame_num_offset) { av_log(h->s.avctx, AV_LOG_ERROR, "error in B-frame picture id\n"); return -1; } } else { h->prev_frame_num = h->frame_num; h->frame_num = h->slice_num; h->prev_frame_num_offset = (h->frame_num - h->prev_frame_num); if (h->prev_frame_num_offset < 0) { h->prev_frame_num_offset += 256; } } for(m=0; m<2; m++){ int i; for(i=0; i<4; i++){ int j; for(j=-1; j<4; j++) h->ref_cache[m][scan8[0] + 8*i + j]= 1; h->ref_cache[m][scan8[0] + 8*i + j]= PART_NOT_AVAILABLE; } } for (s->mb_y=0; s->mb_y < s->mb_height; s->mb_y++) { for (s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) { if ( (get_bits_count(&s->gb) + 7) >= s->gb.size_in_bits && ((get_bits_count(&s->gb) & 7) == 0 || show_bits (&s->gb, (-get_bits_count(&s->gb) & 7)) == 0)) { skip_bits(&s->gb, h->next_slice_index - get_bits_count(&s->gb)); s->gb.size_in_bits = 8*buf_size; if (svq3_decode_slice_header (h)) return -1; /* TODO: support s->mb_skip_run */ } mb_type = svq3_get_ue_golomb (&s->gb); if (s->pict_type == I_TYPE) { mb_type += 8; } else if (s->pict_type == B_TYPE && mb_type >= 4) { mb_type += 4; } if (mb_type > 33 || svq3_decode_mb (h, mb_type)) { av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d\n", s->mb_x, s->mb_y); return -1; } if (mb_type != 0) { hl_decode_mb (h); } if (s->pict_type != B_TYPE && !s->low_delay) { s->current_picture.mb_type[s->mb_x + s->mb_y*s->mb_stride] = (s->pict_type == P_TYPE && mb_type < 8) ? (mb_type - 1) : -1; } } ff_draw_horiz_band(s, 16*s->mb_y, 16); } MPV_frame_end(s); if (s->pict_type == B_TYPE || s->low_delay) { *(AVFrame *) data = *(AVFrame *) &s->current_picture; } else { *(AVFrame *) data = *(AVFrame *) &s->last_picture; } avctx->frame_number = s->picture_number - 1; /* dont output the last pic after seeking */ if (s->last_picture_ptr || s->low_delay) { *data_size = sizeof(AVFrame); } return buf_size; }
17,389
1
static int qemu_rdma_reg_whole_ram_blocks(RDMAContext *rdma) { int i; RDMALocalBlocks *local = &rdma->local_ram_blocks; for (i = 0; i < local->nb_blocks; i++) { local->block[i].mr = ibv_reg_mr(rdma->pd, local->block[i].local_host_addr, local->block[i].length, IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE ); if (!local->block[i].mr) { perror("Failed to register local dest ram block!\n"); break; } rdma->total_registrations++; } if (i >= local->nb_blocks) { return 0; } for (i--; i >= 0; i--) { ibv_dereg_mr(local->block[i].mr); rdma->total_registrations--; } return -1; }
17,390
1
static int encode_plane(AVCodecContext *avctx, uint8_t *src, uint8_t *dst, int step, int stride, int width, int height, PutByteContext *pb) { UtvideoContext *c = avctx->priv_data; uint8_t lengths[256]; uint32_t counts[256] = { 0 }; HuffEntry he[256]; uint32_t offset = 0, slice_len = 0; int i, sstart, send = 0; int symbol; /* Do prediction / make planes */ switch (c->frame_pred) { case PRED_NONE: for (i = 0; i < c->slices; i++) { sstart = send; send = height * (i + 1) / c->slices; write_plane(src + sstart * stride, dst + sstart * width, step, stride, width, send - sstart); } break; case PRED_LEFT: for (i = 0; i < c->slices; i++) { sstart = send; send = height * (i + 1) / c->slices; left_predict(src + sstart * stride, dst + sstart * width, step, stride, width, send - sstart); } break; case PRED_MEDIAN: for (i = 0; i < c->slices; i++) { sstart = send; send = height * (i + 1) / c->slices; median_predict(src + sstart * stride, dst + sstart * width, step, stride, width, send - sstart); } break; default: av_log(avctx, AV_LOG_ERROR, "Unknown prediction mode: %d\n", c->frame_pred); return AVERROR_OPTION_NOT_FOUND; } /* Count the usage of values */ count_usage(dst, width, height, counts); /* Check for a special case where only one symbol was used */ for (symbol = 0; symbol < 256; symbol++) { /* If non-zero count is found, see if it matches width * height */ if (counts[symbol]) { /* Special case if only one symbol was used */ if (counts[symbol] == width * height) { /* * Write a zero for the single symbol * used in the plane, else 0xFF. */ for (i = 0; i < 256; i++) { if (i == symbol) bytestream2_put_byte(pb, 0); else bytestream2_put_byte(pb, 0xFF); } /* Write zeroes for lengths */ for (i = 0; i < c->slices; i++) bytestream2_put_le32(pb, 0); /* And that's all for that plane folks */ return 0; } break; } } /* Calculate huffman lengths */ calculate_code_lengths(lengths, counts); /* * Write the plane's header into the output packet: * - huffman code lengths (256 bytes) * - slice end offsets (gotten from the slice lengths) */ for (i = 0; i < 256; i++) { bytestream2_put_byte(pb, lengths[i]); he[i].len = lengths[i]; he[i].sym = i; } /* Calculate the huffman codes themselves */ calculate_codes(he); send = 0; for (i = 0; i < c->slices; i++) { sstart = send; send = height * (i + 1) / c->slices; /* * Write the huffman codes to a buffer, * get the offset in bits and convert to bytes. */ offset += write_huff_codes(dst + sstart * width, c->slice_bits, width * (send - sstart), width, send - sstart, he) >> 3; slice_len = offset - slice_len; /* Byteswap the written huffman codes */ c->dsp.bswap_buf((uint32_t *) c->slice_bits, (uint32_t *) c->slice_bits, slice_len >> 2); /* Write the offset to the stream */ bytestream2_put_le32(pb, offset); /* Seek to the data part of the packet */ bytestream2_seek_p(pb, 4 * (c->slices - i - 1) + offset - slice_len, SEEK_CUR); /* Write the slices' data into the output packet */ bytestream2_put_buffer(pb, c->slice_bits, slice_len); /* Seek back to the slice offsets */ bytestream2_seek_p(pb, -4 * (c->slices - i - 1) - offset, SEEK_CUR); slice_len = offset; } /* And at the end seek to the end of written slice(s) */ bytestream2_seek_p(pb, offset, SEEK_CUR); return 0; }
17,391
1
static void init_excp_4xx_real (CPUPPCState *env) { #if !defined(CONFIG_USER_ONLY) env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000100; env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; env->excp_vectors[POWERPC_EXCP_PIT] = 0x00001000; env->excp_vectors[POWERPC_EXCP_FIT] = 0x00001010; env->excp_vectors[POWERPC_EXCP_WDT] = 0x00001020; env->excp_vectors[POWERPC_EXCP_DEBUG] = 0x00002000; env->excp_prefix = 0x00000000; env->ivor_mask = 0x0000FFF0; env->ivpr_mask = 0xFFFF0000; /* Hardware reset vector */ env->hreset_vector = 0xFFFFFFFCUL; #endif }
17,392
1
static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf, void *priv) { av_freep(&priv); }
17,393
1
void aio_set_dispatching(AioContext *ctx, bool dispatching) { ctx->dispatching = dispatching; if (!dispatching) { /* Write ctx->dispatching before reading e.g. bh->scheduled. * Optimization: this is only needed when we're entering the "unsafe" * phase where other threads must call event_notifier_set. */ smp_mb(); } }
17,394
1
static int adx_encode_header(AVCodecContext *avctx,unsigned char *buf,size_t bufsize) { #if 0 struct { uint32_t offset; /* 0x80000000 + sample start - 4 */ unsigned char unknown1[3]; /* 03 12 04 */ unsigned char channel; /* 1 or 2 */ uint32_t freq; uint32_t size; uint32_t unknown2; /* 01 f4 03 00 */ uint32_t unknown3; /* 00 00 00 00 */ uint32_t unknown4; /* 00 00 00 00 */ /* if loop unknown3 00 15 00 01 unknown4 00 00 00 01 long loop_start_sample; long loop_start_byte; long loop_end_sample; long loop_end_byte; long */ } adxhdr; /* big endian */ /* offset-6 "(c)CRI" */ #endif write_long(buf+0x00,0x80000000|0x20); write_long(buf+0x04,0x03120400|avctx->channels); write_long(buf+0x08,avctx->sample_rate); write_long(buf+0x0c,0); /* FIXME: set after */ write_long(buf+0x10,0x01040300); write_long(buf+0x14,0x00000000); write_long(buf+0x18,0x00000000); memcpy(buf+0x1c,"\0\0(c)CRI",8); return 0x20+4; }
17,395
1
static vscsi_req *vscsi_find_req(VSCSIState *s, uint32_t tag) { if (tag >= VSCSI_REQ_LIMIT || !s->reqs[tag].active) { return NULL; } return &s->reqs[tag]; }
17,396
1
static inline void RENAME(rgb24tobgr15)(const uint8_t *src, uint8_t *dst, unsigned src_size) { const uint8_t *s = src; const uint8_t *end; #ifdef HAVE_MMX const uint8_t *mm_end; #endif uint16_t *d = (uint16_t *)dst; end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*src):"memory"); __asm __volatile( "movq %0, %%mm7\n\t" "movq %1, %%mm6\n\t" ::"m"(red_15mask),"m"(green_15mask)); mm_end = end - 15; while(s < mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movd %1, %%mm0\n\t" "movd 3%1, %%mm3\n\t" "punpckldq 6%1, %%mm0\n\t" "punpckldq 9%1, %%mm3\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm3, %%mm4\n\t" "movq %%mm3, %%mm5\n\t" "psllq $7, %%mm0\n\t" "psllq $7, %%mm3\n\t" "pand %%mm7, %%mm0\n\t" "pand %%mm7, %%mm3\n\t" "psrlq $6, %%mm1\n\t" "psrlq $6, %%mm4\n\t" "pand %%mm6, %%mm1\n\t" "pand %%mm6, %%mm4\n\t" "psrlq $19, %%mm2\n\t" "psrlq $19, %%mm5\n\t" "pand %2, %%mm2\n\t" "pand %2, %%mm5\n\t" "por %%mm1, %%mm0\n\t" "por %%mm4, %%mm3\n\t" "por %%mm2, %%mm0\n\t" "por %%mm5, %%mm3\n\t" "psllq $16, %%mm3\n\t" "por %%mm3, %%mm0\n\t" MOVNTQ" %%mm0, %0\n\t" :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); d += 4; s += 12; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif while(s < end) { const int r= *s++; const int g= *s++; const int b= *s++; *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7); } }
17,397
1
static void read_tree(GetBitContext *gb, Tree *tree) { uint8_t tmp1[16], tmp2[16], *in = tmp1, *out = tmp2; int i, t, len; tree->vlc_num = get_bits(gb, 4); if (!tree->vlc_num) { for (i = 0; i < 16; i++) tree->syms[i] = i; return; } if (get_bits1(gb)) { len = get_bits(gb, 3); memset(tmp1, 0, sizeof(tmp1)); for (i = 0; i <= len; i++) { tree->syms[i] = get_bits(gb, 4); tmp1[tree->syms[i]] = 1; } for (i = 0; i < 16; i++) if (!tmp1[i]) tree->syms[++len] = i; } else { len = get_bits(gb, 2); for (i = 0; i < 16; i++) in[i] = i; for (i = 0; i <= len; i++) { int size = 1 << i; for (t = 0; t < 16; t += size << 1) merge(gb, out + t, in + t, size); FFSWAP(uint8_t*, in, out); } memcpy(tree->syms, in, 16); } }
17,399
1
uint32_t ide_data_readl(void *opaque, uint32_t addr) { IDEBus *bus = opaque; IDEState *s = idebus_active_if(bus); uint8_t *p; int ret; /* PIO data access allowed only when DRQ bit is set. The result of a read * during PIO in is indeterminate, return 0 and don't move forward. */ if (!(s->status & DRQ_STAT) || !ide_is_pio_out(s)) { p = s->data_ptr; ret = cpu_to_le32(*(uint32_t *)p); p += 4; s->data_ptr = p; if (p >= s->data_end) s->end_transfer_func(s); return ret;
17,400
1
void do_commit(Monitor *mon, const QDict *qdict) { const char *device = qdict_get_str(qdict, "device"); BlockDriverState *bs; if (!strcmp(device, "all")) { bdrv_commit_all(); } else { int ret; bs = bdrv_find(device); if (!bs) { qerror_report(QERR_DEVICE_NOT_FOUND, device); return; } ret = bdrv_commit(bs); if (ret == -EBUSY) { qerror_report(QERR_DEVICE_IN_USE, device); return; } } }
17,401
1
void avfilter_start_frame(AVFilterLink *link, AVFilterPicRef *picref) { void (*start_frame)(AVFilterLink *, AVFilterPicRef *); AVFilterPad *dst = &link_dpad(link); if(!(start_frame = dst->start_frame)) start_frame = avfilter_default_start_frame; /* prepare to copy the picture if it has insufficient permissions */ if((dst->min_perms & picref->perms) != dst->min_perms || dst->rej_perms & picref->perms) { /* av_log(link->dst, AV_LOG_INFO, "frame copy needed (have perms %x, need %x, reject %x)\n", picref->perms, link_dpad(link).min_perms, link_dpad(link).rej_perms); */ link->cur_pic = avfilter_default_get_video_buffer(link, dst->min_perms); link->srcpic = picref; link->cur_pic->pts = link->srcpic->pts; } else link->cur_pic = picref; start_frame(link, link->cur_pic); }
17,403
1
static void ffserver_apply_stream_config(AVCodecContext *enc, const AVDictionary *conf, AVDictionary **opts) { AVDictionaryEntry *e; /* Return values from ffserver_set_*_param are ignored. Values are initially parsed and checked before inserting to AVDictionary. */ //video params if ((e = av_dict_get(conf, "VideoBitRateRangeMin", NULL, 0))) ffserver_set_int_param(&enc->rc_min_rate, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoBitRateRangeMax", NULL, 0))) ffserver_set_int_param(&enc->rc_max_rate, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "Debug", NULL, 0))) ffserver_set_int_param(&enc->debug, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "Strict", NULL, 0))) ffserver_set_int_param(&enc->strict_std_compliance, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoBufferSize", NULL, 0))) ffserver_set_int_param(&enc->rc_buffer_size, e->value, 8*1024, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoBitRateTolerance", NULL, 0))) ffserver_set_int_param(&enc->bit_rate_tolerance, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoBitRate", NULL, 0))) ffserver_set_int_param(&enc->bit_rate, e->value, 1000, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoSizeWidth", NULL, 0))) ffserver_set_int_param(&enc->width, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoSizeHeight", NULL, 0))) ffserver_set_int_param(&enc->height, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "PixelFormat", NULL, 0))) { int val; ffserver_set_int_param(&val, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); enc->pix_fmt = val; } if ((e = av_dict_get(conf, "VideoGopSize", NULL, 0))) ffserver_set_int_param(&enc->gop_size, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoFrameRateNum", NULL, 0))) ffserver_set_int_param(&enc->time_base.num, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoFrameRateDen", NULL, 0))) ffserver_set_int_param(&enc->time_base.den, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoQDiff", NULL, 0))) ffserver_set_int_param(&enc->max_qdiff, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoQMax", NULL, 0))) ffserver_set_int_param(&enc->qmax, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "VideoQMin", NULL, 0))) ffserver_set_int_param(&enc->qmin, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "LumiMask", NULL, 0))) ffserver_set_float_param(&enc->lumi_masking, e->value, 0, -FLT_MAX, FLT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "DarkMask", NULL, 0))) ffserver_set_float_param(&enc->dark_masking, e->value, 0, -FLT_MAX, FLT_MAX, NULL, 0, NULL); if (av_dict_get(conf, "BitExact", NULL, 0)) enc->flags |= CODEC_FLAG_BITEXACT; if (av_dict_get(conf, "DctFastint", NULL, 0)) enc->dct_algo = FF_DCT_FASTINT; if (av_dict_get(conf, "IdctSimple", NULL, 0)) enc->idct_algo = FF_IDCT_SIMPLE; if (av_dict_get(conf, "VideoHighQuality", NULL, 0)) enc->mb_decision = FF_MB_DECISION_BITS; if ((e = av_dict_get(conf, "VideoTag", NULL, 0))) enc->codec_tag = MKTAG(e->value[0], e->value[1], e->value[2], e->value[3]); if (av_dict_get(conf, "Qscale", NULL, 0)) { enc->flags |= CODEC_FLAG_QSCALE; ffserver_set_int_param(&enc->global_quality, e->value, FF_QP2LAMBDA, INT_MIN, INT_MAX, NULL, 0, NULL); } if (av_dict_get(conf, "Video4MotionVector", NULL, 0)) { enc->mb_decision = FF_MB_DECISION_BITS; //FIXME remove enc->flags |= CODEC_FLAG_4MV; } //audio params if ((e = av_dict_get(conf, "AudioChannels", NULL, 0))) ffserver_set_int_param(&enc->channels, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "AudioSampleRate", NULL, 0))) ffserver_set_int_param(&enc->sample_rate, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); if ((e = av_dict_get(conf, "AudioBitRate", NULL, 0))) ffserver_set_int_param(&enc->bit_rate, e->value, 0, INT_MIN, INT_MAX, NULL, 0, NULL); av_opt_set_dict2(enc->priv_data, opts, AV_OPT_SEARCH_CHILDREN); av_opt_set_dict2(enc, opts, AV_OPT_SEARCH_CHILDREN); if (av_dict_count(*opts)) av_log(NULL, AV_LOG_ERROR, "Something went wrong, %d options not set!!!\n", av_dict_count(*opts)); }
17,404
1
static uint32_t grlib_gptimer_readl(void *opaque, target_phys_addr_t addr) { GPTimerUnit *unit = opaque; target_phys_addr_t timer_addr; int id; uint32_t value = 0; addr &= 0xff; /* Unit registers */ switch (addr) { case SCALER_OFFSET: trace_grlib_gptimer_readl(-1, "scaler:", unit->scaler); return unit->scaler; case SCALER_RELOAD_OFFSET: trace_grlib_gptimer_readl(-1, "reload:", unit->reload); return unit->reload; case CONFIG_OFFSET: trace_grlib_gptimer_readl(-1, "config:", unit->config); return unit->config; default: break; } timer_addr = (addr % TIMER_BASE); id = (addr - TIMER_BASE) / TIMER_BASE; if (id >= 0 && id < unit->nr_timers) { /* GPTimer registers */ switch (timer_addr) { case COUNTER_OFFSET: value = ptimer_get_count(unit->timers[id].ptimer); trace_grlib_gptimer_readl(id, "counter value:", value); return value; case COUNTER_RELOAD_OFFSET: value = unit->timers[id].reload; trace_grlib_gptimer_readl(id, "reload value:", value); return value; case CONFIG_OFFSET: trace_grlib_gptimer_readl(id, "scaler value:", unit->timers[id].config); return unit->timers[id].config; default: break; } } trace_grlib_gptimer_unknown_register("read", addr); return 0; }
17,405
1
static void new_subtitle_stream(AVFormatContext *oc, int file_idx) { AVStream *st; AVOutputStream *ost; AVCodec *codec=NULL; AVCodecContext *subtitle_enc; enum CodecID codec_id; st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); if (!st) { fprintf(stderr, "Could not alloc stream\n"); ffmpeg_exit(1); } ost = new_output_stream(oc, file_idx); subtitle_enc = st->codec; output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1); if(!subtitle_stream_copy){ if (subtitle_codec_name) { codec_id = find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 1, avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->strict_std_compliance); codec= output_codecs[nb_output_codecs-1] = avcodec_find_encoder_by_name(subtitle_codec_name); } else { codec_id = av_guess_codec(oc->oformat, NULL, oc->filename, NULL, AVMEDIA_TYPE_SUBTITLE); codec = avcodec_find_encoder(codec_id); } } avcodec_get_context_defaults3(st->codec, codec); ost->bitstream_filters = subtitle_bitstream_filters; subtitle_bitstream_filters= NULL; subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; if(subtitle_codec_tag) subtitle_enc->codec_tag= subtitle_codec_tag; if (oc->oformat->flags & AVFMT_GLOBALHEADER) { subtitle_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; avcodec_opts[AVMEDIA_TYPE_SUBTITLE]->flags |= CODEC_FLAG_GLOBAL_HEADER; } if (subtitle_stream_copy) { st->stream_copy = 1; } else { subtitle_enc->codec_id = codec_id; set_context_opts(avcodec_opts[AVMEDIA_TYPE_SUBTITLE], subtitle_enc, AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); } if (subtitle_language) { av_metadata_set2(&st->metadata, "language", subtitle_language, 0); av_freep(&subtitle_language); } subtitle_disable = 0; av_freep(&subtitle_codec_name); subtitle_stream_copy = 0; }
17,406
1
static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src, int width, enum PixelFormat srcFormat) { __asm__ volatile( "movq 24+%4, %%mm6 \n\t" "mov %3, %%"REG_a" \n\t" "pxor %%mm7, %%mm7 \n\t" "1: \n\t" PREFETCH" 64(%0) \n\t" "movd (%0), %%mm0 \n\t" "movd 2(%0), %%mm1 \n\t" "punpcklbw %%mm7, %%mm0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "pmaddwd %4, %%mm0 \n\t" "pmaddwd 8+%4, %%mm1 \n\t" "pmaddwd 16+%4, %%mm2 \n\t" "pmaddwd %%mm6, %%mm3 \n\t" "paddd %%mm1, %%mm0 \n\t" "paddd %%mm3, %%mm2 \n\t" "movd 6(%0), %%mm1 \n\t" "movd 8(%0), %%mm3 \n\t" "add $12, %0 \n\t" "punpcklbw %%mm7, %%mm1 \n\t" "punpcklbw %%mm7, %%mm3 \n\t" "movq %%mm1, %%mm4 \n\t" "movq %%mm3, %%mm5 \n\t" "pmaddwd %4, %%mm1 \n\t" "pmaddwd 8+%4, %%mm3 \n\t" "pmaddwd 16+%4, %%mm4 \n\t" "pmaddwd %%mm6, %%mm5 \n\t" "paddd %%mm3, %%mm1 \n\t" "paddd %%mm5, %%mm4 \n\t" "movq "MANGLE(ff_bgr24toUVOffset)", %%mm3 \n\t" "paddd %%mm3, %%mm0 \n\t" "paddd %%mm3, %%mm2 \n\t" "paddd %%mm3, %%mm1 \n\t" "paddd %%mm3, %%mm4 \n\t" "psrad $15, %%mm0 \n\t" "psrad $15, %%mm2 \n\t" "psrad $15, %%mm1 \n\t" "psrad $15, %%mm4 \n\t" "packssdw %%mm1, %%mm0 \n\t" "packssdw %%mm4, %%mm2 \n\t" "packuswb %%mm0, %%mm0 \n\t" "packuswb %%mm2, %%mm2 \n\t" "movd %%mm0, (%1, %%"REG_a") \n\t" "movd %%mm2, (%2, %%"REG_a") \n\t" "add $4, %%"REG_a" \n\t" " js 1b \n\t" : "+r" (src) : "r" (dstU+width), "r" (dstV+width), "g" ((x86_reg)-width), "m"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24][0]) : "%"REG_a ); }
17,408
1
static ram_addr_t find_ram_offset(ram_addr_t size) { RAMBlock *block, *next_block; ram_addr_t offset, mingap = ULONG_MAX; if (QLIST_EMPTY(&ram_list.blocks)) return 0; QLIST_FOREACH(block, &ram_list.blocks, next) { ram_addr_t end, next = ULONG_MAX; end = block->offset + block->length; QLIST_FOREACH(next_block, &ram_list.blocks, next) { if (next_block->offset >= end) { next = MIN(next, next_block->offset); } } if (next - end >= size && next - end < mingap) { offset = end; mingap = next - end; } } return offset; }
17,409
1
static void guess_dc(MpegEncContext *s, int16_t *dc, int w, int h, int stride, int is_luma) { int b_x, b_y; int16_t (*col )[4] = av_malloc(stride*h*sizeof( int16_t)*4); uint32_t (*dist)[4] = av_malloc(stride*h*sizeof(uint32_t)*4); for(b_y=0; b_y<h; b_y++){ int color= 1024; int distance= -1; for(b_x=0; b_x<w; b_x++){ int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride; int error_j= s->error_status_table[mb_index_j]; int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); if(intra_j==0 || !(error_j&ER_DC_ERROR)){ color= dc[b_x + b_y*stride]; distance= b_x; } col [b_x + b_y*stride][1]= color; dist[b_x + b_y*stride][1]= distance >= 0 ? b_x-distance : 9999; } color= 1024; distance= -1; for(b_x=w-1; b_x>=0; b_x--){ int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride; int error_j= s->error_status_table[mb_index_j]; int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); if(intra_j==0 || !(error_j&ER_DC_ERROR)){ color= dc[b_x + b_y*stride]; distance= b_x; } col [b_x + b_y*stride][0]= color; dist[b_x + b_y*stride][0]= distance >= 0 ? distance-b_x : 9999; } } for(b_x=0; b_x<w; b_x++){ int color= 1024; int distance= -1; for(b_y=0; b_y<h; b_y++){ int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride; int error_j= s->error_status_table[mb_index_j]; int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); if(intra_j==0 || !(error_j&ER_DC_ERROR)){ color= dc[b_x + b_y*stride]; distance= b_y; } col [b_x + b_y*stride][3]= color; dist[b_x + b_y*stride][3]= distance >= 0 ? b_y-distance : 9999; } color= 1024; distance= -1; for(b_y=h-1; b_y>=0; b_y--){ int mb_index_j= (b_x>>is_luma) + (b_y>>is_luma)*s->mb_stride; int error_j= s->error_status_table[mb_index_j]; int intra_j = IS_INTRA(s->current_picture.f.mb_type[mb_index_j]); if(intra_j==0 || !(error_j&ER_DC_ERROR)){ color= dc[b_x + b_y*stride]; distance= b_y; } col [b_x + b_y*stride][2]= color; dist[b_x + b_y*stride][2]= distance >= 0 ? distance-b_y : 9999; } } for (b_y = 0; b_y < h; b_y++) { for (b_x = 0; b_x < w; b_x++) { int mb_index, error, j; int64_t guess, weight_sum; mb_index = (b_x >> is_luma) + (b_y >> is_luma) * s->mb_stride; error = s->error_status_table[mb_index]; if (IS_INTER(s->current_picture.f.mb_type[mb_index])) continue; // inter if (!(error & ER_DC_ERROR)) continue; // dc-ok weight_sum = 0; guess = 0; for (j = 0; j < 4; j++) { int64_t weight = 256 * 256 * 256 * 16 / dist[b_x + b_y*stride][j]; guess += weight*(int64_t)col[b_x + b_y*stride][j]; weight_sum += weight; } guess = (guess + weight_sum / 2) / weight_sum; dc[b_x + b_y * stride] = guess; } } av_freep(&col); av_freep(&dist); }
17,410
1
Coroutine *qemu_coroutine_create(CoroutineEntry *entry) { Coroutine *co = NULL; if (CONFIG_COROUTINE_POOL) { co = QSLIST_FIRST(&alloc_pool); if (!co) { if (release_pool_size > POOL_BATCH_SIZE) { /* Slow path; a good place to register the destructor, too. */ if (!coroutine_pool_cleanup_notifier.notify) { coroutine_pool_cleanup_notifier.notify = coroutine_pool_cleanup; qemu_thread_atexit_add(&coroutine_pool_cleanup_notifier); } /* This is not exact; there could be a little skew between * release_pool_size and the actual size of release_pool. But * it is just a heuristic, it does not need to be perfect. */ alloc_pool_size = atomic_xchg(&release_pool_size, 0); QSLIST_MOVE_ATOMIC(&alloc_pool, &release_pool); co = QSLIST_FIRST(&alloc_pool); } } if (co) { QSLIST_REMOVE_HEAD(&alloc_pool, pool_next); alloc_pool_size--; } } if (!co) { co = qemu_coroutine_new(); } co->entry = entry; QSIMPLEQ_INIT(&co->co_queue_wakeup); return co; }
17,414
1
static void pxa2xx_gpio_write(void *opaque, target_phys_addr_t offset, uint32_t value) { struct pxa2xx_gpio_info_s *s = (struct pxa2xx_gpio_info_s *) opaque; int bank; offset -= s->base; if (offset >= 0x200) return; bank = pxa2xx_gpio_regs[offset].bank; switch (pxa2xx_gpio_regs[offset].reg) { case GPDR: /* GPIO Pin-Direction registers */ s->dir[bank] = value; pxa2xx_gpio_handler_update(s); break; case GPSR: /* GPIO Pin-Output Set registers */ s->olevel[bank] |= value; pxa2xx_gpio_handler_update(s); break; case GPCR: /* GPIO Pin-Output Clear registers */ s->olevel[bank] &= ~value; pxa2xx_gpio_handler_update(s); break; case GRER: /* GPIO Rising-Edge Detect Enable registers */ s->rising[bank] = value; break; case GFER: /* GPIO Falling-Edge Detect Enable registers */ s->falling[bank] = value; break; case GAFR_L: /* GPIO Alternate Function registers */ s->gafr[bank * 2] = value; break; case GAFR_U: /* GPIO Alternate Function registers */ s->gafr[bank * 2 + 1] = value; break; case GEDR: /* GPIO Edge Detect Status registers */ s->status[bank] &= ~value; pxa2xx_gpio_irq_update(s); break; default: cpu_abort(cpu_single_env, "%s: Bad offset " REG_FMT "\n", __FUNCTION__, offset); } }
17,415
1
static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr) { AVFormatContext *s = nut->avf; AVIOContext *bc = s->pb; int64_t end; uint64_t tmp; nut->last_syncpoint_pos = avio_tell(bc) - 8; end = get_packetheader(nut, bc, 1, SYNCPOINT_STARTCODE); end += avio_tell(bc); tmp = ffio_read_varlen(bc); *back_ptr = nut->last_syncpoint_pos - 16 * ffio_read_varlen(bc); if (*back_ptr < 0) return -1; ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp / nut->time_base_count); if (skip_reserved(bc, end) || ffio_get_checksum(bc)) { av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n"); return -1; } *ts = tmp / s->nb_streams * av_q2d(nut->time_base[tmp % s->nb_streams]) * AV_TIME_BASE; ff_nut_add_sp(nut, nut->last_syncpoint_pos, *back_ptr, *ts); return 0; }
17,416
1
static void coroutine_fn v9fs_flush(void *opaque) { ssize_t err; int16_t tag; size_t offset = 7; V9fsPDU *cancel_pdu; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; err = pdu_unmarshal(pdu, offset, "w", &tag); if (err < 0) { pdu_complete(pdu, err); return; } trace_v9fs_flush(pdu->tag, pdu->id, tag); QLIST_FOREACH(cancel_pdu, &s->active_list, next) { if (cancel_pdu->tag == tag) { break; } } if (cancel_pdu) { cancel_pdu->cancelled = 1; /* * Wait for pdu to complete. */ qemu_co_queue_wait(&cancel_pdu->complete, NULL); cancel_pdu->cancelled = 0; pdu_free(cancel_pdu); } pdu_complete(pdu, 7); }
17,417
1
static inline void expand_category(COOKContext *q, int *category, int *category_index) { int i; for (i = 0; i < q->num_vectors; i++) ++category[category_index[i]]; }
17,418
0
static int gif_encode_close(AVCodecContext *avctx) { GIFContext *s = avctx->priv_data; av_frame_free(&avctx->coded_frame); av_freep(&s->lzw); av_freep(&s->buf); return 0; }
17,419
0
static av_cold int vqa_decode_end(AVCodecContext *avctx) { VqaContext *s = avctx->priv_data; av_free(s->codebook); av_free(s->next_codebook_buffer); av_free(s->decode_buffer); if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); return 0; }
17,420
0
static av_cold int pam_encode_init(AVCodecContext *avctx) { 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; return 0; }
17,421
1
static int write_l2_entries(BlockDriverState *bs, uint64_t *l2_table, uint64_t l2_offset, int l2_index, int num) { int l2_start_index = l2_index & ~(L1_ENTRIES_PER_SECTOR - 1); int start_offset = (8 * l2_index) & ~511; int end_offset = (8 * (l2_index + num) + 511) & ~511; size_t len = end_offset - start_offset; int ret; BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE); ret = bdrv_pwrite(bs->file, l2_offset + start_offset, &l2_table[l2_start_index], len); if (ret < 0) { return ret; } return 0; }
17,422
1
static void FUNC(put_hevc_qpel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width) { int x, y; pixel *src = (pixel*)_src; ptrdiff_t srcstride = _srcstride / sizeof(pixel); pixel *dst = (pixel *)_dst; ptrdiff_t dststride = _dststride / sizeof(pixel); const int8_t *filter = ff_hevc_qpel_filters[mx - 1]; int shift = 14 + 1 - BIT_DEPTH; int log2Wd = denom + shift - 1; ox0 = ox0 * (1 << (BIT_DEPTH - 8)); ox1 = ox1 * (1 << (BIT_DEPTH - 8)); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 + ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1)); src += srcstride; dst += dststride; src2 += MAX_PB_SIZE; } }
17,423
1
void virtqueue_flush(VirtQueue *vq, unsigned int count) { uint16_t old, new; /* Make sure buffer is written before we update index. */ smp_wmb(); trace_virtqueue_flush(vq, count); old = vq->used_idx; new = old + count; vring_used_idx_set(vq, new); if (unlikely((int16_t)(new - vq->signalled_used) < (uint16_t)(new - old))) vq->signalled_used_valid = false;
17,424
1
static void xbr4x(AVFrame *input, AVFrame *output, const uint32_t *r2y) { const int nl = output->linesize[0]>>2; const int nl1 = nl + nl; const int nl2 = nl1 + nl; uint32_t pprev; uint32_t pprev2; int x, y; for (y = 0; y < input->height; y++) { uint32_t * E = (uint32_t *)(output->data[0] + y * output->linesize[0] * 4); /* middle. Offset of -8 is given */ uint32_t * sa2 = (uint32_t *)(input->data[0] + y * input->linesize[0] - 8); /* up one */ uint32_t * sa1 = sa2 - (input->linesize[0]>>2); /* up two */ uint32_t * sa0 = sa1 - (input->linesize[0]>>2); /* down one */ uint32_t * sa3 = sa2 + (input->linesize[0]>>2); /* down two */ uint32_t * sa4 = sa3 + (input->linesize[0]>>2); if (y <= 1) { sa0 = sa1; if (y == 0) { sa0 = sa1 = sa2; } } if (y >= input->height - 2) { sa4 = sa3; if (y == input->height - 1) { sa4 = sa3 = sa2; } } pprev = pprev2 = 2; for (x = 0; x < input->width; x++) { uint32_t B1 = sa0[2]; uint32_t PB = sa1[2]; uint32_t PE = sa2[2]; uint32_t PH = sa3[2]; uint32_t H5 = sa4[2]; uint32_t A1 = sa0[pprev]; uint32_t PA = sa1[pprev]; uint32_t PD = sa2[pprev]; uint32_t PG = sa3[pprev]; uint32_t G5 = sa4[pprev]; uint32_t A0 = sa1[pprev2]; uint32_t D0 = sa2[pprev2]; uint32_t G0 = sa3[pprev2]; uint32_t C1 = 0; uint32_t PC = 0; uint32_t PF = 0; uint32_t PI = 0; uint32_t I5 = 0; uint32_t C4 = 0; uint32_t F4 = 0; uint32_t I4 = 0; if (x >= input->width - 2) { if (x == input->width - 1) { C1 = sa0[2]; PC = sa1[2]; PF = sa2[2]; PI = sa3[2]; I5 = sa4[2]; C4 = sa1[2]; F4 = sa2[2]; I4 = sa3[2]; } else { C1 = sa0[3]; PC = sa1[3]; PF = sa2[3]; PI = sa3[3]; I5 = sa4[3]; C4 = sa1[3]; F4 = sa2[3]; I4 = sa3[3]; } } else { C1 = sa0[3]; PC = sa1[3]; PF = sa2[3]; PI = sa3[3]; I5 = sa4[3]; C4 = sa1[4]; F4 = sa2[4]; I4 = sa3[4]; } E[0] = E[1] = E[2] = E[3] = PE; E[nl] = E[nl+1] = E[nl+2] = E[nl+3] = PE; // 4, 5, 6, 7 E[nl1] = E[nl1+1] = E[nl1+2] = E[nl1+3] = PE; // 8, 9, 10, 11 E[nl2] = E[nl2+1] = E[nl2+2] = E[nl2+3] = PE; // 12, 13, 14, 15 FILT4(PE, PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, nl2+3, nl2+2, nl1+3, 3, nl+3, nl1+2, nl2+1, nl2, nl1+1, nl+2, 2, 1, nl+1, nl1, nl, 0); FILT4(PE, PC, PF, PB, PI, PA, PH, PD, PG, I4, A1, I5, H5, A0, D0, B1, C1, F4, C4, G5, G0, 3, nl+3, 2, 0, 1, nl+2, nl1+3, nl2+3, nl1+2, nl+1, nl, nl1, nl1+1,nl2+2,nl2+1,nl2); FILT4(PE, PA, PB, PD, PC, PG, PF, PH, PI, C1, G0, C4, F4, G5, H5, D0, A0, B1, A1, I4, I5, 0, 1, nl, nl2, nl1, nl+1, 2, 3, nl+2, nl1+1, nl2+1,nl2+2,nl1+2, nl+3,nl1+3,nl2+3); FILT4(PE, PG, PD, PH, PA, PI, PB, PF, PC, A0, I5, A1, B1, I4, F4, H5, G5, D0, G0, C1, C4, nl2, nl1, nl2+1, nl2+3, nl2+2, nl1+1, nl, 0, nl+1, nl1+2, nl1+3, nl+3, nl+2, 1, 2, 3); sa0 += 1; sa1 += 1; sa2 += 1; sa3 += 1; sa4 += 1; E += 4; if (pprev2){ pprev2--; pprev = 1; } } } }
17,425
1
const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){ int i, si, di; uint8_t *dst; int bufidx; // src[0]&0x80; //forbidden bit h->nal_ref_idc= src[0]>>5; h->nal_unit_type= src[0]&0x1F; src++; length--; #if HAVE_FAST_UNALIGNED # if HAVE_FAST_64BIT # define RS 7 for(i=0; i+1<length; i+=9){ if(!((~AV_RN64A(src+i) & (AV_RN64A(src+i) - 0x0100010001000101ULL)) & 0x8000800080008080ULL)) # else # define RS 3 for(i=0; i+1<length; i+=5){ if(!((~AV_RN32A(src+i) & (AV_RN32A(src+i) - 0x01000101U)) & 0x80008080U)) # endif continue; if(i>0 && !src[i]) i--; while(src[i]) i++; #else # define RS 0 for(i=0; i+1<length; i+=2){ if(src[i]) continue; if(i>0 && src[i-1]==0) i--; #endif if(i+2<length && src[i+1]==0 && src[i+2]<=3){ if(src[i+2]!=3){ /* startcode, so we must be past the end */ length=i; } break; } i-= RS; } if(i>=length-1){ //no escaped 0 *dst_length= length; *consumed= length+1; //+1 for the header return src; } bufidx = h->nal_unit_type == NAL_DPC ? 1 : 0; // use second escape buffer for inter data av_fast_malloc(&h->rbsp_buffer[bufidx], &h->rbsp_buffer_size[bufidx], length+FF_INPUT_BUFFER_PADDING_SIZE); dst= h->rbsp_buffer[bufidx]; if (dst == NULL){ return NULL; } //printf("decoding esc\n"); memcpy(dst, src, i); si=di=i; while(si+2<length){ //remove escapes (very rare 1:2^22) if(src[si+2]>3){ dst[di++]= src[si++]; dst[di++]= src[si++]; }else if(src[si]==0 && src[si+1]==0){ if(src[si+2]==3){ //escape dst[di++]= 0; dst[di++]= 0; si+=3; continue; }else //next start code goto nsc; } dst[di++]= src[si++]; } while(si<length) dst[di++]= src[si++]; nsc: memset(dst+di, 0, FF_INPUT_BUFFER_PADDING_SIZE); *dst_length= di; *consumed= si + 1;//+1 for the header //FIXME store exact number of bits in the getbitcontext (it is needed for decoding) return dst; }
17,426
1
static void dct_unquantize_mpeg2_mmx(MpegEncContext *s, DCTELEM *block, int n, int qscale) { int nCoeffs; const UINT16 *quant_matrix; if(s->alternate_scan) nCoeffs= 64; else nCoeffs= nCoeffs= zigzag_end[ s->block_last_index[n] ]; if (s->mb_intra) { int block0; if (n < 4) block0 = block[0] * s->y_dc_scale; else block0 = block[0] * s->c_dc_scale; quant_matrix = s->intra_matrix; asm volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $15, %%mm7 \n\t" "movd %2, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "movl %3, %%eax \n\t" ".balign 16\n\t" "1: \n\t" "movq (%0, %%eax), %%mm0 \n\t" "movq 8(%0, %%eax), %%mm1 \n\t" "movq (%1, %%eax), %%mm4 \n\t" "movq 8(%1, %%eax), %%mm5 \n\t" "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] "pxor %%mm2, %%mm2 \n\t" "pxor %%mm3, %%mm3 \n\t" "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*q "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*q "pxor %%mm4, %%mm4 \n\t" "pxor %%mm5, %%mm5 \n\t" // FIXME slow "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 "psraw $3, %%mm0 \n\t" "psraw $3, %%mm1 \n\t" "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm3, %%mm1 \n\t" "pandn %%mm0, %%mm4 \n\t" "pandn %%mm1, %%mm5 \n\t" "movq %%mm4, (%0, %%eax) \n\t" "movq %%mm5, 8(%0, %%eax) \n\t" "addl $16, %%eax \n\t" "js 1b \n\t" ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "g" (-2*nCoeffs) : "%eax", "memory" ); block[0]= block0; //Note, we dont do mismatch control for intra as errors cannot accumulate } else { quant_matrix = s->non_intra_matrix; asm volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psrlq $48, %%mm7 \n\t" "movd %2, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "packssdw %%mm6, %%mm6 \n\t" "movl %3, %%eax \n\t" ".balign 16\n\t" "1: \n\t" "movq (%0, %%eax), %%mm0 \n\t" "movq 8(%0, %%eax), %%mm1 \n\t" "movq (%1, %%eax), %%mm4 \n\t" "movq 8(%1, %%eax), %%mm5 \n\t" "pmullw %%mm6, %%mm4 \n\t" // q=qscale*quant_matrix[i] "pmullw %%mm6, %%mm5 \n\t" // q=qscale*quant_matrix[i] "pxor %%mm2, %%mm2 \n\t" "pxor %%mm3, %%mm3 \n\t" "pcmpgtw %%mm0, %%mm2 \n\t" // block[i] < 0 ? -1 : 0 "pcmpgtw %%mm1, %%mm3 \n\t" // block[i] < 0 ? -1 : 0 "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" // abs(block[i]) "psubw %%mm3, %%mm1 \n\t" // abs(block[i]) "paddw %%mm0, %%mm0 \n\t" // abs(block[i])*2 "paddw %%mm1, %%mm1 \n\t" // abs(block[i])*2 "pmullw %%mm4, %%mm0 \n\t" // abs(block[i])*2*q "pmullw %%mm5, %%mm1 \n\t" // abs(block[i])*2*q "paddw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q "paddw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q "pxor %%mm4, %%mm4 \n\t" "pxor %%mm5, %%mm5 \n\t" // FIXME slow "pcmpeqw (%0, %%eax), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 "pcmpeqw 8(%0, %%eax), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 "psrlw $4, %%mm0 \n\t" "psrlw $4, %%mm1 \n\t" "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm3, %%mm1 \n\t" "pandn %%mm0, %%mm4 \n\t" "pandn %%mm1, %%mm5 \n\t" "pxor %%mm4, %%mm7 \n\t" "pxor %%mm5, %%mm7 \n\t" "movq %%mm4, (%0, %%eax) \n\t" "movq %%mm5, 8(%0, %%eax) \n\t" "addl $16, %%eax \n\t" "js 1b \n\t" "movd 124(%0, %3), %%mm0 \n\t" "movq %%mm7, %%mm6 \n\t" "psrlq $32, %%mm7 \n\t" "pxor %%mm6, %%mm7 \n\t" "movq %%mm7, %%mm6 \n\t" "psrlq $16, %%mm7 \n\t" "pxor %%mm6, %%mm7 \n\t" "pslld $31, %%mm7 \n\t" "psrlq $15, %%mm7 \n\t" "pxor %%mm7, %%mm0 \n\t" "movd %%mm0, 124(%0, %3) \n\t" ::"r" (block+nCoeffs), "r"(quant_matrix+nCoeffs), "g" (qscale), "r" (-2*nCoeffs) : "%eax", "memory" ); } }
17,427
1
static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track) { int i; avio_wb32(pb, 24); /* size */ ffio_wfourcc(pb, "ACLR"); ffio_wfourcc(pb, "ACLR"); ffio_wfourcc(pb, "0001"); if (track->enc->color_range == AVCOL_RANGE_MPEG || /* Legal range (16-235) */ track->enc->color_range == AVCOL_RANGE_UNSPECIFIED) { avio_wb32(pb, 1); /* Corresponds to 709 in official encoder */ } else { /* Full range (0-255) */ avio_wb32(pb, 2); /* Corresponds to RGB in official encoder */ } avio_wb32(pb, 0); /* unknown */ avio_wb32(pb, 24); /* size */ ffio_wfourcc(pb, "APRG"); ffio_wfourcc(pb, "APRG"); ffio_wfourcc(pb, "0001"); avio_wb32(pb, 1); /* unknown */ avio_wb32(pb, 0); /* unknown */ avio_wb32(pb, 120); /* size */ ffio_wfourcc(pb, "ARES"); ffio_wfourcc(pb, "ARES"); ffio_wfourcc(pb, "0001"); avio_wb32(pb, AV_RB32(track->vos_data + 0x28)); /* dnxhd cid, some id ? */ avio_wb32(pb, track->enc->width); /* values below are based on samples created with quicktime and avid codecs */ if (track->vos_data[5] & 2) { // interlaced avio_wb32(pb, track->enc->height / 2); avio_wb32(pb, 2); /* unknown */ avio_wb32(pb, 0); /* unknown */ avio_wb32(pb, 4); /* unknown */ } else { avio_wb32(pb, track->enc->height); avio_wb32(pb, 1); /* unknown */ avio_wb32(pb, 0); /* unknown */ if (track->enc->height == 1080) avio_wb32(pb, 5); /* unknown */ else avio_wb32(pb, 6); /* unknown */ } /* padding */ for (i = 0; i < 10; i++) avio_wb64(pb, 0); /* extra padding for stsd needed */ avio_wb32(pb, 0); return 0; }
17,429
1
static qemu_irq *icp_pic_init(uint32_t base, qemu_irq parent_irq, qemu_irq parent_fiq) { icp_pic_state *s; int iomemtype; qemu_irq *qi; s = (icp_pic_state *)qemu_mallocz(sizeof(icp_pic_state)); if (!s) return NULL; qi = qemu_allocate_irqs(icp_pic_set_irq, s, 32); s->base = base; s->parent_irq = parent_irq; s->parent_fiq = parent_fiq; iomemtype = cpu_register_io_memory(0, icp_pic_readfn, icp_pic_writefn, s); cpu_register_physical_memory(base, 0x007fffff, iomemtype); /* ??? Save/restore. */ return qi; }
17,430
0
static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s, AVFrame *p) { int i, j; uint8_t *pd = p->data[0]; uint8_t *pd_last = s->last_picture.f->data[0]; uint8_t *pd_last_region = s->dispose_op == APNG_DISPOSE_OP_PREVIOUS ? s->previous_picture.f->data[0] : s->last_picture.f->data[0]; int ls = FFMIN(av_image_get_linesize(p->format, s->width, 0), s->width * s->bpp); if (s->blend_op == APNG_BLEND_OP_OVER && avctx->pix_fmt != AV_PIX_FMT_RGBA && avctx->pix_fmt != AV_PIX_FMT_ARGB) { avpriv_request_sample(avctx, "Blending with pixel format %s", av_get_pix_fmt_name(avctx->pix_fmt)); return AVERROR_PATCHWELCOME; } ff_thread_await_progress(&s->last_picture, INT_MAX, 0); if (s->dispose_op == APNG_DISPOSE_OP_PREVIOUS) ff_thread_await_progress(&s->previous_picture, INT_MAX, 0); for (j = 0; j < s->y_offset; j++) { for (i = 0; i < ls; i++) pd[i] = pd_last[i]; pd += s->image_linesize; pd_last += s->image_linesize; } if (s->dispose_op != APNG_DISPOSE_OP_BACKGROUND && s->blend_op == APNG_BLEND_OP_OVER) { uint8_t ri, gi, bi, ai; pd_last_region += s->y_offset * s->image_linesize; if (avctx->pix_fmt == AV_PIX_FMT_RGBA) { ri = 0; gi = 1; bi = 2; ai = 3; } else { ri = 3; gi = 2; bi = 1; ai = 0; } for (j = s->y_offset; j < s->y_offset + s->cur_h; j++) { for (i = 0; i < s->x_offset * s->bpp; i++) pd[i] = pd_last[i]; for (; i < (s->x_offset + s->cur_w) * s->bpp; i += s->bpp) { uint8_t alpha = pd[i+ai]; /* output = alpha * foreground + (1-alpha) * background */ switch (alpha) { case 0: pd[i+ri] = pd_last_region[i+ri]; pd[i+gi] = pd_last_region[i+gi]; pd[i+bi] = pd_last_region[i+bi]; pd[i+ai] = 0xff; break; case 255: break; default: pd[i+ri] = FAST_DIV255(alpha * pd[i+ri] + (255 - alpha) * pd_last_region[i+ri]); pd[i+gi] = FAST_DIV255(alpha * pd[i+gi] + (255 - alpha) * pd_last_region[i+gi]); pd[i+bi] = FAST_DIV255(alpha * pd[i+bi] + (255 - alpha) * pd_last_region[i+bi]); pd[i+ai] = 0xff; break; } } for (; i < ls; i++) pd[i] = pd_last[i]; pd += s->image_linesize; pd_last += s->image_linesize; pd_last_region += s->image_linesize; } } else { for (j = s->y_offset; j < s->y_offset + s->cur_h; j++) { for (i = 0; i < s->x_offset * s->bpp; i++) pd[i] = pd_last[i]; for (i = (s->x_offset + s->cur_w) * s->bpp; i < ls; i++) pd[i] = pd_last[i]; pd += s->image_linesize; pd_last += s->image_linesize; } } for (j = s->y_offset + s->cur_h; j < s->height; j++) { for (i = 0; i < ls; i++) pd[i] = pd_last[i]; pd += s->image_linesize; pd_last += s->image_linesize; } return 0; }
17,431
0
static int nprobe(AVFormatContext *s, uint8_t *enc_header, int size, const uint8_t *n_val) { OMAContext *oc = s->priv_data; uint32_t pos, taglen, datalen; struct AVDES av_des; if (!enc_header || !n_val) return -1; pos = OMA_ENC_HEADER_SIZE + oc->k_size; if (!memcmp(&enc_header[pos], "EKB ", 4)) pos += 32; if (AV_RB32(&enc_header[pos]) != oc->rid) av_log(s, AV_LOG_DEBUG, "Mismatching RID\n"); taglen = AV_RB32(&enc_header[pos+32]); datalen = AV_RB32(&enc_header[pos+36]) >> 4; if(taglen + (((uint64_t)datalen)<<4) + 44 > size) return -1; pos += 44 + taglen; av_des_init(&av_des, n_val, 192, 1); while (datalen-- > 0) { av_des_crypt(&av_des, oc->r_val, &enc_header[pos], 2, NULL, 1); kset(s, oc->r_val, NULL, 16); if (!rprobe(s, enc_header, oc->r_val)) return 0; pos += 16; } return -1; }
17,432
0
REORDER_OUT_50(int8, int8_t) REORDER_OUT_51(int8, int8_t) REORDER_OUT_71(int8, int8_t) REORDER_OUT_50(int16, int16_t) REORDER_OUT_51(int16, int16_t) REORDER_OUT_71(int16, int16_t) REORDER_OUT_50(int32, int32_t) REORDER_OUT_51(int32, int32_t) REORDER_OUT_71(int32, int32_t) REORDER_OUT_50(f32, float) REORDER_OUT_51(f32, float) REORDER_OUT_71(f32, float) #define FORMAT_I8 0 #define FORMAT_I16 1 #define FORMAT_I32 2 #define FORMAT_F32 3 #define PICK_REORDER(layout)\ switch(format) {\ case FORMAT_I8: s->reorder_func = alsa_reorder_int8_out_ ##layout; break;\ case FORMAT_I16: s->reorder_func = alsa_reorder_int16_out_ ##layout; break;\ case FORMAT_I32: s->reorder_func = alsa_reorder_int32_out_ ##layout; break;\ case FORMAT_F32: s->reorder_func = alsa_reorder_f32_out_ ##layout; break;\ } static av_cold int find_reorder_func(AlsaData *s, int codec_id, int64_t layout, int out) { int format; /* reordering input is not currently supported */ if (!out) return AVERROR(ENOSYS); /* reordering is not needed for QUAD or 2_2 layout */ if (layout == AV_CH_LAYOUT_QUAD || layout == AV_CH_LAYOUT_2_2) return 0; switch (codec_id) { case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: format = FORMAT_I8; break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: format = FORMAT_I16; break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32BE: format = FORMAT_I32; break; case CODEC_ID_PCM_F32LE: case CODEC_ID_PCM_F32BE: format = FORMAT_F32; break; default: return AVERROR(ENOSYS); } if (layout == AV_CH_LAYOUT_5POINT0_BACK || layout == AV_CH_LAYOUT_5POINT0) PICK_REORDER(50) else if (layout == AV_CH_LAYOUT_5POINT1_BACK || layout == AV_CH_LAYOUT_5POINT1) PICK_REORDER(51) else if (layout == AV_CH_LAYOUT_7POINT1) PICK_REORDER(71) return s->reorder_func ? 0 : AVERROR(ENOSYS); }
17,433
1
static inline void RENAME(rgb24ToY)(uint8_t *dst, uint8_t *src, int width) { int i; for(i=0; i<width; i++) { int r= src[i*3+0]; int g= src[i*3+1]; int b= src[i*3+2]; dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); } }
17,434
1
static void dcr_write_pob (void *opaque, int dcrn, uint32_t val) { ppc4xx_pob_t *pob; pob = opaque; switch (dcrn) { case POB0_BEAR: /* Read only */ break; case POB0_BESR0: case POB0_BESR1: /* Write-clear */ pob->besr[dcrn - POB0_BESR0] &= ~val; break; } }
17,435
1
static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW) { //FIXME Optimize (just quickly writen not opti..) int i; for(i=0; i<dstW; i++) { int val=1<<18; int j; for(j=0; j<lumFilterSize; j++) val += lumSrc[j][i] * lumFilter[j]; dest[i]= av_clip_uint8(val>>19); } if(uDest != NULL) for(i=0; i<chrDstW; i++) { int u=1<<18; int v=1<<18; int j; for(j=0; j<chrFilterSize; j++) { u += chrSrc[j][i] * chrFilter[j]; v += chrSrc[j][i + 2048] * chrFilter[j]; } uDest[i]= av_clip_uint8(u>>19); vDest[i]= av_clip_uint8(v>>19); } }
17,436
0
static int mjpeg_decode_com(MJpegDecodeContext *s) { int i; UINT8 *cbuf; /* XXX: verify len field validity */ unsigned int len = get_bits(&s->gb, 16)-2; cbuf = av_malloc(len+1); for (i = 0; i < len; i++) cbuf[i] = get_bits(&s->gb, 8); if (cbuf[i-1] == '\n') cbuf[i-1] = 0; else cbuf[i] = 0; printf("mjpeg comment: '%s'\n", cbuf); /* buggy avid, it puts EOI only at every 10th frame */ if (!strcmp(cbuf, "AVID")) { s->buggy_avid = 1; // if (s->first_picture) // printf("mjpeg: workarounding buggy AVID\n"); } av_free(cbuf); return 0; }
17,437
0
static int doTest(uint8_t *ref[4], int refStride[4], int w, int h, int srcFormat, int dstFormat, int srcW, int srcH, int dstW, int dstH, int flags){ uint8_t *src[4] = {0}; uint8_t *dst[4] = {0}; uint8_t *out[4] = {0}; int srcStride[4], dstStride[4]; int i; uint64_t ssdY, ssdU, ssdV, ssdA=0; struct SwsContext *srcContext = NULL, *dstContext = NULL, *outContext = NULL; int res; res = 0; for (i=0; i<4; i++){ // avoid stride % bpp != 0 if (srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24) srcStride[i]= srcW*3; else if (srcFormat==PIX_FMT_RGB48BE || srcFormat==PIX_FMT_RGB48LE) srcStride[i]= srcW*6; else srcStride[i]= srcW*4; if (dstFormat==PIX_FMT_RGB24 || dstFormat==PIX_FMT_BGR24) dstStride[i]= dstW*3; else if (dstFormat==PIX_FMT_RGB48BE || dstFormat==PIX_FMT_RGB48LE) dstStride[i]= dstW*6; else dstStride[i]= dstW*4; src[i]= (uint8_t*) malloc(srcStride[i]*srcH); dst[i]= (uint8_t*) malloc(dstStride[i]*dstH); out[i]= (uint8_t*) malloc(refStride[i]*h); if (!src[i] || !dst[i] || !out[i]) { perror("Malloc"); res = -1; goto end; } } srcContext= sws_getContext(w, h, PIX_FMT_YUVA420P, srcW, srcH, srcFormat, flags, NULL, NULL, NULL); if (!srcContext) { fprintf(stderr, "Failed to get %s ---> %s\n", sws_format_name(PIX_FMT_YUVA420P), sws_format_name(srcFormat)); res = -1; goto end; } dstContext= sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL, NULL); if (!dstContext) { fprintf(stderr, "Failed to get %s ---> %s\n", sws_format_name(srcFormat), sws_format_name(dstFormat)); res = -1; goto end; } outContext= sws_getContext(dstW, dstH, dstFormat, w, h, PIX_FMT_YUVA420P, flags, NULL, NULL, NULL); if (!outContext) { fprintf(stderr, "Failed to get %s ---> %s\n", sws_format_name(dstFormat), sws_format_name(PIX_FMT_YUVA420P)); res = -1; goto end; } // printf("test %X %X %X -> %X %X %X\n", (int)ref[0], (int)ref[1], (int)ref[2], // (int)src[0], (int)src[1], (int)src[2]); sws_scale(srcContext, ref, refStride, 0, h , src, srcStride); sws_scale(dstContext, src, srcStride, 0, srcH, dst, dstStride); sws_scale(outContext, dst, dstStride, 0, dstH, out, refStride); ssdY= getSSD(ref[0], out[0], refStride[0], refStride[0], w, h); ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1); ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1); if (isALPHA(srcFormat) && isALPHA(dstFormat)) ssdA= getSSD(ref[3], out[3], refStride[3], refStride[3], w, h); if (srcFormat == PIX_FMT_GRAY8 || dstFormat==PIX_FMT_GRAY8) ssdU=ssdV=0; //FIXME check that output is really gray ssdY/= w*h; ssdU/= w*h/4; ssdV/= w*h/4; ssdA/= w*h; printf(" %s %dx%d -> %s %4dx%4d flags=%2d SSD=%5"PRId64",%5"PRId64",%5"PRId64",%5"PRId64"\n", sws_format_name(srcFormat), srcW, srcH, sws_format_name(dstFormat), dstW, dstH, flags, ssdY, ssdU, ssdV, ssdA); fflush(stdout); end: sws_freeContext(srcContext); sws_freeContext(dstContext); sws_freeContext(outContext); for (i=0; i<4; i++){ free(src[i]); free(dst[i]); free(out[i]); } return res; }
17,438
1
static ram_addr_t get_start_block(DumpState *s) { RAMBlock *block; if (!s->has_filter) { s->block = QTAILQ_FIRST(&ram_list.blocks); return 0; } QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (block->offset >= s->begin + s->length || block->offset + block->length <= s->begin) { /* This block is out of the range */ continue; } s->block = block; if (s->begin > block->offset) { s->start = s->begin - block->offset; } else { s->start = 0; } return s->start; } return -1; }
17,440
1
static int get_cluster_table(BlockDriverState *bs, uint64_t offset, uint64_t **new_l2_table, int *new_l2_index) { BDRVQcowState *s = bs->opaque; unsigned int l1_index, l2_index; uint64_t l2_offset; uint64_t *l2_table = NULL; int ret; /* seek the the l2 offset in the l1 table */ l1_index = offset >> (s->l2_bits + s->cluster_bits); if (l1_index >= s->l1_size) { ret = qcow2_grow_l1_table(bs, l1_index + 1, false); if (ret < 0) { return ret; } } l2_offset = s->l1_table[l1_index] & L1E_OFFSET_MASK; /* seek the l2 table of the given l2 offset */ if (s->l1_table[l1_index] & QCOW_OFLAG_COPIED) { /* load the l2 table in memory */ ret = l2_load(bs, l2_offset, &l2_table); if (ret < 0) { return ret; } } else { /* First allocate a new L2 table (and do COW if needed) */ ret = l2_allocate(bs, l1_index, &l2_table); if (ret < 0) { return ret; } /* Then decrease the refcount of the old table */ if (l2_offset) { qcow2_free_clusters(bs, l2_offset, s->l2_size * sizeof(uint64_t)); } } /* find the cluster offset for the given disk offset */ l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1); *new_l2_table = l2_table; *new_l2_index = l2_index; return 0; }
17,441
1
static void gem_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) { CadenceGEMState *s = (CadenceGEMState *)opaque; uint32_t readonly; int i; DB_PRINT("offset: 0x%04x write: 0x%08x ", (unsigned)offset, (unsigned)val); offset >>= 2; /* Squash bits which are read only in write value */ val &= ~(s->regs_ro[offset]); /* Preserve (only) bits which are read only and wtc in register */ readonly = s->regs[offset] & (s->regs_ro[offset] | s->regs_w1c[offset]); /* Copy register write to backing store */ s->regs[offset] = (val & ~s->regs_w1c[offset]) | readonly; /* do w1c */ s->regs[offset] &= ~(s->regs_w1c[offset] & val); /* Handle register write side effects */ switch (offset) { case GEM_NWCTRL: if (val & GEM_NWCTRL_RXENA) { for (i = 0; i < s->num_priority_queues; ++i) { gem_get_rx_desc(s, i); } } if (val & GEM_NWCTRL_TXSTART) { gem_transmit(s); } if (!(val & GEM_NWCTRL_TXENA)) { /* Reset to start of Q when transmit disabled. */ for (i = 0; i < s->num_priority_queues; i++) { s->tx_desc_addr[i] = s->regs[GEM_TXQBASE]; } } if (gem_can_receive(qemu_get_queue(s->nic))) { qemu_flush_queued_packets(qemu_get_queue(s->nic)); } break; case GEM_TXSTATUS: gem_update_int_status(s); break; case GEM_RXQBASE: s->rx_desc_addr[0] = val; break; case GEM_RECEIVE_Q1_PTR ... GEM_RECEIVE_Q15_PTR: s->rx_desc_addr[offset - GEM_RECEIVE_Q1_PTR + 1] = val; break; case GEM_TXQBASE: s->tx_desc_addr[0] = val; break; case GEM_TRANSMIT_Q1_PTR ... GEM_TRANSMIT_Q15_PTR: s->tx_desc_addr[offset - GEM_TRANSMIT_Q1_PTR + 1] = val; break; case GEM_RXSTATUS: gem_update_int_status(s); break; case GEM_IER: s->regs[GEM_IMR] &= ~val; gem_update_int_status(s); break; case GEM_INT_Q1_ENABLE ... GEM_INT_Q7_ENABLE: s->regs[GEM_INT_Q1_MASK + offset - GEM_INT_Q1_ENABLE] &= ~val; gem_update_int_status(s); break; case GEM_INT_Q8_ENABLE ... GEM_INT_Q15_ENABLE: s->regs[GEM_INT_Q8_MASK + offset - GEM_INT_Q8_ENABLE] &= ~val; gem_update_int_status(s); break; case GEM_IDR: s->regs[GEM_IMR] |= val; gem_update_int_status(s); break; case GEM_INT_Q1_DISABLE ... GEM_INT_Q7_DISABLE: s->regs[GEM_INT_Q1_MASK + offset - GEM_INT_Q1_DISABLE] |= val; gem_update_int_status(s); break; case GEM_INT_Q8_DISABLE ... GEM_INT_Q15_DISABLE: s->regs[GEM_INT_Q8_MASK + offset - GEM_INT_Q8_DISABLE] |= val; gem_update_int_status(s); break; case GEM_SPADDR1LO: case GEM_SPADDR2LO: case GEM_SPADDR3LO: case GEM_SPADDR4LO: s->sar_active[(offset - GEM_SPADDR1LO) / 2] = false; break; case GEM_SPADDR1HI: case GEM_SPADDR2HI: case GEM_SPADDR3HI: case GEM_SPADDR4HI: s->sar_active[(offset - GEM_SPADDR1HI) / 2] = true; break; case GEM_PHYMNTNC: if (val & GEM_PHYMNTNC_OP_W) { uint32_t phy_addr, reg_num; phy_addr = (val & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; if (phy_addr == BOARD_PHY_ADDRESS || phy_addr == 0) { reg_num = (val & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; gem_phy_write(s, reg_num, val); } } break; } DB_PRINT("newval: 0x%08x\n", s->regs[offset]); }
17,442
1
static int16_t g726_decode(G726Context* c, int I) { int dq, re_signal, pk0, fa1, i, tr, ylint, ylfrac, thr2, al, dq0; Float11 f; int I_sig= I >> (c->code_size - 1); dq = inverse_quant(c, I); /* Transition detect */ ylint = (c->yl >> 15); ylfrac = (c->yl >> 10) & 0x1f; thr2 = (ylint > 9) ? 0x1f << 10 : (0x20 + ylfrac) << ylint; tr= (c->td == 1 && dq > ((3*thr2)>>2)); if (I_sig) /* get the sign */ dq = -dq; re_signal = (int16_t)(c->se + dq); /* Update second order predictor coefficient A2 and A1 */ pk0 = (c->sez + dq) ? sgn(c->sez + dq) : 0; dq0 = dq ? sgn(dq) : 0; if (tr) { c->a[0] = 0; c->a[1] = 0; for (i=0; i<6; i++) c->b[i] = 0; } else { /* This is a bit crazy, but it really is +255 not +256 */ fa1 = av_clip_intp2((-c->a[0]*c->pk[0]*pk0)>>5, 8); c->a[1] += 128*pk0*c->pk[1] + fa1 - (c->a[1]>>7); c->a[1] = av_clip(c->a[1], -12288, 12288); c->a[0] += 64*3*pk0*c->pk[0] - (c->a[0] >> 8); c->a[0] = av_clip(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]); for (i=0; i<6; i++) c->b[i] += 128*dq0*sgn(-c->dq[i].sign) - (c->b[i]>>8); } /* Update Dq and Sr and Pk */ c->pk[1] = c->pk[0]; c->pk[0] = pk0 ? pk0 : 1; c->sr[1] = c->sr[0]; i2f(re_signal, &c->sr[0]); for (i=5; i>0; i--) c->dq[i] = c->dq[i-1]; i2f(dq, &c->dq[0]); c->dq[0].sign = I_sig; /* Isn't it crazy ?!?! */ c->td = c->a[1] < -11776; /* Update Ap */ c->dms += (c->tbls.F[I]<<4) + ((- c->dms) >> 5); c->dml += (c->tbls.F[I]<<4) + ((- c->dml) >> 7); if (tr) c->ap = 256; else { c->ap += (-c->ap) >> 4; if (c->y <= 1535 || c->td || abs((c->dms << 2) - c->dml) >= (c->dml >> 3)) c->ap += 0x20; } /* Update Yu and Yl */ c->yu = av_clip(c->y + c->tbls.W[I] + ((-c->y)>>5), 544, 5120); c->yl += c->yu + ((-c->yl)>>6); /* Next iteration for Y */ al = (c->ap >= 256) ? 1<<6 : c->ap >> 2; c->y = (c->yl + (c->yu - (c->yl>>6))*al) >> 6; /* Next iteration for SE and SEZ */ c->se = 0; for (i=0; i<6; i++) c->se += mult(i2f(c->b[i] >> 2, &f), &c->dq[i]); c->sez = c->se >> 1; for (i=0; i<2; i++) c->se += mult(i2f(c->a[i] >> 2, &f), &c->sr[i]); c->se >>= 1; return av_clip(re_signal << 2, -0xffff, 0xffff); }
17,443
1
void pl050_init(uint32_t base, qemu_irq irq, int is_mouse) { int iomemtype; pl050_state *s; s = (pl050_state *)qemu_mallocz(sizeof(pl050_state)); iomemtype = cpu_register_io_memory(0, pl050_readfn, pl050_writefn, s); cpu_register_physical_memory(base, 0x00000fff, iomemtype); s->base = base; s->irq = irq; s->is_mouse = is_mouse; if (is_mouse) s->dev = ps2_mouse_init(pl050_update, s); else s->dev = ps2_kbd_init(pl050_update, s); /* ??? Save/restore. */ }
17,444
1
static int matroska_parse_cluster(MatroskaDemuxContext *matroska) { MatroskaCluster cluster = { 0 }; EbmlList *blocks_list; MatroskaBlock *blocks; int i, res; int64_t pos = url_ftell(matroska->ctx->pb); matroska->prev_pkt = NULL; if (matroska->has_cluster_id){ /* For the first cluster we parse, its ID was already read as part of matroska_read_header(), so don't read it again */ res = ebml_parse_id(matroska, matroska_clusters, MATROSKA_ID_CLUSTER, &cluster); pos -= 4; /* sizeof the ID which was already read */ matroska->has_cluster_id = 0; } else res = ebml_parse(matroska, matroska_clusters, &cluster); blocks_list = &cluster.blocks; blocks = blocks_list->elem; for (i=0; i<blocks_list->nb_elem; i++) if (blocks[i].bin.size > 0) { int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1; res=matroska_parse_block(matroska, blocks[i].bin.data, blocks[i].bin.size, blocks[i].bin.pos, cluster.timecode, blocks[i].duration, is_keyframe, pos); } ebml_free(matroska_cluster, &cluster); if (res < 0) matroska->done = 1; return res; }
17,445
1
static av_cold void init_mdct_win(TwinContext *tctx) { int i,j; const ModeTab *mtab = tctx->mtab; int size_s = mtab->size / mtab->fmode[FT_SHORT].sub; int size_m = mtab->size / mtab->fmode[FT_MEDIUM].sub; int channels = tctx->avctx->channels; float norm = channels == 1 ? 2. : 1.; for (i = 0; i < 3; i++) { int bsize = tctx->mtab->size/tctx->mtab->fmode[i].sub; ff_mdct_init(&tctx->mdct_ctx[i], av_log2(bsize) + 1, 1, -sqrt(norm/bsize) / (1<<15)); } tctx->tmp_buf = av_malloc(mtab->size * sizeof(*tctx->tmp_buf)); tctx->spectrum = av_malloc(2*mtab->size*channels*sizeof(float)); tctx->curr_frame = av_malloc(2*mtab->size*channels*sizeof(float)); tctx->prev_frame = av_malloc(2*mtab->size*channels*sizeof(float)); for (i = 0; i < 3; i++) { int m = 4*mtab->size/mtab->fmode[i].sub; double freq = 2*M_PI/m; tctx->cos_tabs[i] = av_malloc((m/4)*sizeof(*tctx->cos_tabs)); for (j = 0; j <= m/8; j++) tctx->cos_tabs[i][j] = cos((2*j + 1)*freq); for (j = 1; j < m/8; j++) tctx->cos_tabs[i][m/4-j] = tctx->cos_tabs[i][j]; } ff_init_ff_sine_windows(av_log2(size_m)); ff_init_ff_sine_windows(av_log2(size_s/2)); ff_init_ff_sine_windows(av_log2(mtab->size)); }
17,446
1
static MemTxResult memory_region_oldmmio_write_accessor(MemoryRegion *mr, hwaddr addr, uint64_t *value, unsigned size, unsigned shift, uint64_t mask, MemTxAttrs attrs) { uint64_t tmp; tmp = (*value >> shift) & mask; if (mr->subpage) { trace_memory_region_subpage_write(get_cpu_index(), mr, addr, tmp, size); } else if (TRACE_MEMORY_REGION_OPS_WRITE_ENABLED) { hwaddr abs_addr = memory_region_to_absolute_addr(mr, addr); trace_memory_region_ops_write(get_cpu_index(), mr, abs_addr, tmp, size); } mr->ops->old_mmio.write[ctz32(size)](mr->opaque, addr, tmp); return MEMTX_OK; }
17,450
0
static av_cold int aacPlus_encode_init(AVCodecContext *avctx) { aacPlusAudioContext *s = avctx->priv_data; aacplusEncConfiguration *aacplus_cfg; /* number of channels */ if (avctx->channels < 1 || avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed\n", avctx->channels); return -1; } s->aacplus_handle = aacplusEncOpen(avctx->sample_rate, avctx->channels, &s->samples_input, &s->max_output_bytes); if(!s->aacplus_handle) { av_log(avctx, AV_LOG_ERROR, "can't open encoder\n"); return -1; } /* check aacplus version */ aacplus_cfg = aacplusEncGetCurrentConfiguration(s->aacplus_handle); /* put the options in the configuration struct */ if(avctx->profile != FF_PROFILE_AAC_LOW && avctx->profile != FF_PROFILE_UNKNOWN) { av_log(avctx, AV_LOG_ERROR, "invalid AAC profile: %d, only LC supported\n", avctx->profile); aacplusEncClose(s->aacplus_handle); return -1; } aacplus_cfg->bitRate = avctx->bit_rate; aacplus_cfg->bandWidth = avctx->cutoff; aacplus_cfg->outputFormat = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER); aacplus_cfg->inputFormat = avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? AACPLUS_INPUT_FLOAT : AACPLUS_INPUT_16BIT; if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) { av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output format!\n"); return -1; } avctx->frame_size = s->samples_input / avctx->channels; /* Set decoder specific info */ avctx->extradata_size = 0; if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { unsigned char *buffer = NULL; unsigned long decoder_specific_info_size; if (aacplusEncGetDecoderSpecificInfo(s->aacplus_handle, &buffer, &decoder_specific_info_size) == 1) { avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE); avctx->extradata_size = decoder_specific_info_size; memcpy(avctx->extradata, buffer, avctx->extradata_size); } free(buffer); } return 0; }
17,451
0
static uint64_t get_v(ByteIOContext *bc) { uint64_t val = 0; for(; bytes_left(bc) > 0; ) { int tmp = get_byte(bc); if (tmp&0x80) val= (val<<7) + tmp - 0x80; else return (val<<7) + tmp; } return -1; }
17,453
1
static av_cold int libgsm_close(AVCodecContext *avctx) { gsm_destroy(avctx->priv_data); avctx->priv_data = NULL; return 0; }
17,455
1
static int mov_open_dref(ByteIOContext **pb, char *src, MOVDref *ref) { /* try absolute path */ if (!url_fopen(pb, ref->path, URL_RDONLY)) return 0; /* try relative path */ if (ref->nlvl_to > 0 && ref->nlvl_from > 0) { char filename[1024]; char *src_path; int i, l; /* find a source dir */ src_path = strrchr(src, '/'); if (src_path) src_path++; else src_path = src; /* find a next level down to target */ for (i = 0, l = strlen(ref->path) - 1; l >= 0; l--) if (ref->path[l] == '/') { if (i == ref->nlvl_to - 1) break; else i++; } /* compose filename if next level down to target was found */ if (i == ref->nlvl_to - 1) { memcpy(filename, src, src_path - src); filename[src_path - src] = 0; for (i = 1; i < ref->nlvl_from; i++) av_strlcat(filename, "../", 1024); av_strlcat(filename, ref->path + l + 1, 1024); if (!url_fopen(pb, filename, URL_RDONLY)) return 0; } } return AVERROR(ENOENT); };
17,456
1
FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, hwaddr ctl_addr, hwaddr data_addr) { DeviceState *dev; SysBusDevice *d; FWCfgState *s; dev = qdev_create(NULL, TYPE_FW_CFG); qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port); qdev_prop_set_uint32(dev, "data_iobase", data_port); d = SYS_BUS_DEVICE(dev); s = FW_CFG(dev); assert(!object_resolve_path(FW_CFG_PATH, NULL)); object_property_add_child(qdev_get_machine(), FW_CFG_NAME, OBJECT(s), NULL); qdev_init_nofail(dev); if (ctl_addr) { sysbus_mmio_map(d, 0, ctl_addr); } if (data_addr) { sysbus_mmio_map(d, 1, data_addr); } fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (char *)"QEMU", 4); fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC)); fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu); fw_cfg_bootsplash(s); fw_cfg_reboot(s); s->machine_ready.notify = fw_cfg_machine_ready; qemu_add_machine_init_done_notifier(&s->machine_ready); return s; }
17,459
1
void qmp_block_passwd(bool has_device, const char *device, bool has_node_name, const char *node_name, const char *password, Error **errp) { Error *local_err = NULL; BlockDriverState *bs; int err; bs = bdrv_lookup_bs(has_device ? device : NULL, has_node_name ? node_name : NULL, &local_err); if (local_err) { error_propagate(errp, local_err); return; } err = bdrv_set_key(bs, password); if (err == -EINVAL) { error_set(errp, QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs)); return; } else if (err < 0) { error_set(errp, QERR_INVALID_PASSWORD); return; } }
17,460
1
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) { int ret; switch (avctx->codec_type) { case AVMEDIA_TYPE_VIDEO: if (!frame->width) frame->width = avctx->width; if (!frame->height) frame->height = avctx->height; if (frame->format < 0) frame->format = avctx->pix_fmt; if (!frame->sample_aspect_ratio.num) frame->sample_aspect_ratio = avctx->sample_aspect_ratio; if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0) return ret; break; case AVMEDIA_TYPE_AUDIO: if (!frame->sample_rate) frame->sample_rate = avctx->sample_rate; if (frame->format < 0) frame->format = avctx->sample_fmt; if (!frame->channel_layout) { if (avctx->channel_layout) { if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) { av_log(avctx, AV_LOG_ERROR, "Inconsistent channel " "configuration.\n"); return AVERROR(EINVAL); } frame->channel_layout = avctx->channel_layout; } else { if (avctx->channels > FF_SANE_NB_CHANNELS) { av_log(avctx, AV_LOG_ERROR, "Too many channels: %d.\n", avctx->channels); return AVERROR(ENOSYS); } frame->channel_layout = av_get_default_channel_layout(avctx->channels); if (!frame->channel_layout) frame->channel_layout = (1ULL << avctx->channels) - 1; } } break; default: return AVERROR(EINVAL); } frame->pkt_pts = avctx->pkt ? avctx->pkt->pts : AV_NOPTS_VALUE; frame->reordered_opaque = avctx->reordered_opaque; #if FF_API_GET_BUFFER /* * Wrap an old get_buffer()-allocated buffer in an bunch of AVBuffers. * We wrap each plane in its own AVBuffer. Each of those has a reference to * a dummy AVBuffer as its private data, unreffing it on free. * When all the planes are freed, the dummy buffer's free callback calls * release_buffer(). */ if (avctx->get_buffer) { CompatReleaseBufPriv *priv = NULL; AVBufferRef *dummy_buf = NULL; int planes, i, ret; if (flags & AV_GET_BUFFER_FLAG_REF) frame->reference = 1; ret = avctx->get_buffer(avctx, frame); if (ret < 0) return ret; /* return if the buffers are already set up * this would happen e.g. when a custom get_buffer() calls * avcodec_default_get_buffer */ if (frame->buf[0]) return 0; priv = av_mallocz(sizeof(*priv)); if (!priv) { ret = AVERROR(ENOMEM); goto fail; } priv->avctx = *avctx; priv->frame = *frame; dummy_buf = av_buffer_create(NULL, 0, compat_free_buffer, priv, 0); if (!dummy_buf) { ret = AVERROR(ENOMEM); goto fail; } #define WRAP_PLANE(ref_out, data, data_size) \ do { \ AVBufferRef *dummy_ref = av_buffer_ref(dummy_buf); \ if (!dummy_ref) { \ ret = AVERROR(ENOMEM); \ goto fail; \ } \ ref_out = av_buffer_create(data, data_size, compat_release_buffer, \ dummy_ref, 0); \ if (!ref_out) { \ av_frame_unref(frame); \ ret = AVERROR(ENOMEM); \ goto fail; \ } \ } while (0) if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); if (!desc) { ret = AVERROR(EINVAL); goto fail; } planes = (desc->flags & PIX_FMT_PLANAR) ? desc->nb_components : 1; for (i = 0; i < planes; i++) { int h_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0; int plane_size = (frame->width >> h_shift) * frame->linesize[i]; WRAP_PLANE(frame->buf[i], frame->data[i], plane_size); } } else { int planar = av_sample_fmt_is_planar(frame->format); planes = planar ? avctx->channels : 1; if (planes > FF_ARRAY_ELEMS(frame->buf)) { frame->nb_extended_buf = planes - FF_ARRAY_ELEMS(frame->buf); frame->extended_buf = av_malloc(sizeof(*frame->extended_buf) * frame->nb_extended_buf); if (!frame->extended_buf) { ret = AVERROR(ENOMEM); goto fail; } } for (i = 0; i < FFMIN(planes, FF_ARRAY_ELEMS(frame->buf)); i++) WRAP_PLANE(frame->buf[i], frame->extended_data[i], frame->linesize[0]); for (i = 0; i < planes - FF_ARRAY_ELEMS(frame->buf); i++) WRAP_PLANE(frame->extended_buf[i], frame->extended_data[i + FF_ARRAY_ELEMS(frame->buf)], frame->linesize[0]); } av_buffer_unref(&dummy_buf); return 0; fail: avctx->release_buffer(avctx, frame); av_freep(&priv); av_buffer_unref(&dummy_buf); return ret; } #endif return avctx->get_buffer2(avctx, frame, flags); }
17,461
1
m_get(Slirp *slirp) { register struct mbuf *m; int flags = 0; DEBUG_CALL("m_get"); if (slirp->m_freelist.m_next == &slirp->m_freelist) { m = (struct mbuf *)malloc(SLIRP_MSIZE); if (m == NULL) goto end_error; slirp->mbuf_alloced++; if (slirp->mbuf_alloced > MBUF_THRESH) flags = M_DOFREE; m->slirp = slirp; } else { m = slirp->m_freelist.m_next; remque(m); } /* Insert it in the used list */ insque(m,&slirp->m_usedlist); m->m_flags = (flags | M_USEDLIST); /* Initialise it */ m->m_size = SLIRP_MSIZE - sizeof(struct m_hdr); m->m_data = m->m_dat; m->m_len = 0; m->m_nextpkt = NULL; m->m_prevpkt = NULL; end_error: DEBUG_ARG("m = %lx", (long )m); return m; }
17,462
1
uint_fast16_t float64_to_uint16_round_to_zero(float64 a STATUS_PARAM) { int64_t v; uint_fast16_t res; v = float64_to_int64_round_to_zero(a STATUS_VAR); if (v < 0) { res = 0; float_raise( float_flag_invalid STATUS_VAR); } else if (v > 0xffff) { res = 0xffff; float_raise( float_flag_invalid STATUS_VAR); } else { res = v; } return res; }
17,464
1
static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc) { uint_fast16_t cb; uint8_t *tmp_vlc_bits; uint32_t *tmp_vlc_codes; GetBitContext *gb=&vc->gb; vc->codebook_count=get_bits(gb,8)+1; AV_DEBUG(" Codebooks: %d \n", vc->codebook_count); vc->codebooks=(vorbis_codebook *)av_mallocz(vc->codebook_count * sizeof(vorbis_codebook)); tmp_vlc_bits=(uint8_t *)av_mallocz(V_MAX_VLCS * sizeof(uint8_t)); tmp_vlc_codes=(uint32_t *)av_mallocz(V_MAX_VLCS * sizeof(uint32_t)); for(cb=0;cb<vc->codebook_count;++cb) { vorbis_codebook *codebook_setup=&vc->codebooks[cb]; uint_fast8_t ordered; uint_fast32_t t, used_entries=0; uint_fast32_t entries; AV_DEBUG(" %d. Codebook \n", cb); if (get_bits(gb, 24)!=0x564342) { av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook setup data corrupt. \n", cb); goto error; } codebook_setup->dimensions=get_bits(gb, 16); if (codebook_setup->dimensions>16) { av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook's dimension is too large (%d). \n", cb, codebook_setup->dimensions); goto error; } entries=get_bits(gb, 24); if (entries>V_MAX_VLCS) { av_log(vc->avccontext, AV_LOG_ERROR, " %"PRIdFAST16". Codebook has too many entries (%"PRIdFAST32"). \n", cb, entries); goto error; } ordered=get_bits1(gb); AV_DEBUG(" codebook_dimensions %d, codebook_entries %d \n", codebook_setup->dimensions, entries); if (!ordered) { uint_fast16_t ce; uint_fast8_t flag; uint_fast8_t sparse=get_bits1(gb); AV_DEBUG(" not ordered \n"); if (sparse) { AV_DEBUG(" sparse \n"); used_entries=0; for(ce=0;ce<entries;++ce) { flag=get_bits1(gb); if (flag) { tmp_vlc_bits[ce]=get_bits(gb, 5)+1; ++used_entries; } else tmp_vlc_bits[ce]=0; } } else { AV_DEBUG(" not sparse \n"); used_entries=entries; for(ce=0;ce<entries;++ce) { tmp_vlc_bits[ce]=get_bits(gb, 5)+1; } } } else { uint_fast16_t current_entry=0; uint_fast8_t current_length=get_bits(gb, 5)+1; AV_DEBUG(" ordered, current length: %d \n", current_length); //FIXME used_entries=entries; for(;current_entry<used_entries;++current_length) { uint_fast16_t i, number; AV_DEBUG(" number bits: %d ", ilog(entries - current_entry)); number=get_bits(gb, ilog(entries - current_entry)); AV_DEBUG(" number: %d \n", number); for(i=current_entry;i<number+current_entry;++i) { if (i<used_entries) tmp_vlc_bits[i]=current_length; } current_entry+=number; } if (current_entry>used_entries) { av_log(vc->avccontext, AV_LOG_ERROR, " More codelengths than codes in codebook. \n"); goto error; } } codebook_setup->lookup_type=get_bits(gb, 4); AV_DEBUG(" lookup type: %d : %s \n", codebook_setup->lookup_type, codebook_setup->lookup_type ? "vq" : "no lookup" ); // If the codebook is used for (inverse) VQ, calculate codevectors. if (codebook_setup->lookup_type==1) { uint_fast16_t i, j, k; uint_fast16_t codebook_lookup_values=ff_vorbis_nth_root(entries, codebook_setup->dimensions); uint_fast16_t codebook_multiplicands[codebook_lookup_values]; float codebook_minimum_value=vorbisfloat2float(get_bits_long(gb, 32)); float codebook_delta_value=vorbisfloat2float(get_bits_long(gb, 32)); uint_fast8_t codebook_value_bits=get_bits(gb, 4)+1; uint_fast8_t codebook_sequence_p=get_bits1(gb); AV_DEBUG(" We expect %d numbers for building the codevectors. \n", codebook_lookup_values); AV_DEBUG(" delta %f minmum %f \n", codebook_delta_value, codebook_minimum_value); for(i=0;i<codebook_lookup_values;++i) { codebook_multiplicands[i]=get_bits(gb, codebook_value_bits); AV_DEBUG(" multiplicands*delta+minmum : %e \n", (float)codebook_multiplicands[i]*codebook_delta_value+codebook_minimum_value); AV_DEBUG(" multiplicand %d \n", codebook_multiplicands[i]); } // Weed out unused vlcs and build codevector vector codebook_setup->codevectors=(float *)av_mallocz(used_entries*codebook_setup->dimensions * sizeof(float)); for(j=0, i=0;i<entries;++i) { uint_fast8_t dim=codebook_setup->dimensions; if (tmp_vlc_bits[i]) { float last=0.0; uint_fast32_t lookup_offset=i; #ifdef V_DEBUG av_log(vc->avccontext, AV_LOG_INFO, "Lookup offset %d ,", i); #endif for(k=0;k<dim;++k) { uint_fast32_t multiplicand_offset = lookup_offset % codebook_lookup_values; codebook_setup->codevectors[j*dim+k]=codebook_multiplicands[multiplicand_offset]*codebook_delta_value+codebook_minimum_value+last; if (codebook_sequence_p) { last=codebook_setup->codevectors[j*dim+k]; } lookup_offset/=codebook_lookup_values; } tmp_vlc_bits[j]=tmp_vlc_bits[i]; #ifdef V_DEBUG av_log(vc->avccontext, AV_LOG_INFO, "real lookup offset %d, vector: ", j); for(k=0;k<dim;++k) { av_log(vc->avccontext, AV_LOG_INFO, " %f ", codebook_setup->codevectors[j*dim+k]); } av_log(vc->avccontext, AV_LOG_INFO, "\n"); #endif ++j; } } if (j!=used_entries) { av_log(vc->avccontext, AV_LOG_ERROR, "Bug in codevector vector building code. \n"); goto error; } entries=used_entries; } else if (codebook_setup->lookup_type>=2) { av_log(vc->avccontext, AV_LOG_ERROR, "Codebook lookup type not supported. \n"); goto error; } // Initialize VLC table if (ff_vorbis_len2vlc(tmp_vlc_bits, tmp_vlc_codes, entries)) { av_log(vc->avccontext, AV_LOG_ERROR, " Invalid code lengths while generating vlcs. \n"); goto error; } codebook_setup->maxdepth=0; for(t=0;t<entries;++t) if (tmp_vlc_bits[t]>=codebook_setup->maxdepth) codebook_setup->maxdepth=tmp_vlc_bits[t]; if(codebook_setup->maxdepth > 3*V_NB_BITS) codebook_setup->nb_bits=V_NB_BITS2; else codebook_setup->nb_bits=V_NB_BITS; codebook_setup->maxdepth=(codebook_setup->maxdepth+codebook_setup->nb_bits-1)/codebook_setup->nb_bits; if (init_vlc(&codebook_setup->vlc, codebook_setup->nb_bits, entries, tmp_vlc_bits, sizeof(*tmp_vlc_bits), sizeof(*tmp_vlc_bits), tmp_vlc_codes, sizeof(*tmp_vlc_codes), sizeof(*tmp_vlc_codes), INIT_VLC_LE)) { av_log(vc->avccontext, AV_LOG_ERROR, " Error generating vlc tables. \n"); goto error; } } av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); return 0; // Error: error: av_free(tmp_vlc_bits); av_free(tmp_vlc_codes); return 1; }
17,465
1
static int load_input_picture(MpegEncContext *s, const AVFrame *pic_arg) { Picture *pic = NULL; int64_t pts; int i, display_picture_number = 0, ret; int encoding_delay = s->max_b_frames ? s->max_b_frames : (s->low_delay ? 0 : 1); int flush_offset = 1; int direct = 1; if (pic_arg) { pts = pic_arg->pts; display_picture_number = s->input_picture_number++; if (pts != AV_NOPTS_VALUE) { if (s->user_specified_pts != AV_NOPTS_VALUE) { int64_t last = s->user_specified_pts; if (pts <= last) { av_log(s->avctx, AV_LOG_ERROR, "Invalid pts (%"PRId64") <= last (%"PRId64")\n", pts, last); return AVERROR(EINVAL); } if (!s->low_delay && display_picture_number == 1) s->dts_delta = pts - last; } s->user_specified_pts = pts; } else { if (s->user_specified_pts != AV_NOPTS_VALUE) { s->user_specified_pts = pts = s->user_specified_pts + 1; av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%"PRId64")\n", pts); } else { pts = display_picture_number; } } if (!pic_arg->buf[0] || pic_arg->linesize[0] != s->linesize || pic_arg->linesize[1] != s->uvlinesize || pic_arg->linesize[2] != s->uvlinesize) direct = 0; if ((s->width & 15) || (s->height & 15)) direct = 0; if (((intptr_t)(pic_arg->data[0])) & (STRIDE_ALIGN-1)) direct = 0; if (s->linesize & (STRIDE_ALIGN-1)) direct = 0; ff_dlog(s->avctx, "%d %d %"PTRDIFF_SPECIFIER" %"PTRDIFF_SPECIFIER"\n", pic_arg->linesize[0], pic_arg->linesize[1], s->linesize, s->uvlinesize); i = ff_find_unused_picture(s->avctx, s->picture, direct); if (i < 0) return i; pic = &s->picture[i]; pic->reference = 3; if (direct) { if ((ret = av_frame_ref(pic->f, pic_arg)) < 0) return ret; } ret = alloc_picture(s, pic, direct); if (ret < 0) return ret; if (!direct) { if (pic->f->data[0] + INPLACE_OFFSET == pic_arg->data[0] && pic->f->data[1] + INPLACE_OFFSET == pic_arg->data[1] && pic->f->data[2] + INPLACE_OFFSET == pic_arg->data[2]) { // empty } else { int h_chroma_shift, v_chroma_shift; av_pix_fmt_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift); for (i = 0; i < 3; i++) { int src_stride = pic_arg->linesize[i]; int dst_stride = i ? s->uvlinesize : s->linesize; int h_shift = i ? h_chroma_shift : 0; int v_shift = i ? v_chroma_shift : 0; int w = s->width >> h_shift; int h = s->height >> v_shift; uint8_t *src = pic_arg->data[i]; uint8_t *dst = pic->f->data[i]; int vpad = 16; if ( s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence && FFALIGN(s->height, 32) - s->height > 16) vpad = 32; if (!s->avctx->rc_buffer_size) dst += INPLACE_OFFSET; if (src_stride == dst_stride) memcpy(dst, src, src_stride * h); else { int h2 = h; uint8_t *dst2 = dst; while (h2--) { memcpy(dst2, src, w); dst2 += dst_stride; src += src_stride; } } if ((s->width & 15) || (s->height & (vpad-1))) { s->mpvencdsp.draw_edges(dst, dst_stride, w, h, 16 >> h_shift, vpad >> v_shift, EDGE_BOTTOM); } } } } ret = av_frame_copy_props(pic->f, pic_arg); if (ret < 0) return ret; pic->f->display_picture_number = display_picture_number; pic->f->pts = pts; // we set this here to avoid modifying pic_arg } else { /* Flushing: When we have not received enough input frames, * ensure s->input_picture[0] contains the first picture */ for (flush_offset = 0; flush_offset < encoding_delay + 1; flush_offset++) if (s->input_picture[flush_offset]) break; if (flush_offset <= 1) flush_offset = 1; else encoding_delay = encoding_delay - flush_offset + 1; } /* shift buffer entries */ for (i = flush_offset; i < MAX_PICTURE_COUNT /*s->encoding_delay + 1*/; i++) s->input_picture[i - flush_offset] = s->input_picture[i]; s->input_picture[encoding_delay] = (Picture*) pic; return 0; }
17,466