id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
func_clean
stringlengths
26
131k
vul_lines
dict
normalized_func
stringlengths
24
132k
lines
sequencelengths
1
2.8k
label
sequencelengths
1
2.8k
line_no
sequencelengths
1
2.8k
376
static int http_receive_data(HTTPContext *c) { int len; HTTPContext *c1; if (c->buffer_ptr >= c->buffer_end) { FFStream *feed = c->stream; /* a packet has been received : write it in the store, except if header */ if (c->data_count > FFM_PACKET_SIZE) { // printf("writing pos=0x%Lx size=0x%Lx\n", feed->feed_write_index, feed->feed_size); /* XXX: use llseek or url_seek */ lseek(c->feed_fd, feed->feed_write_index, SEEK_SET); write(c->feed_fd, c->buffer, FFM_PACKET_SIZE); feed->feed_write_index += FFM_PACKET_SIZE; /* update file size */ if (feed->feed_write_index > c->stream->feed_size) feed->feed_size = feed->feed_write_index; /* handle wrap around if max file size reached */ if (feed->feed_write_index >= c->stream->feed_max_size) feed->feed_write_index = FFM_PACKET_SIZE; /* write index */ ffm_write_write_index(c->feed_fd, feed->feed_write_index); /* wake up any waiting connections */ for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { if (c1->state == HTTPSTATE_WAIT_FEED && c1->stream->feed == c->stream->feed) { c1->state = HTTPSTATE_SEND_DATA; } } } else { /* We have a header in our hands that contains useful data */ AVFormatContext s; ByteIOContext *pb = &s.pb; int i; memset(&s, 0, sizeof(s)); url_open_buf(pb, c->buffer, c->buffer_end - c->buffer, URL_RDONLY); pb->buf_end = c->buffer_end; /* ?? */ pb->is_streamed = 1; if (feed->fmt->read_header(&s, 0) < 0) { goto fail; } /* Now we have the actual streams */ if (s.nb_streams != feed->nb_streams) { goto fail; } for (i = 0; i < s.nb_streams; i++) { memcpy(&feed->streams[i]->codec, &s.streams[i]->codec, sizeof(AVCodecContext)); } } c->buffer_ptr = c->buffer; } len = read(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { /* error : close connection */ goto fail; } } else if (len == 0) { /* end of connection : close it */ goto fail; } else { c->buffer_ptr += len; c->data_count += len; } return 0; fail: c->stream->feed_opened = 0; close(c->feed_fd); return -1; }
true
FFmpeg
a6e14edde01bafbbe54f6f451efa718a48975b47
static int http_receive_data(HTTPContext *c) { int len; HTTPContext *c1; if (c->buffer_ptr >= c->buffer_end) { FFStream *feed = c->stream; if (c->data_count > FFM_PACKET_SIZE) { lseek(c->feed_fd, feed->feed_write_index, SEEK_SET); write(c->feed_fd, c->buffer, FFM_PACKET_SIZE); feed->feed_write_index += FFM_PACKET_SIZE; if (feed->feed_write_index > c->stream->feed_size) feed->feed_size = feed->feed_write_index; if (feed->feed_write_index >= c->stream->feed_max_size) feed->feed_write_index = FFM_PACKET_SIZE; ffm_write_write_index(c->feed_fd, feed->feed_write_index); for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { if (c1->state == HTTPSTATE_WAIT_FEED && c1->stream->feed == c->stream->feed) { c1->state = HTTPSTATE_SEND_DATA; } } } else { AVFormatContext s; ByteIOContext *pb = &s.pb; int i; memset(&s, 0, sizeof(s)); url_open_buf(pb, c->buffer, c->buffer_end - c->buffer, URL_RDONLY); pb->buf_end = c->buffer_end; pb->is_streamed = 1; if (feed->fmt->read_header(&s, 0) < 0) { goto fail; } if (s.nb_streams != feed->nb_streams) { goto fail; } for (i = 0; i < s.nb_streams; i++) { memcpy(&feed->streams[i]->codec, &s.streams[i]->codec, sizeof(AVCodecContext)); } } c->buffer_ptr = c->buffer; } len = read(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr); if (len < 0) { if (errno != EAGAIN && errno != EINTR) { goto fail; } } else if (len == 0) { goto fail; } else { c->buffer_ptr += len; c->data_count += len; } return 0; fail: c->stream->feed_opened = 0; close(c->feed_fd); return -1; }
{ "code": [ " int len;", " len = read(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr);", " if (len < 0) {", " if (errno != EAGAIN && errno != EINTR) {", " goto fail;", " } else if (len == 0) {", " goto fail;", " } else {", " c->buffer_ptr += len;", " c->data_count += len;" ], "line_no": [ 5, 125, 127, 129, 133, 137, 141, 143, 145, 147 ] }
static int FUNC_0(HTTPContext *VAR_0) { int VAR_1; HTTPContext *c1; if (VAR_0->buffer_ptr >= VAR_0->buffer_end) { FFStream *feed = VAR_0->stream; if (VAR_0->data_count > FFM_PACKET_SIZE) { lseek(VAR_0->feed_fd, feed->feed_write_index, SEEK_SET); write(VAR_0->feed_fd, VAR_0->buffer, FFM_PACKET_SIZE); feed->feed_write_index += FFM_PACKET_SIZE; if (feed->feed_write_index > VAR_0->stream->feed_size) feed->feed_size = feed->feed_write_index; if (feed->feed_write_index >= VAR_0->stream->feed_max_size) feed->feed_write_index = FFM_PACKET_SIZE; ffm_write_write_index(VAR_0->feed_fd, feed->feed_write_index); for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { if (c1->state == HTTPSTATE_WAIT_FEED && c1->stream->feed == VAR_0->stream->feed) { c1->state = HTTPSTATE_SEND_DATA; } } } else { AVFormatContext s; ByteIOContext *pb = &s.pb; int VAR_2; memset(&s, 0, sizeof(s)); url_open_buf(pb, VAR_0->buffer, VAR_0->buffer_end - VAR_0->buffer, URL_RDONLY); pb->buf_end = VAR_0->buffer_end; pb->is_streamed = 1; if (feed->fmt->read_header(&s, 0) < 0) { goto fail; } if (s.nb_streams != feed->nb_streams) { goto fail; } for (VAR_2 = 0; VAR_2 < s.nb_streams; VAR_2++) { memcpy(&feed->streams[VAR_2]->codec, &s.streams[VAR_2]->codec, sizeof(AVCodecContext)); } } VAR_0->buffer_ptr = VAR_0->buffer; } VAR_1 = read(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr); if (VAR_1 < 0) { if (errno != EAGAIN && errno != EINTR) { goto fail; } } else if (VAR_1 == 0) { goto fail; } else { VAR_0->buffer_ptr += VAR_1; VAR_0->data_count += VAR_1; } return 0; fail: VAR_0->stream->feed_opened = 0; close(VAR_0->feed_fd); return -1; }
[ "static int FUNC_0(HTTPContext *VAR_0)\n{", "int VAR_1;", "HTTPContext *c1;", "if (VAR_0->buffer_ptr >= VAR_0->buffer_end) {", "FFStream *feed = VAR_0->stream;", "if (VAR_0->data_count > FFM_PACKET_SIZE) {", "lseek(VAR_0->feed_fd, feed->feed_write_index, SEEK_SET);", "write(VAR_0->feed_fd, VAR_0->buffer, FFM_PACKET_SIZE);", "feed->feed_write_index += FFM_PACKET_SIZE;", "if (feed->feed_write_index > VAR_0->stream->feed_size)\nfeed->feed_size = feed->feed_write_index;", "if (feed->feed_write_index >= VAR_0->stream->feed_max_size)\nfeed->feed_write_index = FFM_PACKET_SIZE;", "ffm_write_write_index(VAR_0->feed_fd, feed->feed_write_index);", "for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) {", "if (c1->state == HTTPSTATE_WAIT_FEED &&\nc1->stream->feed == VAR_0->stream->feed) {", "c1->state = HTTPSTATE_SEND_DATA;", "}", "}", "} else {", "AVFormatContext s;", "ByteIOContext *pb = &s.pb;", "int VAR_2;", "memset(&s, 0, sizeof(s));", "url_open_buf(pb, VAR_0->buffer, VAR_0->buffer_end - VAR_0->buffer, URL_RDONLY);", "pb->buf_end = VAR_0->buffer_end;", "pb->is_streamed = 1;", "if (feed->fmt->read_header(&s, 0) < 0) {", "goto fail;", "}", "if (s.nb_streams != feed->nb_streams) {", "goto fail;", "}", "for (VAR_2 = 0; VAR_2 < s.nb_streams; VAR_2++) {", "memcpy(&feed->streams[VAR_2]->codec, &s.streams[VAR_2]->codec, sizeof(AVCodecContext));", "}", "}", "VAR_0->buffer_ptr = VAR_0->buffer;", "}", "VAR_1 = read(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr);", "if (VAR_1 < 0) {", "if (errno != EAGAIN && errno != EINTR) {", "goto fail;", "}", "} else if (VAR_1 == 0) {", "goto fail;", "} else {", "VAR_0->buffer_ptr += VAR_1;", "VAR_0->data_count += VAR_1;", "}", "return 0;", "fail:\nVAR_0->stream->feed_opened = 0;", "close(VAR_0->feed_fd);", "return -1;", "}" ]
[ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 19 ], [ 27 ], [ 29 ], [ 33 ], [ 37, 39 ], [ 45, 47 ], [ 53 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 135 ], [ 137 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153, 155 ], [ 157 ], [ 159 ], [ 161 ] ]
377
static int stellaris_sys_init(uint32_t base, qemu_irq irq, stellaris_board_info * board, uint8_t *macaddr) { ssys_state *s; s = (ssys_state *)g_malloc0(sizeof(ssys_state)); s->irq = irq; s->board = board; /* Most devices come preprogrammed with a MAC address in the user data. */ s->user0 = macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16); s->user1 = macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16); memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000); memory_region_add_subregion(get_system_memory(), base, &s->iomem); ssys_reset(s); vmstate_register(NULL, -1, &vmstate_stellaris_sys, s); return 0; }
true
qemu
b45c03f585ea9bb1af76c73e82195418c294919d
static int stellaris_sys_init(uint32_t base, qemu_irq irq, stellaris_board_info * board, uint8_t *macaddr) { ssys_state *s; s = (ssys_state *)g_malloc0(sizeof(ssys_state)); s->irq = irq; s->board = board; s->user0 = macaddr[0] | (macaddr[1] << 8) | (macaddr[2] << 16); s->user1 = macaddr[3] | (macaddr[4] << 8) | (macaddr[5] << 16); memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000); memory_region_add_subregion(get_system_memory(), base, &s->iomem); ssys_reset(s); vmstate_register(NULL, -1, &vmstate_stellaris_sys, s); return 0; }
{ "code": [ " s = (ssys_state *)g_malloc0(sizeof(ssys_state));" ], "line_no": [ 13 ] }
static int FUNC_0(uint32_t VAR_0, qemu_irq VAR_1, stellaris_board_info * VAR_2, uint8_t *VAR_3) { ssys_state *s; s = (ssys_state *)g_malloc0(sizeof(ssys_state)); s->VAR_1 = VAR_1; s->VAR_2 = VAR_2; s->user0 = VAR_3[0] | (VAR_3[1] << 8) | (VAR_3[2] << 16); s->user1 = VAR_3[3] | (VAR_3[4] << 8) | (VAR_3[5] << 16); memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, "ssys", 0x00001000); memory_region_add_subregion(get_system_memory(), VAR_0, &s->iomem); ssys_reset(s); vmstate_register(NULL, -1, &vmstate_stellaris_sys, s); return 0; }
[ "static int FUNC_0(uint32_t VAR_0, qemu_irq VAR_1,\nstellaris_board_info * VAR_2,\nuint8_t *VAR_3)\n{", "ssys_state *s;", "s = (ssys_state *)g_malloc0(sizeof(ssys_state));", "s->VAR_1 = VAR_1;", "s->VAR_2 = VAR_2;", "s->user0 = VAR_3[0] | (VAR_3[1] << 8) | (VAR_3[2] << 16);", "s->user1 = VAR_3[3] | (VAR_3[4] << 8) | (VAR_3[5] << 16);", "memory_region_init_io(&s->iomem, NULL, &ssys_ops, s, \"ssys\", 0x00001000);", "memory_region_add_subregion(get_system_memory(), VAR_0, &s->iomem);", "ssys_reset(s);", "vmstate_register(NULL, -1, &vmstate_stellaris_sys, s);", "return 0;", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ] ]
379
static int kvm_recommended_vcpus(KVMState *s) { int ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS); return (ret) ? ret : 4; }
true
qemu
11748ba72ea4fc03e975aa5f5d876b5b0902e356
static int kvm_recommended_vcpus(KVMState *s) { int ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS); return (ret) ? ret : 4; }
{ "code": [ " int ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);" ], "line_no": [ 5 ] }
static int FUNC_0(KVMState *VAR_0) { int VAR_1 = kvm_check_extension(VAR_0, KVM_CAP_NR_VCPUS); return (VAR_1) ? VAR_1 : 4; }
[ "static int FUNC_0(KVMState *VAR_0)\n{", "int VAR_1 = kvm_check_extension(VAR_0, KVM_CAP_NR_VCPUS);", "return (VAR_1) ? VAR_1 : 4;", "}" ]
[ 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
380
static void reschedule_dma(void *opaque) { DMAAIOCB *dbs = (DMAAIOCB *)opaque; qemu_bh_delete(dbs->bh); dbs->bh = NULL; dma_bdrv_cb(opaque, 0); }
true
qemu
c3adb5b9168a57790b5074489b6f0275ac3cc8b5
static void reschedule_dma(void *opaque) { DMAAIOCB *dbs = (DMAAIOCB *)opaque; qemu_bh_delete(dbs->bh); dbs->bh = NULL; dma_bdrv_cb(opaque, 0); }
{ "code": [ " dma_bdrv_cb(opaque, 0);" ], "line_no": [ 13 ] }
static void FUNC_0(void *VAR_0) { DMAAIOCB *dbs = (DMAAIOCB *)VAR_0; qemu_bh_delete(dbs->bh); dbs->bh = NULL; dma_bdrv_cb(VAR_0, 0); }
[ "static void FUNC_0(void *VAR_0)\n{", "DMAAIOCB *dbs = (DMAAIOCB *)VAR_0;", "qemu_bh_delete(dbs->bh);", "dbs->bh = NULL;", "dma_bdrv_cb(VAR_0, 0);", "}" ]
[ 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
381
static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { ADPCMContext *c = avctx->priv_data; ADPCMChannelStatus *cs; int n, m, channel, i; int block_predictor[2]; short *samples; short *samples_end; uint8_t *src; int st; /* stereo */ /* DK3 ADPCM accounting variables */ unsigned char last_byte = 0; unsigned char nibble; int decode_top_nibble_next = 0; int diff_channel; /* EA ADPCM state variables */ uint32_t samples_in_chunk; int32_t previous_left_sample, previous_right_sample; int32_t current_left_sample, current_right_sample; int32_t next_left_sample, next_right_sample; int32_t coeff1l, coeff2l, coeff1r, coeff2r; uint8_t shift_left, shift_right; int count1, count2; if (!buf_size) return 0; //should protect all 4bit ADPCM variants //8 is needed for CODEC_ID_ADPCM_IMA_WAV with 2 channels // if(*data_size/4 < buf_size + 8) return -1; samples = data; samples_end= samples + *data_size/2; *data_size= 0; src = buf; st = avctx->channels == 2 ? 1 : 0; switch(avctx->codec->id) { case CODEC_ID_ADPCM_IMA_QT: n = (buf_size - 2);/* >> 2*avctx->channels;*/ channel = c->channel; cs = &(c->status[channel]); /* (pppppp) (piiiiiii) */ /* Bits 15-7 are the _top_ 9 bits of the 16-bit initial predictor value */ cs->predictor = (*src++) << 8; cs->predictor |= (*src & 0x80); cs->predictor &= 0xFF80; /* sign extension */ if(cs->predictor & 0x8000) cs->predictor -= 0x10000; CLAMP_TO_SHORT(cs->predictor); cs->step_index = (*src++) & 0x7F; if (cs->step_index > 88){ av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index); cs->step_index = 88; } cs->step = step_table[cs->step_index]; if (st && channel) samples++; for(m=32; n>0 && m>0; n--, m--) { /* in QuickTime, IMA is encoded by chuncks of 34 bytes (=64 samples) */ *samples = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3); samples += avctx->channels; *samples = adpcm_ima_expand_nibble(cs, (src[0] >> 4) & 0x0F, 3); samples += avctx->channels; src ++; } if(st) { /* handle stereo interlacing */ c->channel = (channel + 1) % 2; /* we get one packet for left, then one for right data */ if(channel == 1) { /* wait for the other packet before outputing anything */ return src - buf; } } break; case CODEC_ID_ADPCM_IMA_WAV: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; // samples_per_block= (block_align-4*chanels)*8 / (bits_per_sample * chanels) + 1; for(i=0; i<avctx->channels; i++){ cs = &(c->status[i]); cs->predictor = (int16_t)(src[0] + (src[1]<<8)); src+=2; // XXX: is this correct ??: *samples++ = cs->predictor; cs->step_index = *src++; if (cs->step_index > 88){ av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index); cs->step_index = 88; } if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null but is %d!!\n", src[-1]); /* unused */ } while(src < buf + buf_size){ for(m=0; m<4; m++){ for(i=0; i<=st; i++) *samples++ = adpcm_ima_expand_nibble(&c->status[i], src[4*i] & 0x0F, 3); for(i=0; i<=st; i++) *samples++ = adpcm_ima_expand_nibble(&c->status[i], src[4*i] >> 4 , 3); src++; } src += 4*st; } break; case CODEC_ID_ADPCM_4XM: cs = &(c->status[0]); c->status[0].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2; if(st){ c->status[1].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2; } c->status[0].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2; if(st){ c->status[1].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2; } if (cs->step_index < 0) cs->step_index = 0; if (cs->step_index > 88) cs->step_index = 88; m= (buf_size - (src - buf))>>st; for(i=0; i<m; i++) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] & 0x0F, 4); if (st) *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] & 0x0F, 4); *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] >> 4, 4); if (st) *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] >> 4, 4); } src += m<<st; break; case CODEC_ID_ADPCM_MS: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; n = buf_size - 7 * avctx->channels; if (n < 0) return -1; block_predictor[0] = av_clip(*src++, 0, 7); block_predictor[1] = 0; if (st) block_predictor[1] = av_clip(*src++, 0, 7); c->status[0].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; if (st){ c->status[1].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; } c->status[0].coeff1 = AdaptCoeff1[block_predictor[0]]; c->status[0].coeff2 = AdaptCoeff2[block_predictor[0]]; c->status[1].coeff1 = AdaptCoeff1[block_predictor[1]]; c->status[1].coeff2 = AdaptCoeff2[block_predictor[1]]; c->status[0].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; if (st) c->status[1].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); if (st) src+=2; c->status[0].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; if (st) c->status[1].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); if (st) src+=2; *samples++ = c->status[0].sample1; if (st) *samples++ = c->status[1].sample1; *samples++ = c->status[0].sample2; if (st) *samples++ = c->status[1].sample2; for(;n>0;n--) { *samples++ = adpcm_ms_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); *samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F); src ++; } break; case CODEC_ID_ADPCM_IMA_DK4: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; c->status[0].predictor = (int16_t)(src[0] | (src[1] << 8)); c->status[0].step_index = src[2]; src += 4; *samples++ = c->status[0].predictor; if (st) { c->status[1].predictor = (int16_t)(src[0] | (src[1] << 8)); c->status[1].step_index = src[2]; src += 4; *samples++ = c->status[1].predictor; } while (src < buf + buf_size) { /* take care of the top nibble (always left or mono channel) */ *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); /* take care of the bottom nibble, which is right sample for * stereo, or another mono sample */ if (st) *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[0] & 0x0F, 3); else *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F, 3); src++; } break; case CODEC_ID_ADPCM_IMA_DK3: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; if(buf_size + 16 > (samples_end - samples)*3/8) return -1; c->status[0].predictor = (int16_t)(src[10] | (src[11] << 8)); c->status[1].predictor = (int16_t)(src[12] | (src[13] << 8)); c->status[0].step_index = src[14]; c->status[1].step_index = src[15]; /* sign extend the predictors */ src += 16; diff_channel = c->status[1].predictor; /* the DK3_GET_NEXT_NIBBLE macro issues the break statement when * the buffer is consumed */ while (1) { /* for this algorithm, c->status[0] is the sum channel and * c->status[1] is the diff channel */ /* process the first predictor of the sum channel */ DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[0], nibble, 3); /* process the diff channel predictor */ DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[1], nibble, 3); /* process the first pair of stereo PCM samples */ diff_channel = (diff_channel + c->status[1].predictor) / 2; *samples++ = c->status[0].predictor + c->status[1].predictor; *samples++ = c->status[0].predictor - c->status[1].predictor; /* process the second predictor of the sum channel */ DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[0], nibble, 3); /* process the second pair of stereo PCM samples */ diff_channel = (diff_channel + c->status[1].predictor) / 2; *samples++ = c->status[0].predictor + c->status[1].predictor; *samples++ = c->status[0].predictor - c->status[1].predictor; } break; case CODEC_ID_ADPCM_IMA_WS: /* no per-block initialization; just start decoding the data */ while (src < buf + buf_size) { if (st) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[0] & 0x0F, 3); } else { *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F, 3); } src++; } break; case CODEC_ID_ADPCM_XA: c->status[0].sample1 = c->status[0].sample2 = c->status[1].sample1 = c->status[1].sample2 = 0; while (buf_size >= 128) { xa_decode(samples, src, &c->status[0], &c->status[1], avctx->channels); src += 128; samples += 28 * 8; buf_size -= 128; } break; case CODEC_ID_ADPCM_EA: samples_in_chunk = AV_RL32(src); if (samples_in_chunk >= ((buf_size - 12) * 2)) { src += buf_size; break; } src += 4; current_left_sample = (int16_t)AV_RL16(src); src += 2; previous_left_sample = (int16_t)AV_RL16(src); src += 2; current_right_sample = (int16_t)AV_RL16(src); src += 2; previous_right_sample = (int16_t)AV_RL16(src); src += 2; for (count1 = 0; count1 < samples_in_chunk/28;count1++) { coeff1l = ea_adpcm_table[(*src >> 4) & 0x0F]; coeff2l = ea_adpcm_table[((*src >> 4) & 0x0F) + 4]; coeff1r = ea_adpcm_table[*src & 0x0F]; coeff2r = ea_adpcm_table[(*src & 0x0F) + 4]; src++; shift_left = ((*src >> 4) & 0x0F) + 8; shift_right = (*src & 0x0F) + 8; src++; for (count2 = 0; count2 < 28; count2++) { next_left_sample = (((*src & 0xF0) << 24) >> shift_left); next_right_sample = (((*src & 0x0F) << 28) >> shift_right); src++; next_left_sample = (next_left_sample + (current_left_sample * coeff1l) + (previous_left_sample * coeff2l) + 0x80) >> 8; next_right_sample = (next_right_sample + (current_right_sample * coeff1r) + (previous_right_sample * coeff2r) + 0x80) >> 8; CLAMP_TO_SHORT(next_left_sample); CLAMP_TO_SHORT(next_right_sample); previous_left_sample = current_left_sample; current_left_sample = next_left_sample; previous_right_sample = current_right_sample; current_right_sample = next_right_sample; *samples++ = (unsigned short)current_left_sample; *samples++ = (unsigned short)current_right_sample; } } break; case CODEC_ID_ADPCM_IMA_SMJPEG: c->status[0].predictor = *src; src += 2; c->status[0].step_index = *src++; src++; /* skip another byte before getting to the meat */ while (src < buf + buf_size) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], *src & 0x0F, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], (*src >> 4) & 0x0F, 3); src++; } break; case CODEC_ID_ADPCM_CT: while (src < buf + buf_size) { if (st) { *samples++ = adpcm_ct_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); *samples++ = adpcm_ct_expand_nibble(&c->status[1], src[0] & 0x0F); } else { *samples++ = adpcm_ct_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); *samples++ = adpcm_ct_expand_nibble(&c->status[0], src[0] & 0x0F); } src++; } break; case CODEC_ID_ADPCM_SBPRO_4: case CODEC_ID_ADPCM_SBPRO_3: case CODEC_ID_ADPCM_SBPRO_2: if (!c->status[0].step_index) { /* the first byte is a raw sample */ *samples++ = 128 * (*src++ - 0x80); if (st) *samples++ = 128 * (*src++ - 0x80); c->status[0].step_index = 1; } if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) { while (src < buf + buf_size) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 4, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], src[0] & 0x0F, 4, 0); src++; } } else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) { while (src < buf + buf_size && samples + 2 < samples_end) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 5) & 0x07, 3, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 2) & 0x07, 3, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] & 0x03, 2, 0); src++; } } else { while (src < buf + buf_size && samples + 3 < samples_end) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 6) & 0x03, 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], (src[0] >> 4) & 0x03, 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 2) & 0x03, 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], src[0] & 0x03, 2, 2); src++; } } break; case CODEC_ID_ADPCM_SWF: { GetBitContext gb; const int *table; int k0, signmask, nb_bits; int size = buf_size*8; init_get_bits(&gb, buf, size); //read bits & inital values nb_bits = get_bits(&gb, 2)+2; //av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits); table = swf_index_tables[nb_bits-2]; k0 = 1 << (nb_bits-2); signmask = 1 << (nb_bits-1); for (i = 0; i < avctx->channels; i++) { *samples++ = c->status[i].predictor = get_sbits(&gb, 16); c->status[i].step_index = get_bits(&gb, 6); } while (get_bits_count(&gb) < size) { int i; for (i = 0; i < avctx->channels; i++) { // similar to IMA adpcm int delta = get_bits(&gb, nb_bits); int step = step_table[c->status[i].step_index]; long vpdiff = 0; // vpdiff = (delta+0.5)*step/4 int k = k0; do { if (delta & k) vpdiff += step; step >>= 1; k >>= 1; } while(k); vpdiff += step; if (delta & signmask) c->status[i].predictor -= vpdiff; else c->status[i].predictor += vpdiff; c->status[i].step_index += table[delta & (~signmask)]; c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88); c->status[i].predictor = av_clip(c->status[i].predictor, -32768, 32767); *samples++ = c->status[i].predictor; if (samples >= samples_end) { av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); return -1; } } } src += buf_size; break; } case CODEC_ID_ADPCM_YAMAHA: while (src < buf + buf_size) { if (st) { *samples++ = adpcm_yamaha_expand_nibble(&c->status[0], src[0] & 0x0F); *samples++ = adpcm_yamaha_expand_nibble(&c->status[1], (src[0] >> 4) & 0x0F); } else { *samples++ = adpcm_yamaha_expand_nibble(&c->status[0], src[0] & 0x0F); *samples++ = adpcm_yamaha_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); } src++; } break; case CODEC_ID_ADPCM_THP: { int table[2][16]; unsigned int samplecnt; int prev[2][2]; int ch; if (buf_size < 80) { av_log(avctx, AV_LOG_ERROR, "frame too small\n"); return -1; } src+=4; samplecnt = bytestream_get_be32(&src); for (i = 0; i < 32; i++) table[0][i] = (int16_t)bytestream_get_be16(&src); /* Initialize the previous sample. */ for (i = 0; i < 4; i++) prev[0][i] = (int16_t)bytestream_get_be16(&src); if (samplecnt >= (samples_end - samples) / (st + 1)) { av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); return -1; } for (ch = 0; ch <= st; ch++) { samples = (unsigned short *) data + ch; /* Read in every sample for this channel. */ for (i = 0; i < samplecnt / 14; i++) { int index = (*src >> 4) & 7; unsigned int exp = 28 - (*src++ & 15); int factor1 = table[ch][index * 2]; int factor2 = table[ch][index * 2 + 1]; /* Decode 14 samples. */ for (n = 0; n < 14; n++) { int32_t sampledat; if(n&1) sampledat= *src++ <<28; else sampledat= (*src&0xF0)<<24; *samples = ((prev[ch][0]*factor1 + prev[ch][1]*factor2) >> 11) + (sampledat>>exp); prev[ch][1] = prev[ch][0]; prev[ch][0] = *samples++; /* In case of stereo, skip one sample, this sample is for the other channel. */ samples += st; } } } /* In the previous loop, in case stereo is used, samples is increased exactly one time too often. */ samples -= st; break; } default: return -1; } *data_size = (uint8_t *)samples - (uint8_t *)data; return src - buf; }
true
FFmpeg
e457023a95e449ac2c80a49256f0611d5a8fffff
static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { ADPCMContext *c = avctx->priv_data; ADPCMChannelStatus *cs; int n, m, channel, i; int block_predictor[2]; short *samples; short *samples_end; uint8_t *src; int st; unsigned char last_byte = 0; unsigned char nibble; int decode_top_nibble_next = 0; int diff_channel; uint32_t samples_in_chunk; int32_t previous_left_sample, previous_right_sample; int32_t current_left_sample, current_right_sample; int32_t next_left_sample, next_right_sample; int32_t coeff1l, coeff2l, coeff1r, coeff2r; uint8_t shift_left, shift_right; int count1, count2; if (!buf_size) return 0; if(*data_size/4 < buf_size + 8) return -1; samples = data; samples_end= samples + *data_size/2; *data_size= 0; src = buf; st = avctx->channels == 2 ? 1 : 0; switch(avctx->codec->id) { case CODEC_ID_ADPCM_IMA_QT: n = (buf_size - 2); channel = c->channel; cs = &(c->status[channel]); cs->predictor = (*src++) << 8; cs->predictor |= (*src & 0x80); cs->predictor &= 0xFF80; if(cs->predictor & 0x8000) cs->predictor -= 0x10000; CLAMP_TO_SHORT(cs->predictor); cs->step_index = (*src++) & 0x7F; if (cs->step_index > 88){ av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index); cs->step_index = 88; } cs->step = step_table[cs->step_index]; if (st && channel) samples++; for(m=32; n>0 && m>0; n--, m--) { *samples = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3); samples += avctx->channels; *samples = adpcm_ima_expand_nibble(cs, (src[0] >> 4) & 0x0F, 3); samples += avctx->channels; src ++; } if(st) { c->channel = (channel + 1) % 2; if(channel == 1) { return src - buf; } } break; case CODEC_ID_ADPCM_IMA_WAV: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; samples_per_block= (block_align-4*chanels)*8 / (bits_per_sample * chanels) + 1; for(i=0; i<avctx->channels; i++){ cs = &(c->status[i]); cs->predictor = (int16_t)(src[0] + (src[1]<<8)); src+=2; XXX: is this correct ??: *samples++ = cs->predictor; cs->step_index = *src++; if (cs->step_index > 88){ av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index); cs->step_index = 88; } if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null but is %d!!\n", src[-1]); } while(src < buf + buf_size){ for(m=0; m<4; m++){ for(i=0; i<=st; i++) *samples++ = adpcm_ima_expand_nibble(&c->status[i], src[4*i] & 0x0F, 3); for(i=0; i<=st; i++) *samples++ = adpcm_ima_expand_nibble(&c->status[i], src[4*i] >> 4 , 3); src++; } src += 4*st; } break; case CODEC_ID_ADPCM_4XM: cs = &(c->status[0]); c->status[0].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2; if(st){ c->status[1].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2; } c->status[0].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2; if(st){ c->status[1].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2; } if (cs->step_index < 0) cs->step_index = 0; if (cs->step_index > 88) cs->step_index = 88; m= (buf_size - (src - buf))>>st; for(i=0; i<m; i++) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] & 0x0F, 4); if (st) *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] & 0x0F, 4); *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[i] >> 4, 4); if (st) *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[i+m] >> 4, 4); } src += m<<st; break; case CODEC_ID_ADPCM_MS: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; n = buf_size - 7 * avctx->channels; if (n < 0) return -1; block_predictor[0] = av_clip(*src++, 0, 7); block_predictor[1] = 0; if (st) block_predictor[1] = av_clip(*src++, 0, 7); c->status[0].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; if (st){ c->status[1].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; } c->status[0].coeff1 = AdaptCoeff1[block_predictor[0]]; c->status[0].coeff2 = AdaptCoeff2[block_predictor[0]]; c->status[1].coeff1 = AdaptCoeff1[block_predictor[1]]; c->status[1].coeff2 = AdaptCoeff2[block_predictor[1]]; c->status[0].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; if (st) c->status[1].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); if (st) src+=2; c->status[0].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; if (st) c->status[1].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); if (st) src+=2; *samples++ = c->status[0].sample1; if (st) *samples++ = c->status[1].sample1; *samples++ = c->status[0].sample2; if (st) *samples++ = c->status[1].sample2; for(;n>0;n--) { *samples++ = adpcm_ms_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); *samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F); src ++; } break; case CODEC_ID_ADPCM_IMA_DK4: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; c->status[0].predictor = (int16_t)(src[0] | (src[1] << 8)); c->status[0].step_index = src[2]; src += 4; *samples++ = c->status[0].predictor; if (st) { c->status[1].predictor = (int16_t)(src[0] | (src[1] << 8)); c->status[1].step_index = src[2]; src += 4; *samples++ = c->status[1].predictor; } while (src < buf + buf_size) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); if (st) *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[0] & 0x0F, 3); else *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F, 3); src++; } break; case CODEC_ID_ADPCM_IMA_DK3: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; if(buf_size + 16 > (samples_end - samples)*3/8) return -1; c->status[0].predictor = (int16_t)(src[10] | (src[11] << 8)); c->status[1].predictor = (int16_t)(src[12] | (src[13] << 8)); c->status[0].step_index = src[14]; c->status[1].step_index = src[15]; src += 16; diff_channel = c->status[1].predictor; while (1) { DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[0], nibble, 3); DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[1], nibble, 3); diff_channel = (diff_channel + c->status[1].predictor) / 2; *samples++ = c->status[0].predictor + c->status[1].predictor; *samples++ = c->status[0].predictor - c->status[1].predictor; DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[0], nibble, 3); diff_channel = (diff_channel + c->status[1].predictor) / 2; *samples++ = c->status[0].predictor + c->status[1].predictor; *samples++ = c->status[0].predictor - c->status[1].predictor; } break; case CODEC_ID_ADPCM_IMA_WS: while (src < buf + buf_size) { if (st) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[1], src[0] & 0x0F, 3); } else { *samples++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F, 3); } src++; } break; case CODEC_ID_ADPCM_XA: c->status[0].sample1 = c->status[0].sample2 = c->status[1].sample1 = c->status[1].sample2 = 0; while (buf_size >= 128) { xa_decode(samples, src, &c->status[0], &c->status[1], avctx->channels); src += 128; samples += 28 * 8; buf_size -= 128; } break; case CODEC_ID_ADPCM_EA: samples_in_chunk = AV_RL32(src); if (samples_in_chunk >= ((buf_size - 12) * 2)) { src += buf_size; break; } src += 4; current_left_sample = (int16_t)AV_RL16(src); src += 2; previous_left_sample = (int16_t)AV_RL16(src); src += 2; current_right_sample = (int16_t)AV_RL16(src); src += 2; previous_right_sample = (int16_t)AV_RL16(src); src += 2; for (count1 = 0; count1 < samples_in_chunk/28;count1++) { coeff1l = ea_adpcm_table[(*src >> 4) & 0x0F]; coeff2l = ea_adpcm_table[((*src >> 4) & 0x0F) + 4]; coeff1r = ea_adpcm_table[*src & 0x0F]; coeff2r = ea_adpcm_table[(*src & 0x0F) + 4]; src++; shift_left = ((*src >> 4) & 0x0F) + 8; shift_right = (*src & 0x0F) + 8; src++; for (count2 = 0; count2 < 28; count2++) { next_left_sample = (((*src & 0xF0) << 24) >> shift_left); next_right_sample = (((*src & 0x0F) << 28) >> shift_right); src++; next_left_sample = (next_left_sample + (current_left_sample * coeff1l) + (previous_left_sample * coeff2l) + 0x80) >> 8; next_right_sample = (next_right_sample + (current_right_sample * coeff1r) + (previous_right_sample * coeff2r) + 0x80) >> 8; CLAMP_TO_SHORT(next_left_sample); CLAMP_TO_SHORT(next_right_sample); previous_left_sample = current_left_sample; current_left_sample = next_left_sample; previous_right_sample = current_right_sample; current_right_sample = next_right_sample; *samples++ = (unsigned short)current_left_sample; *samples++ = (unsigned short)current_right_sample; } } break; case CODEC_ID_ADPCM_IMA_SMJPEG: c->status[0].predictor = *src; src += 2; c->status[0].step_index = *src++; src++; while (src < buf + buf_size) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], *src & 0x0F, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], (*src >> 4) & 0x0F, 3); src++; } break; case CODEC_ID_ADPCM_CT: while (src < buf + buf_size) { if (st) { *samples++ = adpcm_ct_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); *samples++ = adpcm_ct_expand_nibble(&c->status[1], src[0] & 0x0F); } else { *samples++ = adpcm_ct_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); *samples++ = adpcm_ct_expand_nibble(&c->status[0], src[0] & 0x0F); } src++; } break; case CODEC_ID_ADPCM_SBPRO_4: case CODEC_ID_ADPCM_SBPRO_3: case CODEC_ID_ADPCM_SBPRO_2: if (!c->status[0].step_index) { *samples++ = 128 * (*src++ - 0x80); if (st) *samples++ = 128 * (*src++ - 0x80); c->status[0].step_index = 1; } if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) { while (src < buf + buf_size) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 4, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], src[0] & 0x0F, 4, 0); src++; } } else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) { while (src < buf + buf_size && samples + 2 < samples_end) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 5) & 0x07, 3, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 2) & 0x07, 3, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] & 0x03, 2, 0); src++; } } else { while (src < buf + buf_size && samples + 3 < samples_end) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 6) & 0x03, 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], (src[0] >> 4) & 0x03, 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 2) & 0x03, 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], src[0] & 0x03, 2, 2); src++; } } break; case CODEC_ID_ADPCM_SWF: { GetBitContext gb; const int *table; int k0, signmask, nb_bits; int size = buf_size*8; init_get_bits(&gb, buf, size); read bits & inital values nb_bits = get_bits(&gb, 2)+2; av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits); table = swf_index_tables[nb_bits-2]; k0 = 1 << (nb_bits-2); signmask = 1 << (nb_bits-1); for (i = 0; i < avctx->channels; i++) { *samples++ = c->status[i].predictor = get_sbits(&gb, 16); c->status[i].step_index = get_bits(&gb, 6); } while (get_bits_count(&gb) < size) { int i; for (i = 0; i < avctx->channels; i++) { similar to IMA adpcm int delta = get_bits(&gb, nb_bits); int step = step_table[c->status[i].step_index]; long vpdiff = 0; vpdiff = (delta+0.5)*step/4 int k = k0; do { if (delta & k) vpdiff += step; step >>= 1; k >>= 1; } while(k); vpdiff += step; if (delta & signmask) c->status[i].predictor -= vpdiff; else c->status[i].predictor += vpdiff; c->status[i].step_index += table[delta & (~signmask)]; c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88); c->status[i].predictor = av_clip(c->status[i].predictor, -32768, 32767); *samples++ = c->status[i].predictor; if (samples >= samples_end) { av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); return -1; } } } src += buf_size; break; } case CODEC_ID_ADPCM_YAMAHA: while (src < buf + buf_size) { if (st) { *samples++ = adpcm_yamaha_expand_nibble(&c->status[0], src[0] & 0x0F); *samples++ = adpcm_yamaha_expand_nibble(&c->status[1], (src[0] >> 4) & 0x0F); } else { *samples++ = adpcm_yamaha_expand_nibble(&c->status[0], src[0] & 0x0F); *samples++ = adpcm_yamaha_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); } src++; } break; case CODEC_ID_ADPCM_THP: { int table[2][16]; unsigned int samplecnt; int prev[2][2]; int ch; if (buf_size < 80) { av_log(avctx, AV_LOG_ERROR, "frame too small\n"); return -1; } src+=4; samplecnt = bytestream_get_be32(&src); for (i = 0; i < 32; i++) table[0][i] = (int16_t)bytestream_get_be16(&src); for (i = 0; i < 4; i++) prev[0][i] = (int16_t)bytestream_get_be16(&src); if (samplecnt >= (samples_end - samples) / (st + 1)) { av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); return -1; } for (ch = 0; ch <= st; ch++) { samples = (unsigned short *) data + ch; for (i = 0; i < samplecnt / 14; i++) { int index = (*src >> 4) & 7; unsigned int exp = 28 - (*src++ & 15); int factor1 = table[ch][index * 2]; int factor2 = table[ch][index * 2 + 1]; for (n = 0; n < 14; n++) { int32_t sampledat; if(n&1) sampledat= *src++ <<28; else sampledat= (*src&0xF0)<<24; *samples = ((prev[ch][0]*factor1 + prev[ch][1]*factor2) >> 11) + (sampledat>>exp); prev[ch][1] = prev[ch][0]; prev[ch][0] = *samples++; samples += st; } } } samples -= st; break; } default: return -1; } *data_size = (uint8_t *)samples - (uint8_t *)data; return src - buf; }
{ "code": [ " *samples = ((prev[ch][0]*factor1" ], "line_no": [ 1069 ] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, uint8_t *VAR_3, int VAR_4) { ADPCMContext *c = VAR_0->priv_data; ADPCMChannelStatus *cs; int VAR_5, VAR_6, VAR_7, VAR_24; int VAR_9[2]; short *VAR_10; short *VAR_11; uint8_t *src; int VAR_12; unsigned char VAR_13 = 0; unsigned char VAR_14; int VAR_15 = 0; int VAR_16; uint32_t samples_in_chunk; int32_t previous_left_sample, previous_right_sample; int32_t current_left_sample, current_right_sample; int32_t next_left_sample, next_right_sample; int32_t coeff1l, coeff2l, coeff1r, coeff2r; uint8_t shift_left, shift_right; int VAR_17, VAR_18; if (!VAR_4) return 0; if(*VAR_2/4 < VAR_4 + 8) return -1; VAR_10 = VAR_1; VAR_11= VAR_10 + *VAR_2/2; *VAR_2= 0; src = VAR_3; VAR_12 = VAR_0->channels == 2 ? 1 : 0; switch(VAR_0->codec->id) { case CODEC_ID_ADPCM_IMA_QT: VAR_5 = (VAR_4 - 2); VAR_7 = c->VAR_7; cs = &(c->status[VAR_7]); cs->predictor = (*src++) << 8; cs->predictor |= (*src & 0x80); cs->predictor &= 0xFF80; if(cs->predictor & 0x8000) cs->predictor -= 0x10000; CLAMP_TO_SHORT(cs->predictor); cs->step_index = (*src++) & 0x7F; if (cs->step_index > 88){ av_log(VAR_0, AV_LOG_ERROR, "ERROR: step_index = %VAR_24\VAR_5", cs->step_index); cs->step_index = 88; } cs->step = step_table[cs->step_index]; if (VAR_12 && VAR_7) VAR_10++; for(VAR_6=32; VAR_5>0 && VAR_6>0; VAR_5--, VAR_6--) { *VAR_10 = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3); VAR_10 += VAR_0->channels; *VAR_10 = adpcm_ima_expand_nibble(cs, (src[0] >> 4) & 0x0F, 3); VAR_10 += VAR_0->channels; src ++; } if(VAR_12) { c->VAR_7 = (VAR_7 + 1) % 2; if(VAR_7 == 1) { return src - VAR_3; } } break; case CODEC_ID_ADPCM_IMA_WAV: if (VAR_0->block_align != 0 && VAR_4 > VAR_0->block_align) VAR_4 = VAR_0->block_align; samples_per_block= (block_align-4*chanels)*8 / (bits_per_sample * chanels) + 1; for(VAR_24=0; VAR_24<VAR_0->channels; VAR_24++){ cs = &(c->status[VAR_24]); cs->predictor = (int16_t)(src[0] + (src[1]<<8)); src+=2; XXX: is this correct ??: *VAR_10++ = cs->predictor; cs->step_index = *src++; if (cs->step_index > 88){ av_log(VAR_0, AV_LOG_ERROR, "ERROR: step_index = %VAR_24\VAR_5", cs->step_index); cs->step_index = 88; } if (*src++) av_log(VAR_0, AV_LOG_ERROR, "unused byte should be null but is %d!!\VAR_5", src[-1]); } while(src < VAR_3 + VAR_4){ for(VAR_6=0; VAR_6<4; VAR_6++){ for(VAR_24=0; VAR_24<=VAR_12; VAR_24++) *VAR_10++ = adpcm_ima_expand_nibble(&c->status[VAR_24], src[4*VAR_24] & 0x0F, 3); for(VAR_24=0; VAR_24<=VAR_12; VAR_24++) *VAR_10++ = adpcm_ima_expand_nibble(&c->status[VAR_24], src[4*VAR_24] >> 4 , 3); src++; } src += 4*VAR_12; } break; case CODEC_ID_ADPCM_4XM: cs = &(c->status[0]); c->status[0].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2; if(VAR_12){ c->status[1].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2; } c->status[0].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2; if(VAR_12){ c->status[1].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2; } if (cs->step_index < 0) cs->step_index = 0; if (cs->step_index > 88) cs->step_index = 88; VAR_6= (VAR_4 - (src - VAR_3))>>VAR_12; for(VAR_24=0; VAR_24<VAR_6; VAR_24++) { *VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], src[VAR_24] & 0x0F, 4); if (VAR_12) *VAR_10++ = adpcm_ima_expand_nibble(&c->status[1], src[VAR_24+VAR_6] & 0x0F, 4); *VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], src[VAR_24] >> 4, 4); if (VAR_12) *VAR_10++ = adpcm_ima_expand_nibble(&c->status[1], src[VAR_24+VAR_6] >> 4, 4); } src += VAR_6<<VAR_12; break; case CODEC_ID_ADPCM_MS: if (VAR_0->block_align != 0 && VAR_4 > VAR_0->block_align) VAR_4 = VAR_0->block_align; VAR_5 = VAR_4 - 7 * VAR_0->channels; if (VAR_5 < 0) return -1; VAR_9[0] = av_clip(*src++, 0, 7); VAR_9[1] = 0; if (VAR_12) VAR_9[1] = av_clip(*src++, 0, 7); c->status[0].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; if (VAR_12){ c->status[1].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; } c->status[0].coeff1 = AdaptCoeff1[VAR_9[0]]; c->status[0].coeff2 = AdaptCoeff2[VAR_9[0]]; c->status[1].coeff1 = AdaptCoeff1[VAR_9[1]]; c->status[1].coeff2 = AdaptCoeff2[VAR_9[1]]; c->status[0].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; if (VAR_12) c->status[1].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); if (VAR_12) src+=2; c->status[0].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); src+=2; if (VAR_12) c->status[1].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00)); if (VAR_12) src+=2; *VAR_10++ = c->status[0].sample1; if (VAR_12) *VAR_10++ = c->status[1].sample1; *VAR_10++ = c->status[0].sample2; if (VAR_12) *VAR_10++ = c->status[1].sample2; for(;VAR_5>0;VAR_5--) { *VAR_10++ = adpcm_ms_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); *VAR_10++ = adpcm_ms_expand_nibble(&c->status[VAR_12], src[0] & 0x0F); src ++; } break; case CODEC_ID_ADPCM_IMA_DK4: if (VAR_0->block_align != 0 && VAR_4 > VAR_0->block_align) VAR_4 = VAR_0->block_align; c->status[0].predictor = (int16_t)(src[0] | (src[1] << 8)); c->status[0].step_index = src[2]; src += 4; *VAR_10++ = c->status[0].predictor; if (VAR_12) { c->status[1].predictor = (int16_t)(src[0] | (src[1] << 8)); c->status[1].step_index = src[2]; src += 4; *VAR_10++ = c->status[1].predictor; } while (src < VAR_3 + VAR_4) { *VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); if (VAR_12) *VAR_10++ = adpcm_ima_expand_nibble(&c->status[1], src[0] & 0x0F, 3); else *VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F, 3); src++; } break; case CODEC_ID_ADPCM_IMA_DK3: if (VAR_0->block_align != 0 && VAR_4 > VAR_0->block_align) VAR_4 = VAR_0->block_align; if(VAR_4 + 16 > (VAR_11 - VAR_10)*3/8) return -1; c->status[0].predictor = (int16_t)(src[10] | (src[11] << 8)); c->status[1].predictor = (int16_t)(src[12] | (src[13] << 8)); c->status[0].step_index = src[14]; c->status[1].step_index = src[15]; src += 16; VAR_16 = c->status[1].predictor; while (1) { DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[0], VAR_14, 3); DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[1], VAR_14, 3); VAR_16 = (VAR_16 + c->status[1].predictor) / 2; *VAR_10++ = c->status[0].predictor + c->status[1].predictor; *VAR_10++ = c->status[0].predictor - c->status[1].predictor; DK3_GET_NEXT_NIBBLE(); adpcm_ima_expand_nibble(&c->status[0], VAR_14, 3); VAR_16 = (VAR_16 + c->status[1].predictor) / 2; *VAR_10++ = c->status[0].predictor + c->status[1].predictor; *VAR_10++ = c->status[0].predictor - c->status[1].predictor; } break; case CODEC_ID_ADPCM_IMA_WS: while (src < VAR_3 + VAR_4) { if (VAR_12) { *VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); *VAR_10++ = adpcm_ima_expand_nibble(&c->status[1], src[0] & 0x0F, 3); } else { *VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 3); *VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], src[0] & 0x0F, 3); } src++; } break; case CODEC_ID_ADPCM_XA: c->status[0].sample1 = c->status[0].sample2 = c->status[1].sample1 = c->status[1].sample2 = 0; while (VAR_4 >= 128) { xa_decode(VAR_10, src, &c->status[0], &c->status[1], VAR_0->channels); src += 128; VAR_10 += 28 * 8; VAR_4 -= 128; } break; case CODEC_ID_ADPCM_EA: samples_in_chunk = AV_RL32(src); if (samples_in_chunk >= ((VAR_4 - 12) * 2)) { src += VAR_4; break; } src += 4; current_left_sample = (int16_t)AV_RL16(src); src += 2; previous_left_sample = (int16_t)AV_RL16(src); src += 2; current_right_sample = (int16_t)AV_RL16(src); src += 2; previous_right_sample = (int16_t)AV_RL16(src); src += 2; for (VAR_17 = 0; VAR_17 < samples_in_chunk/28;VAR_17++) { coeff1l = ea_adpcm_table[(*src >> 4) & 0x0F]; coeff2l = ea_adpcm_table[((*src >> 4) & 0x0F) + 4]; coeff1r = ea_adpcm_table[*src & 0x0F]; coeff2r = ea_adpcm_table[(*src & 0x0F) + 4]; src++; shift_left = ((*src >> 4) & 0x0F) + 8; shift_right = (*src & 0x0F) + 8; src++; for (VAR_18 = 0; VAR_18 < 28; VAR_18++) { next_left_sample = (((*src & 0xF0) << 24) >> shift_left); next_right_sample = (((*src & 0x0F) << 28) >> shift_right); src++; next_left_sample = (next_left_sample + (current_left_sample * coeff1l) + (previous_left_sample * coeff2l) + 0x80) >> 8; next_right_sample = (next_right_sample + (current_right_sample * coeff1r) + (previous_right_sample * coeff2r) + 0x80) >> 8; CLAMP_TO_SHORT(next_left_sample); CLAMP_TO_SHORT(next_right_sample); previous_left_sample = current_left_sample; current_left_sample = next_left_sample; previous_right_sample = current_right_sample; current_right_sample = next_right_sample; *VAR_10++ = (unsigned short)current_left_sample; *VAR_10++ = (unsigned short)current_right_sample; } } break; case CODEC_ID_ADPCM_IMA_SMJPEG: c->status[0].predictor = *src; src += 2; c->status[0].step_index = *src++; src++; while (src < VAR_3 + VAR_4) { *VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], *src & 0x0F, 3); *VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], (*src >> 4) & 0x0F, 3); src++; } break; case CODEC_ID_ADPCM_CT: while (src < VAR_3 + VAR_4) { if (VAR_12) { *VAR_10++ = adpcm_ct_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); *VAR_10++ = adpcm_ct_expand_nibble(&c->status[1], src[0] & 0x0F); } else { *VAR_10++ = adpcm_ct_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); *VAR_10++ = adpcm_ct_expand_nibble(&c->status[0], src[0] & 0x0F); } src++; } break; case CODEC_ID_ADPCM_SBPRO_4: case CODEC_ID_ADPCM_SBPRO_3: case CODEC_ID_ADPCM_SBPRO_2: if (!c->status[0].step_index) { *VAR_10++ = 128 * (*src++ - 0x80); if (VAR_12) *VAR_10++ = 128 * (*src++ - 0x80); c->status[0].step_index = 1; } if (VAR_0->codec->id == CODEC_ID_ADPCM_SBPRO_4) { while (src < VAR_3 + VAR_4) { *VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F, 4, 0); *VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[VAR_12], src[0] & 0x0F, 4, 0); src++; } } else if (VAR_0->codec->id == CODEC_ID_ADPCM_SBPRO_3) { while (src < VAR_3 + VAR_4 && VAR_10 + 2 < VAR_11) { *VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 5) & 0x07, 3, 0); *VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 2) & 0x07, 3, 0); *VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] & 0x03, 2, 0); src++; } } else { while (src < VAR_3 + VAR_4 && VAR_10 + 3 < VAR_11) { *VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 6) & 0x03, 2, 2); *VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[VAR_12], (src[0] >> 4) & 0x03, 2, 2); *VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 2) & 0x03, 2, 2); *VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[VAR_12], src[0] & 0x03, 2, 2); src++; } } break; case CODEC_ID_ADPCM_SWF: { GetBitContext gb; const int *VAR_24; int VAR_20, VAR_21, VAR_22; int VAR_23 = VAR_4*8; init_get_bits(&gb, VAR_3, VAR_23); read bits & inital values VAR_22 = get_bits(&gb, 2)+2; av_log(NULL,AV_LOG_INFO,"VAR_22: %d\VAR_5", VAR_22); VAR_24 = swf_index_tables[VAR_22-2]; VAR_20 = 1 << (VAR_22-2); VAR_21 = 1 << (VAR_22-1); for (VAR_24 = 0; VAR_24 < VAR_0->channels; VAR_24++) { *VAR_10++ = c->status[VAR_24].predictor = get_sbits(&gb, 16); c->status[VAR_24].step_index = get_bits(&gb, 6); } while (get_bits_count(&gb) < VAR_23) { int VAR_24; for (VAR_24 = 0; VAR_24 < VAR_0->channels; VAR_24++) { similar to IMA adpcm int delta = get_bits(&gb, VAR_22); int step = step_table[c->status[VAR_24].step_index]; long vpdiff = 0; vpdiff = (delta+0.5)*step/4 int k = VAR_20; do { if (delta & k) vpdiff += step; step >>= 1; k >>= 1; } while(k); vpdiff += step; if (delta & VAR_21) c->status[VAR_24].predictor -= vpdiff; else c->status[VAR_24].predictor += vpdiff; c->status[VAR_24].step_index += VAR_24[delta & (~VAR_21)]; c->status[VAR_24].step_index = av_clip(c->status[VAR_24].step_index, 0, 88); c->status[VAR_24].predictor = av_clip(c->status[VAR_24].predictor, -32768, 32767); *VAR_10++ = c->status[VAR_24].predictor; if (VAR_10 >= VAR_11) { av_log(VAR_0, AV_LOG_ERROR, "allocated output buffer is too small\VAR_5"); return -1; } } } src += VAR_4; break; } case CODEC_ID_ADPCM_YAMAHA: while (src < VAR_3 + VAR_4) { if (VAR_12) { *VAR_10++ = adpcm_yamaha_expand_nibble(&c->status[0], src[0] & 0x0F); *VAR_10++ = adpcm_yamaha_expand_nibble(&c->status[1], (src[0] >> 4) & 0x0F); } else { *VAR_10++ = adpcm_yamaha_expand_nibble(&c->status[0], src[0] & 0x0F); *VAR_10++ = adpcm_yamaha_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F); } src++; } break; case CODEC_ID_ADPCM_THP: { int VAR_24[2][16]; unsigned int VAR_24; int VAR_25[2][2]; int VAR_26; if (VAR_4 < 80) { av_log(VAR_0, AV_LOG_ERROR, "frame too small\VAR_5"); return -1; } src+=4; VAR_24 = bytestream_get_be32(&src); for (VAR_24 = 0; VAR_24 < 32; VAR_24++) VAR_24[0][VAR_24] = (int16_t)bytestream_get_be16(&src); for (VAR_24 = 0; VAR_24 < 4; VAR_24++) VAR_25[0][VAR_24] = (int16_t)bytestream_get_be16(&src); if (VAR_24 >= (VAR_11 - VAR_10) / (VAR_12 + 1)) { av_log(VAR_0, AV_LOG_ERROR, "allocated output buffer is too small\VAR_5"); return -1; } for (VAR_26 = 0; VAR_26 <= VAR_12; VAR_26++) { VAR_10 = (unsigned short *) VAR_1 + VAR_26; for (VAR_24 = 0; VAR_24 < VAR_24 / 14; VAR_24++) { int VAR_27 = (*src >> 4) & 7; unsigned int VAR_28 = 28 - (*src++ & 15); int VAR_29 = VAR_24[VAR_26][VAR_27 * 2]; int VAR_30 = VAR_24[VAR_26][VAR_27 * 2 + 1]; for (VAR_5 = 0; VAR_5 < 14; VAR_5++) { int32_t sampledat; if(VAR_5&1) sampledat= *src++ <<28; else sampledat= (*src&0xF0)<<24; *VAR_10 = ((VAR_25[VAR_26][0]*VAR_29 + VAR_25[VAR_26][1]*VAR_30) >> 11) + (sampledat>>VAR_28); VAR_25[VAR_26][1] = VAR_25[VAR_26][0]; VAR_25[VAR_26][0] = *VAR_10++; VAR_10 += VAR_12; } } } VAR_10 -= VAR_12; break; } default: return -1; } *VAR_2 = (uint8_t *)VAR_10 - (uint8_t *)VAR_1; return src - VAR_3; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{", "ADPCMContext *c = VAR_0->priv_data;", "ADPCMChannelStatus *cs;", "int VAR_5, VAR_6, VAR_7, VAR_24;", "int VAR_9[2];", "short *VAR_10;", "short *VAR_11;", "uint8_t *src;", "int VAR_12;", "unsigned char VAR_13 = 0;", "unsigned char VAR_14;", "int VAR_15 = 0;", "int VAR_16;", "uint32_t samples_in_chunk;", "int32_t previous_left_sample, previous_right_sample;", "int32_t current_left_sample, current_right_sample;", "int32_t next_left_sample, next_right_sample;", "int32_t coeff1l, coeff2l, coeff1r, coeff2r;", "uint8_t shift_left, shift_right;", "int VAR_17, VAR_18;", "if (!VAR_4)\nreturn 0;", "if(*VAR_2/4 < VAR_4 + 8)\nreturn -1;", "VAR_10 = VAR_1;", "VAR_11= VAR_10 + *VAR_2/2;", "*VAR_2= 0;", "src = VAR_3;", "VAR_12 = VAR_0->channels == 2 ? 1 : 0;", "switch(VAR_0->codec->id) {", "case CODEC_ID_ADPCM_IMA_QT:\nVAR_5 = (VAR_4 - 2);", "VAR_7 = c->VAR_7;", "cs = &(c->status[VAR_7]);", "cs->predictor = (*src++) << 8;", "cs->predictor |= (*src & 0x80);", "cs->predictor &= 0xFF80;", "if(cs->predictor & 0x8000)\ncs->predictor -= 0x10000;", "CLAMP_TO_SHORT(cs->predictor);", "cs->step_index = (*src++) & 0x7F;", "if (cs->step_index > 88){", "av_log(VAR_0, AV_LOG_ERROR, \"ERROR: step_index = %VAR_24\\VAR_5\", cs->step_index);", "cs->step_index = 88;", "}", "cs->step = step_table[cs->step_index];", "if (VAR_12 && VAR_7)\nVAR_10++;", "for(VAR_6=32; VAR_5>0 && VAR_6>0; VAR_5--, VAR_6--) {", "*VAR_10 = adpcm_ima_expand_nibble(cs, src[0] & 0x0F, 3);", "VAR_10 += VAR_0->channels;", "*VAR_10 = adpcm_ima_expand_nibble(cs, (src[0] >> 4) & 0x0F, 3);", "VAR_10 += VAR_0->channels;", "src ++;", "}", "if(VAR_12) {", "c->VAR_7 = (VAR_7 + 1) % 2;", "if(VAR_7 == 1) {", "return src - VAR_3;", "}", "}", "break;", "case CODEC_ID_ADPCM_IMA_WAV:\nif (VAR_0->block_align != 0 && VAR_4 > VAR_0->block_align)\nVAR_4 = VAR_0->block_align;", "samples_per_block= (block_align-4*chanels)*8 / (bits_per_sample * chanels) + 1;", "for(VAR_24=0; VAR_24<VAR_0->channels; VAR_24++){", "cs = &(c->status[VAR_24]);", "cs->predictor = (int16_t)(src[0] + (src[1]<<8));", "src+=2;", "XXX: is this correct ??: *VAR_10++ = cs->predictor;", "cs->step_index = *src++;", "if (cs->step_index > 88){", "av_log(VAR_0, AV_LOG_ERROR, \"ERROR: step_index = %VAR_24\\VAR_5\", cs->step_index);", "cs->step_index = 88;", "}", "if (*src++) av_log(VAR_0, AV_LOG_ERROR, \"unused byte should be null but is %d!!\\VAR_5\", src[-1]);", "}", "while(src < VAR_3 + VAR_4){", "for(VAR_6=0; VAR_6<4; VAR_6++){", "for(VAR_24=0; VAR_24<=VAR_12; VAR_24++)", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[VAR_24], src[4*VAR_24] & 0x0F, 3);", "for(VAR_24=0; VAR_24<=VAR_12; VAR_24++)", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[VAR_24], src[4*VAR_24] >> 4 , 3);", "src++;", "}", "src += 4*VAR_12;", "}", "break;", "case CODEC_ID_ADPCM_4XM:\ncs = &(c->status[0]);", "c->status[0].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2;", "if(VAR_12){", "c->status[1].predictor= (int16_t)(src[0] + (src[1]<<8)); src+=2;", "}", "c->status[0].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2;", "if(VAR_12){", "c->status[1].step_index= (int16_t)(src[0] + (src[1]<<8)); src+=2;", "}", "if (cs->step_index < 0) cs->step_index = 0;", "if (cs->step_index > 88) cs->step_index = 88;", "VAR_6= (VAR_4 - (src - VAR_3))>>VAR_12;", "for(VAR_24=0; VAR_24<VAR_6; VAR_24++) {", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], src[VAR_24] & 0x0F, 4);", "if (VAR_12)\n*VAR_10++ = adpcm_ima_expand_nibble(&c->status[1], src[VAR_24+VAR_6] & 0x0F, 4);", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[0], src[VAR_24] >> 4, 4);", "if (VAR_12)\n*VAR_10++ = adpcm_ima_expand_nibble(&c->status[1], src[VAR_24+VAR_6] >> 4, 4);", "}", "src += VAR_6<<VAR_12;", "break;", "case CODEC_ID_ADPCM_MS:\nif (VAR_0->block_align != 0 && VAR_4 > VAR_0->block_align)\nVAR_4 = VAR_0->block_align;", "VAR_5 = VAR_4 - 7 * VAR_0->channels;", "if (VAR_5 < 0)\nreturn -1;", "VAR_9[0] = av_clip(*src++, 0, 7);", "VAR_9[1] = 0;", "if (VAR_12)\nVAR_9[1] = av_clip(*src++, 0, 7);", "c->status[0].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00));", "src+=2;", "if (VAR_12){", "c->status[1].idelta = (int16_t)((*src & 0xFF) | ((src[1] << 8) & 0xFF00));", "src+=2;", "}", "c->status[0].coeff1 = AdaptCoeff1[VAR_9[0]];", "c->status[0].coeff2 = AdaptCoeff2[VAR_9[0]];", "c->status[1].coeff1 = AdaptCoeff1[VAR_9[1]];", "c->status[1].coeff2 = AdaptCoeff2[VAR_9[1]];", "c->status[0].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));", "src+=2;", "if (VAR_12) c->status[1].sample1 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));", "if (VAR_12) src+=2;", "c->status[0].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));", "src+=2;", "if (VAR_12) c->status[1].sample2 = ((*src & 0xFF) | ((src[1] << 8) & 0xFF00));", "if (VAR_12) src+=2;", "*VAR_10++ = c->status[0].sample1;", "if (VAR_12) *VAR_10++ = c->status[1].sample1;", "*VAR_10++ = c->status[0].sample2;", "if (VAR_12) *VAR_10++ = c->status[1].sample2;", "for(;VAR_5>0;VAR_5--) {", "*VAR_10++ = adpcm_ms_expand_nibble(&c->status[0], (src[0] >> 4) & 0x0F);", "*VAR_10++ = adpcm_ms_expand_nibble(&c->status[VAR_12], src[0] & 0x0F);", "src ++;", "}", "break;", "case CODEC_ID_ADPCM_IMA_DK4:\nif (VAR_0->block_align != 0 && VAR_4 > VAR_0->block_align)\nVAR_4 = VAR_0->block_align;", "c->status[0].predictor = (int16_t)(src[0] | (src[1] << 8));", "c->status[0].step_index = src[2];", "src += 4;", "*VAR_10++ = c->status[0].predictor;", "if (VAR_12) {", "c->status[1].predictor = (int16_t)(src[0] | (src[1] << 8));", "c->status[1].step_index = src[2];", "src += 4;", "*VAR_10++ = c->status[1].predictor;", "}", "while (src < VAR_3 + VAR_4) {", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[0],\n(src[0] >> 4) & 0x0F, 3);", "if (VAR_12)\n*VAR_10++ = adpcm_ima_expand_nibble(&c->status[1],\nsrc[0] & 0x0F, 3);", "else\n*VAR_10++ = adpcm_ima_expand_nibble(&c->status[0],\nsrc[0] & 0x0F, 3);", "src++;", "}", "break;", "case CODEC_ID_ADPCM_IMA_DK3:\nif (VAR_0->block_align != 0 && VAR_4 > VAR_0->block_align)\nVAR_4 = VAR_0->block_align;", "if(VAR_4 + 16 > (VAR_11 - VAR_10)*3/8)\nreturn -1;", "c->status[0].predictor = (int16_t)(src[10] | (src[11] << 8));", "c->status[1].predictor = (int16_t)(src[12] | (src[13] << 8));", "c->status[0].step_index = src[14];", "c->status[1].step_index = src[15];", "src += 16;", "VAR_16 = c->status[1].predictor;", "while (1) {", "DK3_GET_NEXT_NIBBLE();", "adpcm_ima_expand_nibble(&c->status[0], VAR_14, 3);", "DK3_GET_NEXT_NIBBLE();", "adpcm_ima_expand_nibble(&c->status[1], VAR_14, 3);", "VAR_16 = (VAR_16 + c->status[1].predictor) / 2;", "*VAR_10++ = c->status[0].predictor + c->status[1].predictor;", "*VAR_10++ = c->status[0].predictor - c->status[1].predictor;", "DK3_GET_NEXT_NIBBLE();", "adpcm_ima_expand_nibble(&c->status[0], VAR_14, 3);", "VAR_16 = (VAR_16 + c->status[1].predictor) / 2;", "*VAR_10++ = c->status[0].predictor + c->status[1].predictor;", "*VAR_10++ = c->status[0].predictor - c->status[1].predictor;", "}", "break;", "case CODEC_ID_ADPCM_IMA_WS:\nwhile (src < VAR_3 + VAR_4) {", "if (VAR_12) {", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[0],\n(src[0] >> 4) & 0x0F, 3);", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[1],\nsrc[0] & 0x0F, 3);", "} else {", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[0],\n(src[0] >> 4) & 0x0F, 3);", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[0],\nsrc[0] & 0x0F, 3);", "}", "src++;", "}", "break;", "case CODEC_ID_ADPCM_XA:\nc->status[0].sample1 = c->status[0].sample2 =\nc->status[1].sample1 = c->status[1].sample2 = 0;", "while (VAR_4 >= 128) {", "xa_decode(VAR_10, src, &c->status[0], &c->status[1],\nVAR_0->channels);", "src += 128;", "VAR_10 += 28 * 8;", "VAR_4 -= 128;", "}", "break;", "case CODEC_ID_ADPCM_EA:\nsamples_in_chunk = AV_RL32(src);", "if (samples_in_chunk >= ((VAR_4 - 12) * 2)) {", "src += VAR_4;", "break;", "}", "src += 4;", "current_left_sample = (int16_t)AV_RL16(src);", "src += 2;", "previous_left_sample = (int16_t)AV_RL16(src);", "src += 2;", "current_right_sample = (int16_t)AV_RL16(src);", "src += 2;", "previous_right_sample = (int16_t)AV_RL16(src);", "src += 2;", "for (VAR_17 = 0; VAR_17 < samples_in_chunk/28;VAR_17++) {", "coeff1l = ea_adpcm_table[(*src >> 4) & 0x0F];", "coeff2l = ea_adpcm_table[((*src >> 4) & 0x0F) + 4];", "coeff1r = ea_adpcm_table[*src & 0x0F];", "coeff2r = ea_adpcm_table[(*src & 0x0F) + 4];", "src++;", "shift_left = ((*src >> 4) & 0x0F) + 8;", "shift_right = (*src & 0x0F) + 8;", "src++;", "for (VAR_18 = 0; VAR_18 < 28; VAR_18++) {", "next_left_sample = (((*src & 0xF0) << 24) >> shift_left);", "next_right_sample = (((*src & 0x0F) << 28) >> shift_right);", "src++;", "next_left_sample = (next_left_sample +\n(current_left_sample * coeff1l) +\n(previous_left_sample * coeff2l) + 0x80) >> 8;", "next_right_sample = (next_right_sample +\n(current_right_sample * coeff1r) +\n(previous_right_sample * coeff2r) + 0x80) >> 8;", "CLAMP_TO_SHORT(next_left_sample);", "CLAMP_TO_SHORT(next_right_sample);", "previous_left_sample = current_left_sample;", "current_left_sample = next_left_sample;", "previous_right_sample = current_right_sample;", "current_right_sample = next_right_sample;", "*VAR_10++ = (unsigned short)current_left_sample;", "*VAR_10++ = (unsigned short)current_right_sample;", "}", "}", "break;", "case CODEC_ID_ADPCM_IMA_SMJPEG:\nc->status[0].predictor = *src;", "src += 2;", "c->status[0].step_index = *src++;", "src++;", "while (src < VAR_3 + VAR_4) {", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[0],\n*src & 0x0F, 3);", "*VAR_10++ = adpcm_ima_expand_nibble(&c->status[0],\n(*src >> 4) & 0x0F, 3);", "src++;", "}", "break;", "case CODEC_ID_ADPCM_CT:\nwhile (src < VAR_3 + VAR_4) {", "if (VAR_12) {", "*VAR_10++ = adpcm_ct_expand_nibble(&c->status[0],\n(src[0] >> 4) & 0x0F);", "*VAR_10++ = adpcm_ct_expand_nibble(&c->status[1],\nsrc[0] & 0x0F);", "} else {", "*VAR_10++ = adpcm_ct_expand_nibble(&c->status[0],\n(src[0] >> 4) & 0x0F);", "*VAR_10++ = adpcm_ct_expand_nibble(&c->status[0],\nsrc[0] & 0x0F);", "}", "src++;", "}", "break;", "case CODEC_ID_ADPCM_SBPRO_4:\ncase CODEC_ID_ADPCM_SBPRO_3:\ncase CODEC_ID_ADPCM_SBPRO_2:\nif (!c->status[0].step_index) {", "*VAR_10++ = 128 * (*src++ - 0x80);", "if (VAR_12)\n*VAR_10++ = 128 * (*src++ - 0x80);", "c->status[0].step_index = 1;", "}", "if (VAR_0->codec->id == CODEC_ID_ADPCM_SBPRO_4) {", "while (src < VAR_3 + VAR_4) {", "*VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0],\n(src[0] >> 4) & 0x0F, 4, 0);", "*VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[VAR_12],\nsrc[0] & 0x0F, 4, 0);", "src++;", "}", "} else if (VAR_0->codec->id == CODEC_ID_ADPCM_SBPRO_3) {", "while (src < VAR_3 + VAR_4 && VAR_10 + 2 < VAR_11) {", "*VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0],\n(src[0] >> 5) & 0x07, 3, 0);", "*VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0],\n(src[0] >> 2) & 0x07, 3, 0);", "*VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0],\nsrc[0] & 0x03, 2, 0);", "src++;", "}", "} else {", "while (src < VAR_3 + VAR_4 && VAR_10 + 3 < VAR_11) {", "*VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0],\n(src[0] >> 6) & 0x03, 2, 2);", "*VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[VAR_12],\n(src[0] >> 4) & 0x03, 2, 2);", "*VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[0],\n(src[0] >> 2) & 0x03, 2, 2);", "*VAR_10++ = adpcm_sbpro_expand_nibble(&c->status[VAR_12],\nsrc[0] & 0x03, 2, 2);", "src++;", "}", "}", "break;", "case CODEC_ID_ADPCM_SWF:\n{", "GetBitContext gb;", "const int *VAR_24;", "int VAR_20, VAR_21, VAR_22;", "int VAR_23 = VAR_4*8;", "init_get_bits(&gb, VAR_3, VAR_23);", "read bits & inital values\nVAR_22 = get_bits(&gb, 2)+2;", "av_log(NULL,AV_LOG_INFO,\"VAR_22: %d\\VAR_5\", VAR_22);", "VAR_24 = swf_index_tables[VAR_22-2];", "VAR_20 = 1 << (VAR_22-2);", "VAR_21 = 1 << (VAR_22-1);", "for (VAR_24 = 0; VAR_24 < VAR_0->channels; VAR_24++) {", "*VAR_10++ = c->status[VAR_24].predictor = get_sbits(&gb, 16);", "c->status[VAR_24].step_index = get_bits(&gb, 6);", "}", "while (get_bits_count(&gb) < VAR_23)\n{", "int VAR_24;", "for (VAR_24 = 0; VAR_24 < VAR_0->channels; VAR_24++) {", "similar to IMA adpcm\nint delta = get_bits(&gb, VAR_22);", "int step = step_table[c->status[VAR_24].step_index];", "long vpdiff = 0; vpdiff = (delta+0.5)*step/4", "int k = VAR_20;", "do {", "if (delta & k)\nvpdiff += step;", "step >>= 1;", "k >>= 1;", "} while(k);", "vpdiff += step;", "if (delta & VAR_21)\nc->status[VAR_24].predictor -= vpdiff;", "else\nc->status[VAR_24].predictor += vpdiff;", "c->status[VAR_24].step_index += VAR_24[delta & (~VAR_21)];", "c->status[VAR_24].step_index = av_clip(c->status[VAR_24].step_index, 0, 88);", "c->status[VAR_24].predictor = av_clip(c->status[VAR_24].predictor, -32768, 32767);", "*VAR_10++ = c->status[VAR_24].predictor;", "if (VAR_10 >= VAR_11) {", "av_log(VAR_0, AV_LOG_ERROR, \"allocated output buffer is too small\\VAR_5\");", "return -1;", "}", "}", "}", "src += VAR_4;", "break;", "}", "case CODEC_ID_ADPCM_YAMAHA:\nwhile (src < VAR_3 + VAR_4) {", "if (VAR_12) {", "*VAR_10++ = adpcm_yamaha_expand_nibble(&c->status[0],\nsrc[0] & 0x0F);", "*VAR_10++ = adpcm_yamaha_expand_nibble(&c->status[1],\n(src[0] >> 4) & 0x0F);", "} else {", "*VAR_10++ = adpcm_yamaha_expand_nibble(&c->status[0],\nsrc[0] & 0x0F);", "*VAR_10++ = adpcm_yamaha_expand_nibble(&c->status[0],\n(src[0] >> 4) & 0x0F);", "}", "src++;", "}", "break;", "case CODEC_ID_ADPCM_THP:\n{", "int VAR_24[2][16];", "unsigned int VAR_24;", "int VAR_25[2][2];", "int VAR_26;", "if (VAR_4 < 80) {", "av_log(VAR_0, AV_LOG_ERROR, \"frame too small\\VAR_5\");", "return -1;", "}", "src+=4;", "VAR_24 = bytestream_get_be32(&src);", "for (VAR_24 = 0; VAR_24 < 32; VAR_24++)", "VAR_24[0][VAR_24] = (int16_t)bytestream_get_be16(&src);", "for (VAR_24 = 0; VAR_24 < 4; VAR_24++)", "VAR_25[0][VAR_24] = (int16_t)bytestream_get_be16(&src);", "if (VAR_24 >= (VAR_11 - VAR_10) / (VAR_12 + 1)) {", "av_log(VAR_0, AV_LOG_ERROR, \"allocated output buffer is too small\\VAR_5\");", "return -1;", "}", "for (VAR_26 = 0; VAR_26 <= VAR_12; VAR_26++) {", "VAR_10 = (unsigned short *) VAR_1 + VAR_26;", "for (VAR_24 = 0; VAR_24 < VAR_24 / 14; VAR_24++) {", "int VAR_27 = (*src >> 4) & 7;", "unsigned int VAR_28 = 28 - (*src++ & 15);", "int VAR_29 = VAR_24[VAR_26][VAR_27 * 2];", "int VAR_30 = VAR_24[VAR_26][VAR_27 * 2 + 1];", "for (VAR_5 = 0; VAR_5 < 14; VAR_5++) {", "int32_t sampledat;", "if(VAR_5&1) sampledat= *src++ <<28;", "else sampledat= (*src&0xF0)<<24;", "*VAR_10 = ((VAR_25[VAR_26][0]*VAR_29\n+ VAR_25[VAR_26][1]*VAR_30) >> 11) + (sampledat>>VAR_28);", "VAR_25[VAR_26][1] = VAR_25[VAR_26][0];", "VAR_25[VAR_26][0] = *VAR_10++;", "VAR_10 += VAR_12;", "}", "}", "}", "VAR_10 -= VAR_12;", "break;", "}", "default:\nreturn -1;", "}", "*VAR_2 = (uint8_t *)VAR_10 - (uint8_t *)VAR_1;", "return src - VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 69, 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 105 ], [ 107 ], [ 109 ], [ 115, 117 ], [ 121 ], [ 125 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 143, 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179, 181, 183 ], [ 187 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 201 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243, 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 269 ], [ 271 ], [ 273 ], [ 275, 277 ], [ 279 ], [ 281, 283 ], [ 285 ], [ 289 ], [ 293 ], [ 295, 297, 299 ], [ 301 ], [ 303, 305 ], [ 307 ], [ 309 ], [ 311, 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375, 377, 379 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 409, 411 ], [ 419, 421, 423 ], [ 425, 427, 429 ], [ 433 ], [ 435 ], [ 437 ], [ 439, 441, 443 ], [ 447, 449 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 463 ], [ 465 ], [ 473 ], [ 485 ], [ 487 ], [ 493 ], [ 495 ], [ 501 ], [ 503 ], [ 505 ], [ 511 ], [ 513 ], [ 519 ], [ 521 ], [ 523 ], [ 525 ], [ 527 ], [ 529, 533 ], [ 537 ], [ 539, 541 ], [ 543, 545 ], [ 547 ], [ 549, 551 ], [ 553, 555 ], [ 557 ], [ 561 ], [ 563 ], [ 565 ], [ 567, 569, 571 ], [ 573 ], [ 575, 577 ], [ 579 ], [ 581 ], [ 583 ], [ 585 ], [ 587 ], [ 589, 591 ], [ 593 ], [ 595 ], [ 597 ], [ 599 ], [ 601 ], [ 603 ], [ 605 ], [ 607 ], [ 609 ], [ 611 ], [ 613 ], [ 615 ], [ 617 ], [ 621 ], [ 623 ], [ 625 ], [ 627 ], [ 629 ], [ 631 ], [ 635 ], [ 637 ], [ 639 ], [ 643 ], [ 645 ], [ 647 ], [ 649 ], [ 653, 655, 657 ], [ 659, 661, 663 ], [ 665 ], [ 667 ], [ 671 ], [ 673 ], [ 675 ], [ 677 ], [ 679 ], [ 681 ], [ 683 ], [ 685 ], [ 687 ], [ 689, 691 ], [ 693 ], [ 695 ], [ 697 ], [ 699 ], [ 701, 703 ], [ 705, 707 ], [ 709 ], [ 711 ], [ 713 ], [ 715, 717 ], [ 719 ], [ 721, 723 ], [ 725, 727 ], [ 729 ], [ 731, 733 ], [ 735, 737 ], [ 739 ], [ 741 ], [ 743 ], [ 745 ], [ 747, 749, 751, 753 ], [ 757 ], [ 759, 761 ], [ 763 ], [ 765 ], [ 767 ], [ 769 ], [ 771, 773 ], [ 775, 777 ], [ 779 ], [ 781 ], [ 783 ], [ 785 ], [ 787, 789 ], [ 791, 793 ], [ 795, 797 ], [ 799 ], [ 801 ], [ 803 ], [ 805 ], [ 807, 809 ], [ 811, 813 ], [ 815, 817 ], [ 819, 821 ], [ 823 ], [ 825 ], [ 827 ], [ 829 ], [ 831, 833 ], [ 835 ], [ 837 ], [ 839 ], [ 841 ], [ 845 ], [ 849, 851 ], [ 853 ], [ 855 ], [ 857 ], [ 859 ], [ 863 ], [ 865 ], [ 867 ], [ 869 ], [ 873, 875 ], [ 877 ], [ 881 ], [ 883, 885 ], [ 887 ], [ 889 ], [ 891 ], [ 895 ], [ 897, 899 ], [ 901 ], [ 903 ], [ 905 ], [ 907 ], [ 911, 913 ], [ 915, 917 ], [ 921 ], [ 925 ], [ 927 ], [ 931 ], [ 933 ], [ 935 ], [ 937 ], [ 939 ], [ 941 ], [ 943 ], [ 945 ], [ 947 ], [ 949 ], [ 951, 953 ], [ 955 ], [ 957, 959 ], [ 961, 963 ], [ 965 ], [ 967, 969 ], [ 971, 973 ], [ 975 ], [ 977 ], [ 979 ], [ 981 ], [ 983, 985 ], [ 987 ], [ 989 ], [ 991 ], [ 993 ], [ 997 ], [ 999 ], [ 1001 ], [ 1003 ], [ 1007 ], [ 1009 ], [ 1013 ], [ 1015 ], [ 1021 ], [ 1023 ], [ 1027 ], [ 1029 ], [ 1031 ], [ 1033 ], [ 1037 ], [ 1039 ], [ 1045 ], [ 1047 ], [ 1049 ], [ 1051 ], [ 1053 ], [ 1059 ], [ 1061 ], [ 1063 ], [ 1065 ], [ 1069, 1071 ], [ 1073 ], [ 1075 ], [ 1083 ], [ 1085 ], [ 1087 ], [ 1089 ], [ 1097 ], [ 1099 ], [ 1101 ], [ 1105, 1107 ], [ 1109 ], [ 1111 ], [ 1113 ], [ 1115 ] ]
382
static coroutine_fn void test_multi_co_schedule_entry(void *opaque) { g_assert(to_schedule[id] == NULL); atomic_mb_set(&to_schedule[id], qemu_coroutine_self()); while (!atomic_mb_read(&now_stopping)) { int n; n = g_test_rand_int_range(0, NUM_CONTEXTS); schedule_next(n); qemu_coroutine_yield(); g_assert(to_schedule[id] == NULL); atomic_mb_set(&to_schedule[id], qemu_coroutine_self()); } }
true
qemu
fb0c43f34eed8b18678c6e1f481d8564b35c99ed
static coroutine_fn void test_multi_co_schedule_entry(void *opaque) { g_assert(to_schedule[id] == NULL); atomic_mb_set(&to_schedule[id], qemu_coroutine_self()); while (!atomic_mb_read(&now_stopping)) { int n; n = g_test_rand_int_range(0, NUM_CONTEXTS); schedule_next(n); qemu_coroutine_yield(); g_assert(to_schedule[id] == NULL); atomic_mb_set(&to_schedule[id], qemu_coroutine_self()); } }
{ "code": [ " atomic_mb_set(&to_schedule[id], qemu_coroutine_self());", " qemu_coroutine_yield();", " g_assert(to_schedule[id] == NULL);" ], "line_no": [ 7, 21, 25 ] }
static coroutine_fn void FUNC_0(void *opaque) { g_assert(to_schedule[id] == NULL); atomic_mb_set(&to_schedule[id], qemu_coroutine_self()); while (!atomic_mb_read(&now_stopping)) { int VAR_0; VAR_0 = g_test_rand_int_range(0, NUM_CONTEXTS); schedule_next(VAR_0); qemu_coroutine_yield(); g_assert(to_schedule[id] == NULL); atomic_mb_set(&to_schedule[id], qemu_coroutine_self()); } }
[ "static coroutine_fn void FUNC_0(void *opaque)\n{", "g_assert(to_schedule[id] == NULL);", "atomic_mb_set(&to_schedule[id], qemu_coroutine_self());", "while (!atomic_mb_read(&now_stopping)) {", "int VAR_0;", "VAR_0 = g_test_rand_int_range(0, NUM_CONTEXTS);", "schedule_next(VAR_0);", "qemu_coroutine_yield();", "g_assert(to_schedule[id] == NULL);", "atomic_mb_set(&to_schedule[id], qemu_coroutine_self());", "}", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ] ]
383
static int qcow_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQcowState *s = bs->opaque; int len, i, shift, ret; QCowHeader header; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { goto fail; } be32_to_cpus(&header.magic); be32_to_cpus(&header.version); be64_to_cpus(&header.backing_file_offset); be32_to_cpus(&header.backing_file_size); be32_to_cpus(&header.mtime); be64_to_cpus(&header.size); be32_to_cpus(&header.crypt_method); be64_to_cpus(&header.l1_table_offset); if (header.magic != QCOW_MAGIC) { error_setg(errp, "Image not in qcow format"); ret = -EINVAL; goto fail; } if (header.version != QCOW_VERSION) { char version[64]; snprintf(version, sizeof(version), "QCOW version %" PRIu32, header.version); error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, bs->device_name, "qcow", version); ret = -ENOTSUP; goto fail; } if (header.size <= 1) { error_setg(errp, "Image size is too small (must be at least 2 bytes)"); ret = -EINVAL; goto fail; } if (header.cluster_bits < 9 || header.cluster_bits > 16) { error_setg(errp, "Cluster size must be between 512 and 64k"); ret = -EINVAL; goto fail; } /* l2_bits specifies number of entries; storing a uint64_t in each entry, * so bytes = num_entries << 3. */ if (header.l2_bits < 9 - 3 || header.l2_bits > 16 - 3) { error_setg(errp, "L2 table size must be between 512 and 64k"); ret = -EINVAL; goto fail; } if (header.crypt_method > QCOW_CRYPT_AES) { error_setg(errp, "invalid encryption method in qcow header"); ret = -EINVAL; goto fail; } s->crypt_method_header = header.crypt_method; if (s->crypt_method_header) { bs->encrypted = 1; } s->cluster_bits = header.cluster_bits; s->cluster_size = 1 << s->cluster_bits; s->cluster_sectors = 1 << (s->cluster_bits - 9); s->l2_bits = header.l2_bits; s->l2_size = 1 << s->l2_bits; bs->total_sectors = header.size / 512; s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1; /* read the level 1 table */ shift = s->cluster_bits + s->l2_bits; if (header.size > UINT64_MAX - (1LL << shift)) { error_setg(errp, "Image too large"); ret = -EINVAL; goto fail; } else { uint64_t l1_size = (header.size + (1LL << shift) - 1) >> shift; if (l1_size > INT_MAX / sizeof(uint64_t)) { error_setg(errp, "Image too large"); ret = -EINVAL; goto fail; } s->l1_size = l1_size; } s->l1_table_offset = header.l1_table_offset; s->l1_table = g_malloc(s->l1_size * sizeof(uint64_t)); ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { goto fail; } for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); } /* alloc L2 cache */ s->l2_cache = g_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); s->cluster_cache = g_malloc(s->cluster_size); s->cluster_data = g_malloc(s->cluster_size); s->cluster_cache_offset = -1; /* read the backing file name */ if (header.backing_file_offset != 0) { len = header.backing_file_size; if (len > 1023) { len = 1023; } ret = bdrv_pread(bs->file, header.backing_file_offset, bs->backing_file, len); if (ret < 0) { goto fail; } bs->backing_file[len] = '\0'; } /* Disable migration when qcow images are used */ error_set(&s->migration_blocker, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, "qcow", bs->device_name, "live migration"); migrate_add_blocker(s->migration_blocker); qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->l1_table); g_free(s->l2_cache); g_free(s->cluster_cache); g_free(s->cluster_data); return ret; }
true
qemu
d66e5cee002c471b78139228a4e7012736b375f9
static int qcow_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQcowState *s = bs->opaque; int len, i, shift, ret; QCowHeader header; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { goto fail; } be32_to_cpus(&header.magic); be32_to_cpus(&header.version); be64_to_cpus(&header.backing_file_offset); be32_to_cpus(&header.backing_file_size); be32_to_cpus(&header.mtime); be64_to_cpus(&header.size); be32_to_cpus(&header.crypt_method); be64_to_cpus(&header.l1_table_offset); if (header.magic != QCOW_MAGIC) { error_setg(errp, "Image not in qcow format"); ret = -EINVAL; goto fail; } if (header.version != QCOW_VERSION) { char version[64]; snprintf(version, sizeof(version), "QCOW version %" PRIu32, header.version); error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, bs->device_name, "qcow", version); ret = -ENOTSUP; goto fail; } if (header.size <= 1) { error_setg(errp, "Image size is too small (must be at least 2 bytes)"); ret = -EINVAL; goto fail; } if (header.cluster_bits < 9 || header.cluster_bits > 16) { error_setg(errp, "Cluster size must be between 512 and 64k"); ret = -EINVAL; goto fail; } if (header.l2_bits < 9 - 3 || header.l2_bits > 16 - 3) { error_setg(errp, "L2 table size must be between 512 and 64k"); ret = -EINVAL; goto fail; } if (header.crypt_method > QCOW_CRYPT_AES) { error_setg(errp, "invalid encryption method in qcow header"); ret = -EINVAL; goto fail; } s->crypt_method_header = header.crypt_method; if (s->crypt_method_header) { bs->encrypted = 1; } s->cluster_bits = header.cluster_bits; s->cluster_size = 1 << s->cluster_bits; s->cluster_sectors = 1 << (s->cluster_bits - 9); s->l2_bits = header.l2_bits; s->l2_size = 1 << s->l2_bits; bs->total_sectors = header.size / 512; s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1; shift = s->cluster_bits + s->l2_bits; if (header.size > UINT64_MAX - (1LL << shift)) { error_setg(errp, "Image too large"); ret = -EINVAL; goto fail; } else { uint64_t l1_size = (header.size + (1LL << shift) - 1) >> shift; if (l1_size > INT_MAX / sizeof(uint64_t)) { error_setg(errp, "Image too large"); ret = -EINVAL; goto fail; } s->l1_size = l1_size; } s->l1_table_offset = header.l1_table_offset; s->l1_table = g_malloc(s->l1_size * sizeof(uint64_t)); ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { goto fail; } for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); } s->l2_cache = g_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); s->cluster_cache = g_malloc(s->cluster_size); s->cluster_data = g_malloc(s->cluster_size); s->cluster_cache_offset = -1; if (header.backing_file_offset != 0) { len = header.backing_file_size; if (len > 1023) { len = 1023; } ret = bdrv_pread(bs->file, header.backing_file_offset, bs->backing_file, len); if (ret < 0) { goto fail; } bs->backing_file[len] = '\0'; } error_set(&s->migration_blocker, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, "qcow", bs->device_name, "live migration"); migrate_add_blocker(s->migration_blocker); qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->l1_table); g_free(s->l2_cache); g_free(s->cluster_cache); g_free(s->cluster_data); return ret; }
{ "code": [ " int len, i, shift, ret;", " len = 1023;" ], "line_no": [ 9, 219 ] }
static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2, Error **VAR_3) { BDRVQcowState *s = VAR_0->opaque; int VAR_4, VAR_5, VAR_6, VAR_7; QCowHeader header; VAR_7 = bdrv_pread(VAR_0->file, 0, &header, sizeof(header)); if (VAR_7 < 0) { goto fail; } be32_to_cpus(&header.magic); be32_to_cpus(&header.VAR_8); be64_to_cpus(&header.backing_file_offset); be32_to_cpus(&header.backing_file_size); be32_to_cpus(&header.mtime); be64_to_cpus(&header.size); be32_to_cpus(&header.crypt_method); be64_to_cpus(&header.l1_table_offset); if (header.magic != QCOW_MAGIC) { error_setg(VAR_3, "Image not in qcow format"); VAR_7 = -EINVAL; goto fail; } if (header.VAR_8 != QCOW_VERSION) { char VAR_8[64]; snprintf(VAR_8, sizeof(VAR_8), "QCOW VAR_8 %" PRIu32, header.VAR_8); error_set(VAR_3, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, VAR_0->device_name, "qcow", VAR_8); VAR_7 = -ENOTSUP; goto fail; } if (header.size <= 1) { error_setg(VAR_3, "Image size is too small (must be at least 2 bytes)"); VAR_7 = -EINVAL; goto fail; } if (header.cluster_bits < 9 || header.cluster_bits > 16) { error_setg(VAR_3, "Cluster size must be between 512 and 64k"); VAR_7 = -EINVAL; goto fail; } if (header.l2_bits < 9 - 3 || header.l2_bits > 16 - 3) { error_setg(VAR_3, "L2 table size must be between 512 and 64k"); VAR_7 = -EINVAL; goto fail; } if (header.crypt_method > QCOW_CRYPT_AES) { error_setg(VAR_3, "invalid encryption method in qcow header"); VAR_7 = -EINVAL; goto fail; } s->crypt_method_header = header.crypt_method; if (s->crypt_method_header) { VAR_0->encrypted = 1; } s->cluster_bits = header.cluster_bits; s->cluster_size = 1 << s->cluster_bits; s->cluster_sectors = 1 << (s->cluster_bits - 9); s->l2_bits = header.l2_bits; s->l2_size = 1 << s->l2_bits; VAR_0->total_sectors = header.size / 512; s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1; VAR_6 = s->cluster_bits + s->l2_bits; if (header.size > UINT64_MAX - (1LL << VAR_6)) { error_setg(VAR_3, "Image too large"); VAR_7 = -EINVAL; goto fail; } else { uint64_t l1_size = (header.size + (1LL << VAR_6) - 1) >> VAR_6; if (l1_size > INT_MAX / sizeof(uint64_t)) { error_setg(VAR_3, "Image too large"); VAR_7 = -EINVAL; goto fail; } s->l1_size = l1_size; } s->l1_table_offset = header.l1_table_offset; s->l1_table = g_malloc(s->l1_size * sizeof(uint64_t)); VAR_7 = bdrv_pread(VAR_0->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); if (VAR_7 < 0) { goto fail; } for(VAR_5 = 0;VAR_5 < s->l1_size; VAR_5++) { be64_to_cpus(&s->l1_table[VAR_5]); } s->l2_cache = g_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); s->cluster_cache = g_malloc(s->cluster_size); s->cluster_data = g_malloc(s->cluster_size); s->cluster_cache_offset = -1; if (header.backing_file_offset != 0) { VAR_4 = header.backing_file_size; if (VAR_4 > 1023) { VAR_4 = 1023; } VAR_7 = bdrv_pread(VAR_0->file, header.backing_file_offset, VAR_0->backing_file, VAR_4); if (VAR_7 < 0) { goto fail; } VAR_0->backing_file[VAR_4] = '\0'; } error_set(&s->migration_blocker, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, "qcow", VAR_0->device_name, "live migration"); migrate_add_blocker(s->migration_blocker); qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->l1_table); g_free(s->l2_cache); g_free(s->cluster_cache); g_free(s->cluster_data); return VAR_7; }
[ "static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{", "BDRVQcowState *s = VAR_0->opaque;", "int VAR_4, VAR_5, VAR_6, VAR_7;", "QCowHeader header;", "VAR_7 = bdrv_pread(VAR_0->file, 0, &header, sizeof(header));", "if (VAR_7 < 0) {", "goto fail;", "}", "be32_to_cpus(&header.magic);", "be32_to_cpus(&header.VAR_8);", "be64_to_cpus(&header.backing_file_offset);", "be32_to_cpus(&header.backing_file_size);", "be32_to_cpus(&header.mtime);", "be64_to_cpus(&header.size);", "be32_to_cpus(&header.crypt_method);", "be64_to_cpus(&header.l1_table_offset);", "if (header.magic != QCOW_MAGIC) {", "error_setg(VAR_3, \"Image not in qcow format\");", "VAR_7 = -EINVAL;", "goto fail;", "}", "if (header.VAR_8 != QCOW_VERSION) {", "char VAR_8[64];", "snprintf(VAR_8, sizeof(VAR_8), \"QCOW VAR_8 %\" PRIu32,\nheader.VAR_8);", "error_set(VAR_3, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,\nVAR_0->device_name, \"qcow\", VAR_8);", "VAR_7 = -ENOTSUP;", "goto fail;", "}", "if (header.size <= 1) {", "error_setg(VAR_3, \"Image size is too small (must be at least 2 bytes)\");", "VAR_7 = -EINVAL;", "goto fail;", "}", "if (header.cluster_bits < 9 || header.cluster_bits > 16) {", "error_setg(VAR_3, \"Cluster size must be between 512 and 64k\");", "VAR_7 = -EINVAL;", "goto fail;", "}", "if (header.l2_bits < 9 - 3 || header.l2_bits > 16 - 3) {", "error_setg(VAR_3, \"L2 table size must be between 512 and 64k\");", "VAR_7 = -EINVAL;", "goto fail;", "}", "if (header.crypt_method > QCOW_CRYPT_AES) {", "error_setg(VAR_3, \"invalid encryption method in qcow header\");", "VAR_7 = -EINVAL;", "goto fail;", "}", "s->crypt_method_header = header.crypt_method;", "if (s->crypt_method_header) {", "VAR_0->encrypted = 1;", "}", "s->cluster_bits = header.cluster_bits;", "s->cluster_size = 1 << s->cluster_bits;", "s->cluster_sectors = 1 << (s->cluster_bits - 9);", "s->l2_bits = header.l2_bits;", "s->l2_size = 1 << s->l2_bits;", "VAR_0->total_sectors = header.size / 512;", "s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1;", "VAR_6 = s->cluster_bits + s->l2_bits;", "if (header.size > UINT64_MAX - (1LL << VAR_6)) {", "error_setg(VAR_3, \"Image too large\");", "VAR_7 = -EINVAL;", "goto fail;", "} else {", "uint64_t l1_size = (header.size + (1LL << VAR_6) - 1) >> VAR_6;", "if (l1_size > INT_MAX / sizeof(uint64_t)) {", "error_setg(VAR_3, \"Image too large\");", "VAR_7 = -EINVAL;", "goto fail;", "}", "s->l1_size = l1_size;", "}", "s->l1_table_offset = header.l1_table_offset;", "s->l1_table = g_malloc(s->l1_size * sizeof(uint64_t));", "VAR_7 = bdrv_pread(VAR_0->file, s->l1_table_offset, s->l1_table,\ns->l1_size * sizeof(uint64_t));", "if (VAR_7 < 0) {", "goto fail;", "}", "for(VAR_5 = 0;VAR_5 < s->l1_size; VAR_5++) {", "be64_to_cpus(&s->l1_table[VAR_5]);", "}", "s->l2_cache = g_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t));", "s->cluster_cache = g_malloc(s->cluster_size);", "s->cluster_data = g_malloc(s->cluster_size);", "s->cluster_cache_offset = -1;", "if (header.backing_file_offset != 0) {", "VAR_4 = header.backing_file_size;", "if (VAR_4 > 1023) {", "VAR_4 = 1023;", "}", "VAR_7 = bdrv_pread(VAR_0->file, header.backing_file_offset,\nVAR_0->backing_file, VAR_4);", "if (VAR_7 < 0) {", "goto fail;", "}", "VAR_0->backing_file[VAR_4] = '\\0';", "}", "error_set(&s->migration_blocker,\nQERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED,\n\"qcow\", VAR_0->device_name, \"live migration\");", "migrate_add_blocker(s->migration_blocker);", "qemu_co_mutex_init(&s->lock);", "return 0;", "fail:\ng_free(s->l1_table);", "g_free(s->l2_cache);", "g_free(s->cluster_cache);", "g_free(s->cluster_data);", "return VAR_7;", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55, 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175 ], [ 177 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 197 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223, 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 241, 243, 245 ], [ 247 ], [ 251 ], [ 253 ], [ 257, 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ] ]
384
static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, AVFilterBufferRef *ref) { AVFilterLink *outlink = ctx->outputs[0]; AVFilterBufferRef *buf; int channels, data_size, i; switch (outlink->type) { case AVMEDIA_TYPE_VIDEO: buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, ref->video->w, ref->video->h); av_image_copy(buf->data, buf->linesize, (void*)ref->data, ref->linesize, ref->format, ref->video->w, ref->video->h); break; case AVMEDIA_TYPE_AUDIO: buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE, ref->audio->nb_samples); channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout); av_samples_copy(buf->extended_data, ref->buf->extended_data, 0, 0, ref->audio->nb_samples, channels, ref->format); break; default: } avfilter_copy_buffer_ref_props(buf, ref); return buf; }
true
FFmpeg
ac87c273a646eb8feba8e47f15da4934d119f650
static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, AVFilterBufferRef *ref) { AVFilterLink *outlink = ctx->outputs[0]; AVFilterBufferRef *buf; int channels, data_size, i; switch (outlink->type) { case AVMEDIA_TYPE_VIDEO: buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, ref->video->w, ref->video->h); av_image_copy(buf->data, buf->linesize, (void*)ref->data, ref->linesize, ref->format, ref->video->w, ref->video->h); break; case AVMEDIA_TYPE_AUDIO: buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE, ref->audio->nb_samples); channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout); av_samples_copy(buf->extended_data, ref->buf->extended_data, 0, 0, ref->audio->nb_samples, channels, ref->format); break; default: } avfilter_copy_buffer_ref_props(buf, ref); return buf; }
{ "code": [], "line_no": [] }
static AVFilterBufferRef *FUNC_0(AVFilterContext *ctx, AVFilterBufferRef *ref) { AVFilterLink *outlink = ctx->outputs[0]; AVFilterBufferRef *buf; int VAR_0, VAR_1, VAR_2; switch (outlink->type) { case AVMEDIA_TYPE_VIDEO: buf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, ref->video->w, ref->video->h); av_image_copy(buf->data, buf->linesize, (void*)ref->data, ref->linesize, ref->format, ref->video->w, ref->video->h); break; case AVMEDIA_TYPE_AUDIO: buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE, ref->audio->nb_samples); VAR_0 = av_get_channel_layout_nb_channels(ref->audio->channel_layout); av_samples_copy(buf->extended_data, ref->buf->extended_data, 0, 0, ref->audio->nb_samples, VAR_0, ref->format); break; default: } avfilter_copy_buffer_ref_props(buf, ref); return buf; }
[ "static AVFilterBufferRef *FUNC_0(AVFilterContext *ctx,\nAVFilterBufferRef *ref)\n{", "AVFilterLink *outlink = ctx->outputs[0];", "AVFilterBufferRef *buf;", "int VAR_0, VAR_1, VAR_2;", "switch (outlink->type) {", "case AVMEDIA_TYPE_VIDEO:\nbuf = avfilter_get_video_buffer(outlink, AV_PERM_WRITE,\nref->video->w, ref->video->h);", "av_image_copy(buf->data, buf->linesize,\n(void*)ref->data, ref->linesize,\nref->format, ref->video->w, ref->video->h);", "break;", "case AVMEDIA_TYPE_AUDIO:\nbuf = ff_get_audio_buffer(outlink, AV_PERM_WRITE,\nref->audio->nb_samples);", "VAR_0 = av_get_channel_layout_nb_channels(ref->audio->channel_layout);", "av_samples_copy(buf->extended_data, ref->buf->extended_data,\n0, 0, ref->audio->nb_samples,\nVAR_0,\nref->format);", "break;", "default:\n}", "avfilter_copy_buffer_ref_props(buf, ref);", "return buf;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19, 21, 23 ], [ 27, 29, 31 ], [ 33 ], [ 37, 39, 41 ], [ 45 ], [ 47, 49, 51, 53 ], [ 55 ], [ 59, 62 ], [ 64 ], [ 66 ], [ 68 ] ]
385
void qmp_block_commit(const char *device, bool has_base, const char *base, const char *top, bool has_speed, int64_t speed, Error **errp) { BlockDriverState *bs; BlockDriverState *base_bs, *top_bs; Error *local_err = NULL; /* This will be part of the QMP command, if/when the * BlockdevOnError change for blkmirror makes it in */ BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT; /* drain all i/o before commits */ bdrv_drain_all(); bs = bdrv_find(device); if (!bs) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } if (base && has_base) { base_bs = bdrv_find_backing_image(bs, base); } else { base_bs = bdrv_find_base(bs); } if (base_bs == NULL) { error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL"); return; } /* default top_bs is the active layer */ top_bs = bs; if (top) { if (strcmp(bs->filename, top) != 0) { top_bs = bdrv_find_backing_image(bs, top); } } if (top_bs == NULL) { error_setg(errp, "Top image file %s not found", top ? top : "NULL"); return; } commit_start(bs, base_bs, top_bs, speed, on_error, block_job_cb, bs, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); return; } /* Grab a reference so hotplug does not delete the BlockDriverState from * underneath us. */ drive_get_ref(drive_get_by_blockdev(bs)); }
true
qemu
d5208c45be38ab858db6ec5a5097aa1c1a8ebbc9
void qmp_block_commit(const char *device, bool has_base, const char *base, const char *top, bool has_speed, int64_t speed, Error **errp) { BlockDriverState *bs; BlockDriverState *base_bs, *top_bs; Error *local_err = NULL; BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT; bdrv_drain_all(); bs = bdrv_find(device); if (!bs) { error_set(errp, QERR_DEVICE_NOT_FOUND, device); return; } if (base && has_base) { base_bs = bdrv_find_backing_image(bs, base); } else { base_bs = bdrv_find_base(bs); } if (base_bs == NULL) { error_set(errp, QERR_BASE_NOT_FOUND, base ? base : "NULL"); return; } top_bs = bs; if (top) { if (strcmp(bs->filename, top) != 0) { top_bs = bdrv_find_backing_image(bs, top); } } if (top_bs == NULL) { error_setg(errp, "Top image file %s not found", top ? top : "NULL"); return; } commit_start(bs, base_bs, top_bs, speed, on_error, block_job_cb, bs, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); return; } drive_get_ref(drive_get_by_blockdev(bs)); }
{ "code": [ " if (base && has_base) {", " base_bs = bdrv_find_backing_image(bs, base);", " } else {", " base_bs = bdrv_find_base(bs);", " if (base_bs == NULL) {", " error_set(errp, QERR_BASE_NOT_FOUND, base ? base : \"NULL\");" ], "line_no": [ 43, 45, 47, 49, 55, 57 ] }
void FUNC_0(const char *VAR_0, bool VAR_1, const char *VAR_2, const char *VAR_3, bool VAR_4, int64_t VAR_5, Error **VAR_6) { BlockDriverState *bs; BlockDriverState *base_bs, *top_bs; Error *local_err = NULL; BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT; bdrv_drain_all(); bs = bdrv_find(VAR_0); if (!bs) { error_set(VAR_6, QERR_DEVICE_NOT_FOUND, VAR_0); return; } if (VAR_2 && VAR_1) { base_bs = bdrv_find_backing_image(bs, VAR_2); } else { base_bs = bdrv_find_base(bs); } if (base_bs == NULL) { error_set(VAR_6, QERR_BASE_NOT_FOUND, VAR_2 ? VAR_2 : "NULL"); return; } top_bs = bs; if (VAR_3) { if (strcmp(bs->filename, VAR_3) != 0) { top_bs = bdrv_find_backing_image(bs, VAR_3); } } if (top_bs == NULL) { error_setg(VAR_6, "Top image file %s not found", VAR_3 ? VAR_3 : "NULL"); return; } commit_start(bs, base_bs, top_bs, VAR_5, on_error, block_job_cb, bs, &local_err); if (local_err != NULL) { error_propagate(VAR_6, local_err); return; } drive_get_ref(drive_get_by_blockdev(bs)); }
[ "void FUNC_0(const char *VAR_0,\nbool VAR_1, const char *VAR_2, const char *VAR_3,\nbool VAR_4, int64_t VAR_5,\nError **VAR_6)\n{", "BlockDriverState *bs;", "BlockDriverState *base_bs, *top_bs;", "Error *local_err = NULL;", "BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;", "bdrv_drain_all();", "bs = bdrv_find(VAR_0);", "if (!bs) {", "error_set(VAR_6, QERR_DEVICE_NOT_FOUND, VAR_0);", "return;", "}", "if (VAR_2 && VAR_1) {", "base_bs = bdrv_find_backing_image(bs, VAR_2);", "} else {", "base_bs = bdrv_find_base(bs);", "}", "if (base_bs == NULL) {", "error_set(VAR_6, QERR_BASE_NOT_FOUND, VAR_2 ? VAR_2 : \"NULL\");", "return;", "}", "top_bs = bs;", "if (VAR_3) {", "if (strcmp(bs->filename, VAR_3) != 0) {", "top_bs = bdrv_find_backing_image(bs, VAR_3);", "}", "}", "if (top_bs == NULL) {", "error_setg(VAR_6, \"Top image file %s not found\", VAR_3 ? VAR_3 : \"NULL\");", "return;", "}", "commit_start(bs, base_bs, top_bs, VAR_5, on_error, block_job_cb, bs,\n&local_err);", "if (local_err != NULL) {", "error_propagate(VAR_6, local_err);", "return;", "}", "drive_get_ref(drive_get_by_blockdev(bs));", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 23 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 111 ], [ 113 ] ]
386
static int mkv_check_tag(AVDictionary *m) { AVDictionaryEntry *t = NULL; while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) if (av_strcasecmp(t->key, "title") && av_strcasecmp(t->key, "stereo_mode")) return 1; return 0; }
false
FFmpeg
843e72ea5542845a0a9fed743517c14a92279885
static int mkv_check_tag(AVDictionary *m) { AVDictionaryEntry *t = NULL; while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) if (av_strcasecmp(t->key, "title") && av_strcasecmp(t->key, "stereo_mode")) return 1; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVDictionary *VAR_0) { AVDictionaryEntry *t = NULL; while ((t = av_dict_get(VAR_0, "", t, AV_DICT_IGNORE_SUFFIX))) if (av_strcasecmp(t->key, "title") && av_strcasecmp(t->key, "stereo_mode")) return 1; return 0; }
[ "static int FUNC_0(AVDictionary *VAR_0)\n{", "AVDictionaryEntry *t = NULL;", "while ((t = av_dict_get(VAR_0, \"\", t, AV_DICT_IGNORE_SUFFIX)))\nif (av_strcasecmp(t->key, \"title\") && av_strcasecmp(t->key, \"stereo_mode\"))\nreturn 1;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11, 13 ], [ 17 ], [ 19 ] ]
387
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645NAL *nal) { int i, si, di; uint8_t *dst; nal->skipped_bytes = 0; #define STARTCODE_TEST \ if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \ if (src[i + 2] != 3 && src[i + 2] != 0) { \ /* startcode, so we must be past the end */ \ length = i; \ } \ break; \ } #if HAVE_FAST_UNALIGNED #define FIND_FIRST_ZERO \ if (i > 0 && !src[i]) \ i--; \ while (src[i]) \ i++ #if HAVE_FAST_64BIT for (i = 0; i + 1 < length; i += 9) { if (!((~AV_RN64A(src + i) & (AV_RN64A(src + i) - 0x0100010001000101ULL)) & 0x8000800080008080ULL)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 7; } #else for (i = 0; i + 1 < length; i += 5) { if (!((~AV_RN32A(src + i) & (AV_RN32A(src + i) - 0x01000101U)) & 0x80008080U)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 3; } #endif /* HAVE_FAST_64BIT */ #else for (i = 0; i + 1 < length; i += 2) { if (src[i]) continue; if (i > 0 && src[i - 1] == 0) i--; STARTCODE_TEST; } #endif /* HAVE_FAST_UNALIGNED */ if (i >= length - 1) { // no escaped 0 nal->data = nal->raw_data = src; nal->size = nal->raw_size = length; return length; } av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size, length + AV_INPUT_BUFFER_PADDING_SIZE); if (!nal->rbsp_buffer) return AVERROR(ENOMEM); dst = nal->rbsp_buffer; memcpy(dst, src, i); si = di = i; while (si + 2 < length) { // remove escapes (very rare 1:2^22) if (src[si + 2] > 3) { dst[di++] = src[si++]; dst[di++] = src[si++]; } else if (src[si] == 0 && src[si + 1] == 0 && src[si + 2] != 0) { if (src[si + 2] == 3) { // escape dst[di++] = 0; dst[di++] = 0; si += 3; if (nal->skipped_bytes_pos) { nal->skipped_bytes++; if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { nal->skipped_bytes_pos_size *= 2; av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); av_reallocp_array(&nal->skipped_bytes_pos, nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); if (!nal->skipped_bytes_pos) { nal->skipped_bytes_pos_size = 0; return AVERROR(ENOMEM); } } if (nal->skipped_bytes_pos) nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; } continue; } else // next start code goto nsc; } dst[di++] = src[si++]; } while (si < length) dst[di++] = src[si++]; nsc: memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE); nal->data = dst; nal->size = di; nal->raw_data = src; nal->raw_size = si; return si; }
false
FFmpeg
cc13bc8c4f0f4afa30d0b94c3f3a369ccd2aaf0b
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645NAL *nal) { int i, si, di; uint8_t *dst; nal->skipped_bytes = 0; #define STARTCODE_TEST \ if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \ if (src[i + 2] != 3 && src[i + 2] != 0) { \ \ length = i; \ } \ break; \ } #if HAVE_FAST_UNALIGNED #define FIND_FIRST_ZERO \ if (i > 0 && !src[i]) \ i--; \ while (src[i]) \ i++ #if HAVE_FAST_64BIT for (i = 0; i + 1 < length; i += 9) { if (!((~AV_RN64A(src + i) & (AV_RN64A(src + i) - 0x0100010001000101ULL)) & 0x8000800080008080ULL)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 7; } #else for (i = 0; i + 1 < length; i += 5) { if (!((~AV_RN32A(src + i) & (AV_RN32A(src + i) - 0x01000101U)) & 0x80008080U)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 3; } #endif #else for (i = 0; i + 1 < length; i += 2) { if (src[i]) continue; if (i > 0 && src[i - 1] == 0) i--; STARTCODE_TEST; } #endif if (i >= length - 1) { nal->data = nal->raw_data = src; nal->size = nal->raw_size = length; return length; } av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size, length + AV_INPUT_BUFFER_PADDING_SIZE); if (!nal->rbsp_buffer) return AVERROR(ENOMEM); dst = nal->rbsp_buffer; memcpy(dst, src, i); si = di = i; while (si + 2 < length) { if (src[si + 2] > 3) { dst[di++] = src[si++]; dst[di++] = src[si++]; } else if (src[si] == 0 && src[si + 1] == 0 && src[si + 2] != 0) { if (src[si + 2] == 3) { dst[di++] = 0; dst[di++] = 0; si += 3; if (nal->skipped_bytes_pos) { nal->skipped_bytes++; if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { nal->skipped_bytes_pos_size *= 2; av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); av_reallocp_array(&nal->skipped_bytes_pos, nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); if (!nal->skipped_bytes_pos) { nal->skipped_bytes_pos_size = 0; return AVERROR(ENOMEM); } } if (nal->skipped_bytes_pos) nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; } continue; } else goto nsc; } dst[di++] = src[si++]; } while (si < length) dst[di++] = src[si++]; nsc: memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE); nal->data = dst; nal->size = di; nal->raw_data = src; nal->raw_size = si; return si; }
{ "code": [], "line_no": [] }
int FUNC_0(const uint8_t *VAR_0, int VAR_1, H2645NAL *VAR_2) { int VAR_3, VAR_4, VAR_5; uint8_t *dst; VAR_2->skipped_bytes = 0; #define STARTCODE_TEST \ if (VAR_3 + 2 < VAR_1 && VAR_0[VAR_3 + 1] == 0 && VAR_0[VAR_3 + 2] <= 3) { \ if (VAR_0[VAR_3 + 2] != 3 && VAR_0[VAR_3 + 2] != 0) { \ \ VAR_1 = VAR_3; \ } \ break; \ } #if HAVE_FAST_UNALIGNED #define FIND_FIRST_ZERO \ if (VAR_3 > 0 && !VAR_0[VAR_3]) \ VAR_3--; \ while (VAR_0[VAR_3]) \ VAR_3++ #if HAVE_FAST_64BIT for (VAR_3 = 0; VAR_3 + 1 < VAR_1; VAR_3 += 9) { if (!((~AV_RN64A(VAR_0 + VAR_3) & (AV_RN64A(VAR_0 + VAR_3) - 0x0100010001000101ULL)) & 0x8000800080008080ULL)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; VAR_3 -= 7; } #else for (VAR_3 = 0; VAR_3 + 1 < VAR_1; VAR_3 += 5) { if (!((~AV_RN32A(VAR_0 + VAR_3) & (AV_RN32A(VAR_0 + VAR_3) - 0x01000101U)) & 0x80008080U)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; VAR_3 -= 3; } #endif #else for (VAR_3 = 0; VAR_3 + 1 < VAR_1; VAR_3 += 2) { if (VAR_0[VAR_3]) continue; if (VAR_3 > 0 && VAR_0[VAR_3 - 1] == 0) VAR_3--; STARTCODE_TEST; } #endif if (VAR_3 >= VAR_1 - 1) { VAR_2->data = VAR_2->raw_data = VAR_0; VAR_2->size = VAR_2->raw_size = VAR_1; return VAR_1; } av_fast_malloc(&VAR_2->rbsp_buffer, &VAR_2->rbsp_buffer_size, VAR_1 + AV_INPUT_BUFFER_PADDING_SIZE); if (!VAR_2->rbsp_buffer) return AVERROR(ENOMEM); dst = VAR_2->rbsp_buffer; memcpy(dst, VAR_0, VAR_3); VAR_4 = VAR_5 = VAR_3; while (VAR_4 + 2 < VAR_1) { if (VAR_0[VAR_4 + 2] > 3) { dst[VAR_5++] = VAR_0[VAR_4++]; dst[VAR_5++] = VAR_0[VAR_4++]; } else if (VAR_0[VAR_4] == 0 && VAR_0[VAR_4 + 1] == 0 && VAR_0[VAR_4 + 2] != 0) { if (VAR_0[VAR_4 + 2] == 3) { dst[VAR_5++] = 0; dst[VAR_5++] = 0; VAR_4 += 3; if (VAR_2->skipped_bytes_pos) { VAR_2->skipped_bytes++; if (VAR_2->skipped_bytes_pos_size < VAR_2->skipped_bytes) { VAR_2->skipped_bytes_pos_size *= 2; av_assert0(VAR_2->skipped_bytes_pos_size >= VAR_2->skipped_bytes); av_reallocp_array(&VAR_2->skipped_bytes_pos, VAR_2->skipped_bytes_pos_size, sizeof(*VAR_2->skipped_bytes_pos)); if (!VAR_2->skipped_bytes_pos) { VAR_2->skipped_bytes_pos_size = 0; return AVERROR(ENOMEM); } } if (VAR_2->skipped_bytes_pos) VAR_2->skipped_bytes_pos[VAR_2->skipped_bytes-1] = VAR_5 - 1; } continue; } else goto nsc; } dst[VAR_5++] = VAR_0[VAR_4++]; } while (VAR_4 < VAR_1) dst[VAR_5++] = VAR_0[VAR_4++]; nsc: memset(dst + VAR_5, 0, AV_INPUT_BUFFER_PADDING_SIZE); VAR_2->data = dst; VAR_2->size = VAR_5; VAR_2->raw_data = VAR_0; VAR_2->raw_size = VAR_4; return VAR_4; }
[ "int FUNC_0(const uint8_t *VAR_0, int VAR_1,\nH2645NAL *VAR_2)\n{", "int VAR_3, VAR_4, VAR_5;", "uint8_t *dst;", "VAR_2->skipped_bytes = 0;", "#define STARTCODE_TEST \\\nif (VAR_3 + 2 < VAR_1 && VAR_0[VAR_3 + 1] == 0 && VAR_0[VAR_3 + 2] <= 3) { \\", "if (VAR_0[VAR_3 + 2] != 3 && VAR_0[VAR_3 + 2] != 0) { \\", "\\\nVAR_1 = VAR_3; \\", "} \\", "break; \\", "}", "#if HAVE_FAST_UNALIGNED\n#define FIND_FIRST_ZERO \\\nif (VAR_3 > 0 && !VAR_0[VAR_3]) \\\nVAR_3--; \\", "while (VAR_0[VAR_3]) \\\nVAR_3++\n#if HAVE_FAST_64BIT\nfor (VAR_3 = 0; VAR_3 + 1 < VAR_1; VAR_3 += 9) {", "if (!((~AV_RN64A(VAR_0 + VAR_3) &\n(AV_RN64A(VAR_0 + VAR_3) - 0x0100010001000101ULL)) &\n0x8000800080008080ULL))\ncontinue;", "FIND_FIRST_ZERO;", "STARTCODE_TEST;", "VAR_3 -= 7;", "}", "#else\nfor (VAR_3 = 0; VAR_3 + 1 < VAR_1; VAR_3 += 5) {", "if (!((~AV_RN32A(VAR_0 + VAR_3) &\n(AV_RN32A(VAR_0 + VAR_3) - 0x01000101U)) &\n0x80008080U))\ncontinue;", "FIND_FIRST_ZERO;", "STARTCODE_TEST;", "VAR_3 -= 3;", "}", "#endif\n#else\nfor (VAR_3 = 0; VAR_3 + 1 < VAR_1; VAR_3 += 2) {", "if (VAR_0[VAR_3])\ncontinue;", "if (VAR_3 > 0 && VAR_0[VAR_3 - 1] == 0)\nVAR_3--;", "STARTCODE_TEST;", "}", "#endif\nif (VAR_3 >= VAR_1 - 1) {", "VAR_2->data =\nVAR_2->raw_data = VAR_0;", "VAR_2->size =\nVAR_2->raw_size = VAR_1;", "return VAR_1;", "}", "av_fast_malloc(&VAR_2->rbsp_buffer, &VAR_2->rbsp_buffer_size,\nVAR_1 + AV_INPUT_BUFFER_PADDING_SIZE);", "if (!VAR_2->rbsp_buffer)\nreturn AVERROR(ENOMEM);", "dst = VAR_2->rbsp_buffer;", "memcpy(dst, VAR_0, VAR_3);", "VAR_4 = VAR_5 = VAR_3;", "while (VAR_4 + 2 < VAR_1) {", "if (VAR_0[VAR_4 + 2] > 3) {", "dst[VAR_5++] = VAR_0[VAR_4++];", "dst[VAR_5++] = VAR_0[VAR_4++];", "} else if (VAR_0[VAR_4] == 0 && VAR_0[VAR_4 + 1] == 0 && VAR_0[VAR_4 + 2] != 0) {", "if (VAR_0[VAR_4 + 2] == 3) {", "dst[VAR_5++] = 0;", "dst[VAR_5++] = 0;", "VAR_4 += 3;", "if (VAR_2->skipped_bytes_pos) {", "VAR_2->skipped_bytes++;", "if (VAR_2->skipped_bytes_pos_size < VAR_2->skipped_bytes) {", "VAR_2->skipped_bytes_pos_size *= 2;", "av_assert0(VAR_2->skipped_bytes_pos_size >= VAR_2->skipped_bytes);", "av_reallocp_array(&VAR_2->skipped_bytes_pos,\nVAR_2->skipped_bytes_pos_size,\nsizeof(*VAR_2->skipped_bytes_pos));", "if (!VAR_2->skipped_bytes_pos) {", "VAR_2->skipped_bytes_pos_size = 0;", "return AVERROR(ENOMEM);", "}", "}", "if (VAR_2->skipped_bytes_pos)\nVAR_2->skipped_bytes_pos[VAR_2->skipped_bytes-1] = VAR_5 - 1;", "}", "continue;", "} else", "goto nsc;", "}", "dst[VAR_5++] = VAR_0[VAR_4++];", "}", "while (VAR_4 < VAR_1)\ndst[VAR_5++] = VAR_0[VAR_4++];", "nsc:\nmemset(dst + VAR_5, 0, AV_INPUT_BUFFER_PADDING_SIZE);", "VAR_2->data = dst;", "VAR_2->size = VAR_5;", "VAR_2->raw_data = VAR_0;", "VAR_2->raw_size = VAR_4;", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33, 35, 37 ], [ 39, 41, 43, 45 ], [ 47, 49, 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63, 65 ], [ 67, 69, 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85, 87 ], [ 89, 91 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 101, 105 ], [ 107, 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 121, 123 ], [ 125, 127 ], [ 131 ], [ 135 ], [ 137 ], [ 139 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 173, 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 203 ], [ 205 ], [ 207, 209 ], [ 213, 215 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ] ]
388
static int encode_mode(CinepakEncContext *s, CinepakMode mode, int h, int v1_size, int v4_size, int v4, AVPicture *scratch_pict, strip_info *info, unsigned char *buf) { int x, y, z, flags, bits, temp_size, header_ofs, ret = 0, mb_count = s->w * h / MB_AREA; int needs_extra_bit, should_write_temp; unsigned char temp[64]; //32/2 = 16 V4 blocks at 4 B each -> 64 B mb_info *mb; AVPicture sub_scratch; //encode codebooks if(v1_size) ret += encode_codebook(s, info->v1_codebook, v1_size, 0x22, 0x26, buf + ret); if(v4_size) ret += encode_codebook(s, info->v4_codebook, v4_size, 0x20, 0x24, buf + ret); //update scratch picture for(z = y = 0; y < h; y += MB_SIZE) { for(x = 0; x < s->w; x += MB_SIZE, z++) { mb = &s->mb[z]; if(mode == MODE_MC && mb->best_encoding == ENC_SKIP) continue; get_sub_picture(s, x, y, scratch_pict, &sub_scratch); if(mode == MODE_V1_ONLY || mb->best_encoding == ENC_V1) decode_v1_vector(s, &sub_scratch, mb, info); else if(mode != MODE_V1_ONLY && mb->best_encoding == ENC_V4) decode_v4_vector(s, &sub_scratch, mb->v4_vector[v4], info); } } switch(mode) { case MODE_V1_ONLY: //av_log(s->avctx, AV_LOG_INFO, "mb_count = %i\n", mb_count); ret += write_chunk_header(buf + ret, 0x32, mb_count); for(x = 0; x < mb_count; x++) buf[ret++] = s->mb[x].v1_vector; break; case MODE_V1_V4: //remember header position header_ofs = ret; ret += CHUNK_HEADER_SIZE; for(x = 0; x < mb_count; x += 32) { flags = 0; for(y = x; y < FFMIN(x+32, mb_count); y++) if(s->mb[y].best_encoding == ENC_V4) flags |= 1 << (31 - y + x); AV_WB32(&buf[ret], flags); ret += 4; for(y = x; y < FFMIN(x+32, mb_count); y++) { mb = &s->mb[y]; if(mb->best_encoding == ENC_V1) buf[ret++] = mb->v1_vector; else for(z = 0; z < 4; z++) buf[ret++] = mb->v4_vector[v4][z]; } } write_chunk_header(buf + header_ofs, 0x30, ret - header_ofs - CHUNK_HEADER_SIZE); break; case MODE_MC: //remember header position header_ofs = ret; ret += CHUNK_HEADER_SIZE; flags = bits = temp_size = 0; for(x = 0; x < mb_count; x++) { mb = &s->mb[x]; flags |= (mb->best_encoding != ENC_SKIP) << (31 - bits++); needs_extra_bit = 0; should_write_temp = 0; if(mb->best_encoding != ENC_SKIP) { if(bits < 32) flags |= (mb->best_encoding == ENC_V4) << (31 - bits++); else needs_extra_bit = 1; } if(bits == 32) { AV_WB32(&buf[ret], flags); ret += 4; flags = bits = 0; if(mb->best_encoding == ENC_SKIP || needs_extra_bit) { memcpy(&buf[ret], temp, temp_size); ret += temp_size; temp_size = 0; } else should_write_temp = 1; } if(needs_extra_bit) { flags = (mb->best_encoding == ENC_V4) << 31; bits = 1; } if(mb->best_encoding == ENC_V1) temp[temp_size++] = mb->v1_vector; else if(mb->best_encoding == ENC_V4) for(z = 0; z < 4; z++) temp[temp_size++] = mb->v4_vector[v4][z]; if(should_write_temp) { memcpy(&buf[ret], temp, temp_size); ret += temp_size; temp_size = 0; } } if(bits > 0) { AV_WB32(&buf[ret], flags); ret += 4; memcpy(&buf[ret], temp, temp_size); ret += temp_size; } write_chunk_header(buf + header_ofs, 0x31, ret - header_ofs - CHUNK_HEADER_SIZE); break; } return ret; }
true
FFmpeg
7da9f4523159670d577a2808d4481e64008a8894
static int encode_mode(CinepakEncContext *s, CinepakMode mode, int h, int v1_size, int v4_size, int v4, AVPicture *scratch_pict, strip_info *info, unsigned char *buf) { int x, y, z, flags, bits, temp_size, header_ofs, ret = 0, mb_count = s->w * h / MB_AREA; int needs_extra_bit, should_write_temp; unsigned char temp[64]; mb_info *mb; AVPicture sub_scratch; if(v1_size) ret += encode_codebook(s, info->v1_codebook, v1_size, 0x22, 0x26, buf + ret); if(v4_size) ret += encode_codebook(s, info->v4_codebook, v4_size, 0x20, 0x24, buf + ret); for(z = y = 0; y < h; y += MB_SIZE) { for(x = 0; x < s->w; x += MB_SIZE, z++) { mb = &s->mb[z]; if(mode == MODE_MC && mb->best_encoding == ENC_SKIP) continue; get_sub_picture(s, x, y, scratch_pict, &sub_scratch); if(mode == MODE_V1_ONLY || mb->best_encoding == ENC_V1) decode_v1_vector(s, &sub_scratch, mb, info); else if(mode != MODE_V1_ONLY && mb->best_encoding == ENC_V4) decode_v4_vector(s, &sub_scratch, mb->v4_vector[v4], info); } } switch(mode) { case MODE_V1_ONLY: ret += write_chunk_header(buf + ret, 0x32, mb_count); for(x = 0; x < mb_count; x++) buf[ret++] = s->mb[x].v1_vector; break; case MODE_V1_V4: header_ofs = ret; ret += CHUNK_HEADER_SIZE; for(x = 0; x < mb_count; x += 32) { flags = 0; for(y = x; y < FFMIN(x+32, mb_count); y++) if(s->mb[y].best_encoding == ENC_V4) flags |= 1 << (31 - y + x); AV_WB32(&buf[ret], flags); ret += 4; for(y = x; y < FFMIN(x+32, mb_count); y++) { mb = &s->mb[y]; if(mb->best_encoding == ENC_V1) buf[ret++] = mb->v1_vector; else for(z = 0; z < 4; z++) buf[ret++] = mb->v4_vector[v4][z]; } } write_chunk_header(buf + header_ofs, 0x30, ret - header_ofs - CHUNK_HEADER_SIZE); break; case MODE_MC: header_ofs = ret; ret += CHUNK_HEADER_SIZE; flags = bits = temp_size = 0; for(x = 0; x < mb_count; x++) { mb = &s->mb[x]; flags |= (mb->best_encoding != ENC_SKIP) << (31 - bits++); needs_extra_bit = 0; should_write_temp = 0; if(mb->best_encoding != ENC_SKIP) { if(bits < 32) flags |= (mb->best_encoding == ENC_V4) << (31 - bits++); else needs_extra_bit = 1; } if(bits == 32) { AV_WB32(&buf[ret], flags); ret += 4; flags = bits = 0; if(mb->best_encoding == ENC_SKIP || needs_extra_bit) { memcpy(&buf[ret], temp, temp_size); ret += temp_size; temp_size = 0; } else should_write_temp = 1; } if(needs_extra_bit) { flags = (mb->best_encoding == ENC_V4) << 31; bits = 1; } if(mb->best_encoding == ENC_V1) temp[temp_size++] = mb->v1_vector; else if(mb->best_encoding == ENC_V4) for(z = 0; z < 4; z++) temp[temp_size++] = mb->v4_vector[v4][z]; if(should_write_temp) { memcpy(&buf[ret], temp, temp_size); ret += temp_size; temp_size = 0; } } if(bits > 0) { AV_WB32(&buf[ret], flags); ret += 4; memcpy(&buf[ret], temp, temp_size); ret += temp_size; } write_chunk_header(buf + header_ofs, 0x31, ret - header_ofs - CHUNK_HEADER_SIZE); break; } return ret; }
{ "code": [ " switch(mode) {", " for(x = 0; x < mb_count; x++) {", " mb = &s->mb[x];", " for(x = 0; x < mb_count; x++) {", " mb = &s->mb[x];", "static int encode_mode(CinepakEncContext *s, CinepakMode mode, int h, int v1_size, int v4_size, int v4, AVPicture *scratch_pict, strip_info *info, unsigned char *buf)", " AVPicture sub_scratch;", " if(v1_size)", " ret += encode_codebook(s, info->v1_codebook, v1_size, 0x22, 0x26, buf + ret);", " if(v4_size)", " ret += encode_codebook(s, info->v4_codebook, v4_size, 0x20, 0x24, buf + ret);", " if(mode == MODE_MC && mb->best_encoding == ENC_SKIP)", " continue;", " if(mode == MODE_V1_ONLY || mb->best_encoding == ENC_V1)", " decode_v1_vector(s, &sub_scratch, mb, info);", " else if(mode != MODE_V1_ONLY && mb->best_encoding == ENC_V4)", " decode_v4_vector(s, &sub_scratch, mb->v4_vector[v4], info);", " switch(mode) {", " buf[ret++] = mb->v4_vector[v4][z];", " temp[temp_size++] = mb->v4_vector[v4][z];", " return ret;" ], "line_no": [ 65, 151, 153, 151, 153, 1, 13, 19, 21, 25, 27, 41, 43, 51, 53, 55, 57, 65, 125, 221, 263 ] }
static int FUNC_0(CinepakEncContext *VAR_0, CinepakMode VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5, AVPicture *VAR_6, strip_info *VAR_7, unsigned char *VAR_8) { int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16 = 0, VAR_17 = VAR_0->w * VAR_2 / MB_AREA; int VAR_18, VAR_19; unsigned char VAR_20[64]; mb_info *mb; AVPicture sub_scratch; if(VAR_3) VAR_16 += encode_codebook(VAR_0, VAR_7->v1_codebook, VAR_3, 0x22, 0x26, VAR_8 + VAR_16); if(VAR_4) VAR_16 += encode_codebook(VAR_0, VAR_7->v4_codebook, VAR_4, 0x20, 0x24, VAR_8 + VAR_16); for(VAR_11 = VAR_10 = 0; VAR_10 < VAR_2; VAR_10 += MB_SIZE) { for(VAR_9 = 0; VAR_9 < VAR_0->w; VAR_9 += MB_SIZE, VAR_11++) { mb = &VAR_0->mb[VAR_11]; if(VAR_1 == MODE_MC && mb->best_encoding == ENC_SKIP) continue; get_sub_picture(VAR_0, VAR_9, VAR_10, VAR_6, &sub_scratch); if(VAR_1 == MODE_V1_ONLY || mb->best_encoding == ENC_V1) decode_v1_vector(VAR_0, &sub_scratch, mb, VAR_7); else if(VAR_1 != MODE_V1_ONLY && mb->best_encoding == ENC_V4) decode_v4_vector(VAR_0, &sub_scratch, mb->v4_vector[VAR_5], VAR_7); } } switch(VAR_1) { case MODE_V1_ONLY: VAR_16 += write_chunk_header(VAR_8 + VAR_16, 0x32, VAR_17); for(VAR_9 = 0; VAR_9 < VAR_17; VAR_9++) VAR_8[VAR_16++] = VAR_0->mb[VAR_9].v1_vector; break; case MODE_V1_V4: VAR_15 = VAR_16; VAR_16 += CHUNK_HEADER_SIZE; for(VAR_9 = 0; VAR_9 < VAR_17; VAR_9 += 32) { VAR_12 = 0; for(VAR_10 = VAR_9; VAR_10 < FFMIN(VAR_9+32, VAR_17); VAR_10++) if(VAR_0->mb[VAR_10].best_encoding == ENC_V4) VAR_12 |= 1 << (31 - VAR_10 + VAR_9); AV_WB32(&VAR_8[VAR_16], VAR_12); VAR_16 += 4; for(VAR_10 = VAR_9; VAR_10 < FFMIN(VAR_9+32, VAR_17); VAR_10++) { mb = &VAR_0->mb[VAR_10]; if(mb->best_encoding == ENC_V1) VAR_8[VAR_16++] = mb->v1_vector; else for(VAR_11 = 0; VAR_11 < 4; VAR_11++) VAR_8[VAR_16++] = mb->v4_vector[VAR_5][VAR_11]; } } write_chunk_header(VAR_8 + VAR_15, 0x30, VAR_16 - VAR_15 - CHUNK_HEADER_SIZE); break; case MODE_MC: VAR_15 = VAR_16; VAR_16 += CHUNK_HEADER_SIZE; VAR_12 = VAR_13 = VAR_14 = 0; for(VAR_9 = 0; VAR_9 < VAR_17; VAR_9++) { mb = &VAR_0->mb[VAR_9]; VAR_12 |= (mb->best_encoding != ENC_SKIP) << (31 - VAR_13++); VAR_18 = 0; VAR_19 = 0; if(mb->best_encoding != ENC_SKIP) { if(VAR_13 < 32) VAR_12 |= (mb->best_encoding == ENC_V4) << (31 - VAR_13++); else VAR_18 = 1; } if(VAR_13 == 32) { AV_WB32(&VAR_8[VAR_16], VAR_12); VAR_16 += 4; VAR_12 = VAR_13 = 0; if(mb->best_encoding == ENC_SKIP || VAR_18) { memcpy(&VAR_8[VAR_16], VAR_20, VAR_14); VAR_16 += VAR_14; VAR_14 = 0; } else VAR_19 = 1; } if(VAR_18) { VAR_12 = (mb->best_encoding == ENC_V4) << 31; VAR_13 = 1; } if(mb->best_encoding == ENC_V1) VAR_20[VAR_14++] = mb->v1_vector; else if(mb->best_encoding == ENC_V4) for(VAR_11 = 0; VAR_11 < 4; VAR_11++) VAR_20[VAR_14++] = mb->v4_vector[VAR_5][VAR_11]; if(VAR_19) { memcpy(&VAR_8[VAR_16], VAR_20, VAR_14); VAR_16 += VAR_14; VAR_14 = 0; } } if(VAR_13 > 0) { AV_WB32(&VAR_8[VAR_16], VAR_12); VAR_16 += 4; memcpy(&VAR_8[VAR_16], VAR_20, VAR_14); VAR_16 += VAR_14; } write_chunk_header(VAR_8 + VAR_15, 0x31, VAR_16 - VAR_15 - CHUNK_HEADER_SIZE); break; } return VAR_16; }
[ "static int FUNC_0(CinepakEncContext *VAR_0, CinepakMode VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5, AVPicture *VAR_6, strip_info *VAR_7, unsigned char *VAR_8)\n{", "int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, VAR_15, VAR_16 = 0, VAR_17 = VAR_0->w * VAR_2 / MB_AREA;", "int VAR_18, VAR_19;", "unsigned char VAR_20[64];", "mb_info *mb;", "AVPicture sub_scratch;", "if(VAR_3)\nVAR_16 += encode_codebook(VAR_0, VAR_7->v1_codebook, VAR_3, 0x22, 0x26, VAR_8 + VAR_16);", "if(VAR_4)\nVAR_16 += encode_codebook(VAR_0, VAR_7->v4_codebook, VAR_4, 0x20, 0x24, VAR_8 + VAR_16);", "for(VAR_11 = VAR_10 = 0; VAR_10 < VAR_2; VAR_10 += MB_SIZE) {", "for(VAR_9 = 0; VAR_9 < VAR_0->w; VAR_9 += MB_SIZE, VAR_11++) {", "mb = &VAR_0->mb[VAR_11];", "if(VAR_1 == MODE_MC && mb->best_encoding == ENC_SKIP)\ncontinue;", "get_sub_picture(VAR_0, VAR_9, VAR_10, VAR_6, &sub_scratch);", "if(VAR_1 == MODE_V1_ONLY || mb->best_encoding == ENC_V1)\ndecode_v1_vector(VAR_0, &sub_scratch, mb, VAR_7);", "else if(VAR_1 != MODE_V1_ONLY && mb->best_encoding == ENC_V4)\ndecode_v4_vector(VAR_0, &sub_scratch, mb->v4_vector[VAR_5], VAR_7);", "}", "}", "switch(VAR_1) {", "case MODE_V1_ONLY:\nVAR_16 += write_chunk_header(VAR_8 + VAR_16, 0x32, VAR_17);", "for(VAR_9 = 0; VAR_9 < VAR_17; VAR_9++)", "VAR_8[VAR_16++] = VAR_0->mb[VAR_9].v1_vector;", "break;", "case MODE_V1_V4:\nVAR_15 = VAR_16;", "VAR_16 += CHUNK_HEADER_SIZE;", "for(VAR_9 = 0; VAR_9 < VAR_17; VAR_9 += 32) {", "VAR_12 = 0;", "for(VAR_10 = VAR_9; VAR_10 < FFMIN(VAR_9+32, VAR_17); VAR_10++)", "if(VAR_0->mb[VAR_10].best_encoding == ENC_V4)\nVAR_12 |= 1 << (31 - VAR_10 + VAR_9);", "AV_WB32(&VAR_8[VAR_16], VAR_12);", "VAR_16 += 4;", "for(VAR_10 = VAR_9; VAR_10 < FFMIN(VAR_9+32, VAR_17); VAR_10++) {", "mb = &VAR_0->mb[VAR_10];", "if(mb->best_encoding == ENC_V1)\nVAR_8[VAR_16++] = mb->v1_vector;", "else\nfor(VAR_11 = 0; VAR_11 < 4; VAR_11++)", "VAR_8[VAR_16++] = mb->v4_vector[VAR_5][VAR_11];", "}", "}", "write_chunk_header(VAR_8 + VAR_15, 0x30, VAR_16 - VAR_15 - CHUNK_HEADER_SIZE);", "break;", "case MODE_MC:\nVAR_15 = VAR_16;", "VAR_16 += CHUNK_HEADER_SIZE;", "VAR_12 = VAR_13 = VAR_14 = 0;", "for(VAR_9 = 0; VAR_9 < VAR_17; VAR_9++) {", "mb = &VAR_0->mb[VAR_9];", "VAR_12 |= (mb->best_encoding != ENC_SKIP) << (31 - VAR_13++);", "VAR_18 = 0;", "VAR_19 = 0;", "if(mb->best_encoding != ENC_SKIP) {", "if(VAR_13 < 32)\nVAR_12 |= (mb->best_encoding == ENC_V4) << (31 - VAR_13++);", "else\nVAR_18 = 1;", "}", "if(VAR_13 == 32) {", "AV_WB32(&VAR_8[VAR_16], VAR_12);", "VAR_16 += 4;", "VAR_12 = VAR_13 = 0;", "if(mb->best_encoding == ENC_SKIP || VAR_18) {", "memcpy(&VAR_8[VAR_16], VAR_20, VAR_14);", "VAR_16 += VAR_14;", "VAR_14 = 0;", "} else", "VAR_19 = 1;", "}", "if(VAR_18) {", "VAR_12 = (mb->best_encoding == ENC_V4) << 31;", "VAR_13 = 1;", "}", "if(mb->best_encoding == ENC_V1)\nVAR_20[VAR_14++] = mb->v1_vector;", "else if(mb->best_encoding == ENC_V4)\nfor(VAR_11 = 0; VAR_11 < 4; VAR_11++)", "VAR_20[VAR_14++] = mb->v4_vector[VAR_5][VAR_11];", "if(VAR_19) {", "memcpy(&VAR_8[VAR_16], VAR_20, VAR_14);", "VAR_16 += VAR_14;", "VAR_14 = 0;", "}", "}", "if(VAR_13 > 0) {", "AV_WB32(&VAR_8[VAR_16], VAR_12);", "VAR_16 += 4;", "memcpy(&VAR_8[VAR_16], VAR_20, VAR_14);", "VAR_16 += VAR_14;", "}", "write_chunk_header(VAR_8 + VAR_15, 0x31, VAR_16 - VAR_15 - CHUNK_HEADER_SIZE);", "break;", "}", "return VAR_16;", "}" ]
[ 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 19, 21 ], [ 25, 27 ], [ 33 ], [ 35 ], [ 37 ], [ 41, 43 ], [ 47 ], [ 51, 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67, 71 ], [ 75 ], [ 77 ], [ 81 ], [ 83, 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 117, 119 ], [ 121, 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 137 ], [ 139, 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 163 ], [ 165, 167 ], [ 169, 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 213, 215 ], [ 217, 219 ], [ 221 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 253 ], [ 257 ], [ 259 ], [ 263 ], [ 265 ] ]
389
static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap) { ByteIOContext *pb = &s->pb; SmackerContext *smk = (SmackerContext *)s->priv_data; AVStream *st, *ast[7]; int i, ret; int tbase; /* read and check header */ smk->magic = get_le32(pb); if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4')) smk->width = get_le32(pb); smk->height = get_le32(pb); smk->frames = get_le32(pb); smk->pts_inc = (int32_t)get_le32(pb); smk->flags = get_le32(pb); for(i = 0; i < 7; i++) smk->audio[i] = get_le32(pb); smk->treesize = get_le32(pb); smk->mmap_size = get_le32(pb); smk->mclr_size = get_le32(pb); smk->full_size = get_le32(pb); smk->type_size = get_le32(pb); for(i = 0; i < 7; i++) smk->rates[i] = get_le32(pb); smk->pad = get_le32(pb); /* setup data */ if(smk->frames > 0xFFFFFF) { av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames); smk->frm_size = av_malloc(smk->frames * 4); smk->frm_flags = av_malloc(smk->frames); smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2')); /* read frame info */ for(i = 0; i < smk->frames; i++) { smk->frm_size[i] = get_le32(pb); for(i = 0; i < smk->frames; i++) { smk->frm_flags[i] = get_byte(pb); /* init video codec */ st = av_new_stream(s, 0); if (!st) smk->videoindex = st->index; st->codec->width = smk->width; st->codec->height = smk->height; st->codec->pix_fmt = PIX_FMT_PAL8; st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_SMACKVIDEO; st->codec->codec_tag = smk->is_ver4; /* Smacker uses 100000 as internal timebase */ if(smk->pts_inc < 0) smk->pts_inc = -smk->pts_inc; else smk->pts_inc *= 100; tbase = 100000; av_reduce(&tbase, &smk->pts_inc, tbase, smk->pts_inc, (1UL<<31)-1); av_set_pts_info(st, 33, smk->pts_inc, tbase); /* handle possible audio streams */ for(i = 0; i < 7; i++) { smk->indexes[i] = -1; if((smk->rates[i] & 0xFFFFFF) && !(smk->rates[i] & SMK_AUD_BINKAUD)){ ast[i] = av_new_stream(s, 0); smk->indexes[i] = ast[i]->index; av_set_pts_info(ast[i], 33, smk->pts_inc, tbase); ast[i]->codec->codec_type = CODEC_TYPE_AUDIO; ast[i]->codec->codec_id = (smk->rates[i] & SMK_AUD_PACKED) ? CODEC_ID_SMACKAUDIO : CODEC_ID_PCM_U8; ast[i]->codec->codec_tag = 0; ast[i]->codec->channels = (smk->rates[i] & SMK_AUD_STEREO) ? 2 : 1; ast[i]->codec->sample_rate = smk->rates[i] & 0xFFFFFF; ast[i]->codec->bits_per_sample = (smk->rates[i] & SMK_AUD_16BITS) ? 16 : 8; if(ast[i]->codec->bits_per_sample == 16 && ast[i]->codec->codec_id == CODEC_ID_PCM_U8) ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; /* load trees to extradata, they will be unpacked by decoder */ st->codec->extradata = av_malloc(smk->treesize + 16); st->codec->extradata_size = smk->treesize + 16; if(!st->codec->extradata){ av_log(s, AV_LOG_ERROR, "Cannot allocate %i bytes of extradata\n", smk->treesize + 16); av_free(smk->frm_size); av_free(smk->frm_flags); ret = get_buffer(pb, st->codec->extradata + 16, st->codec->extradata_size - 16); if(ret != st->codec->extradata_size - 16){ av_free(smk->frm_size); av_free(smk->frm_flags); return AVERROR_IO; ((int32_t*)st->codec->extradata)[0] = le2me_32(smk->mmap_size); ((int32_t*)st->codec->extradata)[1] = le2me_32(smk->mclr_size); ((int32_t*)st->codec->extradata)[2] = le2me_32(smk->full_size); ((int32_t*)st->codec->extradata)[3] = le2me_32(smk->type_size); smk->curstream = -1; smk->nextpos = url_ftell(pb); return 0;
true
FFmpeg
a443a2530d00b7019269202ac0f5ca8ba0a021c7
static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap) { ByteIOContext *pb = &s->pb; SmackerContext *smk = (SmackerContext *)s->priv_data; AVStream *st, *ast[7]; int i, ret; int tbase; smk->magic = get_le32(pb); if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4')) smk->width = get_le32(pb); smk->height = get_le32(pb); smk->frames = get_le32(pb); smk->pts_inc = (int32_t)get_le32(pb); smk->flags = get_le32(pb); for(i = 0; i < 7; i++) smk->audio[i] = get_le32(pb); smk->treesize = get_le32(pb); smk->mmap_size = get_le32(pb); smk->mclr_size = get_le32(pb); smk->full_size = get_le32(pb); smk->type_size = get_le32(pb); for(i = 0; i < 7; i++) smk->rates[i] = get_le32(pb); smk->pad = get_le32(pb); if(smk->frames > 0xFFFFFF) { av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames); smk->frm_size = av_malloc(smk->frames * 4); smk->frm_flags = av_malloc(smk->frames); smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2')); for(i = 0; i < smk->frames; i++) { smk->frm_size[i] = get_le32(pb); for(i = 0; i < smk->frames; i++) { smk->frm_flags[i] = get_byte(pb); st = av_new_stream(s, 0); if (!st) smk->videoindex = st->index; st->codec->width = smk->width; st->codec->height = smk->height; st->codec->pix_fmt = PIX_FMT_PAL8; st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_SMACKVIDEO; st->codec->codec_tag = smk->is_ver4; if(smk->pts_inc < 0) smk->pts_inc = -smk->pts_inc; else smk->pts_inc *= 100; tbase = 100000; av_reduce(&tbase, &smk->pts_inc, tbase, smk->pts_inc, (1UL<<31)-1); av_set_pts_info(st, 33, smk->pts_inc, tbase); for(i = 0; i < 7; i++) { smk->indexes[i] = -1; if((smk->rates[i] & 0xFFFFFF) && !(smk->rates[i] & SMK_AUD_BINKAUD)){ ast[i] = av_new_stream(s, 0); smk->indexes[i] = ast[i]->index; av_set_pts_info(ast[i], 33, smk->pts_inc, tbase); ast[i]->codec->codec_type = CODEC_TYPE_AUDIO; ast[i]->codec->codec_id = (smk->rates[i] & SMK_AUD_PACKED) ? CODEC_ID_SMACKAUDIO : CODEC_ID_PCM_U8; ast[i]->codec->codec_tag = 0; ast[i]->codec->channels = (smk->rates[i] & SMK_AUD_STEREO) ? 2 : 1; ast[i]->codec->sample_rate = smk->rates[i] & 0xFFFFFF; ast[i]->codec->bits_per_sample = (smk->rates[i] & SMK_AUD_16BITS) ? 16 : 8; if(ast[i]->codec->bits_per_sample == 16 && ast[i]->codec->codec_id == CODEC_ID_PCM_U8) ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; st->codec->extradata = av_malloc(smk->treesize + 16); st->codec->extradata_size = smk->treesize + 16; if(!st->codec->extradata){ av_log(s, AV_LOG_ERROR, "Cannot allocate %i bytes of extradata\n", smk->treesize + 16); av_free(smk->frm_size); av_free(smk->frm_flags); ret = get_buffer(pb, st->codec->extradata + 16, st->codec->extradata_size - 16); if(ret != st->codec->extradata_size - 16){ av_free(smk->frm_size); av_free(smk->frm_flags); return AVERROR_IO; ((int32_t*)st->codec->extradata)[0] = le2me_32(smk->mmap_size); ((int32_t*)st->codec->extradata)[1] = le2me_32(smk->mclr_size); ((int32_t*)st->codec->extradata)[2] = le2me_32(smk->full_size); ((int32_t*)st->codec->extradata)[3] = le2me_32(smk->type_size); smk->curstream = -1; smk->nextpos = url_ftell(pb); return 0;
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1) { ByteIOContext *pb = &VAR_0->pb; SmackerContext *smk = (SmackerContext *)VAR_0->priv_data; AVStream *st, *ast[7]; int VAR_2, VAR_3; int VAR_4; smk->magic = get_le32(pb); if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4')) smk->width = get_le32(pb); smk->height = get_le32(pb); smk->frames = get_le32(pb); smk->pts_inc = (int32_t)get_le32(pb); smk->flags = get_le32(pb); for(VAR_2 = 0; VAR_2 < 7; VAR_2++) smk->audio[VAR_2] = get_le32(pb); smk->treesize = get_le32(pb); smk->mmap_size = get_le32(pb); smk->mclr_size = get_le32(pb); smk->full_size = get_le32(pb); smk->type_size = get_le32(pb); for(VAR_2 = 0; VAR_2 < 7; VAR_2++) smk->rates[VAR_2] = get_le32(pb); smk->pad = get_le32(pb); if(smk->frames > 0xFFFFFF) { av_log(VAR_0, AV_LOG_ERROR, "Too many frames: %VAR_2\n", smk->frames); smk->frm_size = av_malloc(smk->frames * 4); smk->frm_flags = av_malloc(smk->frames); smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2')); for(VAR_2 = 0; VAR_2 < smk->frames; VAR_2++) { smk->frm_size[VAR_2] = get_le32(pb); for(VAR_2 = 0; VAR_2 < smk->frames; VAR_2++) { smk->frm_flags[VAR_2] = get_byte(pb); st = av_new_stream(VAR_0, 0); if (!st) smk->videoindex = st->index; st->codec->width = smk->width; st->codec->height = smk->height; st->codec->pix_fmt = PIX_FMT_PAL8; st->codec->codec_type = CODEC_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_SMACKVIDEO; st->codec->codec_tag = smk->is_ver4; if(smk->pts_inc < 0) smk->pts_inc = -smk->pts_inc; else smk->pts_inc *= 100; VAR_4 = 100000; av_reduce(&VAR_4, &smk->pts_inc, VAR_4, smk->pts_inc, (1UL<<31)-1); av_set_pts_info(st, 33, smk->pts_inc, VAR_4); for(VAR_2 = 0; VAR_2 < 7; VAR_2++) { smk->indexes[VAR_2] = -1; if((smk->rates[VAR_2] & 0xFFFFFF) && !(smk->rates[VAR_2] & SMK_AUD_BINKAUD)){ ast[VAR_2] = av_new_stream(VAR_0, 0); smk->indexes[VAR_2] = ast[VAR_2]->index; av_set_pts_info(ast[VAR_2], 33, smk->pts_inc, VAR_4); ast[VAR_2]->codec->codec_type = CODEC_TYPE_AUDIO; ast[VAR_2]->codec->codec_id = (smk->rates[VAR_2] & SMK_AUD_PACKED) ? CODEC_ID_SMACKAUDIO : CODEC_ID_PCM_U8; ast[VAR_2]->codec->codec_tag = 0; ast[VAR_2]->codec->channels = (smk->rates[VAR_2] & SMK_AUD_STEREO) ? 2 : 1; ast[VAR_2]->codec->sample_rate = smk->rates[VAR_2] & 0xFFFFFF; ast[VAR_2]->codec->bits_per_sample = (smk->rates[VAR_2] & SMK_AUD_16BITS) ? 16 : 8; if(ast[VAR_2]->codec->bits_per_sample == 16 && ast[VAR_2]->codec->codec_id == CODEC_ID_PCM_U8) ast[VAR_2]->codec->codec_id = CODEC_ID_PCM_S16LE; st->codec->extradata = av_malloc(smk->treesize + 16); st->codec->extradata_size = smk->treesize + 16; if(!st->codec->extradata){ av_log(VAR_0, AV_LOG_ERROR, "Cannot allocate %VAR_2 bytes of extradata\n", smk->treesize + 16); av_free(smk->frm_size); av_free(smk->frm_flags); VAR_3 = get_buffer(pb, st->codec->extradata + 16, st->codec->extradata_size - 16); if(VAR_3 != st->codec->extradata_size - 16){ av_free(smk->frm_size); av_free(smk->frm_flags); return AVERROR_IO; ((int32_t*)st->codec->extradata)[0] = le2me_32(smk->mmap_size); ((int32_t*)st->codec->extradata)[1] = le2me_32(smk->mclr_size); ((int32_t*)st->codec->extradata)[2] = le2me_32(smk->full_size); ((int32_t*)st->codec->extradata)[3] = le2me_32(smk->type_size); smk->curstream = -1; smk->nextpos = url_ftell(pb); return 0;
[ "static int FUNC_0(AVFormatContext *VAR_0, AVFormatParameters *VAR_1)\n{", "ByteIOContext *pb = &VAR_0->pb;", "SmackerContext *smk = (SmackerContext *)VAR_0->priv_data;", "AVStream *st, *ast[7];", "int VAR_2, VAR_3;", "int VAR_4;", "smk->magic = get_le32(pb);", "if (smk->magic != MKTAG('S', 'M', 'K', '2') && smk->magic != MKTAG('S', 'M', 'K', '4'))\nsmk->width = get_le32(pb);", "smk->height = get_le32(pb);", "smk->frames = get_le32(pb);", "smk->pts_inc = (int32_t)get_le32(pb);", "smk->flags = get_le32(pb);", "for(VAR_2 = 0; VAR_2 < 7; VAR_2++)", "smk->audio[VAR_2] = get_le32(pb);", "smk->treesize = get_le32(pb);", "smk->mmap_size = get_le32(pb);", "smk->mclr_size = get_le32(pb);", "smk->full_size = get_le32(pb);", "smk->type_size = get_le32(pb);", "for(VAR_2 = 0; VAR_2 < 7; VAR_2++)", "smk->rates[VAR_2] = get_le32(pb);", "smk->pad = get_le32(pb);", "if(smk->frames > 0xFFFFFF) {", "av_log(VAR_0, AV_LOG_ERROR, \"Too many frames: %VAR_2\\n\", smk->frames);", "smk->frm_size = av_malloc(smk->frames * 4);", "smk->frm_flags = av_malloc(smk->frames);", "smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2'));", "for(VAR_2 = 0; VAR_2 < smk->frames; VAR_2++) {", "smk->frm_size[VAR_2] = get_le32(pb);", "for(VAR_2 = 0; VAR_2 < smk->frames; VAR_2++) {", "smk->frm_flags[VAR_2] = get_byte(pb);", "st = av_new_stream(VAR_0, 0);", "if (!st)\nsmk->videoindex = st->index;", "st->codec->width = smk->width;", "st->codec->height = smk->height;", "st->codec->pix_fmt = PIX_FMT_PAL8;", "st->codec->codec_type = CODEC_TYPE_VIDEO;", "st->codec->codec_id = CODEC_ID_SMACKVIDEO;", "st->codec->codec_tag = smk->is_ver4;", "if(smk->pts_inc < 0)\nsmk->pts_inc = -smk->pts_inc;", "else\nsmk->pts_inc *= 100;", "VAR_4 = 100000;", "av_reduce(&VAR_4, &smk->pts_inc, VAR_4, smk->pts_inc, (1UL<<31)-1);", "av_set_pts_info(st, 33, smk->pts_inc, VAR_4);", "for(VAR_2 = 0; VAR_2 < 7; VAR_2++) {", "smk->indexes[VAR_2] = -1;", "if((smk->rates[VAR_2] & 0xFFFFFF) && !(smk->rates[VAR_2] & SMK_AUD_BINKAUD)){", "ast[VAR_2] = av_new_stream(VAR_0, 0);", "smk->indexes[VAR_2] = ast[VAR_2]->index;", "av_set_pts_info(ast[VAR_2], 33, smk->pts_inc, VAR_4);", "ast[VAR_2]->codec->codec_type = CODEC_TYPE_AUDIO;", "ast[VAR_2]->codec->codec_id = (smk->rates[VAR_2] & SMK_AUD_PACKED) ? CODEC_ID_SMACKAUDIO : CODEC_ID_PCM_U8;", "ast[VAR_2]->codec->codec_tag = 0;", "ast[VAR_2]->codec->channels = (smk->rates[VAR_2] & SMK_AUD_STEREO) ? 2 : 1;", "ast[VAR_2]->codec->sample_rate = smk->rates[VAR_2] & 0xFFFFFF;", "ast[VAR_2]->codec->bits_per_sample = (smk->rates[VAR_2] & SMK_AUD_16BITS) ? 16 : 8;", "if(ast[VAR_2]->codec->bits_per_sample == 16 && ast[VAR_2]->codec->codec_id == CODEC_ID_PCM_U8)\nast[VAR_2]->codec->codec_id = CODEC_ID_PCM_S16LE;", "st->codec->extradata = av_malloc(smk->treesize + 16);", "st->codec->extradata_size = smk->treesize + 16;", "if(!st->codec->extradata){", "av_log(VAR_0, AV_LOG_ERROR, \"Cannot allocate %VAR_2 bytes of extradata\\n\", smk->treesize + 16);", "av_free(smk->frm_size);", "av_free(smk->frm_flags);", "VAR_3 = get_buffer(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);", "if(VAR_3 != st->codec->extradata_size - 16){", "av_free(smk->frm_size);", "av_free(smk->frm_flags);", "return AVERROR_IO;", "((int32_t*)st->codec->extradata)[0] = le2me_32(smk->mmap_size);", "((int32_t*)st->codec->extradata)[1] = le2me_32(smk->mclr_size);", "((int32_t*)st->codec->extradata)[2] = le2me_32(smk->full_size);", "((int32_t*)st->codec->extradata)[3] = le2me_32(smk->type_size);", "smk->curstream = -1;", "smk->nextpos = url_ftell(pb);", "return 0;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 9 ], [ 10, 11 ], [ 12 ], [ 13 ], [ 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18 ], [ 19 ], [ 20 ], [ 21 ], [ 22 ], [ 23 ], [ 24 ], [ 25 ], [ 27 ], [ 28 ], [ 29 ], [ 30 ], [ 31 ], [ 33 ], [ 34 ], [ 35 ], [ 36 ], [ 38 ], [ 39, 40 ], [ 41 ], [ 42 ], [ 43 ], [ 44 ], [ 45 ], [ 46 ], [ 48, 49 ], [ 50, 51 ], [ 52 ], [ 53 ], [ 54 ], [ 56 ], [ 57 ], [ 58 ], [ 59 ], [ 60 ], [ 61 ], [ 62 ], [ 63 ], [ 64 ], [ 65 ], [ 66 ], [ 67 ], [ 68, 69 ], [ 71 ], [ 72 ], [ 73 ], [ 74 ], [ 75 ], [ 76 ], [ 77 ], [ 78 ], [ 79 ], [ 80 ], [ 81 ], [ 82 ], [ 83 ], [ 84 ], [ 85 ], [ 86 ], [ 87 ], [ 88 ] ]
392
static void pci_edu_realize(PCIDevice *pdev, Error **errp) { EduState *edu = DO_UPCAST(EduState, pdev, pdev); uint8_t *pci_conf = pdev->config; timer_init_ms(&edu->dma_timer, QEMU_CLOCK_VIRTUAL, edu_dma_timer, edu); qemu_mutex_init(&edu->thr_mutex); qemu_cond_init(&edu->thr_cond); qemu_thread_create(&edu->thread, "edu", edu_fact_thread, edu, QEMU_THREAD_JOINABLE); pci_config_set_interrupt_pin(pci_conf, 1); if (msi_init(pdev, 0, 1, true, false, errp)) { return; } memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu, "edu-mmio", 1 << 20); pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio); }
true
qemu
c25a67f0c3d0c86231f9653267a222c4effa706f
static void pci_edu_realize(PCIDevice *pdev, Error **errp) { EduState *edu = DO_UPCAST(EduState, pdev, pdev); uint8_t *pci_conf = pdev->config; timer_init_ms(&edu->dma_timer, QEMU_CLOCK_VIRTUAL, edu_dma_timer, edu); qemu_mutex_init(&edu->thr_mutex); qemu_cond_init(&edu->thr_cond); qemu_thread_create(&edu->thread, "edu", edu_fact_thread, edu, QEMU_THREAD_JOINABLE); pci_config_set_interrupt_pin(pci_conf, 1); if (msi_init(pdev, 0, 1, true, false, errp)) { return; } memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu, "edu-mmio", 1 << 20); pci_register_bar(pdev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio); }
{ "code": [ " pci_config_set_interrupt_pin(pci_conf, 1);", " if (msi_init(pdev, 0, 1, true, false, errp)) {" ], "line_no": [ 25, 29 ] }
static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1) { EduState *edu = DO_UPCAST(EduState, VAR_0, VAR_0); uint8_t *pci_conf = VAR_0->config; timer_init_ms(&edu->dma_timer, QEMU_CLOCK_VIRTUAL, edu_dma_timer, edu); qemu_mutex_init(&edu->thr_mutex); qemu_cond_init(&edu->thr_cond); qemu_thread_create(&edu->thread, "edu", edu_fact_thread, edu, QEMU_THREAD_JOINABLE); pci_config_set_interrupt_pin(pci_conf, 1); if (msi_init(VAR_0, 0, 1, true, false, VAR_1)) { return; } memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu, "edu-mmio", 1 << 20); pci_register_bar(VAR_0, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio); }
[ "static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{", "EduState *edu = DO_UPCAST(EduState, VAR_0, VAR_0);", "uint8_t *pci_conf = VAR_0->config;", "timer_init_ms(&edu->dma_timer, QEMU_CLOCK_VIRTUAL, edu_dma_timer, edu);", "qemu_mutex_init(&edu->thr_mutex);", "qemu_cond_init(&edu->thr_cond);", "qemu_thread_create(&edu->thread, \"edu\", edu_fact_thread,\nedu, QEMU_THREAD_JOINABLE);", "pci_config_set_interrupt_pin(pci_conf, 1);", "if (msi_init(VAR_0, 0, 1, true, false, VAR_1)) {", "return;", "}", "memory_region_init_io(&edu->mmio, OBJECT(edu), &edu_mmio_ops, edu,\n\"edu-mmio\", 1 << 20);", "pci_register_bar(VAR_0, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &edu->mmio);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 37, 39 ], [ 41 ], [ 43 ] ]
393
uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, uint64_t address_space_size, uint64_t *hint, uint64_t size, Error **errp) { GSList *list = NULL, *item; uint64_t new_addr, ret = 0; uint64_t address_space_end = address_space_start + address_space_size; assert(address_space_end > address_space_size); object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list); if (hint) { new_addr = *hint; } else { new_addr = address_space_start; } /* find address range that will fit new DIMM */ for (item = list; item; item = g_slist_next(item)) { PCDIMMDevice *dimm = item->data; uint64_t dimm_size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP, errp); if (errp && *errp) { goto out; } if (ranges_overlap(dimm->addr, dimm_size, new_addr, size)) { if (hint) { DeviceState *d = DEVICE(dimm); error_setg(errp, "address range conflicts with '%s'", d->id); goto out; } new_addr = dimm->addr + dimm_size; } } ret = new_addr; if (new_addr < address_space_start) { error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64 "] at 0x%" PRIx64, new_addr, size, address_space_start); } else if ((new_addr + size) > address_space_end) { error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64 "] beyond 0x%" PRIx64, new_addr, size, address_space_end); } out: g_slist_free(list); return ret; }
true
qemu
9b79a76cdbb43b0b00aaf6e9421298842fc68841
uint64_t pc_dimm_get_free_addr(uint64_t address_space_start, uint64_t address_space_size, uint64_t *hint, uint64_t size, Error **errp) { GSList *list = NULL, *item; uint64_t new_addr, ret = 0; uint64_t address_space_end = address_space_start + address_space_size; assert(address_space_end > address_space_size); object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list); if (hint) { new_addr = *hint; } else { new_addr = address_space_start; } for (item = list; item; item = g_slist_next(item)) { PCDIMMDevice *dimm = item->data; uint64_t dimm_size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP, errp); if (errp && *errp) { goto out; } if (ranges_overlap(dimm->addr, dimm_size, new_addr, size)) { if (hint) { DeviceState *d = DEVICE(dimm); error_setg(errp, "address range conflicts with '%s'", d->id); goto out; } new_addr = dimm->addr + dimm_size; } } ret = new_addr; if (new_addr < address_space_start) { error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64 "] at 0x%" PRIx64, new_addr, size, address_space_start); } else if ((new_addr + size) > address_space_end) { error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64 "] beyond 0x%" PRIx64, new_addr, size, address_space_end); } out: g_slist_free(list); return ret; }
{ "code": [ " assert(address_space_end > address_space_size);" ], "line_no": [ 19 ] }
uint64_t FUNC_0(uint64_t address_space_start, uint64_t address_space_size, uint64_t *hint, uint64_t size, Error **errp) { GSList *list = NULL, *item; uint64_t new_addr, ret = 0; uint64_t address_space_end = address_space_start + address_space_size; assert(address_space_end > address_space_size); object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list); if (hint) { new_addr = *hint; } else { new_addr = address_space_start; } for (item = list; item; item = g_slist_next(item)) { PCDIMMDevice *dimm = item->data; uint64_t dimm_size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP, errp); if (errp && *errp) { goto out; } if (ranges_overlap(dimm->addr, dimm_size, new_addr, size)) { if (hint) { DeviceState *d = DEVICE(dimm); error_setg(errp, "address range conflicts with '%s'", d->id); goto out; } new_addr = dimm->addr + dimm_size; } } ret = new_addr; if (new_addr < address_space_start) { error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64 "] at 0x%" PRIx64, new_addr, size, address_space_start); } else if ((new_addr + size) > address_space_end) { error_setg(errp, "can't add memory [0x%" PRIx64 ":0x%" PRIx64 "] beyond 0x%" PRIx64, new_addr, size, address_space_end); } out: g_slist_free(list); return ret; }
[ "uint64_t FUNC_0(uint64_t address_space_start,\nuint64_t address_space_size,\nuint64_t *hint, uint64_t size,\nError **errp)\n{", "GSList *list = NULL, *item;", "uint64_t new_addr, ret = 0;", "uint64_t address_space_end = address_space_start + address_space_size;", "assert(address_space_end > address_space_size);", "object_child_foreach(qdev_get_machine(), pc_dimm_built_list, &list);", "if (hint) {", "new_addr = *hint;", "} else {", "new_addr = address_space_start;", "}", "for (item = list; item; item = g_slist_next(item)) {", "PCDIMMDevice *dimm = item->data;", "uint64_t dimm_size = object_property_get_int(OBJECT(dimm),\nPC_DIMM_SIZE_PROP,\nerrp);", "if (errp && *errp) {", "goto out;", "}", "if (ranges_overlap(dimm->addr, dimm_size, new_addr, size)) {", "if (hint) {", "DeviceState *d = DEVICE(dimm);", "error_setg(errp, \"address range conflicts with '%s'\", d->id);", "goto out;", "}", "new_addr = dimm->addr + dimm_size;", "}", "}", "ret = new_addr;", "if (new_addr < address_space_start) {", "error_setg(errp, \"can't add memory [0x%\" PRIx64 \":0x%\" PRIx64\n\"] at 0x%\" PRIx64, new_addr, size, address_space_start);", "} else if ((new_addr + size) > address_space_end) {", "error_setg(errp, \"can't add memory [0x%\" PRIx64 \":0x%\" PRIx64\n\"] beyond 0x%\" PRIx64, new_addr, size, address_space_end);", "}", "out:\ng_slist_free(list);", "return ret;", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 39 ], [ 41 ], [ 43, 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 95, 97 ], [ 99 ], [ 101 ] ]
394
static int wma_decode_block(WMACodecContext *s) { int n, v, a, ch, bsize; int coef_nb_bits, total_gain; int nb_coefs[MAX_CHANNELS]; float mdct_norm; FFTContext *mdct; #ifdef TRACE tprintf(s->avctx, "***decode_block: %d:%d\n", s->frame_count - 1, s->block_num); #endif /* compute current block length */ if (s->use_variable_block_len) { n = av_log2(s->nb_block_sizes - 1) + 1; if (s->reset_block_lengths) { s->reset_block_lengths = 0; v = get_bits(&s->gb, n); if (v >= s->nb_block_sizes){ av_log(s->avctx, AV_LOG_ERROR, "prev_block_len_bits %d out of range\n", s->frame_len_bits - v); return -1; s->prev_block_len_bits = s->frame_len_bits - v; v = get_bits(&s->gb, n); if (v >= s->nb_block_sizes){ av_log(s->avctx, AV_LOG_ERROR, "block_len_bits %d out of range\n", s->frame_len_bits - v); return -1; s->block_len_bits = s->frame_len_bits - v; } else { /* update block lengths */ s->prev_block_len_bits = s->block_len_bits; s->block_len_bits = s->next_block_len_bits; v = get_bits(&s->gb, n); if (v >= s->nb_block_sizes){ av_log(s->avctx, AV_LOG_ERROR, "next_block_len_bits %d out of range\n", s->frame_len_bits - v); return -1; s->next_block_len_bits = s->frame_len_bits - v; } else { /* fixed block len */ s->next_block_len_bits = s->frame_len_bits; s->prev_block_len_bits = s->frame_len_bits; s->block_len_bits = s->frame_len_bits; if (s->frame_len_bits - s->block_len_bits >= s->nb_block_sizes){ av_log(s->avctx, AV_LOG_ERROR, "block_len_bits not initialized to a valid value\n"); return -1; /* now check if the block length is coherent with the frame length */ s->block_len = 1 << s->block_len_bits; if ((s->block_pos + s->block_len) > s->frame_len){ av_log(s->avctx, AV_LOG_ERROR, "frame_len overflow\n"); return -1; if (s->avctx->channels == 2) { s->ms_stereo = get_bits1(&s->gb); v = 0; for(ch = 0; ch < s->avctx->channels; ch++) { a = get_bits1(&s->gb); s->channel_coded[ch] = a; v |= a; bsize = s->frame_len_bits - s->block_len_bits; /* if no channel coded, no need to go further */ /* XXX: fix potential framing problems */ if (!v) goto next; /* read total gain and extract corresponding number of bits for coef escape coding */ total_gain = 1; for(;;) { a = get_bits(&s->gb, 7); total_gain += a; if (a != 127) break; coef_nb_bits= ff_wma_total_gain_to_bits(total_gain); /* compute number of coefficients */ n = s->coefs_end[bsize] - s->coefs_start; for(ch = 0; ch < s->avctx->channels; ch++) nb_coefs[ch] = n; /* complex coding */ if (s->use_noise_coding) { for(ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { int i, n, a; n = s->exponent_high_sizes[bsize]; for(i=0;i<n;i++) { a = get_bits1(&s->gb); s->high_band_coded[ch][i] = a; /* if noise coding, the coefficients are not transmitted */ if (a) nb_coefs[ch] -= s->exponent_high_bands[bsize][i]; for(ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { int i, n, val, code; n = s->exponent_high_sizes[bsize]; val = (int)0x80000000; for(i=0;i<n;i++) { if (s->high_band_coded[ch][i]) { if (val == (int)0x80000000) { val = get_bits(&s->gb, 7) - 19; } else { code = get_vlc2(&s->gb, s->hgain_vlc.table, HGAINVLCBITS, HGAINMAX); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "hgain vlc invalid\n"); return -1; val += code - 18; s->high_band_values[ch][i] = val; /* exponents can be reused in short blocks. */ if ((s->block_len_bits == s->frame_len_bits) || get_bits1(&s->gb)) { for(ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { if (s->use_exp_vlc) { if (decode_exp_vlc(s, ch) < 0) return -1; } else { decode_exp_lsp(s, ch); s->exponents_bsize[ch] = bsize; /* parse spectral coefficients : just RLE encoding */ for (ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { int tindex; WMACoef* ptr = &s->coefs1[ch][0]; /* special VLC tables are used for ms stereo because there is potentially less energy there */ tindex = (ch == 1 && s->ms_stereo); memset(ptr, 0, s->block_len * sizeof(WMACoef)); ff_wma_run_level_decode(s->avctx, &s->gb, &s->coef_vlc[tindex], s->level_table[tindex], s->run_table[tindex], 0, ptr, 0, nb_coefs[ch], s->block_len, s->frame_len_bits, coef_nb_bits); if (s->version == 1 && s->avctx->channels >= 2) { align_get_bits(&s->gb); /* normalize */ { int n4 = s->block_len / 2; mdct_norm = 1.0 / (float)n4; if (s->version == 1) { mdct_norm *= sqrt(n4); /* finally compute the MDCT coefficients */ for (ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { WMACoef *coefs1; float *coefs, *exponents, mult, mult1, noise; int i, j, n, n1, last_high_band, esize; float exp_power[HIGH_BAND_MAX_SIZE]; coefs1 = s->coefs1[ch]; exponents = s->exponents[ch]; esize = s->exponents_bsize[ch]; mult = pow(10, total_gain * 0.05) / s->max_exponent[ch]; mult *= mdct_norm; coefs = s->coefs[ch]; if (s->use_noise_coding) { mult1 = mult; /* very low freqs : noise */ for(i = 0;i < s->coefs_start; i++) { *coefs++ = s->noise_table[s->noise_index] * exponents[i<<bsize>>esize] * mult1; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); n1 = s->exponent_high_sizes[bsize]; /* compute power of high bands */ exponents = s->exponents[ch] + (s->high_band_start[bsize]<<bsize>>esize); last_high_band = 0; /* avoid warning */ for(j=0;j<n1;j++) { n = s->exponent_high_bands[s->frame_len_bits - s->block_len_bits][j]; if (s->high_band_coded[ch][j]) { float e2, v; e2 = 0; for(i = 0;i < n; i++) { v = exponents[i<<bsize>>esize]; e2 += v * v; exp_power[j] = e2 / n; last_high_band = j; tprintf(s->avctx, "%d: power=%f (%d)\n", j, exp_power[j], n); exponents += n<<bsize>>esize; /* main freqs and high freqs */ exponents = s->exponents[ch] + (s->coefs_start<<bsize>>esize); for(j=-1;j<n1;j++) { if (j < 0) { n = s->high_band_start[bsize] - s->coefs_start; } else { n = s->exponent_high_bands[s->frame_len_bits - s->block_len_bits][j]; if (j >= 0 && s->high_band_coded[ch][j]) { /* use noise with specified power */ mult1 = sqrt(exp_power[j] / exp_power[last_high_band]); /* XXX: use a table */ mult1 = mult1 * pow(10, s->high_band_values[ch][j] * 0.05); mult1 = mult1 / (s->max_exponent[ch] * s->noise_mult); mult1 *= mdct_norm; for(i = 0;i < n; i++) { noise = s->noise_table[s->noise_index]; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); *coefs++ = noise * exponents[i<<bsize>>esize] * mult1; exponents += n<<bsize>>esize; } else { /* coded values + small noise */ for(i = 0;i < n; i++) { noise = s->noise_table[s->noise_index]; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); *coefs++ = ((*coefs1++) + noise) * exponents[i<<bsize>>esize] * mult; exponents += n<<bsize>>esize; /* very high freqs : noise */ n = s->block_len - s->coefs_end[bsize]; mult1 = mult * exponents[((-1<<bsize))>>esize]; for(i = 0; i < n; i++) { *coefs++ = s->noise_table[s->noise_index] * mult1; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); } else { /* XXX: optimize more */ for(i = 0;i < s->coefs_start; i++) *coefs++ = 0.0; n = nb_coefs[ch]; for(i = 0;i < n; i++) { *coefs++ = coefs1[i] * exponents[i<<bsize>>esize] * mult; n = s->block_len - s->coefs_end[bsize]; for(i = 0;i < n; i++) *coefs++ = 0.0; #ifdef TRACE for (ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { dump_floats(s, "exponents", 3, s->exponents[ch], s->block_len); dump_floats(s, "coefs", 1, s->coefs[ch], s->block_len); #endif if (s->ms_stereo && s->channel_coded[1]) { /* nominal case for ms stereo: we do it before mdct */ /* no need to optimize this case because it should almost never happen */ if (!s->channel_coded[0]) { tprintf(s->avctx, "rare ms-stereo case happened\n"); memset(s->coefs[0], 0, sizeof(float) * s->block_len); s->channel_coded[0] = 1; s->fdsp.butterflies_float(s->coefs[0], s->coefs[1], s->block_len); next: mdct = &s->mdct_ctx[bsize]; for (ch = 0; ch < s->avctx->channels; ch++) { int n4, index; n4 = s->block_len / 2; if(s->channel_coded[ch]){ mdct->imdct_calc(mdct, s->output, s->coefs[ch]); }else if(!(s->ms_stereo && ch==1)) memset(s->output, 0, sizeof(s->output)); /* multiply by the window and add in the frame */ index = (s->frame_len / 2) + s->block_pos - n4; wma_window(s, &s->frame_out[ch][index]); /* update block number */ s->block_num++; s->block_pos += s->block_len; if (s->block_pos >= s->frame_len) return 1; else return 0;
true
FFmpeg
ec8a4841f7e81040f9a2757f23e70dff5e6b33a4
static int wma_decode_block(WMACodecContext *s) { int n, v, a, ch, bsize; int coef_nb_bits, total_gain; int nb_coefs[MAX_CHANNELS]; float mdct_norm; FFTContext *mdct; #ifdef TRACE tprintf(s->avctx, "***decode_block: %d:%d\n", s->frame_count - 1, s->block_num); #endif if (s->use_variable_block_len) { n = av_log2(s->nb_block_sizes - 1) + 1; if (s->reset_block_lengths) { s->reset_block_lengths = 0; v = get_bits(&s->gb, n); if (v >= s->nb_block_sizes){ av_log(s->avctx, AV_LOG_ERROR, "prev_block_len_bits %d out of range\n", s->frame_len_bits - v); return -1; s->prev_block_len_bits = s->frame_len_bits - v; v = get_bits(&s->gb, n); if (v >= s->nb_block_sizes){ av_log(s->avctx, AV_LOG_ERROR, "block_len_bits %d out of range\n", s->frame_len_bits - v); return -1; s->block_len_bits = s->frame_len_bits - v; } else { s->prev_block_len_bits = s->block_len_bits; s->block_len_bits = s->next_block_len_bits; v = get_bits(&s->gb, n); if (v >= s->nb_block_sizes){ av_log(s->avctx, AV_LOG_ERROR, "next_block_len_bits %d out of range\n", s->frame_len_bits - v); return -1; s->next_block_len_bits = s->frame_len_bits - v; } else { s->next_block_len_bits = s->frame_len_bits; s->prev_block_len_bits = s->frame_len_bits; s->block_len_bits = s->frame_len_bits; if (s->frame_len_bits - s->block_len_bits >= s->nb_block_sizes){ av_log(s->avctx, AV_LOG_ERROR, "block_len_bits not initialized to a valid value\n"); return -1; s->block_len = 1 << s->block_len_bits; if ((s->block_pos + s->block_len) > s->frame_len){ av_log(s->avctx, AV_LOG_ERROR, "frame_len overflow\n"); return -1; if (s->avctx->channels == 2) { s->ms_stereo = get_bits1(&s->gb); v = 0; for(ch = 0; ch < s->avctx->channels; ch++) { a = get_bits1(&s->gb); s->channel_coded[ch] = a; v |= a; bsize = s->frame_len_bits - s->block_len_bits; if (!v) goto next; total_gain = 1; for(;;) { a = get_bits(&s->gb, 7); total_gain += a; if (a != 127) break; coef_nb_bits= ff_wma_total_gain_to_bits(total_gain); n = s->coefs_end[bsize] - s->coefs_start; for(ch = 0; ch < s->avctx->channels; ch++) nb_coefs[ch] = n; if (s->use_noise_coding) { for(ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { int i, n, a; n = s->exponent_high_sizes[bsize]; for(i=0;i<n;i++) { a = get_bits1(&s->gb); s->high_band_coded[ch][i] = a; if (a) nb_coefs[ch] -= s->exponent_high_bands[bsize][i]; for(ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { int i, n, val, code; n = s->exponent_high_sizes[bsize]; val = (int)0x80000000; for(i=0;i<n;i++) { if (s->high_band_coded[ch][i]) { if (val == (int)0x80000000) { val = get_bits(&s->gb, 7) - 19; } else { code = get_vlc2(&s->gb, s->hgain_vlc.table, HGAINVLCBITS, HGAINMAX); if (code < 0){ av_log(s->avctx, AV_LOG_ERROR, "hgain vlc invalid\n"); return -1; val += code - 18; s->high_band_values[ch][i] = val; if ((s->block_len_bits == s->frame_len_bits) || get_bits1(&s->gb)) { for(ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { if (s->use_exp_vlc) { if (decode_exp_vlc(s, ch) < 0) return -1; } else { decode_exp_lsp(s, ch); s->exponents_bsize[ch] = bsize; for (ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { int tindex; WMACoef* ptr = &s->coefs1[ch][0]; tindex = (ch == 1 && s->ms_stereo); memset(ptr, 0, s->block_len * sizeof(WMACoef)); ff_wma_run_level_decode(s->avctx, &s->gb, &s->coef_vlc[tindex], s->level_table[tindex], s->run_table[tindex], 0, ptr, 0, nb_coefs[ch], s->block_len, s->frame_len_bits, coef_nb_bits); if (s->version == 1 && s->avctx->channels >= 2) { align_get_bits(&s->gb); { int n4 = s->block_len / 2; mdct_norm = 1.0 / (float)n4; if (s->version == 1) { mdct_norm *= sqrt(n4); for (ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { WMACoef *coefs1; float *coefs, *exponents, mult, mult1, noise; int i, j, n, n1, last_high_band, esize; float exp_power[HIGH_BAND_MAX_SIZE]; coefs1 = s->coefs1[ch]; exponents = s->exponents[ch]; esize = s->exponents_bsize[ch]; mult = pow(10, total_gain * 0.05) / s->max_exponent[ch]; mult *= mdct_norm; coefs = s->coefs[ch]; if (s->use_noise_coding) { mult1 = mult; for(i = 0;i < s->coefs_start; i++) { *coefs++ = s->noise_table[s->noise_index] * exponents[i<<bsize>>esize] * mult1; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); n1 = s->exponent_high_sizes[bsize]; exponents = s->exponents[ch] + (s->high_band_start[bsize]<<bsize>>esize); last_high_band = 0; for(j=0;j<n1;j++) { n = s->exponent_high_bands[s->frame_len_bits - s->block_len_bits][j]; if (s->high_band_coded[ch][j]) { float e2, v; e2 = 0; for(i = 0;i < n; i++) { v = exponents[i<<bsize>>esize]; e2 += v * v; exp_power[j] = e2 / n; last_high_band = j; tprintf(s->avctx, "%d: power=%f (%d)\n", j, exp_power[j], n); exponents += n<<bsize>>esize; exponents = s->exponents[ch] + (s->coefs_start<<bsize>>esize); for(j=-1;j<n1;j++) { if (j < 0) { n = s->high_band_start[bsize] - s->coefs_start; } else { n = s->exponent_high_bands[s->frame_len_bits - s->block_len_bits][j]; if (j >= 0 && s->high_band_coded[ch][j]) { mult1 = sqrt(exp_power[j] / exp_power[last_high_band]); mult1 = mult1 * pow(10, s->high_band_values[ch][j] * 0.05); mult1 = mult1 / (s->max_exponent[ch] * s->noise_mult); mult1 *= mdct_norm; for(i = 0;i < n; i++) { noise = s->noise_table[s->noise_index]; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); *coefs++ = noise * exponents[i<<bsize>>esize] * mult1; exponents += n<<bsize>>esize; } else { for(i = 0;i < n; i++) { noise = s->noise_table[s->noise_index]; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); *coefs++ = ((*coefs1++) + noise) * exponents[i<<bsize>>esize] * mult; exponents += n<<bsize>>esize; n = s->block_len - s->coefs_end[bsize]; mult1 = mult * exponents[((-1<<bsize))>>esize]; for(i = 0; i < n; i++) { *coefs++ = s->noise_table[s->noise_index] * mult1; s->noise_index = (s->noise_index + 1) & (NOISE_TAB_SIZE - 1); } else { for(i = 0;i < s->coefs_start; i++) *coefs++ = 0.0; n = nb_coefs[ch]; for(i = 0;i < n; i++) { *coefs++ = coefs1[i] * exponents[i<<bsize>>esize] * mult; n = s->block_len - s->coefs_end[bsize]; for(i = 0;i < n; i++) *coefs++ = 0.0; #ifdef TRACE for (ch = 0; ch < s->avctx->channels; ch++) { if (s->channel_coded[ch]) { dump_floats(s, "exponents", 3, s->exponents[ch], s->block_len); dump_floats(s, "coefs", 1, s->coefs[ch], s->block_len); #endif if (s->ms_stereo && s->channel_coded[1]) { if (!s->channel_coded[0]) { tprintf(s->avctx, "rare ms-stereo case happened\n"); memset(s->coefs[0], 0, sizeof(float) * s->block_len); s->channel_coded[0] = 1; s->fdsp.butterflies_float(s->coefs[0], s->coefs[1], s->block_len); next: mdct = &s->mdct_ctx[bsize]; for (ch = 0; ch < s->avctx->channels; ch++) { int n4, index; n4 = s->block_len / 2; if(s->channel_coded[ch]){ mdct->imdct_calc(mdct, s->output, s->coefs[ch]); }else if(!(s->ms_stereo && ch==1)) memset(s->output, 0, sizeof(s->output)); index = (s->frame_len / 2) + s->block_pos - n4; wma_window(s, &s->frame_out[ch][index]); s->block_num++; s->block_pos += s->block_len; if (s->block_pos >= s->frame_len) return 1; else return 0;
{ "code": [], "line_no": [] }
static int FUNC_0(WMACodecContext *VAR_0) { int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5; int VAR_6, VAR_7; int VAR_8[MAX_CHANNELS]; float VAR_9; FFTContext *mdct; #ifdef TRACE tprintf(VAR_0->avctx, "***decode_block: %d:%d\VAR_1", VAR_0->frame_count - 1, VAR_0->block_num); #endif if (VAR_0->use_variable_block_len) { VAR_1 = av_log2(VAR_0->nb_block_sizes - 1) + 1; if (VAR_0->reset_block_lengths) { VAR_0->reset_block_lengths = 0; VAR_2 = get_bits(&VAR_0->gb, VAR_1); if (VAR_2 >= VAR_0->nb_block_sizes){ av_log(VAR_0->avctx, AV_LOG_ERROR, "prev_block_len_bits %d out of range\VAR_1", VAR_0->frame_len_bits - VAR_2); return -1; VAR_0->prev_block_len_bits = VAR_0->frame_len_bits - VAR_2; VAR_2 = get_bits(&VAR_0->gb, VAR_1); if (VAR_2 >= VAR_0->nb_block_sizes){ av_log(VAR_0->avctx, AV_LOG_ERROR, "block_len_bits %d out of range\VAR_1", VAR_0->frame_len_bits - VAR_2); return -1; VAR_0->block_len_bits = VAR_0->frame_len_bits - VAR_2; } else { VAR_0->prev_block_len_bits = VAR_0->block_len_bits; VAR_0->block_len_bits = VAR_0->next_block_len_bits; VAR_2 = get_bits(&VAR_0->gb, VAR_1); if (VAR_2 >= VAR_0->nb_block_sizes){ av_log(VAR_0->avctx, AV_LOG_ERROR, "next_block_len_bits %d out of range\VAR_1", VAR_0->frame_len_bits - VAR_2); return -1; VAR_0->next_block_len_bits = VAR_0->frame_len_bits - VAR_2; } else { VAR_0->next_block_len_bits = VAR_0->frame_len_bits; VAR_0->prev_block_len_bits = VAR_0->frame_len_bits; VAR_0->block_len_bits = VAR_0->frame_len_bits; if (VAR_0->frame_len_bits - VAR_0->block_len_bits >= VAR_0->nb_block_sizes){ av_log(VAR_0->avctx, AV_LOG_ERROR, "block_len_bits not initialized to VAR_3 valid value\VAR_1"); return -1; VAR_0->block_len = 1 << VAR_0->block_len_bits; if ((VAR_0->block_pos + VAR_0->block_len) > VAR_0->frame_len){ av_log(VAR_0->avctx, AV_LOG_ERROR, "frame_len overflow\VAR_1"); return -1; if (VAR_0->avctx->channels == 2) { VAR_0->ms_stereo = get_bits1(&VAR_0->gb); VAR_2 = 0; for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) { VAR_3 = get_bits1(&VAR_0->gb); VAR_0->channel_coded[VAR_4] = VAR_3; VAR_2 |= VAR_3; VAR_5 = VAR_0->frame_len_bits - VAR_0->block_len_bits; if (!VAR_2) goto next; VAR_7 = 1; for(;;) { VAR_3 = get_bits(&VAR_0->gb, 7); VAR_7 += VAR_3; if (VAR_3 != 127) break; VAR_6= ff_wma_total_gain_to_bits(VAR_7); VAR_1 = VAR_0->coefs_end[VAR_5] - VAR_0->coefs_start; for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) VAR_8[VAR_4] = VAR_1; if (VAR_0->use_noise_coding) { for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) { if (VAR_0->channel_coded[VAR_4]) { int i, VAR_1, VAR_3; VAR_1 = VAR_0->exponent_high_sizes[VAR_5]; for(i=0;i<VAR_1;i++) { VAR_3 = get_bits1(&VAR_0->gb); VAR_0->high_band_coded[VAR_4][i] = VAR_3; if (VAR_3) VAR_8[VAR_4] -= VAR_0->exponent_high_bands[VAR_5][i]; for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) { if (VAR_0->channel_coded[VAR_4]) { int i, VAR_1, val, code; VAR_1 = VAR_0->exponent_high_sizes[VAR_5]; val = (int)0x80000000; for(i=0;i<VAR_1;i++) { if (VAR_0->high_band_coded[VAR_4][i]) { if (val == (int)0x80000000) { val = get_bits(&VAR_0->gb, 7) - 19; } else { code = get_vlc2(&VAR_0->gb, VAR_0->hgain_vlc.table, HGAINVLCBITS, HGAINMAX); if (code < 0){ av_log(VAR_0->avctx, AV_LOG_ERROR, "hgain vlc invalid\VAR_1"); return -1; val += code - 18; VAR_0->high_band_values[VAR_4][i] = val; if ((VAR_0->block_len_bits == VAR_0->frame_len_bits) || get_bits1(&VAR_0->gb)) { for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) { if (VAR_0->channel_coded[VAR_4]) { if (VAR_0->use_exp_vlc) { if (decode_exp_vlc(VAR_0, VAR_4) < 0) return -1; } else { decode_exp_lsp(VAR_0, VAR_4); VAR_0->exponents_bsize[VAR_4] = VAR_5; for (VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) { if (VAR_0->channel_coded[VAR_4]) { int tindex; WMACoef* ptr = &VAR_0->coefs1[VAR_4][0]; tindex = (VAR_4 == 1 && VAR_0->ms_stereo); memset(ptr, 0, VAR_0->block_len * sizeof(WMACoef)); ff_wma_run_level_decode(VAR_0->avctx, &VAR_0->gb, &VAR_0->coef_vlc[tindex], VAR_0->level_table[tindex], VAR_0->run_table[tindex], 0, ptr, 0, VAR_8[VAR_4], VAR_0->block_len, VAR_0->frame_len_bits, VAR_6); if (VAR_0->version == 1 && VAR_0->avctx->channels >= 2) { align_get_bits(&VAR_0->gb); { int n4 = VAR_0->block_len / 2; VAR_9 = 1.0 / (float)n4; if (VAR_0->version == 1) { VAR_9 *= sqrt(n4); for (VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) { if (VAR_0->channel_coded[VAR_4]) { WMACoef *coefs1; float *coefs, *exponents, mult, mult1, noise; int i, j, VAR_1, n1, last_high_band, esize; float exp_power[HIGH_BAND_MAX_SIZE]; coefs1 = VAR_0->coefs1[VAR_4]; exponents = VAR_0->exponents[VAR_4]; esize = VAR_0->exponents_bsize[VAR_4]; mult = pow(10, VAR_7 * 0.05) / VAR_0->max_exponent[VAR_4]; mult *= VAR_9; coefs = VAR_0->coefs[VAR_4]; if (VAR_0->use_noise_coding) { mult1 = mult; for(i = 0;i < VAR_0->coefs_start; i++) { *coefs++ = VAR_0->noise_table[VAR_0->noise_index] * exponents[i<<VAR_5>>esize] * mult1; VAR_0->noise_index = (VAR_0->noise_index + 1) & (NOISE_TAB_SIZE - 1); n1 = VAR_0->exponent_high_sizes[VAR_5]; exponents = VAR_0->exponents[VAR_4] + (VAR_0->high_band_start[VAR_5]<<VAR_5>>esize); last_high_band = 0; for(j=0;j<n1;j++) { VAR_1 = VAR_0->exponent_high_bands[VAR_0->frame_len_bits - VAR_0->block_len_bits][j]; if (VAR_0->high_band_coded[VAR_4][j]) { float e2, VAR_2; e2 = 0; for(i = 0;i < VAR_1; i++) { VAR_2 = exponents[i<<VAR_5>>esize]; e2 += VAR_2 * VAR_2; exp_power[j] = e2 / VAR_1; last_high_band = j; tprintf(VAR_0->avctx, "%d: power=%f (%d)\VAR_1", j, exp_power[j], VAR_1); exponents += VAR_1<<VAR_5>>esize; exponents = VAR_0->exponents[VAR_4] + (VAR_0->coefs_start<<VAR_5>>esize); for(j=-1;j<n1;j++) { if (j < 0) { VAR_1 = VAR_0->high_band_start[VAR_5] - VAR_0->coefs_start; } else { VAR_1 = VAR_0->exponent_high_bands[VAR_0->frame_len_bits - VAR_0->block_len_bits][j]; if (j >= 0 && VAR_0->high_band_coded[VAR_4][j]) { mult1 = sqrt(exp_power[j] / exp_power[last_high_band]); mult1 = mult1 * pow(10, VAR_0->high_band_values[VAR_4][j] * 0.05); mult1 = mult1 / (VAR_0->max_exponent[VAR_4] * VAR_0->noise_mult); mult1 *= VAR_9; for(i = 0;i < VAR_1; i++) { noise = VAR_0->noise_table[VAR_0->noise_index]; VAR_0->noise_index = (VAR_0->noise_index + 1) & (NOISE_TAB_SIZE - 1); *coefs++ = noise * exponents[i<<VAR_5>>esize] * mult1; exponents += VAR_1<<VAR_5>>esize; } else { for(i = 0;i < VAR_1; i++) { noise = VAR_0->noise_table[VAR_0->noise_index]; VAR_0->noise_index = (VAR_0->noise_index + 1) & (NOISE_TAB_SIZE - 1); *coefs++ = ((*coefs1++) + noise) * exponents[i<<VAR_5>>esize] * mult; exponents += VAR_1<<VAR_5>>esize; VAR_1 = VAR_0->block_len - VAR_0->coefs_end[VAR_5]; mult1 = mult * exponents[((-1<<VAR_5))>>esize]; for(i = 0; i < VAR_1; i++) { *coefs++ = VAR_0->noise_table[VAR_0->noise_index] * mult1; VAR_0->noise_index = (VAR_0->noise_index + 1) & (NOISE_TAB_SIZE - 1); } else { for(i = 0;i < VAR_0->coefs_start; i++) *coefs++ = 0.0; VAR_1 = VAR_8[VAR_4]; for(i = 0;i < VAR_1; i++) { *coefs++ = coefs1[i] * exponents[i<<VAR_5>>esize] * mult; VAR_1 = VAR_0->block_len - VAR_0->coefs_end[VAR_5]; for(i = 0;i < VAR_1; i++) *coefs++ = 0.0; #ifdef TRACE for (VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) { if (VAR_0->channel_coded[VAR_4]) { dump_floats(VAR_0, "exponents", 3, VAR_0->exponents[VAR_4], VAR_0->block_len); dump_floats(VAR_0, "coefs", 1, VAR_0->coefs[VAR_4], VAR_0->block_len); #endif if (VAR_0->ms_stereo && VAR_0->channel_coded[1]) { if (!VAR_0->channel_coded[0]) { tprintf(VAR_0->avctx, "rare ms-stereo case happened\VAR_1"); memset(VAR_0->coefs[0], 0, sizeof(float) * VAR_0->block_len); VAR_0->channel_coded[0] = 1; VAR_0->fdsp.butterflies_float(VAR_0->coefs[0], VAR_0->coefs[1], VAR_0->block_len); next: mdct = &VAR_0->mdct_ctx[VAR_5]; for (VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) { int n4, index; n4 = VAR_0->block_len / 2; if(VAR_0->channel_coded[VAR_4]){ mdct->imdct_calc(mdct, VAR_0->output, VAR_0->coefs[VAR_4]); }else if(!(VAR_0->ms_stereo && VAR_4==1)) memset(VAR_0->output, 0, sizeof(VAR_0->output)); index = (VAR_0->frame_len / 2) + VAR_0->block_pos - n4; wma_window(VAR_0, &VAR_0->frame_out[VAR_4][index]); VAR_0->block_num++; VAR_0->block_pos += VAR_0->block_len; if (VAR_0->block_pos >= VAR_0->frame_len) return 1; else return 0;
[ "static int FUNC_0(WMACodecContext *VAR_0)\n{", "int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5;", "int VAR_6, VAR_7;", "int VAR_8[MAX_CHANNELS];", "float VAR_9;", "FFTContext *mdct;", "#ifdef TRACE\ntprintf(VAR_0->avctx, \"***decode_block: %d:%d\\VAR_1\", VAR_0->frame_count - 1, VAR_0->block_num);", "#endif\nif (VAR_0->use_variable_block_len) {", "VAR_1 = av_log2(VAR_0->nb_block_sizes - 1) + 1;", "if (VAR_0->reset_block_lengths) {", "VAR_0->reset_block_lengths = 0;", "VAR_2 = get_bits(&VAR_0->gb, VAR_1);", "if (VAR_2 >= VAR_0->nb_block_sizes){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"prev_block_len_bits %d out of range\\VAR_1\", VAR_0->frame_len_bits - VAR_2);", "return -1;", "VAR_0->prev_block_len_bits = VAR_0->frame_len_bits - VAR_2;", "VAR_2 = get_bits(&VAR_0->gb, VAR_1);", "if (VAR_2 >= VAR_0->nb_block_sizes){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"block_len_bits %d out of range\\VAR_1\", VAR_0->frame_len_bits - VAR_2);", "return -1;", "VAR_0->block_len_bits = VAR_0->frame_len_bits - VAR_2;", "} else {", "VAR_0->prev_block_len_bits = VAR_0->block_len_bits;", "VAR_0->block_len_bits = VAR_0->next_block_len_bits;", "VAR_2 = get_bits(&VAR_0->gb, VAR_1);", "if (VAR_2 >= VAR_0->nb_block_sizes){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"next_block_len_bits %d out of range\\VAR_1\", VAR_0->frame_len_bits - VAR_2);", "return -1;", "VAR_0->next_block_len_bits = VAR_0->frame_len_bits - VAR_2;", "} else {", "VAR_0->next_block_len_bits = VAR_0->frame_len_bits;", "VAR_0->prev_block_len_bits = VAR_0->frame_len_bits;", "VAR_0->block_len_bits = VAR_0->frame_len_bits;", "if (VAR_0->frame_len_bits - VAR_0->block_len_bits >= VAR_0->nb_block_sizes){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"block_len_bits not initialized to VAR_3 valid value\\VAR_1\");", "return -1;", "VAR_0->block_len = 1 << VAR_0->block_len_bits;", "if ((VAR_0->block_pos + VAR_0->block_len) > VAR_0->frame_len){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"frame_len overflow\\VAR_1\");", "return -1;", "if (VAR_0->avctx->channels == 2) {", "VAR_0->ms_stereo = get_bits1(&VAR_0->gb);", "VAR_2 = 0;", "for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) {", "VAR_3 = get_bits1(&VAR_0->gb);", "VAR_0->channel_coded[VAR_4] = VAR_3;", "VAR_2 |= VAR_3;", "VAR_5 = VAR_0->frame_len_bits - VAR_0->block_len_bits;", "if (!VAR_2)\ngoto next;", "VAR_7 = 1;", "for(;;) {", "VAR_3 = get_bits(&VAR_0->gb, 7);", "VAR_7 += VAR_3;", "if (VAR_3 != 127)\nbreak;", "VAR_6= ff_wma_total_gain_to_bits(VAR_7);", "VAR_1 = VAR_0->coefs_end[VAR_5] - VAR_0->coefs_start;", "for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++)", "VAR_8[VAR_4] = VAR_1;", "if (VAR_0->use_noise_coding) {", "for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) {", "if (VAR_0->channel_coded[VAR_4]) {", "int i, VAR_1, VAR_3;", "VAR_1 = VAR_0->exponent_high_sizes[VAR_5];", "for(i=0;i<VAR_1;i++) {", "VAR_3 = get_bits1(&VAR_0->gb);", "VAR_0->high_band_coded[VAR_4][i] = VAR_3;", "if (VAR_3)\nVAR_8[VAR_4] -= VAR_0->exponent_high_bands[VAR_5][i];", "for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) {", "if (VAR_0->channel_coded[VAR_4]) {", "int i, VAR_1, val, code;", "VAR_1 = VAR_0->exponent_high_sizes[VAR_5];", "val = (int)0x80000000;", "for(i=0;i<VAR_1;i++) {", "if (VAR_0->high_band_coded[VAR_4][i]) {", "if (val == (int)0x80000000) {", "val = get_bits(&VAR_0->gb, 7) - 19;", "} else {", "code = get_vlc2(&VAR_0->gb, VAR_0->hgain_vlc.table, HGAINVLCBITS, HGAINMAX);", "if (code < 0){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"hgain vlc invalid\\VAR_1\");", "return -1;", "val += code - 18;", "VAR_0->high_band_values[VAR_4][i] = val;", "if ((VAR_0->block_len_bits == VAR_0->frame_len_bits) ||\nget_bits1(&VAR_0->gb)) {", "for(VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) {", "if (VAR_0->channel_coded[VAR_4]) {", "if (VAR_0->use_exp_vlc) {", "if (decode_exp_vlc(VAR_0, VAR_4) < 0)\nreturn -1;", "} else {", "decode_exp_lsp(VAR_0, VAR_4);", "VAR_0->exponents_bsize[VAR_4] = VAR_5;", "for (VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) {", "if (VAR_0->channel_coded[VAR_4]) {", "int tindex;", "WMACoef* ptr = &VAR_0->coefs1[VAR_4][0];", "tindex = (VAR_4 == 1 && VAR_0->ms_stereo);", "memset(ptr, 0, VAR_0->block_len * sizeof(WMACoef));", "ff_wma_run_level_decode(VAR_0->avctx, &VAR_0->gb, &VAR_0->coef_vlc[tindex],\nVAR_0->level_table[tindex], VAR_0->run_table[tindex],\n0, ptr, 0, VAR_8[VAR_4],\nVAR_0->block_len, VAR_0->frame_len_bits, VAR_6);", "if (VAR_0->version == 1 && VAR_0->avctx->channels >= 2) {", "align_get_bits(&VAR_0->gb);", "{", "int n4 = VAR_0->block_len / 2;", "VAR_9 = 1.0 / (float)n4;", "if (VAR_0->version == 1) {", "VAR_9 *= sqrt(n4);", "for (VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) {", "if (VAR_0->channel_coded[VAR_4]) {", "WMACoef *coefs1;", "float *coefs, *exponents, mult, mult1, noise;", "int i, j, VAR_1, n1, last_high_band, esize;", "float exp_power[HIGH_BAND_MAX_SIZE];", "coefs1 = VAR_0->coefs1[VAR_4];", "exponents = VAR_0->exponents[VAR_4];", "esize = VAR_0->exponents_bsize[VAR_4];", "mult = pow(10, VAR_7 * 0.05) / VAR_0->max_exponent[VAR_4];", "mult *= VAR_9;", "coefs = VAR_0->coefs[VAR_4];", "if (VAR_0->use_noise_coding) {", "mult1 = mult;", "for(i = 0;i < VAR_0->coefs_start; i++) {", "*coefs++ = VAR_0->noise_table[VAR_0->noise_index] *\nexponents[i<<VAR_5>>esize] * mult1;", "VAR_0->noise_index = (VAR_0->noise_index + 1) & (NOISE_TAB_SIZE - 1);", "n1 = VAR_0->exponent_high_sizes[VAR_5];", "exponents = VAR_0->exponents[VAR_4] +\n(VAR_0->high_band_start[VAR_5]<<VAR_5>>esize);", "last_high_band = 0;", "for(j=0;j<n1;j++) {", "VAR_1 = VAR_0->exponent_high_bands[VAR_0->frame_len_bits -\nVAR_0->block_len_bits][j];", "if (VAR_0->high_band_coded[VAR_4][j]) {", "float e2, VAR_2;", "e2 = 0;", "for(i = 0;i < VAR_1; i++) {", "VAR_2 = exponents[i<<VAR_5>>esize];", "e2 += VAR_2 * VAR_2;", "exp_power[j] = e2 / VAR_1;", "last_high_band = j;", "tprintf(VAR_0->avctx, \"%d: power=%f (%d)\\VAR_1\", j, exp_power[j], VAR_1);", "exponents += VAR_1<<VAR_5>>esize;", "exponents = VAR_0->exponents[VAR_4] + (VAR_0->coefs_start<<VAR_5>>esize);", "for(j=-1;j<n1;j++) {", "if (j < 0) {", "VAR_1 = VAR_0->high_band_start[VAR_5] -\nVAR_0->coefs_start;", "} else {", "VAR_1 = VAR_0->exponent_high_bands[VAR_0->frame_len_bits -\nVAR_0->block_len_bits][j];", "if (j >= 0 && VAR_0->high_band_coded[VAR_4][j]) {", "mult1 = sqrt(exp_power[j] / exp_power[last_high_band]);", "mult1 = mult1 * pow(10, VAR_0->high_band_values[VAR_4][j] * 0.05);", "mult1 = mult1 / (VAR_0->max_exponent[VAR_4] * VAR_0->noise_mult);", "mult1 *= VAR_9;", "for(i = 0;i < VAR_1; i++) {", "noise = VAR_0->noise_table[VAR_0->noise_index];", "VAR_0->noise_index = (VAR_0->noise_index + 1) & (NOISE_TAB_SIZE - 1);", "*coefs++ = noise *\nexponents[i<<VAR_5>>esize] * mult1;", "exponents += VAR_1<<VAR_5>>esize;", "} else {", "for(i = 0;i < VAR_1; i++) {", "noise = VAR_0->noise_table[VAR_0->noise_index];", "VAR_0->noise_index = (VAR_0->noise_index + 1) & (NOISE_TAB_SIZE - 1);", "*coefs++ = ((*coefs1++) + noise) *\nexponents[i<<VAR_5>>esize] * mult;", "exponents += VAR_1<<VAR_5>>esize;", "VAR_1 = VAR_0->block_len - VAR_0->coefs_end[VAR_5];", "mult1 = mult * exponents[((-1<<VAR_5))>>esize];", "for(i = 0; i < VAR_1; i++) {", "*coefs++ = VAR_0->noise_table[VAR_0->noise_index] * mult1;", "VAR_0->noise_index = (VAR_0->noise_index + 1) & (NOISE_TAB_SIZE - 1);", "} else {", "for(i = 0;i < VAR_0->coefs_start; i++)", "*coefs++ = 0.0;", "VAR_1 = VAR_8[VAR_4];", "for(i = 0;i < VAR_1; i++) {", "*coefs++ = coefs1[i] * exponents[i<<VAR_5>>esize] * mult;", "VAR_1 = VAR_0->block_len - VAR_0->coefs_end[VAR_5];", "for(i = 0;i < VAR_1; i++)", "*coefs++ = 0.0;", "#ifdef TRACE\nfor (VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) {", "if (VAR_0->channel_coded[VAR_4]) {", "dump_floats(VAR_0, \"exponents\", 3, VAR_0->exponents[VAR_4], VAR_0->block_len);", "dump_floats(VAR_0, \"coefs\", 1, VAR_0->coefs[VAR_4], VAR_0->block_len);", "#endif\nif (VAR_0->ms_stereo && VAR_0->channel_coded[1]) {", "if (!VAR_0->channel_coded[0]) {", "tprintf(VAR_0->avctx, \"rare ms-stereo case happened\\VAR_1\");", "memset(VAR_0->coefs[0], 0, sizeof(float) * VAR_0->block_len);", "VAR_0->channel_coded[0] = 1;", "VAR_0->fdsp.butterflies_float(VAR_0->coefs[0], VAR_0->coefs[1], VAR_0->block_len);", "next:\nmdct = &VAR_0->mdct_ctx[VAR_5];", "for (VAR_4 = 0; VAR_4 < VAR_0->avctx->channels; VAR_4++) {", "int n4, index;", "n4 = VAR_0->block_len / 2;", "if(VAR_0->channel_coded[VAR_4]){", "mdct->imdct_calc(mdct, VAR_0->output, VAR_0->coefs[VAR_4]);", "}else if(!(VAR_0->ms_stereo && VAR_4==1))", "memset(VAR_0->output, 0, sizeof(VAR_0->output));", "index = (VAR_0->frame_len / 2) + VAR_0->block_pos - n4;", "wma_window(VAR_0, &VAR_0->frame_out[VAR_4][index]);", "VAR_0->block_num++;", "VAR_0->block_pos += VAR_0->block_len;", "if (VAR_0->block_pos >= VAR_0->frame_len)\nreturn 1;", "else\nreturn 0;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 21, 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 46 ], [ 48 ], [ 50 ], [ 52 ], [ 54 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 68 ], [ 70 ], [ 72 ], [ 74 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 92 ], [ 94 ], [ 96 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 114 ], [ 116 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 132 ], [ 140, 142 ], [ 150 ], [ 152 ], [ 158 ], [ 160 ], [ 162, 164 ], [ 169 ], [ 175 ], [ 177 ], [ 179 ], [ 185 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 205, 207 ], [ 212 ], [ 214 ], [ 216 ], [ 220 ], [ 222 ], [ 224 ], [ 226 ], [ 228 ], [ 230 ], [ 232 ], [ 234 ], [ 236 ], [ 238 ], [ 240 ], [ 243 ], [ 246 ], [ 257, 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267, 269 ], [ 271 ], [ 273 ], [ 276 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 299 ], [ 301 ], [ 303, 305, 307, 309 ], [ 312 ], [ 314 ], [ 322 ], [ 324 ], [ 326 ], [ 328 ], [ 330 ], [ 338 ], [ 340 ], [ 342 ], [ 344 ], [ 346 ], [ 348 ], [ 352 ], [ 354 ], [ 356 ], [ 358 ], [ 360 ], [ 362 ], [ 364 ], [ 366 ], [ 370 ], [ 372, 374 ], [ 376 ], [ 381 ], [ 387, 389 ], [ 391 ], [ 393 ], [ 395, 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 412 ], [ 414 ], [ 416 ], [ 419 ], [ 426 ], [ 428 ], [ 430 ], [ 432, 434 ], [ 436 ], [ 438, 440 ], [ 443 ], [ 447 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463, 465 ], [ 468 ], [ 470 ], [ 474 ], [ 476 ], [ 478 ], [ 480, 482 ], [ 485 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 504 ], [ 508 ], [ 510 ], [ 512 ], [ 514 ], [ 516 ], [ 519 ], [ 521 ], [ 523 ], [ 530, 532 ], [ 534 ], [ 536 ], [ 538 ], [ 542, 546 ], [ 554 ], [ 556 ], [ 558 ], [ 560 ], [ 565 ], [ 570, 572 ], [ 576 ], [ 578 ], [ 582 ], [ 584 ], [ 586 ], [ 588 ], [ 590 ], [ 596 ], [ 598 ], [ 605 ], [ 607 ], [ 609, 611 ], [ 613, 615 ] ]
397
static int floppy_probe_device(const char *filename) { int fd, ret; int prio = 0; struct floppy_struct fdparam; struct stat st; if (strstart(filename, "/dev/fd", NULL)) prio = 50; fd = open(filename, O_RDONLY | O_NONBLOCK); if (fd < 0) { goto out; } ret = fstat(fd, &st); if (ret == -1 || !S_ISBLK(st.st_mode)) { goto outc; } /* Attempt to detect via a floppy specific ioctl */ ret = ioctl(fd, FDGETPRM, &fdparam); if (ret >= 0) prio = 100; outc: close(fd); out: return prio; }
false
qemu
e17408283562be359f16a7e12ddfee7509d6fe11
static int floppy_probe_device(const char *filename) { int fd, ret; int prio = 0; struct floppy_struct fdparam; struct stat st; if (strstart(filename, "/dev/fd", NULL)) prio = 50; fd = open(filename, O_RDONLY | O_NONBLOCK); if (fd < 0) { goto out; } ret = fstat(fd, &st); if (ret == -1 || !S_ISBLK(st.st_mode)) { goto outc; } ret = ioctl(fd, FDGETPRM, &fdparam); if (ret >= 0) prio = 100; outc: close(fd); out: return prio; }
{ "code": [], "line_no": [] }
static int FUNC_0(const char *VAR_0) { int VAR_1, VAR_2; int VAR_3 = 0; struct floppy_struct VAR_4; struct stat VAR_5; if (strstart(VAR_0, "/dev/VAR_1", NULL)) VAR_3 = 50; VAR_1 = open(VAR_0, O_RDONLY | O_NONBLOCK); if (VAR_1 < 0) { goto out; } VAR_2 = fstat(VAR_1, &VAR_5); if (VAR_2 == -1 || !S_ISBLK(VAR_5.st_mode)) { goto outc; } VAR_2 = ioctl(VAR_1, FDGETPRM, &VAR_4); if (VAR_2 >= 0) VAR_3 = 100; outc: close(VAR_1); out: return VAR_3; }
[ "static int FUNC_0(const char *VAR_0)\n{", "int VAR_1, VAR_2;", "int VAR_3 = 0;", "struct floppy_struct VAR_4;", "struct stat VAR_5;", "if (strstart(VAR_0, \"/dev/VAR_1\", NULL))\nVAR_3 = 50;", "VAR_1 = open(VAR_0, O_RDONLY | O_NONBLOCK);", "if (VAR_1 < 0) {", "goto out;", "}", "VAR_2 = fstat(VAR_1, &VAR_5);", "if (VAR_2 == -1 || !S_ISBLK(VAR_5.st_mode)) {", "goto outc;", "}", "VAR_2 = ioctl(VAR_1, FDGETPRM, &VAR_4);", "if (VAR_2 >= 0)\nVAR_3 = 100;", "outc:\nclose(VAR_1);", "out:\nreturn VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 41 ], [ 43, 45 ], [ 49, 51 ], [ 53, 55 ], [ 57 ] ]
398
struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev) { struct XenDevice *xendev; TAILQ_FOREACH(xendev, &xendevs, next) { if (xendev->dom != dom) continue; if (xendev->dev != dev) continue; if (strcmp(xendev->type, type) != 0) continue; return xendev; } return NULL; }
false
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev) { struct XenDevice *xendev; TAILQ_FOREACH(xendev, &xendevs, next) { if (xendev->dom != dom) continue; if (xendev->dev != dev) continue; if (strcmp(xendev->type, type) != 0) continue; return xendev; } return NULL; }
{ "code": [], "line_no": [] }
struct XenDevice *FUNC_0(const char *VAR_0, int VAR_1, int VAR_2) { struct XenDevice *VAR_3; TAILQ_FOREACH(VAR_3, &xendevs, next) { if (VAR_3->VAR_1 != VAR_1) continue; if (VAR_3->VAR_2 != VAR_2) continue; if (strcmp(VAR_3->VAR_0, VAR_0) != 0) continue; return VAR_3; } return NULL; }
[ "struct XenDevice *FUNC_0(const char *VAR_0, int VAR_1, int VAR_2)\n{", "struct XenDevice *VAR_3;", "TAILQ_FOREACH(VAR_3, &xendevs, next) {", "if (VAR_3->VAR_1 != VAR_1)\ncontinue;", "if (VAR_3->VAR_2 != VAR_2)\ncontinue;", "if (strcmp(VAR_3->VAR_0, VAR_0) != 0)\ncontinue;", "return VAR_3;", "}", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 15, 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
400
static void dct_unquantize_mpeg1_mmx(MpegEncContext *s, DCTELEM *block, int n, int qscale) { int i, level; const UINT16 *quant_matrix; if (s->mb_intra) { if (n < 4) block[0] = block[0] * s->y_dc_scale; else block[0] = block[0] * s->c_dc_scale; if (s->out_format == FMT_H263) { i = 1; goto unquant_even; } /* XXX: only mpeg1 */ quant_matrix = s->intra_matrix; i=1; /* Align on 4 elements boundary */ while(i&3) { level = block[i]; if (level) { if (level < 0) level = -level; level = (int)(level * qscale * quant_matrix[i]) >> 3; level = (level - 1) | 1; if (block[i] < 0) level = -level; block[i] = level; } i++; } __asm __volatile( "movd %0, %%mm6\n\t" /* mm6 = qscale | 0 */ "punpckldq %%mm6, %%mm6\n\t" /* mm6 = qscale | qscale */ "movq %2, %%mm4\n\t" "movq %%mm6, %%mm7\n\t" "movq %1, %%mm5\n\t" "packssdw %%mm6, %%mm7\n\t" /* mm7 = qscale | qscale | qscale | qscale */ "pxor %%mm6, %%mm6\n\t" ::"g"(qscale),"m"(mm_wone),"m"(mm_wabs):"memory"); for(;i<64;i+=4) { __asm __volatile( "movq %1, %%mm0\n\t" "movq %%mm7, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm0, %%mm3\n\t" "pcmpgtw %%mm6, %%mm2\n\t" "pmullw %2, %%mm1\n\t" "pandn %%mm4, %%mm2\n\t" "por %%mm5, %%mm2\n\t" "pmullw %%mm2, %%mm0\n\t" /* mm0 = abs(block[i]). */ "pcmpeqw %%mm6, %%mm3\n\t" "pmullw %%mm0, %%mm1\n\t" "psraw $3, %%mm1\n\t" "psubw %%mm5, %%mm1\n\t" /* block[i] --; */ "pandn %%mm4, %%mm3\n\t" /* fake of pcmpneqw : mm0 != 0 then mm1 = -1 */ "por %%mm5, %%mm1\n\t" /* block[i] |= 1 */ "pmullw %%mm2, %%mm1\n\t" /* change signs again */ "pand %%mm3, %%mm1\n\t" /* nullify if was zero */ "movq %%mm1, %0" :"=m"(block[i]) :"m"(block[i]), "m"(quant_matrix[i]) :"memory"); } } else { i = 0; unquant_even: quant_matrix = s->non_intra_matrix; /* Align on 4 elements boundary */ while(i&7) { level = block[i]; if (level) { if (level < 0) level = -level; level = (((level << 1) + 1) * qscale * ((int) quant_matrix[i])) >> 4; level = (level - 1) | 1; if(block[i] < 0) level = -level; block[i] = level; } i++; } 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" "1: \n\t" "movq (%0, %3), %%mm0 \n\t" "movq 8(%0, %3), %%mm1 \n\t" "movq (%1, %3), %%mm4 \n\t" "movq 8(%1, %3), %%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 "paddw %%mm7, %%mm0 \n\t" // abs(block[i])*2 + 1 "paddw %%mm7, %%mm1 \n\t" // abs(block[i])*2 + 1 "pmullw %%mm4, %%mm0 \n\t" // (abs(block[i])*2 + 1)*q "pmullw %%mm5, %%mm1 \n\t" // (abs(block[i])*2 + 1)*q "pxor %%mm4, %%mm4 \n\t" "pxor %%mm5, %%mm5 \n\t" // FIXME slow "pcmpeqw (%0, %3), %%mm4 \n\t" // block[i] == 0 ? -1 : 0 "pcmpeqw 8(%0, %3), %%mm5 \n\t" // block[i] == 0 ? -1 : 0 "psraw $4, %%mm0 \n\t" "psraw $4, %%mm1 \n\t" "psubw %%mm7, %%mm0 \n\t" "psubw %%mm7, %%mm1 \n\t" "por %%mm7, %%mm0 \n\t" "por %%mm7, %%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, %3) \n\t" "movq %%mm5, 8(%0, %3) \n\t" "addl $16, %3 \n\t" "cmpl $128, %3 \n\t" "jb 1b \n\t" ::"r" (block), "r"(quant_matrix), "g" (qscale), "r" (2*i) : "memory" ); #if 0 __asm __volatile( "movd %0, %%mm6\n\t" /* mm6 = qscale | 0 */ "punpckldq %%mm6, %%mm6\n\t" /* mm6 = qscale | qscale */ "movq %2, %%mm4\n\t" "movq %%mm6, %%mm7\n\t" "movq %1, %%mm5\n\t" "packssdw %%mm6, %%mm7\n\t" /* mm7 = qscale | qscale | qscale | qscale */ "pxor %%mm6, %%mm6\n\t" ::"g"(qscale),"m"(mm_wone),"m"(mm_wabs)); for(;i<64;i+=4) { __asm __volatile( "movq %1, %%mm0\n\t" "movq %%mm7, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm0, %%mm3\n\t" "pcmpgtw %%mm6, %%mm2\n\t" "pmullw %2, %%mm1\n\t" "pandn %%mm4, %%mm2\n\t" "por %%mm5, %%mm2\n\t" "pmullw %%mm2, %%mm0\n\t" /* mm0 = abs(block[i]). */ "psllw $1, %%mm0\n\t" /* block[i] <<= 1 */ "paddw %%mm5, %%mm0\n\t" /* block[i] ++ */ "pmullw %%mm0, %%mm1\n\t" "psraw $4, %%mm1\n\t" "pcmpeqw %%mm6, %%mm3\n\t" "psubw %%mm5, %%mm1\n\t" /* block[i] --; */ "pandn %%mm4, %%mm3\n\t" /* fake of pcmpneqw : mm0 != 0 then mm1 = -1 */ "por %%mm5, %%mm1\n\t" /* block[i] |= 1 */ "pmullw %%mm2, %%mm1\n\t" /* change signs again */ "pand %%mm3, %%mm1\n\t" /* nullify if was zero */ "movq %%mm1, %0" :"=m"(block[i]) :"m"(block[i]), "m"(quant_matrix[i])); } #endif } }
false
FFmpeg
f12e206b4737b84afa6071f4b464664a50b0c916
static void dct_unquantize_mpeg1_mmx(MpegEncContext *s, DCTELEM *block, int n, int qscale) { int i, level; const UINT16 *quant_matrix; if (s->mb_intra) { if (n < 4) block[0] = block[0] * s->y_dc_scale; else block[0] = block[0] * s->c_dc_scale; if (s->out_format == FMT_H263) { i = 1; goto unquant_even; } quant_matrix = s->intra_matrix; i=1; while(i&3) { level = block[i]; if (level) { if (level < 0) level = -level; level = (int)(level * qscale * quant_matrix[i]) >> 3; level = (level - 1) | 1; if (block[i] < 0) level = -level; block[i] = level; } i++; } __asm __volatile( "movd %0, %%mm6\n\t" "punpckldq %%mm6, %%mm6\n\t" "movq %2, %%mm4\n\t" "movq %%mm6, %%mm7\n\t" "movq %1, %%mm5\n\t" "packssdw %%mm6, %%mm7\n\t" "pxor %%mm6, %%mm6\n\t" ::"g"(qscale),"m"(mm_wone),"m"(mm_wabs):"memory"); for(;i<64;i+=4) { __asm __volatile( "movq %1, %%mm0\n\t" "movq %%mm7, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm0, %%mm3\n\t" "pcmpgtw %%mm6, %%mm2\n\t" "pmullw %2, %%mm1\n\t" "pandn %%mm4, %%mm2\n\t" "por %%mm5, %%mm2\n\t" "pmullw %%mm2, %%mm0\n\t" "pcmpeqw %%mm6, %%mm3\n\t" "pmullw %%mm0, %%mm1\n\t" "psraw $3, %%mm1\n\t" "psubw %%mm5, %%mm1\n\t" "pandn %%mm4, %%mm3\n\t" "por %%mm5, %%mm1\n\t" "pmullw %%mm2, %%mm1\n\t" "pand %%mm3, %%mm1\n\t" "movq %%mm1, %0" :"=m"(block[i]) :"m"(block[i]), "m"(quant_matrix[i]) :"memory"); } } else { i = 0; unquant_even: quant_matrix = s->non_intra_matrix; while(i&7) { level = block[i]; if (level) { if (level < 0) level = -level; level = (((level << 1) + 1) * qscale * ((int) quant_matrix[i])) >> 4; level = (level - 1) | 1; if(block[i] < 0) level = -level; block[i] = level; } i++; } 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" "1: \n\t" "movq (%0, %3), %%mm0 \n\t" "movq 8(%0, %3), %%mm1 \n\t" "movq (%1, %3), %%mm4 \n\t" "movq 8(%1, %3), %%mm5 \n\t" "pmullw %%mm6, %%mm4 \n\t" "pmullw %%mm6, %%mm5 \n\t" "pxor %%mm2, %%mm2 \n\t" "pxor %%mm3, %%mm3 \n\t" "pcmpgtw %%mm0, %%mm2 \n\t" "pcmpgtw %%mm1, %%mm3 \n\t" "pxor %%mm2, %%mm0 \n\t" "pxor %%mm3, %%mm1 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm3, %%mm1 \n\t" "paddw %%mm0, %%mm0 \n\t" *2 "paddw %%mm1, %%mm1 \n\t" *2 "paddw %%mm7, %%mm0 \n\t" *2 + 1 "paddw %%mm7, %%mm1 \n\t" *2 + 1 "pmullw %%mm4, %%mm0 \n\t" "pmullw %%mm5, %%mm1 \n\t" "pxor %%mm4, %%mm4 \n\t" "pxor %%mm5, %%mm5 \n\t" "pcmpeqw (%0, %3), %%mm4 \n\t" "pcmpeqw 8(%0, %3), %%mm5 \n\t" "psraw $4, %%mm0 \n\t" "psraw $4, %%mm1 \n\t" "psubw %%mm7, %%mm0 \n\t" "psubw %%mm7, %%mm1 \n\t" "por %%mm7, %%mm0 \n\t" "por %%mm7, %%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, %3) \n\t" "movq %%mm5, 8(%0, %3) \n\t" "addl $16, %3 \n\t" "cmpl $128, %3 \n\t" "jb 1b \n\t" ::"r" (block), "r"(quant_matrix), "g" (qscale), "r" (2*i) : "memory" ); #if 0 __asm __volatile( "movd %0, %%mm6\n\t" "punpckldq %%mm6, %%mm6\n\t" "movq %2, %%mm4\n\t" "movq %%mm6, %%mm7\n\t" "movq %1, %%mm5\n\t" "packssdw %%mm6, %%mm7\n\t" "pxor %%mm6, %%mm6\n\t" ::"g"(qscale),"m"(mm_wone),"m"(mm_wabs)); for(;i<64;i+=4) { __asm __volatile( "movq %1, %%mm0\n\t" "movq %%mm7, %%mm1\n\t" "movq %%mm0, %%mm2\n\t" "movq %%mm0, %%mm3\n\t" "pcmpgtw %%mm6, %%mm2\n\t" "pmullw %2, %%mm1\n\t" "pandn %%mm4, %%mm2\n\t" "por %%mm5, %%mm2\n\t" "pmullw %%mm2, %%mm0\n\t" "psllw $1, %%mm0\n\t" "paddw %%mm5, %%mm0\n\t" "pmullw %%mm0, %%mm1\n\t" "psraw $4, %%mm1\n\t" "pcmpeqw %%mm6, %%mm3\n\t" "psubw %%mm5, %%mm1\n\t" "pandn %%mm4, %%mm3\n\t" "por %%mm5, %%mm1\n\t" "pmullw %%mm2, %%mm1\n\t" "pand %%mm3, %%mm1\n\t" "movq %%mm1, %0" :"=m"(block[i]) :"m"(block[i]), "m"(quant_matrix[i])); } #endif } }
{ "code": [], "line_no": [] }
static void FUNC_0(MpegEncContext *VAR_0, DCTELEM *VAR_1, int VAR_2, int VAR_3) { int VAR_4, VAR_5; const UINT16 *VAR_6; if (VAR_0->mb_intra) { if (VAR_2 < 4) VAR_1[0] = VAR_1[0] * VAR_0->y_dc_scale; else VAR_1[0] = VAR_1[0] * VAR_0->c_dc_scale; if (VAR_0->out_format == FMT_H263) { VAR_4 = 1; goto unquant_even; } VAR_6 = VAR_0->intra_matrix; VAR_4=1; while(VAR_4&3) { VAR_5 = VAR_1[VAR_4]; if (VAR_5) { if (VAR_5 < 0) VAR_5 = -VAR_5; VAR_5 = (int)(VAR_5 * VAR_3 * VAR_6[VAR_4]) >> 3; VAR_5 = (VAR_5 - 1) | 1; if (VAR_1[VAR_4] < 0) VAR_5 = -VAR_5; VAR_1[VAR_4] = VAR_5; } VAR_4++; } __asm __volatile( "movd %0, %%mm6\VAR_2\t" "punpckldq %%mm6, %%mm6\VAR_2\t" "movq %2, %%mm4\VAR_2\t" "movq %%mm6, %%mm7\VAR_2\t" "movq %1, %%mm5\VAR_2\t" "packssdw %%mm6, %%mm7\VAR_2\t" "pxor %%mm6, %%mm6\VAR_2\t" ::"g"(VAR_3),"m"(mm_wone),"m"(mm_wabs):"memory"); for(;VAR_4<64;VAR_4+=4) { __asm __volatile( "movq %1, %%mm0\VAR_2\t" "movq %%mm7, %%mm1\VAR_2\t" "movq %%mm0, %%mm2\VAR_2\t" "movq %%mm0, %%mm3\VAR_2\t" "pcmpgtw %%mm6, %%mm2\VAR_2\t" "pmullw %2, %%mm1\VAR_2\t" "pandn %%mm4, %%mm2\VAR_2\t" "por %%mm5, %%mm2\VAR_2\t" "pmullw %%mm2, %%mm0\VAR_2\t" "pcmpeqw %%mm6, %%mm3\VAR_2\t" "pmullw %%mm0, %%mm1\VAR_2\t" "psraw $3, %%mm1\VAR_2\t" "psubw %%mm5, %%mm1\VAR_2\t" "pandn %%mm4, %%mm3\VAR_2\t" "por %%mm5, %%mm1\VAR_2\t" "pmullw %%mm2, %%mm1\VAR_2\t" "pand %%mm3, %%mm1\VAR_2\t" "movq %%mm1, %0" :"=m"(VAR_1[VAR_4]) :"m"(VAR_1[VAR_4]), "m"(VAR_6[VAR_4]) :"memory"); } } else { VAR_4 = 0; unquant_even: VAR_6 = VAR_0->non_intra_matrix; while(VAR_4&7) { VAR_5 = VAR_1[VAR_4]; if (VAR_5) { if (VAR_5 < 0) VAR_5 = -VAR_5; VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 * ((int) VAR_6[VAR_4])) >> 4; VAR_5 = (VAR_5 - 1) | 1; if(VAR_1[VAR_4] < 0) VAR_5 = -VAR_5; VAR_1[VAR_4] = VAR_5; } VAR_4++; } asm volatile( "pcmpeqw %%mm7, %%mm7 \VAR_2\t" "psrlw $15, %%mm7 \VAR_2\t" "movd %2, %%mm6 \VAR_2\t" "packssdw %%mm6, %%mm6 \VAR_2\t" "packssdw %%mm6, %%mm6 \VAR_2\t" "1: \VAR_2\t" "movq (%0, %3), %%mm0 \VAR_2\t" "movq 8(%0, %3), %%mm1 \VAR_2\t" "movq (%1, %3), %%mm4 \VAR_2\t" "movq 8(%1, %3), %%mm5 \VAR_2\t" "pmullw %%mm6, %%mm4 \VAR_2\t" "pmullw %%mm6, %%mm5 \VAR_2\t" "pxor %%mm2, %%mm2 \VAR_2\t" "pxor %%mm3, %%mm3 \VAR_2\t" "pcmpgtw %%mm0, %%mm2 \VAR_2\t" "pcmpgtw %%mm1, %%mm3 \VAR_2\t" "pxor %%mm2, %%mm0 \VAR_2\t" "pxor %%mm3, %%mm1 \VAR_2\t" "psubw %%mm2, %%mm0 \VAR_2\t" "psubw %%mm3, %%mm1 \VAR_2\t" "paddw %%mm0, %%mm0 \VAR_2\t" *2 "paddw %%mm1, %%mm1 \VAR_2\t" *2 "paddw %%mm7, %%mm0 \VAR_2\t" *2 + 1 "paddw %%mm7, %%mm1 \VAR_2\t" *2 + 1 "pmullw %%mm4, %%mm0 \VAR_2\t" "pmullw %%mm5, %%mm1 \VAR_2\t" "pxor %%mm4, %%mm4 \VAR_2\t" "pxor %%mm5, %%mm5 \VAR_2\t" "pcmpeqw (%0, %3), %%mm4 \VAR_2\t" "pcmpeqw 8(%0, %3), %%mm5 \VAR_2\t" "psraw $4, %%mm0 \VAR_2\t" "psraw $4, %%mm1 \VAR_2\t" "psubw %%mm7, %%mm0 \VAR_2\t" "psubw %%mm7, %%mm1 \VAR_2\t" "por %%mm7, %%mm0 \VAR_2\t" "por %%mm7, %%mm1 \VAR_2\t" "pxor %%mm2, %%mm0 \VAR_2\t" "pxor %%mm3, %%mm1 \VAR_2\t" "psubw %%mm2, %%mm0 \VAR_2\t" "psubw %%mm3, %%mm1 \VAR_2\t" "pandn %%mm0, %%mm4 \VAR_2\t" "pandn %%mm1, %%mm5 \VAR_2\t" "movq %%mm4, (%0, %3) \VAR_2\t" "movq %%mm5, 8(%0, %3) \VAR_2\t" "addl $16, %3 \VAR_2\t" "cmpl $128, %3 \VAR_2\t" "jb 1b \VAR_2\t" ::"r" (VAR_1), "r"(VAR_6), "g" (VAR_3), "r" (2*VAR_4) : "memory" ); #if 0 __asm __volatile( "movd %0, %%mm6\VAR_2\t" "punpckldq %%mm6, %%mm6\VAR_2\t" "movq %2, %%mm4\VAR_2\t" "movq %%mm6, %%mm7\VAR_2\t" "movq %1, %%mm5\VAR_2\t" "packssdw %%mm6, %%mm7\VAR_2\t" "pxor %%mm6, %%mm6\VAR_2\t" ::"g"(VAR_3),"m"(mm_wone),"m"(mm_wabs)); for(;VAR_4<64;VAR_4+=4) { __asm __volatile( "movq %1, %%mm0\VAR_2\t" "movq %%mm7, %%mm1\VAR_2\t" "movq %%mm0, %%mm2\VAR_2\t" "movq %%mm0, %%mm3\VAR_2\t" "pcmpgtw %%mm6, %%mm2\VAR_2\t" "pmullw %2, %%mm1\VAR_2\t" "pandn %%mm4, %%mm2\VAR_2\t" "por %%mm5, %%mm2\VAR_2\t" "pmullw %%mm2, %%mm0\VAR_2\t" "psllw $1, %%mm0\VAR_2\t" "paddw %%mm5, %%mm0\VAR_2\t" "pmullw %%mm0, %%mm1\VAR_2\t" "psraw $4, %%mm1\VAR_2\t" "pcmpeqw %%mm6, %%mm3\VAR_2\t" "psubw %%mm5, %%mm1\VAR_2\t" "pandn %%mm4, %%mm3\VAR_2\t" "por %%mm5, %%mm1\VAR_2\t" "pmullw %%mm2, %%mm1\VAR_2\t" "pand %%mm3, %%mm1\VAR_2\t" "movq %%mm1, %0" :"=m"(VAR_1[VAR_4]) :"m"(VAR_1[VAR_4]), "m"(VAR_6[VAR_4])); } #endif } }
[ "static void FUNC_0(MpegEncContext *VAR_0,\nDCTELEM *VAR_1, int VAR_2, int VAR_3)\n{", "int VAR_4, VAR_5;", "const UINT16 *VAR_6;", "if (VAR_0->mb_intra) {", "if (VAR_2 < 4)\nVAR_1[0] = VAR_1[0] * VAR_0->y_dc_scale;", "else\nVAR_1[0] = VAR_1[0] * VAR_0->c_dc_scale;", "if (VAR_0->out_format == FMT_H263) {", "VAR_4 = 1;", "goto unquant_even;", "}", "VAR_6 = VAR_0->intra_matrix;", "VAR_4=1;", "while(VAR_4&3)\n{", "VAR_5 = VAR_1[VAR_4];", "if (VAR_5) {", "if (VAR_5 < 0) VAR_5 = -VAR_5;", "VAR_5 = (int)(VAR_5 * VAR_3 * VAR_6[VAR_4]) >> 3;", "VAR_5 = (VAR_5 - 1) | 1;", "if (VAR_1[VAR_4] < 0) VAR_5 = -VAR_5;", "VAR_1[VAR_4] = VAR_5;", "}", "VAR_4++;", "}", "__asm __volatile(\n\"movd\t%0, %%mm6\\VAR_2\\t\"\n\"punpckldq %%mm6, %%mm6\\VAR_2\\t\"\n\"movq\t%2, %%mm4\\VAR_2\\t\"\n\"movq\t%%mm6, %%mm7\\VAR_2\\t\"\n\"movq\t%1, %%mm5\\VAR_2\\t\"\n\"packssdw %%mm6, %%mm7\\VAR_2\\t\"\n\"pxor\t%%mm6, %%mm6\\VAR_2\\t\"\n::\"g\"(VAR_3),\"m\"(mm_wone),\"m\"(mm_wabs):\"memory\");", "for(;VAR_4<64;VAR_4+=4) {", "__asm __volatile(\n\"movq\t%1, %%mm0\\VAR_2\\t\"\n\"movq\t%%mm7, %%mm1\\VAR_2\\t\"\n\"movq\t%%mm0, %%mm2\\VAR_2\\t\"\n\"movq\t%%mm0, %%mm3\\VAR_2\\t\"\n\"pcmpgtw %%mm6, %%mm2\\VAR_2\\t\"\n\"pmullw\t%2, %%mm1\\VAR_2\\t\"\n\"pandn\t%%mm4, %%mm2\\VAR_2\\t\"\n\"por\t%%mm5, %%mm2\\VAR_2\\t\"\n\"pmullw\t%%mm2, %%mm0\\VAR_2\\t\"\n\"pcmpeqw %%mm6, %%mm3\\VAR_2\\t\"\n\"pmullw\t%%mm0, %%mm1\\VAR_2\\t\"\n\"psraw\t$3, %%mm1\\VAR_2\\t\"\n\"psubw\t%%mm5, %%mm1\\VAR_2\\t\"\n\"pandn\t%%mm4, %%mm3\\VAR_2\\t\"\n\"por\t%%mm5, %%mm1\\VAR_2\\t\"\n\"pmullw %%mm2, %%mm1\\VAR_2\\t\"\n\"pand\t%%mm3, %%mm1\\VAR_2\\t\"\n\"movq\t%%mm1, %0\"\n:\"=m\"(VAR_1[VAR_4])\n:\"m\"(VAR_1[VAR_4]), \"m\"(VAR_6[VAR_4])\n:\"memory\");", "}", "} else {", "VAR_4 = 0;", "unquant_even:\nVAR_6 = VAR_0->non_intra_matrix;", "while(VAR_4&7)\n{", "VAR_5 = VAR_1[VAR_4];", "if (VAR_5) {", "if (VAR_5 < 0) VAR_5 = -VAR_5;", "VAR_5 = (((VAR_5 << 1) + 1) * VAR_3 *\n((int) VAR_6[VAR_4])) >> 4;", "VAR_5 = (VAR_5 - 1) | 1;", "if(VAR_1[VAR_4] < 0) VAR_5 = -VAR_5;", "VAR_1[VAR_4] = VAR_5;", "}", "VAR_4++;", "}", "asm volatile(\n\"pcmpeqw %%mm7, %%mm7\t\t\\VAR_2\\t\"\n\"psrlw $15, %%mm7\t\t\\VAR_2\\t\"\n\"movd %2, %%mm6\t\t\t\\VAR_2\\t\"\n\"packssdw %%mm6, %%mm6\t\t\\VAR_2\\t\"\n\"packssdw %%mm6, %%mm6\t\t\\VAR_2\\t\"\n\"1:\t\t\t\t\\VAR_2\\t\"\n\"movq (%0, %3), %%mm0\t\t\\VAR_2\\t\"\n\"movq 8(%0, %3), %%mm1\t\t\\VAR_2\\t\"\n\"movq (%1, %3), %%mm4\t\t\\VAR_2\\t\"\n\"movq 8(%1, %3), %%mm5\t\t\\VAR_2\\t\"\n\"pmullw %%mm6, %%mm4\t\t\\VAR_2\\t\"\n\"pmullw %%mm6, %%mm5\t\t\\VAR_2\\t\"\n\"pxor %%mm2, %%mm2\t\t\\VAR_2\\t\"\n\"pxor %%mm3, %%mm3\t\t\\VAR_2\\t\"\n\"pcmpgtw %%mm0, %%mm2\t\t\\VAR_2\\t\"\n\"pcmpgtw %%mm1, %%mm3\t\t\\VAR_2\\t\"\n\"pxor %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"pxor %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"psubw %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"psubw %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"paddw %%mm0, %%mm0\t\t\\VAR_2\\t\" *2\n\"paddw %%mm1, %%mm1\t\t\\VAR_2\\t\" *2\n\"paddw %%mm7, %%mm0\t\t\\VAR_2\\t\" *2 + 1\n\"paddw %%mm7, %%mm1\t\t\\VAR_2\\t\" *2 + 1\n\"pmullw %%mm4, %%mm0\t\t\\VAR_2\\t\"\n\"pmullw %%mm5, %%mm1\t\t\\VAR_2\\t\"\n\"pxor %%mm4, %%mm4\t\t\\VAR_2\\t\"\n\"pxor %%mm5, %%mm5\t\t\\VAR_2\\t\"\n\"pcmpeqw (%0, %3), %%mm4\t\\VAR_2\\t\"\n\"pcmpeqw 8(%0, %3), %%mm5\t\\VAR_2\\t\"\n\"psraw $4, %%mm0\t\t\\VAR_2\\t\"\n\"psraw $4, %%mm1\t\t\\VAR_2\\t\"\n\"psubw %%mm7, %%mm0\t\t\\VAR_2\\t\"\n\"psubw %%mm7, %%mm1\t\t\\VAR_2\\t\"\n\"por %%mm7, %%mm0\t\t\\VAR_2\\t\"\n\"por %%mm7, %%mm1\t\t\\VAR_2\\t\"\n\"pxor %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"pxor %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"psubw %%mm2, %%mm0\t\t\\VAR_2\\t\"\n\"psubw %%mm3, %%mm1\t\t\\VAR_2\\t\"\n\"pandn %%mm0, %%mm4\t\t\\VAR_2\\t\"\n\"pandn %%mm1, %%mm5\t\t\\VAR_2\\t\"\n\"movq %%mm4, (%0, %3)\t\t\\VAR_2\\t\"\n\"movq %%mm5, 8(%0, %3)\t\t\\VAR_2\\t\"\n\"addl $16, %3\t\t\t\\VAR_2\\t\"\n\"cmpl $128, %3\t\t\t\\VAR_2\\t\"\n\"jb 1b\t\t\t\t\\VAR_2\\t\"\n::\"r\" (VAR_1), \"r\"(VAR_6), \"g\" (VAR_3), \"r\" (2*VAR_4)\n: \"memory\"\n);", "#if 0\n__asm __volatile(\n\"movd\t%0, %%mm6\\VAR_2\\t\"\n\"punpckldq %%mm6, %%mm6\\VAR_2\\t\"\n\"movq\t%2, %%mm4\\VAR_2\\t\"\n\"movq\t%%mm6, %%mm7\\VAR_2\\t\"\n\"movq\t%1, %%mm5\\VAR_2\\t\"\n\"packssdw %%mm6, %%mm7\\VAR_2\\t\"\n\"pxor\t%%mm6, %%mm6\\VAR_2\\t\"\n::\"g\"(VAR_3),\"m\"(mm_wone),\"m\"(mm_wabs));", "for(;VAR_4<64;VAR_4+=4) {", "__asm __volatile(\n\"movq\t%1, %%mm0\\VAR_2\\t\"\n\"movq\t%%mm7, %%mm1\\VAR_2\\t\"\n\"movq\t%%mm0, %%mm2\\VAR_2\\t\"\n\"movq\t%%mm0, %%mm3\\VAR_2\\t\"\n\"pcmpgtw %%mm6, %%mm2\\VAR_2\\t\"\n\"pmullw\t%2, %%mm1\\VAR_2\\t\"\n\"pandn\t%%mm4, %%mm2\\VAR_2\\t\"\n\"por\t%%mm5, %%mm2\\VAR_2\\t\"\n\"pmullw\t%%mm2, %%mm0\\VAR_2\\t\"\n\"psllw\t$1, %%mm0\\VAR_2\\t\"\n\"paddw\t%%mm5, %%mm0\\VAR_2\\t\"\n\"pmullw\t%%mm0, %%mm1\\VAR_2\\t\"\n\"psraw\t$4, %%mm1\\VAR_2\\t\"\n\"pcmpeqw %%mm6, %%mm3\\VAR_2\\t\"\n\"psubw\t%%mm5, %%mm1\\VAR_2\\t\"\n\"pandn\t%%mm4, %%mm3\\VAR_2\\t\"\n\"por\t%%mm5, %%mm1\\VAR_2\\t\"\n\"pmullw %%mm2, %%mm1\\VAR_2\\t\"\n\"pand\t%%mm3, %%mm1\\VAR_2\\t\"\n\"movq\t%%mm1, %0\"\n:\"=m\"(VAR_1[VAR_4])\n:\"m\"(VAR_1[VAR_4]), \"m\"(VAR_6[VAR_4]));", "}", "#endif\n}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63, 65, 67, 69, 71, 73, 75, 77 ], [ 79 ], [ 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 103, 105, 107, 109, 111, 113, 115, 119, 121, 123, 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135, 137 ], [ 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151, 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253, 255, 257, 261, 263, 265, 267, 269, 271 ], [ 275, 277, 279, 281, 283, 285, 287, 289, 291, 293 ], [ 295 ], [ 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 323, 325, 327, 329, 331, 333, 335, 339, 341, 343, 345 ], [ 347 ], [ 349, 351 ], [ 353 ] ]
401
static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBlock *info, VqInfoBlockLegacy *linfo) { VirtIODevice *vdev = virtio_ccw_get_vdev(sch); uint16_t index = info ? info->index : linfo->index; uint16_t num = info ? info->num : linfo->num; uint64_t desc = info ? info->desc : linfo->queue; if (index >= VIRTIO_CCW_QUEUE_MAX) { return -EINVAL; } /* Current code in virtio.c relies on 4K alignment. */ if (linfo && desc && (linfo->align != 4096)) { return -EINVAL; } if (!vdev) { return -EINVAL; } if (info) { virtio_queue_set_rings(vdev, index, desc, info->avail, info->used); } else { virtio_queue_set_addr(vdev, index, desc); } if (!desc) { virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR); } else { if (info) { /* virtio-1 allows changing the ring size. */ if (virtio_queue_get_max_num(vdev, index) < num) { /* Fail if we exceed the maximum number. */ return -EINVAL; } virtio_queue_set_num(vdev, index, num); } else if (virtio_queue_get_num(vdev, index) > num) { /* Fail if we don't have a big enough queue. */ return -EINVAL; } /* We ignore possible increased num for legacy for compatibility. */ virtio_queue_set_vector(vdev, index, index); } /* tell notify handler in case of config change */ vdev->config_vector = VIRTIO_CCW_QUEUE_MAX; return 0; }
false
qemu
b1914b824ade1706847428e64ef5637ffc0ae238
static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBlock *info, VqInfoBlockLegacy *linfo) { VirtIODevice *vdev = virtio_ccw_get_vdev(sch); uint16_t index = info ? info->index : linfo->index; uint16_t num = info ? info->num : linfo->num; uint64_t desc = info ? info->desc : linfo->queue; if (index >= VIRTIO_CCW_QUEUE_MAX) { return -EINVAL; } if (linfo && desc && (linfo->align != 4096)) { return -EINVAL; } if (!vdev) { return -EINVAL; } if (info) { virtio_queue_set_rings(vdev, index, desc, info->avail, info->used); } else { virtio_queue_set_addr(vdev, index, desc); } if (!desc) { virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR); } else { if (info) { if (virtio_queue_get_max_num(vdev, index) < num) { return -EINVAL; } virtio_queue_set_num(vdev, index, num); } else if (virtio_queue_get_num(vdev, index) > num) { return -EINVAL; } virtio_queue_set_vector(vdev, index, index); } vdev->config_vector = VIRTIO_CCW_QUEUE_MAX; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(SubchDev *VAR_0, VqInfoBlock *VAR_1, VqInfoBlockLegacy *VAR_2) { VirtIODevice *vdev = virtio_ccw_get_vdev(VAR_0); uint16_t index = VAR_1 ? VAR_1->index : VAR_2->index; uint16_t num = VAR_1 ? VAR_1->num : VAR_2->num; uint64_t desc = VAR_1 ? VAR_1->desc : VAR_2->queue; if (index >= VIRTIO_CCW_QUEUE_MAX) { return -EINVAL; } if (VAR_2 && desc && (VAR_2->align != 4096)) { return -EINVAL; } if (!vdev) { return -EINVAL; } if (VAR_1) { virtio_queue_set_rings(vdev, index, desc, VAR_1->avail, VAR_1->used); } else { virtio_queue_set_addr(vdev, index, desc); } if (!desc) { virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR); } else { if (VAR_1) { if (virtio_queue_get_max_num(vdev, index) < num) { return -EINVAL; } virtio_queue_set_num(vdev, index, num); } else if (virtio_queue_get_num(vdev, index) > num) { return -EINVAL; } virtio_queue_set_vector(vdev, index, index); } vdev->config_vector = VIRTIO_CCW_QUEUE_MAX; return 0; }
[ "static int FUNC_0(SubchDev *VAR_0, VqInfoBlock *VAR_1,\nVqInfoBlockLegacy *VAR_2)\n{", "VirtIODevice *vdev = virtio_ccw_get_vdev(VAR_0);", "uint16_t index = VAR_1 ? VAR_1->index : VAR_2->index;", "uint16_t num = VAR_1 ? VAR_1->num : VAR_2->num;", "uint64_t desc = VAR_1 ? VAR_1->desc : VAR_2->queue;", "if (index >= VIRTIO_CCW_QUEUE_MAX) {", "return -EINVAL;", "}", "if (VAR_2 && desc && (VAR_2->align != 4096)) {", "return -EINVAL;", "}", "if (!vdev) {", "return -EINVAL;", "}", "if (VAR_1) {", "virtio_queue_set_rings(vdev, index, desc, VAR_1->avail, VAR_1->used);", "} else {", "virtio_queue_set_addr(vdev, index, desc);", "}", "if (!desc) {", "virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR);", "} else {", "if (VAR_1) {", "if (virtio_queue_get_max_num(vdev, index) < num) {", "return -EINVAL;", "}", "virtio_queue_set_num(vdev, index, num);", "} else if (virtio_queue_get_num(vdev, index) > num) {", "return -EINVAL;", "}", "virtio_queue_set_vector(vdev, index, index);", "}", "vdev->config_vector = VIRTIO_CCW_QUEUE_MAX;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ] ]
403
void qemu_system_debug_request(void) { debug_requested = 1; vm_stop(VMSTOP_DEBUG); }
false
qemu
83f338f73ecb88cc6f85d6e7b81ebef112ce07be
void qemu_system_debug_request(void) { debug_requested = 1; vm_stop(VMSTOP_DEBUG); }
{ "code": [], "line_no": [] }
void FUNC_0(void) { debug_requested = 1; vm_stop(VMSTOP_DEBUG); }
[ "void FUNC_0(void)\n{", "debug_requested = 1;", "vm_stop(VMSTOP_DEBUG);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
405
static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int count, BdrvRequestFlags flags) { return bdrv_co_pwrite_zeroes(bs->file->bs, offset, count, flags); }
false
qemu
a03ef88f77af045a2eb9629b5ce774a3fb973c5e
static int coroutine_fn raw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int count, BdrvRequestFlags flags) { return bdrv_co_pwrite_zeroes(bs->file->bs, offset, count, flags); }
{ "code": [], "line_no": [] }
static int VAR_0 raw_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int count, BdrvRequestFlags flags) { return bdrv_co_pwrite_zeroes(bs->file->bs, offset, count, flags); }
[ "static int VAR_0 raw_co_pwrite_zeroes(BlockDriverState *bs,\nint64_t offset, int count,\nBdrvRequestFlags flags)\n{", "return bdrv_co_pwrite_zeroes(bs->file->bs, offset, count, flags);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ] ]
406
void monitor_flush(Monitor *mon) { int i; if (term_outbuf_index > 0) { for (i = 0; i < MAX_MON; i++) if (monitor_hd[i] && monitor_hd[i]->focus == 0) qemu_chr_write(monitor_hd[i], term_outbuf, term_outbuf_index); term_outbuf_index = 0; } }
false
qemu
871271615108fd58273423d98b7cefe08e6f75a0
void monitor_flush(Monitor *mon) { int i; if (term_outbuf_index > 0) { for (i = 0; i < MAX_MON; i++) if (monitor_hd[i] && monitor_hd[i]->focus == 0) qemu_chr_write(monitor_hd[i], term_outbuf, term_outbuf_index); term_outbuf_index = 0; } }
{ "code": [], "line_no": [] }
void FUNC_0(Monitor *VAR_0) { int VAR_1; if (term_outbuf_index > 0) { for (VAR_1 = 0; VAR_1 < MAX_MON; VAR_1++) if (monitor_hd[VAR_1] && monitor_hd[VAR_1]->focus == 0) qemu_chr_write(monitor_hd[VAR_1], term_outbuf, term_outbuf_index); term_outbuf_index = 0; } }
[ "void FUNC_0(Monitor *VAR_0)\n{", "int VAR_1;", "if (term_outbuf_index > 0) {", "for (VAR_1 = 0; VAR_1 < MAX_MON; VAR_1++)", "if (monitor_hd[VAR_1] && monitor_hd[VAR_1]->focus == 0)\nqemu_chr_write(monitor_hd[VAR_1], term_outbuf, term_outbuf_index);", "term_outbuf_index = 0;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ] ]
407
void qemu_co_queue_restart_all(CoQueue *queue) { while (qemu_co_queue_next(queue)) { /* Do nothing */ } }
false
qemu
28f082469650a0f4c0e37b4ccd6f9514b1a0698d
void qemu_co_queue_restart_all(CoQueue *queue) { while (qemu_co_queue_next(queue)) { } }
{ "code": [], "line_no": [] }
void FUNC_0(CoQueue *VAR_0) { while (qemu_co_queue_next(VAR_0)) { } }
[ "void FUNC_0(CoQueue *VAR_0)\n{", "while (qemu_co_queue_next(VAR_0)) {", "}", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ] ]
408
static void nvdimm_dsm_func_read_fit(AcpiNVDIMMState *state, NvdimmDsmIn *in, hwaddr dsm_mem_addr) { NvdimmFitBuffer *fit_buf = &state->fit_buf; NvdimmFuncReadFITIn *read_fit; NvdimmFuncReadFITOut *read_fit_out; GArray *fit; uint32_t read_len = 0, func_ret_status; int size; read_fit = (NvdimmFuncReadFITIn *)in->arg3; le32_to_cpus(&read_fit->offset); qemu_mutex_lock(&fit_buf->lock); fit = fit_buf->fit; nvdimm_debug("Read FIT: offset %#x FIT size %#x Dirty %s.\n", read_fit->offset, fit->len, fit_buf->dirty ? "Yes" : "No"); if (read_fit->offset > fit->len) { func_ret_status = 3 /* Invalid Input Parameters */; goto exit; } /* It is the first time to read FIT. */ if (!read_fit->offset) { fit_buf->dirty = false; } else if (fit_buf->dirty) { /* FIT has been changed during RFIT. */ func_ret_status = 0x100 /* fit changed */; goto exit; } func_ret_status = 0 /* Success */; read_len = MIN(fit->len - read_fit->offset, 4096 - sizeof(NvdimmFuncReadFITOut)); exit: size = sizeof(NvdimmFuncReadFITOut) + read_len; read_fit_out = g_malloc(size); read_fit_out->len = cpu_to_le32(size); read_fit_out->func_ret_status = cpu_to_le32(func_ret_status); memcpy(read_fit_out->fit, fit->data + read_fit->offset, read_len); cpu_physical_memory_write(dsm_mem_addr, read_fit_out, size); g_free(read_fit_out); qemu_mutex_unlock(&fit_buf->lock); }
false
qemu
12f86b5b3e1bdf75e0a467d771c16cc42f3a1f1a
static void nvdimm_dsm_func_read_fit(AcpiNVDIMMState *state, NvdimmDsmIn *in, hwaddr dsm_mem_addr) { NvdimmFitBuffer *fit_buf = &state->fit_buf; NvdimmFuncReadFITIn *read_fit; NvdimmFuncReadFITOut *read_fit_out; GArray *fit; uint32_t read_len = 0, func_ret_status; int size; read_fit = (NvdimmFuncReadFITIn *)in->arg3; le32_to_cpus(&read_fit->offset); qemu_mutex_lock(&fit_buf->lock); fit = fit_buf->fit; nvdimm_debug("Read FIT: offset %#x FIT size %#x Dirty %s.\n", read_fit->offset, fit->len, fit_buf->dirty ? "Yes" : "No"); if (read_fit->offset > fit->len) { func_ret_status = 3 ; goto exit; } if (!read_fit->offset) { fit_buf->dirty = false; } else if (fit_buf->dirty) { func_ret_status = 0x100 ; goto exit; } func_ret_status = 0 ; read_len = MIN(fit->len - read_fit->offset, 4096 - sizeof(NvdimmFuncReadFITOut)); exit: size = sizeof(NvdimmFuncReadFITOut) + read_len; read_fit_out = g_malloc(size); read_fit_out->len = cpu_to_le32(size); read_fit_out->func_ret_status = cpu_to_le32(func_ret_status); memcpy(read_fit_out->fit, fit->data + read_fit->offset, read_len); cpu_physical_memory_write(dsm_mem_addr, read_fit_out, size); g_free(read_fit_out); qemu_mutex_unlock(&fit_buf->lock); }
{ "code": [], "line_no": [] }
static void FUNC_0(AcpiNVDIMMState *VAR_0, NvdimmDsmIn *VAR_1, hwaddr VAR_2) { NvdimmFitBuffer *fit_buf = &VAR_0->fit_buf; NvdimmFuncReadFITIn *read_fit; NvdimmFuncReadFITOut *read_fit_out; GArray *fit; uint32_t read_len = 0, func_ret_status; int VAR_3; read_fit = (NvdimmFuncReadFITIn *)VAR_1->arg3; le32_to_cpus(&read_fit->offset); qemu_mutex_lock(&fit_buf->lock); fit = fit_buf->fit; nvdimm_debug("Read FIT: offset %#x FIT VAR_3 %#x Dirty %s.\n", read_fit->offset, fit->len, fit_buf->dirty ? "Yes" : "No"); if (read_fit->offset > fit->len) { func_ret_status = 3 ; goto exit; } if (!read_fit->offset) { fit_buf->dirty = false; } else if (fit_buf->dirty) { func_ret_status = 0x100 ; goto exit; } func_ret_status = 0 ; read_len = MIN(fit->len - read_fit->offset, 4096 - sizeof(NvdimmFuncReadFITOut)); exit: VAR_3 = sizeof(NvdimmFuncReadFITOut) + read_len; read_fit_out = g_malloc(VAR_3); read_fit_out->len = cpu_to_le32(VAR_3); read_fit_out->func_ret_status = cpu_to_le32(func_ret_status); memcpy(read_fit_out->fit, fit->data + read_fit->offset, read_len); cpu_physical_memory_write(VAR_2, read_fit_out, VAR_3); g_free(read_fit_out); qemu_mutex_unlock(&fit_buf->lock); }
[ "static void FUNC_0(AcpiNVDIMMState *VAR_0, NvdimmDsmIn *VAR_1,\nhwaddr VAR_2)\n{", "NvdimmFitBuffer *fit_buf = &VAR_0->fit_buf;", "NvdimmFuncReadFITIn *read_fit;", "NvdimmFuncReadFITOut *read_fit_out;", "GArray *fit;", "uint32_t read_len = 0, func_ret_status;", "int VAR_3;", "read_fit = (NvdimmFuncReadFITIn *)VAR_1->arg3;", "le32_to_cpus(&read_fit->offset);", "qemu_mutex_lock(&fit_buf->lock);", "fit = fit_buf->fit;", "nvdimm_debug(\"Read FIT: offset %#x FIT VAR_3 %#x Dirty %s.\\n\",\nread_fit->offset, fit->len, fit_buf->dirty ? \"Yes\" : \"No\");", "if (read_fit->offset > fit->len) {", "func_ret_status = 3 ;", "goto exit;", "}", "if (!read_fit->offset) {", "fit_buf->dirty = false;", "} else if (fit_buf->dirty) {", "func_ret_status = 0x100 ;", "goto exit;", "}", "func_ret_status = 0 ;", "read_len = MIN(fit->len - read_fit->offset,\n4096 - sizeof(NvdimmFuncReadFITOut));", "exit:\nVAR_3 = sizeof(NvdimmFuncReadFITOut) + read_len;", "read_fit_out = g_malloc(VAR_3);", "read_fit_out->len = cpu_to_le32(VAR_3);", "read_fit_out->func_ret_status = cpu_to_le32(func_ret_status);", "memcpy(read_fit_out->fit, fit->data + read_fit->offset, read_len);", "cpu_physical_memory_write(VAR_2, read_fit_out, VAR_3);", "g_free(read_fit_out);", "qemu_mutex_unlock(&fit_buf->lock);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33, 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67, 69 ], [ 73, 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ] ]
409
static void tftp_send_error(struct tftp_session *spt, uint16_t errorcode, const char *msg, struct tftp_t *recv_tp) { struct sockaddr_in saddr, daddr; struct mbuf *m; struct tftp_t *tp; m = m_get(spt->slirp); if (!m) { goto out; } memset(m->m_data, 0, m->m_size); m->m_data += IF_MAXLINKHDR; tp = (void *)m->m_data; m->m_data += sizeof(struct udpiphdr); tp->tp_op = htons(TFTP_ERROR); tp->x.tp_error.tp_error_code = htons(errorcode); pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_msg), msg); saddr.sin_addr = recv_tp->ip.ip_dst; saddr.sin_port = recv_tp->udp.uh_dport; daddr.sin_addr = spt->client_ip; daddr.sin_port = spt->client_port; m->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(msg) - sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); out: tftp_session_terminate(spt); }
false
qemu
5379229a2708df3a1506113315214c3ce5325859
static void tftp_send_error(struct tftp_session *spt, uint16_t errorcode, const char *msg, struct tftp_t *recv_tp) { struct sockaddr_in saddr, daddr; struct mbuf *m; struct tftp_t *tp; m = m_get(spt->slirp); if (!m) { goto out; } memset(m->m_data, 0, m->m_size); m->m_data += IF_MAXLINKHDR; tp = (void *)m->m_data; m->m_data += sizeof(struct udpiphdr); tp->tp_op = htons(TFTP_ERROR); tp->x.tp_error.tp_error_code = htons(errorcode); pstrcpy((char *)tp->x.tp_error.tp_msg, sizeof(tp->x.tp_error.tp_msg), msg); saddr.sin_addr = recv_tp->ip.ip_dst; saddr.sin_port = recv_tp->udp.uh_dport; daddr.sin_addr = spt->client_ip; daddr.sin_port = spt->client_port; m->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(msg) - sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); out: tftp_session_terminate(spt); }
{ "code": [], "line_no": [] }
static void FUNC_0(struct tftp_session *VAR_0, uint16_t VAR_1, const char *VAR_2, struct tftp_t *VAR_3) { struct sockaddr_in VAR_4, VAR_5; struct mbuf *VAR_6; struct tftp_t *VAR_7; VAR_6 = m_get(VAR_0->slirp); if (!VAR_6) { goto out; } memset(VAR_6->m_data, 0, VAR_6->m_size); VAR_6->m_data += IF_MAXLINKHDR; VAR_7 = (void *)VAR_6->m_data; VAR_6->m_data += sizeof(struct udpiphdr); VAR_7->tp_op = htons(TFTP_ERROR); VAR_7->x.tp_error.tp_error_code = htons(VAR_1); pstrcpy((char *)VAR_7->x.tp_error.tp_msg, sizeof(VAR_7->x.tp_error.tp_msg), VAR_2); VAR_4.sin_addr = VAR_3->ip.ip_dst; VAR_4.sin_port = VAR_3->udp.uh_dport; VAR_5.sin_addr = VAR_0->client_ip; VAR_5.sin_port = VAR_0->client_port; VAR_6->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(VAR_2) - sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, VAR_6, &VAR_4, &VAR_5, IPTOS_LOWDELAY); out: tftp_session_terminate(VAR_0); }
[ "static void FUNC_0(struct tftp_session *VAR_0,\nuint16_t VAR_1, const char *VAR_2,\nstruct tftp_t *VAR_3)\n{", "struct sockaddr_in VAR_4, VAR_5;", "struct mbuf *VAR_6;", "struct tftp_t *VAR_7;", "VAR_6 = m_get(VAR_0->slirp);", "if (!VAR_6) {", "goto out;", "}", "memset(VAR_6->m_data, 0, VAR_6->m_size);", "VAR_6->m_data += IF_MAXLINKHDR;", "VAR_7 = (void *)VAR_6->m_data;", "VAR_6->m_data += sizeof(struct udpiphdr);", "VAR_7->tp_op = htons(TFTP_ERROR);", "VAR_7->x.tp_error.tp_error_code = htons(VAR_1);", "pstrcpy((char *)VAR_7->x.tp_error.tp_msg, sizeof(VAR_7->x.tp_error.tp_msg), VAR_2);", "VAR_4.sin_addr = VAR_3->ip.ip_dst;", "VAR_4.sin_port = VAR_3->udp.uh_dport;", "VAR_5.sin_addr = VAR_0->client_ip;", "VAR_5.sin_port = VAR_0->client_port;", "VAR_6->m_len = sizeof(struct tftp_t) - 514 + 3 + strlen(VAR_2) -\nsizeof(struct ip) - sizeof(struct udphdr);", "udp_output2(NULL, VAR_6, &VAR_4, &VAR_5, IPTOS_LOWDELAY);", "out:\ntftp_session_terminate(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 61, 63 ], [ 67 ], [ 71, 73 ], [ 75 ] ]
410
static void omap_rtc_alarm_update(struct omap_rtc_s *s) { s->alarm_ti = mktimegm(&s->alarm_tm); if (s->alarm_ti == -1) printf("%s: conversion failed\n", __FUNCTION__); }
false
qemu
a89f364ae8740dfc31b321eed9ee454e996dc3c1
static void omap_rtc_alarm_update(struct omap_rtc_s *s) { s->alarm_ti = mktimegm(&s->alarm_tm); if (s->alarm_ti == -1) printf("%s: conversion failed\n", __FUNCTION__); }
{ "code": [], "line_no": [] }
static void FUNC_0(struct omap_rtc_s *VAR_0) { VAR_0->alarm_ti = mktimegm(&VAR_0->alarm_tm); if (VAR_0->alarm_ti == -1) printf("%VAR_0: conversion failed\n", __FUNCTION__); }
[ "static void FUNC_0(struct omap_rtc_s *VAR_0)\n{", "VAR_0->alarm_ti = mktimegm(&VAR_0->alarm_tm);", "if (VAR_0->alarm_ti == -1)\nprintf(\"%VAR_0: conversion failed\\n\", __FUNCTION__);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11 ] ]
411
static int http_send_data(HTTPContext *c) { int len, ret; for(;;) { if (c->buffer_ptr >= c->buffer_end) { ret = http_prepare_data(c); if (ret < 0) return -1; else if (ret != 0) /* state change requested */ break; } else { if (c->is_packetized) { /* RTP data output */ len = c->buffer_end - c->buffer_ptr; if (len < 4) { /* fail safe - should never happen */ fail1: c->buffer_ptr = c->buffer_end; return 0; } len = (c->buffer_ptr[0] << 24) | (c->buffer_ptr[1] << 16) | (c->buffer_ptr[2] << 8) | (c->buffer_ptr[3]); if (len > (c->buffer_end - c->buffer_ptr)) goto fail1; if ((get_packet_send_clock(c) - get_server_clock(c)) > 0) { /* nothing to send yet: we can wait */ return 0; } c->data_count += len; update_datarate(&c->datarate, c->data_count); if (c->stream) c->stream->bytes_served += len; if (c->rtp_protocol == RTSP_LOWER_TRANSPORT_TCP) { /* RTP packets are sent inside the RTSP TCP connection */ AVIOContext *pb; int interleaved_index, size; uint8_t header[4]; HTTPContext *rtsp_c; rtsp_c = c->rtsp_c; /* if no RTSP connection left, error */ if (!rtsp_c) return -1; /* if already sending something, then wait. */ if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST) break; if (avio_open_dyn_buf(&pb) < 0) goto fail1; interleaved_index = c->packet_stream_index * 2; /* RTCP packets are sent at odd indexes */ if (c->buffer_ptr[1] == 200) interleaved_index++; /* write RTSP TCP header */ header[0] = '$'; header[1] = interleaved_index; header[2] = len >> 8; header[3] = len; avio_write(pb, header, 4); /* write RTP packet data */ c->buffer_ptr += 4; avio_write(pb, c->buffer_ptr, len); size = avio_close_dyn_buf(pb, &c->packet_buffer); /* prepare asynchronous TCP sending */ rtsp_c->packet_buffer_ptr = c->packet_buffer; rtsp_c->packet_buffer_end = c->packet_buffer + size; c->buffer_ptr += len; /* send everything we can NOW */ len = send(rtsp_c->fd, rtsp_c->packet_buffer_ptr, rtsp_c->packet_buffer_end - rtsp_c->packet_buffer_ptr, 0); if (len > 0) rtsp_c->packet_buffer_ptr += len; if (rtsp_c->packet_buffer_ptr < rtsp_c->packet_buffer_end) { /* if we could not send all the data, we will send it later, so a new state is needed to "lock" the RTSP TCP connection */ rtsp_c->state = RTSPSTATE_SEND_PACKET; break; } else /* all data has been sent */ av_freep(&c->packet_buffer); } else { /* send RTP packet directly in UDP */ c->buffer_ptr += 4; ffurl_write(c->rtp_handles[c->packet_stream_index], c->buffer_ptr, len); c->buffer_ptr += len; /* here we continue as we can send several packets per 10 ms slot */ } } else { /* TCP data output */ len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0); if (len < 0) { if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() != AVERROR(EINTR)) /* error : close connection */ return -1; else return 0; } else c->buffer_ptr += len; c->data_count += len; update_datarate(&c->datarate, c->data_count); if (c->stream) c->stream->bytes_served += len; break; } } } /* for(;;) */ return 0; }
false
FFmpeg
33d6f90e3e0241939ea0be9ca9e1f335942081c8
static int http_send_data(HTTPContext *c) { int len, ret; for(;;) { if (c->buffer_ptr >= c->buffer_end) { ret = http_prepare_data(c); if (ret < 0) return -1; else if (ret != 0) break; } else { if (c->is_packetized) { len = c->buffer_end - c->buffer_ptr; if (len < 4) { fail1: c->buffer_ptr = c->buffer_end; return 0; } len = (c->buffer_ptr[0] << 24) | (c->buffer_ptr[1] << 16) | (c->buffer_ptr[2] << 8) | (c->buffer_ptr[3]); if (len > (c->buffer_end - c->buffer_ptr)) goto fail1; if ((get_packet_send_clock(c) - get_server_clock(c)) > 0) { return 0; } c->data_count += len; update_datarate(&c->datarate, c->data_count); if (c->stream) c->stream->bytes_served += len; if (c->rtp_protocol == RTSP_LOWER_TRANSPORT_TCP) { AVIOContext *pb; int interleaved_index, size; uint8_t header[4]; HTTPContext *rtsp_c; rtsp_c = c->rtsp_c; if (!rtsp_c) return -1; if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST) break; if (avio_open_dyn_buf(&pb) < 0) goto fail1; interleaved_index = c->packet_stream_index * 2; if (c->buffer_ptr[1] == 200) interleaved_index++; header[0] = '$'; header[1] = interleaved_index; header[2] = len >> 8; header[3] = len; avio_write(pb, header, 4); c->buffer_ptr += 4; avio_write(pb, c->buffer_ptr, len); size = avio_close_dyn_buf(pb, &c->packet_buffer); rtsp_c->packet_buffer_ptr = c->packet_buffer; rtsp_c->packet_buffer_end = c->packet_buffer + size; c->buffer_ptr += len; len = send(rtsp_c->fd, rtsp_c->packet_buffer_ptr, rtsp_c->packet_buffer_end - rtsp_c->packet_buffer_ptr, 0); if (len > 0) rtsp_c->packet_buffer_ptr += len; if (rtsp_c->packet_buffer_ptr < rtsp_c->packet_buffer_end) { rtsp_c->state = RTSPSTATE_SEND_PACKET; break; } else av_freep(&c->packet_buffer); } else { c->buffer_ptr += 4; ffurl_write(c->rtp_handles[c->packet_stream_index], c->buffer_ptr, len); c->buffer_ptr += len; } } else { len = send(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0); if (len < 0) { if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() != AVERROR(EINTR)) return -1; else return 0; } else c->buffer_ptr += len; c->data_count += len; update_datarate(&c->datarate, c->data_count); if (c->stream) c->stream->bytes_served += len; break; } } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(HTTPContext *VAR_0) { int VAR_1, VAR_2; for(;;) { if (VAR_0->buffer_ptr >= VAR_0->buffer_end) { VAR_2 = http_prepare_data(VAR_0); if (VAR_2 < 0) return -1; else if (VAR_2 != 0) break; } else { if (VAR_0->is_packetized) { VAR_1 = VAR_0->buffer_end - VAR_0->buffer_ptr; if (VAR_1 < 4) { fail1: VAR_0->buffer_ptr = VAR_0->buffer_end; return 0; } VAR_1 = (VAR_0->buffer_ptr[0] << 24) | (VAR_0->buffer_ptr[1] << 16) | (VAR_0->buffer_ptr[2] << 8) | (VAR_0->buffer_ptr[3]); if (VAR_1 > (VAR_0->buffer_end - VAR_0->buffer_ptr)) goto fail1; if ((get_packet_send_clock(VAR_0) - get_server_clock(VAR_0)) > 0) { return 0; } VAR_0->data_count += VAR_1; update_datarate(&VAR_0->datarate, VAR_0->data_count); if (VAR_0->stream) VAR_0->stream->bytes_served += VAR_1; if (VAR_0->rtp_protocol == RTSP_LOWER_TRANSPORT_TCP) { AVIOContext *pb; int VAR_3, VAR_4; uint8_t header[4]; HTTPContext *rtsp_c; rtsp_c = VAR_0->rtsp_c; if (!rtsp_c) return -1; if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST) break; if (avio_open_dyn_buf(&pb) < 0) goto fail1; VAR_3 = VAR_0->packet_stream_index * 2; if (VAR_0->buffer_ptr[1] == 200) VAR_3++; header[0] = '$'; header[1] = VAR_3; header[2] = VAR_1 >> 8; header[3] = VAR_1; avio_write(pb, header, 4); VAR_0->buffer_ptr += 4; avio_write(pb, VAR_0->buffer_ptr, VAR_1); VAR_4 = avio_close_dyn_buf(pb, &VAR_0->packet_buffer); rtsp_c->packet_buffer_ptr = VAR_0->packet_buffer; rtsp_c->packet_buffer_end = VAR_0->packet_buffer + VAR_4; VAR_0->buffer_ptr += VAR_1; VAR_1 = send(rtsp_c->fd, rtsp_c->packet_buffer_ptr, rtsp_c->packet_buffer_end - rtsp_c->packet_buffer_ptr, 0); if (VAR_1 > 0) rtsp_c->packet_buffer_ptr += VAR_1; if (rtsp_c->packet_buffer_ptr < rtsp_c->packet_buffer_end) { rtsp_c->state = RTSPSTATE_SEND_PACKET; break; } else av_freep(&VAR_0->packet_buffer); } else { VAR_0->buffer_ptr += 4; ffurl_write(VAR_0->rtp_handles[VAR_0->packet_stream_index], VAR_0->buffer_ptr, VAR_1); VAR_0->buffer_ptr += VAR_1; } } else { VAR_1 = send(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr, 0); if (VAR_1 < 0) { if (ff_neterrno() != AVERROR(EAGAIN) && ff_neterrno() != AVERROR(EINTR)) return -1; else return 0; } else VAR_0->buffer_ptr += VAR_1; VAR_0->data_count += VAR_1; update_datarate(&VAR_0->datarate, VAR_0->data_count); if (VAR_0->stream) VAR_0->stream->bytes_served += VAR_1; break; } } } return 0; }
[ "static int FUNC_0(HTTPContext *VAR_0)\n{", "int VAR_1, VAR_2;", "for(;;) {", "if (VAR_0->buffer_ptr >= VAR_0->buffer_end) {", "VAR_2 = http_prepare_data(VAR_0);", "if (VAR_2 < 0)\nreturn -1;", "else if (VAR_2 != 0)\nbreak;", "} else {", "if (VAR_0->is_packetized) {", "VAR_1 = VAR_0->buffer_end - VAR_0->buffer_ptr;", "if (VAR_1 < 4) {", "fail1:\nVAR_0->buffer_ptr = VAR_0->buffer_end;", "return 0;", "}", "VAR_1 = (VAR_0->buffer_ptr[0] << 24) |\n(VAR_0->buffer_ptr[1] << 16) |\n(VAR_0->buffer_ptr[2] << 8) |\n(VAR_0->buffer_ptr[3]);", "if (VAR_1 > (VAR_0->buffer_end - VAR_0->buffer_ptr))\ngoto fail1;", "if ((get_packet_send_clock(VAR_0) - get_server_clock(VAR_0)) > 0) {", "return 0;", "}", "VAR_0->data_count += VAR_1;", "update_datarate(&VAR_0->datarate, VAR_0->data_count);", "if (VAR_0->stream)\nVAR_0->stream->bytes_served += VAR_1;", "if (VAR_0->rtp_protocol == RTSP_LOWER_TRANSPORT_TCP) {", "AVIOContext *pb;", "int VAR_3, VAR_4;", "uint8_t header[4];", "HTTPContext *rtsp_c;", "rtsp_c = VAR_0->rtsp_c;", "if (!rtsp_c)\nreturn -1;", "if (rtsp_c->state != RTSPSTATE_WAIT_REQUEST)\nbreak;", "if (avio_open_dyn_buf(&pb) < 0)\ngoto fail1;", "VAR_3 = VAR_0->packet_stream_index * 2;", "if (VAR_0->buffer_ptr[1] == 200)\nVAR_3++;", "header[0] = '$';", "header[1] = VAR_3;", "header[2] = VAR_1 >> 8;", "header[3] = VAR_1;", "avio_write(pb, header, 4);", "VAR_0->buffer_ptr += 4;", "avio_write(pb, VAR_0->buffer_ptr, VAR_1);", "VAR_4 = avio_close_dyn_buf(pb, &VAR_0->packet_buffer);", "rtsp_c->packet_buffer_ptr = VAR_0->packet_buffer;", "rtsp_c->packet_buffer_end = VAR_0->packet_buffer + VAR_4;", "VAR_0->buffer_ptr += VAR_1;", "VAR_1 = send(rtsp_c->fd, rtsp_c->packet_buffer_ptr,\nrtsp_c->packet_buffer_end - rtsp_c->packet_buffer_ptr, 0);", "if (VAR_1 > 0)\nrtsp_c->packet_buffer_ptr += VAR_1;", "if (rtsp_c->packet_buffer_ptr < rtsp_c->packet_buffer_end) {", "rtsp_c->state = RTSPSTATE_SEND_PACKET;", "break;", "} else", "av_freep(&VAR_0->packet_buffer);", "} else {", "VAR_0->buffer_ptr += 4;", "ffurl_write(VAR_0->rtp_handles[VAR_0->packet_stream_index],\nVAR_0->buffer_ptr, VAR_1);", "VAR_0->buffer_ptr += VAR_1;", "}", "} else {", "VAR_1 = send(VAR_0->fd, VAR_0->buffer_ptr, VAR_0->buffer_end - VAR_0->buffer_ptr, 0);", "if (VAR_1 < 0) {", "if (ff_neterrno() != AVERROR(EAGAIN) &&\nff_neterrno() != AVERROR(EINTR))\nreturn -1;", "else\nreturn 0;", "} else", "VAR_0->buffer_ptr += VAR_1;", "VAR_0->data_count += VAR_1;", "update_datarate(&VAR_0->datarate, VAR_0->data_count);", "if (VAR_0->stream)\nVAR_0->stream->bytes_served += VAR_1;", "break;", "}", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19, 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45, 47, 49, 51 ], [ 53, 55 ], [ 57 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 95, 97 ], [ 101, 103 ], [ 105, 107 ], [ 109 ], [ 113, 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 149, 151 ], [ 153, 155 ], [ 157 ], [ 165 ], [ 167 ], [ 169 ], [ 173 ], [ 175 ], [ 179 ], [ 181, 183 ], [ 185 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 199, 201, 205 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ] ]
412
static inline bool vtd_iova_range_check(uint64_t iova, VTDContextEntry *ce) { /* * Check if @iova is above 2^X-1, where X is the minimum of MGAW * in CAP_REG and AW in context-entry. */ return !(iova & ~(vtd_iova_limit(ce) - 1)); }
false
qemu
37f51384ae05bd50f83308339dbffa3e78404874
static inline bool vtd_iova_range_check(uint64_t iova, VTDContextEntry *ce) { return !(iova & ~(vtd_iova_limit(ce) - 1)); }
{ "code": [], "line_no": [] }
static inline bool FUNC_0(uint64_t iova, VTDContextEntry *ce) { return !(iova & ~(vtd_iova_limit(ce) - 1)); }
[ "static inline bool FUNC_0(uint64_t iova, VTDContextEntry *ce)\n{", "return !(iova & ~(vtd_iova_limit(ce) - 1));", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 13 ], [ 15 ] ]
413
DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) { const char *value; BlockBackend *blk; DriveInfo *dinfo = NULL; QDict *bs_opts; QemuOpts *legacy_opts; DriveMediaType media = MEDIA_DISK; BlockInterfaceType type; int cyls, heads, secs, translation; int max_devs, bus_id, unit_id, index; const char *devaddr; const char *werror, *rerror; bool read_only = false; bool copy_on_read; const char *serial; const char *filename; Error *local_err = NULL; int i; const char *deprecated[] = { "serial", "trans", "secs", "heads", "cyls", "addr" }; /* Change legacy command line options into QMP ones */ static const struct { const char *from; const char *to; } opt_renames[] = { { "iops", "throttling.iops-total" }, { "iops_rd", "throttling.iops-read" }, { "iops_wr", "throttling.iops-write" }, { "bps", "throttling.bps-total" }, { "bps_rd", "throttling.bps-read" }, { "bps_wr", "throttling.bps-write" }, { "iops_max", "throttling.iops-total-max" }, { "iops_rd_max", "throttling.iops-read-max" }, { "iops_wr_max", "throttling.iops-write-max" }, { "bps_max", "throttling.bps-total-max" }, { "bps_rd_max", "throttling.bps-read-max" }, { "bps_wr_max", "throttling.bps-write-max" }, { "iops_size", "throttling.iops-size" }, { "group", "throttling.group" }, { "readonly", BDRV_OPT_READ_ONLY }, }; for (i = 0; i < ARRAY_SIZE(opt_renames); i++) { qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to, &local_err); if (local_err) { error_report_err(local_err); return NULL; } } value = qemu_opt_get(all_opts, "cache"); if (value) { int flags = 0; bool writethrough; if (bdrv_parse_cache_mode(value, &flags, &writethrough) != 0) { error_report("invalid cache option"); return NULL; } /* Specific options take precedence */ if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_WB)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_WB, !writethrough, &error_abort); } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_DIRECT)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_DIRECT, !!(flags & BDRV_O_NOCACHE), &error_abort); } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_NO_FLUSH)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_NO_FLUSH, !!(flags & BDRV_O_NO_FLUSH), &error_abort); } qemu_opt_unset(all_opts, "cache"); } /* Get a QDict for processing the options */ bs_opts = qdict_new(); qemu_opts_to_qdict(all_opts, bs_opts); legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err); if (local_err) { error_report_err(local_err); goto fail; } /* Deprecated option boot=[on|off] */ if (qemu_opt_get(legacy_opts, "boot") != NULL) { fprintf(stderr, "qemu-kvm: boot=on|off is deprecated and will be " "ignored. Future versions will reject this parameter. Please " "update your scripts.\n"); } /* Other deprecated options */ if (!qtest_enabled()) { for (i = 0; i < ARRAY_SIZE(deprecated); i++) { if (qemu_opt_get(legacy_opts, deprecated[i]) != NULL) { error_report("'%s' is deprecated, please use the corresponding " "option of '-device' instead", deprecated[i]); } } } /* Media type */ value = qemu_opt_get(legacy_opts, "media"); if (value) { if (!strcmp(value, "disk")) { media = MEDIA_DISK; } else if (!strcmp(value, "cdrom")) { media = MEDIA_CDROM; read_only = true; } else { error_report("'%s' invalid media", value); goto fail; } } /* copy-on-read is disabled with a warning for read-only devices */ read_only |= qemu_opt_get_bool(legacy_opts, BDRV_OPT_READ_ONLY, false); copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false); if (read_only && copy_on_read) { error_report("warning: disabling copy-on-read on read-only drive"); copy_on_read = false; } qdict_put_str(bs_opts, BDRV_OPT_READ_ONLY, read_only ? "on" : "off"); qdict_put_str(bs_opts, "copy-on-read", copy_on_read ? "on" : "off"); /* Controller type */ value = qemu_opt_get(legacy_opts, "if"); if (value) { for (type = 0; type < IF_COUNT && strcmp(value, if_name[type]); type++) { } if (type == IF_COUNT) { error_report("unsupported bus type '%s'", value); goto fail; } } else { type = block_default_type; } /* Geometry */ cyls = qemu_opt_get_number(legacy_opts, "cyls", 0); heads = qemu_opt_get_number(legacy_opts, "heads", 0); secs = qemu_opt_get_number(legacy_opts, "secs", 0); if (cyls || heads || secs) { if (cyls < 1) { error_report("invalid physical cyls number"); goto fail; } if (heads < 1) { error_report("invalid physical heads number"); goto fail; } if (secs < 1) { error_report("invalid physical secs number"); goto fail; } } translation = BIOS_ATA_TRANSLATION_AUTO; value = qemu_opt_get(legacy_opts, "trans"); if (value != NULL) { if (!cyls) { error_report("'%s' trans must be used with cyls, heads and secs", value); goto fail; } if (!strcmp(value, "none")) { translation = BIOS_ATA_TRANSLATION_NONE; } else if (!strcmp(value, "lba")) { translation = BIOS_ATA_TRANSLATION_LBA; } else if (!strcmp(value, "large")) { translation = BIOS_ATA_TRANSLATION_LARGE; } else if (!strcmp(value, "rechs")) { translation = BIOS_ATA_TRANSLATION_RECHS; } else if (!strcmp(value, "auto")) { translation = BIOS_ATA_TRANSLATION_AUTO; } else { error_report("'%s' invalid translation type", value); goto fail; } } if (media == MEDIA_CDROM) { if (cyls || secs || heads) { error_report("CHS can't be set with media=cdrom"); goto fail; } } /* Device address specified by bus/unit or index. * If none was specified, try to find the first free one. */ bus_id = qemu_opt_get_number(legacy_opts, "bus", 0); unit_id = qemu_opt_get_number(legacy_opts, "unit", -1); index = qemu_opt_get_number(legacy_opts, "index", -1); max_devs = if_max_devs[type]; if (index != -1) { if (bus_id != 0 || unit_id != -1) { error_report("index cannot be used with bus and unit"); goto fail; } bus_id = drive_index_to_bus_id(type, index); unit_id = drive_index_to_unit_id(type, index); } if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } if (max_devs && unit_id >= max_devs) { error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); goto fail; } if (drive_get(type, bus_id, unit_id) != NULL) { error_report("drive with bus=%d, unit=%d (index=%d) exists", bus_id, unit_id, index); goto fail; } /* Serial number */ serial = qemu_opt_get(legacy_opts, "serial"); /* no id supplied -> create one */ if (qemu_opts_id(all_opts) == NULL) { char *new_id; const char *mediastr = ""; if (type == IF_IDE || type == IF_SCSI) { mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; } if (max_devs) { new_id = g_strdup_printf("%s%i%s%i", if_name[type], bus_id, mediastr, unit_id); } else { new_id = g_strdup_printf("%s%s%i", if_name[type], mediastr, unit_id); } qdict_put_str(bs_opts, "id", new_id); g_free(new_id); } /* Add virtio block device */ devaddr = qemu_opt_get(legacy_opts, "addr"); if (devaddr && type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); goto fail; } if (type == IF_VIRTIO) { QemuOpts *devopts; devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(devopts, "driver", "virtio-blk-ccw", &error_abort); } else { qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort); } qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"), &error_abort); if (devaddr) { qemu_opt_set(devopts, "addr", devaddr, &error_abort); } } filename = qemu_opt_get(legacy_opts, "file"); /* Check werror/rerror compatibility with if=... */ werror = qemu_opt_get(legacy_opts, "werror"); if (werror != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "werror", werror); } rerror = qemu_opt_get(legacy_opts, "rerror"); if (rerror != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "rerror", rerror); } /* Actual block device init: Functionality shared with blockdev-add */ blk = blockdev_init(filename, bs_opts, &local_err); bs_opts = NULL; if (!blk) { if (local_err) { error_report_err(local_err); } goto fail; } else { assert(!local_err); } /* Create legacy DriveInfo */ dinfo = g_malloc0(sizeof(*dinfo)); dinfo->opts = all_opts; dinfo->cyls = cyls; dinfo->heads = heads; dinfo->secs = secs; dinfo->trans = translation; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->devaddr = devaddr; dinfo->serial = g_strdup(serial); blk_set_legacy_dinfo(blk, dinfo); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: dinfo->media_cd = media == MEDIA_CDROM; break; default: break; } fail: qemu_opts_del(legacy_opts); QDECREF(bs_opts); return dinfo; }
false
qemu
3dc6f8693694a649a9c83f1e2746565b47683923
DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) { const char *value; BlockBackend *blk; DriveInfo *dinfo = NULL; QDict *bs_opts; QemuOpts *legacy_opts; DriveMediaType media = MEDIA_DISK; BlockInterfaceType type; int cyls, heads, secs, translation; int max_devs, bus_id, unit_id, index; const char *devaddr; const char *werror, *rerror; bool read_only = false; bool copy_on_read; const char *serial; const char *filename; Error *local_err = NULL; int i; const char *deprecated[] = { "serial", "trans", "secs", "heads", "cyls", "addr" }; static const struct { const char *from; const char *to; } opt_renames[] = { { "iops", "throttling.iops-total" }, { "iops_rd", "throttling.iops-read" }, { "iops_wr", "throttling.iops-write" }, { "bps", "throttling.bps-total" }, { "bps_rd", "throttling.bps-read" }, { "bps_wr", "throttling.bps-write" }, { "iops_max", "throttling.iops-total-max" }, { "iops_rd_max", "throttling.iops-read-max" }, { "iops_wr_max", "throttling.iops-write-max" }, { "bps_max", "throttling.bps-total-max" }, { "bps_rd_max", "throttling.bps-read-max" }, { "bps_wr_max", "throttling.bps-write-max" }, { "iops_size", "throttling.iops-size" }, { "group", "throttling.group" }, { "readonly", BDRV_OPT_READ_ONLY }, }; for (i = 0; i < ARRAY_SIZE(opt_renames); i++) { qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to, &local_err); if (local_err) { error_report_err(local_err); return NULL; } } value = qemu_opt_get(all_opts, "cache"); if (value) { int flags = 0; bool writethrough; if (bdrv_parse_cache_mode(value, &flags, &writethrough) != 0) { error_report("invalid cache option"); return NULL; } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_WB)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_WB, !writethrough, &error_abort); } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_DIRECT)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_DIRECT, !!(flags & BDRV_O_NOCACHE), &error_abort); } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_NO_FLUSH)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_NO_FLUSH, !!(flags & BDRV_O_NO_FLUSH), &error_abort); } qemu_opt_unset(all_opts, "cache"); } bs_opts = qdict_new(); qemu_opts_to_qdict(all_opts, bs_opts); legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err); if (local_err) { error_report_err(local_err); goto fail; } if (qemu_opt_get(legacy_opts, "boot") != NULL) { fprintf(stderr, "qemu-kvm: boot=on|off is deprecated and will be " "ignored. Future versions will reject this parameter. Please " "update your scripts.\n"); } if (!qtest_enabled()) { for (i = 0; i < ARRAY_SIZE(deprecated); i++) { if (qemu_opt_get(legacy_opts, deprecated[i]) != NULL) { error_report("'%s' is deprecated, please use the corresponding " "option of '-device' instead", deprecated[i]); } } } value = qemu_opt_get(legacy_opts, "media"); if (value) { if (!strcmp(value, "disk")) { media = MEDIA_DISK; } else if (!strcmp(value, "cdrom")) { media = MEDIA_CDROM; read_only = true; } else { error_report("'%s' invalid media", value); goto fail; } } read_only |= qemu_opt_get_bool(legacy_opts, BDRV_OPT_READ_ONLY, false); copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false); if (read_only && copy_on_read) { error_report("warning: disabling copy-on-read on read-only drive"); copy_on_read = false; } qdict_put_str(bs_opts, BDRV_OPT_READ_ONLY, read_only ? "on" : "off"); qdict_put_str(bs_opts, "copy-on-read", copy_on_read ? "on" : "off"); value = qemu_opt_get(legacy_opts, "if"); if (value) { for (type = 0; type < IF_COUNT && strcmp(value, if_name[type]); type++) { } if (type == IF_COUNT) { error_report("unsupported bus type '%s'", value); goto fail; } } else { type = block_default_type; } cyls = qemu_opt_get_number(legacy_opts, "cyls", 0); heads = qemu_opt_get_number(legacy_opts, "heads", 0); secs = qemu_opt_get_number(legacy_opts, "secs", 0); if (cyls || heads || secs) { if (cyls < 1) { error_report("invalid physical cyls number"); goto fail; } if (heads < 1) { error_report("invalid physical heads number"); goto fail; } if (secs < 1) { error_report("invalid physical secs number"); goto fail; } } translation = BIOS_ATA_TRANSLATION_AUTO; value = qemu_opt_get(legacy_opts, "trans"); if (value != NULL) { if (!cyls) { error_report("'%s' trans must be used with cyls, heads and secs", value); goto fail; } if (!strcmp(value, "none")) { translation = BIOS_ATA_TRANSLATION_NONE; } else if (!strcmp(value, "lba")) { translation = BIOS_ATA_TRANSLATION_LBA; } else if (!strcmp(value, "large")) { translation = BIOS_ATA_TRANSLATION_LARGE; } else if (!strcmp(value, "rechs")) { translation = BIOS_ATA_TRANSLATION_RECHS; } else if (!strcmp(value, "auto")) { translation = BIOS_ATA_TRANSLATION_AUTO; } else { error_report("'%s' invalid translation type", value); goto fail; } } if (media == MEDIA_CDROM) { if (cyls || secs || heads) { error_report("CHS can't be set with media=cdrom"); goto fail; } } bus_id = qemu_opt_get_number(legacy_opts, "bus", 0); unit_id = qemu_opt_get_number(legacy_opts, "unit", -1); index = qemu_opt_get_number(legacy_opts, "index", -1); max_devs = if_max_devs[type]; if (index != -1) { if (bus_id != 0 || unit_id != -1) { error_report("index cannot be used with bus and unit"); goto fail; } bus_id = drive_index_to_bus_id(type, index); unit_id = drive_index_to_unit_id(type, index); } if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } if (max_devs && unit_id >= max_devs) { error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); goto fail; } if (drive_get(type, bus_id, unit_id) != NULL) { error_report("drive with bus=%d, unit=%d (index=%d) exists", bus_id, unit_id, index); goto fail; } serial = qemu_opt_get(legacy_opts, "serial"); if (qemu_opts_id(all_opts) == NULL) { char *new_id; const char *mediastr = ""; if (type == IF_IDE || type == IF_SCSI) { mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; } if (max_devs) { new_id = g_strdup_printf("%s%i%s%i", if_name[type], bus_id, mediastr, unit_id); } else { new_id = g_strdup_printf("%s%s%i", if_name[type], mediastr, unit_id); } qdict_put_str(bs_opts, "id", new_id); g_free(new_id); } devaddr = qemu_opt_get(legacy_opts, "addr"); if (devaddr && type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); goto fail; } if (type == IF_VIRTIO) { QemuOpts *devopts; devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(devopts, "driver", "virtio-blk-ccw", &error_abort); } else { qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort); } qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"), &error_abort); if (devaddr) { qemu_opt_set(devopts, "addr", devaddr, &error_abort); } } filename = qemu_opt_get(legacy_opts, "file"); werror = qemu_opt_get(legacy_opts, "werror"); if (werror != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "werror", werror); } rerror = qemu_opt_get(legacy_opts, "rerror"); if (rerror != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "rerror", rerror); } blk = blockdev_init(filename, bs_opts, &local_err); bs_opts = NULL; if (!blk) { if (local_err) { error_report_err(local_err); } goto fail; } else { assert(!local_err); } dinfo = g_malloc0(sizeof(*dinfo)); dinfo->opts = all_opts; dinfo->cyls = cyls; dinfo->heads = heads; dinfo->secs = secs; dinfo->trans = translation; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->devaddr = devaddr; dinfo->serial = g_strdup(serial); blk_set_legacy_dinfo(blk, dinfo); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: dinfo->media_cd = media == MEDIA_CDROM; break; default: break; } fail: qemu_opts_del(legacy_opts); QDECREF(bs_opts); return dinfo; }
{ "code": [], "line_no": [] }
DriveInfo *FUNC_0(QemuOpts *all_opts, BlockInterfaceType block_default_type) { const char *VAR_0; BlockBackend *blk; DriveInfo *dinfo = NULL; QDict *bs_opts; QemuOpts *legacy_opts; DriveMediaType media = MEDIA_DISK; BlockInterfaceType type; int VAR_1, VAR_2, VAR_3, VAR_4; int VAR_5, VAR_6, VAR_7, VAR_8; const char *VAR_9; const char *VAR_10, *VAR_11; bool read_only = false; bool copy_on_read; const char *VAR_12; const char *VAR_13; Error *local_err = NULL; int VAR_14; const char *VAR_15[] = { "VAR_12", "trans", "VAR_3", "VAR_2", "VAR_1", "addr" }; static const struct { const char *from; const char *to; } VAR_16[] = { { "iops", "throttling.iops-total" }, { "iops_rd", "throttling.iops-read" }, { "iops_wr", "throttling.iops-write" }, { "bps", "throttling.bps-total" }, { "bps_rd", "throttling.bps-read" }, { "bps_wr", "throttling.bps-write" }, { "iops_max", "throttling.iops-total-max" }, { "iops_rd_max", "throttling.iops-read-max" }, { "iops_wr_max", "throttling.iops-write-max" }, { "bps_max", "throttling.bps-total-max" }, { "bps_rd_max", "throttling.bps-read-max" }, { "bps_wr_max", "throttling.bps-write-max" }, { "iops_size", "throttling.iops-size" }, { "group", "throttling.group" }, { "readonly", BDRV_OPT_READ_ONLY }, }; for (VAR_14 = 0; VAR_14 < ARRAY_SIZE(VAR_16); VAR_14++) { qemu_opt_rename(all_opts, VAR_16[VAR_14].from, VAR_16[VAR_14].to, &local_err); if (local_err) { error_report_err(local_err); return NULL; } } VAR_0 = qemu_opt_get(all_opts, "cache"); if (VAR_0) { int VAR_17 = 0; bool writethrough; if (bdrv_parse_cache_mode(VAR_0, &VAR_17, &writethrough) != 0) { error_report("invalid cache option"); return NULL; } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_WB)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_WB, !writethrough, &error_abort); } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_DIRECT)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_DIRECT, !!(VAR_17 & BDRV_O_NOCACHE), &error_abort); } if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_NO_FLUSH)) { qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_NO_FLUSH, !!(VAR_17 & BDRV_O_NO_FLUSH), &error_abort); } qemu_opt_unset(all_opts, "cache"); } bs_opts = qdict_new(); qemu_opts_to_qdict(all_opts, bs_opts); legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err); if (local_err) { error_report_err(local_err); goto fail; } if (qemu_opt_get(legacy_opts, "boot") != NULL) { fprintf(stderr, "qemu-kvm: boot=on|off is VAR_15 and will be " "ignored. Future versions will reject this parameter. Please " "update your scripts.\n"); } if (!qtest_enabled()) { for (VAR_14 = 0; VAR_14 < ARRAY_SIZE(VAR_15); VAR_14++) { if (qemu_opt_get(legacy_opts, VAR_15[VAR_14]) != NULL) { error_report("'%s' is VAR_15, please use the corresponding " "option of '-device' instead", VAR_15[VAR_14]); } } } VAR_0 = qemu_opt_get(legacy_opts, "media"); if (VAR_0) { if (!strcmp(VAR_0, "disk")) { media = MEDIA_DISK; } else if (!strcmp(VAR_0, "cdrom")) { media = MEDIA_CDROM; read_only = true; } else { error_report("'%s' invalid media", VAR_0); goto fail; } } read_only |= qemu_opt_get_bool(legacy_opts, BDRV_OPT_READ_ONLY, false); copy_on_read = qemu_opt_get_bool(legacy_opts, "copy-on-read", false); if (read_only && copy_on_read) { error_report("warning: disabling copy-on-read on read-only drive"); copy_on_read = false; } qdict_put_str(bs_opts, BDRV_OPT_READ_ONLY, read_only ? "on" : "off"); qdict_put_str(bs_opts, "copy-on-read", copy_on_read ? "on" : "off"); VAR_0 = qemu_opt_get(legacy_opts, "if"); if (VAR_0) { for (type = 0; type < IF_COUNT && strcmp(VAR_0, if_name[type]); type++) { } if (type == IF_COUNT) { error_report("unsupported bus type '%s'", VAR_0); goto fail; } } else { type = block_default_type; } VAR_1 = qemu_opt_get_number(legacy_opts, "VAR_1", 0); VAR_2 = qemu_opt_get_number(legacy_opts, "VAR_2", 0); VAR_3 = qemu_opt_get_number(legacy_opts, "VAR_3", 0); if (VAR_1 || VAR_2 || VAR_3) { if (VAR_1 < 1) { error_report("invalid physical VAR_1 number"); goto fail; } if (VAR_2 < 1) { error_report("invalid physical VAR_2 number"); goto fail; } if (VAR_3 < 1) { error_report("invalid physical VAR_3 number"); goto fail; } } VAR_4 = BIOS_ATA_TRANSLATION_AUTO; VAR_0 = qemu_opt_get(legacy_opts, "trans"); if (VAR_0 != NULL) { if (!VAR_1) { error_report("'%s' trans must be used with VAR_1, VAR_2 and VAR_3", VAR_0); goto fail; } if (!strcmp(VAR_0, "none")) { VAR_4 = BIOS_ATA_TRANSLATION_NONE; } else if (!strcmp(VAR_0, "lba")) { VAR_4 = BIOS_ATA_TRANSLATION_LBA; } else if (!strcmp(VAR_0, "large")) { VAR_4 = BIOS_ATA_TRANSLATION_LARGE; } else if (!strcmp(VAR_0, "rechs")) { VAR_4 = BIOS_ATA_TRANSLATION_RECHS; } else if (!strcmp(VAR_0, "auto")) { VAR_4 = BIOS_ATA_TRANSLATION_AUTO; } else { error_report("'%s' invalid VAR_4 type", VAR_0); goto fail; } } if (media == MEDIA_CDROM) { if (VAR_1 || VAR_3 || VAR_2) { error_report("CHS can't be set with media=cdrom"); goto fail; } } VAR_6 = qemu_opt_get_number(legacy_opts, "bus", 0); VAR_7 = qemu_opt_get_number(legacy_opts, "unit", -1); VAR_8 = qemu_opt_get_number(legacy_opts, "VAR_8", -1); VAR_5 = if_max_devs[type]; if (VAR_8 != -1) { if (VAR_6 != 0 || VAR_7 != -1) { error_report("VAR_8 cannot be used with bus and unit"); goto fail; } VAR_6 = drive_index_to_bus_id(type, VAR_8); VAR_7 = drive_index_to_unit_id(type, VAR_8); } if (VAR_7 == -1) { VAR_7 = 0; while (drive_get(type, VAR_6, VAR_7) != NULL) { VAR_7++; if (VAR_5 && VAR_7 >= VAR_5) { VAR_7 -= VAR_5; VAR_6++; } } } if (VAR_5 && VAR_7 >= VAR_5) { error_report("unit %d too big (max is %d)", VAR_7, VAR_5 - 1); goto fail; } if (drive_get(type, VAR_6, VAR_7) != NULL) { error_report("drive with bus=%d, unit=%d (VAR_8=%d) exists", VAR_6, VAR_7, VAR_8); goto fail; } VAR_12 = qemu_opt_get(legacy_opts, "VAR_12"); if (qemu_opts_id(all_opts) == NULL) { char *VAR_18; const char *VAR_19 = ""; if (type == IF_IDE || type == IF_SCSI) { VAR_19 = (media == MEDIA_CDROM) ? "-cd" : "-hd"; } if (VAR_5) { VAR_18 = g_strdup_printf("%s%VAR_14%s%VAR_14", if_name[type], VAR_6, VAR_19, VAR_7); } else { VAR_18 = g_strdup_printf("%s%s%VAR_14", if_name[type], VAR_19, VAR_7); } qdict_put_str(bs_opts, "id", VAR_18); g_free(VAR_18); } VAR_9 = qemu_opt_get(legacy_opts, "addr"); if (VAR_9 && type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); goto fail; } if (type == IF_VIRTIO) { QemuOpts *devopts; devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0, &error_abort); if (arch_type == QEMU_ARCH_S390X) { qemu_opt_set(devopts, "driver", "virtio-blk-ccw", &error_abort); } else { qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort); } qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"), &error_abort); if (VAR_9) { qemu_opt_set(devopts, "addr", VAR_9, &error_abort); } } VAR_13 = qemu_opt_get(legacy_opts, "file"); VAR_10 = qemu_opt_get(legacy_opts, "VAR_10"); if (VAR_10 != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("VAR_10 is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "VAR_10", VAR_10); } VAR_11 = qemu_opt_get(legacy_opts, "VAR_11"); if (VAR_11 != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("VAR_11 is not supported by this bus type"); goto fail; } qdict_put_str(bs_opts, "VAR_11", VAR_11); } blk = blockdev_init(VAR_13, bs_opts, &local_err); bs_opts = NULL; if (!blk) { if (local_err) { error_report_err(local_err); } goto fail; } else { assert(!local_err); } dinfo = g_malloc0(sizeof(*dinfo)); dinfo->opts = all_opts; dinfo->VAR_1 = VAR_1; dinfo->VAR_2 = VAR_2; dinfo->VAR_3 = VAR_3; dinfo->trans = VAR_4; dinfo->type = type; dinfo->bus = VAR_6; dinfo->unit = VAR_7; dinfo->VAR_9 = VAR_9; dinfo->VAR_12 = g_strdup(VAR_12); blk_set_legacy_dinfo(blk, dinfo); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: dinfo->media_cd = media == MEDIA_CDROM; break; default: break; } fail: qemu_opts_del(legacy_opts); QDECREF(bs_opts); return dinfo; }
[ "DriveInfo *FUNC_0(QemuOpts *all_opts, BlockInterfaceType block_default_type)\n{", "const char *VAR_0;", "BlockBackend *blk;", "DriveInfo *dinfo = NULL;", "QDict *bs_opts;", "QemuOpts *legacy_opts;", "DriveMediaType media = MEDIA_DISK;", "BlockInterfaceType type;", "int VAR_1, VAR_2, VAR_3, VAR_4;", "int VAR_5, VAR_6, VAR_7, VAR_8;", "const char *VAR_9;", "const char *VAR_10, *VAR_11;", "bool read_only = false;", "bool copy_on_read;", "const char *VAR_12;", "const char *VAR_13;", "Error *local_err = NULL;", "int VAR_14;", "const char *VAR_15[] = {", "\"VAR_12\", \"trans\", \"VAR_3\", \"VAR_2\", \"VAR_1\", \"addr\"\n};", "static const struct {", "const char *from;", "const char *to;", "} VAR_16[] = {", "{ \"iops\", \"throttling.iops-total\" },", "{ \"iops_rd\", \"throttling.iops-read\" },", "{ \"iops_wr\", \"throttling.iops-write\" },", "{ \"bps\", \"throttling.bps-total\" },", "{ \"bps_rd\", \"throttling.bps-read\" },", "{ \"bps_wr\", \"throttling.bps-write\" },", "{ \"iops_max\", \"throttling.iops-total-max\" },", "{ \"iops_rd_max\", \"throttling.iops-read-max\" },", "{ \"iops_wr_max\", \"throttling.iops-write-max\" },", "{ \"bps_max\", \"throttling.bps-total-max\" },", "{ \"bps_rd_max\", \"throttling.bps-read-max\" },", "{ \"bps_wr_max\", \"throttling.bps-write-max\" },", "{ \"iops_size\", \"throttling.iops-size\" },", "{ \"group\", \"throttling.group\" },", "{ \"readonly\", BDRV_OPT_READ_ONLY },", "};", "for (VAR_14 = 0; VAR_14 < ARRAY_SIZE(VAR_16); VAR_14++) {", "qemu_opt_rename(all_opts, VAR_16[VAR_14].from, VAR_16[VAR_14].to,\n&local_err);", "if (local_err) {", "error_report_err(local_err);", "return NULL;", "}", "}", "VAR_0 = qemu_opt_get(all_opts, \"cache\");", "if (VAR_0) {", "int VAR_17 = 0;", "bool writethrough;", "if (bdrv_parse_cache_mode(VAR_0, &VAR_17, &writethrough) != 0) {", "error_report(\"invalid cache option\");", "return NULL;", "}", "if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_WB)) {", "qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_WB,\n!writethrough, &error_abort);", "}", "if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_DIRECT)) {", "qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_DIRECT,\n!!(VAR_17 & BDRV_O_NOCACHE), &error_abort);", "}", "if (!qemu_opt_get(all_opts, BDRV_OPT_CACHE_NO_FLUSH)) {", "qemu_opt_set_bool(all_opts, BDRV_OPT_CACHE_NO_FLUSH,\n!!(VAR_17 & BDRV_O_NO_FLUSH), &error_abort);", "}", "qemu_opt_unset(all_opts, \"cache\");", "}", "bs_opts = qdict_new();", "qemu_opts_to_qdict(all_opts, bs_opts);", "legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0,\n&error_abort);", "qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err);", "if (local_err) {", "error_report_err(local_err);", "goto fail;", "}", "if (qemu_opt_get(legacy_opts, \"boot\") != NULL) {", "fprintf(stderr, \"qemu-kvm: boot=on|off is VAR_15 and will be \"\n\"ignored. Future versions will reject this parameter. Please \"\n\"update your scripts.\\n\");", "}", "if (!qtest_enabled()) {", "for (VAR_14 = 0; VAR_14 < ARRAY_SIZE(VAR_15); VAR_14++) {", "if (qemu_opt_get(legacy_opts, VAR_15[VAR_14]) != NULL) {", "error_report(\"'%s' is VAR_15, please use the corresponding \"\n\"option of '-device' instead\", VAR_15[VAR_14]);", "}", "}", "}", "VAR_0 = qemu_opt_get(legacy_opts, \"media\");", "if (VAR_0) {", "if (!strcmp(VAR_0, \"disk\")) {", "media = MEDIA_DISK;", "} else if (!strcmp(VAR_0, \"cdrom\")) {", "media = MEDIA_CDROM;", "read_only = true;", "} else {", "error_report(\"'%s' invalid media\", VAR_0);", "goto fail;", "}", "}", "read_only |= qemu_opt_get_bool(legacy_opts, BDRV_OPT_READ_ONLY, false);", "copy_on_read = qemu_opt_get_bool(legacy_opts, \"copy-on-read\", false);", "if (read_only && copy_on_read) {", "error_report(\"warning: disabling copy-on-read on read-only drive\");", "copy_on_read = false;", "}", "qdict_put_str(bs_opts, BDRV_OPT_READ_ONLY, read_only ? \"on\" : \"off\");", "qdict_put_str(bs_opts, \"copy-on-read\", copy_on_read ? \"on\" : \"off\");", "VAR_0 = qemu_opt_get(legacy_opts, \"if\");", "if (VAR_0) {", "for (type = 0;", "type < IF_COUNT && strcmp(VAR_0, if_name[type]);", "type++) {", "}", "if (type == IF_COUNT) {", "error_report(\"unsupported bus type '%s'\", VAR_0);", "goto fail;", "}", "} else {", "type = block_default_type;", "}", "VAR_1 = qemu_opt_get_number(legacy_opts, \"VAR_1\", 0);", "VAR_2 = qemu_opt_get_number(legacy_opts, \"VAR_2\", 0);", "VAR_3 = qemu_opt_get_number(legacy_opts, \"VAR_3\", 0);", "if (VAR_1 || VAR_2 || VAR_3) {", "if (VAR_1 < 1) {", "error_report(\"invalid physical VAR_1 number\");", "goto fail;", "}", "if (VAR_2 < 1) {", "error_report(\"invalid physical VAR_2 number\");", "goto fail;", "}", "if (VAR_3 < 1) {", "error_report(\"invalid physical VAR_3 number\");", "goto fail;", "}", "}", "VAR_4 = BIOS_ATA_TRANSLATION_AUTO;", "VAR_0 = qemu_opt_get(legacy_opts, \"trans\");", "if (VAR_0 != NULL) {", "if (!VAR_1) {", "error_report(\"'%s' trans must be used with VAR_1, VAR_2 and VAR_3\",\nVAR_0);", "goto fail;", "}", "if (!strcmp(VAR_0, \"none\")) {", "VAR_4 = BIOS_ATA_TRANSLATION_NONE;", "} else if (!strcmp(VAR_0, \"lba\")) {", "VAR_4 = BIOS_ATA_TRANSLATION_LBA;", "} else if (!strcmp(VAR_0, \"large\")) {", "VAR_4 = BIOS_ATA_TRANSLATION_LARGE;", "} else if (!strcmp(VAR_0, \"rechs\")) {", "VAR_4 = BIOS_ATA_TRANSLATION_RECHS;", "} else if (!strcmp(VAR_0, \"auto\")) {", "VAR_4 = BIOS_ATA_TRANSLATION_AUTO;", "} else {", "error_report(\"'%s' invalid VAR_4 type\", VAR_0);", "goto fail;", "}", "}", "if (media == MEDIA_CDROM) {", "if (VAR_1 || VAR_3 || VAR_2) {", "error_report(\"CHS can't be set with media=cdrom\");", "goto fail;", "}", "}", "VAR_6 = qemu_opt_get_number(legacy_opts, \"bus\", 0);", "VAR_7 = qemu_opt_get_number(legacy_opts, \"unit\", -1);", "VAR_8 = qemu_opt_get_number(legacy_opts, \"VAR_8\", -1);", "VAR_5 = if_max_devs[type];", "if (VAR_8 != -1) {", "if (VAR_6 != 0 || VAR_7 != -1) {", "error_report(\"VAR_8 cannot be used with bus and unit\");", "goto fail;", "}", "VAR_6 = drive_index_to_bus_id(type, VAR_8);", "VAR_7 = drive_index_to_unit_id(type, VAR_8);", "}", "if (VAR_7 == -1) {", "VAR_7 = 0;", "while (drive_get(type, VAR_6, VAR_7) != NULL) {", "VAR_7++;", "if (VAR_5 && VAR_7 >= VAR_5) {", "VAR_7 -= VAR_5;", "VAR_6++;", "}", "}", "}", "if (VAR_5 && VAR_7 >= VAR_5) {", "error_report(\"unit %d too big (max is %d)\", VAR_7, VAR_5 - 1);", "goto fail;", "}", "if (drive_get(type, VAR_6, VAR_7) != NULL) {", "error_report(\"drive with bus=%d, unit=%d (VAR_8=%d) exists\",\nVAR_6, VAR_7, VAR_8);", "goto fail;", "}", "VAR_12 = qemu_opt_get(legacy_opts, \"VAR_12\");", "if (qemu_opts_id(all_opts) == NULL) {", "char *VAR_18;", "const char *VAR_19 = \"\";", "if (type == IF_IDE || type == IF_SCSI) {", "VAR_19 = (media == MEDIA_CDROM) ? \"-cd\" : \"-hd\";", "}", "if (VAR_5) {", "VAR_18 = g_strdup_printf(\"%s%VAR_14%s%VAR_14\", if_name[type], VAR_6,\nVAR_19, VAR_7);", "} else {", "VAR_18 = g_strdup_printf(\"%s%s%VAR_14\", if_name[type],\nVAR_19, VAR_7);", "}", "qdict_put_str(bs_opts, \"id\", VAR_18);", "g_free(VAR_18);", "}", "VAR_9 = qemu_opt_get(legacy_opts, \"addr\");", "if (VAR_9 && type != IF_VIRTIO) {", "error_report(\"addr is not supported by this bus type\");", "goto fail;", "}", "if (type == IF_VIRTIO) {", "QemuOpts *devopts;", "devopts = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0,\n&error_abort);", "if (arch_type == QEMU_ARCH_S390X) {", "qemu_opt_set(devopts, \"driver\", \"virtio-blk-ccw\", &error_abort);", "} else {", "qemu_opt_set(devopts, \"driver\", \"virtio-blk-pci\", &error_abort);", "}", "qemu_opt_set(devopts, \"drive\", qdict_get_str(bs_opts, \"id\"),\n&error_abort);", "if (VAR_9) {", "qemu_opt_set(devopts, \"addr\", VAR_9, &error_abort);", "}", "}", "VAR_13 = qemu_opt_get(legacy_opts, \"file\");", "VAR_10 = qemu_opt_get(legacy_opts, \"VAR_10\");", "if (VAR_10 != NULL) {", "if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO &&\ntype != IF_NONE) {", "error_report(\"VAR_10 is not supported by this bus type\");", "goto fail;", "}", "qdict_put_str(bs_opts, \"VAR_10\", VAR_10);", "}", "VAR_11 = qemu_opt_get(legacy_opts, \"VAR_11\");", "if (VAR_11 != NULL) {", "if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI &&\ntype != IF_NONE) {", "error_report(\"VAR_11 is not supported by this bus type\");", "goto fail;", "}", "qdict_put_str(bs_opts, \"VAR_11\", VAR_11);", "}", "blk = blockdev_init(VAR_13, bs_opts, &local_err);", "bs_opts = NULL;", "if (!blk) {", "if (local_err) {", "error_report_err(local_err);", "}", "goto fail;", "} else {", "assert(!local_err);", "}", "dinfo = g_malloc0(sizeof(*dinfo));", "dinfo->opts = all_opts;", "dinfo->VAR_1 = VAR_1;", "dinfo->VAR_2 = VAR_2;", "dinfo->VAR_3 = VAR_3;", "dinfo->trans = VAR_4;", "dinfo->type = type;", "dinfo->bus = VAR_6;", "dinfo->unit = VAR_7;", "dinfo->VAR_9 = VAR_9;", "dinfo->VAR_12 = g_strdup(VAR_12);", "blk_set_legacy_dinfo(blk, dinfo);", "switch(type) {", "case IF_IDE:\ncase IF_SCSI:\ncase IF_XEN:\ncase IF_NONE:\ndinfo->media_cd = media == MEDIA_CDROM;", "break;", "default:\nbreak;", "}", "fail:\nqemu_opts_del(legacy_opts);", "QDECREF(bs_opts);", "return dinfo;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 93 ], [ 97 ], [ 99 ], [ 103 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 143 ], [ 145, 147 ], [ 149 ], [ 151 ], [ 153, 155 ], [ 157 ], [ 159 ], [ 161, 163 ], [ 165 ], [ 167 ], [ 169 ], [ 175 ], [ 177 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 199 ], [ 201, 203, 205 ], [ 207 ], [ 213 ], [ 215 ], [ 217 ], [ 219, 221 ], [ 223 ], [ 225 ], [ 227 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 261 ], [ 263 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 277 ], [ 279 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 315 ], [ 317 ], [ 319 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361, 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 411 ], [ 419 ], [ 421 ], [ 423 ], [ 427 ], [ 431 ], [ 433 ], [ 435 ], [ 437 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 449 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463 ], [ 465 ], [ 467 ], [ 471 ], [ 473 ], [ 475 ], [ 477 ], [ 481 ], [ 483, 485 ], [ 487 ], [ 489 ], [ 495 ], [ 501 ], [ 503 ], [ 505 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 515, 517 ], [ 519 ], [ 521, 523 ], [ 525 ], [ 527 ], [ 529 ], [ 531 ], [ 537 ], [ 539 ], [ 541 ], [ 543 ], [ 545 ], [ 549 ], [ 551 ], [ 553, 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563 ], [ 565 ], [ 567, 569 ], [ 571 ], [ 573 ], [ 575 ], [ 577 ], [ 581 ], [ 587 ], [ 589 ], [ 591, 593 ], [ 595 ], [ 597 ], [ 599 ], [ 601 ], [ 603 ], [ 607 ], [ 609 ], [ 611, 613 ], [ 615 ], [ 617 ], [ 619 ], [ 621 ], [ 623 ], [ 629 ], [ 631 ], [ 633 ], [ 635 ], [ 637 ], [ 639 ], [ 641 ], [ 643 ], [ 645 ], [ 647 ], [ 653 ], [ 655 ], [ 659 ], [ 661 ], [ 663 ], [ 665 ], [ 669 ], [ 671 ], [ 673 ], [ 675 ], [ 677 ], [ 681 ], [ 685 ], [ 687, 689, 691, 693, 695 ], [ 697 ], [ 699, 701 ], [ 703 ], [ 707, 709 ], [ 711 ], [ 713 ], [ 715 ] ]
414
void qerror_report_internal(const char *file, int linenr, const char *func, const char *fmt, ...) { va_list va; QError *qerror; va_start(va, fmt); qerror = qerror_from_info(file, linenr, func, fmt, &va); va_end(va); if (cur_mon) { monitor_set_error(cur_mon, qerror); } else { qerror_print(qerror); QDECREF(qerror); } }
false
qemu
cde0fc7544ca590c83f349d4dcccf375d55d6042
void qerror_report_internal(const char *file, int linenr, const char *func, const char *fmt, ...) { va_list va; QError *qerror; va_start(va, fmt); qerror = qerror_from_info(file, linenr, func, fmt, &va); va_end(va); if (cur_mon) { monitor_set_error(cur_mon, qerror); } else { qerror_print(qerror); QDECREF(qerror); } }
{ "code": [], "line_no": [] }
void FUNC_0(const char *VAR_0, int VAR_1, const char *VAR_2, const char *VAR_3, ...) { va_list va; QError *qerror; va_start(va, VAR_3); qerror = qerror_from_info(VAR_0, VAR_1, VAR_2, VAR_3, &va); va_end(va); if (cur_mon) { monitor_set_error(cur_mon, qerror); } else { qerror_print(qerror); QDECREF(qerror); } }
[ "void FUNC_0(const char *VAR_0, int VAR_1, const char *VAR_2,\nconst char *VAR_3, ...)\n{", "va_list va;", "QError *qerror;", "va_start(va, VAR_3);", "qerror = qerror_from_info(VAR_0, VAR_1, VAR_2, VAR_3, &va);", "va_end(va);", "if (cur_mon) {", "monitor_set_error(cur_mon, qerror);", "} else {", "qerror_print(qerror);", "QDECREF(qerror);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ] ]
415
static void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type) { Property *prop; prop = qdev_prop_find(dev, name); if (!prop) { fprintf(stderr, "%s: property \"%s.%s\" not found\n", __FUNCTION__, object_get_typename(OBJECT(dev)), name); abort(); } if (prop->info->type != type) { fprintf(stderr, "%s: property \"%s.%s\" type mismatch\n", __FUNCTION__, object_get_typename(OBJECT(dev)), name); abort(); } qdev_prop_cpy(dev, prop, src); }
false
qemu
7a7aae21ccab06606cee9aba846d2e30cb616763
static void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type) { Property *prop; prop = qdev_prop_find(dev, name); if (!prop) { fprintf(stderr, "%s: property \"%s.%s\" not found\n", __FUNCTION__, object_get_typename(OBJECT(dev)), name); abort(); } if (prop->info->type != type) { fprintf(stderr, "%s: property \"%s.%s\" type mismatch\n", __FUNCTION__, object_get_typename(OBJECT(dev)), name); abort(); } qdev_prop_cpy(dev, prop, src); }
{ "code": [], "line_no": [] }
static void FUNC_0(DeviceState *VAR_0, const char *VAR_1, void *VAR_2, enum PropertyType VAR_3) { Property *prop; prop = qdev_prop_find(VAR_0, VAR_1); if (!prop) { fprintf(stderr, "%s: property \"%s.%s\" not found\n", __FUNCTION__, object_get_typename(OBJECT(VAR_0)), VAR_1); abort(); } if (prop->info->VAR_3 != VAR_3) { fprintf(stderr, "%s: property \"%s.%s\" VAR_3 mismatch\n", __FUNCTION__, object_get_typename(OBJECT(VAR_0)), VAR_1); abort(); } qdev_prop_cpy(VAR_0, prop, VAR_2); }
[ "static void FUNC_0(DeviceState *VAR_0, const char *VAR_1, void *VAR_2, enum PropertyType VAR_3)\n{", "Property *prop;", "prop = qdev_prop_find(VAR_0, VAR_1);", "if (!prop) {", "fprintf(stderr, \"%s: property \\\"%s.%s\\\" not found\\n\",\n__FUNCTION__, object_get_typename(OBJECT(VAR_0)), VAR_1);", "abort();", "}", "if (prop->info->VAR_3 != VAR_3) {", "fprintf(stderr, \"%s: property \\\"%s.%s\\\" VAR_3 mismatch\\n\",\n__FUNCTION__, object_get_typename(OBJECT(VAR_0)), VAR_1);", "abort();", "}", "qdev_prop_cpy(VAR_0, prop, VAR_2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ] ]
416
void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value) { if (qdev_prop_set_drive(dev, name, value) < 0) { exit(1); } }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
void qdev_prop_set_drive_nofail(DeviceState *dev, const char *name, BlockDriverState *value) { if (qdev_prop_set_drive(dev, name, value) < 0) { exit(1); } }
{ "code": [], "line_no": [] }
void FUNC_0(DeviceState *VAR_0, const char *VAR_1, BlockDriverState *VAR_2) { if (qdev_prop_set_drive(VAR_0, VAR_1, VAR_2) < 0) { exit(1); } }
[ "void FUNC_0(DeviceState *VAR_0, const char *VAR_1,\nBlockDriverState *VAR_2)\n{", "if (qdev_prop_set_drive(VAR_0, VAR_1, VAR_2) < 0) {", "exit(1);", "}", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
417
static int piix3_post_load(void *opaque, int version_id) { PIIX3State *piix3 = opaque; int pirq; /* Because the i8259 has not been deserialized yet, qemu_irq_raise * might bring the system to a different state than the saved one; * for example, the interrupt could be masked but the i8259 would * not know that yet and would trigger an interrupt in the CPU. * * Here, we update irq levels without raising the interrupt. * Interrupt state will be deserialized separately through the i8259. */ piix3->pic_levels = 0; for (pirq = 0; pirq < PIIX_NUM_PIRQS; pirq++) { piix3_set_irq_level_internal(piix3, pirq, pci_bus_get_irq_level(piix3->dev.bus, pirq)); } return 0; }
false
qemu
fd56e0612b6454a282fa6a953fdb09281a98c589
static int piix3_post_load(void *opaque, int version_id) { PIIX3State *piix3 = opaque; int pirq; piix3->pic_levels = 0; for (pirq = 0; pirq < PIIX_NUM_PIRQS; pirq++) { piix3_set_irq_level_internal(piix3, pirq, pci_bus_get_irq_level(piix3->dev.bus, pirq)); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0, int VAR_1) { PIIX3State *piix3 = VAR_0; int VAR_2; piix3->pic_levels = 0; for (VAR_2 = 0; VAR_2 < PIIX_NUM_PIRQS; VAR_2++) { piix3_set_irq_level_internal(piix3, VAR_2, pci_bus_get_irq_level(piix3->dev.bus, VAR_2)); } return 0; }
[ "static int FUNC_0(void *VAR_0, int VAR_1)\n{", "PIIX3State *piix3 = VAR_0;", "int VAR_2;", "piix3->pic_levels = 0;", "for (VAR_2 = 0; VAR_2 < PIIX_NUM_PIRQS; VAR_2++) {", "piix3_set_irq_level_internal(piix3, VAR_2,\npci_bus_get_irq_level(piix3->dev.bus, VAR_2));", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39 ] ]
418
static void unset_dirty_tracking(void) { BlkMigDevState *bmds; QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { aio_context_acquire(blk_get_aio_context(bmds->blk)); bdrv_release_dirty_bitmap(blk_bs(bmds->blk), bmds->dirty_bitmap); aio_context_release(blk_get_aio_context(bmds->blk)); } }
false
qemu
2119882c7eb7e2c612b24fc0c8d86f5887d6f1c3
static void unset_dirty_tracking(void) { BlkMigDevState *bmds; QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { aio_context_acquire(blk_get_aio_context(bmds->blk)); bdrv_release_dirty_bitmap(blk_bs(bmds->blk), bmds->dirty_bitmap); aio_context_release(blk_get_aio_context(bmds->blk)); } }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { BlkMigDevState *bmds; QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) { aio_context_acquire(blk_get_aio_context(bmds->blk)); bdrv_release_dirty_bitmap(blk_bs(bmds->blk), bmds->dirty_bitmap); aio_context_release(blk_get_aio_context(bmds->blk)); } }
[ "static void FUNC_0(void)\n{", "BlkMigDevState *bmds;", "QSIMPLEQ_FOREACH(bmds, &block_mig_state.bmds_list, entry) {", "aio_context_acquire(blk_get_aio_context(bmds->blk));", "bdrv_release_dirty_bitmap(blk_bs(bmds->blk), bmds->dirty_bitmap);", "aio_context_release(blk_get_aio_context(bmds->blk));", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
419
static void cb_hmp_change_bdrv_pwd(Monitor *mon, const char *password, void *opaque) { Error *encryption_err = opaque; Error *err = NULL; const char *device; device = error_get_field(encryption_err, "device"); qmp_block_passwd(device, password, &err); hmp_handle_error(mon, &err); error_free(encryption_err); monitor_read_command(mon, 1); }
false
qemu
eef5ad1086403d8ac8d91208a0e8dc34734b671c
static void cb_hmp_change_bdrv_pwd(Monitor *mon, const char *password, void *opaque) { Error *encryption_err = opaque; Error *err = NULL; const char *device; device = error_get_field(encryption_err, "device"); qmp_block_passwd(device, password, &err); hmp_handle_error(mon, &err); error_free(encryption_err); monitor_read_command(mon, 1); }
{ "code": [], "line_no": [] }
static void FUNC_0(Monitor *VAR_0, const char *VAR_1, void *VAR_2) { Error *encryption_err = VAR_2; Error *err = NULL; const char *VAR_3; VAR_3 = error_get_field(encryption_err, "VAR_3"); qmp_block_passwd(VAR_3, VAR_1, &err); hmp_handle_error(VAR_0, &err); error_free(encryption_err); monitor_read_command(VAR_0, 1); }
[ "static void FUNC_0(Monitor *VAR_0, const char *VAR_1,\nvoid *VAR_2)\n{", "Error *encryption_err = VAR_2;", "Error *err = NULL;", "const char *VAR_3;", "VAR_3 = error_get_field(encryption_err, \"VAR_3\");", "qmp_block_passwd(VAR_3, VAR_1, &err);", "hmp_handle_error(VAR_0, &err);", "error_free(encryption_err);", "monitor_read_command(VAR_0, 1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ] ]
421
av_cold int ff_ivi_decode_close(AVCodecContext *avctx) { IVI45DecContext *ctx = avctx->priv_data; ivi_free_buffers(&ctx->planes[0]); if (ctx->mb_vlc.cust_tab.table) ff_free_vlc(&ctx->mb_vlc.cust_tab); #if IVI4_STREAM_ANALYSER if (ctx->is_indeo4) { if (ctx->is_scalable) av_log(avctx, AV_LOG_ERROR, "This video uses scalability mode!\n"); if (ctx->uses_tiling) av_log(avctx, AV_LOG_ERROR, "This video uses local decoding!\n"); if (ctx->has_b_frames) av_log(avctx, AV_LOG_ERROR, "This video contains B-frames!\n"); if (ctx->has_transp) av_log(avctx, AV_LOG_ERROR, "Transparency mode is enabled!\n"); if (ctx->uses_haar) av_log(avctx, AV_LOG_ERROR, "This video uses Haar transform!\n"); if (ctx->uses_fullpel) av_log(avctx, AV_LOG_ERROR, "This video uses fullpel motion vectors!\n"); } #endif av_frame_free(&ctx->p_frame); return 0; }
false
FFmpeg
6202e2fede75df92cbc374a3f7d6893d0c5ac721
av_cold int ff_ivi_decode_close(AVCodecContext *avctx) { IVI45DecContext *ctx = avctx->priv_data; ivi_free_buffers(&ctx->planes[0]); if (ctx->mb_vlc.cust_tab.table) ff_free_vlc(&ctx->mb_vlc.cust_tab); #if IVI4_STREAM_ANALYSER if (ctx->is_indeo4) { if (ctx->is_scalable) av_log(avctx, AV_LOG_ERROR, "This video uses scalability mode!\n"); if (ctx->uses_tiling) av_log(avctx, AV_LOG_ERROR, "This video uses local decoding!\n"); if (ctx->has_b_frames) av_log(avctx, AV_LOG_ERROR, "This video contains B-frames!\n"); if (ctx->has_transp) av_log(avctx, AV_LOG_ERROR, "Transparency mode is enabled!\n"); if (ctx->uses_haar) av_log(avctx, AV_LOG_ERROR, "This video uses Haar transform!\n"); if (ctx->uses_fullpel) av_log(avctx, AV_LOG_ERROR, "This video uses fullpel motion vectors!\n"); } #endif av_frame_free(&ctx->p_frame); return 0; }
{ "code": [], "line_no": [] }
av_cold int FUNC_0(AVCodecContext *avctx) { IVI45DecContext *ctx = avctx->priv_data; ivi_free_buffers(&ctx->planes[0]); if (ctx->mb_vlc.cust_tab.table) ff_free_vlc(&ctx->mb_vlc.cust_tab); #if IVI4_STREAM_ANALYSER if (ctx->is_indeo4) { if (ctx->is_scalable) av_log(avctx, AV_LOG_ERROR, "This video uses scalability mode!\n"); if (ctx->uses_tiling) av_log(avctx, AV_LOG_ERROR, "This video uses local decoding!\n"); if (ctx->has_b_frames) av_log(avctx, AV_LOG_ERROR, "This video contains B-frames!\n"); if (ctx->has_transp) av_log(avctx, AV_LOG_ERROR, "Transparency mode is enabled!\n"); if (ctx->uses_haar) av_log(avctx, AV_LOG_ERROR, "This video uses Haar transform!\n"); if (ctx->uses_fullpel) av_log(avctx, AV_LOG_ERROR, "This video uses fullpel motion vectors!\n"); } #endif av_frame_free(&ctx->p_frame); return 0; }
[ "av_cold int FUNC_0(AVCodecContext *avctx)\n{", "IVI45DecContext *ctx = avctx->priv_data;", "ivi_free_buffers(&ctx->planes[0]);", "if (ctx->mb_vlc.cust_tab.table)\nff_free_vlc(&ctx->mb_vlc.cust_tab);", "#if IVI4_STREAM_ANALYSER\nif (ctx->is_indeo4) {", "if (ctx->is_scalable)\nav_log(avctx, AV_LOG_ERROR, \"This video uses scalability mode!\\n\");", "if (ctx->uses_tiling)\nav_log(avctx, AV_LOG_ERROR, \"This video uses local decoding!\\n\");", "if (ctx->has_b_frames)\nav_log(avctx, AV_LOG_ERROR, \"This video contains B-frames!\\n\");", "if (ctx->has_transp)\nav_log(avctx, AV_LOG_ERROR, \"Transparency mode is enabled!\\n\");", "if (ctx->uses_haar)\nav_log(avctx, AV_LOG_ERROR, \"This video uses Haar transform!\\n\");", "if (ctx->uses_fullpel)\nav_log(avctx, AV_LOG_ERROR, \"This video uses fullpel motion vectors!\\n\");", "}", "#endif\nav_frame_free(&ctx->p_frame);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13, 15 ], [ 19, 21 ], [ 23, 25 ], [ 27, 29 ], [ 31, 33 ], [ 35, 37 ], [ 39, 41 ], [ 43, 45 ], [ 47 ], [ 49, 53 ], [ 57 ], [ 59 ] ]
422
static av_cold int cinepak_decode_init(AVCodecContext *avctx) { CinepakContext *s = avctx->priv_data; s->avctx = avctx; s->width = (avctx->width + 3) & ~3; s->height = (avctx->height + 3) & ~3; s->sega_film_skip_bytes = -1; /* uninitialized state */ // check for paletted data if (avctx->bits_per_coded_sample != 8) { s->palette_video = 0; avctx->pix_fmt = AV_PIX_FMT_YUV420P; } else { s->palette_video = 1; avctx->pix_fmt = AV_PIX_FMT_PAL8; } s->frame.data[0] = NULL; return 0; }
false
FFmpeg
3b199d29cd597a3518136d78860e172060b9e83d
static av_cold int cinepak_decode_init(AVCodecContext *avctx) { CinepakContext *s = avctx->priv_data; s->avctx = avctx; s->width = (avctx->width + 3) & ~3; s->height = (avctx->height + 3) & ~3; s->sega_film_skip_bytes = -1; if (avctx->bits_per_coded_sample != 8) { s->palette_video = 0; avctx->pix_fmt = AV_PIX_FMT_YUV420P; } else { s->palette_video = 1; avctx->pix_fmt = AV_PIX_FMT_PAL8; } s->frame.data[0] = NULL; return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { CinepakContext *s = avctx->priv_data; s->avctx = avctx; s->width = (avctx->width + 3) & ~3; s->height = (avctx->height + 3) & ~3; s->sega_film_skip_bytes = -1; if (avctx->bits_per_coded_sample != 8) { s->palette_video = 0; avctx->pix_fmt = AV_PIX_FMT_YUV420P; } else { s->palette_video = 1; avctx->pix_fmt = AV_PIX_FMT_PAL8; } s->frame.data[0] = NULL; return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "CinepakContext *s = avctx->priv_data;", "s->avctx = avctx;", "s->width = (avctx->width + 3) & ~3;", "s->height = (avctx->height + 3) & ~3;", "s->sega_film_skip_bytes = -1;", "if (avctx->bits_per_coded_sample != 8) {", "s->palette_video = 0;", "avctx->pix_fmt = AV_PIX_FMT_YUV420P;", "} else {", "s->palette_video = 1;", "avctx->pix_fmt = AV_PIX_FMT_PAL8;", "}", "s->frame.data[0] = NULL;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 41 ], [ 43 ] ]
423
static int xen_host_pci_config_open(XenHostPCIDevice *d) { char path[PATH_MAX]; int rc; rc = xen_host_pci_sysfs_path(d, "config", path, sizeof (path)); if (rc) { return rc; } d->config_fd = open(path, O_RDWR); if (d->config_fd < 0) { return -errno; } return 0; }
true
qemu
599d0c45615b7d099d256738a586d0f63bc707e6
static int xen_host_pci_config_open(XenHostPCIDevice *d) { char path[PATH_MAX]; int rc; rc = xen_host_pci_sysfs_path(d, "config", path, sizeof (path)); if (rc) { return rc; } d->config_fd = open(path, O_RDWR); if (d->config_fd < 0) { return -errno; } return 0; }
{ "code": [ " return 0;", " if (rc) {", " return rc;", " if (rc) {", " return rc;", " int rc;", " rc = xen_host_pci_sysfs_path(d, \"config\", path, sizeof (path));", " if (rc) {", " return rc;" ], "line_no": [ 27, 13, 15, 13, 15, 7, 11, 13, 15 ] }
static int FUNC_0(XenHostPCIDevice *VAR_0) { char VAR_1[PATH_MAX]; int VAR_2; VAR_2 = xen_host_pci_sysfs_path(VAR_0, "config", VAR_1, sizeof (VAR_1)); if (VAR_2) { return VAR_2; } VAR_0->config_fd = open(VAR_1, O_RDWR); if (VAR_0->config_fd < 0) { return -errno; } return 0; }
[ "static int FUNC_0(XenHostPCIDevice *VAR_0)\n{", "char VAR_1[PATH_MAX];", "int VAR_2;", "VAR_2 = xen_host_pci_sysfs_path(VAR_0, \"config\", VAR_1, sizeof (VAR_1));", "if (VAR_2) {", "return VAR_2;", "}", "VAR_0->config_fd = open(VAR_1, O_RDWR);", "if (VAR_0->config_fd < 0) {", "return -errno;", "}", "return 0;", "}" ]
[ 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
424
void cpu_exec_init(CPUArchState *env) { CPUState *cpu = ENV_GET_CPU(env); CPUClass *cc = CPU_GET_CLASS(cpu); CPUState *some_cpu; int cpu_index; #if defined(CONFIG_USER_ONLY) cpu_list_lock(); #endif cpu_index = 0; CPU_FOREACH(some_cpu) { cpu_index++; } cpu->cpu_index = cpu_index; cpu->numa_node = 0; QTAILQ_INIT(&cpu->breakpoints); QTAILQ_INIT(&cpu->watchpoints); #ifndef CONFIG_USER_ONLY cpu->as = &address_space_memory; cpu->thread_id = qemu_get_thread_id(); #endif QTAILQ_INSERT_TAIL(&cpus, cpu, node); #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); #endif if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { vmstate_register(NULL, cpu_index, &vmstate_cpu_common, cpu); } #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION, cpu_save, cpu_load, env); assert(cc->vmsd == NULL); assert(qdev_get_vmsd(DEVICE(cpu)) == NULL); #endif if (cc->vmsd != NULL) { vmstate_register(NULL, cpu_index, cc->vmsd, cpu); } }
true
qemu
cba7054928b10a7fda57c64807451bbc9a31e42e
void cpu_exec_init(CPUArchState *env) { CPUState *cpu = ENV_GET_CPU(env); CPUClass *cc = CPU_GET_CLASS(cpu); CPUState *some_cpu; int cpu_index; #if defined(CONFIG_USER_ONLY) cpu_list_lock(); #endif cpu_index = 0; CPU_FOREACH(some_cpu) { cpu_index++; } cpu->cpu_index = cpu_index; cpu->numa_node = 0; QTAILQ_INIT(&cpu->breakpoints); QTAILQ_INIT(&cpu->watchpoints); #ifndef CONFIG_USER_ONLY cpu->as = &address_space_memory; cpu->thread_id = qemu_get_thread_id(); #endif QTAILQ_INSERT_TAIL(&cpus, cpu, node); #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); #endif if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { vmstate_register(NULL, cpu_index, &vmstate_cpu_common, cpu); } #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION, cpu_save, cpu_load, env); assert(cc->vmsd == NULL); assert(qdev_get_vmsd(DEVICE(cpu)) == NULL); #endif if (cc->vmsd != NULL) { vmstate_register(NULL, cpu_index, cc->vmsd, cpu); } }
{ "code": [], "line_no": [] }
void FUNC_0(CPUArchState *VAR_0) { CPUState *cpu = ENV_GET_CPU(VAR_0); CPUClass *cc = CPU_GET_CLASS(cpu); CPUState *some_cpu; int VAR_1; #if defined(CONFIG_USER_ONLY) cpu_list_lock(); #endif VAR_1 = 0; CPU_FOREACH(some_cpu) { VAR_1++; } cpu->VAR_1 = VAR_1; cpu->numa_node = 0; QTAILQ_INIT(&cpu->breakpoints); QTAILQ_INIT(&cpu->watchpoints); #ifndef CONFIG_USER_ONLY cpu->as = &address_space_memory; cpu->thread_id = qemu_get_thread_id(); #endif QTAILQ_INSERT_TAIL(&cpus, cpu, node); #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); #endif if (qdev_get_vmsd(DEVICE(cpu)) == NULL) { vmstate_register(NULL, VAR_1, &vmstate_cpu_common, cpu); } #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) register_savevm(NULL, "cpu", VAR_1, CPU_SAVE_VERSION, cpu_save, cpu_load, VAR_0); assert(cc->vmsd == NULL); assert(qdev_get_vmsd(DEVICE(cpu)) == NULL); #endif if (cc->vmsd != NULL) { vmstate_register(NULL, VAR_1, cc->vmsd, cpu); } }
[ "void FUNC_0(CPUArchState *VAR_0)\n{", "CPUState *cpu = ENV_GET_CPU(VAR_0);", "CPUClass *cc = CPU_GET_CLASS(cpu);", "CPUState *some_cpu;", "int VAR_1;", "#if defined(CONFIG_USER_ONLY)\ncpu_list_lock();", "#endif\nVAR_1 = 0;", "CPU_FOREACH(some_cpu) {", "VAR_1++;", "}", "cpu->VAR_1 = VAR_1;", "cpu->numa_node = 0;", "QTAILQ_INIT(&cpu->breakpoints);", "QTAILQ_INIT(&cpu->watchpoints);", "#ifndef CONFIG_USER_ONLY\ncpu->as = &address_space_memory;", "cpu->thread_id = qemu_get_thread_id();", "#endif\nQTAILQ_INSERT_TAIL(&cpus, cpu, node);", "#if defined(CONFIG_USER_ONLY)\ncpu_list_unlock();", "#endif\nif (qdev_get_vmsd(DEVICE(cpu)) == NULL) {", "vmstate_register(NULL, VAR_1, &vmstate_cpu_common, cpu);", "}", "#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)\nregister_savevm(NULL, \"cpu\", VAR_1, CPU_SAVE_VERSION,\ncpu_save, cpu_load, VAR_0);", "assert(cc->vmsd == NULL);", "assert(qdev_get_vmsd(DEVICE(cpu)) == NULL);", "#endif\nif (cc->vmsd != NULL) {", "vmstate_register(NULL, VAR_1, cc->vmsd, cpu);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 44, 46 ], [ 48, 50 ], [ 52, 54 ], [ 56 ], [ 58 ], [ 60, 62, 64 ], [ 66 ], [ 68 ], [ 70, 72 ], [ 74 ], [ 76 ], [ 78 ] ]
425
static int vhost_set_vring_file(struct vhost_dev *dev, VhostUserRequest request, struct vhost_vring_file *file) { int fds[VHOST_MEMORY_MAX_NREGIONS]; size_t fd_num = 0; VhostUserMsg msg = { .request = request, .flags = VHOST_USER_VERSION, .payload.u64 = file->index & VHOST_USER_VRING_IDX_MASK, .size = sizeof(msg.payload.u64), }; if (ioeventfd_enabled() && file->fd > 0) { fds[fd_num++] = file->fd; } else { msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK; } vhost_user_write(dev, &msg, fds, fd_num); return 0; }
true
qemu
c4843a45e3d4f3698b214275ab5e78cdb6a3d212
static int vhost_set_vring_file(struct vhost_dev *dev, VhostUserRequest request, struct vhost_vring_file *file) { int fds[VHOST_MEMORY_MAX_NREGIONS]; size_t fd_num = 0; VhostUserMsg msg = { .request = request, .flags = VHOST_USER_VERSION, .payload.u64 = file->index & VHOST_USER_VRING_IDX_MASK, .size = sizeof(msg.payload.u64), }; if (ioeventfd_enabled() && file->fd > 0) { fds[fd_num++] = file->fd; } else { msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK; } vhost_user_write(dev, &msg, fds, fd_num); return 0; }
{ "code": [ " vhost_user_write(dev, &msg, fds, fd_num);", " vhost_user_write(dev, &msg, fds, fd_num);", " vhost_user_write(dev, &msg, fds, fd_num);" ], "line_no": [ 39, 39, 39 ] }
static int FUNC_0(struct vhost_dev *VAR_0, VhostUserRequest VAR_1, struct vhost_vring_file *VAR_2) { int VAR_3[VHOST_MEMORY_MAX_NREGIONS]; size_t fd_num = 0; VhostUserMsg msg = { .VAR_1 = VAR_1, .flags = VHOST_USER_VERSION, .payload.u64 = VAR_2->index & VHOST_USER_VRING_IDX_MASK, .size = sizeof(msg.payload.u64), }; if (ioeventfd_enabled() && VAR_2->fd > 0) { VAR_3[fd_num++] = VAR_2->fd; } else { msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK; } vhost_user_write(VAR_0, &msg, VAR_3, fd_num); return 0; }
[ "static int FUNC_0(struct vhost_dev *VAR_0,\nVhostUserRequest VAR_1,\nstruct vhost_vring_file *VAR_2)\n{", "int VAR_3[VHOST_MEMORY_MAX_NREGIONS];", "size_t fd_num = 0;", "VhostUserMsg msg = {", ".VAR_1 = VAR_1,\n.flags = VHOST_USER_VERSION,\n.payload.u64 = VAR_2->index & VHOST_USER_VRING_IDX_MASK,\n.size = sizeof(msg.payload.u64),\n};", "if (ioeventfd_enabled() && VAR_2->fd > 0) {", "VAR_3[fd_num++] = VAR_2->fd;", "} else {", "msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK;", "}", "vhost_user_write(VAR_0, &msg, VAR_3, fd_num);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15, 17, 19, 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 43 ], [ 45 ] ]
426
char *qdist_pr(const struct qdist *dist, size_t n_bins, uint32_t opt) { const char *border = opt & QDIST_PR_BORDER ? "|" : ""; char *llabel, *rlabel; char *hgram; GString *s; if (dist->n == 0) { return NULL; } s = g_string_new(""); llabel = qdist_pr_label(dist, n_bins, opt, true); rlabel = qdist_pr_label(dist, n_bins, opt, false); hgram = qdist_pr_plain(dist, n_bins); g_string_append_printf(s, "%s%s%s%s%s", llabel, border, hgram, border, rlabel); g_free(llabel); g_free(rlabel); g_free(hgram); return g_string_free(s, FALSE); }
true
qemu
11b7b07f8a15879134a54e73fade98d5e11e04f8
char *qdist_pr(const struct qdist *dist, size_t n_bins, uint32_t opt) { const char *border = opt & QDIST_PR_BORDER ? "|" : ""; char *llabel, *rlabel; char *hgram; GString *s; if (dist->n == 0) { return NULL; } s = g_string_new(""); llabel = qdist_pr_label(dist, n_bins, opt, true); rlabel = qdist_pr_label(dist, n_bins, opt, false); hgram = qdist_pr_plain(dist, n_bins); g_string_append_printf(s, "%s%s%s%s%s", llabel, border, hgram, border, rlabel); g_free(llabel); g_free(rlabel); g_free(hgram); return g_string_free(s, FALSE); }
{ "code": [ " return NULL;", " return NULL;" ], "line_no": [ 17, 17 ] }
char *FUNC_0(const struct qdist *VAR_0, size_t VAR_1, uint32_t VAR_2) { const char *VAR_3 = VAR_2 & QDIST_PR_BORDER ? "|" : ""; char *VAR_4, *VAR_5; char *VAR_6; GString *s; if (VAR_0->n == 0) { return NULL; } s = g_string_new(""); VAR_4 = qdist_pr_label(VAR_0, VAR_1, VAR_2, true); VAR_5 = qdist_pr_label(VAR_0, VAR_1, VAR_2, false); VAR_6 = qdist_pr_plain(VAR_0, VAR_1); g_string_append_printf(s, "%s%s%s%s%s", VAR_4, VAR_3, VAR_6, VAR_3, VAR_5); g_free(VAR_4); g_free(VAR_5); g_free(VAR_6); return g_string_free(s, FALSE); }
[ "char *FUNC_0(const struct qdist *VAR_0, size_t VAR_1, uint32_t VAR_2)\n{", "const char *VAR_3 = VAR_2 & QDIST_PR_BORDER ? \"|\" : \"\";", "char *VAR_4, *VAR_5;", "char *VAR_6;", "GString *s;", "if (VAR_0->n == 0) {", "return NULL;", "}", "s = g_string_new(\"\");", "VAR_4 = qdist_pr_label(VAR_0, VAR_1, VAR_2, true);", "VAR_5 = qdist_pr_label(VAR_0, VAR_1, VAR_2, false);", "VAR_6 = qdist_pr_plain(VAR_0, VAR_1);", "g_string_append_printf(s, \"%s%s%s%s%s\",\nVAR_4, VAR_3, VAR_6, VAR_3, VAR_5);", "g_free(VAR_4);", "g_free(VAR_5);", "g_free(VAR_6);", "return g_string_free(s, FALSE);", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ] ]
428
static int qemu_rdma_write_one(QEMUFile *f, RDMAContext *rdma, int current_index, uint64_t current_addr, uint64_t length) { struct ibv_sge sge; struct ibv_send_wr send_wr = { 0 }; struct ibv_send_wr *bad_wr; int reg_result_idx, ret, count = 0; uint64_t chunk, chunks; uint8_t *chunk_start, *chunk_end; RDMALocalBlock *block = &(rdma->local_ram_blocks.block[current_index]); RDMARegister reg; RDMARegisterResult *reg_result; RDMAControlHeader resp = { .type = RDMA_CONTROL_REGISTER_RESULT }; RDMAControlHeader head = { .len = sizeof(RDMARegister), .type = RDMA_CONTROL_REGISTER_REQUEST, .repeat = 1, }; retry: sge.addr = (uint64_t)(block->local_host_addr + (current_addr - block->offset)); sge.length = length; chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) sge.addr); chunk_start = ram_chunk_start(block, chunk); if (block->is_ram_block) { chunks = length / (1UL << RDMA_REG_CHUNK_SHIFT); if (chunks && ((length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) { chunks--; } } else { chunks = block->length / (1UL << RDMA_REG_CHUNK_SHIFT); if (chunks && ((block->length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) { chunks--; } } DDPRINTF("Writing %" PRIu64 " chunks, (%" PRIu64 " MB)\n", chunks + 1, (chunks + 1) * (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024); chunk_end = ram_chunk_end(block, chunk + chunks); if (!rdma->pin_all) { #ifdef RDMA_UNREGISTRATION_EXAMPLE qemu_rdma_unregister_waiting(rdma); #endif } while (test_bit(chunk, block->transit_bitmap)) { (void)count; DDPRINTF("(%d) Not clobbering: block: %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d %d\n", count++, current_index, chunk, sge.addr, length, rdma->nb_sent, block->nb_chunks); ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); if (ret < 0) { fprintf(stderr, "Failed to Wait for previous write to complete " "block %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d\n", current_index, chunk, sge.addr, length, rdma->nb_sent); return ret; } } if (!rdma->pin_all || !block->is_ram_block) { if (!block->remote_keys[chunk]) { /* * This chunk has not yet been registered, so first check to see * if the entire chunk is zero. If so, tell the other size to * memset() + madvise() the entire chunk without RDMA. */ if (can_use_buffer_find_nonzero_offset((void *)sge.addr, length) && buffer_find_nonzero_offset((void *)sge.addr, length) == length) { RDMACompress comp = { .offset = current_addr, .value = 0, .block_idx = current_index, .length = length, }; head.len = sizeof(comp); head.type = RDMA_CONTROL_COMPRESS; DDPRINTF("Entire chunk is zero, sending compress: %" PRIu64 " for %d " "bytes, index: %d, offset: %" PRId64 "...\n", chunk, sge.length, current_index, current_addr); compress_to_network(&comp); ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) &comp, NULL, NULL, NULL); if (ret < 0) { return -EIO; } acct_update_position(f, sge.length, true); return 1; } /* * Otherwise, tell other side to register. */ reg.current_index = current_index; if (block->is_ram_block) { reg.key.current_addr = current_addr; } else { reg.key.chunk = chunk; } reg.chunks = chunks; DDPRINTF("Sending registration request chunk %" PRIu64 " for %d " "bytes, index: %d, offset: %" PRId64 "...\n", chunk, sge.length, current_index, current_addr); register_to_network(&reg); ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) &reg, &resp, &reg_result_idx, NULL); if (ret < 0) { return ret; } /* try to overlap this single registration with the one we sent. */ if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *) sge.addr, &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get lkey!\n"); return -EINVAL; } reg_result = (RDMARegisterResult *) rdma->wr_data[reg_result_idx].control_curr; network_to_result(reg_result); DDPRINTF("Received registration result:" " my key: %x their key %x, chunk %" PRIu64 "\n", block->remote_keys[chunk], reg_result->rkey, chunk); block->remote_keys[chunk] = reg_result->rkey; block->remote_host_addr = reg_result->host_addr; } else { /* already registered before */ if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)sge.addr, &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get lkey!\n"); return -EINVAL; } } send_wr.wr.rdma.rkey = block->remote_keys[chunk]; } else { send_wr.wr.rdma.rkey = block->remote_rkey; if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)sge.addr, &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get lkey!\n"); return -EINVAL; } } /* * Encode the ram block index and chunk within this wrid. * We will use this information at the time of completion * to figure out which bitmap to check against and then which * chunk in the bitmap to look for. */ send_wr.wr_id = qemu_rdma_make_wrid(RDMA_WRID_RDMA_WRITE, current_index, chunk); send_wr.opcode = IBV_WR_RDMA_WRITE; send_wr.send_flags = IBV_SEND_SIGNALED; send_wr.sg_list = &sge; send_wr.num_sge = 1; send_wr.wr.rdma.remote_addr = block->remote_host_addr + (current_addr - block->offset); DDDPRINTF("Posting chunk: %" PRIu64 ", addr: %lx" " remote: %lx, bytes %" PRIu32 "\n", chunk, sge.addr, send_wr.wr.rdma.remote_addr, sge.length); /* * ibv_post_send() does not return negative error numbers, * per the specification they are positive - no idea why. */ ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr); if (ret == ENOMEM) { DDPRINTF("send queue is full. wait a little....\n"); ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); if (ret < 0) { fprintf(stderr, "rdma migration: failed to make " "room in full send queue! %d\n", ret); return ret; } goto retry; } else if (ret > 0) { perror("rdma migration: post rdma write failed"); return -ret; } set_bit(chunk, block->transit_bitmap); acct_update_position(f, sge.length, false); rdma->total_writes++; return 0; }
true
qemu
60fe637bf0e4d7989e21e50f52526444765c63b4
static int qemu_rdma_write_one(QEMUFile *f, RDMAContext *rdma, int current_index, uint64_t current_addr, uint64_t length) { struct ibv_sge sge; struct ibv_send_wr send_wr = { 0 }; struct ibv_send_wr *bad_wr; int reg_result_idx, ret, count = 0; uint64_t chunk, chunks; uint8_t *chunk_start, *chunk_end; RDMALocalBlock *block = &(rdma->local_ram_blocks.block[current_index]); RDMARegister reg; RDMARegisterResult *reg_result; RDMAControlHeader resp = { .type = RDMA_CONTROL_REGISTER_RESULT }; RDMAControlHeader head = { .len = sizeof(RDMARegister), .type = RDMA_CONTROL_REGISTER_REQUEST, .repeat = 1, }; retry: sge.addr = (uint64_t)(block->local_host_addr + (current_addr - block->offset)); sge.length = length; chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) sge.addr); chunk_start = ram_chunk_start(block, chunk); if (block->is_ram_block) { chunks = length / (1UL << RDMA_REG_CHUNK_SHIFT); if (chunks && ((length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) { chunks--; } } else { chunks = block->length / (1UL << RDMA_REG_CHUNK_SHIFT); if (chunks && ((block->length % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) { chunks--; } } DDPRINTF("Writing %" PRIu64 " chunks, (%" PRIu64 " MB)\n", chunks + 1, (chunks + 1) * (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024); chunk_end = ram_chunk_end(block, chunk + chunks); if (!rdma->pin_all) { #ifdef RDMA_UNREGISTRATION_EXAMPLE qemu_rdma_unregister_waiting(rdma); #endif } while (test_bit(chunk, block->transit_bitmap)) { (void)count; DDPRINTF("(%d) Not clobbering: block: %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d %d\n", count++, current_index, chunk, sge.addr, length, rdma->nb_sent, block->nb_chunks); ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); if (ret < 0) { fprintf(stderr, "Failed to Wait for previous write to complete " "block %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d\n", current_index, chunk, sge.addr, length, rdma->nb_sent); return ret; } } if (!rdma->pin_all || !block->is_ram_block) { if (!block->remote_keys[chunk]) { if (can_use_buffer_find_nonzero_offset((void *)sge.addr, length) && buffer_find_nonzero_offset((void *)sge.addr, length) == length) { RDMACompress comp = { .offset = current_addr, .value = 0, .block_idx = current_index, .length = length, }; head.len = sizeof(comp); head.type = RDMA_CONTROL_COMPRESS; DDPRINTF("Entire chunk is zero, sending compress: %" PRIu64 " for %d " "bytes, index: %d, offset: %" PRId64 "...\n", chunk, sge.length, current_index, current_addr); compress_to_network(&comp); ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) &comp, NULL, NULL, NULL); if (ret < 0) { return -EIO; } acct_update_position(f, sge.length, true); return 1; } reg.current_index = current_index; if (block->is_ram_block) { reg.key.current_addr = current_addr; } else { reg.key.chunk = chunk; } reg.chunks = chunks; DDPRINTF("Sending registration request chunk %" PRIu64 " for %d " "bytes, index: %d, offset: %" PRId64 "...\n", chunk, sge.length, current_index, current_addr); register_to_network(&reg); ret = qemu_rdma_exchange_send(rdma, &head, (uint8_t *) &reg, &resp, &reg_result_idx, NULL); if (ret < 0) { return ret; } if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *) sge.addr, &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get lkey!\n"); return -EINVAL; } reg_result = (RDMARegisterResult *) rdma->wr_data[reg_result_idx].control_curr; network_to_result(reg_result); DDPRINTF("Received registration result:" " my key: %x their key %x, chunk %" PRIu64 "\n", block->remote_keys[chunk], reg_result->rkey, chunk); block->remote_keys[chunk] = reg_result->rkey; block->remote_host_addr = reg_result->host_addr; } else { if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)sge.addr, &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get lkey!\n"); return -EINVAL; } } send_wr.wr.rdma.rkey = block->remote_keys[chunk]; } else { send_wr.wr.rdma.rkey = block->remote_rkey; if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)sge.addr, &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get lkey!\n"); return -EINVAL; } } send_wr.wr_id = qemu_rdma_make_wrid(RDMA_WRID_RDMA_WRITE, current_index, chunk); send_wr.opcode = IBV_WR_RDMA_WRITE; send_wr.send_flags = IBV_SEND_SIGNALED; send_wr.sg_list = &sge; send_wr.num_sge = 1; send_wr.wr.rdma.remote_addr = block->remote_host_addr + (current_addr - block->offset); DDDPRINTF("Posting chunk: %" PRIu64 ", addr: %lx" " remote: %lx, bytes %" PRIu32 "\n", chunk, sge.addr, send_wr.wr.rdma.remote_addr, sge.length); ret = ibv_post_send(rdma->qp, &send_wr, &bad_wr); if (ret == ENOMEM) { DDPRINTF("send queue is full. wait a little....\n"); ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); if (ret < 0) { fprintf(stderr, "rdma migration: failed to make " "room in full send queue! %d\n", ret); return ret; } goto retry; } else if (ret > 0) { perror("rdma migration: post rdma write failed"); return -ret; } set_bit(chunk, block->transit_bitmap); acct_update_position(f, sge.length, false); rdma->total_writes++; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QEMUFile *VAR_0, RDMAContext *VAR_1, int VAR_2, uint64_t VAR_3, uint64_t VAR_4) { struct ibv_sge VAR_5; struct ibv_send_wr VAR_6 = { 0 }; struct ibv_send_wr *VAR_7; int VAR_8, VAR_9, VAR_10 = 0; uint64_t chunk, chunks; uint8_t *chunk_start, *chunk_end; RDMALocalBlock *block = &(VAR_1->local_ram_blocks.block[VAR_2]); RDMARegister reg; RDMARegisterResult *reg_result; RDMAControlHeader resp = { .type = RDMA_CONTROL_REGISTER_RESULT }; RDMAControlHeader head = { .len = sizeof(RDMARegister), .type = RDMA_CONTROL_REGISTER_REQUEST, .repeat = 1, }; retry: VAR_5.addr = (uint64_t)(block->local_host_addr + (VAR_3 - block->offset)); VAR_5.VAR_4 = VAR_4; chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) VAR_5.addr); chunk_start = ram_chunk_start(block, chunk); if (block->is_ram_block) { chunks = VAR_4 / (1UL << RDMA_REG_CHUNK_SHIFT); if (chunks && ((VAR_4 % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) { chunks--; } } else { chunks = block->VAR_4 / (1UL << RDMA_REG_CHUNK_SHIFT); if (chunks && ((block->VAR_4 % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) { chunks--; } } DDPRINTF("Writing %" PRIu64 " chunks, (%" PRIu64 " MB)\n", chunks + 1, (chunks + 1) * (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024); chunk_end = ram_chunk_end(block, chunk + chunks); if (!VAR_1->pin_all) { #ifdef RDMA_UNREGISTRATION_EXAMPLE qemu_rdma_unregister_waiting(VAR_1); #endif } while (test_bit(chunk, block->transit_bitmap)) { (void)VAR_10; DDPRINTF("(%d) Not clobbering: block: %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d %d\n", VAR_10++, VAR_2, chunk, VAR_5.addr, VAR_4, VAR_1->nb_sent, block->nb_chunks); VAR_9 = qemu_rdma_block_for_wrid(VAR_1, RDMA_WRID_RDMA_WRITE, NULL); if (VAR_9 < 0) { fprintf(stderr, "Failed to Wait for previous write to complete " "block %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d\n", VAR_2, chunk, VAR_5.addr, VAR_4, VAR_1->nb_sent); return VAR_9; } } if (!VAR_1->pin_all || !block->is_ram_block) { if (!block->remote_keys[chunk]) { if (can_use_buffer_find_nonzero_offset((void *)VAR_5.addr, VAR_4) && buffer_find_nonzero_offset((void *)VAR_5.addr, VAR_4) == VAR_4) { RDMACompress comp = { .offset = VAR_3, .value = 0, .block_idx = VAR_2, .VAR_4 = VAR_4, }; head.len = sizeof(comp); head.type = RDMA_CONTROL_COMPRESS; DDPRINTF("Entire chunk is zero, sending compress: %" PRIu64 " for %d " "bytes, index: %d, offset: %" PRId64 "...\n", chunk, VAR_5.VAR_4, VAR_2, VAR_3); compress_to_network(&comp); VAR_9 = qemu_rdma_exchange_send(VAR_1, &head, (uint8_t *) &comp, NULL, NULL, NULL); if (VAR_9 < 0) { return -EIO; } acct_update_position(VAR_0, VAR_5.VAR_4, true); return 1; } reg.VAR_2 = VAR_2; if (block->is_ram_block) { reg.key.VAR_3 = VAR_3; } else { reg.key.chunk = chunk; } reg.chunks = chunks; DDPRINTF("Sending registration request chunk %" PRIu64 " for %d " "bytes, index: %d, offset: %" PRId64 "...\n", chunk, VAR_5.VAR_4, VAR_2, VAR_3); register_to_network(&reg); VAR_9 = qemu_rdma_exchange_send(VAR_1, &head, (uint8_t *) &reg, &resp, &VAR_8, NULL); if (VAR_9 < 0) { return VAR_9; } if (qemu_rdma_register_and_get_keys(VAR_1, block, (uint8_t *) VAR_5.addr, &VAR_5.lkey, NULL, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get lkey!\n"); return -EINVAL; } reg_result = (RDMARegisterResult *) VAR_1->wr_data[VAR_8].control_curr; network_to_result(reg_result); DDPRINTF("Received registration result:" " my key: %x their key %x, chunk %" PRIu64 "\n", block->remote_keys[chunk], reg_result->rkey, chunk); block->remote_keys[chunk] = reg_result->rkey; block->remote_host_addr = reg_result->host_addr; } else { if (qemu_rdma_register_and_get_keys(VAR_1, block, (uint8_t *)VAR_5.addr, &VAR_5.lkey, NULL, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get lkey!\n"); return -EINVAL; } } VAR_6.wr.VAR_1.rkey = block->remote_keys[chunk]; } else { VAR_6.wr.VAR_1.rkey = block->remote_rkey; if (qemu_rdma_register_and_get_keys(VAR_1, block, (uint8_t *)VAR_5.addr, &VAR_5.lkey, NULL, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get lkey!\n"); return -EINVAL; } } VAR_6.wr_id = qemu_rdma_make_wrid(RDMA_WRID_RDMA_WRITE, VAR_2, chunk); VAR_6.opcode = IBV_WR_RDMA_WRITE; VAR_6.send_flags = IBV_SEND_SIGNALED; VAR_6.sg_list = &VAR_5; VAR_6.num_sge = 1; VAR_6.wr.VAR_1.remote_addr = block->remote_host_addr + (VAR_3 - block->offset); DDDPRINTF("Posting chunk: %" PRIu64 ", addr: %lx" " remote: %lx, bytes %" PRIu32 "\n", chunk, VAR_5.addr, VAR_6.wr.VAR_1.remote_addr, VAR_5.VAR_4); VAR_9 = ibv_post_send(VAR_1->qp, &VAR_6, &VAR_7); if (VAR_9 == ENOMEM) { DDPRINTF("send queue is full. wait a little....\n"); VAR_9 = qemu_rdma_block_for_wrid(VAR_1, RDMA_WRID_RDMA_WRITE, NULL); if (VAR_9 < 0) { fprintf(stderr, "VAR_1 migration: failed to make " "room in full send queue! %d\n", VAR_9); return VAR_9; } goto retry; } else if (VAR_9 > 0) { perror("VAR_1 migration: post VAR_1 write failed"); return -VAR_9; } set_bit(chunk, block->transit_bitmap); acct_update_position(VAR_0, VAR_5.VAR_4, false); VAR_1->total_writes++; return 0; }
[ "static int FUNC_0(QEMUFile *VAR_0, RDMAContext *VAR_1,\nint VAR_2, uint64_t VAR_3,\nuint64_t VAR_4)\n{", "struct ibv_sge VAR_5;", "struct ibv_send_wr VAR_6 = { 0 };", "struct ibv_send_wr *VAR_7;", "int VAR_8, VAR_9, VAR_10 = 0;", "uint64_t chunk, chunks;", "uint8_t *chunk_start, *chunk_end;", "RDMALocalBlock *block = &(VAR_1->local_ram_blocks.block[VAR_2]);", "RDMARegister reg;", "RDMARegisterResult *reg_result;", "RDMAControlHeader resp = { .type = RDMA_CONTROL_REGISTER_RESULT };", "RDMAControlHeader head = { .len = sizeof(RDMARegister),", ".type = RDMA_CONTROL_REGISTER_REQUEST,\n.repeat = 1,\n};", "retry:\nVAR_5.addr = (uint64_t)(block->local_host_addr +\n(VAR_3 - block->offset));", "VAR_5.VAR_4 = VAR_4;", "chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) VAR_5.addr);", "chunk_start = ram_chunk_start(block, chunk);", "if (block->is_ram_block) {", "chunks = VAR_4 / (1UL << RDMA_REG_CHUNK_SHIFT);", "if (chunks && ((VAR_4 % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {", "chunks--;", "}", "} else {", "chunks = block->VAR_4 / (1UL << RDMA_REG_CHUNK_SHIFT);", "if (chunks && ((block->VAR_4 % (1UL << RDMA_REG_CHUNK_SHIFT)) == 0)) {", "chunks--;", "}", "}", "DDPRINTF(\"Writing %\" PRIu64 \" chunks, (%\" PRIu64 \" MB)\\n\",\nchunks + 1, (chunks + 1) * (1UL << RDMA_REG_CHUNK_SHIFT) / 1024 / 1024);", "chunk_end = ram_chunk_end(block, chunk + chunks);", "if (!VAR_1->pin_all) {", "#ifdef RDMA_UNREGISTRATION_EXAMPLE\nqemu_rdma_unregister_waiting(VAR_1);", "#endif\n}", "while (test_bit(chunk, block->transit_bitmap)) {", "(void)VAR_10;", "DDPRINTF(\"(%d) Not clobbering: block: %d chunk %\" PRIu64\n\" current %\" PRIu64 \" len %\" PRIu64 \" %d %d\\n\",\nVAR_10++, VAR_2, chunk,\nVAR_5.addr, VAR_4, VAR_1->nb_sent, block->nb_chunks);", "VAR_9 = qemu_rdma_block_for_wrid(VAR_1, RDMA_WRID_RDMA_WRITE, NULL);", "if (VAR_9 < 0) {", "fprintf(stderr, \"Failed to Wait for previous write to complete \"\n\"block %d chunk %\" PRIu64\n\" current %\" PRIu64 \" len %\" PRIu64 \" %d\\n\",\nVAR_2, chunk, VAR_5.addr, VAR_4, VAR_1->nb_sent);", "return VAR_9;", "}", "}", "if (!VAR_1->pin_all || !block->is_ram_block) {", "if (!block->remote_keys[chunk]) {", "if (can_use_buffer_find_nonzero_offset((void *)VAR_5.addr, VAR_4)\n&& buffer_find_nonzero_offset((void *)VAR_5.addr,\nVAR_4) == VAR_4) {", "RDMACompress comp = {", ".offset = VAR_3,\n.value = 0,\n.block_idx = VAR_2,\n.VAR_4 = VAR_4,\n};", "head.len = sizeof(comp);", "head.type = RDMA_CONTROL_COMPRESS;", "DDPRINTF(\"Entire chunk is zero, sending compress: %\"\nPRIu64 \" for %d \"\n\"bytes, index: %d, offset: %\" PRId64 \"...\\n\",\nchunk, VAR_5.VAR_4, VAR_2, VAR_3);", "compress_to_network(&comp);", "VAR_9 = qemu_rdma_exchange_send(VAR_1, &head,\n(uint8_t *) &comp, NULL, NULL, NULL);", "if (VAR_9 < 0) {", "return -EIO;", "}", "acct_update_position(VAR_0, VAR_5.VAR_4, true);", "return 1;", "}", "reg.VAR_2 = VAR_2;", "if (block->is_ram_block) {", "reg.key.VAR_3 = VAR_3;", "} else {", "reg.key.chunk = chunk;", "}", "reg.chunks = chunks;", "DDPRINTF(\"Sending registration request chunk %\" PRIu64 \" for %d \"\n\"bytes, index: %d, offset: %\" PRId64 \"...\\n\",\nchunk, VAR_5.VAR_4, VAR_2, VAR_3);", "register_to_network(&reg);", "VAR_9 = qemu_rdma_exchange_send(VAR_1, &head, (uint8_t *) &reg,\n&resp, &VAR_8, NULL);", "if (VAR_9 < 0) {", "return VAR_9;", "}", "if (qemu_rdma_register_and_get_keys(VAR_1, block,\n(uint8_t *) VAR_5.addr,\n&VAR_5.lkey, NULL, chunk,\nchunk_start, chunk_end)) {", "fprintf(stderr, \"cannot get lkey!\\n\");", "return -EINVAL;", "}", "reg_result = (RDMARegisterResult *)\nVAR_1->wr_data[VAR_8].control_curr;", "network_to_result(reg_result);", "DDPRINTF(\"Received registration result:\"\n\" my key: %x their key %x, chunk %\" PRIu64 \"\\n\",\nblock->remote_keys[chunk], reg_result->rkey, chunk);", "block->remote_keys[chunk] = reg_result->rkey;", "block->remote_host_addr = reg_result->host_addr;", "} else {", "if (qemu_rdma_register_and_get_keys(VAR_1, block,\n(uint8_t *)VAR_5.addr,\n&VAR_5.lkey, NULL, chunk,\nchunk_start, chunk_end)) {", "fprintf(stderr, \"cannot get lkey!\\n\");", "return -EINVAL;", "}", "}", "VAR_6.wr.VAR_1.rkey = block->remote_keys[chunk];", "} else {", "VAR_6.wr.VAR_1.rkey = block->remote_rkey;", "if (qemu_rdma_register_and_get_keys(VAR_1, block, (uint8_t *)VAR_5.addr,\n&VAR_5.lkey, NULL, chunk,\nchunk_start, chunk_end)) {", "fprintf(stderr, \"cannot get lkey!\\n\");", "return -EINVAL;", "}", "}", "VAR_6.wr_id = qemu_rdma_make_wrid(RDMA_WRID_RDMA_WRITE,\nVAR_2, chunk);", "VAR_6.opcode = IBV_WR_RDMA_WRITE;", "VAR_6.send_flags = IBV_SEND_SIGNALED;", "VAR_6.sg_list = &VAR_5;", "VAR_6.num_sge = 1;", "VAR_6.wr.VAR_1.remote_addr = block->remote_host_addr +\n(VAR_3 - block->offset);", "DDDPRINTF(\"Posting chunk: %\" PRIu64 \", addr: %lx\"\n\" remote: %lx, bytes %\" PRIu32 \"\\n\",\nchunk, VAR_5.addr, VAR_6.wr.VAR_1.remote_addr,\nVAR_5.VAR_4);", "VAR_9 = ibv_post_send(VAR_1->qp, &VAR_6, &VAR_7);", "if (VAR_9 == ENOMEM) {", "DDPRINTF(\"send queue is full. wait a little....\\n\");", "VAR_9 = qemu_rdma_block_for_wrid(VAR_1, RDMA_WRID_RDMA_WRITE, NULL);", "if (VAR_9 < 0) {", "fprintf(stderr, \"VAR_1 migration: failed to make \"\n\"room in full send queue! %d\\n\", VAR_9);", "return VAR_9;", "}", "goto retry;", "} else if (VAR_9 > 0) {", "perror(\"VAR_1 migration: post VAR_1 write failed\");", "return -VAR_9;", "}", "set_bit(chunk, block->transit_bitmap);", "acct_update_position(VAR_0, VAR_5.VAR_4, false);", "VAR_1->total_writes++;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33, 35 ], [ 39, 41, 43 ], [ 45 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83, 85 ], [ 89 ], [ 93 ], [ 95, 97 ], [ 99, 101 ], [ 105 ], [ 107 ], [ 109, 111, 113, 115 ], [ 119 ], [ 123 ], [ 125, 127, 129, 131 ], [ 133 ], [ 135 ], [ 137 ], [ 141 ], [ 143 ], [ 157, 159, 161 ], [ 163 ], [ 165, 167, 169, 171, 173 ], [ 177 ], [ 179 ], [ 183, 185, 187, 189 ], [ 193 ], [ 195, 197 ], [ 201 ], [ 203 ], [ 205 ], [ 209 ], [ 213 ], [ 215 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 241, 243, 245 ], [ 249 ], [ 251, 253 ], [ 255 ], [ 257 ], [ 259 ], [ 265, 267, 269, 271 ], [ 273 ], [ 275 ], [ 277 ], [ 281, 283 ], [ 287 ], [ 291, 293, 295 ], [ 299 ], [ 301 ], [ 303 ], [ 307, 309, 311, 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 325 ], [ 327 ], [ 329 ], [ 333, 335, 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 361, 363 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375, 377 ], [ 381, 383, 385, 387 ], [ 399 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 411, 413 ], [ 415 ], [ 417 ], [ 421 ], [ 425 ], [ 427 ], [ 429 ], [ 431 ], [ 435 ], [ 437 ], [ 439 ], [ 443 ], [ 445 ] ]
429
static int init_directories(BDRVVVFATState* s, const char* dirname) { bootsector_t* bootsector; mapping_t* mapping; unsigned int i; unsigned int cluster; memset(&(s->first_sectors[0]),0,0x40*0x200); s->cluster_size=s->sectors_per_cluster*0x200; s->cluster_buffer=qemu_malloc(s->cluster_size); /* * The formula: sc = spf+1+spf*spc*(512*8/fat_type), * where sc is sector_count, * spf is sectors_per_fat, * spc is sectors_per_clusters, and * fat_type = 12, 16 or 32. */ i = 1+s->sectors_per_cluster*0x200*8/s->fat_type; s->sectors_per_fat=(s->sector_count+i)/i; /* round up */ array_init(&(s->mapping),sizeof(mapping_t)); array_init(&(s->directory),sizeof(direntry_t)); /* add volume label */ { direntry_t* entry=array_get_next(&(s->directory)); entry->attributes=0x28; /* archive | volume label */ snprintf((char*)entry->name,11,"QEMU VVFAT"); } /* Now build FAT, and write back information into directory */ init_fat(s); s->faked_sectors=s->first_sectors_number+s->sectors_per_fat*2; s->cluster_count=sector2cluster(s, s->sector_count); mapping = array_get_next(&(s->mapping)); mapping->begin = 0; mapping->dir_index = 0; mapping->info.dir.parent_mapping_index = -1; mapping->first_mapping_index = -1; mapping->path = strdup(dirname); i = strlen(mapping->path); if (i > 0 && mapping->path[i - 1] == '/') mapping->path[i - 1] = '\0'; mapping->mode = MODE_DIRECTORY; mapping->read_only = 0; s->path = mapping->path; for (i = 0, cluster = 0; i < s->mapping.next; i++) { /* MS-DOS expects the FAT to be 0 for the root directory * (except for the media byte). */ /* LATER TODO: still true for FAT32? */ int fix_fat = (i != 0); mapping = array_get(&(s->mapping), i); if (mapping->mode & MODE_DIRECTORY) { mapping->begin = cluster; if(read_directory(s, i)) { fprintf(stderr, "Could not read directory %s\n", mapping->path); return -1; } mapping = array_get(&(s->mapping), i); } else { assert(mapping->mode == MODE_UNDEFINED); mapping->mode=MODE_NORMAL; mapping->begin = cluster; if (mapping->end > 0) { direntry_t* direntry = array_get(&(s->directory), mapping->dir_index); mapping->end = cluster + 1 + (mapping->end-1)/s->cluster_size; set_begin_of_direntry(direntry, mapping->begin); } else { mapping->end = cluster + 1; fix_fat = 0; } } assert(mapping->begin < mapping->end); /* next free cluster */ cluster = mapping->end; if(cluster > s->cluster_count) { fprintf(stderr,"Directory does not fit in FAT%d (capacity %s)\n", s->fat_type, s->fat_type == 12 ? s->sector_count == 2880 ? "1.44 MB" : "2.88 MB" : "504MB"); return -EINVAL; } /* fix fat for entry */ if (fix_fat) { int j; for(j = mapping->begin; j < mapping->end - 1; j++) fat_set(s, j, j+1); fat_set(s, mapping->end - 1, s->max_fat_value); } } mapping = array_get(&(s->mapping), 0); s->sectors_of_root_directory = mapping->end * s->sectors_per_cluster; s->last_cluster_of_root_directory = mapping->end; /* the FAT signature */ fat_set(s,0,s->max_fat_value); fat_set(s,1,s->max_fat_value); s->current_mapping = NULL; bootsector=(bootsector_t*)(s->first_sectors+(s->first_sectors_number-1)*0x200); bootsector->jump[0]=0xeb; bootsector->jump[1]=0x3e; bootsector->jump[2]=0x90; memcpy(bootsector->name,"QEMU ",8); bootsector->sector_size=cpu_to_le16(0x200); bootsector->sectors_per_cluster=s->sectors_per_cluster; bootsector->reserved_sectors=cpu_to_le16(1); bootsector->number_of_fats=0x2; /* number of FATs */ bootsector->root_entries=cpu_to_le16(s->sectors_of_root_directory*0x10); bootsector->total_sectors16=s->sector_count>0xffff?0:cpu_to_le16(s->sector_count); bootsector->media_type=(s->fat_type!=12?0xf8:s->sector_count==5760?0xf9:0xf8); /* media descriptor */ s->fat.pointer[0] = bootsector->media_type; bootsector->sectors_per_fat=cpu_to_le16(s->sectors_per_fat); bootsector->sectors_per_track=cpu_to_le16(s->bs->secs); bootsector->number_of_heads=cpu_to_le16(s->bs->heads); bootsector->hidden_sectors=cpu_to_le32(s->first_sectors_number==1?0:0x3f); bootsector->total_sectors=cpu_to_le32(s->sector_count>0xffff?s->sector_count:0); /* LATER TODO: if FAT32, this is wrong */ bootsector->u.fat16.drive_number=s->fat_type==12?0:0x80; /* assume this is hda (TODO) */ bootsector->u.fat16.current_head=0; bootsector->u.fat16.signature=0x29; bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd); memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11); memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8); bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa; return 0; }
true
qemu
2dedf83ef0cc3463783d6b71bf1b25476f691f3a
static int init_directories(BDRVVVFATState* s, const char* dirname) { bootsector_t* bootsector; mapping_t* mapping; unsigned int i; unsigned int cluster; memset(&(s->first_sectors[0]),0,0x40*0x200); s->cluster_size=s->sectors_per_cluster*0x200; s->cluster_buffer=qemu_malloc(s->cluster_size); i = 1+s->sectors_per_cluster*0x200*8/s->fat_type; s->sectors_per_fat=(s->sector_count+i)/i; array_init(&(s->mapping),sizeof(mapping_t)); array_init(&(s->directory),sizeof(direntry_t)); { direntry_t* entry=array_get_next(&(s->directory)); entry->attributes=0x28; snprintf((char*)entry->name,11,"QEMU VVFAT"); } init_fat(s); s->faked_sectors=s->first_sectors_number+s->sectors_per_fat*2; s->cluster_count=sector2cluster(s, s->sector_count); mapping = array_get_next(&(s->mapping)); mapping->begin = 0; mapping->dir_index = 0; mapping->info.dir.parent_mapping_index = -1; mapping->first_mapping_index = -1; mapping->path = strdup(dirname); i = strlen(mapping->path); if (i > 0 && mapping->path[i - 1] == '/') mapping->path[i - 1] = '\0'; mapping->mode = MODE_DIRECTORY; mapping->read_only = 0; s->path = mapping->path; for (i = 0, cluster = 0; i < s->mapping.next; i++) { int fix_fat = (i != 0); mapping = array_get(&(s->mapping), i); if (mapping->mode & MODE_DIRECTORY) { mapping->begin = cluster; if(read_directory(s, i)) { fprintf(stderr, "Could not read directory %s\n", mapping->path); return -1; } mapping = array_get(&(s->mapping), i); } else { assert(mapping->mode == MODE_UNDEFINED); mapping->mode=MODE_NORMAL; mapping->begin = cluster; if (mapping->end > 0) { direntry_t* direntry = array_get(&(s->directory), mapping->dir_index); mapping->end = cluster + 1 + (mapping->end-1)/s->cluster_size; set_begin_of_direntry(direntry, mapping->begin); } else { mapping->end = cluster + 1; fix_fat = 0; } } assert(mapping->begin < mapping->end); cluster = mapping->end; if(cluster > s->cluster_count) { fprintf(stderr,"Directory does not fit in FAT%d (capacity %s)\n", s->fat_type, s->fat_type == 12 ? s->sector_count == 2880 ? "1.44 MB" : "2.88 MB" : "504MB"); return -EINVAL; } if (fix_fat) { int j; for(j = mapping->begin; j < mapping->end - 1; j++) fat_set(s, j, j+1); fat_set(s, mapping->end - 1, s->max_fat_value); } } mapping = array_get(&(s->mapping), 0); s->sectors_of_root_directory = mapping->end * s->sectors_per_cluster; s->last_cluster_of_root_directory = mapping->end; fat_set(s,0,s->max_fat_value); fat_set(s,1,s->max_fat_value); s->current_mapping = NULL; bootsector=(bootsector_t*)(s->first_sectors+(s->first_sectors_number-1)*0x200); bootsector->jump[0]=0xeb; bootsector->jump[1]=0x3e; bootsector->jump[2]=0x90; memcpy(bootsector->name,"QEMU ",8); bootsector->sector_size=cpu_to_le16(0x200); bootsector->sectors_per_cluster=s->sectors_per_cluster; bootsector->reserved_sectors=cpu_to_le16(1); bootsector->number_of_fats=0x2; bootsector->root_entries=cpu_to_le16(s->sectors_of_root_directory*0x10); bootsector->total_sectors16=s->sector_count>0xffff?0:cpu_to_le16(s->sector_count); bootsector->media_type=(s->fat_type!=12?0xf8:s->sector_count==5760?0xf9:0xf8); s->fat.pointer[0] = bootsector->media_type; bootsector->sectors_per_fat=cpu_to_le16(s->sectors_per_fat); bootsector->sectors_per_track=cpu_to_le16(s->bs->secs); bootsector->number_of_heads=cpu_to_le16(s->bs->heads); bootsector->hidden_sectors=cpu_to_le32(s->first_sectors_number==1?0:0x3f); bootsector->total_sectors=cpu_to_le32(s->sector_count>0xffff?s->sector_count:0); bootsector->u.fat16.drive_number=s->fat_type==12?0:0x80; bootsector->u.fat16.current_head=0; bootsector->u.fat16.signature=0x29; bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd); memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11); memcpy(bootsector->fat_type,(s->fat_type==12?"FAT12 ":s->fat_type==16?"FAT16 ":"FAT32 "),8); bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa; return 0; }
{ "code": [ "\tsnprintf((char*)entry->name,11,\"QEMU VVFAT\");" ], "line_no": [ 61 ] }
static int FUNC_0(BDRVVVFATState* VAR_0, const char* VAR_1) { bootsector_t* bootsector; mapping_t* mapping; unsigned int VAR_2; unsigned int VAR_3; memset(&(VAR_0->first_sectors[0]),0,0x40*0x200); VAR_0->cluster_size=VAR_0->sectors_per_cluster*0x200; VAR_0->cluster_buffer=qemu_malloc(VAR_0->cluster_size); VAR_2 = 1+VAR_0->sectors_per_cluster*0x200*8/VAR_0->fat_type; VAR_0->sectors_per_fat=(VAR_0->sector_count+VAR_2)/VAR_2; array_init(&(VAR_0->mapping),sizeof(mapping_t)); array_init(&(VAR_0->directory),sizeof(direntry_t)); { direntry_t* entry=array_get_next(&(VAR_0->directory)); entry->attributes=0x28; snprintf((char*)entry->name,11,"QEMU VVFAT"); } init_fat(VAR_0); VAR_0->faked_sectors=VAR_0->first_sectors_number+VAR_0->sectors_per_fat*2; VAR_0->cluster_count=sector2cluster(VAR_0, VAR_0->sector_count); mapping = array_get_next(&(VAR_0->mapping)); mapping->begin = 0; mapping->dir_index = 0; mapping->info.dir.parent_mapping_index = -1; mapping->first_mapping_index = -1; mapping->path = strdup(VAR_1); VAR_2 = strlen(mapping->path); if (VAR_2 > 0 && mapping->path[VAR_2 - 1] == '/') mapping->path[VAR_2 - 1] = '\0'; mapping->mode = MODE_DIRECTORY; mapping->read_only = 0; VAR_0->path = mapping->path; for (VAR_2 = 0, VAR_3 = 0; VAR_2 < VAR_0->mapping.next; VAR_2++) { int fix_fat = (VAR_2 != 0); mapping = array_get(&(VAR_0->mapping), VAR_2); if (mapping->mode & MODE_DIRECTORY) { mapping->begin = VAR_3; if(read_directory(VAR_0, VAR_2)) { fprintf(stderr, "Could not read directory %VAR_0\n", mapping->path); return -1; } mapping = array_get(&(VAR_0->mapping), VAR_2); } else { assert(mapping->mode == MODE_UNDEFINED); mapping->mode=MODE_NORMAL; mapping->begin = VAR_3; if (mapping->end > 0) { direntry_t* direntry = array_get(&(VAR_0->directory), mapping->dir_index); mapping->end = VAR_3 + 1 + (mapping->end-1)/VAR_0->cluster_size; set_begin_of_direntry(direntry, mapping->begin); } else { mapping->end = VAR_3 + 1; fix_fat = 0; } } assert(mapping->begin < mapping->end); VAR_3 = mapping->end; if(VAR_3 > VAR_0->cluster_count) { fprintf(stderr,"Directory does not fit in FAT%d (capacity %VAR_0)\n", VAR_0->fat_type, VAR_0->fat_type == 12 ? VAR_0->sector_count == 2880 ? "1.44 MB" : "2.88 MB" : "504MB"); return -EINVAL; } if (fix_fat) { int j; for(j = mapping->begin; j < mapping->end - 1; j++) fat_set(VAR_0, j, j+1); fat_set(VAR_0, mapping->end - 1, VAR_0->max_fat_value); } } mapping = array_get(&(VAR_0->mapping), 0); VAR_0->sectors_of_root_directory = mapping->end * VAR_0->sectors_per_cluster; VAR_0->last_cluster_of_root_directory = mapping->end; fat_set(VAR_0,0,VAR_0->max_fat_value); fat_set(VAR_0,1,VAR_0->max_fat_value); VAR_0->current_mapping = NULL; bootsector=(bootsector_t*)(VAR_0->first_sectors+(VAR_0->first_sectors_number-1)*0x200); bootsector->jump[0]=0xeb; bootsector->jump[1]=0x3e; bootsector->jump[2]=0x90; memcpy(bootsector->name,"QEMU ",8); bootsector->sector_size=cpu_to_le16(0x200); bootsector->sectors_per_cluster=VAR_0->sectors_per_cluster; bootsector->reserved_sectors=cpu_to_le16(1); bootsector->number_of_fats=0x2; bootsector->root_entries=cpu_to_le16(VAR_0->sectors_of_root_directory*0x10); bootsector->total_sectors16=VAR_0->sector_count>0xffff?0:cpu_to_le16(VAR_0->sector_count); bootsector->media_type=(VAR_0->fat_type!=12?0xf8:VAR_0->sector_count==5760?0xf9:0xf8); VAR_0->fat.pointer[0] = bootsector->media_type; bootsector->sectors_per_fat=cpu_to_le16(VAR_0->sectors_per_fat); bootsector->sectors_per_track=cpu_to_le16(VAR_0->bs->secs); bootsector->number_of_heads=cpu_to_le16(VAR_0->bs->heads); bootsector->hidden_sectors=cpu_to_le32(VAR_0->first_sectors_number==1?0:0x3f); bootsector->total_sectors=cpu_to_le32(VAR_0->sector_count>0xffff?VAR_0->sector_count:0); bootsector->u.fat16.drive_number=VAR_0->fat_type==12?0:0x80; bootsector->u.fat16.current_head=0; bootsector->u.fat16.signature=0x29; bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd); memcpy(bootsector->u.fat16.volume_label,"QEMU VVFAT ",11); memcpy(bootsector->fat_type,(VAR_0->fat_type==12?"FAT12 ":VAR_0->fat_type==16?"FAT16 ":"FAT32 "),8); bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa; return 0; }
[ "static int FUNC_0(BDRVVVFATState* VAR_0,\nconst char* VAR_1)\n{", "bootsector_t* bootsector;", "mapping_t* mapping;", "unsigned int VAR_2;", "unsigned int VAR_3;", "memset(&(VAR_0->first_sectors[0]),0,0x40*0x200);", "VAR_0->cluster_size=VAR_0->sectors_per_cluster*0x200;", "VAR_0->cluster_buffer=qemu_malloc(VAR_0->cluster_size);", "VAR_2 = 1+VAR_0->sectors_per_cluster*0x200*8/VAR_0->fat_type;", "VAR_0->sectors_per_fat=(VAR_0->sector_count+VAR_2)/VAR_2;", "array_init(&(VAR_0->mapping),sizeof(mapping_t));", "array_init(&(VAR_0->directory),sizeof(direntry_t));", "{", "direntry_t* entry=array_get_next(&(VAR_0->directory));", "entry->attributes=0x28;", "snprintf((char*)entry->name,11,\"QEMU VVFAT\");", "}", "init_fat(VAR_0);", "VAR_0->faked_sectors=VAR_0->first_sectors_number+VAR_0->sectors_per_fat*2;", "VAR_0->cluster_count=sector2cluster(VAR_0, VAR_0->sector_count);", "mapping = array_get_next(&(VAR_0->mapping));", "mapping->begin = 0;", "mapping->dir_index = 0;", "mapping->info.dir.parent_mapping_index = -1;", "mapping->first_mapping_index = -1;", "mapping->path = strdup(VAR_1);", "VAR_2 = strlen(mapping->path);", "if (VAR_2 > 0 && mapping->path[VAR_2 - 1] == '/')\nmapping->path[VAR_2 - 1] = '\\0';", "mapping->mode = MODE_DIRECTORY;", "mapping->read_only = 0;", "VAR_0->path = mapping->path;", "for (VAR_2 = 0, VAR_3 = 0; VAR_2 < VAR_0->mapping.next; VAR_2++) {", "int fix_fat = (VAR_2 != 0);", "mapping = array_get(&(VAR_0->mapping), VAR_2);", "if (mapping->mode & MODE_DIRECTORY) {", "mapping->begin = VAR_3;", "if(read_directory(VAR_0, VAR_2)) {", "fprintf(stderr, \"Could not read directory %VAR_0\\n\",\nmapping->path);", "return -1;", "}", "mapping = array_get(&(VAR_0->mapping), VAR_2);", "} else {", "assert(mapping->mode == MODE_UNDEFINED);", "mapping->mode=MODE_NORMAL;", "mapping->begin = VAR_3;", "if (mapping->end > 0) {", "direntry_t* direntry = array_get(&(VAR_0->directory),\nmapping->dir_index);", "mapping->end = VAR_3 + 1 + (mapping->end-1)/VAR_0->cluster_size;", "set_begin_of_direntry(direntry, mapping->begin);", "} else {", "mapping->end = VAR_3 + 1;", "fix_fat = 0;", "}", "}", "assert(mapping->begin < mapping->end);", "VAR_3 = mapping->end;", "if(VAR_3 > VAR_0->cluster_count) {", "fprintf(stderr,\"Directory does not fit in FAT%d (capacity %VAR_0)\\n\",\nVAR_0->fat_type,\nVAR_0->fat_type == 12 ? VAR_0->sector_count == 2880 ? \"1.44 MB\"\n: \"2.88 MB\"\n: \"504MB\");", "return -EINVAL;", "}", "if (fix_fat) {", "int j;", "for(j = mapping->begin; j < mapping->end - 1; j++)", "fat_set(VAR_0, j, j+1);", "fat_set(VAR_0, mapping->end - 1, VAR_0->max_fat_value);", "}", "}", "mapping = array_get(&(VAR_0->mapping), 0);", "VAR_0->sectors_of_root_directory = mapping->end * VAR_0->sectors_per_cluster;", "VAR_0->last_cluster_of_root_directory = mapping->end;", "fat_set(VAR_0,0,VAR_0->max_fat_value);", "fat_set(VAR_0,1,VAR_0->max_fat_value);", "VAR_0->current_mapping = NULL;", "bootsector=(bootsector_t*)(VAR_0->first_sectors+(VAR_0->first_sectors_number-1)*0x200);", "bootsector->jump[0]=0xeb;", "bootsector->jump[1]=0x3e;", "bootsector->jump[2]=0x90;", "memcpy(bootsector->name,\"QEMU \",8);", "bootsector->sector_size=cpu_to_le16(0x200);", "bootsector->sectors_per_cluster=VAR_0->sectors_per_cluster;", "bootsector->reserved_sectors=cpu_to_le16(1);", "bootsector->number_of_fats=0x2;", "bootsector->root_entries=cpu_to_le16(VAR_0->sectors_of_root_directory*0x10);", "bootsector->total_sectors16=VAR_0->sector_count>0xffff?0:cpu_to_le16(VAR_0->sector_count);", "bootsector->media_type=(VAR_0->fat_type!=12?0xf8:VAR_0->sector_count==5760?0xf9:0xf8);", "VAR_0->fat.pointer[0] = bootsector->media_type;", "bootsector->sectors_per_fat=cpu_to_le16(VAR_0->sectors_per_fat);", "bootsector->sectors_per_track=cpu_to_le16(VAR_0->bs->secs);", "bootsector->number_of_heads=cpu_to_le16(VAR_0->bs->heads);", "bootsector->hidden_sectors=cpu_to_le32(VAR_0->first_sectors_number==1?0:0x3f);", "bootsector->total_sectors=cpu_to_le32(VAR_0->sector_count>0xffff?VAR_0->sector_count:0);", "bootsector->u.fat16.drive_number=VAR_0->fat_type==12?0:0x80;", "bootsector->u.fat16.current_head=0;", "bootsector->u.fat16.signature=0x29;", "bootsector->u.fat16.id=cpu_to_le32(0xfabe1afd);", "memcpy(bootsector->u.fat16.volume_label,\"QEMU VVFAT \",11);", "memcpy(bootsector->fat_type,(VAR_0->fat_type==12?\"FAT12 \":VAR_0->fat_type==16?\"FAT16 \":\"FAT32 \"),8);", "bootsector->magic[0]=0x55; bootsector->magic[1]=0xaa;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 69 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145, 147 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 173 ], [ 177 ], [ 179, 181, 183, 185, 187 ], [ 189 ], [ 191 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 213 ], [ 215 ], [ 217 ], [ 223 ], [ 225 ], [ 229 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 283 ], [ 285 ], [ 287 ], [ 291 ], [ 293 ] ]
430
static int mpegts_read_header(AVFormatContext *s) { MpegTSContext *ts = s->priv_data; AVIOContext *pb = s->pb; uint8_t buf[8 * 1024] = {0}; int len; int64_t pos, probesize = s->probesize; if (ffio_ensure_seekback(pb, probesize) < 0) av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); /* read the first 8192 bytes to get packet size */ pos = avio_tell(pb); len = avio_read(pb, buf, sizeof(buf)); ts->raw_packet_size = get_packet_size(buf, len); if (ts->raw_packet_size <= 0) { av_log(s, AV_LOG_WARNING, "Could not detect TS packet size, defaulting to non-FEC/DVHS\n"); ts->raw_packet_size = TS_PACKET_SIZE; } ts->stream = s; ts->auto_guess = 0; if (s->iformat == &ff_mpegts_demuxer) { /* normal demux */ /* first do a scan to get all the services */ seek_back(s, pb, pos); mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1); handle_packets(ts, probesize / ts->raw_packet_size); /* if could not find service, enable auto_guess */ ts->auto_guess = 1; av_log(ts->stream, AV_LOG_TRACE, "tuning done\n"); s->ctx_flags |= AVFMTCTX_NOHEADER; } else { AVStream *st; int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l; int64_t pcrs[2], pcr_h; int packet_count[2]; uint8_t packet[TS_PACKET_SIZE]; const uint8_t *data; /* only read packets */ st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 60, 1, 27000000); st->codecpar->codec_type = AVMEDIA_TYPE_DATA; st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS; /* we iterate until we find two PCRs to estimate the bitrate */ pcr_pid = -1; nb_pcrs = 0; nb_packets = 0; for (;;) { ret = read_packet(s, packet, ts->raw_packet_size, &data); if (ret < 0) return ret; pid = AV_RB16(data + 1) & 0x1fff; if ((pcr_pid == -1 || pcr_pid == pid) && parse_pcr(&pcr_h, &pcr_l, data) == 0) { finished_reading_packet(s, ts->raw_packet_size); pcr_pid = pid; packet_count[nb_pcrs] = nb_packets; pcrs[nb_pcrs] = pcr_h * 300 + pcr_l; nb_pcrs++; if (nb_pcrs >= 2) break; } else { finished_reading_packet(s, ts->raw_packet_size); } nb_packets++; } /* NOTE1: the bitrate is computed without the FEC */ /* NOTE2: it is only the bitrate of the start of the stream */ ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]); ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; s->bit_rate = TS_PACKET_SIZE * 8 * 27000000LL / ts->pcr_incr; st->codecpar->bit_rate = s->bit_rate; st->start_time = ts->cur_pcr; av_log(ts->stream, AV_LOG_TRACE, "start=%0.3f pcr=%0.3f incr=%d\n", st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr); } seek_back(s, pb, pos); return 0; }
true
FFmpeg
1bbb18fe82fc77a10d45fa53bd2738d2c54de6c6
static int mpegts_read_header(AVFormatContext *s) { MpegTSContext *ts = s->priv_data; AVIOContext *pb = s->pb; uint8_t buf[8 * 1024] = {0}; int len; int64_t pos, probesize = s->probesize; if (ffio_ensure_seekback(pb, probesize) < 0) av_log(s, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); pos = avio_tell(pb); len = avio_read(pb, buf, sizeof(buf)); ts->raw_packet_size = get_packet_size(buf, len); if (ts->raw_packet_size <= 0) { av_log(s, AV_LOG_WARNING, "Could not detect TS packet size, defaulting to non-FEC/DVHS\n"); ts->raw_packet_size = TS_PACKET_SIZE; } ts->stream = s; ts->auto_guess = 0; if (s->iformat == &ff_mpegts_demuxer) { seek_back(s, pb, pos); mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1); handle_packets(ts, probesize / ts->raw_packet_size); ts->auto_guess = 1; av_log(ts->stream, AV_LOG_TRACE, "tuning done\n"); s->ctx_flags |= AVFMTCTX_NOHEADER; } else { AVStream *st; int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l; int64_t pcrs[2], pcr_h; int packet_count[2]; uint8_t packet[TS_PACKET_SIZE]; const uint8_t *data; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 60, 1, 27000000); st->codecpar->codec_type = AVMEDIA_TYPE_DATA; st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS; pcr_pid = -1; nb_pcrs = 0; nb_packets = 0; for (;;) { ret = read_packet(s, packet, ts->raw_packet_size, &data); if (ret < 0) return ret; pid = AV_RB16(data + 1) & 0x1fff; if ((pcr_pid == -1 || pcr_pid == pid) && parse_pcr(&pcr_h, &pcr_l, data) == 0) { finished_reading_packet(s, ts->raw_packet_size); pcr_pid = pid; packet_count[nb_pcrs] = nb_packets; pcrs[nb_pcrs] = pcr_h * 300 + pcr_l; nb_pcrs++; if (nb_pcrs >= 2) break; } else { finished_reading_packet(s, ts->raw_packet_size); } nb_packets++; } ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]); ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; s->bit_rate = TS_PACKET_SIZE * 8 * 27000000LL / ts->pcr_incr; st->codecpar->bit_rate = s->bit_rate; st->start_time = ts->cur_pcr; av_log(ts->stream, AV_LOG_TRACE, "start=%0.3f pcr=%0.3f incr=%d\n", st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr); } seek_back(s, pb, pos); return 0; }
{ "code": [ " if (nb_pcrs >= 2)", " break;" ], "line_no": [ 147, 149 ] }
static int FUNC_0(AVFormatContext *VAR_0) { MpegTSContext *ts = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; uint8_t buf[8 * 1024] = {0}; int VAR_1; int64_t pos, probesize = VAR_0->probesize; if (ffio_ensure_seekback(pb, probesize) < 0) av_log(VAR_0, AV_LOG_WARNING, "Failed to allocate buffers for seekback\n"); pos = avio_tell(pb); VAR_1 = avio_read(pb, buf, sizeof(buf)); ts->raw_packet_size = get_packet_size(buf, VAR_1); if (ts->raw_packet_size <= 0) { av_log(VAR_0, AV_LOG_WARNING, "Could not detect TS packet size, defaulting to non-FEC/DVHS\n"); ts->raw_packet_size = TS_PACKET_SIZE; } ts->stream = VAR_0; ts->auto_guess = 0; if (VAR_0->iformat == &ff_mpegts_demuxer) { seek_back(VAR_0, pb, pos); mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1); handle_packets(ts, probesize / ts->raw_packet_size); ts->auto_guess = 1; av_log(ts->stream, AV_LOG_TRACE, "tuning done\n"); VAR_0->ctx_flags |= AVFMTCTX_NOHEADER; } else { AVStream *st; int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; int64_t pcrs[2], pcr_h; int VAR_8[2]; uint8_t packet[TS_PACKET_SIZE]; const uint8_t *VAR_9; st = avformat_new_stream(VAR_0, NULL); if (!st) return AVERROR(ENOMEM); avpriv_set_pts_info(st, 60, 1, 27000000); st->codecpar->codec_type = AVMEDIA_TYPE_DATA; st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS; VAR_2 = -1; VAR_5 = 0; VAR_4 = 0; for (;;) { VAR_6 = read_packet(VAR_0, packet, ts->raw_packet_size, &VAR_9); if (VAR_6 < 0) return VAR_6; VAR_3 = AV_RB16(VAR_9 + 1) & 0x1fff; if ((VAR_2 == -1 || VAR_2 == VAR_3) && parse_pcr(&pcr_h, &VAR_7, VAR_9) == 0) { finished_reading_packet(VAR_0, ts->raw_packet_size); VAR_2 = VAR_3; VAR_8[VAR_5] = VAR_4; pcrs[VAR_5] = pcr_h * 300 + VAR_7; VAR_5++; if (VAR_5 >= 2) break; } else { finished_reading_packet(VAR_0, ts->raw_packet_size); } VAR_4++; } ts->pcr_incr = (pcrs[1] - pcrs[0]) / (VAR_8[1] - VAR_8[0]); ts->cur_pcr = pcrs[0] - ts->pcr_incr * VAR_8[0]; VAR_0->bit_rate = TS_PACKET_SIZE * 8 * 27000000LL / ts->pcr_incr; st->codecpar->bit_rate = VAR_0->bit_rate; st->start_time = ts->cur_pcr; av_log(ts->stream, AV_LOG_TRACE, "start=%0.3f pcr=%0.3f incr=%d\n", st->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr); } seek_back(VAR_0, pb, pos); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "MpegTSContext *ts = VAR_0->priv_data;", "AVIOContext *pb = VAR_0->pb;", "uint8_t buf[8 * 1024] = {0};", "int VAR_1;", "int64_t pos, probesize = VAR_0->probesize;", "if (ffio_ensure_seekback(pb, probesize) < 0)\nav_log(VAR_0, AV_LOG_WARNING, \"Failed to allocate buffers for seekback\\n\");", "pos = avio_tell(pb);", "VAR_1 = avio_read(pb, buf, sizeof(buf));", "ts->raw_packet_size = get_packet_size(buf, VAR_1);", "if (ts->raw_packet_size <= 0) {", "av_log(VAR_0, AV_LOG_WARNING, \"Could not detect TS packet size, defaulting to non-FEC/DVHS\\n\");", "ts->raw_packet_size = TS_PACKET_SIZE;", "}", "ts->stream = VAR_0;", "ts->auto_guess = 0;", "if (VAR_0->iformat == &ff_mpegts_demuxer) {", "seek_back(VAR_0, pb, pos);", "mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1);", "mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);", "handle_packets(ts, probesize / ts->raw_packet_size);", "ts->auto_guess = 1;", "av_log(ts->stream, AV_LOG_TRACE, \"tuning done\\n\");", "VAR_0->ctx_flags |= AVFMTCTX_NOHEADER;", "} else {", "AVStream *st;", "int VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;", "int64_t pcrs[2], pcr_h;", "int VAR_8[2];", "uint8_t packet[TS_PACKET_SIZE];", "const uint8_t *VAR_9;", "st = avformat_new_stream(VAR_0, NULL);", "if (!st)\nreturn AVERROR(ENOMEM);", "avpriv_set_pts_info(st, 60, 1, 27000000);", "st->codecpar->codec_type = AVMEDIA_TYPE_DATA;", "st->codecpar->codec_id = AV_CODEC_ID_MPEG2TS;", "VAR_2 = -1;", "VAR_5 = 0;", "VAR_4 = 0;", "for (;;) {", "VAR_6 = read_packet(VAR_0, packet, ts->raw_packet_size, &VAR_9);", "if (VAR_6 < 0)\nreturn VAR_6;", "VAR_3 = AV_RB16(VAR_9 + 1) & 0x1fff;", "if ((VAR_2 == -1 || VAR_2 == VAR_3) &&\nparse_pcr(&pcr_h, &VAR_7, VAR_9) == 0) {", "finished_reading_packet(VAR_0, ts->raw_packet_size);", "VAR_2 = VAR_3;", "VAR_8[VAR_5] = VAR_4;", "pcrs[VAR_5] = pcr_h * 300 + VAR_7;", "VAR_5++;", "if (VAR_5 >= 2)\nbreak;", "} else {", "finished_reading_packet(VAR_0, ts->raw_packet_size);", "}", "VAR_4++;", "}", "ts->pcr_incr = (pcrs[1] - pcrs[0]) / (VAR_8[1] - VAR_8[0]);", "ts->cur_pcr = pcrs[0] - ts->pcr_incr * VAR_8[0];", "VAR_0->bit_rate = TS_PACKET_SIZE * 8 * 27000000LL / ts->pcr_incr;", "st->codecpar->bit_rate = VAR_0->bit_rate;", "st->start_time = ts->cur_pcr;", "av_log(ts->stream, AV_LOG_TRACE, \"start=%0.3f pcr=%0.3f incr=%d\\n\",\nst->start_time / 1000000.0, pcrs[0] / 27e6, ts->pcr_incr);", "}", "seek_back(VAR_0, pb, pos);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 53 ], [ 57 ], [ 61 ], [ 65 ], [ 71 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109 ], [ 111 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127, 129 ], [ 131 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 185 ], [ 187 ], [ 189 ] ]
431
static QPCIDevice *get_ahci_device(uint32_t *fingerprint) { QPCIDevice *ahci; uint32_t ahci_fingerprint; QPCIBus *pcibus; pcibus = qpci_init_pc(); /* Find the AHCI PCI device and verify it's the right one. */ ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02)); g_assert(ahci != NULL); ahci_fingerprint = qpci_config_readl(ahci, PCI_VENDOR_ID); switch (ahci_fingerprint) { case AHCI_INTEL_ICH9: break; default: /* Unknown device. */ g_assert_not_reached(); } if (fingerprint) { *fingerprint = ahci_fingerprint; } return ahci; }
true
qemu
9a75b0a037e3a8030992244353f17b62f6daf2ab
static QPCIDevice *get_ahci_device(uint32_t *fingerprint) { QPCIDevice *ahci; uint32_t ahci_fingerprint; QPCIBus *pcibus; pcibus = qpci_init_pc(); ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02)); g_assert(ahci != NULL); ahci_fingerprint = qpci_config_readl(ahci, PCI_VENDOR_ID); switch (ahci_fingerprint) { case AHCI_INTEL_ICH9: break; default: g_assert_not_reached(); } if (fingerprint) { *fingerprint = ahci_fingerprint; } return ahci; }
{ "code": [ "static QPCIDevice *get_ahci_device(uint32_t *fingerprint)", " QPCIDevice *ahci;", " uint32_t ahci_fingerprint;", " QPCIBus *pcibus;", " pcibus = qpci_init_pc();", " ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02));", " g_assert(ahci != NULL);", " ahci_fingerprint = qpci_config_readl(ahci, PCI_VENDOR_ID);", " switch (ahci_fingerprint) {", " case AHCI_INTEL_ICH9:", " break;", " default:", " g_assert_not_reached();", " if (fingerprint) {", " *fingerprint = ahci_fingerprint;", " return ahci;", " case AHCI_INTEL_ICH9:", " break;", " g_assert(ahci != NULL);" ], "line_no": [ 1, 5, 7, 9, 13, 19, 21, 25, 29, 31, 33, 35, 39, 45, 47, 51, 31, 33, 21 ] }
static QPCIDevice *FUNC_0(uint32_t *fingerprint) { QPCIDevice *ahci; uint32_t ahci_fingerprint; QPCIBus *pcibus; pcibus = qpci_init_pc(); ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02)); g_assert(ahci != NULL); ahci_fingerprint = qpci_config_readl(ahci, PCI_VENDOR_ID); switch (ahci_fingerprint) { case AHCI_INTEL_ICH9: break; default: g_assert_not_reached(); } if (fingerprint) { *fingerprint = ahci_fingerprint; } return ahci; }
[ "static QPCIDevice *FUNC_0(uint32_t *fingerprint)\n{", "QPCIDevice *ahci;", "uint32_t ahci_fingerprint;", "QPCIBus *pcibus;", "pcibus = qpci_init_pc();", "ahci = qpci_device_find(pcibus, QPCI_DEVFN(0x1F, 0x02));", "g_assert(ahci != NULL);", "ahci_fingerprint = qpci_config_readl(ahci, PCI_VENDOR_ID);", "switch (ahci_fingerprint) {", "case AHCI_INTEL_ICH9:\nbreak;", "default:\ng_assert_not_reached();", "}", "if (fingerprint) {", "*fingerprint = ahci_fingerprint;", "}", "return ahci;", "}" ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 19 ], [ 21 ], [ 25 ], [ 29 ], [ 31, 33 ], [ 35, 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ] ]
432
static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len) { int i; uint16_t limit; switch (data[0]) { case 0: if (len == 1) return 20; set_pixel_format(vs, read_u8(data, 4), read_u8(data, 5), read_u8(data, 6), read_u8(data, 7), read_u16(data, 8), read_u16(data, 10), read_u16(data, 12), read_u8(data, 14), read_u8(data, 15), read_u8(data, 16)); break; case 2: if (len == 1) return 4; if (len == 4) return 4 + (read_u16(data, 2) * 4); limit = read_u16(data, 2); for (i = 0; i < limit; i++) { int32_t val = read_s32(data, 4 + (i * 4)); memcpy(data + 4 + (i * 4), &val, sizeof(val)); } set_encodings(vs, (int32_t *)(data + 4), limit); break; case 3: if (len == 1) return 10; framebuffer_update_request(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4), read_u16(data, 6), read_u16(data, 8)); break; case 4: if (len == 1) return 8; key_event(vs, read_u8(data, 1), read_u32(data, 4)); break; case 5: if (len == 1) return 6; pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4)); break; case 6: if (len == 1) return 8; if (len == 8) { uint32_t dlen = read_u32(data, 4); if (dlen > 0) return 8 + dlen; } client_cut_text(vs, read_u32(data, 4), data + 8); break; case 255: if (len == 1) return 2; switch (read_u8(data, 1)) { case 0: if (len == 2) return 12; ext_key_event(vs, read_u16(data, 2), read_u32(data, 4), read_u32(data, 8)); break; case 1: if (len == 2) return 4; switch (read_u16 (data, 2)) { case 0: audio_add(vs); break; case 1: audio_del(vs); break; case 2: if (len == 4) return 10; switch (read_u8(data, 4)) { case 0: vs->as.fmt = AUD_FMT_U8; break; case 1: vs->as.fmt = AUD_FMT_S8; break; case 2: vs->as.fmt = AUD_FMT_U16; break; case 3: vs->as.fmt = AUD_FMT_S16; break; case 4: vs->as.fmt = AUD_FMT_U32; break; case 5: vs->as.fmt = AUD_FMT_S32; break; default: printf("Invalid audio format %d\n", read_u8(data, 4)); vnc_client_error(vs); break; } vs->as.nchannels = read_u8(data, 5); if (vs->as.nchannels != 1 && vs->as.nchannels != 2) { printf("Invalid audio channel coount %d\n", read_u8(data, 5)); vnc_client_error(vs); break; } vs->as.freq = read_u32(data, 6); break; default: printf ("Invalid audio message %d\n", read_u8(data, 4)); vnc_client_error(vs); break; } break; default: printf("Msg: %d\n", read_u16(data, 0)); vnc_client_error(vs); break; } break; default: printf("Msg: %d\n", data[0]); vnc_client_error(vs); break; } vnc_read_when(vs, protocol_client_msg, 1); return 0; }
true
qemu
69dd5c9ffd5c0c6a01ad14b9c6a8d7135ccc2b9a
static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len) { int i; uint16_t limit; switch (data[0]) { case 0: if (len == 1) return 20; set_pixel_format(vs, read_u8(data, 4), read_u8(data, 5), read_u8(data, 6), read_u8(data, 7), read_u16(data, 8), read_u16(data, 10), read_u16(data, 12), read_u8(data, 14), read_u8(data, 15), read_u8(data, 16)); break; case 2: if (len == 1) return 4; if (len == 4) return 4 + (read_u16(data, 2) * 4); limit = read_u16(data, 2); for (i = 0; i < limit; i++) { int32_t val = read_s32(data, 4 + (i * 4)); memcpy(data + 4 + (i * 4), &val, sizeof(val)); } set_encodings(vs, (int32_t *)(data + 4), limit); break; case 3: if (len == 1) return 10; framebuffer_update_request(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4), read_u16(data, 6), read_u16(data, 8)); break; case 4: if (len == 1) return 8; key_event(vs, read_u8(data, 1), read_u32(data, 4)); break; case 5: if (len == 1) return 6; pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4)); break; case 6: if (len == 1) return 8; if (len == 8) { uint32_t dlen = read_u32(data, 4); if (dlen > 0) return 8 + dlen; } client_cut_text(vs, read_u32(data, 4), data + 8); break; case 255: if (len == 1) return 2; switch (read_u8(data, 1)) { case 0: if (len == 2) return 12; ext_key_event(vs, read_u16(data, 2), read_u32(data, 4), read_u32(data, 8)); break; case 1: if (len == 2) return 4; switch (read_u16 (data, 2)) { case 0: audio_add(vs); break; case 1: audio_del(vs); break; case 2: if (len == 4) return 10; switch (read_u8(data, 4)) { case 0: vs->as.fmt = AUD_FMT_U8; break; case 1: vs->as.fmt = AUD_FMT_S8; break; case 2: vs->as.fmt = AUD_FMT_U16; break; case 3: vs->as.fmt = AUD_FMT_S16; break; case 4: vs->as.fmt = AUD_FMT_U32; break; case 5: vs->as.fmt = AUD_FMT_S32; break; default: printf("Invalid audio format %d\n", read_u8(data, 4)); vnc_client_error(vs); break; } vs->as.nchannels = read_u8(data, 5); if (vs->as.nchannels != 1 && vs->as.nchannels != 2) { printf("Invalid audio channel coount %d\n", read_u8(data, 5)); vnc_client_error(vs); break; } vs->as.freq = read_u32(data, 6); break; default: printf ("Invalid audio message %d\n", read_u8(data, 4)); vnc_client_error(vs); break; } break; default: printf("Msg: %d\n", read_u16(data, 0)); vnc_client_error(vs); break; } break; default: printf("Msg: %d\n", data[0]); vnc_client_error(vs); break; } vnc_read_when(vs, protocol_client_msg, 1); return 0; }
{ "code": [ "\tif (len == 4)", "\t return 4 + (read_u16(data, 2) * 4);", "\tlimit = read_u16(data, 2);" ], "line_no": [ 41, 43, 47 ] }
static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2) { int VAR_3; uint16_t limit; switch (VAR_1[0]) { case 0: if (VAR_2 == 1) return 20; set_pixel_format(VAR_0, read_u8(VAR_1, 4), read_u8(VAR_1, 5), read_u8(VAR_1, 6), read_u8(VAR_1, 7), read_u16(VAR_1, 8), read_u16(VAR_1, 10), read_u16(VAR_1, 12), read_u8(VAR_1, 14), read_u8(VAR_1, 15), read_u8(VAR_1, 16)); break; case 2: if (VAR_2 == 1) return 4; if (VAR_2 == 4) return 4 + (read_u16(VAR_1, 2) * 4); limit = read_u16(VAR_1, 2); for (VAR_3 = 0; VAR_3 < limit; VAR_3++) { int32_t val = read_s32(VAR_1, 4 + (VAR_3 * 4)); memcpy(VAR_1 + 4 + (VAR_3 * 4), &val, sizeof(val)); } set_encodings(VAR_0, (int32_t *)(VAR_1 + 4), limit); break; case 3: if (VAR_2 == 1) return 10; framebuffer_update_request(VAR_0, read_u8(VAR_1, 1), read_u16(VAR_1, 2), read_u16(VAR_1, 4), read_u16(VAR_1, 6), read_u16(VAR_1, 8)); break; case 4: if (VAR_2 == 1) return 8; key_event(VAR_0, read_u8(VAR_1, 1), read_u32(VAR_1, 4)); break; case 5: if (VAR_2 == 1) return 6; pointer_event(VAR_0, read_u8(VAR_1, 1), read_u16(VAR_1, 2), read_u16(VAR_1, 4)); break; case 6: if (VAR_2 == 1) return 8; if (VAR_2 == 8) { uint32_t dlen = read_u32(VAR_1, 4); if (dlen > 0) return 8 + dlen; } client_cut_text(VAR_0, read_u32(VAR_1, 4), VAR_1 + 8); break; case 255: if (VAR_2 == 1) return 2; switch (read_u8(VAR_1, 1)) { case 0: if (VAR_2 == 2) return 12; ext_key_event(VAR_0, read_u16(VAR_1, 2), read_u32(VAR_1, 4), read_u32(VAR_1, 8)); break; case 1: if (VAR_2 == 2) return 4; switch (read_u16 (VAR_1, 2)) { case 0: audio_add(VAR_0); break; case 1: audio_del(VAR_0); break; case 2: if (VAR_2 == 4) return 10; switch (read_u8(VAR_1, 4)) { case 0: VAR_0->as.fmt = AUD_FMT_U8; break; case 1: VAR_0->as.fmt = AUD_FMT_S8; break; case 2: VAR_0->as.fmt = AUD_FMT_U16; break; case 3: VAR_0->as.fmt = AUD_FMT_S16; break; case 4: VAR_0->as.fmt = AUD_FMT_U32; break; case 5: VAR_0->as.fmt = AUD_FMT_S32; break; default: printf("Invalid audio format %d\n", read_u8(VAR_1, 4)); vnc_client_error(VAR_0); break; } VAR_0->as.nchannels = read_u8(VAR_1, 5); if (VAR_0->as.nchannels != 1 && VAR_0->as.nchannels != 2) { printf("Invalid audio channel coount %d\n", read_u8(VAR_1, 5)); vnc_client_error(VAR_0); break; } VAR_0->as.freq = read_u32(VAR_1, 6); break; default: printf ("Invalid audio message %d\n", read_u8(VAR_1, 4)); vnc_client_error(VAR_0); break; } break; default: printf("Msg: %d\n", read_u16(VAR_1, 0)); vnc_client_error(VAR_0); break; } break; default: printf("Msg: %d\n", VAR_1[0]); vnc_client_error(VAR_0); break; } vnc_read_when(VAR_0, FUNC_0, 1); return 0; }
[ "static int FUNC_0(VncState *VAR_0, uint8_t *VAR_1, size_t VAR_2)\n{", "int VAR_3;", "uint16_t limit;", "switch (VAR_1[0]) {", "case 0:\nif (VAR_2 == 1)\nreturn 20;", "set_pixel_format(VAR_0, read_u8(VAR_1, 4), read_u8(VAR_1, 5),\nread_u8(VAR_1, 6), read_u8(VAR_1, 7),\nread_u16(VAR_1, 8), read_u16(VAR_1, 10),\nread_u16(VAR_1, 12), read_u8(VAR_1, 14),\nread_u8(VAR_1, 15), read_u8(VAR_1, 16));", "break;", "case 2:\nif (VAR_2 == 1)\nreturn 4;", "if (VAR_2 == 4)\nreturn 4 + (read_u16(VAR_1, 2) * 4);", "limit = read_u16(VAR_1, 2);", "for (VAR_3 = 0; VAR_3 < limit; VAR_3++) {", "int32_t val = read_s32(VAR_1, 4 + (VAR_3 * 4));", "memcpy(VAR_1 + 4 + (VAR_3 * 4), &val, sizeof(val));", "}", "set_encodings(VAR_0, (int32_t *)(VAR_1 + 4), limit);", "break;", "case 3:\nif (VAR_2 == 1)\nreturn 10;", "framebuffer_update_request(VAR_0,\nread_u8(VAR_1, 1), read_u16(VAR_1, 2), read_u16(VAR_1, 4),\nread_u16(VAR_1, 6), read_u16(VAR_1, 8));", "break;", "case 4:\nif (VAR_2 == 1)\nreturn 8;", "key_event(VAR_0, read_u8(VAR_1, 1), read_u32(VAR_1, 4));", "break;", "case 5:\nif (VAR_2 == 1)\nreturn 6;", "pointer_event(VAR_0, read_u8(VAR_1, 1), read_u16(VAR_1, 2), read_u16(VAR_1, 4));", "break;", "case 6:\nif (VAR_2 == 1)\nreturn 8;", "if (VAR_2 == 8) {", "uint32_t dlen = read_u32(VAR_1, 4);", "if (dlen > 0)\nreturn 8 + dlen;", "}", "client_cut_text(VAR_0, read_u32(VAR_1, 4), VAR_1 + 8);", "break;", "case 255:\nif (VAR_2 == 1)\nreturn 2;", "switch (read_u8(VAR_1, 1)) {", "case 0:\nif (VAR_2 == 2)\nreturn 12;", "ext_key_event(VAR_0, read_u16(VAR_1, 2),\nread_u32(VAR_1, 4), read_u32(VAR_1, 8));", "break;", "case 1:\nif (VAR_2 == 2)\nreturn 4;", "switch (read_u16 (VAR_1, 2)) {", "case 0:\naudio_add(VAR_0);", "break;", "case 1:\naudio_del(VAR_0);", "break;", "case 2:\nif (VAR_2 == 4)\nreturn 10;", "switch (read_u8(VAR_1, 4)) {", "case 0: VAR_0->as.fmt = AUD_FMT_U8; break;", "case 1: VAR_0->as.fmt = AUD_FMT_S8; break;", "case 2: VAR_0->as.fmt = AUD_FMT_U16; break;", "case 3: VAR_0->as.fmt = AUD_FMT_S16; break;", "case 4: VAR_0->as.fmt = AUD_FMT_U32; break;", "case 5: VAR_0->as.fmt = AUD_FMT_S32; break;", "default:\nprintf(\"Invalid audio format %d\\n\", read_u8(VAR_1, 4));", "vnc_client_error(VAR_0);", "break;", "}", "VAR_0->as.nchannels = read_u8(VAR_1, 5);", "if (VAR_0->as.nchannels != 1 && VAR_0->as.nchannels != 2) {", "printf(\"Invalid audio channel coount %d\\n\",\nread_u8(VAR_1, 5));", "vnc_client_error(VAR_0);", "break;", "}", "VAR_0->as.freq = read_u32(VAR_1, 6);", "break;", "default:\nprintf (\"Invalid audio message %d\\n\", read_u8(VAR_1, 4));", "vnc_client_error(VAR_0);", "break;", "}", "break;", "default:\nprintf(\"Msg: %d\\n\", read_u16(VAR_1, 0));", "vnc_client_error(VAR_0);", "break;", "}", "break;", "default:\nprintf(\"Msg: %d\\n\", VAR_1[0]);", "vnc_client_error(VAR_0);", "break;", "}", "vnc_read_when(VAR_0, FUNC_0, 1);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15, 17 ], [ 21, 23, 25, 27, 29 ], [ 31 ], [ 33, 35, 37 ], [ 41, 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63, 65, 67 ], [ 71, 73, 75 ], [ 77 ], [ 79, 81, 83 ], [ 87 ], [ 89 ], [ 91, 93, 95 ], [ 99 ], [ 101 ], [ 103, 105, 107 ], [ 111 ], [ 113 ], [ 115, 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127, 129, 131 ], [ 135 ], [ 137, 139, 141 ], [ 145, 147 ], [ 149 ], [ 151, 153, 155 ], [ 159 ], [ 161, 163 ], [ 165 ], [ 167, 169 ], [ 171 ], [ 173, 175, 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193, 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221, 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235, 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247, 249 ], [ 251 ], [ 253 ], [ 255 ], [ 259 ], [ 261 ], [ 263 ] ]
433
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVSubtitle *sub = data; const uint8_t *buf_end = buf + buf_size; uint8_t *bitmap; int w, h, x, y, i, ret; int64_t packet_time = 0; GetBitContext gb; int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A'); // check that at least header fits if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) { av_log(avctx, AV_LOG_ERROR, "coded frame size %d too small\n", buf_size); return -1; } // read start and end time if (buf[0] != '[' || buf[13] != '-' || buf[26] != ']') { av_log(avctx, AV_LOG_ERROR, "invalid time code\n"); return -1; } if (avpkt->pts != AV_NOPTS_VALUE) packet_time = av_rescale_q(avpkt->pts, AV_TIME_BASE_Q, (AVRational){1, 1000}); sub->start_display_time = parse_timecode(buf + 1, packet_time); sub->end_display_time = parse_timecode(buf + 14, packet_time); buf += 27; // read header w = bytestream_get_le16(&buf); h = bytestream_get_le16(&buf); if (av_image_check_size(w, h, 0, avctx) < 0) return -1; x = bytestream_get_le16(&buf); y = bytestream_get_le16(&buf); // skip bottom right position, it gives no new information bytestream_get_le16(&buf); bytestream_get_le16(&buf); // The following value is supposed to indicate the start offset // (relative to the palette) of the data for the second field, // however there are files in which it has a bogus value and thus // we just ignore it bytestream_get_le16(&buf); // allocate sub and set values sub->rects = av_mallocz(sizeof(*sub->rects)); if (!sub->rects) return AVERROR(ENOMEM); sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); if (!sub->rects[0]) { av_freep(&sub->rects); return AVERROR(ENOMEM); } sub->rects[0]->x = x; sub->rects[0]->y = y; sub->rects[0]->w = w; sub->rects[0]->h = h; sub->rects[0]->type = SUBTITLE_BITMAP; sub->rects[0]->linesize[0] = w; sub->rects[0]->data[0] = av_malloc(w * h); sub->rects[0]->nb_colors = 4; sub->rects[0]->data[1] = av_mallocz(AVPALETTE_SIZE); if (!sub->rects[0]->data[0] || !sub->rects[0]->data[1]) { av_freep(&sub->rects[0]->data[1]); av_freep(&sub->rects[0]->data[0]); av_freep(&sub->rects[0]); av_freep(&sub->rects); return AVERROR(ENOMEM); } sub->num_rects = 1; // read palette for (i = 0; i < sub->rects[0]->nb_colors; i++) ((uint32_t*)sub->rects[0]->data[1])[i] = bytestream_get_be24(&buf); if (!has_alpha) { // make all except background (first entry) non-transparent for (i = 1; i < sub->rects[0]->nb_colors; i++) ((uint32_t *)sub->rects[0]->data[1])[i] |= 0xff000000; } else { for (i = 0; i < sub->rects[0]->nb_colors; i++) ((uint32_t *)sub->rects[0]->data[1])[i] |= *buf++ << 24; } #if FF_API_AVPICTURE FF_DISABLE_DEPRECATION_WARNINGS { AVSubtitleRect *rect; int j; rect = sub->rects[0]; for (j = 0; j < 4; j++) { rect->pict.data[j] = rect->data[j]; rect->pict.linesize[j] = rect->linesize[j]; } } FF_ENABLE_DEPRECATION_WARNINGS #endif // process RLE-compressed data if ((ret = init_get_bits8(&gb, buf, buf_end - buf)) < 0) return ret; bitmap = sub->rects[0]->data[0]; for (y = 0; y < h; y++) { // interlaced: do odd lines if (y == (h + 1) / 2) bitmap = sub->rects[0]->data[0] + w; for (x = 0; x < w; ) { int log2 = ff_log2_tab[show_bits(&gb, 8)]; int run = get_bits(&gb, 14 - 4 * (log2 >> 1)); int color = get_bits(&gb, 2); run = FFMIN(run, w - x); // run length 0 means till end of row if (!run) run = w - x; memset(bitmap, color, run); bitmap += run; x += run; } // interlaced, skip every second line bitmap += w; align_get_bits(&gb); } *data_size = 1; return buf_size; }
true
FFmpeg
2002436b0c914e18eda4f45ef816b14501a1dbae
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVSubtitle *sub = data; const uint8_t *buf_end = buf + buf_size; uint8_t *bitmap; int w, h, x, y, i, ret; int64_t packet_time = 0; GetBitContext gb; int has_alpha = avctx->codec_tag == MKTAG('D','X','S','A'); if (buf_size < 27 + 7 * 2 + 4 * (3 + has_alpha)) { av_log(avctx, AV_LOG_ERROR, "coded frame size %d too small\n", buf_size); return -1; } if (buf[0] != '[' || buf[13] != '-' || buf[26] != ']') { av_log(avctx, AV_LOG_ERROR, "invalid time code\n"); return -1; } if (avpkt->pts != AV_NOPTS_VALUE) packet_time = av_rescale_q(avpkt->pts, AV_TIME_BASE_Q, (AVRational){1, 1000}); sub->start_display_time = parse_timecode(buf + 1, packet_time); sub->end_display_time = parse_timecode(buf + 14, packet_time); buf += 27; w = bytestream_get_le16(&buf); h = bytestream_get_le16(&buf); if (av_image_check_size(w, h, 0, avctx) < 0) return -1; x = bytestream_get_le16(&buf); y = bytestream_get_le16(&buf); bytestream_get_le16(&buf); bytestream_get_le16(&buf); bytestream_get_le16(&buf); sub->rects = av_mallocz(sizeof(*sub->rects)); if (!sub->rects) return AVERROR(ENOMEM); sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); if (!sub->rects[0]) { av_freep(&sub->rects); return AVERROR(ENOMEM); } sub->rects[0]->x = x; sub->rects[0]->y = y; sub->rects[0]->w = w; sub->rects[0]->h = h; sub->rects[0]->type = SUBTITLE_BITMAP; sub->rects[0]->linesize[0] = w; sub->rects[0]->data[0] = av_malloc(w * h); sub->rects[0]->nb_colors = 4; sub->rects[0]->data[1] = av_mallocz(AVPALETTE_SIZE); if (!sub->rects[0]->data[0] || !sub->rects[0]->data[1]) { av_freep(&sub->rects[0]->data[1]); av_freep(&sub->rects[0]->data[0]); av_freep(&sub->rects[0]); av_freep(&sub->rects); return AVERROR(ENOMEM); } sub->num_rects = 1; for (i = 0; i < sub->rects[0]->nb_colors; i++) ((uint32_t*)sub->rects[0]->data[1])[i] = bytestream_get_be24(&buf); if (!has_alpha) { for (i = 1; i < sub->rects[0]->nb_colors; i++) ((uint32_t *)sub->rects[0]->data[1])[i] |= 0xff000000; } else { for (i = 0; i < sub->rects[0]->nb_colors; i++) ((uint32_t *)sub->rects[0]->data[1])[i] |= *buf++ << 24; } #if FF_API_AVPICTURE FF_DISABLE_DEPRECATION_WARNINGS { AVSubtitleRect *rect; int j; rect = sub->rects[0]; for (j = 0; j < 4; j++) { rect->pict.data[j] = rect->data[j]; rect->pict.linesize[j] = rect->linesize[j]; } } FF_ENABLE_DEPRECATION_WARNINGS #endif if ((ret = init_get_bits8(&gb, buf, buf_end - buf)) < 0) return ret; bitmap = sub->rects[0]->data[0]; for (y = 0; y < h; y++) { if (y == (h + 1) / 2) bitmap = sub->rects[0]->data[0] + w; for (x = 0; x < w; ) { int log2 = ff_log2_tab[show_bits(&gb, 8)]; int run = get_bits(&gb, 14 - 4 * (log2 >> 1)); int color = get_bits(&gb, 2); run = FFMIN(run, w - x); if (!run) run = w - x; memset(bitmap, color, run); bitmap += run; x += run; } bitmap += w; align_get_bits(&gb); } *data_size = 1; return buf_size; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3) { const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5 = VAR_3->size; AVSubtitle *sub = VAR_1; const uint8_t *VAR_6 = VAR_4 + VAR_5; uint8_t *bitmap; int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12; int64_t packet_time = 0; GetBitContext gb; int VAR_13 = VAR_0->codec_tag == MKTAG('D','X','S','A'); if (VAR_5 < 27 + 7 * 2 + 4 * (3 + VAR_13)) { av_log(VAR_0, AV_LOG_ERROR, "coded frame size %d too small\n", VAR_5); return -1; } if (VAR_4[0] != '[' || VAR_4[13] != '-' || VAR_4[26] != ']') { av_log(VAR_0, AV_LOG_ERROR, "invalid time code\n"); return -1; } if (VAR_3->pts != AV_NOPTS_VALUE) packet_time = av_rescale_q(VAR_3->pts, AV_TIME_BASE_Q, (AVRational){1, 1000}); sub->start_display_time = parse_timecode(VAR_4 + 1, packet_time); sub->end_display_time = parse_timecode(VAR_4 + 14, packet_time); VAR_4 += 27; VAR_7 = bytestream_get_le16(&VAR_4); VAR_8 = bytestream_get_le16(&VAR_4); if (av_image_check_size(VAR_7, VAR_8, 0, VAR_0) < 0) return -1; VAR_9 = bytestream_get_le16(&VAR_4); VAR_10 = bytestream_get_le16(&VAR_4); bytestream_get_le16(&VAR_4); bytestream_get_le16(&VAR_4); bytestream_get_le16(&VAR_4); sub->rects = av_mallocz(sizeof(*sub->rects)); if (!sub->rects) return AVERROR(ENOMEM); sub->rects[0] = av_mallocz(sizeof(*sub->rects[0])); if (!sub->rects[0]) { av_freep(&sub->rects); return AVERROR(ENOMEM); } sub->rects[0]->VAR_9 = VAR_9; sub->rects[0]->VAR_10 = VAR_10; sub->rects[0]->VAR_7 = VAR_7; sub->rects[0]->VAR_8 = VAR_8; sub->rects[0]->type = SUBTITLE_BITMAP; sub->rects[0]->linesize[0] = VAR_7; sub->rects[0]->VAR_1[0] = av_malloc(VAR_7 * VAR_8); sub->rects[0]->nb_colors = 4; sub->rects[0]->VAR_1[1] = av_mallocz(AVPALETTE_SIZE); if (!sub->rects[0]->VAR_1[0] || !sub->rects[0]->VAR_1[1]) { av_freep(&sub->rects[0]->VAR_1[1]); av_freep(&sub->rects[0]->VAR_1[0]); av_freep(&sub->rects[0]); av_freep(&sub->rects); return AVERROR(ENOMEM); } sub->num_rects = 1; for (VAR_11 = 0; VAR_11 < sub->rects[0]->nb_colors; VAR_11++) ((uint32_t*)sub->rects[0]->VAR_1[1])[VAR_11] = bytestream_get_be24(&VAR_4); if (!VAR_13) { for (VAR_11 = 1; VAR_11 < sub->rects[0]->nb_colors; VAR_11++) ((uint32_t *)sub->rects[0]->VAR_1[1])[VAR_11] |= 0xff000000; } else { for (VAR_11 = 0; VAR_11 < sub->rects[0]->nb_colors; VAR_11++) ((uint32_t *)sub->rects[0]->VAR_1[1])[VAR_11] |= *VAR_4++ << 24; } #if FF_API_AVPICTURE FF_DISABLE_DEPRECATION_WARNINGS { AVSubtitleRect *rect; int j; rect = sub->rects[0]; for (j = 0; j < 4; j++) { rect->pict.VAR_1[j] = rect->VAR_1[j]; rect->pict.linesize[j] = rect->linesize[j]; } } FF_ENABLE_DEPRECATION_WARNINGS #endif if ((VAR_12 = init_get_bits8(&gb, VAR_4, VAR_6 - VAR_4)) < 0) return VAR_12; bitmap = sub->rects[0]->VAR_1[0]; for (VAR_10 = 0; VAR_10 < VAR_8; VAR_10++) { if (VAR_10 == (VAR_8 + 1) / 2) bitmap = sub->rects[0]->VAR_1[0] + VAR_7; for (VAR_9 = 0; VAR_9 < VAR_7; ) { int VAR_14 = ff_log2_tab[show_bits(&gb, 8)]; int VAR_15 = get_bits(&gb, 14 - 4 * (VAR_14 >> 1)); int VAR_16 = get_bits(&gb, 2); VAR_15 = FFMIN(VAR_15, VAR_7 - VAR_9); if (!VAR_15) VAR_15 = VAR_7 - VAR_9; memset(bitmap, VAR_16, VAR_15); bitmap += VAR_15; VAR_9 += VAR_15; } bitmap += VAR_7; align_get_bits(&gb); } *VAR_2 = 1; return VAR_5; }
[ "static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,\nAVPacket *VAR_3) {", "const uint8_t *VAR_4 = VAR_3->VAR_1;", "int VAR_5 = VAR_3->size;", "AVSubtitle *sub = VAR_1;", "const uint8_t *VAR_6 = VAR_4 + VAR_5;", "uint8_t *bitmap;", "int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;", "int64_t packet_time = 0;", "GetBitContext gb;", "int VAR_13 = VAR_0->codec_tag == MKTAG('D','X','S','A');", "if (VAR_5 < 27 + 7 * 2 + 4 * (3 + VAR_13)) {", "av_log(VAR_0, AV_LOG_ERROR, \"coded frame size %d too small\\n\", VAR_5);", "return -1;", "}", "if (VAR_4[0] != '[' || VAR_4[13] != '-' || VAR_4[26] != ']') {", "av_log(VAR_0, AV_LOG_ERROR, \"invalid time code\\n\");", "return -1;", "}", "if (VAR_3->pts != AV_NOPTS_VALUE)\npacket_time = av_rescale_q(VAR_3->pts, AV_TIME_BASE_Q, (AVRational){1, 1000});", "sub->start_display_time = parse_timecode(VAR_4 + 1, packet_time);", "sub->end_display_time = parse_timecode(VAR_4 + 14, packet_time);", "VAR_4 += 27;", "VAR_7 = bytestream_get_le16(&VAR_4);", "VAR_8 = bytestream_get_le16(&VAR_4);", "if (av_image_check_size(VAR_7, VAR_8, 0, VAR_0) < 0)\nreturn -1;", "VAR_9 = bytestream_get_le16(&VAR_4);", "VAR_10 = bytestream_get_le16(&VAR_4);", "bytestream_get_le16(&VAR_4);", "bytestream_get_le16(&VAR_4);", "bytestream_get_le16(&VAR_4);", "sub->rects = av_mallocz(sizeof(*sub->rects));", "if (!sub->rects)\nreturn AVERROR(ENOMEM);", "sub->rects[0] = av_mallocz(sizeof(*sub->rects[0]));", "if (!sub->rects[0]) {", "av_freep(&sub->rects);", "return AVERROR(ENOMEM);", "}", "sub->rects[0]->VAR_9 = VAR_9; sub->rects[0]->VAR_10 = VAR_10;", "sub->rects[0]->VAR_7 = VAR_7; sub->rects[0]->VAR_8 = VAR_8;", "sub->rects[0]->type = SUBTITLE_BITMAP;", "sub->rects[0]->linesize[0] = VAR_7;", "sub->rects[0]->VAR_1[0] = av_malloc(VAR_7 * VAR_8);", "sub->rects[0]->nb_colors = 4;", "sub->rects[0]->VAR_1[1] = av_mallocz(AVPALETTE_SIZE);", "if (!sub->rects[0]->VAR_1[0] || !sub->rects[0]->VAR_1[1]) {", "av_freep(&sub->rects[0]->VAR_1[1]);", "av_freep(&sub->rects[0]->VAR_1[0]);", "av_freep(&sub->rects[0]);", "av_freep(&sub->rects);", "return AVERROR(ENOMEM);", "}", "sub->num_rects = 1;", "for (VAR_11 = 0; VAR_11 < sub->rects[0]->nb_colors; VAR_11++)", "((uint32_t*)sub->rects[0]->VAR_1[1])[VAR_11] = bytestream_get_be24(&VAR_4);", "if (!VAR_13) {", "for (VAR_11 = 1; VAR_11 < sub->rects[0]->nb_colors; VAR_11++)", "((uint32_t *)sub->rects[0]->VAR_1[1])[VAR_11] |= 0xff000000;", "} else {", "for (VAR_11 = 0; VAR_11 < sub->rects[0]->nb_colors; VAR_11++)", "((uint32_t *)sub->rects[0]->VAR_1[1])[VAR_11] |= *VAR_4++ << 24;", "}", "#if FF_API_AVPICTURE\nFF_DISABLE_DEPRECATION_WARNINGS\n{", "AVSubtitleRect *rect;", "int j;", "rect = sub->rects[0];", "for (j = 0; j < 4; j++) {", "rect->pict.VAR_1[j] = rect->VAR_1[j];", "rect->pict.linesize[j] = rect->linesize[j];", "}", "}", "FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nif ((VAR_12 = init_get_bits8(&gb, VAR_4, VAR_6 - VAR_4)) < 0)\nreturn VAR_12;", "bitmap = sub->rects[0]->VAR_1[0];", "for (VAR_10 = 0; VAR_10 < VAR_8; VAR_10++) {", "if (VAR_10 == (VAR_8 + 1) / 2) bitmap = sub->rects[0]->VAR_1[0] + VAR_7;", "for (VAR_9 = 0; VAR_9 < VAR_7; ) {", "int VAR_14 = ff_log2_tab[show_bits(&gb, 8)];", "int VAR_15 = get_bits(&gb, 14 - 4 * (VAR_14 >> 1));", "int VAR_16 = get_bits(&gb, 2);", "VAR_15 = FFMIN(VAR_15, VAR_7 - VAR_9);", "if (!VAR_15) VAR_15 = VAR_7 - VAR_9;", "memset(bitmap, VAR_16, VAR_15);", "bitmap += VAR_15;", "VAR_9 += VAR_15;", "}", "bitmap += VAR_7;", "align_get_bits(&gb);", "}", "*VAR_2 = 1;", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 13 ], [ 14 ], [ 15 ], [ 16 ], [ 18 ], [ 19 ], [ 20 ], [ 21 ], [ 22, 23 ], [ 24 ], [ 25 ], [ 26 ], [ 28 ], [ 29 ], [ 30, 31 ], [ 32 ], [ 33 ], [ 35 ], [ 36 ], [ 41 ], [ 43 ], [ 44, 45 ], [ 46 ], [ 47 ], [ 48 ], [ 49 ], [ 50 ], [ 51 ], [ 52 ], [ 53 ], [ 54 ], [ 55 ], [ 56 ], [ 57 ], [ 58 ], [ 59 ], [ 60 ], [ 61 ], [ 62 ], [ 63 ], [ 64 ], [ 65 ], [ 67 ], [ 68 ], [ 69 ], [ 71 ], [ 72 ], [ 73 ], [ 74 ], [ 75 ], [ 76 ], [ 77, 78, 79 ], [ 80 ], [ 81 ], [ 82 ], [ 83 ], [ 84 ], [ 85 ], [ 86 ], [ 87 ], [ 88, 89, 91, 92 ], [ 93 ], [ 94 ], [ 96 ], [ 97 ], [ 98 ], [ 99 ], [ 100 ], [ 101 ], [ 103 ], [ 104 ], [ 105 ], [ 106 ], [ 107 ], [ 109 ], [ 110 ], [ 111 ], [ 112 ], [ 113 ], [ 114 ] ]
434
static void tpm_tis_initfn(Object *obj) { ISADevice *dev = ISA_DEVICE(obj); TPMState *s = TPM(obj); memory_region_init_io(&s->mmio, OBJECT(s), &tpm_tis_memory_ops, s, "tpm-tis-mmio", TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT); memory_region_add_subregion(isa_address_space(dev), TPM_TIS_ADDR_BASE, &s->mmio); }
true
qemu
9dfd24ed848228643293e37c36848b5ac520ab98
static void tpm_tis_initfn(Object *obj) { ISADevice *dev = ISA_DEVICE(obj); TPMState *s = TPM(obj); memory_region_init_io(&s->mmio, OBJECT(s), &tpm_tis_memory_ops, s, "tpm-tis-mmio", TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT); memory_region_add_subregion(isa_address_space(dev), TPM_TIS_ADDR_BASE, &s->mmio); }
{ "code": [ " ISADevice *dev = ISA_DEVICE(obj);", " memory_region_add_subregion(isa_address_space(dev), TPM_TIS_ADDR_BASE,", " &s->mmio);" ], "line_no": [ 5, 17, 19 ] }
static void FUNC_0(Object *VAR_0) { ISADevice *dev = ISA_DEVICE(VAR_0); TPMState *s = TPM(VAR_0); memory_region_init_io(&s->mmio, OBJECT(s), &tpm_tis_memory_ops, s, "tpm-tis-mmio", TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT); memory_region_add_subregion(isa_address_space(dev), TPM_TIS_ADDR_BASE, &s->mmio); }
[ "static void FUNC_0(Object *VAR_0)\n{", "ISADevice *dev = ISA_DEVICE(VAR_0);", "TPMState *s = TPM(VAR_0);", "memory_region_init_io(&s->mmio, OBJECT(s), &tpm_tis_memory_ops,\ns, \"tpm-tis-mmio\",\nTPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT);", "memory_region_add_subregion(isa_address_space(dev), TPM_TIS_ADDR_BASE,\n&s->mmio);", "}" ]
[ 0, 1, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13, 15 ], [ 17, 19 ], [ 21 ] ]
435
static int process_frame(FFFrameSync *fs) { AVFilterContext *ctx = fs->parent; LUT2Context *s = fs->opaque; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out, *srcx, *srcy; int ret; if ((ret = ff_framesync2_get_frame(&s->fs, 0, &srcx, 0)) < 0 || (ret = ff_framesync2_get_frame(&s->fs, 1, &srcy, 0)) < 0) return ret; if (ctx->is_disabled) { out = av_frame_clone(srcx); if (!out) return AVERROR(ENOMEM); } else { out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) return AVERROR(ENOMEM); av_frame_copy_props(out, srcx); s->lut2(s, out, srcx, srcy); } out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base); return ff_filter_frame(outlink, out); }
true
FFmpeg
a4d18a3f54e5b0277234d8fcff65dff8516417a0
static int process_frame(FFFrameSync *fs) { AVFilterContext *ctx = fs->parent; LUT2Context *s = fs->opaque; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out, *srcx, *srcy; int ret; if ((ret = ff_framesync2_get_frame(&s->fs, 0, &srcx, 0)) < 0 || (ret = ff_framesync2_get_frame(&s->fs, 1, &srcy, 0)) < 0) return ret; if (ctx->is_disabled) { out = av_frame_clone(srcx); if (!out) return AVERROR(ENOMEM); } else { out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) return AVERROR(ENOMEM); av_frame_copy_props(out, srcx); s->lut2(s, out, srcx, srcy); } out->pts = av_rescale_q(s->fs.pts, s->fs.time_base, outlink->time_base); return ff_filter_frame(outlink, out); }
{ "code": [ " AVFrame *out, *srcx, *srcy;", " if (ctx->is_disabled) {" ], "line_no": [ 11, 25 ] }
static int FUNC_0(FFFrameSync *VAR_0) { AVFilterContext *ctx = VAR_0->parent; LUT2Context *s = VAR_0->opaque; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out, *srcx, *srcy; int VAR_1; if ((VAR_1 = ff_framesync2_get_frame(&s->VAR_0, 0, &srcx, 0)) < 0 || (VAR_1 = ff_framesync2_get_frame(&s->VAR_0, 1, &srcy, 0)) < 0) return VAR_1; if (ctx->is_disabled) { out = av_frame_clone(srcx); if (!out) return AVERROR(ENOMEM); } else { out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) return AVERROR(ENOMEM); av_frame_copy_props(out, srcx); s->lut2(s, out, srcx, srcy); } out->pts = av_rescale_q(s->VAR_0.pts, s->VAR_0.time_base, outlink->time_base); return ff_filter_frame(outlink, out); }
[ "static int FUNC_0(FFFrameSync *VAR_0)\n{", "AVFilterContext *ctx = VAR_0->parent;", "LUT2Context *s = VAR_0->opaque;", "AVFilterLink *outlink = ctx->outputs[0];", "AVFrame *out, *srcx, *srcy;", "int VAR_1;", "if ((VAR_1 = ff_framesync2_get_frame(&s->VAR_0, 0, &srcx, 0)) < 0 ||\n(VAR_1 = ff_framesync2_get_frame(&s->VAR_0, 1, &srcy, 0)) < 0)\nreturn VAR_1;", "if (ctx->is_disabled) {", "out = av_frame_clone(srcx);", "if (!out)\nreturn AVERROR(ENOMEM);", "} else {", "out = ff_get_video_buffer(outlink, outlink->w, outlink->h);", "if (!out)\nreturn AVERROR(ENOMEM);", "av_frame_copy_props(out, srcx);", "s->lut2(s, out, srcx, srcy);", "}", "out->pts = av_rescale_q(s->VAR_0.pts, s->VAR_0.time_base, outlink->time_base);", "return ff_filter_frame(outlink, out);", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19, 21 ], [ 25 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 45 ], [ 47 ], [ 51 ], [ 55 ], [ 57 ] ]
437
static int handle_primary_tcp_pkt(NetFilterState *nf, Connection *conn, Packet *pkt) { struct tcphdr *tcp_pkt; tcp_pkt = (struct tcphdr *)pkt->transport_header; if (trace_event_get_state_backends(TRACE_COLO_FILTER_REWRITER_DEBUG)) { trace_colo_filter_rewriter_pkt_info(__func__, inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst), ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack), tcp_pkt->th_flags); trace_colo_filter_rewriter_conn_offset(conn->offset); } if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) { /* * we use this flag update offset func * run once in independent tcp connection */ conn->syn_flag = 1; } if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_ACK)) { if (conn->syn_flag) { /* * offset = secondary_seq - primary seq * ack packet sent by guest from primary node, * so we use th_ack - 1 get primary_seq */ conn->offset -= (ntohl(tcp_pkt->th_ack) - 1); conn->syn_flag = 0; } if (conn->offset) { /* handle packets to the secondary from the primary */ tcp_pkt->th_ack = htonl(ntohl(tcp_pkt->th_ack) + conn->offset); net_checksum_calculate((uint8_t *)pkt->data, pkt->size); } } return 0; }
true
qemu
6ce310b5356abb7edc3aa8b8b097d0b8cc76f83f
static int handle_primary_tcp_pkt(NetFilterState *nf, Connection *conn, Packet *pkt) { struct tcphdr *tcp_pkt; tcp_pkt = (struct tcphdr *)pkt->transport_header; if (trace_event_get_state_backends(TRACE_COLO_FILTER_REWRITER_DEBUG)) { trace_colo_filter_rewriter_pkt_info(__func__, inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_dst), ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack), tcp_pkt->th_flags); trace_colo_filter_rewriter_conn_offset(conn->offset); } if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) { conn->syn_flag = 1; } if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) == TH_ACK)) { if (conn->syn_flag) { conn->offset -= (ntohl(tcp_pkt->th_ack) - 1); conn->syn_flag = 0; } if (conn->offset) { tcp_pkt->th_ack = htonl(ntohl(tcp_pkt->th_ack) + conn->offset); net_checksum_calculate((uint8_t *)pkt->data, pkt->size); } } return 0; }
{ "code": [ " net_checksum_calculate((uint8_t *)pkt->data, pkt->size);", " net_checksum_calculate((uint8_t *)pkt->data, pkt->size);" ], "line_no": [ 75, 75 ] }
static int FUNC_0(NetFilterState *VAR_0, Connection *VAR_1, Packet *VAR_2) { struct tcphdr *VAR_3; VAR_3 = (struct tcphdr *)VAR_2->transport_header; if (trace_event_get_state_backends(TRACE_COLO_FILTER_REWRITER_DEBUG)) { trace_colo_filter_rewriter_pkt_info(__func__, inet_ntoa(VAR_2->ip->ip_src), inet_ntoa(VAR_2->ip->ip_dst), ntohl(VAR_3->th_seq), ntohl(VAR_3->th_ack), VAR_3->th_flags); trace_colo_filter_rewriter_conn_offset(VAR_1->offset); } if (((VAR_3->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) { VAR_1->syn_flag = 1; } if (((VAR_3->th_flags & (TH_ACK | TH_SYN)) == TH_ACK)) { if (VAR_1->syn_flag) { VAR_1->offset -= (ntohl(VAR_3->th_ack) - 1); VAR_1->syn_flag = 0; } if (VAR_1->offset) { VAR_3->th_ack = htonl(ntohl(VAR_3->th_ack) + VAR_1->offset); net_checksum_calculate((uint8_t *)VAR_2->data, VAR_2->size); } } return 0; }
[ "static int FUNC_0(NetFilterState *VAR_0,\nConnection *VAR_1,\nPacket *VAR_2)\n{", "struct tcphdr *VAR_3;", "VAR_3 = (struct tcphdr *)VAR_2->transport_header;", "if (trace_event_get_state_backends(TRACE_COLO_FILTER_REWRITER_DEBUG)) {", "trace_colo_filter_rewriter_pkt_info(__func__,\ninet_ntoa(VAR_2->ip->ip_src), inet_ntoa(VAR_2->ip->ip_dst),\nntohl(VAR_3->th_seq), ntohl(VAR_3->th_ack),\nVAR_3->th_flags);", "trace_colo_filter_rewriter_conn_offset(VAR_1->offset);", "}", "if (((VAR_3->th_flags & (TH_ACK | TH_SYN)) == TH_SYN)) {", "VAR_1->syn_flag = 1;", "}", "if (((VAR_3->th_flags & (TH_ACK | TH_SYN)) == TH_ACK)) {", "if (VAR_1->syn_flag) {", "VAR_1->offset -= (ntohl(VAR_3->th_ack) - 1);", "VAR_1->syn_flag = 0;", "}", "if (VAR_1->offset) {", "VAR_3->th_ack = htonl(ntohl(VAR_3->th_ack) + VAR_1->offset);", "net_checksum_calculate((uint8_t *)VAR_2->data, VAR_2->size);", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17, 19, 21, 23 ], [ 25 ], [ 27 ], [ 31 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ] ]
438
av_cold void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx) { const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (avctx->bits_per_raw_sample <= 8 && (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) { c->idct_put = ff_simple_idct_put_armv6; c->idct_add = ff_simple_idct_add_armv6; c->idct = ff_simple_idct_armv6; c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM; } if (!high_bit_depth) { c->put_pixels_tab[0][0] = ff_put_pixels16_armv6; c->put_pixels_tab[0][1] = ff_put_pixels16_x2_armv6; c->put_pixels_tab[0][2] = ff_put_pixels16_y2_armv6; /* c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_armv6; */ c->put_pixels_tab[1][0] = ff_put_pixels8_armv6; c->put_pixels_tab[1][1] = ff_put_pixels8_x2_armv6; c->put_pixels_tab[1][2] = ff_put_pixels8_y2_armv6; /* c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_armv6; */ c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_armv6; c->put_no_rnd_pixels_tab[0][1] = ff_put_pixels16_x2_no_rnd_armv6; c->put_no_rnd_pixels_tab[0][2] = ff_put_pixels16_y2_no_rnd_armv6; /* c->put_no_rnd_pixels_tab[0][3] = ff_put_pixels16_xy2_no_rnd_armv6; */ c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_armv6; c->put_no_rnd_pixels_tab[1][1] = ff_put_pixels8_x2_no_rnd_armv6; c->put_no_rnd_pixels_tab[1][2] = ff_put_pixels8_y2_no_rnd_armv6; /* c->put_no_rnd_pixels_tab[1][3] = ff_put_pixels8_xy2_no_rnd_armv6; */ c->avg_pixels_tab[0][0] = ff_avg_pixels16_armv6; c->avg_pixels_tab[1][0] = ff_avg_pixels8_armv6; } if (!high_bit_depth) c->get_pixels = ff_get_pixels_armv6; c->add_pixels_clamped = ff_add_pixels_clamped_armv6; c->diff_pixels = ff_diff_pixels_armv6; c->pix_abs[0][0] = ff_pix_abs16_armv6; c->pix_abs[0][1] = ff_pix_abs16_x2_armv6; c->pix_abs[0][2] = ff_pix_abs16_y2_armv6; c->pix_abs[1][0] = ff_pix_abs8_armv6; c->sad[0] = ff_pix_abs16_armv6; c->sad[1] = ff_pix_abs8_armv6; c->sse[0] = ff_sse16_armv6; c->pix_norm1 = ff_pix_norm1_armv6; c->pix_sum = ff_pix_sum_armv6; }
false
FFmpeg
70d54392f5015b9c6594fcae558f59f952501e3b
av_cold void ff_dsputil_init_armv6(DSPContext *c, AVCodecContext *avctx) { const int high_bit_depth = avctx->bits_per_raw_sample > 8; if (avctx->bits_per_raw_sample <= 8 && (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) { c->idct_put = ff_simple_idct_put_armv6; c->idct_add = ff_simple_idct_add_armv6; c->idct = ff_simple_idct_armv6; c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM; } if (!high_bit_depth) { c->put_pixels_tab[0][0] = ff_put_pixels16_armv6; c->put_pixels_tab[0][1] = ff_put_pixels16_x2_armv6; c->put_pixels_tab[0][2] = ff_put_pixels16_y2_armv6; c->put_pixels_tab[1][0] = ff_put_pixels8_armv6; c->put_pixels_tab[1][1] = ff_put_pixels8_x2_armv6; c->put_pixels_tab[1][2] = ff_put_pixels8_y2_armv6; c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_armv6; c->put_no_rnd_pixels_tab[0][1] = ff_put_pixels16_x2_no_rnd_armv6; c->put_no_rnd_pixels_tab[0][2] = ff_put_pixels16_y2_no_rnd_armv6; c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_armv6; c->put_no_rnd_pixels_tab[1][1] = ff_put_pixels8_x2_no_rnd_armv6; c->put_no_rnd_pixels_tab[1][2] = ff_put_pixels8_y2_no_rnd_armv6; c->avg_pixels_tab[0][0] = ff_avg_pixels16_armv6; c->avg_pixels_tab[1][0] = ff_avg_pixels8_armv6; } if (!high_bit_depth) c->get_pixels = ff_get_pixels_armv6; c->add_pixels_clamped = ff_add_pixels_clamped_armv6; c->diff_pixels = ff_diff_pixels_armv6; c->pix_abs[0][0] = ff_pix_abs16_armv6; c->pix_abs[0][1] = ff_pix_abs16_x2_armv6; c->pix_abs[0][2] = ff_pix_abs16_y2_armv6; c->pix_abs[1][0] = ff_pix_abs8_armv6; c->sad[0] = ff_pix_abs16_armv6; c->sad[1] = ff_pix_abs8_armv6; c->sse[0] = ff_sse16_armv6; c->pix_norm1 = ff_pix_norm1_armv6; c->pix_sum = ff_pix_sum_armv6; }
{ "code": [], "line_no": [] }
av_cold void FUNC_0(DSPContext *c, AVCodecContext *avctx) { const int VAR_0 = avctx->bits_per_raw_sample > 8; if (avctx->bits_per_raw_sample <= 8 && (avctx->idct_algo == FF_IDCT_AUTO || avctx->idct_algo == FF_IDCT_SIMPLEARMV6)) { c->idct_put = ff_simple_idct_put_armv6; c->idct_add = ff_simple_idct_add_armv6; c->idct = ff_simple_idct_armv6; c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM; } if (!VAR_0) { c->put_pixels_tab[0][0] = ff_put_pixels16_armv6; c->put_pixels_tab[0][1] = ff_put_pixels16_x2_armv6; c->put_pixels_tab[0][2] = ff_put_pixels16_y2_armv6; c->put_pixels_tab[1][0] = ff_put_pixels8_armv6; c->put_pixels_tab[1][1] = ff_put_pixels8_x2_armv6; c->put_pixels_tab[1][2] = ff_put_pixels8_y2_armv6; c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_armv6; c->put_no_rnd_pixels_tab[0][1] = ff_put_pixels16_x2_no_rnd_armv6; c->put_no_rnd_pixels_tab[0][2] = ff_put_pixels16_y2_no_rnd_armv6; c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_armv6; c->put_no_rnd_pixels_tab[1][1] = ff_put_pixels8_x2_no_rnd_armv6; c->put_no_rnd_pixels_tab[1][2] = ff_put_pixels8_y2_no_rnd_armv6; c->avg_pixels_tab[0][0] = ff_avg_pixels16_armv6; c->avg_pixels_tab[1][0] = ff_avg_pixels8_armv6; } if (!VAR_0) c->get_pixels = ff_get_pixels_armv6; c->add_pixels_clamped = ff_add_pixels_clamped_armv6; c->diff_pixels = ff_diff_pixels_armv6; c->pix_abs[0][0] = ff_pix_abs16_armv6; c->pix_abs[0][1] = ff_pix_abs16_x2_armv6; c->pix_abs[0][2] = ff_pix_abs16_y2_armv6; c->pix_abs[1][0] = ff_pix_abs8_armv6; c->sad[0] = ff_pix_abs16_armv6; c->sad[1] = ff_pix_abs8_armv6; c->sse[0] = ff_sse16_armv6; c->pix_norm1 = ff_pix_norm1_armv6; c->pix_sum = ff_pix_sum_armv6; }
[ "av_cold void FUNC_0(DSPContext *c, AVCodecContext *avctx)\n{", "const int VAR_0 = avctx->bits_per_raw_sample > 8;", "if (avctx->bits_per_raw_sample <= 8 &&\n(avctx->idct_algo == FF_IDCT_AUTO ||\navctx->idct_algo == FF_IDCT_SIMPLEARMV6)) {", "c->idct_put = ff_simple_idct_put_armv6;", "c->idct_add = ff_simple_idct_add_armv6;", "c->idct = ff_simple_idct_armv6;", "c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;", "}", "if (!VAR_0) {", "c->put_pixels_tab[0][0] = ff_put_pixels16_armv6;", "c->put_pixels_tab[0][1] = ff_put_pixels16_x2_armv6;", "c->put_pixels_tab[0][2] = ff_put_pixels16_y2_armv6;", "c->put_pixels_tab[1][0] = ff_put_pixels8_armv6;", "c->put_pixels_tab[1][1] = ff_put_pixels8_x2_armv6;", "c->put_pixels_tab[1][2] = ff_put_pixels8_y2_armv6;", "c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_armv6;", "c->put_no_rnd_pixels_tab[0][1] = ff_put_pixels16_x2_no_rnd_armv6;", "c->put_no_rnd_pixels_tab[0][2] = ff_put_pixels16_y2_no_rnd_armv6;", "c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_armv6;", "c->put_no_rnd_pixels_tab[1][1] = ff_put_pixels8_x2_no_rnd_armv6;", "c->put_no_rnd_pixels_tab[1][2] = ff_put_pixels8_y2_no_rnd_armv6;", "c->avg_pixels_tab[0][0] = ff_avg_pixels16_armv6;", "c->avg_pixels_tab[1][0] = ff_avg_pixels8_armv6;", "}", "if (!VAR_0)\nc->get_pixels = ff_get_pixels_armv6;", "c->add_pixels_clamped = ff_add_pixels_clamped_armv6;", "c->diff_pixels = ff_diff_pixels_armv6;", "c->pix_abs[0][0] = ff_pix_abs16_armv6;", "c->pix_abs[0][1] = ff_pix_abs16_x2_armv6;", "c->pix_abs[0][2] = ff_pix_abs16_y2_armv6;", "c->pix_abs[1][0] = ff_pix_abs8_armv6;", "c->sad[0] = ff_pix_abs16_armv6;", "c->sad[1] = ff_pix_abs8_armv6;", "c->sse[0] = ff_sse16_armv6;", "c->pix_norm1 = ff_pix_norm1_armv6;", "c->pix_sum = ff_pix_sum_armv6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 65 ], [ 67 ], [ 69 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 95 ], [ 97 ], [ 101 ], [ 105 ], [ 107 ], [ 109 ] ]
440
static int decode_exponents(AC3DecodeContext *ctx) { ac3_audio_block *ab = &ctx->audio_block; int i; uint8_t *exps; uint8_t *dexps; if (ab->flags & AC3_AB_CPLINU && ab->cplexpstr != AC3_EXPSTR_REUSE) if (_decode_exponents(ab->cplexpstr, ab->ncplgrps, ab->cplabsexp, ab->cplexps, ab->dcplexps + ab->cplstrtmant)) return -1; for (i = 0; i < ctx->bsi.nfchans; i++) if (ab->chexpstr[i] != AC3_EXPSTR_REUSE) { exps = ab->exps[i]; dexps = ab->dexps[i]; if (_decode_exponents(ab->chexpstr[i], ab->nchgrps[i], exps[0], exps + 1, dexps + 1)) return -1; } if (ctx->bsi.flags & AC3_BSI_LFEON && ab->lfeexpstr != AC3_EXPSTR_REUSE) if (_decode_exponents(ab->lfeexpstr, 2, ab->lfeexps[0], ab->lfeexps + 1, ab->dlfeexps)) return -1; return 0; }
false
FFmpeg
0058584580b87feb47898e60e4b80c7f425882ad
static int decode_exponents(AC3DecodeContext *ctx) { ac3_audio_block *ab = &ctx->audio_block; int i; uint8_t *exps; uint8_t *dexps; if (ab->flags & AC3_AB_CPLINU && ab->cplexpstr != AC3_EXPSTR_REUSE) if (_decode_exponents(ab->cplexpstr, ab->ncplgrps, ab->cplabsexp, ab->cplexps, ab->dcplexps + ab->cplstrtmant)) return -1; for (i = 0; i < ctx->bsi.nfchans; i++) if (ab->chexpstr[i] != AC3_EXPSTR_REUSE) { exps = ab->exps[i]; dexps = ab->dexps[i]; if (_decode_exponents(ab->chexpstr[i], ab->nchgrps[i], exps[0], exps + 1, dexps + 1)) return -1; } if (ctx->bsi.flags & AC3_BSI_LFEON && ab->lfeexpstr != AC3_EXPSTR_REUSE) if (_decode_exponents(ab->lfeexpstr, 2, ab->lfeexps[0], ab->lfeexps + 1, ab->dlfeexps)) return -1; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AC3DecodeContext *VAR_0) { ac3_audio_block *ab = &VAR_0->audio_block; int VAR_1; uint8_t *exps; uint8_t *dexps; if (ab->flags & AC3_AB_CPLINU && ab->cplexpstr != AC3_EXPSTR_REUSE) if (_decode_exponents(ab->cplexpstr, ab->ncplgrps, ab->cplabsexp, ab->cplexps, ab->dcplexps + ab->cplstrtmant)) return -1; for (VAR_1 = 0; VAR_1 < VAR_0->bsi.nfchans; VAR_1++) if (ab->chexpstr[VAR_1] != AC3_EXPSTR_REUSE) { exps = ab->exps[VAR_1]; dexps = ab->dexps[VAR_1]; if (_decode_exponents(ab->chexpstr[VAR_1], ab->nchgrps[VAR_1], exps[0], exps + 1, dexps + 1)) return -1; } if (VAR_0->bsi.flags & AC3_BSI_LFEON && ab->lfeexpstr != AC3_EXPSTR_REUSE) if (_decode_exponents(ab->lfeexpstr, 2, ab->lfeexps[0], ab->lfeexps + 1, ab->dlfeexps)) return -1; return 0; }
[ "static int FUNC_0(AC3DecodeContext *VAR_0)\n{", "ac3_audio_block *ab = &VAR_0->audio_block;", "int VAR_1;", "uint8_t *exps;", "uint8_t *dexps;", "if (ab->flags & AC3_AB_CPLINU && ab->cplexpstr != AC3_EXPSTR_REUSE)\nif (_decode_exponents(ab->cplexpstr, ab->ncplgrps, ab->cplabsexp,\nab->cplexps, ab->dcplexps + ab->cplstrtmant))\nreturn -1;", "for (VAR_1 = 0; VAR_1 < VAR_0->bsi.nfchans; VAR_1++)", "if (ab->chexpstr[VAR_1] != AC3_EXPSTR_REUSE) {", "exps = ab->exps[VAR_1];", "dexps = ab->dexps[VAR_1];", "if (_decode_exponents(ab->chexpstr[VAR_1], ab->nchgrps[VAR_1], exps[0], exps + 1, dexps + 1))\nreturn -1;", "}", "if (VAR_0->bsi.flags & AC3_BSI_LFEON && ab->lfeexpstr != AC3_EXPSTR_REUSE)\nif (_decode_exponents(ab->lfeexpstr, 2, ab->lfeexps[0], ab->lfeexps + 1, ab->dlfeexps))\nreturn -1;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15, 17, 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37, 39, 41 ], [ 43 ], [ 45 ] ]
441
static void handle_pending_signal(CPUArchState *cpu_env, int sig, struct emulated_sigtable *k) { CPUState *cpu = ENV_GET_CPU(cpu_env); abi_ulong handler; sigset_t set; target_sigset_t target_old_set; struct target_sigaction *sa; TaskState *ts = cpu->opaque; trace_user_handle_signal(cpu_env, sig); /* dequeue signal */ k->pending = 0; sig = gdb_handlesig(cpu, sig); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; } else { sa = &sigact_table[sig - 1]; handler = sa->_sa_handler; } if (do_strace) { print_taken_signal(sig, &k->info); } if (handler == TARGET_SIG_DFL) { /* default handler : ignore some signal. The other are job control or fatal */ if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) { kill(getpid(),SIGSTOP); } else if (sig != TARGET_SIGCHLD && sig != TARGET_SIGURG && sig != TARGET_SIGWINCH && sig != TARGET_SIGCONT) { force_sig(sig); } } else if (handler == TARGET_SIG_IGN) { /* ignore sig */ } else if (handler == TARGET_SIG_ERR) { force_sig(sig); } else { /* compute the blocked signals during the handler execution */ sigset_t *blocked_set; target_to_host_sigset(&set, &sa->sa_mask); /* SA_NODEFER indicates that the current signal should not be blocked during the handler */ if (!(sa->sa_flags & TARGET_SA_NODEFER)) sigaddset(&set, target_to_host_signal(sig)); /* save the previous blocked signal state to restore it at the end of the signal execution (see do_sigreturn) */ host_to_target_sigset_internal(&target_old_set, &ts->signal_mask); /* block signals in the handler */ blocked_set = ts->in_sigsuspend ? &ts->sigsuspend_mask : &ts->signal_mask; sigorset(&ts->signal_mask, blocked_set, &set); ts->in_sigsuspend = 0; /* if the CPU is in VM86 mode, we restore the 32 bit values */ #if defined(TARGET_I386) && !defined(TARGET_X86_64) { CPUX86State *env = cpu_env; if (env->eflags & VM_MASK) save_v86_state(env); } #endif /* prepare the stack frame of the virtual CPU */ #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) \ || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) /* These targets do not have traditional signals. */ setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env); #else if (sa->sa_flags & TARGET_SA_SIGINFO) setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env); else setup_frame(sig, sa, &target_old_set, cpu_env); #endif if (sa->sa_flags & TARGET_SA_RESETHAND) { sa->_sa_handler = TARGET_SIG_DFL; } } }
true
qemu
c599d4d6d6e9bfdb64e54c33a22cb26e3496b96d
static void handle_pending_signal(CPUArchState *cpu_env, int sig, struct emulated_sigtable *k) { CPUState *cpu = ENV_GET_CPU(cpu_env); abi_ulong handler; sigset_t set; target_sigset_t target_old_set; struct target_sigaction *sa; TaskState *ts = cpu->opaque; trace_user_handle_signal(cpu_env, sig); k->pending = 0; sig = gdb_handlesig(cpu, sig); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; } else { sa = &sigact_table[sig - 1]; handler = sa->_sa_handler; } if (do_strace) { print_taken_signal(sig, &k->info); } if (handler == TARGET_SIG_DFL) { if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) { kill(getpid(),SIGSTOP); } else if (sig != TARGET_SIGCHLD && sig != TARGET_SIGURG && sig != TARGET_SIGWINCH && sig != TARGET_SIGCONT) { force_sig(sig); } } else if (handler == TARGET_SIG_IGN) { } else if (handler == TARGET_SIG_ERR) { force_sig(sig); } else { sigset_t *blocked_set; target_to_host_sigset(&set, &sa->sa_mask); if (!(sa->sa_flags & TARGET_SA_NODEFER)) sigaddset(&set, target_to_host_signal(sig)); host_to_target_sigset_internal(&target_old_set, &ts->signal_mask); blocked_set = ts->in_sigsuspend ? &ts->sigsuspend_mask : &ts->signal_mask; sigorset(&ts->signal_mask, blocked_set, &set); ts->in_sigsuspend = 0; #if defined(TARGET_I386) && !defined(TARGET_X86_64) { CPUX86State *env = cpu_env; if (env->eflags & VM_MASK) save_v86_state(env); } #endif #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) \ || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env); #else if (sa->sa_flags & TARGET_SA_SIGINFO) setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env); else setup_frame(sig, sa, &target_old_set, cpu_env); #endif if (sa->sa_flags & TARGET_SA_RESETHAND) { sa->_sa_handler = TARGET_SIG_DFL; } } }
{ "code": [ " force_sig(sig);", " force_sig(sig);" ], "line_no": [ 71, 81 ] }
static void FUNC_0(CPUArchState *VAR_0, int VAR_1, struct emulated_sigtable *VAR_2) { CPUState *cpu = ENV_GET_CPU(VAR_0); abi_ulong handler; sigset_t set; target_sigset_t target_old_set; struct target_sigaction *VAR_3; TaskState *ts = cpu->opaque; trace_user_handle_signal(VAR_0, VAR_1); VAR_2->pending = 0; VAR_1 = gdb_handlesig(cpu, VAR_1); if (!VAR_1) { VAR_3 = NULL; handler = TARGET_SIG_IGN; } else { VAR_3 = &sigact_table[VAR_1 - 1]; handler = VAR_3->_sa_handler; } if (do_strace) { print_taken_signal(VAR_1, &VAR_2->info); } if (handler == TARGET_SIG_DFL) { if (VAR_1 == TARGET_SIGTSTP || VAR_1 == TARGET_SIGTTIN || VAR_1 == TARGET_SIGTTOU) { kill(getpid(),SIGSTOP); } else if (VAR_1 != TARGET_SIGCHLD && VAR_1 != TARGET_SIGURG && VAR_1 != TARGET_SIGWINCH && VAR_1 != TARGET_SIGCONT) { force_sig(VAR_1); } } else if (handler == TARGET_SIG_IGN) { } else if (handler == TARGET_SIG_ERR) { force_sig(VAR_1); } else { sigset_t *blocked_set; target_to_host_sigset(&set, &VAR_3->sa_mask); if (!(VAR_3->sa_flags & TARGET_SA_NODEFER)) sigaddset(&set, target_to_host_signal(VAR_1)); host_to_target_sigset_internal(&target_old_set, &ts->signal_mask); blocked_set = ts->in_sigsuspend ? &ts->sigsuspend_mask : &ts->signal_mask; sigorset(&ts->signal_mask, blocked_set, &set); ts->in_sigsuspend = 0; #if defined(TARGET_I386) && !defined(TARGET_X86_64) { CPUX86State *env = VAR_0; if (env->eflags & VM_MASK) save_v86_state(env); } #endif #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) \ || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) setup_rt_frame(VAR_1, VAR_3, &VAR_2->info, &target_old_set, VAR_0); #else if (VAR_3->sa_flags & TARGET_SA_SIGINFO) setup_rt_frame(VAR_1, VAR_3, &VAR_2->info, &target_old_set, VAR_0); else setup_frame(VAR_1, VAR_3, &target_old_set, VAR_0); #endif if (VAR_3->sa_flags & TARGET_SA_RESETHAND) { VAR_3->_sa_handler = TARGET_SIG_DFL; } } }
[ "static void FUNC_0(CPUArchState *VAR_0, int VAR_1,\nstruct emulated_sigtable *VAR_2)\n{", "CPUState *cpu = ENV_GET_CPU(VAR_0);", "abi_ulong handler;", "sigset_t set;", "target_sigset_t target_old_set;", "struct target_sigaction *VAR_3;", "TaskState *ts = cpu->opaque;", "trace_user_handle_signal(VAR_0, VAR_1);", "VAR_2->pending = 0;", "VAR_1 = gdb_handlesig(cpu, VAR_1);", "if (!VAR_1) {", "VAR_3 = NULL;", "handler = TARGET_SIG_IGN;", "} else {", "VAR_3 = &sigact_table[VAR_1 - 1];", "handler = VAR_3->_sa_handler;", "}", "if (do_strace) {", "print_taken_signal(VAR_1, &VAR_2->info);", "}", "if (handler == TARGET_SIG_DFL) {", "if (VAR_1 == TARGET_SIGTSTP || VAR_1 == TARGET_SIGTTIN || VAR_1 == TARGET_SIGTTOU) {", "kill(getpid(),SIGSTOP);", "} else if (VAR_1 != TARGET_SIGCHLD &&", "VAR_1 != TARGET_SIGURG &&\nVAR_1 != TARGET_SIGWINCH &&\nVAR_1 != TARGET_SIGCONT) {", "force_sig(VAR_1);", "}", "} else if (handler == TARGET_SIG_IGN) {", "} else if (handler == TARGET_SIG_ERR) {", "force_sig(VAR_1);", "} else {", "sigset_t *blocked_set;", "target_to_host_sigset(&set, &VAR_3->sa_mask);", "if (!(VAR_3->sa_flags & TARGET_SA_NODEFER))\nsigaddset(&set, target_to_host_signal(VAR_1));", "host_to_target_sigset_internal(&target_old_set, &ts->signal_mask);", "blocked_set = ts->in_sigsuspend ?\n&ts->sigsuspend_mask : &ts->signal_mask;", "sigorset(&ts->signal_mask, blocked_set, &set);", "ts->in_sigsuspend = 0;", "#if defined(TARGET_I386) && !defined(TARGET_X86_64)\n{", "CPUX86State *env = VAR_0;", "if (env->eflags & VM_MASK)\nsave_v86_state(env);", "}", "#endif\n#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) \\\n|| defined(TARGET_OPENRISC) || defined(TARGET_TILEGX)\nsetup_rt_frame(VAR_1, VAR_3, &VAR_2->info, &target_old_set, VAR_0);", "#else\nif (VAR_3->sa_flags & TARGET_SA_SIGINFO)\nsetup_rt_frame(VAR_1, VAR_3, &VAR_2->info, &target_old_set, VAR_0);", "else\nsetup_frame(VAR_1, VAR_3, &target_old_set, VAR_0);", "#endif\nif (VAR_3->sa_flags & TARGET_SA_RESETHAND) {", "VAR_3->_sa_handler = TARGET_SIG_DFL;", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65, 67, 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 91 ], [ 97, 99 ], [ 107 ], [ 113, 115 ], [ 117 ], [ 119 ], [ 125, 127 ], [ 129 ], [ 131, 133 ], [ 135 ], [ 137, 141, 143, 147 ], [ 149, 151, 153 ], [ 155, 157 ], [ 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ] ]
442
void block_job_yield(BlockJob *job) { assert(job->busy); /* Check cancellation *before* setting busy = false, too! */ if (block_job_is_cancelled(job)) { return; } job->busy = false; if (!block_job_should_pause(job)) { qemu_coroutine_yield(); } job->busy = true; block_job_pause_point(job); }
true
qemu
356f59b8757f47c0aca3e2e4e51d6010f64cade1
void block_job_yield(BlockJob *job) { assert(job->busy); if (block_job_is_cancelled(job)) { return; } job->busy = false; if (!block_job_should_pause(job)) { qemu_coroutine_yield(); } job->busy = true; block_job_pause_point(job); }
{ "code": [ " job->busy = false;", " qemu_coroutine_yield();", " job->busy = true;" ], "line_no": [ 19, 23, 27 ] }
void FUNC_0(BlockJob *VAR_0) { assert(VAR_0->busy); if (block_job_is_cancelled(VAR_0)) { return; } VAR_0->busy = false; if (!block_job_should_pause(VAR_0)) { qemu_coroutine_yield(); } VAR_0->busy = true; block_job_pause_point(VAR_0); }
[ "void FUNC_0(BlockJob *VAR_0)\n{", "assert(VAR_0->busy);", "if (block_job_is_cancelled(VAR_0)) {", "return;", "}", "VAR_0->busy = false;", "if (!block_job_should_pause(VAR_0)) {", "qemu_coroutine_yield();", "}", "VAR_0->busy = true;", "block_job_pause_point(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ] ]
445
static int udp_close(URLContext *h) { UDPContext *s = h->priv_data; if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr,(struct sockaddr *)&s->local_addr_storage); closesocket(s->udp_fd); #if HAVE_PTHREAD_CANCEL if (s->thread_started) { int ret; pthread_cancel(s->circular_buffer_thread); ret = pthread_join(s->circular_buffer_thread, NULL); if (ret != 0) av_log(h, AV_LOG_ERROR, "pthread_join(): %s\n", strerror(ret)); pthread_mutex_destroy(&s->mutex); pthread_cond_destroy(&s->cond); } #endif av_fifo_freep(&s->fifo); return 0; }
true
FFmpeg
9b7a8bddac52bd05dddb28afd4dff92739946d3b
static int udp_close(URLContext *h) { UDPContext *s = h->priv_data; if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr,(struct sockaddr *)&s->local_addr_storage); closesocket(s->udp_fd); #if HAVE_PTHREAD_CANCEL if (s->thread_started) { int ret; pthread_cancel(s->circular_buffer_thread); ret = pthread_join(s->circular_buffer_thread, NULL); if (ret != 0) av_log(h, AV_LOG_ERROR, "pthread_join(): %s\n", strerror(ret)); pthread_mutex_destroy(&s->mutex); pthread_cond_destroy(&s->cond); } #endif av_fifo_freep(&s->fifo); return 0; }
{ "code": [ " UDPContext *s = h->priv_data;", " pthread_cancel(s->circular_buffer_thread);" ], "line_no": [ 5, 21 ] }
static int FUNC_0(URLContext *VAR_0) { UDPContext *s = VAR_0->priv_data; if (s->is_multicast && (VAR_0->flags & AVIO_FLAG_READ)) udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr,(struct sockaddr *)&s->local_addr_storage); closesocket(s->udp_fd); #if HAVE_PTHREAD_CANCEL if (s->thread_started) { int ret; pthread_cancel(s->circular_buffer_thread); ret = pthread_join(s->circular_buffer_thread, NULL); if (ret != 0) av_log(VAR_0, AV_LOG_ERROR, "pthread_join(): %s\n", strerror(ret)); pthread_mutex_destroy(&s->mutex); pthread_cond_destroy(&s->cond); } #endif av_fifo_freep(&s->fifo); return 0; }
[ "static int FUNC_0(URLContext *VAR_0)\n{", "UDPContext *s = VAR_0->priv_data;", "if (s->is_multicast && (VAR_0->flags & AVIO_FLAG_READ))\nudp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr,(struct sockaddr *)&s->local_addr_storage);", "closesocket(s->udp_fd);", "#if HAVE_PTHREAD_CANCEL\nif (s->thread_started) {", "int ret;", "pthread_cancel(s->circular_buffer_thread);", "ret = pthread_join(s->circular_buffer_thread, NULL);", "if (ret != 0)\nav_log(VAR_0, AV_LOG_ERROR, \"pthread_join(): %s\\n\", strerror(ret));", "pthread_mutex_destroy(&s->mutex);", "pthread_cond_destroy(&s->cond);", "}", "#endif\nav_fifo_freep(&s->fifo);", "return 0;", "}" ]
[ 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41 ] ]
447
static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, uint8_t (*layout_map)[3], GetBitContext *gb, int byte_align_ref) { int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc; int sampling_index; int comment_len; int tags; skip_bits(gb, 2); // object_type sampling_index = get_bits(gb, 4); if (m4ac->sampling_index != sampling_index) av_log(avctx, AV_LOG_WARNING, "Sample rate index in program config element does not " "match the sample rate index configured by the container.\n"); num_front = get_bits(gb, 4); num_side = get_bits(gb, 4); num_back = get_bits(gb, 4); num_lfe = get_bits(gb, 2); num_assoc_data = get_bits(gb, 3); num_cc = get_bits(gb, 4); if (get_bits1(gb)) skip_bits(gb, 4); // mono_mixdown_tag if (get_bits1(gb)) skip_bits(gb, 4); // stereo_mixdown_tag if (get_bits1(gb)) skip_bits(gb, 3); // mixdown_coeff_index and pseudo_surround if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) { av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); return -1; } decode_channel_map(layout_map , AAC_CHANNEL_FRONT, gb, num_front); tags = num_front; decode_channel_map(layout_map + tags, AAC_CHANNEL_SIDE, gb, num_side); tags += num_side; decode_channel_map(layout_map + tags, AAC_CHANNEL_BACK, gb, num_back); tags += num_back; decode_channel_map(layout_map + tags, AAC_CHANNEL_LFE, gb, num_lfe); tags += num_lfe; skip_bits_long(gb, 4 * num_assoc_data); decode_channel_map(layout_map + tags, AAC_CHANNEL_CC, gb, num_cc); tags += num_cc; relative_align_get_bits(gb, byte_align_ref); /* comment field, first byte is length */ comment_len = get_bits(gb, 8) * 8; if (get_bits_left(gb) < comment_len) { av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); return AVERROR_INVALIDDATA; } skip_bits_long(gb, comment_len); return tags; }
true
FFmpeg
df884e038f5dc95f55ef07500b5b99b722835f8a
static int decode_pce(AVCodecContext *avctx, MPEG4AudioConfig *m4ac, uint8_t (*layout_map)[3], GetBitContext *gb, int byte_align_ref) { int num_front, num_side, num_back, num_lfe, num_assoc_data, num_cc; int sampling_index; int comment_len; int tags; skip_bits(gb, 2); sampling_index = get_bits(gb, 4); if (m4ac->sampling_index != sampling_index) av_log(avctx, AV_LOG_WARNING, "Sample rate index in program config element does not " "match the sample rate index configured by the container.\n"); num_front = get_bits(gb, 4); num_side = get_bits(gb, 4); num_back = get_bits(gb, 4); num_lfe = get_bits(gb, 2); num_assoc_data = get_bits(gb, 3); num_cc = get_bits(gb, 4); if (get_bits1(gb)) skip_bits(gb, 4); if (get_bits1(gb)) skip_bits(gb, 4); if (get_bits1(gb)) skip_bits(gb, 3); if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) { av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); return -1; } decode_channel_map(layout_map , AAC_CHANNEL_FRONT, gb, num_front); tags = num_front; decode_channel_map(layout_map + tags, AAC_CHANNEL_SIDE, gb, num_side); tags += num_side; decode_channel_map(layout_map + tags, AAC_CHANNEL_BACK, gb, num_back); tags += num_back; decode_channel_map(layout_map + tags, AAC_CHANNEL_LFE, gb, num_lfe); tags += num_lfe; skip_bits_long(gb, 4 * num_assoc_data); decode_channel_map(layout_map + tags, AAC_CHANNEL_CC, gb, num_cc); tags += num_cc; relative_align_get_bits(gb, byte_align_ref); comment_len = get_bits(gb, 8) * 8; if (get_bits_left(gb) < comment_len) { av_log(avctx, AV_LOG_ERROR, "decode_pce: " overread_err); return AVERROR_INVALIDDATA; } skip_bits_long(gb, comment_len); return tags; }
{ "code": [ " if (get_bits_left(gb) < 4 * (num_front + num_side + num_back + num_lfe + num_assoc_data + num_cc)) {" ], "line_no": [ 65 ] }
static int FUNC_0(AVCodecContext *VAR_0, MPEG4AudioConfig *VAR_1, VAR_2 (*layout_map)[3], GetBitContext *VAR_3, int VAR_4) { int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10; int VAR_11; int VAR_12; int VAR_13; skip_bits(VAR_3, 2); VAR_11 = get_bits(VAR_3, 4); if (VAR_1->VAR_11 != VAR_11) av_log(VAR_0, AV_LOG_WARNING, "Sample rate index in program config element does not " "match the sample rate index configured by the container.\n"); VAR_5 = get_bits(VAR_3, 4); VAR_6 = get_bits(VAR_3, 4); VAR_7 = get_bits(VAR_3, 4); VAR_8 = get_bits(VAR_3, 2); VAR_9 = get_bits(VAR_3, 3); VAR_10 = get_bits(VAR_3, 4); if (get_bits1(VAR_3)) skip_bits(VAR_3, 4); if (get_bits1(VAR_3)) skip_bits(VAR_3, 4); if (get_bits1(VAR_3)) skip_bits(VAR_3, 3); if (get_bits_left(VAR_3) < 4 * (VAR_5 + VAR_6 + VAR_7 + VAR_8 + VAR_9 + VAR_10)) { av_log(VAR_0, AV_LOG_ERROR, "FUNC_0: " overread_err); return -1; } decode_channel_map(layout_map , AAC_CHANNEL_FRONT, VAR_3, VAR_5); VAR_13 = VAR_5; decode_channel_map(layout_map + VAR_13, AAC_CHANNEL_SIDE, VAR_3, VAR_6); VAR_13 += VAR_6; decode_channel_map(layout_map + VAR_13, AAC_CHANNEL_BACK, VAR_3, VAR_7); VAR_13 += VAR_7; decode_channel_map(layout_map + VAR_13, AAC_CHANNEL_LFE, VAR_3, VAR_8); VAR_13 += VAR_8; skip_bits_long(VAR_3, 4 * VAR_9); decode_channel_map(layout_map + VAR_13, AAC_CHANNEL_CC, VAR_3, VAR_10); VAR_13 += VAR_10; relative_align_get_bits(VAR_3, VAR_4); VAR_12 = get_bits(VAR_3, 8) * 8; if (get_bits_left(VAR_3) < VAR_12) { av_log(VAR_0, AV_LOG_ERROR, "FUNC_0: " overread_err); return AVERROR_INVALIDDATA; } skip_bits_long(VAR_3, VAR_12); return VAR_13; }
[ "static int FUNC_0(AVCodecContext *VAR_0, MPEG4AudioConfig *VAR_1,\nVAR_2 (*layout_map)[3],\nGetBitContext *VAR_3, int VAR_4)\n{", "int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;", "int VAR_11;", "int VAR_12;", "int VAR_13;", "skip_bits(VAR_3, 2);", "VAR_11 = get_bits(VAR_3, 4);", "if (VAR_1->VAR_11 != VAR_11)\nav_log(VAR_0, AV_LOG_WARNING,\n\"Sample rate index in program config element does not \"\n\"match the sample rate index configured by the container.\\n\");", "VAR_5 = get_bits(VAR_3, 4);", "VAR_6 = get_bits(VAR_3, 4);", "VAR_7 = get_bits(VAR_3, 4);", "VAR_8 = get_bits(VAR_3, 2);", "VAR_9 = get_bits(VAR_3, 3);", "VAR_10 = get_bits(VAR_3, 4);", "if (get_bits1(VAR_3))\nskip_bits(VAR_3, 4);", "if (get_bits1(VAR_3))\nskip_bits(VAR_3, 4);", "if (get_bits1(VAR_3))\nskip_bits(VAR_3, 3);", "if (get_bits_left(VAR_3) < 4 * (VAR_5 + VAR_6 + VAR_7 + VAR_8 + VAR_9 + VAR_10)) {", "av_log(VAR_0, AV_LOG_ERROR, \"FUNC_0: \" overread_err);", "return -1;", "}", "decode_channel_map(layout_map , AAC_CHANNEL_FRONT, VAR_3, VAR_5);", "VAR_13 = VAR_5;", "decode_channel_map(layout_map + VAR_13, AAC_CHANNEL_SIDE, VAR_3, VAR_6);", "VAR_13 += VAR_6;", "decode_channel_map(layout_map + VAR_13, AAC_CHANNEL_BACK, VAR_3, VAR_7);", "VAR_13 += VAR_7;", "decode_channel_map(layout_map + VAR_13, AAC_CHANNEL_LFE, VAR_3, VAR_8);", "VAR_13 += VAR_8;", "skip_bits_long(VAR_3, 4 * VAR_9);", "decode_channel_map(layout_map + VAR_13, AAC_CHANNEL_CC, VAR_3, VAR_10);", "VAR_13 += VAR_10;", "relative_align_get_bits(VAR_3, VAR_4);", "VAR_12 = get_bits(VAR_3, 8) * 8;", "if (get_bits_left(VAR_3) < VAR_12) {", "av_log(VAR_0, AV_LOG_ERROR, \"FUNC_0: \" overread_err);", "return AVERROR_INVALIDDATA;", "}", "skip_bits_long(VAR_3, VAR_12);", "return VAR_13;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25, 27, 29, 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49, 51 ], [ 53, 55 ], [ 59, 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 95 ], [ 97 ], [ 101 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ] ]
448
void ff_decode_dxt1(const uint8_t *s, uint8_t *dst, const unsigned int w, const unsigned int h, const unsigned int stride) { unsigned int bx, by, qstride = stride/4; uint32_t *d = (uint32_t *) dst; for (by=0; by < h/4; by++, d += stride-w) for (bx=0; bx < w/4; bx++, s+=8, d+=4) dxt1_decode_pixels(s, d, qstride, 0, 0LL); }
true
FFmpeg
919f3554387e043bdfe10c6369356d1104882183
void ff_decode_dxt1(const uint8_t *s, uint8_t *dst, const unsigned int w, const unsigned int h, const unsigned int stride) { unsigned int bx, by, qstride = stride/4; uint32_t *d = (uint32_t *) dst; for (by=0; by < h/4; by++, d += stride-w) for (bx=0; bx < w/4; bx++, s+=8, d+=4) dxt1_decode_pixels(s, d, qstride, 0, 0LL); }
{ "code": [ "void ff_decode_dxt1(const uint8_t *s, uint8_t *dst,", " for (bx=0; bx < w/4; bx++, s+=8, d+=4)", " dxt1_decode_pixels(s, d, qstride, 0, 0LL);" ], "line_no": [ 1, 15, 17 ] }
void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1, const unsigned int VAR_2, const unsigned int VAR_3, const unsigned int VAR_4) { unsigned int VAR_5, VAR_6, VAR_7 = VAR_4/4; uint32_t *d = (uint32_t *) VAR_1; for (VAR_6=0; VAR_6 < VAR_3/4; VAR_6++, d += VAR_4-VAR_2) for (VAR_5=0; VAR_5 < VAR_2/4; VAR_5++, VAR_0+=8, d+=4) dxt1_decode_pixels(VAR_0, d, VAR_7, 0, 0LL); }
[ "void FUNC_0(const uint8_t *VAR_0, uint8_t *VAR_1,\nconst unsigned int VAR_2, const unsigned int VAR_3,\nconst unsigned int VAR_4) {", "unsigned int VAR_5, VAR_6, VAR_7 = VAR_4/4;", "uint32_t *d = (uint32_t *) VAR_1;", "for (VAR_6=0; VAR_6 < VAR_3/4; VAR_6++, d += VAR_4-VAR_2)", "for (VAR_5=0; VAR_5 < VAR_2/4; VAR_5++, VAR_0+=8, d+=4)", "dxt1_decode_pixels(VAR_0, d, VAR_7, 0, 0LL);", "}" ]
[ 1, 0, 0, 0, 1, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
450
static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt) { int i; for (i = 0; hwaccels[i].name; i++) if (hwaccels[i].pix_fmt == pix_fmt) return &hwaccels[i]; return NULL; }
false
FFmpeg
6a4d1c9063174234ca439244cf8f5f534afa1c28
static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt) { int i; for (i = 0; hwaccels[i].name; i++) if (hwaccels[i].pix_fmt == pix_fmt) return &hwaccels[i]; return NULL; }
{ "code": [], "line_no": [] }
static const HWAccel *FUNC_0(enum AVPixelFormat pix_fmt) { int VAR_0; for (VAR_0 = 0; hwaccels[VAR_0].name; VAR_0++) if (hwaccels[VAR_0].pix_fmt == pix_fmt) return &hwaccels[VAR_0]; return NULL; }
[ "static const HWAccel *FUNC_0(enum AVPixelFormat pix_fmt)\n{", "int VAR_0;", "for (VAR_0 = 0; hwaccels[VAR_0].name; VAR_0++)", "if (hwaccels[VAR_0].pix_fmt == pix_fmt)\nreturn &hwaccels[VAR_0];", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9, 11 ], [ 13 ], [ 15 ] ]
451
static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) { VirtIOPCIProxy *proxy = opaque; VirtIODevice *vdev = proxy->vdev; target_phys_addr_t pa; switch (addr) { case VIRTIO_PCI_GUEST_FEATURES: /* Guest does not negotiate properly? We have to assume nothing. */ if (val & (1 << VIRTIO_F_BAD_FEATURE)) { if (vdev->bad_features) val = proxy->host_features & vdev->bad_features(vdev); else val = 0; } if (vdev->set_features) vdev->set_features(vdev, val); vdev->guest_features = val; break; case VIRTIO_PCI_QUEUE_PFN: pa = (target_phys_addr_t)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT; if (pa == 0) { virtio_pci_stop_ioeventfd(proxy); virtio_reset(proxy->vdev); msix_unuse_all_vectors(&proxy->pci_dev); } else virtio_queue_set_addr(vdev, vdev->queue_sel, pa); break; case VIRTIO_PCI_QUEUE_SEL: if (val < VIRTIO_PCI_QUEUE_MAX) vdev->queue_sel = val; break; case VIRTIO_PCI_QUEUE_NOTIFY: virtio_queue_notify(vdev, val); break; case VIRTIO_PCI_STATUS: if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) { virtio_pci_stop_ioeventfd(proxy); } virtio_set_status(vdev, val & 0xFF); if (val & VIRTIO_CONFIG_S_DRIVER_OK) { virtio_pci_start_ioeventfd(proxy); } if (vdev->status == 0) { virtio_reset(proxy->vdev); msix_unuse_all_vectors(&proxy->pci_dev); } /* Linux before 2.6.34 sets the device as OK without enabling the PCI device bus master bit. In this case we need to disable some safety checks. */ if ((val & VIRTIO_CONFIG_S_DRIVER_OK) && !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG; } break; case VIRTIO_MSI_CONFIG_VECTOR: msix_vector_unuse(&proxy->pci_dev, vdev->config_vector); /* Make it possible for guest to discover an error took place. */ if (msix_vector_use(&proxy->pci_dev, val) < 0) val = VIRTIO_NO_VECTOR; vdev->config_vector = val; break; case VIRTIO_MSI_QUEUE_VECTOR: msix_vector_unuse(&proxy->pci_dev, virtio_queue_vector(vdev, vdev->queue_sel)); /* Make it possible for guest to discover an error took place. */ if (msix_vector_use(&proxy->pci_dev, val) < 0) val = VIRTIO_NO_VECTOR; virtio_queue_set_vector(vdev, vdev->queue_sel, val); break; default: error_report("%s: unexpected address 0x%x value 0x%x", __func__, addr, val); break; } }
true
qemu
7157e2e23e89adcd436caeab31fdd6b47eded377
static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) { VirtIOPCIProxy *proxy = opaque; VirtIODevice *vdev = proxy->vdev; target_phys_addr_t pa; switch (addr) { case VIRTIO_PCI_GUEST_FEATURES: if (val & (1 << VIRTIO_F_BAD_FEATURE)) { if (vdev->bad_features) val = proxy->host_features & vdev->bad_features(vdev); else val = 0; } if (vdev->set_features) vdev->set_features(vdev, val); vdev->guest_features = val; break; case VIRTIO_PCI_QUEUE_PFN: pa = (target_phys_addr_t)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT; if (pa == 0) { virtio_pci_stop_ioeventfd(proxy); virtio_reset(proxy->vdev); msix_unuse_all_vectors(&proxy->pci_dev); } else virtio_queue_set_addr(vdev, vdev->queue_sel, pa); break; case VIRTIO_PCI_QUEUE_SEL: if (val < VIRTIO_PCI_QUEUE_MAX) vdev->queue_sel = val; break; case VIRTIO_PCI_QUEUE_NOTIFY: virtio_queue_notify(vdev, val); break; case VIRTIO_PCI_STATUS: if (!(val & VIRTIO_CONFIG_S_DRIVER_OK)) { virtio_pci_stop_ioeventfd(proxy); } virtio_set_status(vdev, val & 0xFF); if (val & VIRTIO_CONFIG_S_DRIVER_OK) { virtio_pci_start_ioeventfd(proxy); } if (vdev->status == 0) { virtio_reset(proxy->vdev); msix_unuse_all_vectors(&proxy->pci_dev); } if ((val & VIRTIO_CONFIG_S_DRIVER_OK) && !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG; } break; case VIRTIO_MSI_CONFIG_VECTOR: msix_vector_unuse(&proxy->pci_dev, vdev->config_vector); if (msix_vector_use(&proxy->pci_dev, val) < 0) val = VIRTIO_NO_VECTOR; vdev->config_vector = val; break; case VIRTIO_MSI_QUEUE_VECTOR: msix_vector_unuse(&proxy->pci_dev, virtio_queue_vector(vdev, vdev->queue_sel)); if (msix_vector_use(&proxy->pci_dev, val) < 0) val = VIRTIO_NO_VECTOR; virtio_queue_set_vector(vdev, vdev->queue_sel, val); break; default: error_report("%s: unexpected address 0x%x value 0x%x", __func__, addr, val); break; } }
{ "code": [ " virtio_queue_notify(vdev, val);" ], "line_no": [ 69 ] }
static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2) { VirtIOPCIProxy *proxy = VAR_0; VirtIODevice *vdev = proxy->vdev; target_phys_addr_t pa; switch (VAR_1) { case VIRTIO_PCI_GUEST_FEATURES: if (VAR_2 & (1 << VIRTIO_F_BAD_FEATURE)) { if (vdev->bad_features) VAR_2 = proxy->host_features & vdev->bad_features(vdev); else VAR_2 = 0; } if (vdev->set_features) vdev->set_features(vdev, VAR_2); vdev->guest_features = VAR_2; break; case VIRTIO_PCI_QUEUE_PFN: pa = (target_phys_addr_t)VAR_2 << VIRTIO_PCI_QUEUE_ADDR_SHIFT; if (pa == 0) { virtio_pci_stop_ioeventfd(proxy); virtio_reset(proxy->vdev); msix_unuse_all_vectors(&proxy->pci_dev); } else virtio_queue_set_addr(vdev, vdev->queue_sel, pa); break; case VIRTIO_PCI_QUEUE_SEL: if (VAR_2 < VIRTIO_PCI_QUEUE_MAX) vdev->queue_sel = VAR_2; break; case VIRTIO_PCI_QUEUE_NOTIFY: virtio_queue_notify(vdev, VAR_2); break; case VIRTIO_PCI_STATUS: if (!(VAR_2 & VIRTIO_CONFIG_S_DRIVER_OK)) { virtio_pci_stop_ioeventfd(proxy); } virtio_set_status(vdev, VAR_2 & 0xFF); if (VAR_2 & VIRTIO_CONFIG_S_DRIVER_OK) { virtio_pci_start_ioeventfd(proxy); } if (vdev->status == 0) { virtio_reset(proxy->vdev); msix_unuse_all_vectors(&proxy->pci_dev); } if ((VAR_2 & VIRTIO_CONFIG_S_DRIVER_OK) && !(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) { proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG; } break; case VIRTIO_MSI_CONFIG_VECTOR: msix_vector_unuse(&proxy->pci_dev, vdev->config_vector); if (msix_vector_use(&proxy->pci_dev, VAR_2) < 0) VAR_2 = VIRTIO_NO_VECTOR; vdev->config_vector = VAR_2; break; case VIRTIO_MSI_QUEUE_VECTOR: msix_vector_unuse(&proxy->pci_dev, virtio_queue_vector(vdev, vdev->queue_sel)); if (msix_vector_use(&proxy->pci_dev, VAR_2) < 0) VAR_2 = VIRTIO_NO_VECTOR; virtio_queue_set_vector(vdev, vdev->queue_sel, VAR_2); break; default: error_report("%s: unexpected address 0x%x value 0x%x", __func__, VAR_1, VAR_2); break; } }
[ "static void FUNC_0(void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{", "VirtIOPCIProxy *proxy = VAR_0;", "VirtIODevice *vdev = proxy->vdev;", "target_phys_addr_t pa;", "switch (VAR_1) {", "case VIRTIO_PCI_GUEST_FEATURES:\nif (VAR_2 & (1 << VIRTIO_F_BAD_FEATURE)) {", "if (vdev->bad_features)\nVAR_2 = proxy->host_features & vdev->bad_features(vdev);", "else\nVAR_2 = 0;", "}", "if (vdev->set_features)\nvdev->set_features(vdev, VAR_2);", "vdev->guest_features = VAR_2;", "break;", "case VIRTIO_PCI_QUEUE_PFN:\npa = (target_phys_addr_t)VAR_2 << VIRTIO_PCI_QUEUE_ADDR_SHIFT;", "if (pa == 0) {", "virtio_pci_stop_ioeventfd(proxy);", "virtio_reset(proxy->vdev);", "msix_unuse_all_vectors(&proxy->pci_dev);", "}", "else\nvirtio_queue_set_addr(vdev, vdev->queue_sel, pa);", "break;", "case VIRTIO_PCI_QUEUE_SEL:\nif (VAR_2 < VIRTIO_PCI_QUEUE_MAX)\nvdev->queue_sel = VAR_2;", "break;", "case VIRTIO_PCI_QUEUE_NOTIFY:\nvirtio_queue_notify(vdev, VAR_2);", "break;", "case VIRTIO_PCI_STATUS:\nif (!(VAR_2 & VIRTIO_CONFIG_S_DRIVER_OK)) {", "virtio_pci_stop_ioeventfd(proxy);", "}", "virtio_set_status(vdev, VAR_2 & 0xFF);", "if (VAR_2 & VIRTIO_CONFIG_S_DRIVER_OK) {", "virtio_pci_start_ioeventfd(proxy);", "}", "if (vdev->status == 0) {", "virtio_reset(proxy->vdev);", "msix_unuse_all_vectors(&proxy->pci_dev);", "}", "if ((VAR_2 & VIRTIO_CONFIG_S_DRIVER_OK) &&\n!(proxy->pci_dev.config[PCI_COMMAND] & PCI_COMMAND_MASTER)) {", "proxy->flags |= VIRTIO_PCI_FLAG_BUS_MASTER_BUG;", "}", "break;", "case VIRTIO_MSI_CONFIG_VECTOR:\nmsix_vector_unuse(&proxy->pci_dev, vdev->config_vector);", "if (msix_vector_use(&proxy->pci_dev, VAR_2) < 0)\nVAR_2 = VIRTIO_NO_VECTOR;", "vdev->config_vector = VAR_2;", "break;", "case VIRTIO_MSI_QUEUE_VECTOR:\nmsix_vector_unuse(&proxy->pci_dev,\nvirtio_queue_vector(vdev, vdev->queue_sel));", "if (msix_vector_use(&proxy->pci_dev, VAR_2) < 0)\nVAR_2 = VIRTIO_NO_VECTOR;", "virtio_queue_set_vector(vdev, vdev->queue_sel, VAR_2);", "break;", "default:\nerror_report(\"%s: unexpected address 0x%x value 0x%x\",\n__func__, VAR_1, VAR_2);", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 19 ], [ 21, 23 ], [ 25, 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59, 61, 63 ], [ 65 ], [ 67, 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121, 123 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135, 137, 139 ], [ 143, 145 ], [ 147 ], [ 149 ], [ 151, 153, 155 ], [ 157 ], [ 159 ], [ 161 ] ]
453
int ff_get_cpu_flags_x86(void) { int rval = 0; #ifdef cpuid int eax, ebx, ecx, edx; int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0; int family = 0, model = 0; union { int i[3]; char c[12]; } vendor; if (!cpuid_test()) return 0; /* CPUID not supported */ cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]); if (max_std_level >= 1) { cpuid(1, eax, ebx, ecx, std_caps); family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0); if (std_caps & (1 << 15)) rval |= AV_CPU_FLAG_CMOV; if (std_caps & (1 << 23)) rval |= AV_CPU_FLAG_MMX; if (std_caps & (1 << 25)) rval |= AV_CPU_FLAG_MMXEXT; #if HAVE_SSE if (std_caps & (1 << 25)) rval |= AV_CPU_FLAG_SSE; if (std_caps & (1 << 26)) rval |= AV_CPU_FLAG_SSE2; if (ecx & 1) rval |= AV_CPU_FLAG_SSE3; if (ecx & 0x00000200 ) rval |= AV_CPU_FLAG_SSSE3; if (ecx & 0x00080000 ) rval |= AV_CPU_FLAG_SSE4; if (ecx & 0x00100000 ) rval |= AV_CPU_FLAG_SSE42; #if HAVE_AVX /* Check OXSAVE and AVX bits */ if ((ecx & 0x18000000) == 0x18000000) { /* Check for OS support */ xgetbv(0, eax, edx); if ((eax & 0x6) == 0x6) { rval |= AV_CPU_FLAG_AVX; if (ecx & 0x00001000) rval |= AV_CPU_FLAG_FMA3; } } #endif /* HAVE_AVX */ #endif /* HAVE_SSE */ } if (max_std_level >= 7) { cpuid(7, eax, ebx, ecx, edx); #if HAVE_AVX2 if (ebx & 0x00000020) rval |= AV_CPU_FLAG_AVX2; #endif /* HAVE_AVX2 */ /* BMI1/2 don't need OS support */ if (ebx & 0x00000008) { rval |= AV_CPU_FLAG_BMI1; if (ebx & 0x00000100) rval |= AV_CPU_FLAG_BMI2; } } cpuid(0x80000000, max_ext_level, ebx, ecx, edx); if (max_ext_level >= 0x80000001) { cpuid(0x80000001, eax, ebx, ecx, ext_caps); if (ext_caps & (1U << 31)) rval |= AV_CPU_FLAG_3DNOW; if (ext_caps & (1 << 30)) rval |= AV_CPU_FLAG_3DNOWEXT; if (ext_caps & (1 << 23)) rval |= AV_CPU_FLAG_MMX; if (ext_caps & (1 << 22)) rval |= AV_CPU_FLAG_MMXEXT; /* Allow for selectively disabling SSE2 functions on AMD processors with SSE2 support but not SSE4a. This includes Athlon64, some Opteron, and some Sempron processors. MMX, SSE, or 3DNow! are faster than SSE2 often enough to utilize this special-case flag. AV_CPU_FLAG_SSE2 and AV_CPU_FLAG_SSE2SLOW are both set in this case so that SSE2 is used unless explicitly disabled by checking AV_CPU_FLAG_SSE2SLOW. */ if (!strncmp(vendor.c, "AuthenticAMD", 12) && rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) { rval |= AV_CPU_FLAG_SSE2SLOW; } /* XOP and FMA4 use the AVX instruction coding scheme, so they can't be * used unless the OS has AVX support. */ if (rval & AV_CPU_FLAG_AVX) { if (ecx & 0x00000800) rval |= AV_CPU_FLAG_XOP; if (ecx & 0x00010000) rval |= AV_CPU_FLAG_FMA4; } } if (!strncmp(vendor.c, "GenuineIntel", 12)) { if (family == 6 && (model == 9 || model == 13 || model == 14)) { /* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and * 6/14 (core1 "yonah") theoretically support sse2, but it's * usually slower than mmx, so let's just pretend they don't. * AV_CPU_FLAG_SSE2 is disabled and AV_CPU_FLAG_SSE2SLOW is * enabled so that SSE2 is not used unless explicitly enabled * by checking AV_CPU_FLAG_SSE2SLOW. The same situation * applies for AV_CPU_FLAG_SSE3 and AV_CPU_FLAG_SSE3SLOW. */ if (rval & AV_CPU_FLAG_SSE2) rval ^= AV_CPU_FLAG_SSE2SLOW | AV_CPU_FLAG_SSE2; if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW | AV_CPU_FLAG_SSE3; } /* The Atom processor has SSSE3 support, which is useful in many cases, * but sometimes the SSSE3 version is slower than the SSE2 equivalent * on the Atom, but is generally faster on other processors supporting * SSSE3. This flag allows for selectively disabling certain SSSE3 * functions on the Atom. */ if (family == 6 && model == 28) rval |= AV_CPU_FLAG_ATOM; } #endif /* cpuid */ return rval; }
false
FFmpeg
2d9821a2081aff5dca253386c6e7e71a04509cff
int ff_get_cpu_flags_x86(void) { int rval = 0; #ifdef cpuid int eax, ebx, ecx, edx; int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0; int family = 0, model = 0; union { int i[3]; char c[12]; } vendor; if (!cpuid_test()) return 0; cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]); if (max_std_level >= 1) { cpuid(1, eax, ebx, ecx, std_caps); family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0); if (std_caps & (1 << 15)) rval |= AV_CPU_FLAG_CMOV; if (std_caps & (1 << 23)) rval |= AV_CPU_FLAG_MMX; if (std_caps & (1 << 25)) rval |= AV_CPU_FLAG_MMXEXT; #if HAVE_SSE if (std_caps & (1 << 25)) rval |= AV_CPU_FLAG_SSE; if (std_caps & (1 << 26)) rval |= AV_CPU_FLAG_SSE2; if (ecx & 1) rval |= AV_CPU_FLAG_SSE3; if (ecx & 0x00000200 ) rval |= AV_CPU_FLAG_SSSE3; if (ecx & 0x00080000 ) rval |= AV_CPU_FLAG_SSE4; if (ecx & 0x00100000 ) rval |= AV_CPU_FLAG_SSE42; #if HAVE_AVX if ((ecx & 0x18000000) == 0x18000000) { xgetbv(0, eax, edx); if ((eax & 0x6) == 0x6) { rval |= AV_CPU_FLAG_AVX; if (ecx & 0x00001000) rval |= AV_CPU_FLAG_FMA3; } } #endif #endif } if (max_std_level >= 7) { cpuid(7, eax, ebx, ecx, edx); #if HAVE_AVX2 if (ebx & 0x00000020) rval |= AV_CPU_FLAG_AVX2; #endif if (ebx & 0x00000008) { rval |= AV_CPU_FLAG_BMI1; if (ebx & 0x00000100) rval |= AV_CPU_FLAG_BMI2; } } cpuid(0x80000000, max_ext_level, ebx, ecx, edx); if (max_ext_level >= 0x80000001) { cpuid(0x80000001, eax, ebx, ecx, ext_caps); if (ext_caps & (1U << 31)) rval |= AV_CPU_FLAG_3DNOW; if (ext_caps & (1 << 30)) rval |= AV_CPU_FLAG_3DNOWEXT; if (ext_caps & (1 << 23)) rval |= AV_CPU_FLAG_MMX; if (ext_caps & (1 << 22)) rval |= AV_CPU_FLAG_MMXEXT; if (!strncmp(vendor.c, "AuthenticAMD", 12) && rval & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) { rval |= AV_CPU_FLAG_SSE2SLOW; } if (rval & AV_CPU_FLAG_AVX) { if (ecx & 0x00000800) rval |= AV_CPU_FLAG_XOP; if (ecx & 0x00010000) rval |= AV_CPU_FLAG_FMA4; } } if (!strncmp(vendor.c, "GenuineIntel", 12)) { if (family == 6 && (model == 9 || model == 13 || model == 14)) { if (rval & AV_CPU_FLAG_SSE2) rval ^= AV_CPU_FLAG_SSE2SLOW | AV_CPU_FLAG_SSE2; if (rval & AV_CPU_FLAG_SSE3) rval ^= AV_CPU_FLAG_SSE3SLOW | AV_CPU_FLAG_SSE3; } if (family == 6 && model == 28) rval |= AV_CPU_FLAG_ATOM; } #endif return rval; }
{ "code": [], "line_no": [] }
int FUNC_0(void) { int VAR_0 = 0; #ifdef cpuid int eax, ebx, ecx, edx; int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0; int family = 0, model = 0; union { int i[3]; char c[12]; } vendor; if (!cpuid_test()) return 0; cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]); if (max_std_level >= 1) { cpuid(1, eax, ebx, ecx, std_caps); family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0); if (std_caps & (1 << 15)) VAR_0 |= AV_CPU_FLAG_CMOV; if (std_caps & (1 << 23)) VAR_0 |= AV_CPU_FLAG_MMX; if (std_caps & (1 << 25)) VAR_0 |= AV_CPU_FLAG_MMXEXT; #if HAVE_SSE if (std_caps & (1 << 25)) VAR_0 |= AV_CPU_FLAG_SSE; if (std_caps & (1 << 26)) VAR_0 |= AV_CPU_FLAG_SSE2; if (ecx & 1) VAR_0 |= AV_CPU_FLAG_SSE3; if (ecx & 0x00000200 ) VAR_0 |= AV_CPU_FLAG_SSSE3; if (ecx & 0x00080000 ) VAR_0 |= AV_CPU_FLAG_SSE4; if (ecx & 0x00100000 ) VAR_0 |= AV_CPU_FLAG_SSE42; #if HAVE_AVX if ((ecx & 0x18000000) == 0x18000000) { xgetbv(0, eax, edx); if ((eax & 0x6) == 0x6) { VAR_0 |= AV_CPU_FLAG_AVX; if (ecx & 0x00001000) VAR_0 |= AV_CPU_FLAG_FMA3; } } #endif #endif } if (max_std_level >= 7) { cpuid(7, eax, ebx, ecx, edx); #if HAVE_AVX2 if (ebx & 0x00000020) VAR_0 |= AV_CPU_FLAG_AVX2; #endif if (ebx & 0x00000008) { VAR_0 |= AV_CPU_FLAG_BMI1; if (ebx & 0x00000100) VAR_0 |= AV_CPU_FLAG_BMI2; } } cpuid(0x80000000, max_ext_level, ebx, ecx, edx); if (max_ext_level >= 0x80000001) { cpuid(0x80000001, eax, ebx, ecx, ext_caps); if (ext_caps & (1U << 31)) VAR_0 |= AV_CPU_FLAG_3DNOW; if (ext_caps & (1 << 30)) VAR_0 |= AV_CPU_FLAG_3DNOWEXT; if (ext_caps & (1 << 23)) VAR_0 |= AV_CPU_FLAG_MMX; if (ext_caps & (1 << 22)) VAR_0 |= AV_CPU_FLAG_MMXEXT; if (!strncmp(vendor.c, "AuthenticAMD", 12) && VAR_0 & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) { VAR_0 |= AV_CPU_FLAG_SSE2SLOW; } if (VAR_0 & AV_CPU_FLAG_AVX) { if (ecx & 0x00000800) VAR_0 |= AV_CPU_FLAG_XOP; if (ecx & 0x00010000) VAR_0 |= AV_CPU_FLAG_FMA4; } } if (!strncmp(vendor.c, "GenuineIntel", 12)) { if (family == 6 && (model == 9 || model == 13 || model == 14)) { if (VAR_0 & AV_CPU_FLAG_SSE2) VAR_0 ^= AV_CPU_FLAG_SSE2SLOW | AV_CPU_FLAG_SSE2; if (VAR_0 & AV_CPU_FLAG_SSE3) VAR_0 ^= AV_CPU_FLAG_SSE3SLOW | AV_CPU_FLAG_SSE3; } if (family == 6 && model == 28) VAR_0 |= AV_CPU_FLAG_ATOM; } #endif return VAR_0; }
[ "int FUNC_0(void)\n{", "int VAR_0 = 0;", "#ifdef cpuid\nint eax, ebx, ecx, edx;", "int max_std_level, max_ext_level, std_caps = 0, ext_caps = 0;", "int family = 0, model = 0;", "union { int i[3]; char c[12]; } vendor;", "if (!cpuid_test())\nreturn 0;", "cpuid(0, max_std_level, vendor.i[0], vendor.i[2], vendor.i[1]);", "if (max_std_level >= 1) {", "cpuid(1, eax, ebx, ecx, std_caps);", "family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);", "model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);", "if (std_caps & (1 << 15))\nVAR_0 |= AV_CPU_FLAG_CMOV;", "if (std_caps & (1 << 23))\nVAR_0 |= AV_CPU_FLAG_MMX;", "if (std_caps & (1 << 25))\nVAR_0 |= AV_CPU_FLAG_MMXEXT;", "#if HAVE_SSE\nif (std_caps & (1 << 25))\nVAR_0 |= AV_CPU_FLAG_SSE;", "if (std_caps & (1 << 26))\nVAR_0 |= AV_CPU_FLAG_SSE2;", "if (ecx & 1)\nVAR_0 |= AV_CPU_FLAG_SSE3;", "if (ecx & 0x00000200 )\nVAR_0 |= AV_CPU_FLAG_SSSE3;", "if (ecx & 0x00080000 )\nVAR_0 |= AV_CPU_FLAG_SSE4;", "if (ecx & 0x00100000 )\nVAR_0 |= AV_CPU_FLAG_SSE42;", "#if HAVE_AVX\nif ((ecx & 0x18000000) == 0x18000000) {", "xgetbv(0, eax, edx);", "if ((eax & 0x6) == 0x6) {", "VAR_0 |= AV_CPU_FLAG_AVX;", "if (ecx & 0x00001000)\nVAR_0 |= AV_CPU_FLAG_FMA3;", "}", "}", "#endif\n#endif\n}", "if (max_std_level >= 7) {", "cpuid(7, eax, ebx, ecx, edx);", "#if HAVE_AVX2\nif (ebx & 0x00000020)\nVAR_0 |= AV_CPU_FLAG_AVX2;", "#endif\nif (ebx & 0x00000008) {", "VAR_0 |= AV_CPU_FLAG_BMI1;", "if (ebx & 0x00000100)\nVAR_0 |= AV_CPU_FLAG_BMI2;", "}", "}", "cpuid(0x80000000, max_ext_level, ebx, ecx, edx);", "if (max_ext_level >= 0x80000001) {", "cpuid(0x80000001, eax, ebx, ecx, ext_caps);", "if (ext_caps & (1U << 31))\nVAR_0 |= AV_CPU_FLAG_3DNOW;", "if (ext_caps & (1 << 30))\nVAR_0 |= AV_CPU_FLAG_3DNOWEXT;", "if (ext_caps & (1 << 23))\nVAR_0 |= AV_CPU_FLAG_MMX;", "if (ext_caps & (1 << 22))\nVAR_0 |= AV_CPU_FLAG_MMXEXT;", "if (!strncmp(vendor.c, \"AuthenticAMD\", 12) &&\nVAR_0 & AV_CPU_FLAG_SSE2 && !(ecx & 0x00000040)) {", "VAR_0 |= AV_CPU_FLAG_SSE2SLOW;", "}", "if (VAR_0 & AV_CPU_FLAG_AVX) {", "if (ecx & 0x00000800)\nVAR_0 |= AV_CPU_FLAG_XOP;", "if (ecx & 0x00010000)\nVAR_0 |= AV_CPU_FLAG_FMA4;", "}", "}", "if (!strncmp(vendor.c, \"GenuineIntel\", 12)) {", "if (family == 6 && (model == 9 || model == 13 || model == 14)) {", "if (VAR_0 & AV_CPU_FLAG_SSE2)\nVAR_0 ^= AV_CPU_FLAG_SSE2SLOW | AV_CPU_FLAG_SSE2;", "if (VAR_0 & AV_CPU_FLAG_SSE3)\nVAR_0 ^= AV_CPU_FLAG_SSE3SLOW | AV_CPU_FLAG_SSE3;", "}", "if (family == 6 && model == 28)\nVAR_0 |= AV_CPU_FLAG_ATOM;", "}", "#endif\nreturn VAR_0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23, 25 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45, 47 ], [ 49, 51 ], [ 53, 55, 57 ], [ 59, 61 ], [ 63, 65 ], [ 67, 69 ], [ 71, 73 ], [ 75, 77 ], [ 79, 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 101, 103, 105 ], [ 107 ], [ 109 ], [ 111, 113, 115 ], [ 117, 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 135 ], [ 139 ], [ 141 ], [ 143, 145 ], [ 147, 149 ], [ 151, 153 ], [ 155, 157 ], [ 175, 177 ], [ 179 ], [ 181 ], [ 189 ], [ 191, 193 ], [ 195, 197 ], [ 199 ], [ 201 ], [ 205 ], [ 207 ], [ 223, 225 ], [ 227, 229 ], [ 231 ], [ 243, 245 ], [ 247 ], [ 251, 255 ], [ 257 ] ]
454
static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size) { GetBitContext gb; int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0; int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0; int dts_flag = -1, cts_flag = -1; int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE; init_get_bits(&gb, buf, buf_size*8); if (sl->use_au_start) au_start_flag = get_bits1(&gb); if (sl->use_au_end) au_end_flag = get_bits1(&gb); if (!sl->use_au_start && !sl->use_au_end) au_start_flag = au_end_flag = 1; if (sl->ocr_len > 0) ocr_flag = get_bits1(&gb); if (sl->use_idle) idle_flag = get_bits1(&gb); if (sl->use_padding) padding_flag = get_bits1(&gb); if (padding_flag) padding_bits = get_bits(&gb, 3); if (!idle_flag && (!padding_flag || padding_bits != 0)) { if (sl->packet_seq_num_len) skip_bits_long(&gb, sl->packet_seq_num_len); if (sl->degr_prior_len) if (get_bits1(&gb)) skip_bits(&gb, sl->degr_prior_len); if (ocr_flag) skip_bits_long(&gb, sl->ocr_len); if (au_start_flag) { if (sl->use_rand_acc_pt) get_bits1(&gb); if (sl->au_seq_num_len > 0) skip_bits_long(&gb, sl->au_seq_num_len); if (sl->use_timestamps) { dts_flag = get_bits1(&gb); cts_flag = get_bits1(&gb); } } if (sl->inst_bitrate_len) inst_bitrate_flag = get_bits1(&gb); if (dts_flag == 1) dts = get_bits64(&gb, sl->timestamp_len); if (cts_flag == 1) cts = get_bits64(&gb, sl->timestamp_len); if (sl->au_len > 0) skip_bits_long(&gb, sl->au_len); if (inst_bitrate_flag) skip_bits_long(&gb, sl->inst_bitrate_len); } if (dts != AV_NOPTS_VALUE) pes->dts = dts; if (cts != AV_NOPTS_VALUE) pes->pts = cts; avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res); return (get_bits_count(&gb) + 7) >> 3; }
false
FFmpeg
41bdd4adc4ab90a5ef7d63050a4046fcba711365
static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size) { GetBitContext gb; int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0; int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0; int dts_flag = -1, cts_flag = -1; int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE; init_get_bits(&gb, buf, buf_size*8); if (sl->use_au_start) au_start_flag = get_bits1(&gb); if (sl->use_au_end) au_end_flag = get_bits1(&gb); if (!sl->use_au_start && !sl->use_au_end) au_start_flag = au_end_flag = 1; if (sl->ocr_len > 0) ocr_flag = get_bits1(&gb); if (sl->use_idle) idle_flag = get_bits1(&gb); if (sl->use_padding) padding_flag = get_bits1(&gb); if (padding_flag) padding_bits = get_bits(&gb, 3); if (!idle_flag && (!padding_flag || padding_bits != 0)) { if (sl->packet_seq_num_len) skip_bits_long(&gb, sl->packet_seq_num_len); if (sl->degr_prior_len) if (get_bits1(&gb)) skip_bits(&gb, sl->degr_prior_len); if (ocr_flag) skip_bits_long(&gb, sl->ocr_len); if (au_start_flag) { if (sl->use_rand_acc_pt) get_bits1(&gb); if (sl->au_seq_num_len > 0) skip_bits_long(&gb, sl->au_seq_num_len); if (sl->use_timestamps) { dts_flag = get_bits1(&gb); cts_flag = get_bits1(&gb); } } if (sl->inst_bitrate_len) inst_bitrate_flag = get_bits1(&gb); if (dts_flag == 1) dts = get_bits64(&gb, sl->timestamp_len); if (cts_flag == 1) cts = get_bits64(&gb, sl->timestamp_len); if (sl->au_len > 0) skip_bits_long(&gb, sl->au_len); if (inst_bitrate_flag) skip_bits_long(&gb, sl->inst_bitrate_len); } if (dts != AV_NOPTS_VALUE) pes->dts = dts; if (cts != AV_NOPTS_VALUE) pes->pts = cts; avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res); return (get_bits_count(&gb) + 7) >> 3; }
{ "code": [], "line_no": [] }
static int FUNC_0(PESContext *VAR_0, SLConfigDescr *VAR_1, const uint8_t *VAR_2, int VAR_3) { GetBitContext gb; int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0; int VAR_8 = 0, VAR_9 = 0, VAR_10 = 0; int VAR_11 = -1, VAR_12 = -1; int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE; init_get_bits(&gb, VAR_2, VAR_3*8); if (VAR_1->use_au_start) VAR_4 = get_bits1(&gb); if (VAR_1->use_au_end) VAR_5 = get_bits1(&gb); if (!VAR_1->use_au_start && !VAR_1->use_au_end) VAR_4 = VAR_5 = 1; if (VAR_1->ocr_len > 0) VAR_6 = get_bits1(&gb); if (VAR_1->use_idle) VAR_7 = get_bits1(&gb); if (VAR_1->use_padding) VAR_8 = get_bits1(&gb); if (VAR_8) VAR_9 = get_bits(&gb, 3); if (!VAR_7 && (!VAR_8 || VAR_9 != 0)) { if (VAR_1->packet_seq_num_len) skip_bits_long(&gb, VAR_1->packet_seq_num_len); if (VAR_1->degr_prior_len) if (get_bits1(&gb)) skip_bits(&gb, VAR_1->degr_prior_len); if (VAR_6) skip_bits_long(&gb, VAR_1->ocr_len); if (VAR_4) { if (VAR_1->use_rand_acc_pt) get_bits1(&gb); if (VAR_1->au_seq_num_len > 0) skip_bits_long(&gb, VAR_1->au_seq_num_len); if (VAR_1->use_timestamps) { VAR_11 = get_bits1(&gb); VAR_12 = get_bits1(&gb); } } if (VAR_1->inst_bitrate_len) VAR_10 = get_bits1(&gb); if (VAR_11 == 1) dts = get_bits64(&gb, VAR_1->timestamp_len); if (VAR_12 == 1) cts = get_bits64(&gb, VAR_1->timestamp_len); if (VAR_1->au_len > 0) skip_bits_long(&gb, VAR_1->au_len); if (VAR_10) skip_bits_long(&gb, VAR_1->inst_bitrate_len); } if (dts != AV_NOPTS_VALUE) VAR_0->dts = dts; if (cts != AV_NOPTS_VALUE) VAR_0->pts = cts; avpriv_set_pts_info(VAR_0->st, VAR_1->timestamp_len, 1, VAR_1->timestamp_res); return (get_bits_count(&gb) + 7) >> 3; }
[ "static int FUNC_0(PESContext *VAR_0, SLConfigDescr *VAR_1, const uint8_t *VAR_2, int VAR_3)\n{", "GetBitContext gb;", "int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7 = 0;", "int VAR_8 = 0, VAR_9 = 0, VAR_10 = 0;", "int VAR_11 = -1, VAR_12 = -1;", "int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE;", "init_get_bits(&gb, VAR_2, VAR_3*8);", "if (VAR_1->use_au_start)\nVAR_4 = get_bits1(&gb);", "if (VAR_1->use_au_end)\nVAR_5 = get_bits1(&gb);", "if (!VAR_1->use_au_start && !VAR_1->use_au_end)\nVAR_4 = VAR_5 = 1;", "if (VAR_1->ocr_len > 0)\nVAR_6 = get_bits1(&gb);", "if (VAR_1->use_idle)\nVAR_7 = get_bits1(&gb);", "if (VAR_1->use_padding)\nVAR_8 = get_bits1(&gb);", "if (VAR_8)\nVAR_9 = get_bits(&gb, 3);", "if (!VAR_7 && (!VAR_8 || VAR_9 != 0)) {", "if (VAR_1->packet_seq_num_len)\nskip_bits_long(&gb, VAR_1->packet_seq_num_len);", "if (VAR_1->degr_prior_len)\nif (get_bits1(&gb))\nskip_bits(&gb, VAR_1->degr_prior_len);", "if (VAR_6)\nskip_bits_long(&gb, VAR_1->ocr_len);", "if (VAR_4) {", "if (VAR_1->use_rand_acc_pt)\nget_bits1(&gb);", "if (VAR_1->au_seq_num_len > 0)\nskip_bits_long(&gb, VAR_1->au_seq_num_len);", "if (VAR_1->use_timestamps) {", "VAR_11 = get_bits1(&gb);", "VAR_12 = get_bits1(&gb);", "}", "}", "if (VAR_1->inst_bitrate_len)\nVAR_10 = get_bits1(&gb);", "if (VAR_11 == 1)\ndts = get_bits64(&gb, VAR_1->timestamp_len);", "if (VAR_12 == 1)\ncts = get_bits64(&gb, VAR_1->timestamp_len);", "if (VAR_1->au_len > 0)\nskip_bits_long(&gb, VAR_1->au_len);", "if (VAR_10)\nskip_bits_long(&gb, VAR_1->inst_bitrate_len);", "}", "if (dts != AV_NOPTS_VALUE)\nVAR_0->dts = dts;", "if (cts != AV_NOPTS_VALUE)\nVAR_0->pts = cts;", "avpriv_set_pts_info(VAR_0->st, VAR_1->timestamp_len, 1, VAR_1->timestamp_res);", "return (get_bits_count(&gb) + 7) >> 3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19, 21 ], [ 23, 25 ], [ 27, 29 ], [ 31, 33 ], [ 35, 37 ], [ 39, 41 ], [ 43, 45 ], [ 49 ], [ 51, 53 ], [ 55, 57, 59 ], [ 61, 63 ], [ 65 ], [ 67, 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 89, 91 ], [ 93, 95 ], [ 97, 99 ], [ 101, 103 ], [ 105 ], [ 109, 111 ], [ 113, 115 ], [ 119 ], [ 123 ], [ 125 ] ]
455
static enum AVHWDeviceType hw_device_match_type_in_name(const char *codec_name) { const char *type_name; enum AVHWDeviceType type; for (type = av_hwdevice_iterate_types(AV_HWDEVICE_TYPE_NONE); type != AV_HWDEVICE_TYPE_NONE; type = av_hwdevice_iterate_types(type)) { type_name = av_hwdevice_get_type_name(type); if (strstr(codec_name, type_name)) return type; } return AV_HWDEVICE_TYPE_NONE; }
false
FFmpeg
b0cd14fb1dab4b044f7fe6b53ac635409849de77
static enum AVHWDeviceType hw_device_match_type_in_name(const char *codec_name) { const char *type_name; enum AVHWDeviceType type; for (type = av_hwdevice_iterate_types(AV_HWDEVICE_TYPE_NONE); type != AV_HWDEVICE_TYPE_NONE; type = av_hwdevice_iterate_types(type)) { type_name = av_hwdevice_get_type_name(type); if (strstr(codec_name, type_name)) return type; } return AV_HWDEVICE_TYPE_NONE; }
{ "code": [], "line_no": [] }
static enum AVHWDeviceType FUNC_0(const char *VAR_0) { const char *VAR_1; enum AVHWDeviceType VAR_2; for (VAR_2 = av_hwdevice_iterate_types(AV_HWDEVICE_TYPE_NONE); VAR_2 != AV_HWDEVICE_TYPE_NONE; VAR_2 = av_hwdevice_iterate_types(VAR_2)) { VAR_1 = av_hwdevice_get_type_name(VAR_2); if (strstr(VAR_0, VAR_1)) return VAR_2; } return AV_HWDEVICE_TYPE_NONE; }
[ "static enum AVHWDeviceType FUNC_0(const char *VAR_0)\n{", "const char *VAR_1;", "enum AVHWDeviceType VAR_2;", "for (VAR_2 = av_hwdevice_iterate_types(AV_HWDEVICE_TYPE_NONE);", "VAR_2 != AV_HWDEVICE_TYPE_NONE;", "VAR_2 = av_hwdevice_iterate_types(VAR_2)) {", "VAR_1 = av_hwdevice_get_type_name(VAR_2);", "if (strstr(VAR_0, VAR_1))\nreturn VAR_2;", "}", "return AV_HWDEVICE_TYPE_NONE;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 25 ] ]
456
static av_cold int encode_close(AVCodecContext* avc_context) { TheoraContext *h = avc_context->priv_data; th_encode_free(h->t_state); av_freep(&h->stats); av_freep(&avc_context->coded_frame); av_freep(&avc_context->stats_out); av_freep(&avc_context->extradata); avc_context->extradata_size = 0; return 0; }
false
FFmpeg
d6604b29ef544793479d7fb4e05ef6622bb3e534
static av_cold int encode_close(AVCodecContext* avc_context) { TheoraContext *h = avc_context->priv_data; th_encode_free(h->t_state); av_freep(&h->stats); av_freep(&avc_context->coded_frame); av_freep(&avc_context->stats_out); av_freep(&avc_context->extradata); avc_context->extradata_size = 0; return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext* avc_context) { TheoraContext *h = avc_context->priv_data; th_encode_free(h->t_state); av_freep(&h->stats); av_freep(&avc_context->coded_frame); av_freep(&avc_context->stats_out); av_freep(&avc_context->extradata); avc_context->extradata_size = 0; return 0; }
[ "static av_cold int FUNC_0(AVCodecContext* avc_context)\n{", "TheoraContext *h = avc_context->priv_data;", "th_encode_free(h->t_state);", "av_freep(&h->stats);", "av_freep(&avc_context->coded_frame);", "av_freep(&avc_context->stats_out);", "av_freep(&avc_context->extradata);", "avc_context->extradata_size = 0;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ] ]
457
static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice) { VAAPIEncodeContext *ctx = avctx->priv_data; VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params; VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params; VAEncSliceParameterBufferH264 *vslice = slice->codec_slice_params; VAAPIEncodeH264Context *priv = ctx->priv_data; VAAPIEncodeH264Slice *pslice; VAAPIEncodeH264MiscSliceParams *mslice; int i; slice->priv_data = av_mallocz(sizeof(*pslice)); if (!slice->priv_data) return AVERROR(ENOMEM); pslice = slice->priv_data; mslice = &pslice->misc_slice_params; if (pic->type == PICTURE_TYPE_IDR) mslice->nal_unit_type = H264_NAL_IDR_SLICE; else mslice->nal_unit_type = H264_NAL_SLICE; switch (pic->type) { case PICTURE_TYPE_IDR: vslice->slice_type = SLICE_TYPE_I; mslice->nal_ref_idc = 3; break; case PICTURE_TYPE_I: vslice->slice_type = SLICE_TYPE_I; mslice->nal_ref_idc = 2; break; case PICTURE_TYPE_P: vslice->slice_type = SLICE_TYPE_P; mslice->nal_ref_idc = 1; break; case PICTURE_TYPE_B: vslice->slice_type = SLICE_TYPE_B; mslice->nal_ref_idc = 0; break; default: av_assert0(0 && "invalid picture type"); } // Only one slice per frame. vslice->macroblock_address = 0; vslice->num_macroblocks = priv->mb_width * priv->mb_height; vslice->macroblock_info = VA_INVALID_ID; vslice->pic_parameter_set_id = vpic->pic_parameter_set_id; vslice->idr_pic_id = priv->idr_pic_count++; vslice->pic_order_cnt_lsb = pic->display_order & ((1 << (4 + vseq->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4)) - 1); for (i = 0; i < FF_ARRAY_ELEMS(vslice->RefPicList0); i++) { vslice->RefPicList0[i].picture_id = VA_INVALID_ID; vslice->RefPicList0[i].flags = VA_PICTURE_H264_INVALID; vslice->RefPicList1[i].picture_id = VA_INVALID_ID; vslice->RefPicList1[i].flags = VA_PICTURE_H264_INVALID; } av_assert0(pic->nb_refs <= 2); if (pic->nb_refs >= 1) { // Backward reference for P- or B-frame. av_assert0(pic->type == PICTURE_TYPE_P || pic->type == PICTURE_TYPE_B); vslice->num_ref_idx_l0_active_minus1 = 0; vslice->RefPicList0[0] = vpic->ReferenceFrames[0]; } if (pic->nb_refs >= 2) { // Forward reference for B-frame. av_assert0(pic->type == PICTURE_TYPE_B); vslice->num_ref_idx_l1_active_minus1 = 0; vslice->RefPicList1[0] = vpic->ReferenceFrames[1]; } if (pic->type == PICTURE_TYPE_B) vslice->slice_qp_delta = priv->fixed_qp_b - vpic->pic_init_qp; else if (pic->type == PICTURE_TYPE_P) vslice->slice_qp_delta = priv->fixed_qp_p - vpic->pic_init_qp; else vslice->slice_qp_delta = priv->fixed_qp_idr - vpic->pic_init_qp; vslice->direct_spatial_mv_pred_flag = 1; return 0; }
false
FFmpeg
e72662e131e5099e34d5a7519c5690d2fff7b83f
static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice) { VAAPIEncodeContext *ctx = avctx->priv_data; VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params; VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params; VAEncSliceParameterBufferH264 *vslice = slice->codec_slice_params; VAAPIEncodeH264Context *priv = ctx->priv_data; VAAPIEncodeH264Slice *pslice; VAAPIEncodeH264MiscSliceParams *mslice; int i; slice->priv_data = av_mallocz(sizeof(*pslice)); if (!slice->priv_data) return AVERROR(ENOMEM); pslice = slice->priv_data; mslice = &pslice->misc_slice_params; if (pic->type == PICTURE_TYPE_IDR) mslice->nal_unit_type = H264_NAL_IDR_SLICE; else mslice->nal_unit_type = H264_NAL_SLICE; switch (pic->type) { case PICTURE_TYPE_IDR: vslice->slice_type = SLICE_TYPE_I; mslice->nal_ref_idc = 3; break; case PICTURE_TYPE_I: vslice->slice_type = SLICE_TYPE_I; mslice->nal_ref_idc = 2; break; case PICTURE_TYPE_P: vslice->slice_type = SLICE_TYPE_P; mslice->nal_ref_idc = 1; break; case PICTURE_TYPE_B: vslice->slice_type = SLICE_TYPE_B; mslice->nal_ref_idc = 0; break; default: av_assert0(0 && "invalid picture type"); } vslice->macroblock_address = 0; vslice->num_macroblocks = priv->mb_width * priv->mb_height; vslice->macroblock_info = VA_INVALID_ID; vslice->pic_parameter_set_id = vpic->pic_parameter_set_id; vslice->idr_pic_id = priv->idr_pic_count++; vslice->pic_order_cnt_lsb = pic->display_order & ((1 << (4 + vseq->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4)) - 1); for (i = 0; i < FF_ARRAY_ELEMS(vslice->RefPicList0); i++) { vslice->RefPicList0[i].picture_id = VA_INVALID_ID; vslice->RefPicList0[i].flags = VA_PICTURE_H264_INVALID; vslice->RefPicList1[i].picture_id = VA_INVALID_ID; vslice->RefPicList1[i].flags = VA_PICTURE_H264_INVALID; } av_assert0(pic->nb_refs <= 2); if (pic->nb_refs >= 1) { av_assert0(pic->type == PICTURE_TYPE_P || pic->type == PICTURE_TYPE_B); vslice->num_ref_idx_l0_active_minus1 = 0; vslice->RefPicList0[0] = vpic->ReferenceFrames[0]; } if (pic->nb_refs >= 2) { av_assert0(pic->type == PICTURE_TYPE_B); vslice->num_ref_idx_l1_active_minus1 = 0; vslice->RefPicList1[0] = vpic->ReferenceFrames[1]; } if (pic->type == PICTURE_TYPE_B) vslice->slice_qp_delta = priv->fixed_qp_b - vpic->pic_init_qp; else if (pic->type == PICTURE_TYPE_P) vslice->slice_qp_delta = priv->fixed_qp_p - vpic->pic_init_qp; else vslice->slice_qp_delta = priv->fixed_qp_idr - vpic->pic_init_qp; vslice->direct_spatial_mv_pred_flag = 1; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, VAAPIEncodePicture *VAR_1, VAAPIEncodeSlice *VAR_2) { VAAPIEncodeContext *ctx = VAR_0->priv_data; VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params; VAEncPictureParameterBufferH264 *vpic = VAR_1->codec_picture_params; VAEncSliceParameterBufferH264 *vslice = VAR_2->codec_slice_params; VAAPIEncodeH264Context *priv = ctx->priv_data; VAAPIEncodeH264Slice *pslice; VAAPIEncodeH264MiscSliceParams *mslice; int VAR_3; VAR_2->priv_data = av_mallocz(sizeof(*pslice)); if (!VAR_2->priv_data) return AVERROR(ENOMEM); pslice = VAR_2->priv_data; mslice = &pslice->misc_slice_params; if (VAR_1->type == PICTURE_TYPE_IDR) mslice->nal_unit_type = H264_NAL_IDR_SLICE; else mslice->nal_unit_type = H264_NAL_SLICE; switch (VAR_1->type) { case PICTURE_TYPE_IDR: vslice->slice_type = SLICE_TYPE_I; mslice->nal_ref_idc = 3; break; case PICTURE_TYPE_I: vslice->slice_type = SLICE_TYPE_I; mslice->nal_ref_idc = 2; break; case PICTURE_TYPE_P: vslice->slice_type = SLICE_TYPE_P; mslice->nal_ref_idc = 1; break; case PICTURE_TYPE_B: vslice->slice_type = SLICE_TYPE_B; mslice->nal_ref_idc = 0; break; default: av_assert0(0 && "invalid picture type"); } vslice->macroblock_address = 0; vslice->num_macroblocks = priv->mb_width * priv->mb_height; vslice->macroblock_info = VA_INVALID_ID; vslice->pic_parameter_set_id = vpic->pic_parameter_set_id; vslice->idr_pic_id = priv->idr_pic_count++; vslice->pic_order_cnt_lsb = VAR_1->display_order & ((1 << (4 + vseq->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4)) - 1); for (VAR_3 = 0; VAR_3 < FF_ARRAY_ELEMS(vslice->RefPicList0); VAR_3++) { vslice->RefPicList0[VAR_3].picture_id = VA_INVALID_ID; vslice->RefPicList0[VAR_3].flags = VA_PICTURE_H264_INVALID; vslice->RefPicList1[VAR_3].picture_id = VA_INVALID_ID; vslice->RefPicList1[VAR_3].flags = VA_PICTURE_H264_INVALID; } av_assert0(VAR_1->nb_refs <= 2); if (VAR_1->nb_refs >= 1) { av_assert0(VAR_1->type == PICTURE_TYPE_P || VAR_1->type == PICTURE_TYPE_B); vslice->num_ref_idx_l0_active_minus1 = 0; vslice->RefPicList0[0] = vpic->ReferenceFrames[0]; } if (VAR_1->nb_refs >= 2) { av_assert0(VAR_1->type == PICTURE_TYPE_B); vslice->num_ref_idx_l1_active_minus1 = 0; vslice->RefPicList1[0] = vpic->ReferenceFrames[1]; } if (VAR_1->type == PICTURE_TYPE_B) vslice->slice_qp_delta = priv->fixed_qp_b - vpic->pic_init_qp; else if (VAR_1->type == PICTURE_TYPE_P) vslice->slice_qp_delta = priv->fixed_qp_p - vpic->pic_init_qp; else vslice->slice_qp_delta = priv->fixed_qp_idr - vpic->pic_init_qp; vslice->direct_spatial_mv_pred_flag = 1; return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nVAAPIEncodePicture *VAR_1,\nVAAPIEncodeSlice *VAR_2)\n{", "VAAPIEncodeContext *ctx = VAR_0->priv_data;", "VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;", "VAEncPictureParameterBufferH264 *vpic = VAR_1->codec_picture_params;", "VAEncSliceParameterBufferH264 *vslice = VAR_2->codec_slice_params;", "VAAPIEncodeH264Context *priv = ctx->priv_data;", "VAAPIEncodeH264Slice *pslice;", "VAAPIEncodeH264MiscSliceParams *mslice;", "int VAR_3;", "VAR_2->priv_data = av_mallocz(sizeof(*pslice));", "if (!VAR_2->priv_data)\nreturn AVERROR(ENOMEM);", "pslice = VAR_2->priv_data;", "mslice = &pslice->misc_slice_params;", "if (VAR_1->type == PICTURE_TYPE_IDR)\nmslice->nal_unit_type = H264_NAL_IDR_SLICE;", "else\nmslice->nal_unit_type = H264_NAL_SLICE;", "switch (VAR_1->type) {", "case PICTURE_TYPE_IDR:\nvslice->slice_type = SLICE_TYPE_I;", "mslice->nal_ref_idc = 3;", "break;", "case PICTURE_TYPE_I:\nvslice->slice_type = SLICE_TYPE_I;", "mslice->nal_ref_idc = 2;", "break;", "case PICTURE_TYPE_P:\nvslice->slice_type = SLICE_TYPE_P;", "mslice->nal_ref_idc = 1;", "break;", "case PICTURE_TYPE_B:\nvslice->slice_type = SLICE_TYPE_B;", "mslice->nal_ref_idc = 0;", "break;", "default:\nav_assert0(0 && \"invalid picture type\");", "}", "vslice->macroblock_address = 0;", "vslice->num_macroblocks = priv->mb_width * priv->mb_height;", "vslice->macroblock_info = VA_INVALID_ID;", "vslice->pic_parameter_set_id = vpic->pic_parameter_set_id;", "vslice->idr_pic_id = priv->idr_pic_count++;", "vslice->pic_order_cnt_lsb = VAR_1->display_order &\n((1 << (4 + vseq->seq_fields.bits.log2_max_pic_order_cnt_lsb_minus4)) - 1);", "for (VAR_3 = 0; VAR_3 < FF_ARRAY_ELEMS(vslice->RefPicList0); VAR_3++) {", "vslice->RefPicList0[VAR_3].picture_id = VA_INVALID_ID;", "vslice->RefPicList0[VAR_3].flags = VA_PICTURE_H264_INVALID;", "vslice->RefPicList1[VAR_3].picture_id = VA_INVALID_ID;", "vslice->RefPicList1[VAR_3].flags = VA_PICTURE_H264_INVALID;", "}", "av_assert0(VAR_1->nb_refs <= 2);", "if (VAR_1->nb_refs >= 1) {", "av_assert0(VAR_1->type == PICTURE_TYPE_P ||\nVAR_1->type == PICTURE_TYPE_B);", "vslice->num_ref_idx_l0_active_minus1 = 0;", "vslice->RefPicList0[0] = vpic->ReferenceFrames[0];", "}", "if (VAR_1->nb_refs >= 2) {", "av_assert0(VAR_1->type == PICTURE_TYPE_B);", "vslice->num_ref_idx_l1_active_minus1 = 0;", "vslice->RefPicList1[0] = vpic->ReferenceFrames[1];", "}", "if (VAR_1->type == PICTURE_TYPE_B)\nvslice->slice_qp_delta = priv->fixed_qp_b - vpic->pic_init_qp;", "else if (VAR_1->type == PICTURE_TYPE_P)\nvslice->slice_qp_delta = priv->fixed_qp_p - vpic->pic_init_qp;", "else\nvslice->slice_qp_delta = priv->fixed_qp_idr - vpic->pic_init_qp;", "vslice->direct_spatial_mv_pred_flag = 1;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 39, 41 ], [ 43, 45 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67, 69 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 93 ], [ 95 ], [ 99 ], [ 103 ], [ 105 ], [ 109, 111 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 135, 137 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 155 ], [ 157 ], [ 159 ], [ 163, 165 ], [ 167, 169 ], [ 171, 173 ], [ 177 ], [ 181 ], [ 183 ] ]
458
static char *assign_name(NetClientState *nc1, const char *model) { NetClientState *nc; char buf[256]; int id = 0; QTAILQ_FOREACH(nc, &net_clients, next) { if (nc == nc1) { continue; } /* For compatibility only bump id for net clients on a vlan */ if (strcmp(nc->model, model) == 0 && net_hub_id_for_client(nc, NULL) == 0) { id++; } } snprintf(buf, sizeof(buf), "%s.%d", model, id); return g_strdup(buf); }
false
qemu
c963530a5b3e3e0f7304841adfe84416d82f59f6
static char *assign_name(NetClientState *nc1, const char *model) { NetClientState *nc; char buf[256]; int id = 0; QTAILQ_FOREACH(nc, &net_clients, next) { if (nc == nc1) { continue; } if (strcmp(nc->model, model) == 0 && net_hub_id_for_client(nc, NULL) == 0) { id++; } } snprintf(buf, sizeof(buf), "%s.%d", model, id); return g_strdup(buf); }
{ "code": [], "line_no": [] }
static char *FUNC_0(NetClientState *VAR_0, const char *VAR_1) { NetClientState *nc; char VAR_2[256]; int VAR_3 = 0; QTAILQ_FOREACH(nc, &net_clients, next) { if (nc == VAR_0) { continue; } if (strcmp(nc->VAR_1, VAR_1) == 0 && net_hub_id_for_client(nc, NULL) == 0) { VAR_3++; } } snprintf(VAR_2, sizeof(VAR_2), "%s.%d", VAR_1, VAR_3); return g_strdup(VAR_2); }
[ "static char *FUNC_0(NetClientState *VAR_0, const char *VAR_1)\n{", "NetClientState *nc;", "char VAR_2[256];", "int VAR_3 = 0;", "QTAILQ_FOREACH(nc, &net_clients, next) {", "if (nc == VAR_0) {", "continue;", "}", "if (strcmp(nc->VAR_1, VAR_1) == 0 &&\nnet_hub_id_for_client(nc, NULL) == 0) {", "VAR_3++;", "}", "}", "snprintf(VAR_2, sizeof(VAR_2), \"%s.%d\", VAR_1, VAR_3);", "return g_strdup(VAR_2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 39 ], [ 41 ] ]
459
static void nbd_accept(void *opaque) { int server_fd = (uintptr_t) opaque; struct sockaddr_in addr; socklen_t addr_len = sizeof(addr); int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len); nbd_started = true; if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) { nb_fds++; } }
false
qemu
7860a380ac2a9fd09a6e8f31fd9db5318fc91285
static void nbd_accept(void *opaque) { int server_fd = (uintptr_t) opaque; struct sockaddr_in addr; socklen_t addr_len = sizeof(addr); int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len); nbd_started = true; if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) { nb_fds++; } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { int VAR_1 = (uintptr_t) VAR_0; struct sockaddr_in VAR_2; socklen_t addr_len = sizeof(VAR_2); int VAR_3 = accept(VAR_1, (struct sockaddr *)&VAR_2, &addr_len); nbd_started = true; if (VAR_3 >= 0 && nbd_client_new(exp, VAR_3, nbd_client_closed)) { nb_fds++; } }
[ "static void FUNC_0(void *VAR_0)\n{", "int VAR_1 = (uintptr_t) VAR_0;", "struct sockaddr_in VAR_2;", "socklen_t addr_len = sizeof(VAR_2);", "int VAR_3 = accept(VAR_1, (struct sockaddr *)&VAR_2, &addr_len);", "nbd_started = true;", "if (VAR_3 >= 0 && nbd_client_new(exp, VAR_3, nbd_client_closed)) {", "nb_fds++;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
460
static void dma_init2(struct dma_cont *d, int base, int dshift, int page_base, int pageh_base, qemu_irq *cpu_request_exit) { int i; d->dshift = dshift; d->cpu_request_exit = cpu_request_exit; memory_region_init_io(&d->channel_io, NULL, &channel_io_ops, d, "dma-chan", 8 << d->dshift); memory_region_add_subregion(isa_address_space_io(NULL), base, &d->channel_io); isa_register_portio_list(NULL, page_base, page_portio_list, d, "dma-page"); if (pageh_base >= 0) { isa_register_portio_list(NULL, pageh_base, pageh_portio_list, d, "dma-pageh"); } memory_region_init_io(&d->cont_io, NULL, &cont_io_ops, d, "dma-cont", 8 << d->dshift); memory_region_add_subregion(isa_address_space_io(NULL), base + (8 << d->dshift), &d->cont_io); qemu_register_reset(dma_reset, d); dma_reset(d); for (i = 0; i < ARRAY_SIZE (d->regs); ++i) { d->regs[i].transfer_handler = dma_phony_handler; } }
false
qemu
5039d6e23586fe6bbedc5e4fe302b48a66890ade
static void dma_init2(struct dma_cont *d, int base, int dshift, int page_base, int pageh_base, qemu_irq *cpu_request_exit) { int i; d->dshift = dshift; d->cpu_request_exit = cpu_request_exit; memory_region_init_io(&d->channel_io, NULL, &channel_io_ops, d, "dma-chan", 8 << d->dshift); memory_region_add_subregion(isa_address_space_io(NULL), base, &d->channel_io); isa_register_portio_list(NULL, page_base, page_portio_list, d, "dma-page"); if (pageh_base >= 0) { isa_register_portio_list(NULL, pageh_base, pageh_portio_list, d, "dma-pageh"); } memory_region_init_io(&d->cont_io, NULL, &cont_io_ops, d, "dma-cont", 8 << d->dshift); memory_region_add_subregion(isa_address_space_io(NULL), base + (8 << d->dshift), &d->cont_io); qemu_register_reset(dma_reset, d); dma_reset(d); for (i = 0; i < ARRAY_SIZE (d->regs); ++i) { d->regs[i].transfer_handler = dma_phony_handler; } }
{ "code": [], "line_no": [] }
static void FUNC_0(struct dma_cont *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, qemu_irq *VAR_5) { int VAR_6; VAR_0->VAR_2 = VAR_2; VAR_0->VAR_5 = VAR_5; memory_region_init_io(&VAR_0->channel_io, NULL, &channel_io_ops, VAR_0, "dma-chan", 8 << VAR_0->VAR_2); memory_region_add_subregion(isa_address_space_io(NULL), VAR_1, &VAR_0->channel_io); isa_register_portio_list(NULL, VAR_3, page_portio_list, VAR_0, "dma-page"); if (VAR_4 >= 0) { isa_register_portio_list(NULL, VAR_4, pageh_portio_list, VAR_0, "dma-pageh"); } memory_region_init_io(&VAR_0->cont_io, NULL, &cont_io_ops, VAR_0, "dma-cont", 8 << VAR_0->VAR_2); memory_region_add_subregion(isa_address_space_io(NULL), VAR_1 + (8 << VAR_0->VAR_2), &VAR_0->cont_io); qemu_register_reset(dma_reset, VAR_0); dma_reset(VAR_0); for (VAR_6 = 0; VAR_6 < ARRAY_SIZE (VAR_0->regs); ++VAR_6) { VAR_0->regs[VAR_6].transfer_handler = dma_phony_handler; } }
[ "static void FUNC_0(struct dma_cont *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4,\nqemu_irq *VAR_5)\n{", "int VAR_6;", "VAR_0->VAR_2 = VAR_2;", "VAR_0->VAR_5 = VAR_5;", "memory_region_init_io(&VAR_0->channel_io, NULL, &channel_io_ops, VAR_0,\n\"dma-chan\", 8 << VAR_0->VAR_2);", "memory_region_add_subregion(isa_address_space_io(NULL),\nVAR_1, &VAR_0->channel_io);", "isa_register_portio_list(NULL, VAR_3, page_portio_list, VAR_0,\n\"dma-page\");", "if (VAR_4 >= 0) {", "isa_register_portio_list(NULL, VAR_4, pageh_portio_list, VAR_0,\n\"dma-pageh\");", "}", "memory_region_init_io(&VAR_0->cont_io, NULL, &cont_io_ops, VAR_0, \"dma-cont\",\n8 << VAR_0->VAR_2);", "memory_region_add_subregion(isa_address_space_io(NULL),\nVAR_1 + (8 << VAR_0->VAR_2), &VAR_0->cont_io);", "qemu_register_reset(dma_reset, VAR_0);", "dma_reset(VAR_0);", "for (VAR_6 = 0; VAR_6 < ARRAY_SIZE (VAR_0->regs); ++VAR_6) {", "VAR_0->regs[VAR_6].transfer_handler = dma_phony_handler;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19, 21 ], [ 23, 25 ], [ 29, 31 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 43, 45 ], [ 47, 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ] ]
462
static inline bool migration_bitmap_test_and_reset_dirty(MemoryRegion *mr, ram_addr_t offset) { bool ret; int nr = (mr->ram_addr + offset) >> TARGET_PAGE_BITS; ret = test_and_clear_bit(nr, migration_bitmap); if (ret) { migration_dirty_pages--; } return ret; }
false
qemu
4c8ae0f60e63478aea0a1741cca95474b68fb949
static inline bool migration_bitmap_test_and_reset_dirty(MemoryRegion *mr, ram_addr_t offset) { bool ret; int nr = (mr->ram_addr + offset) >> TARGET_PAGE_BITS; ret = test_and_clear_bit(nr, migration_bitmap); if (ret) { migration_dirty_pages--; } return ret; }
{ "code": [], "line_no": [] }
static inline bool FUNC_0(MemoryRegion *mr, ram_addr_t offset) { bool ret; int VAR_0 = (mr->ram_addr + offset) >> TARGET_PAGE_BITS; ret = test_and_clear_bit(VAR_0, migration_bitmap); if (ret) { migration_dirty_pages--; } return ret; }
[ "static inline bool FUNC_0(MemoryRegion *mr,\nram_addr_t offset)\n{", "bool ret;", "int VAR_0 = (mr->ram_addr + offset) >> TARGET_PAGE_BITS;", "ret = test_and_clear_bit(VAR_0, migration_bitmap);", "if (ret) {", "migration_dirty_pages--;", "}", "return ret;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
463
static inline void gen_op_eval_bge(TCGv dst, TCGv_i32 src) { gen_mov_reg_V(cpu_tmp0, src); gen_mov_reg_N(dst, src); tcg_gen_xor_tl(dst, dst, cpu_tmp0); tcg_gen_xori_tl(dst, dst, 0x1); }
false
qemu
de9e9d9f17a36ff76c1a02a5348835e5e0a081b0
static inline void gen_op_eval_bge(TCGv dst, TCGv_i32 src) { gen_mov_reg_V(cpu_tmp0, src); gen_mov_reg_N(dst, src); tcg_gen_xor_tl(dst, dst, cpu_tmp0); tcg_gen_xori_tl(dst, dst, 0x1); }
{ "code": [], "line_no": [] }
static inline void FUNC_0(TCGv VAR_0, TCGv_i32 VAR_1) { gen_mov_reg_V(cpu_tmp0, VAR_1); gen_mov_reg_N(VAR_0, VAR_1); tcg_gen_xor_tl(VAR_0, VAR_0, cpu_tmp0); tcg_gen_xori_tl(VAR_0, VAR_0, 0x1); }
[ "static inline void FUNC_0(TCGv VAR_0, TCGv_i32 VAR_1)\n{", "gen_mov_reg_V(cpu_tmp0, VAR_1);", "gen_mov_reg_N(VAR_0, VAR_1);", "tcg_gen_xor_tl(VAR_0, VAR_0, cpu_tmp0);", "tcg_gen_xori_tl(VAR_0, VAR_0, 0x1);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
464
static int qcow_set_key(BlockDriverState *bs, const char *key) { BDRVQcowState *s = bs->opaque; uint8_t keybuf[16]; int len, i; Error *err; memset(keybuf, 0, 16); len = strlen(key); if (len > 16) len = 16; /* XXX: we could compress the chars to 7 bits to increase entropy */ for(i = 0;i < len;i++) { keybuf[i] = key[i]; } assert(bs->encrypted); qcrypto_cipher_free(s->cipher); s->cipher = qcrypto_cipher_new( QCRYPTO_CIPHER_ALG_AES_128, QCRYPTO_CIPHER_MODE_CBC, keybuf, G_N_ELEMENTS(keybuf), &err); if (!s->cipher) { /* XXX would be nice if errors in this method could * be properly propagate to the caller. Would need * the bdrv_set_key() API signature to be fixed. */ error_free(err); return -1; } return 0; }
false
qemu
d85f4222b4681da7ebf8a90b26e085a68fa2c55a
static int qcow_set_key(BlockDriverState *bs, const char *key) { BDRVQcowState *s = bs->opaque; uint8_t keybuf[16]; int len, i; Error *err; memset(keybuf, 0, 16); len = strlen(key); if (len > 16) len = 16; for(i = 0;i < len;i++) { keybuf[i] = key[i]; } assert(bs->encrypted); qcrypto_cipher_free(s->cipher); s->cipher = qcrypto_cipher_new( QCRYPTO_CIPHER_ALG_AES_128, QCRYPTO_CIPHER_MODE_CBC, keybuf, G_N_ELEMENTS(keybuf), &err); if (!s->cipher) { error_free(err); return -1; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1) { BDRVQcowState *s = VAR_0->opaque; uint8_t keybuf[16]; int VAR_2, VAR_3; Error *err; memset(keybuf, 0, 16); VAR_2 = strlen(VAR_1); if (VAR_2 > 16) VAR_2 = 16; for(VAR_3 = 0;VAR_3 < VAR_2;VAR_3++) { keybuf[VAR_3] = VAR_1[VAR_3]; } assert(VAR_0->encrypted); qcrypto_cipher_free(s->cipher); s->cipher = qcrypto_cipher_new( QCRYPTO_CIPHER_ALG_AES_128, QCRYPTO_CIPHER_MODE_CBC, keybuf, G_N_ELEMENTS(keybuf), &err); if (!s->cipher) { error_free(err); return -1; } return 0; }
[ "static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1)\n{", "BDRVQcowState *s = VAR_0->opaque;", "uint8_t keybuf[16];", "int VAR_2, VAR_3;", "Error *err;", "memset(keybuf, 0, 16);", "VAR_2 = strlen(VAR_1);", "if (VAR_2 > 16)\nVAR_2 = 16;", "for(VAR_3 = 0;VAR_3 < VAR_2;VAR_3++) {", "keybuf[VAR_3] = VAR_1[VAR_3];", "}", "assert(VAR_0->encrypted);", "qcrypto_cipher_free(s->cipher);", "s->cipher = qcrypto_cipher_new(\nQCRYPTO_CIPHER_ALG_AES_128,\nQCRYPTO_CIPHER_MODE_CBC,\nkeybuf, G_N_ELEMENTS(keybuf),\n&err);", "if (!s->cipher) {", "error_free(err);", "return -1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39, 41, 43, 45, 47 ], [ 51 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ] ]
465
int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, bool force) { uint64_t features; int r; if (devfd >= 0) { hdev->control = devfd; } else { hdev->control = open(devpath, O_RDWR); if (hdev->control < 0) { return -errno; } } r = ioctl(hdev->control, VHOST_SET_OWNER, NULL); if (r < 0) { goto fail; } r = ioctl(hdev->control, VHOST_GET_FEATURES, &features); if (r < 0) { goto fail; } hdev->features = features; hdev->memory_listener = (MemoryListener) { .begin = vhost_begin, .commit = vhost_commit, .region_add = vhost_region_add, .region_del = vhost_region_del, .region_nop = vhost_region_nop, .log_start = vhost_log_start, .log_stop = vhost_log_stop, .log_sync = vhost_log_sync, .log_global_start = vhost_log_global_start, .log_global_stop = vhost_log_global_stop, .eventfd_add = vhost_eventfd_add, .eventfd_del = vhost_eventfd_del, .priority = 10 }; hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions)); hdev->n_mem_sections = 0; hdev->mem_sections = NULL; hdev->log = NULL; hdev->log_size = 0; hdev->log_enabled = false; hdev->started = false; memory_listener_register(&hdev->memory_listener, NULL); hdev->force = force; return 0; fail: r = -errno; close(hdev->control); return r; }
false
qemu
0fada67420e29f389119ca6f44285203400e0730
int vhost_dev_init(struct vhost_dev *hdev, int devfd, const char *devpath, bool force) { uint64_t features; int r; if (devfd >= 0) { hdev->control = devfd; } else { hdev->control = open(devpath, O_RDWR); if (hdev->control < 0) { return -errno; } } r = ioctl(hdev->control, VHOST_SET_OWNER, NULL); if (r < 0) { goto fail; } r = ioctl(hdev->control, VHOST_GET_FEATURES, &features); if (r < 0) { goto fail; } hdev->features = features; hdev->memory_listener = (MemoryListener) { .begin = vhost_begin, .commit = vhost_commit, .region_add = vhost_region_add, .region_del = vhost_region_del, .region_nop = vhost_region_nop, .log_start = vhost_log_start, .log_stop = vhost_log_stop, .log_sync = vhost_log_sync, .log_global_start = vhost_log_global_start, .log_global_stop = vhost_log_global_stop, .eventfd_add = vhost_eventfd_add, .eventfd_del = vhost_eventfd_del, .priority = 10 }; hdev->mem = g_malloc0(offsetof(struct vhost_memory, regions)); hdev->n_mem_sections = 0; hdev->mem_sections = NULL; hdev->log = NULL; hdev->log_size = 0; hdev->log_enabled = false; hdev->started = false; memory_listener_register(&hdev->memory_listener, NULL); hdev->force = force; return 0; fail: r = -errno; close(hdev->control); return r; }
{ "code": [], "line_no": [] }
int FUNC_0(struct vhost_dev *VAR_0, int VAR_1, const char *VAR_2, bool VAR_3) { uint64_t features; int VAR_4; if (VAR_1 >= 0) { VAR_0->control = VAR_1; } else { VAR_0->control = open(VAR_2, O_RDWR); if (VAR_0->control < 0) { return -errno; } } VAR_4 = ioctl(VAR_0->control, VHOST_SET_OWNER, NULL); if (VAR_4 < 0) { goto fail; } VAR_4 = ioctl(VAR_0->control, VHOST_GET_FEATURES, &features); if (VAR_4 < 0) { goto fail; } VAR_0->features = features; VAR_0->memory_listener = (MemoryListener) { .begin = vhost_begin, .commit = vhost_commit, .region_add = vhost_region_add, .region_del = vhost_region_del, .region_nop = vhost_region_nop, .log_start = vhost_log_start, .log_stop = vhost_log_stop, .log_sync = vhost_log_sync, .log_global_start = vhost_log_global_start, .log_global_stop = vhost_log_global_stop, .eventfd_add = vhost_eventfd_add, .eventfd_del = vhost_eventfd_del, .priority = 10 }; VAR_0->mem = g_malloc0(offsetof(struct vhost_memory, regions)); VAR_0->n_mem_sections = 0; VAR_0->mem_sections = NULL; VAR_0->log = NULL; VAR_0->log_size = 0; VAR_0->log_enabled = false; VAR_0->started = false; memory_listener_register(&VAR_0->memory_listener, NULL); VAR_0->VAR_3 = VAR_3; return 0; fail: VAR_4 = -errno; close(VAR_0->control); return VAR_4; }
[ "int FUNC_0(struct vhost_dev *VAR_0, int VAR_1, const char *VAR_2,\nbool VAR_3)\n{", "uint64_t features;", "int VAR_4;", "if (VAR_1 >= 0) {", "VAR_0->control = VAR_1;", "} else {", "VAR_0->control = open(VAR_2, O_RDWR);", "if (VAR_0->control < 0) {", "return -errno;", "}", "}", "VAR_4 = ioctl(VAR_0->control, VHOST_SET_OWNER, NULL);", "if (VAR_4 < 0) {", "goto fail;", "}", "VAR_4 = ioctl(VAR_0->control, VHOST_GET_FEATURES, &features);", "if (VAR_4 < 0) {", "goto fail;", "}", "VAR_0->features = features;", "VAR_0->memory_listener = (MemoryListener) {", ".begin = vhost_begin,\n.commit = vhost_commit,\n.region_add = vhost_region_add,\n.region_del = vhost_region_del,\n.region_nop = vhost_region_nop,\n.log_start = vhost_log_start,\n.log_stop = vhost_log_stop,\n.log_sync = vhost_log_sync,\n.log_global_start = vhost_log_global_start,\n.log_global_stop = vhost_log_global_stop,\n.eventfd_add = vhost_eventfd_add,\n.eventfd_del = vhost_eventfd_del,\n.priority = 10\n};", "VAR_0->mem = g_malloc0(offsetof(struct vhost_memory, regions));", "VAR_0->n_mem_sections = 0;", "VAR_0->mem_sections = NULL;", "VAR_0->log = NULL;", "VAR_0->log_size = 0;", "VAR_0->log_enabled = false;", "VAR_0->started = false;", "memory_listener_register(&VAR_0->memory_listener, NULL);", "VAR_0->VAR_3 = VAR_3;", "return 0;", "fail:\nVAR_4 = -errno;", "close(VAR_0->control);", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ] ]
466
static void fw_cfg_mem_realize(DeviceState *dev, Error **errp) { FWCfgMemState *s = FW_CFG_MEM(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); memory_region_init_io(&s->ctl_iomem, OBJECT(s), &fw_cfg_ctl_mem_ops, FW_CFG(s), "fwcfg.ctl", FW_CFG_SIZE); sysbus_init_mmio(sbd, &s->ctl_iomem); memory_region_init_io(&s->data_iomem, OBJECT(s), &fw_cfg_data_mem_ops, FW_CFG(s), "fwcfg.data", fw_cfg_data_mem_ops.valid.max_access_size); sysbus_init_mmio(sbd, &s->data_iomem); }
false
qemu
cfaadf0e89e7c2a47462d5f96390c9a9b4de037c
static void fw_cfg_mem_realize(DeviceState *dev, Error **errp) { FWCfgMemState *s = FW_CFG_MEM(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); memory_region_init_io(&s->ctl_iomem, OBJECT(s), &fw_cfg_ctl_mem_ops, FW_CFG(s), "fwcfg.ctl", FW_CFG_SIZE); sysbus_init_mmio(sbd, &s->ctl_iomem); memory_region_init_io(&s->data_iomem, OBJECT(s), &fw_cfg_data_mem_ops, FW_CFG(s), "fwcfg.data", fw_cfg_data_mem_ops.valid.max_access_size); sysbus_init_mmio(sbd, &s->data_iomem); }
{ "code": [], "line_no": [] }
static void FUNC_0(DeviceState *VAR_0, Error **VAR_1) { FWCfgMemState *s = FW_CFG_MEM(VAR_0); SysBusDevice *sbd = SYS_BUS_DEVICE(VAR_0); memory_region_init_io(&s->ctl_iomem, OBJECT(s), &fw_cfg_ctl_mem_ops, FW_CFG(s), "fwcfg.ctl", FW_CFG_SIZE); sysbus_init_mmio(sbd, &s->ctl_iomem); memory_region_init_io(&s->data_iomem, OBJECT(s), &fw_cfg_data_mem_ops, FW_CFG(s), "fwcfg.data", fw_cfg_data_mem_ops.valid.max_access_size); sysbus_init_mmio(sbd, &s->data_iomem); }
[ "static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{", "FWCfgMemState *s = FW_CFG_MEM(VAR_0);", "SysBusDevice *sbd = SYS_BUS_DEVICE(VAR_0);", "memory_region_init_io(&s->ctl_iomem, OBJECT(s), &fw_cfg_ctl_mem_ops,\nFW_CFG(s), \"fwcfg.ctl\", FW_CFG_SIZE);", "sysbus_init_mmio(sbd, &s->ctl_iomem);", "memory_region_init_io(&s->data_iomem, OBJECT(s), &fw_cfg_data_mem_ops,\nFW_CFG(s), \"fwcfg.data\",\nfw_cfg_data_mem_ops.valid.max_access_size);", "sysbus_init_mmio(sbd, &s->data_iomem);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 15 ], [ 19, 21, 23 ], [ 25 ], [ 27 ] ]
467
static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int partIdx) { #define POS(c_idx, x, y) \ &s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \ (((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)] HEVCLocalContext *lc = &s->HEVClc; int merge_idx = 0; struct MvField current_mv = {{{ 0 }}}; int min_pu_width = s->sps->min_pu_width; MvField *tab_mvf = s->ref->tab_mvf; RefPicList *refPicList = s->ref->refPicList; HEVCFrame *ref0, *ref1; int tmpstride = MAX_PB_SIZE; uint8_t *dst0 = POS(0, x0, y0); uint8_t *dst1 = POS(1, x0, y0); uint8_t *dst2 = POS(2, x0, y0); int log2_min_cb_size = s->sps->log2_min_cb_size; int min_cb_width = s->sps->min_cb_width; int x_cb = x0 >> log2_min_cb_size; int y_cb = y0 >> log2_min_cb_size; int x_pu, y_pu; int i, j; int skip_flag = SAMPLE_CTB(s->skip_flag, x_cb, y_cb); if (!skip_flag) lc->pu.merge_flag = ff_hevc_merge_flag_decode(s); if (skip_flag || lc->pu.merge_flag) { if (s->sh.max_num_merge_cand > 1) merge_idx = ff_hevc_merge_idx_decode(s); else merge_idx = 0; ff_hevc_luma_mv_merge_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, partIdx, merge_idx, &current_mv); } else { enum InterPredIdc inter_pred_idc = PRED_L0; int mvp_flag; ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH); if (s->sh.slice_type == B_SLICE) inter_pred_idc = ff_hevc_inter_pred_idc_decode(s, nPbW, nPbH); if (inter_pred_idc != PRED_L1) { if (s->sh.nb_refs[L0]) { current_mv.ref_idx[0]= ff_hevc_ref_idx_lx_decode(s, s->sh.nb_refs[L0]); } current_mv.pred_flag[0] = 1; hls_mvd_coding(s, x0, y0, 0); mvp_flag = ff_hevc_mvp_lx_flag_decode(s); ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, partIdx, merge_idx, &current_mv, mvp_flag, 0); current_mv.mv[0].x += lc->pu.mvd.x; current_mv.mv[0].y += lc->pu.mvd.y; } if (inter_pred_idc != PRED_L0) { if (s->sh.nb_refs[L1]) { current_mv.ref_idx[1]= ff_hevc_ref_idx_lx_decode(s, s->sh.nb_refs[L1]); } if (s->sh.mvd_l1_zero_flag == 1 && inter_pred_idc == PRED_BI) { AV_ZERO32(&lc->pu.mvd); } else { hls_mvd_coding(s, x0, y0, 1); } current_mv.pred_flag[1] = 1; mvp_flag = ff_hevc_mvp_lx_flag_decode(s); ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, partIdx, merge_idx, &current_mv, mvp_flag, 1); current_mv.mv[1].x += lc->pu.mvd.x; current_mv.mv[1].y += lc->pu.mvd.y; } } x_pu = x0 >> s->sps->log2_min_pu_size; y_pu = y0 >> s->sps->log2_min_pu_size; for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++) for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++) tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; if (current_mv.pred_flag[0]) { ref0 = refPicList[0].ref[current_mv.ref_idx[0]]; if (!ref0) return; hevc_await_progress(s, ref0, &current_mv.mv[0], y0, nPbH); } if (current_mv.pred_flag[1]) { ref1 = refPicList[1].ref[current_mv.ref_idx[1]]; if (!ref1) return; hevc_await_progress(s, ref1, &current_mv.mv[1], y0, nPbH); } if (current_mv.pred_flag[0] && !current_mv.pred_flag[1]) { DECLARE_ALIGNED(16, int16_t, tmp[MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]); luma_mc(s, tmp, tmpstride, ref0->frame, &current_mv.mv[0], x0, y0, nPbW, nPbH); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred(s->sh.luma_log2_weight_denom, s->sh.luma_weight_l0[current_mv.ref_idx[0]], s->sh.luma_offset_l0[current_mv.ref_idx[0]], dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH); } else { s->hevcdsp.put_unweighted_pred(dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH); } chroma_mc(s, tmp, tmp2, tmpstride, ref0->frame, &current_mv.mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0], dst1, s->frame->linesize[1], tmp, tmpstride, nPbW / 2, nPbH / 2); s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1], dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW / 2, nPbH / 2); } else { s->hevcdsp.put_unweighted_pred(dst1, s->frame->linesize[1], tmp, tmpstride, nPbW/2, nPbH/2); s->hevcdsp.put_unweighted_pred(dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2); } } else if (!current_mv.pred_flag[0] && current_mv.pred_flag[1]) { DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]); if (!ref1) return; luma_mc(s, tmp, tmpstride, ref1->frame, &current_mv.mv[1], x0, y0, nPbW, nPbH); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred(s->sh.luma_log2_weight_denom, s->sh.luma_weight_l1[current_mv.ref_idx[1]], s->sh.luma_offset_l1[current_mv.ref_idx[1]], dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH); } else { s->hevcdsp.put_unweighted_pred(dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH); } chroma_mc(s, tmp, tmp2, tmpstride, ref1->frame, &current_mv.mv[1], x0/2, y0/2, nPbW/2, nPbH/2); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0], dst1, s->frame->linesize[1], tmp, tmpstride, nPbW/2, nPbH/2); s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1], dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2); } else { s->hevcdsp.put_unweighted_pred(dst1, s->frame->linesize[1], tmp, tmpstride, nPbW/2, nPbH/2); s->hevcdsp.put_unweighted_pred(dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2); } } else if (current_mv.pred_flag[0] && current_mv.pred_flag[1]) { DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp3[MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp4[MAX_PB_SIZE * MAX_PB_SIZE]); HEVCFrame *ref0 = refPicList[0].ref[current_mv.ref_idx[0]]; HEVCFrame *ref1 = refPicList[1].ref[current_mv.ref_idx[1]]; if (!ref0 || !ref1) return; luma_mc(s, tmp, tmpstride, ref0->frame, &current_mv.mv[0], x0, y0, nPbW, nPbH); luma_mc(s, tmp2, tmpstride, ref1->frame, &current_mv.mv[1], x0, y0, nPbW, nPbH); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred_avg(s->sh.luma_log2_weight_denom, s->sh.luma_weight_l0[current_mv.ref_idx[0]], s->sh.luma_weight_l1[current_mv.ref_idx[1]], s->sh.luma_offset_l0[current_mv.ref_idx[0]], s->sh.luma_offset_l1[current_mv.ref_idx[1]], dst0, s->frame->linesize[0], tmp, tmp2, tmpstride, nPbW, nPbH); } else { s->hevcdsp.put_weighted_pred_avg(dst0, s->frame->linesize[0], tmp, tmp2, tmpstride, nPbW, nPbH); } chroma_mc(s, tmp, tmp2, tmpstride, ref0->frame, &current_mv.mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2); chroma_mc(s, tmp3, tmp4, tmpstride, ref1->frame, &current_mv.mv[1], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred_avg(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0], dst1, s->frame->linesize[1], tmp, tmp3, tmpstride, nPbW / 2, nPbH / 2); s->hevcdsp.weighted_pred_avg(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1], dst2, s->frame->linesize[2], tmp2, tmp4, tmpstride, nPbW / 2, nPbH / 2); } else { s->hevcdsp.put_weighted_pred_avg(dst1, s->frame->linesize[1], tmp, tmp3, tmpstride, nPbW/2, nPbH/2); s->hevcdsp.put_weighted_pred_avg(dst2, s->frame->linesize[2], tmp2, tmp4, tmpstride, nPbW/2, nPbH/2); } } }
false
FFmpeg
8b573ddda75980f724f779ff75aacc2ff81d9e0e
static void hls_prediction_unit(HEVCContext *s, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int partIdx) { #define POS(c_idx, x, y) \ &s->frame->data[c_idx][((y) >> s->sps->vshift[c_idx]) * s->frame->linesize[c_idx] + \ (((x) >> s->sps->hshift[c_idx]) << s->sps->pixel_shift)] HEVCLocalContext *lc = &s->HEVClc; int merge_idx = 0; struct MvField current_mv = {{{ 0 }}}; int min_pu_width = s->sps->min_pu_width; MvField *tab_mvf = s->ref->tab_mvf; RefPicList *refPicList = s->ref->refPicList; HEVCFrame *ref0, *ref1; int tmpstride = MAX_PB_SIZE; uint8_t *dst0 = POS(0, x0, y0); uint8_t *dst1 = POS(1, x0, y0); uint8_t *dst2 = POS(2, x0, y0); int log2_min_cb_size = s->sps->log2_min_cb_size; int min_cb_width = s->sps->min_cb_width; int x_cb = x0 >> log2_min_cb_size; int y_cb = y0 >> log2_min_cb_size; int x_pu, y_pu; int i, j; int skip_flag = SAMPLE_CTB(s->skip_flag, x_cb, y_cb); if (!skip_flag) lc->pu.merge_flag = ff_hevc_merge_flag_decode(s); if (skip_flag || lc->pu.merge_flag) { if (s->sh.max_num_merge_cand > 1) merge_idx = ff_hevc_merge_idx_decode(s); else merge_idx = 0; ff_hevc_luma_mv_merge_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, partIdx, merge_idx, &current_mv); } else { enum InterPredIdc inter_pred_idc = PRED_L0; int mvp_flag; ff_hevc_set_neighbour_available(s, x0, y0, nPbW, nPbH); if (s->sh.slice_type == B_SLICE) inter_pred_idc = ff_hevc_inter_pred_idc_decode(s, nPbW, nPbH); if (inter_pred_idc != PRED_L1) { if (s->sh.nb_refs[L0]) { current_mv.ref_idx[0]= ff_hevc_ref_idx_lx_decode(s, s->sh.nb_refs[L0]); } current_mv.pred_flag[0] = 1; hls_mvd_coding(s, x0, y0, 0); mvp_flag = ff_hevc_mvp_lx_flag_decode(s); ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, partIdx, merge_idx, &current_mv, mvp_flag, 0); current_mv.mv[0].x += lc->pu.mvd.x; current_mv.mv[0].y += lc->pu.mvd.y; } if (inter_pred_idc != PRED_L0) { if (s->sh.nb_refs[L1]) { current_mv.ref_idx[1]= ff_hevc_ref_idx_lx_decode(s, s->sh.nb_refs[L1]); } if (s->sh.mvd_l1_zero_flag == 1 && inter_pred_idc == PRED_BI) { AV_ZERO32(&lc->pu.mvd); } else { hls_mvd_coding(s, x0, y0, 1); } current_mv.pred_flag[1] = 1; mvp_flag = ff_hevc_mvp_lx_flag_decode(s); ff_hevc_luma_mv_mvp_mode(s, x0, y0, nPbW, nPbH, log2_cb_size, partIdx, merge_idx, &current_mv, mvp_flag, 1); current_mv.mv[1].x += lc->pu.mvd.x; current_mv.mv[1].y += lc->pu.mvd.y; } } x_pu = x0 >> s->sps->log2_min_pu_size; y_pu = y0 >> s->sps->log2_min_pu_size; for (j = 0; j < nPbH >> s->sps->log2_min_pu_size; j++) for (i = 0; i < nPbW >> s->sps->log2_min_pu_size; i++) tab_mvf[(y_pu + j) * min_pu_width + x_pu + i] = current_mv; if (current_mv.pred_flag[0]) { ref0 = refPicList[0].ref[current_mv.ref_idx[0]]; if (!ref0) return; hevc_await_progress(s, ref0, &current_mv.mv[0], y0, nPbH); } if (current_mv.pred_flag[1]) { ref1 = refPicList[1].ref[current_mv.ref_idx[1]]; if (!ref1) return; hevc_await_progress(s, ref1, &current_mv.mv[1], y0, nPbH); } if (current_mv.pred_flag[0] && !current_mv.pred_flag[1]) { DECLARE_ALIGNED(16, int16_t, tmp[MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]); luma_mc(s, tmp, tmpstride, ref0->frame, &current_mv.mv[0], x0, y0, nPbW, nPbH); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred(s->sh.luma_log2_weight_denom, s->sh.luma_weight_l0[current_mv.ref_idx[0]], s->sh.luma_offset_l0[current_mv.ref_idx[0]], dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH); } else { s->hevcdsp.put_unweighted_pred(dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH); } chroma_mc(s, tmp, tmp2, tmpstride, ref0->frame, &current_mv.mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0], dst1, s->frame->linesize[1], tmp, tmpstride, nPbW / 2, nPbH / 2); s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1], dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW / 2, nPbH / 2); } else { s->hevcdsp.put_unweighted_pred(dst1, s->frame->linesize[1], tmp, tmpstride, nPbW/2, nPbH/2); s->hevcdsp.put_unweighted_pred(dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2); } } else if (!current_mv.pred_flag[0] && current_mv.pred_flag[1]) { DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]); if (!ref1) return; luma_mc(s, tmp, tmpstride, ref1->frame, &current_mv.mv[1], x0, y0, nPbW, nPbH); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred(s->sh.luma_log2_weight_denom, s->sh.luma_weight_l1[current_mv.ref_idx[1]], s->sh.luma_offset_l1[current_mv.ref_idx[1]], dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH); } else { s->hevcdsp.put_unweighted_pred(dst0, s->frame->linesize[0], tmp, tmpstride, nPbW, nPbH); } chroma_mc(s, tmp, tmp2, tmpstride, ref1->frame, &current_mv.mv[1], x0/2, y0/2, nPbW/2, nPbH/2); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0], dst1, s->frame->linesize[1], tmp, tmpstride, nPbW/2, nPbH/2); s->hevcdsp.weighted_pred(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1], dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2); } else { s->hevcdsp.put_unweighted_pred(dst1, s->frame->linesize[1], tmp, tmpstride, nPbW/2, nPbH/2); s->hevcdsp.put_unweighted_pred(dst2, s->frame->linesize[2], tmp2, tmpstride, nPbW/2, nPbH/2); } } else if (current_mv.pred_flag[0] && current_mv.pred_flag[1]) { DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp3[MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp4[MAX_PB_SIZE * MAX_PB_SIZE]); HEVCFrame *ref0 = refPicList[0].ref[current_mv.ref_idx[0]]; HEVCFrame *ref1 = refPicList[1].ref[current_mv.ref_idx[1]]; if (!ref0 || !ref1) return; luma_mc(s, tmp, tmpstride, ref0->frame, &current_mv.mv[0], x0, y0, nPbW, nPbH); luma_mc(s, tmp2, tmpstride, ref1->frame, &current_mv.mv[1], x0, y0, nPbW, nPbH); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred_avg(s->sh.luma_log2_weight_denom, s->sh.luma_weight_l0[current_mv.ref_idx[0]], s->sh.luma_weight_l1[current_mv.ref_idx[1]], s->sh.luma_offset_l0[current_mv.ref_idx[0]], s->sh.luma_offset_l1[current_mv.ref_idx[1]], dst0, s->frame->linesize[0], tmp, tmp2, tmpstride, nPbW, nPbH); } else { s->hevcdsp.put_weighted_pred_avg(dst0, s->frame->linesize[0], tmp, tmp2, tmpstride, nPbW, nPbH); } chroma_mc(s, tmp, tmp2, tmpstride, ref0->frame, &current_mv.mv[0], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2); chroma_mc(s, tmp3, tmp4, tmpstride, ref1->frame, &current_mv.mv[1], x0 / 2, y0 / 2, nPbW / 2, nPbH / 2); if ((s->sh.slice_type == P_SLICE && s->pps->weighted_pred_flag) || (s->sh.slice_type == B_SLICE && s->pps->weighted_bipred_flag)) { s->hevcdsp.weighted_pred_avg(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][0], s->sh.chroma_weight_l1[current_mv.ref_idx[1]][0], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][0], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][0], dst1, s->frame->linesize[1], tmp, tmp3, tmpstride, nPbW / 2, nPbH / 2); s->hevcdsp.weighted_pred_avg(s->sh.chroma_log2_weight_denom, s->sh.chroma_weight_l0[current_mv.ref_idx[0]][1], s->sh.chroma_weight_l1[current_mv.ref_idx[1]][1], s->sh.chroma_offset_l0[current_mv.ref_idx[0]][1], s->sh.chroma_offset_l1[current_mv.ref_idx[1]][1], dst2, s->frame->linesize[2], tmp2, tmp4, tmpstride, nPbW / 2, nPbH / 2); } else { s->hevcdsp.put_weighted_pred_avg(dst1, s->frame->linesize[1], tmp, tmp3, tmpstride, nPbW/2, nPbH/2); s->hevcdsp.put_weighted_pred_avg(dst2, s->frame->linesize[2], tmp2, tmp4, tmpstride, nPbW/2, nPbH/2); } } }
{ "code": [], "line_no": [] }
static void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6) { #define POS(c_idx, x, y) \ &VAR_0->frame->data[c_idx][((y) >> VAR_0->sps->vshift[c_idx]) * VAR_0->frame->linesize[c_idx] + \ (((x) >> VAR_0->sps->hshift[c_idx]) << VAR_0->sps->pixel_shift)] HEVCLocalContext *lc = &VAR_0->HEVClc; int VAR_7 = 0; struct MvField VAR_8 = {{{ 0 }}}; int VAR_9 = VAR_0->sps->VAR_9; MvField *VAR_10 = VAR_0->ref->VAR_10; RefPicList *refPicList = VAR_0->ref->refPicList; HEVCFrame *ref0, *ref1; int VAR_11 = MAX_PB_SIZE; uint8_t *dst0 = POS(0, VAR_1, VAR_2); uint8_t *dst1 = POS(1, VAR_1, VAR_2); uint8_t *dst2 = POS(2, VAR_1, VAR_2); int VAR_12 = VAR_0->sps->VAR_12; int VAR_13 = VAR_0->sps->VAR_13; int VAR_14 = VAR_1 >> VAR_12; int VAR_15 = VAR_2 >> VAR_12; int VAR_16, VAR_17; int VAR_18, VAR_19; int VAR_20 = SAMPLE_CTB(VAR_0->VAR_20, VAR_14, VAR_15); if (!VAR_20) lc->pu.merge_flag = ff_hevc_merge_flag_decode(VAR_0); if (VAR_20 || lc->pu.merge_flag) { if (VAR_0->sh.max_num_merge_cand > 1) VAR_7 = ff_hevc_merge_idx_decode(VAR_0); else VAR_7 = 0; ff_hevc_luma_mv_merge_mode(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, &VAR_8); } else { enum InterPredIdc VAR_21 = PRED_L0; int VAR_22; ff_hevc_set_neighbour_available(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4); if (VAR_0->sh.slice_type == B_SLICE) VAR_21 = ff_hevc_inter_pred_idc_decode(VAR_0, VAR_3, VAR_4); if (VAR_21 != PRED_L1) { if (VAR_0->sh.nb_refs[L0]) { VAR_8.ref_idx[0]= ff_hevc_ref_idx_lx_decode(VAR_0, VAR_0->sh.nb_refs[L0]); } VAR_8.pred_flag[0] = 1; hls_mvd_coding(VAR_0, VAR_1, VAR_2, 0); VAR_22 = ff_hevc_mvp_lx_flag_decode(VAR_0); ff_hevc_luma_mv_mvp_mode(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, &VAR_8, VAR_22, 0); VAR_8.mv[0].x += lc->pu.mvd.x; VAR_8.mv[0].y += lc->pu.mvd.y; } if (VAR_21 != PRED_L0) { if (VAR_0->sh.nb_refs[L1]) { VAR_8.ref_idx[1]= ff_hevc_ref_idx_lx_decode(VAR_0, VAR_0->sh.nb_refs[L1]); } if (VAR_0->sh.mvd_l1_zero_flag == 1 && VAR_21 == PRED_BI) { AV_ZERO32(&lc->pu.mvd); } else { hls_mvd_coding(VAR_0, VAR_1, VAR_2, 1); } VAR_8.pred_flag[1] = 1; VAR_22 = ff_hevc_mvp_lx_flag_decode(VAR_0); ff_hevc_luma_mv_mvp_mode(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, &VAR_8, VAR_22, 1); VAR_8.mv[1].x += lc->pu.mvd.x; VAR_8.mv[1].y += lc->pu.mvd.y; } } VAR_16 = VAR_1 >> VAR_0->sps->log2_min_pu_size; VAR_17 = VAR_2 >> VAR_0->sps->log2_min_pu_size; for (VAR_19 = 0; VAR_19 < VAR_4 >> VAR_0->sps->log2_min_pu_size; VAR_19++) for (VAR_18 = 0; VAR_18 < VAR_3 >> VAR_0->sps->log2_min_pu_size; VAR_18++) VAR_10[(VAR_17 + VAR_19) * VAR_9 + VAR_16 + VAR_18] = VAR_8; if (VAR_8.pred_flag[0]) { ref0 = refPicList[0].ref[VAR_8.ref_idx[0]]; if (!ref0) return; hevc_await_progress(VAR_0, ref0, &VAR_8.mv[0], VAR_2, VAR_4); } if (VAR_8.pred_flag[1]) { ref1 = refPicList[1].ref[VAR_8.ref_idx[1]]; if (!ref1) return; hevc_await_progress(VAR_0, ref1, &VAR_8.mv[1], VAR_2, VAR_4); } if (VAR_8.pred_flag[0] && !VAR_8.pred_flag[1]) { DECLARE_ALIGNED(16, int16_t, tmp[MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]); luma_mc(VAR_0, tmp, VAR_11, ref0->frame, &VAR_8.mv[0], VAR_1, VAR_2, VAR_3, VAR_4); if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) || (VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) { VAR_0->hevcdsp.weighted_pred(VAR_0->sh.luma_log2_weight_denom, VAR_0->sh.luma_weight_l0[VAR_8.ref_idx[0]], VAR_0->sh.luma_offset_l0[VAR_8.ref_idx[0]], dst0, VAR_0->frame->linesize[0], tmp, VAR_11, VAR_3, VAR_4); } else { VAR_0->hevcdsp.put_unweighted_pred(dst0, VAR_0->frame->linesize[0], tmp, VAR_11, VAR_3, VAR_4); } chroma_mc(VAR_0, tmp, tmp2, VAR_11, ref0->frame, &VAR_8.mv[0], VAR_1 / 2, VAR_2 / 2, VAR_3 / 2, VAR_4 / 2); if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) || (VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) { VAR_0->hevcdsp.weighted_pred(VAR_0->sh.chroma_log2_weight_denom, VAR_0->sh.chroma_weight_l0[VAR_8.ref_idx[0]][0], VAR_0->sh.chroma_offset_l0[VAR_8.ref_idx[0]][0], dst1, VAR_0->frame->linesize[1], tmp, VAR_11, VAR_3 / 2, VAR_4 / 2); VAR_0->hevcdsp.weighted_pred(VAR_0->sh.chroma_log2_weight_denom, VAR_0->sh.chroma_weight_l0[VAR_8.ref_idx[0]][1], VAR_0->sh.chroma_offset_l0[VAR_8.ref_idx[0]][1], dst2, VAR_0->frame->linesize[2], tmp2, VAR_11, VAR_3 / 2, VAR_4 / 2); } else { VAR_0->hevcdsp.put_unweighted_pred(dst1, VAR_0->frame->linesize[1], tmp, VAR_11, VAR_3/2, VAR_4/2); VAR_0->hevcdsp.put_unweighted_pred(dst2, VAR_0->frame->linesize[2], tmp2, VAR_11, VAR_3/2, VAR_4/2); } } else if (!VAR_8.pred_flag[0] && VAR_8.pred_flag[1]) { DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]); if (!ref1) return; luma_mc(VAR_0, tmp, VAR_11, ref1->frame, &VAR_8.mv[1], VAR_1, VAR_2, VAR_3, VAR_4); if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) || (VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) { VAR_0->hevcdsp.weighted_pred(VAR_0->sh.luma_log2_weight_denom, VAR_0->sh.luma_weight_l1[VAR_8.ref_idx[1]], VAR_0->sh.luma_offset_l1[VAR_8.ref_idx[1]], dst0, VAR_0->frame->linesize[0], tmp, VAR_11, VAR_3, VAR_4); } else { VAR_0->hevcdsp.put_unweighted_pred(dst0, VAR_0->frame->linesize[0], tmp, VAR_11, VAR_3, VAR_4); } chroma_mc(VAR_0, tmp, tmp2, VAR_11, ref1->frame, &VAR_8.mv[1], VAR_1/2, VAR_2/2, VAR_3/2, VAR_4/2); if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) || (VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) { VAR_0->hevcdsp.weighted_pred(VAR_0->sh.chroma_log2_weight_denom, VAR_0->sh.chroma_weight_l1[VAR_8.ref_idx[1]][0], VAR_0->sh.chroma_offset_l1[VAR_8.ref_idx[1]][0], dst1, VAR_0->frame->linesize[1], tmp, VAR_11, VAR_3/2, VAR_4/2); VAR_0->hevcdsp.weighted_pred(VAR_0->sh.chroma_log2_weight_denom, VAR_0->sh.chroma_weight_l1[VAR_8.ref_idx[1]][1], VAR_0->sh.chroma_offset_l1[VAR_8.ref_idx[1]][1], dst2, VAR_0->frame->linesize[2], tmp2, VAR_11, VAR_3/2, VAR_4/2); } else { VAR_0->hevcdsp.put_unweighted_pred(dst1, VAR_0->frame->linesize[1], tmp, VAR_11, VAR_3/2, VAR_4/2); VAR_0->hevcdsp.put_unweighted_pred(dst2, VAR_0->frame->linesize[2], tmp2, VAR_11, VAR_3/2, VAR_4/2); } } else if (VAR_8.pred_flag[0] && VAR_8.pred_flag[1]) { DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp3[MAX_PB_SIZE * MAX_PB_SIZE]); DECLARE_ALIGNED(16, int16_t, tmp4[MAX_PB_SIZE * MAX_PB_SIZE]); HEVCFrame *ref0 = refPicList[0].ref[VAR_8.ref_idx[0]]; HEVCFrame *ref1 = refPicList[1].ref[VAR_8.ref_idx[1]]; if (!ref0 || !ref1) return; luma_mc(VAR_0, tmp, VAR_11, ref0->frame, &VAR_8.mv[0], VAR_1, VAR_2, VAR_3, VAR_4); luma_mc(VAR_0, tmp2, VAR_11, ref1->frame, &VAR_8.mv[1], VAR_1, VAR_2, VAR_3, VAR_4); if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) || (VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) { VAR_0->hevcdsp.weighted_pred_avg(VAR_0->sh.luma_log2_weight_denom, VAR_0->sh.luma_weight_l0[VAR_8.ref_idx[0]], VAR_0->sh.luma_weight_l1[VAR_8.ref_idx[1]], VAR_0->sh.luma_offset_l0[VAR_8.ref_idx[0]], VAR_0->sh.luma_offset_l1[VAR_8.ref_idx[1]], dst0, VAR_0->frame->linesize[0], tmp, tmp2, VAR_11, VAR_3, VAR_4); } else { VAR_0->hevcdsp.put_weighted_pred_avg(dst0, VAR_0->frame->linesize[0], tmp, tmp2, VAR_11, VAR_3, VAR_4); } chroma_mc(VAR_0, tmp, tmp2, VAR_11, ref0->frame, &VAR_8.mv[0], VAR_1 / 2, VAR_2 / 2, VAR_3 / 2, VAR_4 / 2); chroma_mc(VAR_0, tmp3, tmp4, VAR_11, ref1->frame, &VAR_8.mv[1], VAR_1 / 2, VAR_2 / 2, VAR_3 / 2, VAR_4 / 2); if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) || (VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) { VAR_0->hevcdsp.weighted_pred_avg(VAR_0->sh.chroma_log2_weight_denom, VAR_0->sh.chroma_weight_l0[VAR_8.ref_idx[0]][0], VAR_0->sh.chroma_weight_l1[VAR_8.ref_idx[1]][0], VAR_0->sh.chroma_offset_l0[VAR_8.ref_idx[0]][0], VAR_0->sh.chroma_offset_l1[VAR_8.ref_idx[1]][0], dst1, VAR_0->frame->linesize[1], tmp, tmp3, VAR_11, VAR_3 / 2, VAR_4 / 2); VAR_0->hevcdsp.weighted_pred_avg(VAR_0->sh.chroma_log2_weight_denom, VAR_0->sh.chroma_weight_l0[VAR_8.ref_idx[0]][1], VAR_0->sh.chroma_weight_l1[VAR_8.ref_idx[1]][1], VAR_0->sh.chroma_offset_l0[VAR_8.ref_idx[0]][1], VAR_0->sh.chroma_offset_l1[VAR_8.ref_idx[1]][1], dst2, VAR_0->frame->linesize[2], tmp2, tmp4, VAR_11, VAR_3 / 2, VAR_4 / 2); } else { VAR_0->hevcdsp.put_weighted_pred_avg(dst1, VAR_0->frame->linesize[1], tmp, tmp3, VAR_11, VAR_3/2, VAR_4/2); VAR_0->hevcdsp.put_weighted_pred_avg(dst2, VAR_0->frame->linesize[2], tmp2, tmp4, VAR_11, VAR_3/2, VAR_4/2); } } }
[ "static void FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4,\nint VAR_5, int VAR_6)\n{", "#define POS(c_idx, x, y) \\\n&VAR_0->frame->data[c_idx][((y) >> VAR_0->sps->vshift[c_idx]) * VAR_0->frame->linesize[c_idx] + \\\n(((x) >> VAR_0->sps->hshift[c_idx]) << VAR_0->sps->pixel_shift)]\nHEVCLocalContext *lc = &VAR_0->HEVClc;", "int VAR_7 = 0;", "struct MvField VAR_8 = {{{ 0 }}};", "int VAR_9 = VAR_0->sps->VAR_9;", "MvField *VAR_10 = VAR_0->ref->VAR_10;", "RefPicList *refPicList = VAR_0->ref->refPicList;", "HEVCFrame *ref0, *ref1;", "int VAR_11 = MAX_PB_SIZE;", "uint8_t *dst0 = POS(0, VAR_1, VAR_2);", "uint8_t *dst1 = POS(1, VAR_1, VAR_2);", "uint8_t *dst2 = POS(2, VAR_1, VAR_2);", "int VAR_12 = VAR_0->sps->VAR_12;", "int VAR_13 = VAR_0->sps->VAR_13;", "int VAR_14 = VAR_1 >> VAR_12;", "int VAR_15 = VAR_2 >> VAR_12;", "int VAR_16, VAR_17;", "int VAR_18, VAR_19;", "int VAR_20 = SAMPLE_CTB(VAR_0->VAR_20, VAR_14, VAR_15);", "if (!VAR_20)\nlc->pu.merge_flag = ff_hevc_merge_flag_decode(VAR_0);", "if (VAR_20 || lc->pu.merge_flag) {", "if (VAR_0->sh.max_num_merge_cand > 1)\nVAR_7 = ff_hevc_merge_idx_decode(VAR_0);", "else\nVAR_7 = 0;", "ff_hevc_luma_mv_merge_mode(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5,\nVAR_6, VAR_7, &VAR_8);", "} else {", "enum InterPredIdc VAR_21 = PRED_L0;", "int VAR_22;", "ff_hevc_set_neighbour_available(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);", "if (VAR_0->sh.slice_type == B_SLICE)\nVAR_21 = ff_hevc_inter_pred_idc_decode(VAR_0, VAR_3, VAR_4);", "if (VAR_21 != PRED_L1) {", "if (VAR_0->sh.nb_refs[L0]) {", "VAR_8.ref_idx[0]= ff_hevc_ref_idx_lx_decode(VAR_0, VAR_0->sh.nb_refs[L0]);", "}", "VAR_8.pred_flag[0] = 1;", "hls_mvd_coding(VAR_0, VAR_1, VAR_2, 0);", "VAR_22 = ff_hevc_mvp_lx_flag_decode(VAR_0);", "ff_hevc_luma_mv_mvp_mode(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5,\nVAR_6, VAR_7, &VAR_8,\nVAR_22, 0);", "VAR_8.mv[0].x += lc->pu.mvd.x;", "VAR_8.mv[0].y += lc->pu.mvd.y;", "}", "if (VAR_21 != PRED_L0) {", "if (VAR_0->sh.nb_refs[L1]) {", "VAR_8.ref_idx[1]= ff_hevc_ref_idx_lx_decode(VAR_0, VAR_0->sh.nb_refs[L1]);", "}", "if (VAR_0->sh.mvd_l1_zero_flag == 1 && VAR_21 == PRED_BI) {", "AV_ZERO32(&lc->pu.mvd);", "} else {", "hls_mvd_coding(VAR_0, VAR_1, VAR_2, 1);", "}", "VAR_8.pred_flag[1] = 1;", "VAR_22 = ff_hevc_mvp_lx_flag_decode(VAR_0);", "ff_hevc_luma_mv_mvp_mode(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5,\nVAR_6, VAR_7, &VAR_8,\nVAR_22, 1);", "VAR_8.mv[1].x += lc->pu.mvd.x;", "VAR_8.mv[1].y += lc->pu.mvd.y;", "}", "}", "VAR_16 = VAR_1 >> VAR_0->sps->log2_min_pu_size;", "VAR_17 = VAR_2 >> VAR_0->sps->log2_min_pu_size;", "for (VAR_19 = 0; VAR_19 < VAR_4 >> VAR_0->sps->log2_min_pu_size; VAR_19++)", "for (VAR_18 = 0; VAR_18 < VAR_3 >> VAR_0->sps->log2_min_pu_size; VAR_18++)", "VAR_10[(VAR_17 + VAR_19) * VAR_9 + VAR_16 + VAR_18] = VAR_8;", "if (VAR_8.pred_flag[0]) {", "ref0 = refPicList[0].ref[VAR_8.ref_idx[0]];", "if (!ref0)\nreturn;", "hevc_await_progress(VAR_0, ref0, &VAR_8.mv[0], VAR_2, VAR_4);", "}", "if (VAR_8.pred_flag[1]) {", "ref1 = refPicList[1].ref[VAR_8.ref_idx[1]];", "if (!ref1)\nreturn;", "hevc_await_progress(VAR_0, ref1, &VAR_8.mv[1], VAR_2, VAR_4);", "}", "if (VAR_8.pred_flag[0] && !VAR_8.pred_flag[1]) {", "DECLARE_ALIGNED(16, int16_t, tmp[MAX_PB_SIZE * MAX_PB_SIZE]);", "DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]);", "luma_mc(VAR_0, tmp, VAR_11, ref0->frame,\n&VAR_8.mv[0], VAR_1, VAR_2, VAR_3, VAR_4);", "if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) ||\n(VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) {", "VAR_0->hevcdsp.weighted_pred(VAR_0->sh.luma_log2_weight_denom,\nVAR_0->sh.luma_weight_l0[VAR_8.ref_idx[0]],\nVAR_0->sh.luma_offset_l0[VAR_8.ref_idx[0]],\ndst0, VAR_0->frame->linesize[0], tmp,\nVAR_11, VAR_3, VAR_4);", "} else {", "VAR_0->hevcdsp.put_unweighted_pred(dst0, VAR_0->frame->linesize[0], tmp, VAR_11, VAR_3, VAR_4);", "}", "chroma_mc(VAR_0, tmp, tmp2, VAR_11, ref0->frame,\n&VAR_8.mv[0], VAR_1 / 2, VAR_2 / 2, VAR_3 / 2, VAR_4 / 2);", "if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) ||\n(VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) {", "VAR_0->hevcdsp.weighted_pred(VAR_0->sh.chroma_log2_weight_denom,\nVAR_0->sh.chroma_weight_l0[VAR_8.ref_idx[0]][0],\nVAR_0->sh.chroma_offset_l0[VAR_8.ref_idx[0]][0],\ndst1, VAR_0->frame->linesize[1], tmp, VAR_11,\nVAR_3 / 2, VAR_4 / 2);", "VAR_0->hevcdsp.weighted_pred(VAR_0->sh.chroma_log2_weight_denom,\nVAR_0->sh.chroma_weight_l0[VAR_8.ref_idx[0]][1],\nVAR_0->sh.chroma_offset_l0[VAR_8.ref_idx[0]][1],\ndst2, VAR_0->frame->linesize[2], tmp2, VAR_11,\nVAR_3 / 2, VAR_4 / 2);", "} else {", "VAR_0->hevcdsp.put_unweighted_pred(dst1, VAR_0->frame->linesize[1], tmp, VAR_11, VAR_3/2, VAR_4/2);", "VAR_0->hevcdsp.put_unweighted_pred(dst2, VAR_0->frame->linesize[2], tmp2, VAR_11, VAR_3/2, VAR_4/2);", "}", "} else if (!VAR_8.pred_flag[0] && VAR_8.pred_flag[1]) {", "DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]);", "DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]);", "if (!ref1)\nreturn;", "luma_mc(VAR_0, tmp, VAR_11, ref1->frame,\n&VAR_8.mv[1], VAR_1, VAR_2, VAR_3, VAR_4);", "if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) ||\n(VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) {", "VAR_0->hevcdsp.weighted_pred(VAR_0->sh.luma_log2_weight_denom,\nVAR_0->sh.luma_weight_l1[VAR_8.ref_idx[1]],\nVAR_0->sh.luma_offset_l1[VAR_8.ref_idx[1]],\ndst0, VAR_0->frame->linesize[0], tmp, VAR_11,\nVAR_3, VAR_4);", "} else {", "VAR_0->hevcdsp.put_unweighted_pred(dst0, VAR_0->frame->linesize[0], tmp, VAR_11, VAR_3, VAR_4);", "}", "chroma_mc(VAR_0, tmp, tmp2, VAR_11, ref1->frame,\n&VAR_8.mv[1], VAR_1/2, VAR_2/2, VAR_3/2, VAR_4/2);", "if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) ||\n(VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) {", "VAR_0->hevcdsp.weighted_pred(VAR_0->sh.chroma_log2_weight_denom,\nVAR_0->sh.chroma_weight_l1[VAR_8.ref_idx[1]][0],\nVAR_0->sh.chroma_offset_l1[VAR_8.ref_idx[1]][0],\ndst1, VAR_0->frame->linesize[1], tmp, VAR_11, VAR_3/2, VAR_4/2);", "VAR_0->hevcdsp.weighted_pred(VAR_0->sh.chroma_log2_weight_denom,\nVAR_0->sh.chroma_weight_l1[VAR_8.ref_idx[1]][1],\nVAR_0->sh.chroma_offset_l1[VAR_8.ref_idx[1]][1],\ndst2, VAR_0->frame->linesize[2], tmp2, VAR_11, VAR_3/2, VAR_4/2);", "} else {", "VAR_0->hevcdsp.put_unweighted_pred(dst1, VAR_0->frame->linesize[1], tmp, VAR_11, VAR_3/2, VAR_4/2);", "VAR_0->hevcdsp.put_unweighted_pred(dst2, VAR_0->frame->linesize[2], tmp2, VAR_11, VAR_3/2, VAR_4/2);", "}", "} else if (VAR_8.pred_flag[0] && VAR_8.pred_flag[1]) {", "DECLARE_ALIGNED(16, int16_t, tmp [MAX_PB_SIZE * MAX_PB_SIZE]);", "DECLARE_ALIGNED(16, int16_t, tmp2[MAX_PB_SIZE * MAX_PB_SIZE]);", "DECLARE_ALIGNED(16, int16_t, tmp3[MAX_PB_SIZE * MAX_PB_SIZE]);", "DECLARE_ALIGNED(16, int16_t, tmp4[MAX_PB_SIZE * MAX_PB_SIZE]);", "HEVCFrame *ref0 = refPicList[0].ref[VAR_8.ref_idx[0]];", "HEVCFrame *ref1 = refPicList[1].ref[VAR_8.ref_idx[1]];", "if (!ref0 || !ref1)\nreturn;", "luma_mc(VAR_0, tmp, VAR_11, ref0->frame,\n&VAR_8.mv[0], VAR_1, VAR_2, VAR_3, VAR_4);", "luma_mc(VAR_0, tmp2, VAR_11, ref1->frame,\n&VAR_8.mv[1], VAR_1, VAR_2, VAR_3, VAR_4);", "if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) ||\n(VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) {", "VAR_0->hevcdsp.weighted_pred_avg(VAR_0->sh.luma_log2_weight_denom,\nVAR_0->sh.luma_weight_l0[VAR_8.ref_idx[0]],\nVAR_0->sh.luma_weight_l1[VAR_8.ref_idx[1]],\nVAR_0->sh.luma_offset_l0[VAR_8.ref_idx[0]],\nVAR_0->sh.luma_offset_l1[VAR_8.ref_idx[1]],\ndst0, VAR_0->frame->linesize[0],\ntmp, tmp2, VAR_11, VAR_3, VAR_4);", "} else {", "VAR_0->hevcdsp.put_weighted_pred_avg(dst0, VAR_0->frame->linesize[0],\ntmp, tmp2, VAR_11, VAR_3, VAR_4);", "}", "chroma_mc(VAR_0, tmp, tmp2, VAR_11, ref0->frame,\n&VAR_8.mv[0], VAR_1 / 2, VAR_2 / 2, VAR_3 / 2, VAR_4 / 2);", "chroma_mc(VAR_0, tmp3, tmp4, VAR_11, ref1->frame,\n&VAR_8.mv[1], VAR_1 / 2, VAR_2 / 2, VAR_3 / 2, VAR_4 / 2);", "if ((VAR_0->sh.slice_type == P_SLICE && VAR_0->pps->weighted_pred_flag) ||\n(VAR_0->sh.slice_type == B_SLICE && VAR_0->pps->weighted_bipred_flag)) {", "VAR_0->hevcdsp.weighted_pred_avg(VAR_0->sh.chroma_log2_weight_denom,\nVAR_0->sh.chroma_weight_l0[VAR_8.ref_idx[0]][0],\nVAR_0->sh.chroma_weight_l1[VAR_8.ref_idx[1]][0],\nVAR_0->sh.chroma_offset_l0[VAR_8.ref_idx[0]][0],\nVAR_0->sh.chroma_offset_l1[VAR_8.ref_idx[1]][0],\ndst1, VAR_0->frame->linesize[1], tmp, tmp3,\nVAR_11, VAR_3 / 2, VAR_4 / 2);", "VAR_0->hevcdsp.weighted_pred_avg(VAR_0->sh.chroma_log2_weight_denom,\nVAR_0->sh.chroma_weight_l0[VAR_8.ref_idx[0]][1],\nVAR_0->sh.chroma_weight_l1[VAR_8.ref_idx[1]][1],\nVAR_0->sh.chroma_offset_l0[VAR_8.ref_idx[0]][1],\nVAR_0->sh.chroma_offset_l1[VAR_8.ref_idx[1]][1],\ndst2, VAR_0->frame->linesize[2], tmp2, tmp4,\nVAR_11, VAR_3 / 2, VAR_4 / 2);", "} else {", "VAR_0->hevcdsp.put_weighted_pred_avg(dst1, VAR_0->frame->linesize[1], tmp, tmp3, VAR_11, VAR_3/2, VAR_4/2);", "VAR_0->hevcdsp.put_weighted_pred_avg(dst2, VAR_0->frame->linesize[2], tmp2, tmp4, VAR_11, VAR_3/2, VAR_4/2);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9, 11, 13, 15 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 63, 65 ], [ 69 ], [ 71, 73 ], [ 75, 77 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95, 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115, 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155, 157, 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 189, 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201, 203 ], [ 205 ], [ 207 ], [ 211 ], [ 213 ], [ 215 ], [ 219, 221 ], [ 225, 227 ], [ 229, 231, 233, 235, 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245, 247 ], [ 251, 253 ], [ 255, 257, 259, 261, 263 ], [ 265, 267, 269, 271, 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 291, 293 ], [ 297, 299 ], [ 303, 305 ], [ 307, 309, 311, 313, 315 ], [ 317 ], [ 319 ], [ 321 ], [ 325, 327 ], [ 331, 333 ], [ 335, 337, 339, 341 ], [ 343, 345, 347, 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 375, 377 ], [ 381, 383 ], [ 385, 387 ], [ 391, 393 ], [ 395, 397, 399, 401, 403, 405, 407 ], [ 409 ], [ 411, 413 ], [ 415 ], [ 419, 421 ], [ 423, 425 ], [ 429, 431 ], [ 433, 435, 437, 439, 441, 443, 445 ], [ 447, 449, 451, 453, 455, 457, 459 ], [ 461 ], [ 463 ], [ 465 ], [ 467 ], [ 469 ], [ 471 ] ]
468
static void select_soundhw (const char *optarg) { struct soundhw *c; if (*optarg == '?') { show_valid_cards: printf ("Valid sound card names (comma separated):\n"); for (c = soundhw; c->name; ++c) { printf ("%-11s %s\n", c->name, c->descr); } printf ("\n-soundhw all will enable all of the above\n"); exit (*optarg != '?'); } else { size_t l; const char *p; char *e; int bad_card = 0; if (!strcmp (optarg, "all")) { for (c = soundhw; c->name; ++c) { c->enabled = 1; } return; } p = optarg; while (*p) { e = strchr (p, ','); l = !e ? strlen (p) : (size_t) (e - p); for (c = soundhw; c->name; ++c) { if (!strncmp (c->name, p, l) && !c->name[l]) { c->enabled = 1; break; } } if (!c->name) { if (l > 80) { fprintf (stderr, "Unknown sound card name (too big to show)\n"); } else { fprintf (stderr, "Unknown sound card name `%.*s'\n", (int) l, p); } bad_card = 1; } p += l + (e != NULL); } if (bad_card) goto show_valid_cards; } }
false
qemu
ad96090a01d848df67d70c5259ed8aa321fa8716
static void select_soundhw (const char *optarg) { struct soundhw *c; if (*optarg == '?') { show_valid_cards: printf ("Valid sound card names (comma separated):\n"); for (c = soundhw; c->name; ++c) { printf ("%-11s %s\n", c->name, c->descr); } printf ("\n-soundhw all will enable all of the above\n"); exit (*optarg != '?'); } else { size_t l; const char *p; char *e; int bad_card = 0; if (!strcmp (optarg, "all")) { for (c = soundhw; c->name; ++c) { c->enabled = 1; } return; } p = optarg; while (*p) { e = strchr (p, ','); l = !e ? strlen (p) : (size_t) (e - p); for (c = soundhw; c->name; ++c) { if (!strncmp (c->name, p, l) && !c->name[l]) { c->enabled = 1; break; } } if (!c->name) { if (l > 80) { fprintf (stderr, "Unknown sound card name (too big to show)\n"); } else { fprintf (stderr, "Unknown sound card name `%.*s'\n", (int) l, p); } bad_card = 1; } p += l + (e != NULL); } if (bad_card) goto show_valid_cards; } }
{ "code": [], "line_no": [] }
static void FUNC_0 (const char *VAR_0) { struct soundhw *VAR_1; if (*VAR_0 == '?') { show_valid_cards: printf ("Valid sound card names (comma separated):\n"); for (VAR_1 = soundhw; VAR_1->name; ++VAR_1) { printf ("%-11s %s\n", VAR_1->name, VAR_1->descr); } printf ("\n-soundhw all will enable all of the above\n"); exit (*VAR_0 != '?'); } else { size_t l; const char *VAR_2; char *VAR_3; int VAR_4 = 0; if (!strcmp (VAR_0, "all")) { for (VAR_1 = soundhw; VAR_1->name; ++VAR_1) { VAR_1->enabled = 1; } return; } VAR_2 = VAR_0; while (*VAR_2) { VAR_3 = strchr (VAR_2, ','); l = !VAR_3 ? strlen (VAR_2) : (size_t) (VAR_3 - VAR_2); for (VAR_1 = soundhw; VAR_1->name; ++VAR_1) { if (!strncmp (VAR_1->name, VAR_2, l) && !VAR_1->name[l]) { VAR_1->enabled = 1; break; } } if (!VAR_1->name) { if (l > 80) { fprintf (stderr, "Unknown sound card name (too big to show)\n"); } else { fprintf (stderr, "Unknown sound card name `%.*s'\n", (int) l, VAR_2); } VAR_4 = 1; } VAR_2 += l + (VAR_3 != NULL); } if (VAR_4) goto show_valid_cards; } }
[ "static void FUNC_0 (const char *VAR_0)\n{", "struct soundhw *VAR_1;", "if (*VAR_0 == '?') {", "show_valid_cards:\nprintf (\"Valid sound card names (comma separated):\\n\");", "for (VAR_1 = soundhw; VAR_1->name; ++VAR_1) {", "printf (\"%-11s %s\\n\", VAR_1->name, VAR_1->descr);", "}", "printf (\"\\n-soundhw all will enable all of the above\\n\");", "exit (*VAR_0 != '?');", "}", "else {", "size_t l;", "const char *VAR_2;", "char *VAR_3;", "int VAR_4 = 0;", "if (!strcmp (VAR_0, \"all\")) {", "for (VAR_1 = soundhw; VAR_1->name; ++VAR_1) {", "VAR_1->enabled = 1;", "}", "return;", "}", "VAR_2 = VAR_0;", "while (*VAR_2) {", "VAR_3 = strchr (VAR_2, ',');", "l = !VAR_3 ? strlen (VAR_2) : (size_t) (VAR_3 - VAR_2);", "for (VAR_1 = soundhw; VAR_1->name; ++VAR_1) {", "if (!strncmp (VAR_1->name, VAR_2, l) && !VAR_1->name[l]) {", "VAR_1->enabled = 1;", "break;", "}", "}", "if (!VAR_1->name) {", "if (l > 80) {", "fprintf (stderr,\n\"Unknown sound card name (too big to show)\\n\");", "}", "else {", "fprintf (stderr, \"Unknown sound card name `%.*s'\\n\",\n(int) l, VAR_2);", "}", "VAR_4 = 1;", "}", "VAR_2 += l + (VAR_3 != NULL);", "}", "if (VAR_4)\ngoto show_valid_cards;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 107, 109 ], [ 111 ], [ 113 ] ]
469
void ide_bus_reset(IDEBus *bus) { bus->unit = 0; bus->cmd = 0; ide_reset(&bus->ifs[0]); ide_reset(&bus->ifs[1]); ide_clear_hob(bus); /* pending async DMA */ if (bus->dma->aiocb) { #ifdef DEBUG_AIO printf("aio_cancel\n"); #endif bdrv_aio_cancel(bus->dma->aiocb); bus->dma->aiocb = NULL; } /* reset dma provider too */ if (bus->dma->ops->reset) { bus->dma->ops->reset(bus->dma); } }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
void ide_bus_reset(IDEBus *bus) { bus->unit = 0; bus->cmd = 0; ide_reset(&bus->ifs[0]); ide_reset(&bus->ifs[1]); ide_clear_hob(bus); if (bus->dma->aiocb) { #ifdef DEBUG_AIO printf("aio_cancel\n"); #endif bdrv_aio_cancel(bus->dma->aiocb); bus->dma->aiocb = NULL; } if (bus->dma->ops->reset) { bus->dma->ops->reset(bus->dma); } }
{ "code": [], "line_no": [] }
void FUNC_0(IDEBus *VAR_0) { VAR_0->unit = 0; VAR_0->cmd = 0; ide_reset(&VAR_0->ifs[0]); ide_reset(&VAR_0->ifs[1]); ide_clear_hob(VAR_0); if (VAR_0->dma->aiocb) { #ifdef DEBUG_AIO printf("aio_cancel\n"); #endif bdrv_aio_cancel(VAR_0->dma->aiocb); VAR_0->dma->aiocb = NULL; } if (VAR_0->dma->ops->reset) { VAR_0->dma->ops->reset(VAR_0->dma); } }
[ "void FUNC_0(IDEBus *VAR_0)\n{", "VAR_0->unit = 0;", "VAR_0->cmd = 0;", "ide_reset(&VAR_0->ifs[0]);", "ide_reset(&VAR_0->ifs[1]);", "ide_clear_hob(VAR_0);", "if (VAR_0->dma->aiocb) {", "#ifdef DEBUG_AIO\nprintf(\"aio_cancel\\n\");", "#endif\nbdrv_aio_cancel(VAR_0->dma->aiocb);", "VAR_0->dma->aiocb = NULL;", "}", "if (VAR_0->dma->ops->reset) {", "VAR_0->dma->ops->reset(VAR_0->dma);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 19 ], [ 21, 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ] ]
470
if_start(void) { struct mbuf *ifm, *ifqt; DEBUG_CALL("if_start"); if (if_queued == 0) return; /* Nothing to do */ again: /* check if we can really output */ if (!slirp_can_output()) return; /* * See which queue to get next packet from * If there's something in the fastq, select it immediately */ if (if_fastq.ifq_next != &if_fastq) { ifm = if_fastq.ifq_next; } else { /* Nothing on fastq, see if next_m is valid */ if (next_m != &if_batchq) ifm = next_m; else ifm = if_batchq.ifq_next; /* Set which packet to send on next iteration */ next_m = ifm->ifq_next; } /* Remove it from the queue */ ifqt = ifm->ifq_prev; remque(ifm); --if_queued; /* If there are more packets for this session, re-queue them */ if (ifm->ifs_next != /* ifm->ifs_prev != */ ifm) { insque(ifm->ifs_next, ifqt); ifs_remque(ifm); } /* Update so_queued */ if (ifm->ifq_so) { if (--ifm->ifq_so->so_queued == 0) /* If there's no more queued, reset nqueued */ ifm->ifq_so->so_nqueued = 0; } /* Encapsulate the packet for sending */ if_encap(ifm->m_data, ifm->m_len); m_free(ifm); if (if_queued) goto again; }
false
qemu
242acf3af4605adce933906bdc053b2414181ec7
if_start(void) { struct mbuf *ifm, *ifqt; DEBUG_CALL("if_start"); if (if_queued == 0) return; again: if (!slirp_can_output()) return; if (if_fastq.ifq_next != &if_fastq) { ifm = if_fastq.ifq_next; } else { if (next_m != &if_batchq) ifm = next_m; else ifm = if_batchq.ifq_next; next_m = ifm->ifq_next; } ifqt = ifm->ifq_prev; remque(ifm); --if_queued; if (ifm->ifs_next != ifm) { insque(ifm->ifs_next, ifqt); ifs_remque(ifm); } if (ifm->ifq_so) { if (--ifm->ifq_so->so_queued == 0) ifm->ifq_so->so_nqueued = 0; } if_encap(ifm->m_data, ifm->m_len); m_free(ifm); if (if_queued) goto again; }
{ "code": [], "line_no": [] }
FUNC_0(void) { struct mbuf *VAR_0, *VAR_1; DEBUG_CALL("FUNC_0"); if (if_queued == 0) return; again: if (!slirp_can_output()) return; if (if_fastq.ifq_next != &if_fastq) { VAR_0 = if_fastq.ifq_next; } else { if (next_m != &if_batchq) VAR_0 = next_m; else VAR_0 = if_batchq.ifq_next; next_m = VAR_0->ifq_next; } VAR_1 = VAR_0->ifq_prev; remque(VAR_0); --if_queued; if (VAR_0->ifs_next != VAR_0) { insque(VAR_0->ifs_next, VAR_1); ifs_remque(VAR_0); } if (VAR_0->ifq_so) { if (--VAR_0->ifq_so->so_queued == 0) VAR_0->ifq_so->so_nqueued = 0; } if_encap(VAR_0->m_data, VAR_0->m_len); m_free(VAR_0); if (if_queued) goto again; }
[ "FUNC_0(void)\n{", "struct mbuf *VAR_0, *VAR_1;", "DEBUG_CALL(\"FUNC_0\");", "if (if_queued == 0)\nreturn;", "again:\nif (!slirp_can_output())\nreturn;", "if (if_fastq.ifq_next != &if_fastq) {", "VAR_0 = if_fastq.ifq_next;", "} else {", "if (next_m != &if_batchq)\nVAR_0 = next_m;", "else\nVAR_0 = if_batchq.ifq_next;", "next_m = VAR_0->ifq_next;", "}", "VAR_1 = VAR_0->ifq_prev;", "remque(VAR_0);", "--if_queued;", "if (VAR_0->ifs_next != VAR_0) {", "insque(VAR_0->ifs_next, VAR_1);", "ifs_remque(VAR_0);", "}", "if (VAR_0->ifq_so) {", "if (--VAR_0->ifq_so->so_queued == 0)\nVAR_0->ifq_so->so_nqueued = 0;", "}", "if_encap(VAR_0->m_data, VAR_0->m_len);", "m_free(VAR_0);", "if (if_queued)\ngoto again;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13, 15 ], [ 19, 23, 25 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 49, 51 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 85 ], [ 87, 91 ], [ 93 ], [ 99 ], [ 103 ], [ 107, 109 ], [ 111 ] ]
471
MacIONVRAMState *macio_nvram_init (target_phys_addr_t size, unsigned int it_shift) { MacIONVRAMState *s; s = g_malloc0(sizeof(MacIONVRAMState)); s->data = g_malloc0(size); s->size = size; s->it_shift = it_shift; memory_region_init_io(&s->mem, &macio_nvram_ops, s, "macio-nvram", size << it_shift); vmstate_register(NULL, -1, &vmstate_macio_nvram, s); qemu_register_reset(macio_nvram_reset, s); return s; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
MacIONVRAMState *macio_nvram_init (target_phys_addr_t size, unsigned int it_shift) { MacIONVRAMState *s; s = g_malloc0(sizeof(MacIONVRAMState)); s->data = g_malloc0(size); s->size = size; s->it_shift = it_shift; memory_region_init_io(&s->mem, &macio_nvram_ops, s, "macio-nvram", size << it_shift); vmstate_register(NULL, -1, &vmstate_macio_nvram, s); qemu_register_reset(macio_nvram_reset, s); return s; }
{ "code": [], "line_no": [] }
MacIONVRAMState *FUNC_0 (target_phys_addr_t size, unsigned int it_shift) { MacIONVRAMState *s; s = g_malloc0(sizeof(MacIONVRAMState)); s->data = g_malloc0(size); s->size = size; s->it_shift = it_shift; memory_region_init_io(&s->mem, &macio_nvram_ops, s, "macio-nvram", size << it_shift); vmstate_register(NULL, -1, &vmstate_macio_nvram, s); qemu_register_reset(macio_nvram_reset, s); return s; }
[ "MacIONVRAMState *FUNC_0 (target_phys_addr_t size,\nunsigned int it_shift)\n{", "MacIONVRAMState *s;", "s = g_malloc0(sizeof(MacIONVRAMState));", "s->data = g_malloc0(size);", "s->size = size;", "s->it_shift = it_shift;", "memory_region_init_io(&s->mem, &macio_nvram_ops, s, \"macio-nvram\",\nsize << it_shift);", "vmstate_register(NULL, -1, &vmstate_macio_nvram, s);", "qemu_register_reset(macio_nvram_reset, s);", "return s;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ] ]
472
static void cmd646_data_write(void *opaque, target_phys_addr_t addr, uint64_t data, unsigned size) { CMD646BAR *cmd646bar = opaque; if (size == 1) { ide_ioport_write(cmd646bar->bus, addr, data); } else if (addr == 0) { if (size == 2) { ide_data_writew(cmd646bar->bus, addr, data); } else { ide_data_writel(cmd646bar->bus, addr, data); } } }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void cmd646_data_write(void *opaque, target_phys_addr_t addr, uint64_t data, unsigned size) { CMD646BAR *cmd646bar = opaque; if (size == 1) { ide_ioport_write(cmd646bar->bus, addr, data); } else if (addr == 0) { if (size == 2) { ide_data_writew(cmd646bar->bus, addr, data); } else { ide_data_writel(cmd646bar->bus, addr, data); } } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { CMD646BAR *cmd646bar = VAR_0; if (VAR_3 == 1) { ide_ioport_write(cmd646bar->bus, VAR_1, VAR_2); } else if (VAR_1 == 0) { if (VAR_3 == 2) { ide_data_writew(cmd646bar->bus, VAR_1, VAR_2); } else { ide_data_writel(cmd646bar->bus, VAR_1, VAR_2); } } }
[ "static void FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "CMD646BAR *cmd646bar = VAR_0;", "if (VAR_3 == 1) {", "ide_ioport_write(cmd646bar->bus, VAR_1, VAR_2);", "} else if (VAR_1 == 0) {", "if (VAR_3 == 2) {", "ide_data_writew(cmd646bar->bus, VAR_1, VAR_2);", "} else {", "ide_data_writel(cmd646bar->bus, VAR_1, VAR_2);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
473
static uint64_t kvm_apic_mem_read(void *opaque, target_phys_addr_t addr, unsigned size) { return ~(uint64_t)0; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t kvm_apic_mem_read(void *opaque, target_phys_addr_t addr, unsigned size) { return ~(uint64_t)0; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size) { return ~(uint64_t)0; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{", "return ~(uint64_t)0;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
475
static uint64_t bonito_cop_readl(void *opaque, target_phys_addr_t addr, unsigned size) { uint32_t val; PCIBonitoState *s = opaque; val = ((uint32_t *)(&s->boncop))[addr/sizeof(uint32_t)]; return val; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t bonito_cop_readl(void *opaque, target_phys_addr_t addr, unsigned size) { uint32_t val; PCIBonitoState *s = opaque; val = ((uint32_t *)(&s->boncop))[addr/sizeof(uint32_t)]; return val; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr, unsigned size) { uint32_t val; PCIBonitoState *s = opaque; val = ((uint32_t *)(&s->boncop))[addr/sizeof(uint32_t)]; return val; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t addr,\nunsigned size)\n{", "uint32_t val;", "PCIBonitoState *s = opaque;", "val = ((uint32_t *)(&s->boncop))[addr/sizeof(uint32_t)];", "return val;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ] ]
476
size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, size_t iov_off, int fillc, size_t size) { size_t iovec_off, buf_off; unsigned int i; iovec_off = 0; buf_off = 0; for (i = 0; i < iov_cnt && size; i++) { if (iov_off < (iovec_off + iov[i].iov_len)) { size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size); memset(iov[i].iov_base + (iov_off - iovec_off), fillc, len); buf_off += len; iov_off += len; size -= len; } iovec_off += iov[i].iov_len; } return buf_off; }
false
qemu
2278a69e7020d86a8c73a28474e7709d3e7d5081
size_t iov_memset(const struct iovec *iov, const unsigned int iov_cnt, size_t iov_off, int fillc, size_t size) { size_t iovec_off, buf_off; unsigned int i; iovec_off = 0; buf_off = 0; for (i = 0; i < iov_cnt && size; i++) { if (iov_off < (iovec_off + iov[i].iov_len)) { size_t len = MIN((iovec_off + iov[i].iov_len) - iov_off , size); memset(iov[i].iov_base + (iov_off - iovec_off), fillc, len); buf_off += len; iov_off += len; size -= len; } iovec_off += iov[i].iov_len; } return buf_off; }
{ "code": [], "line_no": [] }
size_t FUNC_0(const struct iovec *iov, const unsigned int iov_cnt, size_t iov_off, int fillc, size_t size) { size_t iovec_off, buf_off; unsigned int VAR_0; iovec_off = 0; buf_off = 0; for (VAR_0 = 0; VAR_0 < iov_cnt && size; VAR_0++) { if (iov_off < (iovec_off + iov[VAR_0].iov_len)) { size_t len = MIN((iovec_off + iov[VAR_0].iov_len) - iov_off , size); memset(iov[VAR_0].iov_base + (iov_off - iovec_off), fillc, len); buf_off += len; iov_off += len; size -= len; } iovec_off += iov[VAR_0].iov_len; } return buf_off; }
[ "size_t FUNC_0(const struct iovec *iov, const unsigned int iov_cnt,\nsize_t iov_off, int fillc, size_t size)\n{", "size_t iovec_off, buf_off;", "unsigned int VAR_0;", "iovec_off = 0;", "buf_off = 0;", "for (VAR_0 = 0; VAR_0 < iov_cnt && size; VAR_0++) {", "if (iov_off < (iovec_off + iov[VAR_0].iov_len)) {", "size_t len = MIN((iovec_off + iov[VAR_0].iov_len) - iov_off , size);", "memset(iov[VAR_0].iov_base + (iov_off - iovec_off), fillc, len);", "buf_off += len;", "iov_off += len;", "size -= len;", "}", "iovec_off += iov[VAR_0].iov_len;", "}", "return buf_off;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ] ]
477
static int img_open_password(BlockBackend *blk, const char *filename, int flags, bool quiet) { BlockDriverState *bs; char password[256]; bs = blk_bs(blk); if (bdrv_is_encrypted(bs) && !(flags & BDRV_O_NO_IO)) { qprintf(quiet, "Disk image '%s' is encrypted.\n", filename); if (qemu_read_password(password, sizeof(password)) < 0) { error_report("No password given"); return -1; } if (bdrv_set_key(bs, password) < 0) { error_report("invalid password"); return -1; } } return 0; }
false
qemu
4ef130fca87b7a8c77e1af9ca967f28b683811d7
static int img_open_password(BlockBackend *blk, const char *filename, int flags, bool quiet) { BlockDriverState *bs; char password[256]; bs = blk_bs(blk); if (bdrv_is_encrypted(bs) && !(flags & BDRV_O_NO_IO)) { qprintf(quiet, "Disk image '%s' is encrypted.\n", filename); if (qemu_read_password(password, sizeof(password)) < 0) { error_report("No password given"); return -1; } if (bdrv_set_key(bs, password) < 0) { error_report("invalid password"); return -1; } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockBackend *VAR_0, const char *VAR_1, int VAR_2, bool VAR_3) { BlockDriverState *bs; char VAR_4[256]; bs = blk_bs(VAR_0); if (bdrv_is_encrypted(bs) && !(VAR_2 & BDRV_O_NO_IO)) { qprintf(VAR_3, "Disk image '%s' is encrypted.\n", VAR_1); if (qemu_read_password(VAR_4, sizeof(VAR_4)) < 0) { error_report("No VAR_4 given"); return -1; } if (bdrv_set_key(bs, VAR_4) < 0) { error_report("invalid VAR_4"); return -1; } } return 0; }
[ "static int FUNC_0(BlockBackend *VAR_0, const char *VAR_1,\nint VAR_2, bool VAR_3)\n{", "BlockDriverState *bs;", "char VAR_4[256];", "bs = blk_bs(VAR_0);", "if (bdrv_is_encrypted(bs) && !(VAR_2 & BDRV_O_NO_IO)) {", "qprintf(VAR_3, \"Disk image '%s' is encrypted.\\n\", VAR_1);", "if (qemu_read_password(VAR_4, sizeof(VAR_4)) < 0) {", "error_report(\"No VAR_4 given\");", "return -1;", "}", "if (bdrv_set_key(bs, VAR_4) < 0) {", "error_report(\"invalid VAR_4\");", "return -1;", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ] ]
478
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) { const char *codec_name; AVCodec *p; char buf1[32]; int bitrate; AVRational display_aspect_ratio; if (encode) p = avcodec_find_encoder(enc->codec_id); else p = avcodec_find_decoder(enc->codec_id); if (p) { codec_name = p->name; if (!encode && enc->codec_id == CODEC_ID_MP3) { if (enc->sub_id == 2) codec_name = "mp2"; else if (enc->sub_id == 1) codec_name = "mp1"; } } else if (enc->codec_id == CODEC_ID_MPEG2TS) { /* fake mpeg2 transport stream codec (currently not registered) */ codec_name = "mpeg2ts"; } else if (enc->codec_name[0] != '\0') { codec_name = enc->codec_name; } else { /* output avi tags */ if( isprint(enc->codec_tag&0xFF) && isprint((enc->codec_tag>>8)&0xFF) && isprint((enc->codec_tag>>16)&0xFF) && isprint((enc->codec_tag>>24)&0xFF)){ snprintf(buf1, sizeof(buf1), "%c%c%c%c / 0x%04X", enc->codec_tag & 0xff, (enc->codec_tag >> 8) & 0xff, (enc->codec_tag >> 16) & 0xff, (enc->codec_tag >> 24) & 0xff, enc->codec_tag); } else { snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag); } codec_name = buf1; } switch(enc->codec_type) { case CODEC_TYPE_VIDEO: snprintf(buf, buf_size, "Video: %s%s", codec_name, enc->mb_decision ? " (hq)" : ""); if (enc->pix_fmt != PIX_FMT_NONE) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s", avcodec_get_pix_fmt_name(enc->pix_fmt)); } if (enc->width) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %dx%d", enc->width, enc->height); if (enc->sample_aspect_ratio.num) { av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, enc->width*enc->sample_aspect_ratio.num, enc->height*enc->sample_aspect_ratio.den, 1024*1024); snprintf(buf + strlen(buf), buf_size - strlen(buf), " [PAR %d:%d DAR %d:%d]", enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den); } if(av_log_get_level() >= AV_LOG_DEBUG){ int g= ff_gcd(enc->time_base.num, enc->time_base.den); snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %d/%d", enc->time_base.num/g, enc->time_base.den/g); } } if (encode) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", q=%d-%d", enc->qmin, enc->qmax); } bitrate = enc->bit_rate; break; case CODEC_TYPE_AUDIO: snprintf(buf, buf_size, "Audio: %s", codec_name); if (enc->sample_rate) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %d Hz", enc->sample_rate); } av_strlcat(buf, ", ", buf_size); avcodec_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout); if (enc->sample_fmt != SAMPLE_FMT_NONE) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s", avcodec_get_sample_fmt_name(enc->sample_fmt)); } /* for PCM codecs, compute bitrate directly */ switch(enc->codec_id) { case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F64LE: bitrate = enc->sample_rate * enc->channels * 64; break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32BE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_F32LE: bitrate = enc->sample_rate * enc->channels * 32; break; case CODEC_ID_PCM_S24LE: case CODEC_ID_PCM_S24BE: case CODEC_ID_PCM_U24LE: case CODEC_ID_PCM_U24BE: case CODEC_ID_PCM_S24DAUD: bitrate = enc->sample_rate * enc->channels * 24; break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S16LE_PLANAR: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: bitrate = enc->sample_rate * enc->channels * 16; break; case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_ZORK: bitrate = enc->sample_rate * enc->channels * 8; break; default: bitrate = enc->bit_rate; break; } break; case CODEC_TYPE_DATA: snprintf(buf, buf_size, "Data: %s", codec_name); bitrate = enc->bit_rate; break; case CODEC_TYPE_SUBTITLE: snprintf(buf, buf_size, "Subtitle: %s", codec_name); bitrate = enc->bit_rate; break; case CODEC_TYPE_ATTACHMENT: snprintf(buf, buf_size, "Attachment: %s", codec_name); bitrate = enc->bit_rate; break; default: snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type); return; } if (encode) { if (enc->flags & CODEC_FLAG_PASS1) snprintf(buf + strlen(buf), buf_size - strlen(buf), ", pass 1"); if (enc->flags & CODEC_FLAG_PASS2) snprintf(buf + strlen(buf), buf_size - strlen(buf), ", pass 2"); } if (bitrate != 0) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %d kb/s", bitrate / 1000); } }
false
FFmpeg
c9b3c0c740ac912c835ccb7179afc2c5da8d5d23
void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode) { const char *codec_name; AVCodec *p; char buf1[32]; int bitrate; AVRational display_aspect_ratio; if (encode) p = avcodec_find_encoder(enc->codec_id); else p = avcodec_find_decoder(enc->codec_id); if (p) { codec_name = p->name; if (!encode && enc->codec_id == CODEC_ID_MP3) { if (enc->sub_id == 2) codec_name = "mp2"; else if (enc->sub_id == 1) codec_name = "mp1"; } } else if (enc->codec_id == CODEC_ID_MPEG2TS) { codec_name = "mpeg2ts"; } else if (enc->codec_name[0] != '\0') { codec_name = enc->codec_name; } else { if( isprint(enc->codec_tag&0xFF) && isprint((enc->codec_tag>>8)&0xFF) && isprint((enc->codec_tag>>16)&0xFF) && isprint((enc->codec_tag>>24)&0xFF)){ snprintf(buf1, sizeof(buf1), "%c%c%c%c / 0x%04X", enc->codec_tag & 0xff, (enc->codec_tag >> 8) & 0xff, (enc->codec_tag >> 16) & 0xff, (enc->codec_tag >> 24) & 0xff, enc->codec_tag); } else { snprintf(buf1, sizeof(buf1), "0x%04x", enc->codec_tag); } codec_name = buf1; } switch(enc->codec_type) { case CODEC_TYPE_VIDEO: snprintf(buf, buf_size, "Video: %s%s", codec_name, enc->mb_decision ? " (hq)" : ""); if (enc->pix_fmt != PIX_FMT_NONE) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s", avcodec_get_pix_fmt_name(enc->pix_fmt)); } if (enc->width) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %dx%d", enc->width, enc->height); if (enc->sample_aspect_ratio.num) { av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, enc->width*enc->sample_aspect_ratio.num, enc->height*enc->sample_aspect_ratio.den, 1024*1024); snprintf(buf + strlen(buf), buf_size - strlen(buf), " [PAR %d:%d DAR %d:%d]", enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den); } if(av_log_get_level() >= AV_LOG_DEBUG){ int g= ff_gcd(enc->time_base.num, enc->time_base.den); snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %d/%d", enc->time_base.num/g, enc->time_base.den/g); } } if (encode) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", q=%d-%d", enc->qmin, enc->qmax); } bitrate = enc->bit_rate; break; case CODEC_TYPE_AUDIO: snprintf(buf, buf_size, "Audio: %s", codec_name); if (enc->sample_rate) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %d Hz", enc->sample_rate); } av_strlcat(buf, ", ", buf_size); avcodec_get_channel_layout_string(buf + strlen(buf), buf_size - strlen(buf), enc->channels, enc->channel_layout); if (enc->sample_fmt != SAMPLE_FMT_NONE) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %s", avcodec_get_sample_fmt_name(enc->sample_fmt)); } switch(enc->codec_id) { case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F64LE: bitrate = enc->sample_rate * enc->channels * 64; break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32BE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_F32LE: bitrate = enc->sample_rate * enc->channels * 32; break; case CODEC_ID_PCM_S24LE: case CODEC_ID_PCM_S24BE: case CODEC_ID_PCM_U24LE: case CODEC_ID_PCM_U24BE: case CODEC_ID_PCM_S24DAUD: bitrate = enc->sample_rate * enc->channels * 24; break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S16LE_PLANAR: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: bitrate = enc->sample_rate * enc->channels * 16; break; case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_ZORK: bitrate = enc->sample_rate * enc->channels * 8; break; default: bitrate = enc->bit_rate; break; } break; case CODEC_TYPE_DATA: snprintf(buf, buf_size, "Data: %s", codec_name); bitrate = enc->bit_rate; break; case CODEC_TYPE_SUBTITLE: snprintf(buf, buf_size, "Subtitle: %s", codec_name); bitrate = enc->bit_rate; break; case CODEC_TYPE_ATTACHMENT: snprintf(buf, buf_size, "Attachment: %s", codec_name); bitrate = enc->bit_rate; break; default: snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type); return; } if (encode) { if (enc->flags & CODEC_FLAG_PASS1) snprintf(buf + strlen(buf), buf_size - strlen(buf), ", pass 1"); if (enc->flags & CODEC_FLAG_PASS2) snprintf(buf + strlen(buf), buf_size - strlen(buf), ", pass 2"); } if (bitrate != 0) { snprintf(buf + strlen(buf), buf_size - strlen(buf), ", %d kb/s", bitrate / 1000); } }
{ "code": [], "line_no": [] }
void FUNC_0(char *VAR_0, int VAR_1, AVCodecContext *VAR_2, int VAR_3) { const char *VAR_4; AVCodec *p; char VAR_5[32]; int VAR_6; AVRational display_aspect_ratio; if (VAR_3) p = avcodec_find_encoder(VAR_2->codec_id); else p = avcodec_find_decoder(VAR_2->codec_id); if (p) { VAR_4 = p->name; if (!VAR_3 && VAR_2->codec_id == CODEC_ID_MP3) { if (VAR_2->sub_id == 2) VAR_4 = "mp2"; else if (VAR_2->sub_id == 1) VAR_4 = "mp1"; } } else if (VAR_2->codec_id == CODEC_ID_MPEG2TS) { VAR_4 = "mpeg2ts"; } else if (VAR_2->VAR_4[0] != '\0') { VAR_4 = VAR_2->VAR_4; } else { if( isprint(VAR_2->codec_tag&0xFF) && isprint((VAR_2->codec_tag>>8)&0xFF) && isprint((VAR_2->codec_tag>>16)&0xFF) && isprint((VAR_2->codec_tag>>24)&0xFF)){ snprintf(VAR_5, sizeof(VAR_5), "%c%c%c%c / 0x%04X", VAR_2->codec_tag & 0xff, (VAR_2->codec_tag >> 8) & 0xff, (VAR_2->codec_tag >> 16) & 0xff, (VAR_2->codec_tag >> 24) & 0xff, VAR_2->codec_tag); } else { snprintf(VAR_5, sizeof(VAR_5), "0x%04x", VAR_2->codec_tag); } VAR_4 = VAR_5; } switch(VAR_2->codec_type) { case CODEC_TYPE_VIDEO: snprintf(VAR_0, VAR_1, "Video: %s%s", VAR_4, VAR_2->mb_decision ? " (hq)" : ""); if (VAR_2->pix_fmt != PIX_FMT_NONE) { snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), ", %s", avcodec_get_pix_fmt_name(VAR_2->pix_fmt)); } if (VAR_2->width) { snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), ", %dx%d", VAR_2->width, VAR_2->height); if (VAR_2->sample_aspect_ratio.num) { av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, VAR_2->width*VAR_2->sample_aspect_ratio.num, VAR_2->height*VAR_2->sample_aspect_ratio.den, 1024*1024); snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), " [PAR %d:%d DAR %d:%d]", VAR_2->sample_aspect_ratio.num, VAR_2->sample_aspect_ratio.den, display_aspect_ratio.num, display_aspect_ratio.den); } if(av_log_get_level() >= AV_LOG_DEBUG){ int VAR_7= ff_gcd(VAR_2->time_base.num, VAR_2->time_base.den); snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), ", %d/%d", VAR_2->time_base.num/VAR_7, VAR_2->time_base.den/VAR_7); } } if (VAR_3) { snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), ", q=%d-%d", VAR_2->qmin, VAR_2->qmax); } VAR_6 = VAR_2->bit_rate; break; case CODEC_TYPE_AUDIO: snprintf(VAR_0, VAR_1, "Audio: %s", VAR_4); if (VAR_2->sample_rate) { snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), ", %d Hz", VAR_2->sample_rate); } av_strlcat(VAR_0, ", ", VAR_1); avcodec_get_channel_layout_string(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), VAR_2->channels, VAR_2->channel_layout); if (VAR_2->sample_fmt != SAMPLE_FMT_NONE) { snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), ", %s", avcodec_get_sample_fmt_name(VAR_2->sample_fmt)); } switch(VAR_2->codec_id) { case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F64LE: VAR_6 = VAR_2->sample_rate * VAR_2->channels * 64; break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_S32BE: case CODEC_ID_PCM_U32LE: case CODEC_ID_PCM_U32BE: case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_F32LE: VAR_6 = VAR_2->sample_rate * VAR_2->channels * 32; break; case CODEC_ID_PCM_S24LE: case CODEC_ID_PCM_S24BE: case CODEC_ID_PCM_U24LE: case CODEC_ID_PCM_U24BE: case CODEC_ID_PCM_S24DAUD: VAR_6 = VAR_2->sample_rate * VAR_2->channels * 24; break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S16LE_PLANAR: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: VAR_6 = VAR_2->sample_rate * VAR_2->channels * 16; break; case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_ZORK: VAR_6 = VAR_2->sample_rate * VAR_2->channels * 8; break; default: VAR_6 = VAR_2->bit_rate; break; } break; case CODEC_TYPE_DATA: snprintf(VAR_0, VAR_1, "Data: %s", VAR_4); VAR_6 = VAR_2->bit_rate; break; case CODEC_TYPE_SUBTITLE: snprintf(VAR_0, VAR_1, "Subtitle: %s", VAR_4); VAR_6 = VAR_2->bit_rate; break; case CODEC_TYPE_ATTACHMENT: snprintf(VAR_0, VAR_1, "Attachment: %s", VAR_4); VAR_6 = VAR_2->bit_rate; break; default: snprintf(VAR_0, VAR_1, "Invalid Codec type %d", VAR_2->codec_type); return; } if (VAR_3) { if (VAR_2->flags & CODEC_FLAG_PASS1) snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), ", pass 1"); if (VAR_2->flags & CODEC_FLAG_PASS2) snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), ", pass 2"); } if (VAR_6 != 0) { snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), ", %d kb/s", VAR_6 / 1000); } }
[ "void FUNC_0(char *VAR_0, int VAR_1, AVCodecContext *VAR_2, int VAR_3)\n{", "const char *VAR_4;", "AVCodec *p;", "char VAR_5[32];", "int VAR_6;", "AVRational display_aspect_ratio;", "if (VAR_3)\np = avcodec_find_encoder(VAR_2->codec_id);", "else\np = avcodec_find_decoder(VAR_2->codec_id);", "if (p) {", "VAR_4 = p->name;", "if (!VAR_3 && VAR_2->codec_id == CODEC_ID_MP3) {", "if (VAR_2->sub_id == 2)\nVAR_4 = \"mp2\";", "else if (VAR_2->sub_id == 1)\nVAR_4 = \"mp1\";", "}", "} else if (VAR_2->codec_id == CODEC_ID_MPEG2TS) {", "VAR_4 = \"mpeg2ts\";", "} else if (VAR_2->VAR_4[0] != '\\0') {", "VAR_4 = VAR_2->VAR_4;", "} else {", "if( isprint(VAR_2->codec_tag&0xFF) && isprint((VAR_2->codec_tag>>8)&0xFF)\n&& isprint((VAR_2->codec_tag>>16)&0xFF) && isprint((VAR_2->codec_tag>>24)&0xFF)){", "snprintf(VAR_5, sizeof(VAR_5), \"%c%c%c%c / 0x%04X\",\nVAR_2->codec_tag & 0xff,\n(VAR_2->codec_tag >> 8) & 0xff,\n(VAR_2->codec_tag >> 16) & 0xff,\n(VAR_2->codec_tag >> 24) & 0xff,\nVAR_2->codec_tag);", "} else {", "snprintf(VAR_5, sizeof(VAR_5), \"0x%04x\", VAR_2->codec_tag);", "}", "VAR_4 = VAR_5;", "}", "switch(VAR_2->codec_type) {", "case CODEC_TYPE_VIDEO:\nsnprintf(VAR_0, VAR_1,\n\"Video: %s%s\",\nVAR_4, VAR_2->mb_decision ? \" (hq)\" : \"\");", "if (VAR_2->pix_fmt != PIX_FMT_NONE) {", "snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\", %s\",\navcodec_get_pix_fmt_name(VAR_2->pix_fmt));", "}", "if (VAR_2->width) {", "snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\", %dx%d\",\nVAR_2->width, VAR_2->height);", "if (VAR_2->sample_aspect_ratio.num) {", "av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,\nVAR_2->width*VAR_2->sample_aspect_ratio.num,\nVAR_2->height*VAR_2->sample_aspect_ratio.den,\n1024*1024);", "snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\" [PAR %d:%d DAR %d:%d]\",\nVAR_2->sample_aspect_ratio.num, VAR_2->sample_aspect_ratio.den,\ndisplay_aspect_ratio.num, display_aspect_ratio.den);", "}", "if(av_log_get_level() >= AV_LOG_DEBUG){", "int VAR_7= ff_gcd(VAR_2->time_base.num, VAR_2->time_base.den);", "snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\", %d/%d\",\nVAR_2->time_base.num/VAR_7, VAR_2->time_base.den/VAR_7);", "}", "}", "if (VAR_3) {", "snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\", q=%d-%d\", VAR_2->qmin, VAR_2->qmax);", "}", "VAR_6 = VAR_2->bit_rate;", "break;", "case CODEC_TYPE_AUDIO:\nsnprintf(VAR_0, VAR_1,\n\"Audio: %s\",\nVAR_4);", "if (VAR_2->sample_rate) {", "snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\", %d Hz\", VAR_2->sample_rate);", "}", "av_strlcat(VAR_0, \", \", VAR_1);", "avcodec_get_channel_layout_string(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0), VAR_2->channels, VAR_2->channel_layout);", "if (VAR_2->sample_fmt != SAMPLE_FMT_NONE) {", "snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\", %s\", avcodec_get_sample_fmt_name(VAR_2->sample_fmt));", "}", "switch(VAR_2->codec_id) {", "case CODEC_ID_PCM_F64BE:\ncase CODEC_ID_PCM_F64LE:\nVAR_6 = VAR_2->sample_rate * VAR_2->channels * 64;", "break;", "case CODEC_ID_PCM_S32LE:\ncase CODEC_ID_PCM_S32BE:\ncase CODEC_ID_PCM_U32LE:\ncase CODEC_ID_PCM_U32BE:\ncase CODEC_ID_PCM_F32BE:\ncase CODEC_ID_PCM_F32LE:\nVAR_6 = VAR_2->sample_rate * VAR_2->channels * 32;", "break;", "case CODEC_ID_PCM_S24LE:\ncase CODEC_ID_PCM_S24BE:\ncase CODEC_ID_PCM_U24LE:\ncase CODEC_ID_PCM_U24BE:\ncase CODEC_ID_PCM_S24DAUD:\nVAR_6 = VAR_2->sample_rate * VAR_2->channels * 24;", "break;", "case CODEC_ID_PCM_S16LE:\ncase CODEC_ID_PCM_S16BE:\ncase CODEC_ID_PCM_S16LE_PLANAR:\ncase CODEC_ID_PCM_U16LE:\ncase CODEC_ID_PCM_U16BE:\nVAR_6 = VAR_2->sample_rate * VAR_2->channels * 16;", "break;", "case CODEC_ID_PCM_S8:\ncase CODEC_ID_PCM_U8:\ncase CODEC_ID_PCM_ALAW:\ncase CODEC_ID_PCM_MULAW:\ncase CODEC_ID_PCM_ZORK:\nVAR_6 = VAR_2->sample_rate * VAR_2->channels * 8;", "break;", "default:\nVAR_6 = VAR_2->bit_rate;", "break;", "}", "break;", "case CODEC_TYPE_DATA:\nsnprintf(VAR_0, VAR_1, \"Data: %s\", VAR_4);", "VAR_6 = VAR_2->bit_rate;", "break;", "case CODEC_TYPE_SUBTITLE:\nsnprintf(VAR_0, VAR_1, \"Subtitle: %s\", VAR_4);", "VAR_6 = VAR_2->bit_rate;", "break;", "case CODEC_TYPE_ATTACHMENT:\nsnprintf(VAR_0, VAR_1, \"Attachment: %s\", VAR_4);", "VAR_6 = VAR_2->bit_rate;", "break;", "default:\nsnprintf(VAR_0, VAR_1, \"Invalid Codec type %d\", VAR_2->codec_type);", "return;", "}", "if (VAR_3) {", "if (VAR_2->flags & CODEC_FLAG_PASS1)\nsnprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\", pass 1\");", "if (VAR_2->flags & CODEC_FLAG_PASS2)\nsnprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\", pass 2\");", "}", "if (VAR_6 != 0) {", "snprintf(VAR_0 + strlen(VAR_0), VAR_1 - strlen(VAR_0),\n\", %d kb/s\", VAR_6 / 1000);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59, 61 ], [ 63, 65, 67, 69, 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89, 91, 93, 95 ], [ 97 ], [ 99, 101, 103 ], [ 105 ], [ 107 ], [ 109, 111, 113 ], [ 115 ], [ 117, 119, 121, 123 ], [ 125, 127, 129, 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139, 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151, 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161, 163, 165, 167 ], [ 169 ], [ 171, 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 193 ], [ 195, 197, 199 ], [ 201 ], [ 203, 205, 207, 209, 211, 213, 215 ], [ 217 ], [ 219, 221, 223, 225, 227, 229 ], [ 231 ], [ 233, 235, 237, 239, 241, 243 ], [ 245 ], [ 247, 249, 251, 253, 255, 257 ], [ 259 ], [ 261, 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271, 273 ], [ 275 ], [ 277 ], [ 279, 281 ], [ 283 ], [ 285 ], [ 287, 289 ], [ 291 ], [ 293 ], [ 295, 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305, 307, 309 ], [ 311, 313, 315 ], [ 317 ], [ 319 ], [ 321, 323 ], [ 325 ], [ 327 ] ]
479
static int transcode_init(OutputFile *output_files, int nb_output_files, InputFile *input_files, int nb_input_files) { int ret = 0, i, j; AVFormatContext *os; AVCodecContext *codec, *icodec; OutputStream *ost; InputStream *ist; char error[1024]; int want_sdp = 1; /* init framerate emulation */ for (i = 0; i < nb_input_files; i++) { InputFile *ifile = &input_files[i]; if (ifile->rate_emu) for (j = 0; j < ifile->nb_streams; j++) input_streams[j + ifile->ist_index].start = av_gettime(); } /* output stream init */ for(i=0;i<nb_output_files;i++) { os = output_files[i].ctx; if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(os, i, os->filename, 1); fprintf(stderr, "Output file #%d does not contain any stream\n", i); return AVERROR(EINVAL); } } /* for each output stream, we compute the right encoding parameters */ for (i = 0; i < nb_output_streams; i++) { ost = &output_streams[i]; os = output_files[ost->file_index].ctx; ist = &input_streams[ost->source_index]; codec = ost->st->codec; icodec = ist->st->codec; ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) { return AVERROR(EINVAL); } /* if stream_copy is selected, no need to decode or encode */ codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if(!codec->codec_tag){ if( !os->oformat->codec_tag || av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->extradata= av_mallocz(extra_size); if (!codec->extradata) { return AVERROR(ENOMEM); } memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n"); exit_program(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align= icodec->block_align; if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3) codec->block_align= 0; if(codec->codec_id == CODEC_ID_AC3) codec->block_align= 0; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; if (!codec->sample_aspect_ratio.num) { codec->sample_aspect_ratio = ost->st->sample_aspect_ratio = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : ist->st->codec->sample_aspect_ratio.num ? ist->st->codec->sample_aspect_ratio : (AVRational){0, 1}; } break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; case AVMEDIA_TYPE_DATA: break; default: abort(); } } else { if (!ost->enc) ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if (!ost->fifo) { return AVERROR(ENOMEM); } ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); if (!codec->sample_rate) { codec->sample_rate = icodec->sample_rate; if (icodec->lowres) codec->sample_rate >>= icodec->lowres; } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) codec->sample_fmt = icodec->sample_fmt; choose_sample_fmt(ost->st, ost->enc); if (!codec->channels) codec->channels = icodec->channels; codec->channel_layout = icodec->channel_layout; if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; break; case AVMEDIA_TYPE_VIDEO: if (codec->pix_fmt == PIX_FMT_NONE) codec->pix_fmt = icodec->pix_fmt; choose_pixel_fmt(ost->st, ost->enc); if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); exit_program(1); } if (!codec->width || !codec->height) { codec->width = icodec->width; codec->height = icodec->height; } ost->video_resample = codec->width != icodec->width || codec->height != icodec->height || codec->pix_fmt != icodec->pix_fmt; if (ost->video_resample) { #if !CONFIG_AVFILTER avcodec_get_frame_defaults(&ost->pict_tmp); if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt, codec->width, codec->height)) { fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n"); exit_program(1); } ost->img_resample_ctx = sws_getContext( icodec->width, icodec->height, icodec->pix_fmt, codec->width, codec->height, codec->pix_fmt, ost->sws_flags, NULL, NULL, NULL); if (ost->img_resample_ctx == NULL) { fprintf(stderr, "Cannot get resampling context\n"); exit_program(1); } #endif codec->bits_per_raw_sample= 0; } ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; ost->encoding_needed = 1; ist->decoding_needed = 1; if (!ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1}; if (ost->enc && ost->enc->supported_framerates && !force_fps) { int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[idx]; } codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num}; #if CONFIG_AVFILTER if (configure_video_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\n"); exit(1); } #endif break; case AVMEDIA_TYPE_SUBTITLE: ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: abort(); break; } /* two pass mode */ if (ost->encoding_needed && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, i); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); exit_program(1); } ost->logfile = f; } else { char *logbuffer; size_t logbuffer_size; if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename); exit_program(1); } codec->stats_in = logbuffer; } } } if(codec->codec_type == AVMEDIA_TYPE_VIDEO){ int size= codec->width * codec->height; bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 200); } } if (!bit_buffer) bit_buffer = av_malloc(bit_buffer_size); if (!bit_buffer) { fprintf(stderr, "Cannot allocate %d bytes output buffer\n", bit_buffer_size); return AVERROR(ENOMEM); } /* open each encoder */ for (i = 0; i < nb_output_streams; i++) { ost = &output_streams[i]; if (ost->encoding_needed) { AVCodec *codec = ost->enc; AVCodecContext *dec = input_streams[ost->source_index].st->codec; if (!codec) { snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d", ost->st->codec->codec_id, ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } if (dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { ret = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ost->st->codec, 1); assert_avoptions(ost->opts); if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." "It takes bits/s as argument, not kbits/s\n"); extra_size += ost->st->codec->extradata_size; } } /* init input streams */ for (i = 0; i < nb_input_streams; i++) if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error))) < 0) goto dump_format; /* open files and write file headers */ for (i = 0; i < nb_output_files; i++) { os = output_files[i].ctx; if (avformat_write_header(os, &output_files[i].opts) < 0) { snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i); ret = AVERROR(EINVAL); goto dump_format; } assert_avoptions(output_files[i].opts); if (strcmp(os->oformat->name, "rtp")) { want_sdp = 0; } } dump_format: /* dump the file output parameters - cannot be done before in case of stream copy */ for(i=0;i<nb_output_files;i++) { av_dump_format(output_files[i].ctx, i, output_files[i].ctx->filename, 1); } /* dump the stream mapping */ if (verbose >= 0) { fprintf(stderr, "Stream mapping:\n"); for (i = 0; i < nb_output_streams;i ++) { ost = &output_streams[i]; fprintf(stderr, " Stream #%d.%d -> #%d.%d", input_streams[ost->source_index].file_index, input_streams[ost->source_index].st->index, ost->file_index, ost->index); if (ost->sync_ist != &input_streams[ost->source_index]) fprintf(stderr, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->st->index); if (ost->st->stream_copy) fprintf(stderr, " (copy)"); else fprintf(stderr, " (%s -> %s)", input_streams[ost->source_index].dec ? input_streams[ost->source_index].dec->name : "?", ost->enc ? ost->enc->name : "?"); fprintf(stderr, "\n"); } } if (ret) { fprintf(stderr, "%s\n", error); return ret; } if (want_sdp) { print_sdp(output_files, nb_output_files); } return 0; }
false
FFmpeg
2c474ddbc5b90541ea4a65961490b6469d12529f
static int transcode_init(OutputFile *output_files, int nb_output_files, InputFile *input_files, int nb_input_files) { int ret = 0, i, j; AVFormatContext *os; AVCodecContext *codec, *icodec; OutputStream *ost; InputStream *ist; char error[1024]; int want_sdp = 1; for (i = 0; i < nb_input_files; i++) { InputFile *ifile = &input_files[i]; if (ifile->rate_emu) for (j = 0; j < ifile->nb_streams; j++) input_streams[j + ifile->ist_index].start = av_gettime(); } for(i=0;i<nb_output_files;i++) { os = output_files[i].ctx; if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(os, i, os->filename, 1); fprintf(stderr, "Output file #%d does not contain any stream\n", i); return AVERROR(EINVAL); } } for (i = 0; i < nb_output_streams; i++) { ost = &output_streams[i]; os = output_files[ost->file_index].ctx; ist = &input_streams[ost->source_index]; codec = ost->st->codec; icodec = ist->st->codec; ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) { return AVERROR(EINVAL); } codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if(!codec->codec_tag){ if( !os->oformat->codec_tag || av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->extradata= av_mallocz(extra_size); if (!codec->extradata) { return AVERROR(ENOMEM); } memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n"); exit_program(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align= icodec->block_align; if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3) codec->block_align= 0; if(codec->codec_id == CODEC_ID_AC3) codec->block_align= 0; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; if (!codec->sample_aspect_ratio.num) { codec->sample_aspect_ratio = ost->st->sample_aspect_ratio = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : ist->st->codec->sample_aspect_ratio.num ? ist->st->codec->sample_aspect_ratio : (AVRational){0, 1}; } break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; case AVMEDIA_TYPE_DATA: break; default: abort(); } } else { if (!ost->enc) ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if (!ost->fifo) { return AVERROR(ENOMEM); } ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); if (!codec->sample_rate) { codec->sample_rate = icodec->sample_rate; if (icodec->lowres) codec->sample_rate >>= icodec->lowres; } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) codec->sample_fmt = icodec->sample_fmt; choose_sample_fmt(ost->st, ost->enc); if (!codec->channels) codec->channels = icodec->channels; codec->channel_layout = icodec->channel_layout; if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; break; case AVMEDIA_TYPE_VIDEO: if (codec->pix_fmt == PIX_FMT_NONE) codec->pix_fmt = icodec->pix_fmt; choose_pixel_fmt(ost->st, ost->enc); if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); exit_program(1); } if (!codec->width || !codec->height) { codec->width = icodec->width; codec->height = icodec->height; } ost->video_resample = codec->width != icodec->width || codec->height != icodec->height || codec->pix_fmt != icodec->pix_fmt; if (ost->video_resample) { #if !CONFIG_AVFILTER avcodec_get_frame_defaults(&ost->pict_tmp); if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt, codec->width, codec->height)) { fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n"); exit_program(1); } ost->img_resample_ctx = sws_getContext( icodec->width, icodec->height, icodec->pix_fmt, codec->width, codec->height, codec->pix_fmt, ost->sws_flags, NULL, NULL, NULL); if (ost->img_resample_ctx == NULL) { fprintf(stderr, "Cannot get resampling context\n"); exit_program(1); } #endif codec->bits_per_raw_sample= 0; } ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; ost->encoding_needed = 1; ist->decoding_needed = 1; if (!ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1}; if (ost->enc && ost->enc->supported_framerates && !force_fps) { int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[idx]; } codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num}; #if CONFIG_AVFILTER if (configure_video_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\n"); exit(1); } #endif break; case AVMEDIA_TYPE_SUBTITLE: ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: abort(); break; } if (ost->encoding_needed && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, i); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); exit_program(1); } ost->logfile = f; } else { char *logbuffer; size_t logbuffer_size; if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename); exit_program(1); } codec->stats_in = logbuffer; } } } if(codec->codec_type == AVMEDIA_TYPE_VIDEO){ int size= codec->width * codec->height; bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 200); } } if (!bit_buffer) bit_buffer = av_malloc(bit_buffer_size); if (!bit_buffer) { fprintf(stderr, "Cannot allocate %d bytes output buffer\n", bit_buffer_size); return AVERROR(ENOMEM); } for (i = 0; i < nb_output_streams; i++) { ost = &output_streams[i]; if (ost->encoding_needed) { AVCodec *codec = ost->enc; AVCodecContext *dec = input_streams[ost->source_index].st->codec; if (!codec) { snprintf(error, sizeof(error), "Encoder (codec id %d) not found for output stream #%d.%d", ost->st->codec->codec_id, ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } if (dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { ret = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); ret = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ost->st->codec, 1); assert_avoptions(ost->opts); if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." "It takes bits/s as argument, not kbits/s\n"); extra_size += ost->st->codec->extradata_size; } } for (i = 0; i < nb_input_streams; i++) if ((ret = init_input_stream(i, output_streams, nb_output_streams, error, sizeof(error))) < 0) goto dump_format; for (i = 0; i < nb_output_files; i++) { os = output_files[i].ctx; if (avformat_write_header(os, &output_files[i].opts) < 0) { snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i); ret = AVERROR(EINVAL); goto dump_format; } assert_avoptions(output_files[i].opts); if (strcmp(os->oformat->name, "rtp")) { want_sdp = 0; } } dump_format: for(i=0;i<nb_output_files;i++) { av_dump_format(output_files[i].ctx, i, output_files[i].ctx->filename, 1); } if (verbose >= 0) { fprintf(stderr, "Stream mapping:\n"); for (i = 0; i < nb_output_streams;i ++) { ost = &output_streams[i]; fprintf(stderr, " Stream #%d.%d -> #%d.%d", input_streams[ost->source_index].file_index, input_streams[ost->source_index].st->index, ost->file_index, ost->index); if (ost->sync_ist != &input_streams[ost->source_index]) fprintf(stderr, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->st->index); if (ost->st->stream_copy) fprintf(stderr, " (copy)"); else fprintf(stderr, " (%s -> %s)", input_streams[ost->source_index].dec ? input_streams[ost->source_index].dec->name : "?", ost->enc ? ost->enc->name : "?"); fprintf(stderr, "\n"); } } if (ret) { fprintf(stderr, "%s\n", error); return ret; } if (want_sdp) { print_sdp(output_files, nb_output_files); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(OutputFile *VAR_0, int VAR_1, InputFile *VAR_2, int VAR_3) { int VAR_4 = 0, VAR_5, VAR_6; AVFormatContext *os; AVCodecContext *codec, *icodec; OutputStream *ost; InputStream *ist; char VAR_7[1024]; int VAR_8 = 1; for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) { InputFile *ifile = &VAR_2[VAR_5]; if (ifile->rate_emu) for (VAR_6 = 0; VAR_6 < ifile->nb_streams; VAR_6++) input_streams[VAR_6 + ifile->ist_index].start = av_gettime(); } for(VAR_5=0;VAR_5<VAR_1;VAR_5++) { os = VAR_0[VAR_5].ctx; if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) { av_dump_format(os, VAR_5, os->filename, 1); fprintf(stderr, "Output file #%d does not contain any stream\n", VAR_5); return AVERROR(EINVAL); } } for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) { ost = &output_streams[VAR_5]; os = VAR_0[ost->file_index].ctx; ist = &input_streams[ost->source_index]; codec = ost->st->codec; icodec = ist->st->codec; ost->st->disposition = ist->st->disposition; codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; if (ost->st->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) { return AVERROR(EINVAL); } codec->codec_id = icodec->codec_id; codec->codec_type = icodec->codec_type; if(!codec->codec_tag){ if( !os->oformat->codec_tag || av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0) codec->codec_tag = icodec->codec_tag; } codec->bit_rate = icodec->bit_rate; codec->rc_max_rate = icodec->rc_max_rate; codec->rc_buffer_size = icodec->rc_buffer_size; codec->extradata= av_mallocz(extra_size); if (!codec->extradata) { return AVERROR(ENOMEM); } memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); codec->extradata_size= icodec->extradata_size; if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ codec->time_base = icodec->time_base; codec->time_base.num *= icodec->ticks_per_frame; av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); }else codec->time_base = ist->st->time_base; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(audio_volume != 256) { fprintf(stderr,"-acodec copy and -vol are incompatible (frames are not decoded)\n"); exit_program(1); } codec->channel_layout = icodec->channel_layout; codec->sample_rate = icodec->sample_rate; codec->channels = icodec->channels; codec->frame_size = icodec->frame_size; codec->audio_service_type = icodec->audio_service_type; codec->block_align= icodec->block_align; if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3) codec->block_align= 0; if(codec->codec_id == CODEC_ID_AC3) codec->block_align= 0; break; case AVMEDIA_TYPE_VIDEO: codec->pix_fmt = icodec->pix_fmt; codec->width = icodec->width; codec->height = icodec->height; codec->has_b_frames = icodec->has_b_frames; if (!codec->sample_aspect_ratio.num) { codec->sample_aspect_ratio = ost->st->sample_aspect_ratio = ist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio : ist->st->codec->sample_aspect_ratio.num ? ist->st->codec->sample_aspect_ratio : (AVRational){0, 1}; } break; case AVMEDIA_TYPE_SUBTITLE: codec->width = icodec->width; codec->height = icodec->height; break; case AVMEDIA_TYPE_DATA: break; default: abort(); } } else { if (!ost->enc) ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if (!ost->fifo) { return AVERROR(ENOMEM); } ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); if (!codec->sample_rate) { codec->sample_rate = icodec->sample_rate; if (icodec->lowres) codec->sample_rate >>= icodec->lowres; } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) codec->sample_fmt = icodec->sample_fmt; choose_sample_fmt(ost->st, ost->enc); if (!codec->channels) codec->channels = icodec->channels; codec->channel_layout = icodec->channel_layout; if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; ist->decoding_needed = 1; ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; break; case AVMEDIA_TYPE_VIDEO: if (codec->pix_fmt == PIX_FMT_NONE) codec->pix_fmt = icodec->pix_fmt; choose_pixel_fmt(ost->st, ost->enc); if (ost->st->codec->pix_fmt == PIX_FMT_NONE) { fprintf(stderr, "Video pixel format is unknown, stream cannot be encoded\n"); exit_program(1); } if (!codec->width || !codec->height) { codec->width = icodec->width; codec->height = icodec->height; } ost->video_resample = codec->width != icodec->width || codec->height != icodec->height || codec->pix_fmt != icodec->pix_fmt; if (ost->video_resample) { #if !CONFIG_AVFILTER avcodec_get_frame_defaults(&ost->pict_tmp); if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt, codec->width, codec->height)) { fprintf(stderr, "Cannot allocate temp picture, check pix fmt\n"); exit_program(1); } ost->img_resample_ctx = sws_getContext( icodec->width, icodec->height, icodec->pix_fmt, codec->width, codec->height, codec->pix_fmt, ost->sws_flags, NULL, NULL, NULL); if (ost->img_resample_ctx == NULL) { fprintf(stderr, "Cannot get resampling context\n"); exit_program(1); } #endif codec->bits_per_raw_sample= 0; } ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; ost->encoding_needed = 1; ist->decoding_needed = 1; if (!ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1}; if (ost->enc && ost->enc->supported_framerates && !force_fps) { int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); ost->frame_rate = ost->enc->supported_framerates[idx]; } codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num}; #if CONFIG_AVFILTER if (configure_video_filters(ist, ost)) { fprintf(stderr, "Error opening filters!\n"); exit(1); } #endif break; case AVMEDIA_TYPE_SUBTITLE: ost->encoding_needed = 1; ist->decoding_needed = 1; break; default: abort(); break; } if (ost->encoding_needed && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, VAR_5); if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "wb"); if (!f) { fprintf(stderr, "Cannot write log file '%s' for pass-1 encoding: %s\n", logfilename, strerror(errno)); exit_program(1); } ost->logfile = f; } else { char *logbuffer; size_t logbuffer_size; if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { fprintf(stderr, "Error reading log file '%s' for pass-2 encoding\n", logfilename); exit_program(1); } codec->stats_in = logbuffer; } } } if(codec->codec_type == AVMEDIA_TYPE_VIDEO){ int size= codec->width * codec->height; bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 200); } } if (!bit_buffer) bit_buffer = av_malloc(bit_buffer_size); if (!bit_buffer) { fprintf(stderr, "Cannot allocate %d bytes output buffer\n", bit_buffer_size); return AVERROR(ENOMEM); } for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) { ost = &output_streams[VAR_5]; if (ost->encoding_needed) { AVCodec *codec = ost->enc; AVCodecContext *dec = input_streams[ost->source_index].st->codec; if (!codec) { snprintf(VAR_7, sizeof(VAR_7), "Encoder (codec id %d) not found for output stream #%d.%d", ost->st->codec->codec_id, ost->file_index, ost->index); VAR_4 = AVERROR(EINVAL); goto dump_format; } if (dec->subtitle_header) { ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size); if (!ost->st->codec->subtitle_header) { VAR_4 = AVERROR(ENOMEM); goto dump_format; } memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); ost->st->codec->subtitle_header_size = dec->subtitle_header_size; } if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) { snprintf(VAR_7, sizeof(VAR_7), "Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height", ost->file_index, ost->index); VAR_4 = AVERROR(EINVAL); goto dump_format; } assert_codec_experimental(ost->st->codec, 1); assert_avoptions(ost->opts); if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." "It takes bits/s as argument, not kbits/s\n"); extra_size += ost->st->codec->extradata_size; } } for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++) if ((VAR_4 = init_input_stream(VAR_5, output_streams, nb_output_streams, VAR_7, sizeof(VAR_7))) < 0) goto dump_format; for (VAR_5 = 0; VAR_5 < VAR_1; VAR_5++) { os = VAR_0[VAR_5].ctx; if (avformat_write_header(os, &VAR_0[VAR_5].opts) < 0) { snprintf(VAR_7, sizeof(VAR_7), "Could not write header for output file #%d (incorrect codec parameters ?)", VAR_5); VAR_4 = AVERROR(EINVAL); goto dump_format; } assert_avoptions(VAR_0[VAR_5].opts); if (strcmp(os->oformat->name, "rtp")) { VAR_8 = 0; } } dump_format: for(VAR_5=0;VAR_5<VAR_1;VAR_5++) { av_dump_format(VAR_0[VAR_5].ctx, VAR_5, VAR_0[VAR_5].ctx->filename, 1); } if (verbose >= 0) { fprintf(stderr, "Stream mapping:\n"); for (VAR_5 = 0; VAR_5 < nb_output_streams;VAR_5 ++) { ost = &output_streams[VAR_5]; fprintf(stderr, " Stream #%d.%d -> #%d.%d", input_streams[ost->source_index].file_index, input_streams[ost->source_index].st->index, ost->file_index, ost->index); if (ost->sync_ist != &input_streams[ost->source_index]) fprintf(stderr, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->st->index); if (ost->st->stream_copy) fprintf(stderr, " (copy)"); else fprintf(stderr, " (%s -> %s)", input_streams[ost->source_index].dec ? input_streams[ost->source_index].dec->name : "?", ost->enc ? ost->enc->name : "?"); fprintf(stderr, "\n"); } } if (VAR_4) { fprintf(stderr, "%s\n", VAR_7); return VAR_4; } if (VAR_8) { print_sdp(VAR_0, VAR_1); } return 0; }
[ "static int FUNC_0(OutputFile *VAR_0,\nint VAR_1,\nInputFile *VAR_2,\nint VAR_3)\n{", "int VAR_4 = 0, VAR_5, VAR_6;", "AVFormatContext *os;", "AVCodecContext *codec, *icodec;", "OutputStream *ost;", "InputStream *ist;", "char VAR_7[1024];", "int VAR_8 = 1;", "for (VAR_5 = 0; VAR_5 < VAR_3; VAR_5++) {", "InputFile *ifile = &VAR_2[VAR_5];", "if (ifile->rate_emu)\nfor (VAR_6 = 0; VAR_6 < ifile->nb_streams; VAR_6++)", "input_streams[VAR_6 + ifile->ist_index].start = av_gettime();", "}", "for(VAR_5=0;VAR_5<VAR_1;VAR_5++) {", "os = VAR_0[VAR_5].ctx;", "if (!os->nb_streams && !(os->oformat->flags & AVFMT_NOSTREAMS)) {", "av_dump_format(os, VAR_5, os->filename, 1);", "fprintf(stderr, \"Output file #%d does not contain any stream\\n\", VAR_5);", "return AVERROR(EINVAL);", "}", "}", "for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {", "ost = &output_streams[VAR_5];", "os = VAR_0[ost->file_index].ctx;", "ist = &input_streams[ost->source_index];", "codec = ost->st->codec;", "icodec = ist->st->codec;", "ost->st->disposition = ist->st->disposition;", "codec->bits_per_raw_sample= icodec->bits_per_raw_sample;", "codec->chroma_sample_location = icodec->chroma_sample_location;", "if (ost->st->stream_copy) {", "uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE;", "if (extra_size > INT_MAX) {", "return AVERROR(EINVAL);", "}", "codec->codec_id = icodec->codec_id;", "codec->codec_type = icodec->codec_type;", "if(!codec->codec_tag){", "if( !os->oformat->codec_tag\n|| av_codec_get_id (os->oformat->codec_tag, icodec->codec_tag) == codec->codec_id\n|| av_codec_get_tag(os->oformat->codec_tag, icodec->codec_id) <= 0)\ncodec->codec_tag = icodec->codec_tag;", "}", "codec->bit_rate = icodec->bit_rate;", "codec->rc_max_rate = icodec->rc_max_rate;", "codec->rc_buffer_size = icodec->rc_buffer_size;", "codec->extradata= av_mallocz(extra_size);", "if (!codec->extradata) {", "return AVERROR(ENOMEM);", "}", "memcpy(codec->extradata, icodec->extradata, icodec->extradata_size);", "codec->extradata_size= icodec->extradata_size;", "if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){", "codec->time_base = icodec->time_base;", "codec->time_base.num *= icodec->ticks_per_frame;", "av_reduce(&codec->time_base.num, &codec->time_base.den,\ncodec->time_base.num, codec->time_base.den, INT_MAX);", "}else", "codec->time_base = ist->st->time_base;", "switch(codec->codec_type) {", "case AVMEDIA_TYPE_AUDIO:\nif(audio_volume != 256) {", "fprintf(stderr,\"-acodec copy and -vol are incompatible (frames are not decoded)\\n\");", "exit_program(1);", "}", "codec->channel_layout = icodec->channel_layout;", "codec->sample_rate = icodec->sample_rate;", "codec->channels = icodec->channels;", "codec->frame_size = icodec->frame_size;", "codec->audio_service_type = icodec->audio_service_type;", "codec->block_align= icodec->block_align;", "if(codec->block_align == 1 && codec->codec_id == CODEC_ID_MP3)\ncodec->block_align= 0;", "if(codec->codec_id == CODEC_ID_AC3)\ncodec->block_align= 0;", "break;", "case AVMEDIA_TYPE_VIDEO:\ncodec->pix_fmt = icodec->pix_fmt;", "codec->width = icodec->width;", "codec->height = icodec->height;", "codec->has_b_frames = icodec->has_b_frames;", "if (!codec->sample_aspect_ratio.num) {", "codec->sample_aspect_ratio =\nost->st->sample_aspect_ratio =\nist->st->sample_aspect_ratio.num ? ist->st->sample_aspect_ratio :\nist->st->codec->sample_aspect_ratio.num ?\nist->st->codec->sample_aspect_ratio : (AVRational){0, 1};", "}", "break;", "case AVMEDIA_TYPE_SUBTITLE:\ncodec->width = icodec->width;", "codec->height = icodec->height;", "break;", "case AVMEDIA_TYPE_DATA:\nbreak;", "default:\nabort();", "}", "} else {", "if (!ost->enc)\nost->enc = avcodec_find_encoder(ost->st->codec->codec_id);", "switch(codec->codec_type) {", "case AVMEDIA_TYPE_AUDIO:\nost->fifo= av_fifo_alloc(1024);", "if (!ost->fifo) {", "return AVERROR(ENOMEM);", "}", "ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);", "if (!codec->sample_rate) {", "codec->sample_rate = icodec->sample_rate;", "if (icodec->lowres)\ncodec->sample_rate >>= icodec->lowres;", "}", "choose_sample_rate(ost->st, ost->enc);", "codec->time_base = (AVRational){1, codec->sample_rate};", "if (codec->sample_fmt == AV_SAMPLE_FMT_NONE)\ncodec->sample_fmt = icodec->sample_fmt;", "choose_sample_fmt(ost->st, ost->enc);", "if (!codec->channels)\ncodec->channels = icodec->channels;", "codec->channel_layout = icodec->channel_layout;", "if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels)\ncodec->channel_layout = 0;", "ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;", "icodec->request_channels = codec->channels;", "ist->decoding_needed = 1;", "ost->encoding_needed = 1;", "ost->resample_sample_fmt = icodec->sample_fmt;", "ost->resample_sample_rate = icodec->sample_rate;", "ost->resample_channels = icodec->channels;", "break;", "case AVMEDIA_TYPE_VIDEO:\nif (codec->pix_fmt == PIX_FMT_NONE)\ncodec->pix_fmt = icodec->pix_fmt;", "choose_pixel_fmt(ost->st, ost->enc);", "if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {", "fprintf(stderr, \"Video pixel format is unknown, stream cannot be encoded\\n\");", "exit_program(1);", "}", "if (!codec->width || !codec->height) {", "codec->width = icodec->width;", "codec->height = icodec->height;", "}", "ost->video_resample = codec->width != icodec->width ||\ncodec->height != icodec->height ||\ncodec->pix_fmt != icodec->pix_fmt;", "if (ost->video_resample) {", "#if !CONFIG_AVFILTER\navcodec_get_frame_defaults(&ost->pict_tmp);", "if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,\ncodec->width, codec->height)) {", "fprintf(stderr, \"Cannot allocate temp picture, check pix fmt\\n\");", "exit_program(1);", "}", "ost->img_resample_ctx = sws_getContext(\nicodec->width,\nicodec->height,\nicodec->pix_fmt,\ncodec->width,\ncodec->height,\ncodec->pix_fmt,\nost->sws_flags, NULL, NULL, NULL);", "if (ost->img_resample_ctx == NULL) {", "fprintf(stderr, \"Cannot get resampling context\\n\");", "exit_program(1);", "}", "#endif\ncodec->bits_per_raw_sample= 0;", "}", "ost->resample_height = icodec->height;", "ost->resample_width = icodec->width;", "ost->resample_pix_fmt= icodec->pix_fmt;", "ost->encoding_needed = 1;", "ist->decoding_needed = 1;", "if (!ost->frame_rate.num)\nost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1};", "if (ost->enc && ost->enc->supported_framerates && !force_fps) {", "int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);", "ost->frame_rate = ost->enc->supported_framerates[idx];", "}", "codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};", "#if CONFIG_AVFILTER\nif (configure_video_filters(ist, ost)) {", "fprintf(stderr, \"Error opening filters!\\n\");", "exit(1);", "}", "#endif\nbreak;", "case AVMEDIA_TYPE_SUBTITLE:\nost->encoding_needed = 1;", "ist->decoding_needed = 1;", "break;", "default:\nabort();", "break;", "}", "if (ost->encoding_needed &&\n(codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) {", "char logfilename[1024];", "FILE *f;", "snprintf(logfilename, sizeof(logfilename), \"%s-%d.log\",\npass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX,\nVAR_5);", "if (codec->flags & CODEC_FLAG_PASS1) {", "f = fopen(logfilename, \"wb\");", "if (!f) {", "fprintf(stderr, \"Cannot write log file '%s' for pass-1 encoding: %s\\n\", logfilename, strerror(errno));", "exit_program(1);", "}", "ost->logfile = f;", "} else {", "char *logbuffer;", "size_t logbuffer_size;", "if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) {", "fprintf(stderr, \"Error reading log file '%s' for pass-2 encoding\\n\", logfilename);", "exit_program(1);", "}", "codec->stats_in = logbuffer;", "}", "}", "}", "if(codec->codec_type == AVMEDIA_TYPE_VIDEO){", "int size= codec->width * codec->height;", "bit_buffer_size= FFMAX(bit_buffer_size, 6*size + 200);", "}", "}", "if (!bit_buffer)\nbit_buffer = av_malloc(bit_buffer_size);", "if (!bit_buffer) {", "fprintf(stderr, \"Cannot allocate %d bytes output buffer\\n\",\nbit_buffer_size);", "return AVERROR(ENOMEM);", "}", "for (VAR_5 = 0; VAR_5 < nb_output_streams; VAR_5++) {", "ost = &output_streams[VAR_5];", "if (ost->encoding_needed) {", "AVCodec *codec = ost->enc;", "AVCodecContext *dec = input_streams[ost->source_index].st->codec;", "if (!codec) {", "snprintf(VAR_7, sizeof(VAR_7), \"Encoder (codec id %d) not found for output stream #%d.%d\",\nost->st->codec->codec_id, ost->file_index, ost->index);", "VAR_4 = AVERROR(EINVAL);", "goto dump_format;", "}", "if (dec->subtitle_header) {", "ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);", "if (!ost->st->codec->subtitle_header) {", "VAR_4 = AVERROR(ENOMEM);", "goto dump_format;", "}", "memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);", "ost->st->codec->subtitle_header_size = dec->subtitle_header_size;", "}", "if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {", "snprintf(VAR_7, sizeof(VAR_7), \"Error while opening encoder for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\",\nost->file_index, ost->index);", "VAR_4 = AVERROR(EINVAL);", "goto dump_format;", "}", "assert_codec_experimental(ost->st->codec, 1);", "assert_avoptions(ost->opts);", "if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)\nav_log(NULL, AV_LOG_WARNING, \"The bitrate parameter is set too low.\"\n\"It takes bits/s as argument, not kbits/s\\n\");", "extra_size += ost->st->codec->extradata_size;", "}", "}", "for (VAR_5 = 0; VAR_5 < nb_input_streams; VAR_5++)", "if ((VAR_4 = init_input_stream(VAR_5, output_streams, nb_output_streams, VAR_7, sizeof(VAR_7))) < 0)\ngoto dump_format;", "for (VAR_5 = 0; VAR_5 < VAR_1; VAR_5++) {", "os = VAR_0[VAR_5].ctx;", "if (avformat_write_header(os, &VAR_0[VAR_5].opts) < 0) {", "snprintf(VAR_7, sizeof(VAR_7), \"Could not write header for output file #%d (incorrect codec parameters ?)\", VAR_5);", "VAR_4 = AVERROR(EINVAL);", "goto dump_format;", "}", "assert_avoptions(VAR_0[VAR_5].opts);", "if (strcmp(os->oformat->name, \"rtp\")) {", "VAR_8 = 0;", "}", "}", "dump_format:\nfor(VAR_5=0;VAR_5<VAR_1;VAR_5++) {", "av_dump_format(VAR_0[VAR_5].ctx, VAR_5, VAR_0[VAR_5].ctx->filename, 1);", "}", "if (verbose >= 0) {", "fprintf(stderr, \"Stream mapping:\\n\");", "for (VAR_5 = 0; VAR_5 < nb_output_streams;VAR_5 ++) {", "ost = &output_streams[VAR_5];", "fprintf(stderr, \" Stream #%d.%d -> #%d.%d\",\ninput_streams[ost->source_index].file_index,\ninput_streams[ost->source_index].st->index,\nost->file_index,\nost->index);", "if (ost->sync_ist != &input_streams[ost->source_index])\nfprintf(stderr, \" [sync #%d.%d]\",\nost->sync_ist->file_index,\nost->sync_ist->st->index);", "if (ost->st->stream_copy)\nfprintf(stderr, \" (copy)\");", "else\nfprintf(stderr, \" (%s -> %s)\", input_streams[ost->source_index].dec ?\ninput_streams[ost->source_index].dec->name : \"?\",\nost->enc ? ost->enc->name : \"?\");", "fprintf(stderr, \"\\n\");", "}", "}", "if (VAR_4) {", "fprintf(stderr, \"%s\\n\", VAR_7);", "return VAR_4;", "}", "if (VAR_8) {", "print_sdp(VAR_0, VAR_1);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 105 ], [ 107 ], [ 111 ], [ 113, 115, 117, 119 ], [ 121 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149, 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181, 183 ], [ 185, 187 ], [ 189 ], [ 191, 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203, 205, 207, 209, 211 ], [ 213 ], [ 215 ], [ 217, 219 ], [ 221 ], [ 223 ], [ 225, 227 ], [ 229, 231 ], [ 233 ], [ 235 ], [ 237, 239 ], [ 241 ], [ 243, 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259, 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269, 271 ], [ 273 ], [ 275, 277 ], [ 279 ], [ 281, 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301, 303, 305 ], [ 307 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 331, 333, 335 ], [ 337 ], [ 339, 341 ], [ 343, 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353, 355, 357, 359, 361, 363, 365, 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 377, 379 ], [ 381 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 393 ], [ 397, 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 413, 415 ], [ 417 ], [ 419 ], [ 421 ], [ 423, 425 ], [ 427, 429 ], [ 431 ], [ 433 ], [ 435, 437 ], [ 439 ], [ 441 ], [ 445, 447 ], [ 449 ], [ 451 ], [ 455, 457, 459 ], [ 461 ], [ 463 ], [ 465 ], [ 467 ], [ 469 ], [ 471 ], [ 473 ], [ 475 ], [ 477 ], [ 479 ], [ 481 ], [ 483 ], [ 485 ], [ 487 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 503 ], [ 505 ], [ 509, 511 ], [ 513 ], [ 515, 517 ], [ 519 ], [ 521 ], [ 527 ], [ 529 ], [ 531 ], [ 533 ], [ 535 ], [ 537 ], [ 539, 541 ], [ 543 ], [ 545 ], [ 547 ], [ 549 ], [ 551 ], [ 553 ], [ 555 ], [ 557 ], [ 559 ], [ 561 ], [ 563 ], [ 565 ], [ 567 ], [ 569, 571 ], [ 573 ], [ 575 ], [ 577 ], [ 579 ], [ 581 ], [ 583, 585, 587 ], [ 589 ], [ 591 ], [ 593 ], [ 599 ], [ 601, 603 ], [ 609 ], [ 611 ], [ 613 ], [ 615 ], [ 617 ], [ 619 ], [ 621 ], [ 623 ], [ 625 ], [ 627 ], [ 629 ], [ 631 ], [ 635, 641 ], [ 643 ], [ 645 ], [ 651 ], [ 653 ], [ 655 ], [ 657 ], [ 659, 661, 663, 665, 667 ], [ 669, 671, 673, 675 ], [ 677, 679 ], [ 681, 683, 685, 687 ], [ 689 ], [ 691 ], [ 693 ], [ 697 ], [ 699 ], [ 701 ], [ 703 ], [ 707 ], [ 709 ], [ 711 ], [ 715 ], [ 717 ] ]
480
static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) { LavfiContext *lavfi = avctx->priv_data; double min_pts = DBL_MAX; int stream_idx, min_pts_sink_idx = 0; AVFrame *frame = lavfi->decoded_frame; AVPicture pict; AVDictionary *frame_metadata; int ret, i; int size = 0; if (lavfi->subcc_packet.size) { *pkt = lavfi->subcc_packet; av_init_packet(&lavfi->subcc_packet); lavfi->subcc_packet.size = 0; lavfi->subcc_packet.data = NULL; return pkt->size; } /* iterate through all the graph sinks. Select the sink with the * minimum PTS */ for (i = 0; i < lavfi->nb_sinks; i++) { AVRational tb = lavfi->sinks[i]->inputs[0]->time_base; double d; int ret; if (lavfi->sink_eof[i]) continue; ret = av_buffersink_get_frame_flags(lavfi->sinks[i], frame, AV_BUFFERSINK_FLAG_PEEK); if (ret == AVERROR_EOF) { av_dlog(avctx, "EOF sink_idx:%d\n", i); lavfi->sink_eof[i] = 1; continue; } else if (ret < 0) return ret; d = av_rescale_q_rnd(frame->pts, tb, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); av_dlog(avctx, "sink_idx:%d time:%f\n", i, d); av_frame_unref(frame); if (d < min_pts) { min_pts = d; min_pts_sink_idx = i; } } if (min_pts == DBL_MAX) return AVERROR_EOF; av_dlog(avctx, "min_pts_sink_idx:%i\n", min_pts_sink_idx); av_buffersink_get_frame_flags(lavfi->sinks[min_pts_sink_idx], frame, 0); stream_idx = lavfi->sink_stream_map[min_pts_sink_idx]; if (frame->width /* FIXME best way of testing a video */) { size = avpicture_get_size(frame->format, frame->width, frame->height); if ((ret = av_new_packet(pkt, size)) < 0) return ret; memcpy(pict.data, frame->data, 4*sizeof(frame->data[0])); memcpy(pict.linesize, frame->linesize, 4*sizeof(frame->linesize[0])); avpicture_layout(&pict, frame->format, frame->width, frame->height, pkt->data, size); } else if (av_frame_get_channels(frame) /* FIXME test audio */) { size = frame->nb_samples * av_get_bytes_per_sample(frame->format) * av_frame_get_channels(frame); if ((ret = av_new_packet(pkt, size)) < 0) return ret; memcpy(pkt->data, frame->data[0], size); } frame_metadata = av_frame_get_metadata(frame); if (frame_metadata) { uint8_t *metadata; AVDictionaryEntry *e = NULL; AVBPrint meta_buf; av_bprint_init(&meta_buf, 0, AV_BPRINT_SIZE_UNLIMITED); while ((e = av_dict_get(frame_metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { av_bprintf(&meta_buf, "%s", e->key); av_bprint_chars(&meta_buf, '\0', 1); av_bprintf(&meta_buf, "%s", e->value); av_bprint_chars(&meta_buf, '\0', 1); } if (!av_bprint_is_complete(&meta_buf) || !(metadata = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, meta_buf.len))) { av_bprint_finalize(&meta_buf, NULL); return AVERROR(ENOMEM); } memcpy(metadata, meta_buf.str, meta_buf.len); av_bprint_finalize(&meta_buf, NULL); } if ((ret = create_subcc_packet(avctx, frame, min_pts_sink_idx)) < 0) { av_frame_unref(frame); av_packet_unref(pkt); return ret; } pkt->stream_index = stream_idx; pkt->pts = frame->pts; pkt->pos = av_frame_get_pkt_pos(frame); pkt->size = size; av_frame_unref(frame); return size; }
false
FFmpeg
229843aa359ae0c9519977d7fa952688db63f559
static int lavfi_read_packet(AVFormatContext *avctx, AVPacket *pkt) { LavfiContext *lavfi = avctx->priv_data; double min_pts = DBL_MAX; int stream_idx, min_pts_sink_idx = 0; AVFrame *frame = lavfi->decoded_frame; AVPicture pict; AVDictionary *frame_metadata; int ret, i; int size = 0; if (lavfi->subcc_packet.size) { *pkt = lavfi->subcc_packet; av_init_packet(&lavfi->subcc_packet); lavfi->subcc_packet.size = 0; lavfi->subcc_packet.data = NULL; return pkt->size; } for (i = 0; i < lavfi->nb_sinks; i++) { AVRational tb = lavfi->sinks[i]->inputs[0]->time_base; double d; int ret; if (lavfi->sink_eof[i]) continue; ret = av_buffersink_get_frame_flags(lavfi->sinks[i], frame, AV_BUFFERSINK_FLAG_PEEK); if (ret == AVERROR_EOF) { av_dlog(avctx, "EOF sink_idx:%d\n", i); lavfi->sink_eof[i] = 1; continue; } else if (ret < 0) return ret; d = av_rescale_q_rnd(frame->pts, tb, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); av_dlog(avctx, "sink_idx:%d time:%f\n", i, d); av_frame_unref(frame); if (d < min_pts) { min_pts = d; min_pts_sink_idx = i; } } if (min_pts == DBL_MAX) return AVERROR_EOF; av_dlog(avctx, "min_pts_sink_idx:%i\n", min_pts_sink_idx); av_buffersink_get_frame_flags(lavfi->sinks[min_pts_sink_idx], frame, 0); stream_idx = lavfi->sink_stream_map[min_pts_sink_idx]; if (frame->width ) { size = avpicture_get_size(frame->format, frame->width, frame->height); if ((ret = av_new_packet(pkt, size)) < 0) return ret; memcpy(pict.data, frame->data, 4*sizeof(frame->data[0])); memcpy(pict.linesize, frame->linesize, 4*sizeof(frame->linesize[0])); avpicture_layout(&pict, frame->format, frame->width, frame->height, pkt->data, size); } else if (av_frame_get_channels(frame) ) { size = frame->nb_samples * av_get_bytes_per_sample(frame->format) * av_frame_get_channels(frame); if ((ret = av_new_packet(pkt, size)) < 0) return ret; memcpy(pkt->data, frame->data[0], size); } frame_metadata = av_frame_get_metadata(frame); if (frame_metadata) { uint8_t *metadata; AVDictionaryEntry *e = NULL; AVBPrint meta_buf; av_bprint_init(&meta_buf, 0, AV_BPRINT_SIZE_UNLIMITED); while ((e = av_dict_get(frame_metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { av_bprintf(&meta_buf, "%s", e->key); av_bprint_chars(&meta_buf, '\0', 1); av_bprintf(&meta_buf, "%s", e->value); av_bprint_chars(&meta_buf, '\0', 1); } if (!av_bprint_is_complete(&meta_buf) || !(metadata = av_packet_new_side_data(pkt, AV_PKT_DATA_STRINGS_METADATA, meta_buf.len))) { av_bprint_finalize(&meta_buf, NULL); return AVERROR(ENOMEM); } memcpy(metadata, meta_buf.str, meta_buf.len); av_bprint_finalize(&meta_buf, NULL); } if ((ret = create_subcc_packet(avctx, frame, min_pts_sink_idx)) < 0) { av_frame_unref(frame); av_packet_unref(pkt); return ret; } pkt->stream_index = stream_idx; pkt->pts = frame->pts; pkt->pos = av_frame_get_pkt_pos(frame); pkt->size = size; av_frame_unref(frame); return size; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { LavfiContext *lavfi = VAR_0->priv_data; double VAR_2 = DBL_MAX; int VAR_3, VAR_4 = 0; AVFrame *frame = lavfi->decoded_frame; AVPicture pict; AVDictionary *frame_metadata; int VAR_5, VAR_6; int VAR_7 = 0; if (lavfi->subcc_packet.VAR_7) { *VAR_1 = lavfi->subcc_packet; av_init_packet(&lavfi->subcc_packet); lavfi->subcc_packet.VAR_7 = 0; lavfi->subcc_packet.data = NULL; return VAR_1->VAR_7; } for (VAR_6 = 0; VAR_6 < lavfi->nb_sinks; VAR_6++) { AVRational tb = lavfi->sinks[VAR_6]->inputs[0]->time_base; double d; int VAR_5; if (lavfi->sink_eof[VAR_6]) continue; VAR_5 = av_buffersink_get_frame_flags(lavfi->sinks[VAR_6], frame, AV_BUFFERSINK_FLAG_PEEK); if (VAR_5 == AVERROR_EOF) { av_dlog(VAR_0, "EOF sink_idx:%d\n", VAR_6); lavfi->sink_eof[VAR_6] = 1; continue; } else if (VAR_5 < 0) return VAR_5; d = av_rescale_q_rnd(frame->pts, tb, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX); av_dlog(VAR_0, "sink_idx:%d time:%f\n", VAR_6, d); av_frame_unref(frame); if (d < VAR_2) { VAR_2 = d; VAR_4 = VAR_6; } } if (VAR_2 == DBL_MAX) return AVERROR_EOF; av_dlog(VAR_0, "VAR_4:%VAR_6\n", VAR_4); av_buffersink_get_frame_flags(lavfi->sinks[VAR_4], frame, 0); VAR_3 = lavfi->sink_stream_map[VAR_4]; if (frame->width ) { VAR_7 = avpicture_get_size(frame->format, frame->width, frame->height); if ((VAR_5 = av_new_packet(VAR_1, VAR_7)) < 0) return VAR_5; memcpy(pict.data, frame->data, 4*sizeof(frame->data[0])); memcpy(pict.linesize, frame->linesize, 4*sizeof(frame->linesize[0])); avpicture_layout(&pict, frame->format, frame->width, frame->height, VAR_1->data, VAR_7); } else if (av_frame_get_channels(frame) ) { VAR_7 = frame->nb_samples * av_get_bytes_per_sample(frame->format) * av_frame_get_channels(frame); if ((VAR_5 = av_new_packet(VAR_1, VAR_7)) < 0) return VAR_5; memcpy(VAR_1->data, frame->data[0], VAR_7); } frame_metadata = av_frame_get_metadata(frame); if (frame_metadata) { uint8_t *metadata; AVDictionaryEntry *e = NULL; AVBPrint meta_buf; av_bprint_init(&meta_buf, 0, AV_BPRINT_SIZE_UNLIMITED); while ((e = av_dict_get(frame_metadata, "", e, AV_DICT_IGNORE_SUFFIX))) { av_bprintf(&meta_buf, "%s", e->key); av_bprint_chars(&meta_buf, '\0', 1); av_bprintf(&meta_buf, "%s", e->value); av_bprint_chars(&meta_buf, '\0', 1); } if (!av_bprint_is_complete(&meta_buf) || !(metadata = av_packet_new_side_data(VAR_1, AV_PKT_DATA_STRINGS_METADATA, meta_buf.len))) { av_bprint_finalize(&meta_buf, NULL); return AVERROR(ENOMEM); } memcpy(metadata, meta_buf.str, meta_buf.len); av_bprint_finalize(&meta_buf, NULL); } if ((VAR_5 = create_subcc_packet(VAR_0, frame, VAR_4)) < 0) { av_frame_unref(frame); av_packet_unref(VAR_1); return VAR_5; } VAR_1->stream_index = VAR_3; VAR_1->pts = frame->pts; VAR_1->pos = av_frame_get_pkt_pos(frame); VAR_1->VAR_7 = VAR_7; av_frame_unref(frame); return VAR_7; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "LavfiContext *lavfi = VAR_0->priv_data;", "double VAR_2 = DBL_MAX;", "int VAR_3, VAR_4 = 0;", "AVFrame *frame = lavfi->decoded_frame;", "AVPicture pict;", "AVDictionary *frame_metadata;", "int VAR_5, VAR_6;", "int VAR_7 = 0;", "if (lavfi->subcc_packet.VAR_7) {", "*VAR_1 = lavfi->subcc_packet;", "av_init_packet(&lavfi->subcc_packet);", "lavfi->subcc_packet.VAR_7 = 0;", "lavfi->subcc_packet.data = NULL;", "return VAR_1->VAR_7;", "}", "for (VAR_6 = 0; VAR_6 < lavfi->nb_sinks; VAR_6++) {", "AVRational tb = lavfi->sinks[VAR_6]->inputs[0]->time_base;", "double d;", "int VAR_5;", "if (lavfi->sink_eof[VAR_6])\ncontinue;", "VAR_5 = av_buffersink_get_frame_flags(lavfi->sinks[VAR_6], frame,\nAV_BUFFERSINK_FLAG_PEEK);", "if (VAR_5 == AVERROR_EOF) {", "av_dlog(VAR_0, \"EOF sink_idx:%d\\n\", VAR_6);", "lavfi->sink_eof[VAR_6] = 1;", "continue;", "} else if (VAR_5 < 0)", "return VAR_5;", "d = av_rescale_q_rnd(frame->pts, tb, AV_TIME_BASE_Q, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);", "av_dlog(VAR_0, \"sink_idx:%d time:%f\\n\", VAR_6, d);", "av_frame_unref(frame);", "if (d < VAR_2) {", "VAR_2 = d;", "VAR_4 = VAR_6;", "}", "}", "if (VAR_2 == DBL_MAX)\nreturn AVERROR_EOF;", "av_dlog(VAR_0, \"VAR_4:%VAR_6\\n\", VAR_4);", "av_buffersink_get_frame_flags(lavfi->sinks[VAR_4], frame, 0);", "VAR_3 = lavfi->sink_stream_map[VAR_4];", "if (frame->width ) {", "VAR_7 = avpicture_get_size(frame->format, frame->width, frame->height);", "if ((VAR_5 = av_new_packet(VAR_1, VAR_7)) < 0)\nreturn VAR_5;", "memcpy(pict.data, frame->data, 4*sizeof(frame->data[0]));", "memcpy(pict.linesize, frame->linesize, 4*sizeof(frame->linesize[0]));", "avpicture_layout(&pict, frame->format, frame->width, frame->height,\nVAR_1->data, VAR_7);", "} else if (av_frame_get_channels(frame) ) {", "VAR_7 = frame->nb_samples * av_get_bytes_per_sample(frame->format) *\nav_frame_get_channels(frame);", "if ((VAR_5 = av_new_packet(VAR_1, VAR_7)) < 0)\nreturn VAR_5;", "memcpy(VAR_1->data, frame->data[0], VAR_7);", "}", "frame_metadata = av_frame_get_metadata(frame);", "if (frame_metadata) {", "uint8_t *metadata;", "AVDictionaryEntry *e = NULL;", "AVBPrint meta_buf;", "av_bprint_init(&meta_buf, 0, AV_BPRINT_SIZE_UNLIMITED);", "while ((e = av_dict_get(frame_metadata, \"\", e, AV_DICT_IGNORE_SUFFIX))) {", "av_bprintf(&meta_buf, \"%s\", e->key);", "av_bprint_chars(&meta_buf, '\\0', 1);", "av_bprintf(&meta_buf, \"%s\", e->value);", "av_bprint_chars(&meta_buf, '\\0', 1);", "}", "if (!av_bprint_is_complete(&meta_buf) ||\n!(metadata = av_packet_new_side_data(VAR_1, AV_PKT_DATA_STRINGS_METADATA,\nmeta_buf.len))) {", "av_bprint_finalize(&meta_buf, NULL);", "return AVERROR(ENOMEM);", "}", "memcpy(metadata, meta_buf.str, meta_buf.len);", "av_bprint_finalize(&meta_buf, NULL);", "}", "if ((VAR_5 = create_subcc_packet(VAR_0, frame, VAR_4)) < 0) {", "av_frame_unref(frame);", "av_packet_unref(VAR_1);", "return VAR_5;", "}", "VAR_1->stream_index = VAR_3;", "VAR_1->pts = frame->pts;", "VAR_1->pos = av_frame_get_pkt_pos(frame);", "VAR_1->VAR_7 = VAR_7;", "av_frame_unref(frame);", "return VAR_7;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53, 55 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93, 95 ], [ 99 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 119 ], [ 121 ], [ 125, 127 ], [ 129 ], [ 131, 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171, 173, 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ] ]
481
static void iothread_complete(UserCreatable *obj, Error **errp) { IOThread *iothread = IOTHREAD(obj); iothread->stopping = false; iothread->ctx = aio_context_new(); iothread->thread_id = -1; qemu_mutex_init(&iothread->init_done_lock); qemu_cond_init(&iothread->init_done_cond); /* This assumes we are called from a thread with useful CPU affinity for us * to inherit. */ qemu_thread_create(&iothread->thread, "iothread", iothread_run, iothread, QEMU_THREAD_JOINABLE); /* Wait for initialization to complete */ qemu_mutex_lock(&iothread->init_done_lock); while (iothread->thread_id == -1) { qemu_cond_wait(&iothread->init_done_cond, &iothread->init_done_lock); } qemu_mutex_unlock(&iothread->init_done_lock); }
true
qemu
2f78e491d7b46542158ce0b8132ee4e05bc0ade4
static void iothread_complete(UserCreatable *obj, Error **errp) { IOThread *iothread = IOTHREAD(obj); iothread->stopping = false; iothread->ctx = aio_context_new(); iothread->thread_id = -1; qemu_mutex_init(&iothread->init_done_lock); qemu_cond_init(&iothread->init_done_cond); qemu_thread_create(&iothread->thread, "iothread", iothread_run, iothread, QEMU_THREAD_JOINABLE); qemu_mutex_lock(&iothread->init_done_lock); while (iothread->thread_id == -1) { qemu_cond_wait(&iothread->init_done_cond, &iothread->init_done_lock); } qemu_mutex_unlock(&iothread->init_done_lock); }
{ "code": [ " iothread->ctx = aio_context_new();" ], "line_no": [ 11 ] }
static void FUNC_0(UserCreatable *VAR_0, Error **VAR_1) { IOThread *iothread = IOTHREAD(VAR_0); iothread->stopping = false; iothread->ctx = aio_context_new(); iothread->thread_id = -1; qemu_mutex_init(&iothread->init_done_lock); qemu_cond_init(&iothread->init_done_cond); qemu_thread_create(&iothread->thread, "iothread", iothread_run, iothread, QEMU_THREAD_JOINABLE); qemu_mutex_lock(&iothread->init_done_lock); while (iothread->thread_id == -1) { qemu_cond_wait(&iothread->init_done_cond, &iothread->init_done_lock); } qemu_mutex_unlock(&iothread->init_done_lock); }
[ "static void FUNC_0(UserCreatable *VAR_0, Error **VAR_1)\n{", "IOThread *iothread = IOTHREAD(VAR_0);", "iothread->stopping = false;", "iothread->ctx = aio_context_new();", "iothread->thread_id = -1;", "qemu_mutex_init(&iothread->init_done_lock);", "qemu_cond_init(&iothread->init_done_cond);", "qemu_thread_create(&iothread->thread, \"iothread\", iothread_run,\niothread, QEMU_THREAD_JOINABLE);", "qemu_mutex_lock(&iothread->init_done_lock);", "while (iothread->thread_id == -1) {", "qemu_cond_wait(&iothread->init_done_cond,\n&iothread->init_done_lock);", "}", "qemu_mutex_unlock(&iothread->init_done_lock);", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 29, 31 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ] ]
482
static void gen_tlbre_440(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } switch (rB(ctx->opcode)) { case 0: case 1: case 2: { TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode)); gen_helper_440_tlbre(cpu_gpr[rD(ctx->opcode)], cpu_env, t0, cpu_gpr[rA(ctx->opcode)]); tcg_temp_free_i32(t0); } break; default: gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); break; } #endif }
true
qemu
9b2fadda3e0196ffd485adde4fe9cdd6fae35300
static void gen_tlbre_440(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } switch (rB(ctx->opcode)) { case 0: case 1: case 2: { TCGv_i32 t0 = tcg_const_i32(rB(ctx->opcode)); gen_helper_440_tlbre(cpu_gpr[rD(ctx->opcode)], cpu_env, t0, cpu_gpr[rA(ctx->opcode)]); tcg_temp_free_i32(t0); } break; default: gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); break; } #endif }
{ "code": [ " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#if defined(CONFIG_USER_ONLY)", "#else", " if (unlikely(ctx->pr)) {", "#endif", "#if defined(CONFIG_USER_ONLY)", "#else", " if (unlikely(ctx->pr)) {", "#endif", "#endif", "#if defined(CONFIG_USER_ONLY)", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", " if (unlikely(ctx->pr)) {", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#else", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", "#if defined(CONFIG_USER_ONLY)", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", " if (unlikely(ctx->pr)) {", " gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);", "#endif" ], "line_no": [ 13, 7, 11, 13, 7, 11, 13, 7, 13, 5, 9, 11, 49, 5, 9, 11, 49, 49, 5, 9, 11, 7, 11, 13, 49, 11, 49, 11, 49, 11, 49, 11, 49, 11, 49, 11, 49, 11, 49, 11, 49, 11, 49, 11, 49, 11, 49, 7, 13, 49, 7, 11, 13, 49, 7, 13, 49, 7, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 11, 49, 11, 49, 11, 49, 11, 49, 5, 7, 9, 11, 13, 49, 7, 11, 13, 49, 5, 7, 9, 11, 13, 49, 5, 7, 9, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 5, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49, 7, 11, 13, 49 ] }
static void FUNC_0(DisasContext *VAR_0) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(VAR_0->pr)) { gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC); return; } switch (rB(VAR_0->opcode)) { case 0: case 1: case 2: { TCGv_i32 t0 = tcg_const_i32(rB(VAR_0->opcode)); gen_helper_440_tlbre(cpu_gpr[rD(VAR_0->opcode)], cpu_env, t0, cpu_gpr[rA(VAR_0->opcode)]); tcg_temp_free_i32(t0); } break; default: gen_inval_exception(VAR_0, POWERPC_EXCP_INVAL_INVAL); break; } #endif }
[ "static void FUNC_0(DisasContext *VAR_0)\n{", "#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);", "#else\nif (unlikely(VAR_0->pr)) {", "gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);", "return;", "}", "switch (rB(VAR_0->opcode)) {", "case 0:\ncase 1:\ncase 2:\n{", "TCGv_i32 t0 = tcg_const_i32(rB(VAR_0->opcode));", "gen_helper_440_tlbre(cpu_gpr[rD(VAR_0->opcode)], cpu_env,\nt0, cpu_gpr[rA(VAR_0->opcode)]);", "tcg_temp_free_i32(t0);", "}", "break;", "default:\ngen_inval_exception(VAR_0, POWERPC_EXCP_INVAL_INVAL);", "break;", "}", "#endif\n}" ]
[ 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21, 23, 25, 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49, 51 ] ]
483
target_ulong helper_evpe(target_ulong arg1) { // TODO arg1 = 0; // rt = arg1 return arg1; }
true
qemu
9ed5726c043958359b0f1fa44ab3e4f25f9d9a47
target_ulong helper_evpe(target_ulong arg1) { arg1 = 0; return arg1; }
{ "code": [ " arg1 = 0;", " return arg1;", " arg1 = 0;", " return arg1;", " arg1 = 0;", " return arg1;", "target_ulong helper_evpe(target_ulong arg1)", " arg1 = 0;", " return arg1;" ], "line_no": [ 7, 13, 7, 13, 7, 13, 1, 7, 13 ] }
target_ulong FUNC_0(target_ulong arg1) { arg1 = 0; return arg1; }
[ "target_ulong FUNC_0(target_ulong arg1)\n{", "arg1 = 0;", "return arg1;", "}" ]
[ 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 7 ], [ 13 ], [ 15 ] ]
484
void helper_ldmxcsr(CPUX86State *env, uint32_t val) { env->mxcsr = val; update_sse_status(env); }
true
qemu
4e47e39ab0ded72c0af174131ecf49d588d66c12
void helper_ldmxcsr(CPUX86State *env, uint32_t val) { env->mxcsr = val; update_sse_status(env); }
{ "code": [ " env->mxcsr = val;", " update_sse_status(env);" ], "line_no": [ 5, 7 ] }
void FUNC_0(CPUX86State *VAR_0, uint32_t VAR_1) { VAR_0->mxcsr = VAR_1; update_sse_status(VAR_0); }
[ "void FUNC_0(CPUX86State *VAR_0, uint32_t VAR_1)\n{", "VAR_0->mxcsr = VAR_1;", "update_sse_status(VAR_0);", "}" ]
[ 0, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
485
void ff_snow_horizontal_compose97i_mmx(IDWTELEM *b, int width){ const int w2= (width+1)>>1; IDWTELEM temp[width >> 1]; const int w_l= (width>>1); const int w_r= w2 - 1; int i; { // Lift 0 IDWTELEM * const ref = b + w2 - 1; i = 1; b[0] = b[0] - ((W_DM * 2 * ref[1]+W_DO)>>W_DS); asm volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psllw $15, %%mm7 \n\t" "psrlw $14, %%mm7 \n\t" ::); for(; i<w_l-7; i+=8){ asm volatile( "movq (%1), %%mm2 \n\t" "movq 8(%1), %%mm6 \n\t" "paddw 2(%1), %%mm2 \n\t" "paddw 10(%1), %%mm6 \n\t" "movq %%mm2, %%mm0 \n\t" "movq %%mm6, %%mm4 \n\t" "psraw $1, %%mm2 \n\t" "psraw $1, %%mm6 \n\t" "paddw %%mm0, %%mm2 \n\t" "paddw %%mm4, %%mm6 \n\t" "paddw %%mm7, %%mm2 \n\t" "paddw %%mm7, %%mm6 \n\t" "psraw $2, %%mm2 \n\t" "psraw $2, %%mm6 \n\t" "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm4 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm6, %%mm4 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm4, 8(%0) \n\t" :: "r"(&b[i]), "r"(&ref[i]) : "memory" ); } snow_horizontal_compose_lift_lead_out(i, b, b, ref, width, w_l, 0, W_DM, W_DO, W_DS); } { // Lift 1 IDWTELEM * const dst = b+w2; i = 0; for(; i<w_r-7; i+=8){ asm volatile( "movq (%1), %%mm2 \n\t" "movq 8(%1), %%mm6 \n\t" "paddw 2(%1), %%mm2 \n\t" "paddw 10(%1), %%mm6 \n\t" "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm4 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm6, %%mm4 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm4, 8(%0) \n\t" :: "r"(&dst[i]), "r"(&b[i]) : "memory" ); } snow_horizontal_compose_lift_lead_out(i, dst, dst, b, width, w_r, 1, W_CM, W_CO, W_CS); } { // Lift 2 IDWTELEM * const ref = b+w2 - 1; i = 1; b[0] = b[0] + (((2 * ref[1] + W_BO) + 4 * b[0]) >> W_BS); asm volatile( "psllw $2, %%mm7 \n\t" ::); for(; i<w_l-7; i+=8){ asm volatile( "movq (%1), %%mm0 \n\t" "movq 8(%1), %%mm4 \n\t" "paddw 2(%1), %%mm0 \n\t" "paddw 10(%1), %%mm4 \n\t" "paddw %%mm7, %%mm0 \n\t" "paddw %%mm7, %%mm4 \n\t" "psraw $2, %%mm0 \n\t" "psraw $2, %%mm4 \n\t" "movq (%0), %%mm1 \n\t" "movq 8(%0), %%mm5 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm5, %%mm4 \n\t" "psraw $2, %%mm0 \n\t" "psraw $2, %%mm4 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm5, %%mm4 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm4, 8(%0) \n\t" :: "r"(&b[i]), "r"(&ref[i]) : "memory" ); } snow_horizontal_compose_liftS_lead_out(i, b, b, ref, width, w_l); } { // Lift 3 IDWTELEM * const src = b+w2; i = 0; for(; i<w_r-7; i+=8){ asm volatile( "movq 2(%1), %%mm2 \n\t" "movq 10(%1), %%mm6 \n\t" "paddw (%1), %%mm2 \n\t" "paddw 8(%1), %%mm6 \n\t" "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm4 \n\t" "paddw %%mm2, %%mm0 \n\t" "paddw %%mm6, %%mm4 \n\t" "psraw $1, %%mm2 \n\t" "psraw $1, %%mm6 \n\t" "paddw %%mm0, %%mm2 \n\t" "paddw %%mm4, %%mm6 \n\t" "movq %%mm2, (%2) \n\t" "movq %%mm6, 8(%2) \n\t" :: "r"(&src[i]), "r"(&b[i]), "r"(&temp[i]) : "memory" ); } snow_horizontal_compose_lift_lead_out(i, temp, src, b, width, w_r, 1, -W_AM, W_AO+1, W_AS); } { snow_interleave_line_header(&i, width, b, temp); for (; (i & 0x1E) != 0x1E; i-=2){ b[i+1] = temp[i>>1]; b[i] = b[i>>1]; } for (i-=30; i>=0; i-=32){ asm volatile( "movq (%1), %%mm0 \n\t" "movq 8(%1), %%mm2 \n\t" "movq 16(%1), %%mm4 \n\t" "movq 24(%1), %%mm6 \n\t" "movq (%1), %%mm1 \n\t" "movq 8(%1), %%mm3 \n\t" "movq 16(%1), %%mm5 \n\t" "movq 24(%1), %%mm7 \n\t" "punpcklwd (%2), %%mm0 \n\t" "punpcklwd 8(%2), %%mm2 \n\t" "punpcklwd 16(%2), %%mm4 \n\t" "punpcklwd 24(%2), %%mm6 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm2, 16(%0) \n\t" "movq %%mm4, 32(%0) \n\t" "movq %%mm6, 48(%0) \n\t" "punpckhwd (%2), %%mm1 \n\t" "punpckhwd 8(%2), %%mm3 \n\t" "punpckhwd 16(%2), %%mm5 \n\t" "punpckhwd 24(%2), %%mm7 \n\t" "movq %%mm1, 8(%0) \n\t" "movq %%mm3, 24(%0) \n\t" "movq %%mm5, 40(%0) \n\t" "movq %%mm7, 56(%0) \n\t" :: "r"(&b[i]), "r"(&b[i>>1]), "r"(&temp[i>>1]) : "memory" ); } } }
true
FFmpeg
629750290f6122a72e68c34cf94f521a90def2ef
void ff_snow_horizontal_compose97i_mmx(IDWTELEM *b, int width){ const int w2= (width+1)>>1; IDWTELEM temp[width >> 1]; const int w_l= (width>>1); const int w_r= w2 - 1; int i; { IDWTELEM * const ref = b + w2 - 1; i = 1; b[0] = b[0] - ((W_DM * 2 * ref[1]+W_DO)>>W_DS); asm volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psllw $15, %%mm7 \n\t" "psrlw $14, %%mm7 \n\t" ::); for(; i<w_l-7; i+=8){ asm volatile( "movq (%1), %%mm2 \n\t" "movq 8(%1), %%mm6 \n\t" "paddw 2(%1), %%mm2 \n\t" "paddw 10(%1), %%mm6 \n\t" "movq %%mm2, %%mm0 \n\t" "movq %%mm6, %%mm4 \n\t" "psraw $1, %%mm2 \n\t" "psraw $1, %%mm6 \n\t" "paddw %%mm0, %%mm2 \n\t" "paddw %%mm4, %%mm6 \n\t" "paddw %%mm7, %%mm2 \n\t" "paddw %%mm7, %%mm6 \n\t" "psraw $2, %%mm2 \n\t" "psraw $2, %%mm6 \n\t" "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm4 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm6, %%mm4 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm4, 8(%0) \n\t" :: "r"(&b[i]), "r"(&ref[i]) : "memory" ); } snow_horizontal_compose_lift_lead_out(i, b, b, ref, width, w_l, 0, W_DM, W_DO, W_DS); } { IDWTELEM * const dst = b+w2; i = 0; for(; i<w_r-7; i+=8){ asm volatile( "movq (%1), %%mm2 \n\t" "movq 8(%1), %%mm6 \n\t" "paddw 2(%1), %%mm2 \n\t" "paddw 10(%1), %%mm6 \n\t" "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm4 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm6, %%mm4 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm4, 8(%0) \n\t" :: "r"(&dst[i]), "r"(&b[i]) : "memory" ); } snow_horizontal_compose_lift_lead_out(i, dst, dst, b, width, w_r, 1, W_CM, W_CO, W_CS); } { IDWTELEM * const ref = b+w2 - 1; i = 1; b[0] = b[0] + (((2 * ref[1] + W_BO) + 4 * b[0]) >> W_BS); asm volatile( "psllw $2, %%mm7 \n\t" ::); for(; i<w_l-7; i+=8){ asm volatile( "movq (%1), %%mm0 \n\t" "movq 8(%1), %%mm4 \n\t" "paddw 2(%1), %%mm0 \n\t" "paddw 10(%1), %%mm4 \n\t" "paddw %%mm7, %%mm0 \n\t" "paddw %%mm7, %%mm4 \n\t" "psraw $2, %%mm0 \n\t" "psraw $2, %%mm4 \n\t" "movq (%0), %%mm1 \n\t" "movq 8(%0), %%mm5 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm5, %%mm4 \n\t" "psraw $2, %%mm0 \n\t" "psraw $2, %%mm4 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm5, %%mm4 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm4, 8(%0) \n\t" :: "r"(&b[i]), "r"(&ref[i]) : "memory" ); } snow_horizontal_compose_liftS_lead_out(i, b, b, ref, width, w_l); } { IDWTELEM * const src = b+w2; i = 0; for(; i<w_r-7; i+=8){ asm volatile( "movq 2(%1), %%mm2 \n\t" "movq 10(%1), %%mm6 \n\t" "paddw (%1), %%mm2 \n\t" "paddw 8(%1), %%mm6 \n\t" "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm4 \n\t" "paddw %%mm2, %%mm0 \n\t" "paddw %%mm6, %%mm4 \n\t" "psraw $1, %%mm2 \n\t" "psraw $1, %%mm6 \n\t" "paddw %%mm0, %%mm2 \n\t" "paddw %%mm4, %%mm6 \n\t" "movq %%mm2, (%2) \n\t" "movq %%mm6, 8(%2) \n\t" :: "r"(&src[i]), "r"(&b[i]), "r"(&temp[i]) : "memory" ); } snow_horizontal_compose_lift_lead_out(i, temp, src, b, width, w_r, 1, -W_AM, W_AO+1, W_AS); } { snow_interleave_line_header(&i, width, b, temp); for (; (i & 0x1E) != 0x1E; i-=2){ b[i+1] = temp[i>>1]; b[i] = b[i>>1]; } for (i-=30; i>=0; i-=32){ asm volatile( "movq (%1), %%mm0 \n\t" "movq 8(%1), %%mm2 \n\t" "movq 16(%1), %%mm4 \n\t" "movq 24(%1), %%mm6 \n\t" "movq (%1), %%mm1 \n\t" "movq 8(%1), %%mm3 \n\t" "movq 16(%1), %%mm5 \n\t" "movq 24(%1), %%mm7 \n\t" "punpcklwd (%2), %%mm0 \n\t" "punpcklwd 8(%2), %%mm2 \n\t" "punpcklwd 16(%2), %%mm4 \n\t" "punpcklwd 24(%2), %%mm6 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm2, 16(%0) \n\t" "movq %%mm4, 32(%0) \n\t" "movq %%mm6, 48(%0) \n\t" "punpckhwd (%2), %%mm1 \n\t" "punpckhwd 8(%2), %%mm3 \n\t" "punpckhwd 16(%2), %%mm5 \n\t" "punpckhwd 24(%2), %%mm7 \n\t" "movq %%mm1, 8(%0) \n\t" "movq %%mm3, 24(%0) \n\t" "movq %%mm5, 40(%0) \n\t" "movq %%mm7, 56(%0) \n\t" :: "r"(&b[i]), "r"(&b[i>>1]), "r"(&temp[i>>1]) : "memory" ); } } }
{ "code": [ " \"psllw $2, %%mm7 \\n\\t\"", " \"paddw 2(%1), %%mm0 \\n\\t\"", " \"paddw 10(%1), %%mm4 \\n\\t\"", " \"paddw %%mm7, %%mm0 \\n\\t\"", " \"paddw %%mm7, %%mm4 \\n\\t\"", " \"psraw $2, %%mm0 \\n\\t\"", " \"psraw $2, %%mm4 \\n\\t\"" ], "line_no": [ 151, 163, 165, 167, 169, 171, 173 ] }
void FUNC_0(IDWTELEM *VAR_0, int VAR_1){ const int VAR_2= (VAR_1+1)>>1; IDWTELEM temp[VAR_1 >> 1]; const int VAR_3= (VAR_1>>1); const int VAR_4= VAR_2 - 1; int VAR_5; { IDWTELEM * const ref = VAR_0 + VAR_2 - 1; VAR_5 = 1; VAR_0[0] = VAR_0[0] - ((W_DM * 2 * ref[1]+W_DO)>>W_DS); asm volatile( "pcmpeqw %%mm7, %%mm7 \n\t" "psllw $15, %%mm7 \n\t" "psrlw $14, %%mm7 \n\t" ::); for(; VAR_5<VAR_3-7; VAR_5+=8){ asm volatile( "movq (%1), %%mm2 \n\t" "movq 8(%1), %%mm6 \n\t" "paddw 2(%1), %%mm2 \n\t" "paddw 10(%1), %%mm6 \n\t" "movq %%mm2, %%mm0 \n\t" "movq %%mm6, %%mm4 \n\t" "psraw $1, %%mm2 \n\t" "psraw $1, %%mm6 \n\t" "paddw %%mm0, %%mm2 \n\t" "paddw %%mm4, %%mm6 \n\t" "paddw %%mm7, %%mm2 \n\t" "paddw %%mm7, %%mm6 \n\t" "psraw $2, %%mm2 \n\t" "psraw $2, %%mm6 \n\t" "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm4 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm6, %%mm4 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm4, 8(%0) \n\t" :: "r"(&VAR_0[VAR_5]), "r"(&ref[VAR_5]) : "memory" ); } snow_horizontal_compose_lift_lead_out(VAR_5, VAR_0, VAR_0, ref, VAR_1, VAR_3, 0, W_DM, W_DO, W_DS); } { IDWTELEM * const dst = VAR_0+VAR_2; VAR_5 = 0; for(; VAR_5<VAR_4-7; VAR_5+=8){ asm volatile( "movq (%1), %%mm2 \n\t" "movq 8(%1), %%mm6 \n\t" "paddw 2(%1), %%mm2 \n\t" "paddw 10(%1), %%mm6 \n\t" "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm4 \n\t" "psubw %%mm2, %%mm0 \n\t" "psubw %%mm6, %%mm4 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm4, 8(%0) \n\t" :: "r"(&dst[VAR_5]), "r"(&VAR_0[VAR_5]) : "memory" ); } snow_horizontal_compose_lift_lead_out(VAR_5, dst, dst, VAR_0, VAR_1, VAR_4, 1, W_CM, W_CO, W_CS); } { IDWTELEM * const ref = VAR_0+VAR_2 - 1; VAR_5 = 1; VAR_0[0] = VAR_0[0] + (((2 * ref[1] + W_BO) + 4 * VAR_0[0]) >> W_BS); asm volatile( "psllw $2, %%mm7 \n\t" ::); for(; VAR_5<VAR_3-7; VAR_5+=8){ asm volatile( "movq (%1), %%mm0 \n\t" "movq 8(%1), %%mm4 \n\t" "paddw 2(%1), %%mm0 \n\t" "paddw 10(%1), %%mm4 \n\t" "paddw %%mm7, %%mm0 \n\t" "paddw %%mm7, %%mm4 \n\t" "psraw $2, %%mm0 \n\t" "psraw $2, %%mm4 \n\t" "movq (%0), %%mm1 \n\t" "movq 8(%0), %%mm5 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm5, %%mm4 \n\t" "psraw $2, %%mm0 \n\t" "psraw $2, %%mm4 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm5, %%mm4 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm4, 8(%0) \n\t" :: "r"(&VAR_0[VAR_5]), "r"(&ref[VAR_5]) : "memory" ); } snow_horizontal_compose_liftS_lead_out(VAR_5, VAR_0, VAR_0, ref, VAR_1, VAR_3); } { IDWTELEM * const src = VAR_0+VAR_2; VAR_5 = 0; for(; VAR_5<VAR_4-7; VAR_5+=8){ asm volatile( "movq 2(%1), %%mm2 \n\t" "movq 10(%1), %%mm6 \n\t" "paddw (%1), %%mm2 \n\t" "paddw 8(%1), %%mm6 \n\t" "movq (%0), %%mm0 \n\t" "movq 8(%0), %%mm4 \n\t" "paddw %%mm2, %%mm0 \n\t" "paddw %%mm6, %%mm4 \n\t" "psraw $1, %%mm2 \n\t" "psraw $1, %%mm6 \n\t" "paddw %%mm0, %%mm2 \n\t" "paddw %%mm4, %%mm6 \n\t" "movq %%mm2, (%2) \n\t" "movq %%mm6, 8(%2) \n\t" :: "r"(&src[VAR_5]), "r"(&VAR_0[VAR_5]), "r"(&temp[VAR_5]) : "memory" ); } snow_horizontal_compose_lift_lead_out(VAR_5, temp, src, VAR_0, VAR_1, VAR_4, 1, -W_AM, W_AO+1, W_AS); } { snow_interleave_line_header(&VAR_5, VAR_1, VAR_0, temp); for (; (VAR_5 & 0x1E) != 0x1E; VAR_5-=2){ VAR_0[VAR_5+1] = temp[VAR_5>>1]; VAR_0[VAR_5] = VAR_0[VAR_5>>1]; } for (VAR_5-=30; VAR_5>=0; VAR_5-=32){ asm volatile( "movq (%1), %%mm0 \n\t" "movq 8(%1), %%mm2 \n\t" "movq 16(%1), %%mm4 \n\t" "movq 24(%1), %%mm6 \n\t" "movq (%1), %%mm1 \n\t" "movq 8(%1), %%mm3 \n\t" "movq 16(%1), %%mm5 \n\t" "movq 24(%1), %%mm7 \n\t" "punpcklwd (%2), %%mm0 \n\t" "punpcklwd 8(%2), %%mm2 \n\t" "punpcklwd 16(%2), %%mm4 \n\t" "punpcklwd 24(%2), %%mm6 \n\t" "movq %%mm0, (%0) \n\t" "movq %%mm2, 16(%0) \n\t" "movq %%mm4, 32(%0) \n\t" "movq %%mm6, 48(%0) \n\t" "punpckhwd (%2), %%mm1 \n\t" "punpckhwd 8(%2), %%mm3 \n\t" "punpckhwd 16(%2), %%mm5 \n\t" "punpckhwd 24(%2), %%mm7 \n\t" "movq %%mm1, 8(%0) \n\t" "movq %%mm3, 24(%0) \n\t" "movq %%mm5, 40(%0) \n\t" "movq %%mm7, 56(%0) \n\t" :: "r"(&VAR_0[VAR_5]), "r"(&VAR_0[VAR_5>>1]), "r"(&temp[VAR_5>>1]) : "memory" ); } } }
[ "void FUNC_0(IDWTELEM *VAR_0, int VAR_1){", "const int VAR_2= (VAR_1+1)>>1;", "IDWTELEM temp[VAR_1 >> 1];", "const int VAR_3= (VAR_1>>1);", "const int VAR_4= VAR_2 - 1;", "int VAR_5;", "{", "IDWTELEM * const ref = VAR_0 + VAR_2 - 1;", "VAR_5 = 1;", "VAR_0[0] = VAR_0[0] - ((W_DM * 2 * ref[1]+W_DO)>>W_DS);", "asm volatile(\n\"pcmpeqw %%mm7, %%mm7 \\n\\t\"\n\"psllw $15, %%mm7 \\n\\t\"\n\"psrlw $14, %%mm7 \\n\\t\"\n::);", "for(; VAR_5<VAR_3-7; VAR_5+=8){", "asm volatile(\n\"movq (%1), %%mm2 \\n\\t\"\n\"movq 8(%1), %%mm6 \\n\\t\"\n\"paddw 2(%1), %%mm2 \\n\\t\"\n\"paddw 10(%1), %%mm6 \\n\\t\"\n\"movq %%mm2, %%mm0 \\n\\t\"\n\"movq %%mm6, %%mm4 \\n\\t\"\n\"psraw $1, %%mm2 \\n\\t\"\n\"psraw $1, %%mm6 \\n\\t\"\n\"paddw %%mm0, %%mm2 \\n\\t\"\n\"paddw %%mm4, %%mm6 \\n\\t\"\n\"paddw %%mm7, %%mm2 \\n\\t\"\n\"paddw %%mm7, %%mm6 \\n\\t\"\n\"psraw $2, %%mm2 \\n\\t\"\n\"psraw $2, %%mm6 \\n\\t\"\n\"movq (%0), %%mm0 \\n\\t\"\n\"movq 8(%0), %%mm4 \\n\\t\"\n\"psubw %%mm2, %%mm0 \\n\\t\"\n\"psubw %%mm6, %%mm4 \\n\\t\"\n\"movq %%mm0, (%0) \\n\\t\"\n\"movq %%mm4, 8(%0) \\n\\t\"\n:: \"r\"(&VAR_0[VAR_5]), \"r\"(&ref[VAR_5])\n: \"memory\"\n);", "}", "snow_horizontal_compose_lift_lead_out(VAR_5, VAR_0, VAR_0, ref, VAR_1, VAR_3, 0, W_DM, W_DO, W_DS);", "}", "{", "IDWTELEM * const dst = VAR_0+VAR_2;", "VAR_5 = 0;", "for(; VAR_5<VAR_4-7; VAR_5+=8){", "asm volatile(\n\"movq (%1), %%mm2 \\n\\t\"\n\"movq 8(%1), %%mm6 \\n\\t\"\n\"paddw 2(%1), %%mm2 \\n\\t\"\n\"paddw 10(%1), %%mm6 \\n\\t\"\n\"movq (%0), %%mm0 \\n\\t\"\n\"movq 8(%0), %%mm4 \\n\\t\"\n\"psubw %%mm2, %%mm0 \\n\\t\"\n\"psubw %%mm6, %%mm4 \\n\\t\"\n\"movq %%mm0, (%0) \\n\\t\"\n\"movq %%mm4, 8(%0) \\n\\t\"\n:: \"r\"(&dst[VAR_5]), \"r\"(&VAR_0[VAR_5])\n: \"memory\"\n);", "}", "snow_horizontal_compose_lift_lead_out(VAR_5, dst, dst, VAR_0, VAR_1, VAR_4, 1, W_CM, W_CO, W_CS);", "}", "{", "IDWTELEM * const ref = VAR_0+VAR_2 - 1;", "VAR_5 = 1;", "VAR_0[0] = VAR_0[0] + (((2 * ref[1] + W_BO) + 4 * VAR_0[0]) >> W_BS);", "asm volatile(\n\"psllw $2, %%mm7 \\n\\t\"\n::);", "for(; VAR_5<VAR_3-7; VAR_5+=8){", "asm volatile(\n\"movq (%1), %%mm0 \\n\\t\"\n\"movq 8(%1), %%mm4 \\n\\t\"\n\"paddw 2(%1), %%mm0 \\n\\t\"\n\"paddw 10(%1), %%mm4 \\n\\t\"\n\"paddw %%mm7, %%mm0 \\n\\t\"\n\"paddw %%mm7, %%mm4 \\n\\t\"\n\"psraw $2, %%mm0 \\n\\t\"\n\"psraw $2, %%mm4 \\n\\t\"\n\"movq (%0), %%mm1 \\n\\t\"\n\"movq 8(%0), %%mm5 \\n\\t\"\n\"paddw %%mm1, %%mm0 \\n\\t\"\n\"paddw %%mm5, %%mm4 \\n\\t\"\n\"psraw $2, %%mm0 \\n\\t\"\n\"psraw $2, %%mm4 \\n\\t\"\n\"paddw %%mm1, %%mm0 \\n\\t\"\n\"paddw %%mm5, %%mm4 \\n\\t\"\n\"movq %%mm0, (%0) \\n\\t\"\n\"movq %%mm4, 8(%0) \\n\\t\"\n:: \"r\"(&VAR_0[VAR_5]), \"r\"(&ref[VAR_5])\n: \"memory\"\n);", "}", "snow_horizontal_compose_liftS_lead_out(VAR_5, VAR_0, VAR_0, ref, VAR_1, VAR_3);", "}", "{", "IDWTELEM * const src = VAR_0+VAR_2;", "VAR_5 = 0;", "for(; VAR_5<VAR_4-7; VAR_5+=8){", "asm volatile(\n\"movq 2(%1), %%mm2 \\n\\t\"\n\"movq 10(%1), %%mm6 \\n\\t\"\n\"paddw (%1), %%mm2 \\n\\t\"\n\"paddw 8(%1), %%mm6 \\n\\t\"\n\"movq (%0), %%mm0 \\n\\t\"\n\"movq 8(%0), %%mm4 \\n\\t\"\n\"paddw %%mm2, %%mm0 \\n\\t\"\n\"paddw %%mm6, %%mm4 \\n\\t\"\n\"psraw $1, %%mm2 \\n\\t\"\n\"psraw $1, %%mm6 \\n\\t\"\n\"paddw %%mm0, %%mm2 \\n\\t\"\n\"paddw %%mm4, %%mm6 \\n\\t\"\n\"movq %%mm2, (%2) \\n\\t\"\n\"movq %%mm6, 8(%2) \\n\\t\"\n:: \"r\"(&src[VAR_5]), \"r\"(&VAR_0[VAR_5]), \"r\"(&temp[VAR_5])\n: \"memory\"\n);", "}", "snow_horizontal_compose_lift_lead_out(VAR_5, temp, src, VAR_0, VAR_1, VAR_4, 1, -W_AM, W_AO+1, W_AS);", "}", "{", "snow_interleave_line_header(&VAR_5, VAR_1, VAR_0, temp);", "for (; (VAR_5 & 0x1E) != 0x1E; VAR_5-=2){", "VAR_0[VAR_5+1] = temp[VAR_5>>1];", "VAR_0[VAR_5] = VAR_0[VAR_5>>1];", "}", "for (VAR_5-=30; VAR_5>=0; VAR_5-=32){", "asm volatile(\n\"movq (%1), %%mm0 \\n\\t\"\n\"movq 8(%1), %%mm2 \\n\\t\"\n\"movq 16(%1), %%mm4 \\n\\t\"\n\"movq 24(%1), %%mm6 \\n\\t\"\n\"movq (%1), %%mm1 \\n\\t\"\n\"movq 8(%1), %%mm3 \\n\\t\"\n\"movq 16(%1), %%mm5 \\n\\t\"\n\"movq 24(%1), %%mm7 \\n\\t\"\n\"punpcklwd (%2), %%mm0 \\n\\t\"\n\"punpcklwd 8(%2), %%mm2 \\n\\t\"\n\"punpcklwd 16(%2), %%mm4 \\n\\t\"\n\"punpcklwd 24(%2), %%mm6 \\n\\t\"\n\"movq %%mm0, (%0) \\n\\t\"\n\"movq %%mm2, 16(%0) \\n\\t\"\n\"movq %%mm4, 32(%0) \\n\\t\"\n\"movq %%mm6, 48(%0) \\n\\t\"\n\"punpckhwd (%2), %%mm1 \\n\\t\"\n\"punpckhwd 8(%2), %%mm3 \\n\\t\"\n\"punpckhwd 16(%2), %%mm5 \\n\\t\"\n\"punpckhwd 24(%2), %%mm7 \\n\\t\"\n\"movq %%mm1, 8(%0) \\n\\t\"\n\"movq %%mm3, 24(%0) \\n\\t\"\n\"movq %%mm5, 40(%0) \\n\\t\"\n\"movq %%mm7, 56(%0) \\n\\t\"\n:: \"r\"(&VAR_0[VAR_5]), \"r\"(&VAR_0[VAR_5>>1]), \"r\"(&temp[VAR_5>>1])\n: \"memory\"\n);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25, 27, 29, 31, 33 ], [ 35 ], [ 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149, 151, 153 ], [ 155 ], [ 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199 ], [ 201 ], [ 203 ], [ 205 ], [ 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219, 221, 223, 225, 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, 247, 249, 251, 253 ], [ 255 ], [ 257 ], [ 259 ], [ 263 ], [ 265 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279, 281, 283, 285, 287, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, 323, 325, 327, 329, 331, 333 ], [ 335 ], [ 337 ], [ 339 ] ]
486
static int net_dump_init(VLANState *vlan, const char *device, const char *name, const char *filename, int len) { struct pcap_file_hdr hdr; DumpState *s; s = qemu_malloc(sizeof(DumpState)); s->fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644); if (s->fd < 0) { qemu_error("-net dump: can't open %s\n", filename); return -1; } s->pcap_caplen = len; hdr.magic = PCAP_MAGIC; hdr.version_major = 2; hdr.version_minor = 4; hdr.thiszone = 0; hdr.sigfigs = 0; hdr.snaplen = s->pcap_caplen; hdr.linktype = 1; if (write(s->fd, &hdr, sizeof(hdr)) < sizeof(hdr)) { qemu_error("-net dump write error: %s\n", strerror(errno)); close(s->fd); qemu_free(s); return -1; } s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP, vlan, NULL, device, name, NULL, dump_receive, NULL, NULL, net_dump_cleanup, s); snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str), "dump to %s (len=%d)", filename, len); return 0; }
true
qemu
731d5856cbb9c160fe02b90cd3cf354ea4f52f34
static int net_dump_init(VLANState *vlan, const char *device, const char *name, const char *filename, int len) { struct pcap_file_hdr hdr; DumpState *s; s = qemu_malloc(sizeof(DumpState)); s->fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644); if (s->fd < 0) { qemu_error("-net dump: can't open %s\n", filename); return -1; } s->pcap_caplen = len; hdr.magic = PCAP_MAGIC; hdr.version_major = 2; hdr.version_minor = 4; hdr.thiszone = 0; hdr.sigfigs = 0; hdr.snaplen = s->pcap_caplen; hdr.linktype = 1; if (write(s->fd, &hdr, sizeof(hdr)) < sizeof(hdr)) { qemu_error("-net dump write error: %s\n", strerror(errno)); close(s->fd); qemu_free(s); return -1; } s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP, vlan, NULL, device, name, NULL, dump_receive, NULL, NULL, net_dump_cleanup, s); snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str), "dump to %s (len=%d)", filename, len); return 0; }
{ "code": [ " s = qemu_malloc(sizeof(DumpState));", " s->fd = open(filename, O_CREAT | O_WRONLY | O_BINARY, 0644);", " if (s->fd < 0) {", " s->pcap_caplen = len;", " hdr.snaplen = s->pcap_caplen;", " if (write(s->fd, &hdr, sizeof(hdr)) < sizeof(hdr)) {", " close(s->fd);", " qemu_free(s);", " s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP,", " vlan, NULL, device, name, NULL,", " dump_receive, NULL, NULL,", " net_dump_cleanup, s);", " snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str)," ], "line_no": [ 13, 17, 19, 29, 43, 49, 53, 55, 63, 65, 67, 69, 71 ] }
static int FUNC_0(VLANState *VAR_0, const char *VAR_1, const char *VAR_2, const char *VAR_3, int VAR_4) { struct pcap_file_hdr VAR_5; DumpState *s; s = qemu_malloc(sizeof(DumpState)); s->fd = open(VAR_3, O_CREAT | O_WRONLY | O_BINARY, 0644); if (s->fd < 0) { qemu_error("-net dump: can't open %s\n", VAR_3); return -1; } s->pcap_caplen = VAR_4; VAR_5.magic = PCAP_MAGIC; VAR_5.version_major = 2; VAR_5.version_minor = 4; VAR_5.thiszone = 0; VAR_5.sigfigs = 0; VAR_5.snaplen = s->pcap_caplen; VAR_5.linktype = 1; if (write(s->fd, &VAR_5, sizeof(VAR_5)) < sizeof(VAR_5)) { qemu_error("-net dump write error: %s\n", strerror(errno)); close(s->fd); qemu_free(s); return -1; } s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP, VAR_0, NULL, VAR_1, VAR_2, NULL, dump_receive, NULL, NULL, net_dump_cleanup, s); snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str), "dump to %s (VAR_4=%d)", VAR_3, VAR_4); return 0; }
[ "static int FUNC_0(VLANState *VAR_0, const char *VAR_1,\nconst char *VAR_2, const char *VAR_3, int VAR_4)\n{", "struct pcap_file_hdr VAR_5;", "DumpState *s;", "s = qemu_malloc(sizeof(DumpState));", "s->fd = open(VAR_3, O_CREAT | O_WRONLY | O_BINARY, 0644);", "if (s->fd < 0) {", "qemu_error(\"-net dump: can't open %s\\n\", VAR_3);", "return -1;", "}", "s->pcap_caplen = VAR_4;", "VAR_5.magic = PCAP_MAGIC;", "VAR_5.version_major = 2;", "VAR_5.version_minor = 4;", "VAR_5.thiszone = 0;", "VAR_5.sigfigs = 0;", "VAR_5.snaplen = s->pcap_caplen;", "VAR_5.linktype = 1;", "if (write(s->fd, &VAR_5, sizeof(VAR_5)) < sizeof(VAR_5)) {", "qemu_error(\"-net dump write error: %s\\n\", strerror(errno));", "close(s->fd);", "qemu_free(s);", "return -1;", "}", "s->pcap_vc = qemu_new_vlan_client(NET_CLIENT_TYPE_DUMP,\nVAR_0, NULL, VAR_1, VAR_2, NULL,\ndump_receive, NULL, NULL,\nnet_dump_cleanup, s);", "snprintf(s->pcap_vc->info_str, sizeof(s->pcap_vc->info_str),\n\"dump to %s (VAR_4=%d)\", VAR_3, VAR_4);", "return 0;", "}" ]
[ 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63, 65, 67, 69 ], [ 71, 73 ], [ 75 ], [ 77 ] ]
487
void check_values (eq2_param_t *par) { /* yuck! floating point comparisons... */ if ((par->c == 1.0) && (par->b == 0.0) && (par->g == 1.0)) { par->adjust = NULL; } #if HAVE_MMX && HAVE_6REGS else if (par->g == 1.0 && ff_gCpuCaps.hasMMX) { par->adjust = &affine_1d_MMX; } #endif else { par->adjust = &apply_lut; } }
false
FFmpeg
70205f1799252c3363a5bb5ea7ea5df090f2c88f
void check_values (eq2_param_t *par) { if ((par->c == 1.0) && (par->b == 0.0) && (par->g == 1.0)) { par->adjust = NULL; } #if HAVE_MMX && HAVE_6REGS else if (par->g == 1.0 && ff_gCpuCaps.hasMMX) { par->adjust = &affine_1d_MMX; } #endif else { par->adjust = &apply_lut; } }
{ "code": [], "line_no": [] }
void FUNC_0 (eq2_param_t *VAR_0) { if ((VAR_0->c == 1.0) && (VAR_0->b == 0.0) && (VAR_0->g == 1.0)) { VAR_0->adjust = NULL; } #if HAVE_MMX && HAVE_6REGS else if (VAR_0->g == 1.0 && ff_gCpuCaps.hasMMX) { VAR_0->adjust = &affine_1d_MMX; } #endif else { VAR_0->adjust = &apply_lut; } }
[ "void FUNC_0 (eq2_param_t *VAR_0)\n{", "if ((VAR_0->c == 1.0) && (VAR_0->b == 0.0) && (VAR_0->g == 1.0)) {", "VAR_0->adjust = NULL;", "}", "#if HAVE_MMX && HAVE_6REGS\nelse if (VAR_0->g == 1.0 && ff_gCpuCaps.hasMMX) {", "VAR_0->adjust = &affine_1d_MMX;", "}", "#endif\nelse {", "VAR_0->adjust = &apply_lut;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 9 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ] ]
488
static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s) { unsigned char B; int x, y; /* copy block from 2 frames ago using a motion vector; need 1 more byte */ CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 1); B = *s->stream_ptr++; if (B < 56) { x = 8 + (B % 7); y = B / 7; } else { x = -14 + ((B - 56) % 29); y = 8 + ((B - 56) / 29); } debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); return copy_from(s, &s->second_last_frame, x, y); }
false
FFmpeg
dcfb0cad687ec89d3c7fe21a014c58f283050283
static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s) { unsigned char B; int x, y; CHECK_STREAM_PTR(s->stream_ptr, s->stream_end, 1); B = *s->stream_ptr++; if (B < 56) { x = 8 + (B % 7); y = B / 7; } else { x = -14 + ((B - 56) % 29); y = 8 + ((B - 56) / 29); } debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y); return copy_from(s, &s->second_last_frame, x, y); }
{ "code": [], "line_no": [] }
static int FUNC_0(IpvideoContext *VAR_0) { unsigned char VAR_1; int VAR_2, VAR_3; CHECK_STREAM_PTR(VAR_0->stream_ptr, VAR_0->stream_end, 1); VAR_1 = *VAR_0->stream_ptr++; if (VAR_1 < 56) { VAR_2 = 8 + (VAR_1 % 7); VAR_3 = VAR_1 / 7; } else { VAR_2 = -14 + ((VAR_1 - 56) % 29); VAR_3 = 8 + ((VAR_1 - 56) / 29); } debug_interplay (" motion byte = %d, (VAR_2, VAR_3) = (%d, %d)\n", VAR_1, VAR_2, VAR_3); return copy_from(VAR_0, &VAR_0->second_last_frame, VAR_2, VAR_3); }
[ "static int FUNC_0(IpvideoContext *VAR_0)\n{", "unsigned char VAR_1;", "int VAR_2, VAR_3;", "CHECK_STREAM_PTR(VAR_0->stream_ptr, VAR_0->stream_end, 1);", "VAR_1 = *VAR_0->stream_ptr++;", "if (VAR_1 < 56) {", "VAR_2 = 8 + (VAR_1 % 7);", "VAR_3 = VAR_1 / 7;", "} else {", "VAR_2 = -14 + ((VAR_1 - 56) % 29);", "VAR_3 = 8 + ((VAR_1 - 56) / 29);", "}", "debug_interplay (\" motion byte = %d, (VAR_2, VAR_3) = (%d, %d)\\n\", VAR_1, VAR_2, VAR_3);", "return copy_from(VAR_0, &VAR_0->second_last_frame, VAR_2, VAR_3);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ] ]
489
static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) { AVFilterContext *ctx = codec->opaque; AVFilterBufferRef *ref; int perms = AV_PERM_WRITE; int i, w, h, stride[4]; unsigned edge; if(av_image_check_size(w, h, 0, codec)) return -1; if (codec->codec->capabilities & CODEC_CAP_NEG_LINESIZES) perms |= AV_PERM_NEG_LINESIZES; if(pic->buffer_hints & FF_BUFFER_HINTS_VALID) { if(pic->buffer_hints & FF_BUFFER_HINTS_READABLE) perms |= AV_PERM_READ; if(pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) perms |= AV_PERM_PRESERVE; if(pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE) perms |= AV_PERM_REUSE2; } if(pic->reference) perms |= AV_PERM_READ | AV_PERM_PRESERVE; w = codec->width; h = codec->height; avcodec_align_dimensions2(codec, &w, &h, stride); edge = codec->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width(); w += edge << 1; h += edge << 1; if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h))) return -1; ref->video->w = codec->width; ref->video->h = codec->height; for(i = 0; i < 4; i ++) { unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0; unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0; if (ref->data[i]) { ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift); } pic->data[i] = ref->data[i]; pic->linesize[i] = ref->linesize[i]; } pic->opaque = ref; pic->age = INT_MAX; pic->type = FF_BUFFER_TYPE_USER; pic->reordered_opaque = codec->reordered_opaque; if(codec->pkt) pic->pkt_pts = codec->pkt->pts; else pic->pkt_pts = AV_NOPTS_VALUE; return 0; }
false
FFmpeg
9f8008a9815ed5ee8846de2bb97c980ddb7b2485
static int input_get_buffer(AVCodecContext *codec, AVFrame *pic) { AVFilterContext *ctx = codec->opaque; AVFilterBufferRef *ref; int perms = AV_PERM_WRITE; int i, w, h, stride[4]; unsigned edge; if(av_image_check_size(w, h, 0, codec)) return -1; if (codec->codec->capabilities & CODEC_CAP_NEG_LINESIZES) perms |= AV_PERM_NEG_LINESIZES; if(pic->buffer_hints & FF_BUFFER_HINTS_VALID) { if(pic->buffer_hints & FF_BUFFER_HINTS_READABLE) perms |= AV_PERM_READ; if(pic->buffer_hints & FF_BUFFER_HINTS_PRESERVE) perms |= AV_PERM_PRESERVE; if(pic->buffer_hints & FF_BUFFER_HINTS_REUSABLE) perms |= AV_PERM_REUSE2; } if(pic->reference) perms |= AV_PERM_READ | AV_PERM_PRESERVE; w = codec->width; h = codec->height; avcodec_align_dimensions2(codec, &w, &h, stride); edge = codec->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width(); w += edge << 1; h += edge << 1; if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], perms, w, h))) return -1; ref->video->w = codec->width; ref->video->h = codec->height; for(i = 0; i < 4; i ++) { unsigned hshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0; unsigned vshift = (i == 1 || i == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0; if (ref->data[i]) { ref->data[i] += (edge >> hshift) + ((edge * ref->linesize[i]) >> vshift); } pic->data[i] = ref->data[i]; pic->linesize[i] = ref->linesize[i]; } pic->opaque = ref; pic->age = INT_MAX; pic->type = FF_BUFFER_TYPE_USER; pic->reordered_opaque = codec->reordered_opaque; if(codec->pkt) pic->pkt_pts = codec->pkt->pts; else pic->pkt_pts = AV_NOPTS_VALUE; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1) { AVFilterContext *ctx = VAR_0->opaque; AVFilterBufferRef *ref; int VAR_2 = AV_PERM_WRITE; int VAR_3, VAR_4, VAR_5, VAR_6[4]; unsigned VAR_7; if(av_image_check_size(VAR_4, VAR_5, 0, VAR_0)) return -1; if (VAR_0->VAR_0->capabilities & CODEC_CAP_NEG_LINESIZES) VAR_2 |= AV_PERM_NEG_LINESIZES; if(VAR_1->buffer_hints & FF_BUFFER_HINTS_VALID) { if(VAR_1->buffer_hints & FF_BUFFER_HINTS_READABLE) VAR_2 |= AV_PERM_READ; if(VAR_1->buffer_hints & FF_BUFFER_HINTS_PRESERVE) VAR_2 |= AV_PERM_PRESERVE; if(VAR_1->buffer_hints & FF_BUFFER_HINTS_REUSABLE) VAR_2 |= AV_PERM_REUSE2; } if(VAR_1->reference) VAR_2 |= AV_PERM_READ | AV_PERM_PRESERVE; VAR_4 = VAR_0->width; VAR_5 = VAR_0->height; avcodec_align_dimensions2(VAR_0, &VAR_4, &VAR_5, VAR_6); VAR_7 = VAR_0->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width(); VAR_4 += VAR_7 << 1; VAR_5 += VAR_7 << 1; if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], VAR_2, VAR_4, VAR_5))) return -1; ref->video->VAR_4 = VAR_0->width; ref->video->VAR_5 = VAR_0->height; for(VAR_3 = 0; VAR_3 < 4; VAR_3 ++) { unsigned VAR_8 = (VAR_3 == 1 || VAR_3 == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0; unsigned VAR_9 = (VAR_3 == 1 || VAR_3 == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0; if (ref->data[VAR_3]) { ref->data[VAR_3] += (VAR_7 >> VAR_8) + ((VAR_7 * ref->linesize[VAR_3]) >> VAR_9); } VAR_1->data[VAR_3] = ref->data[VAR_3]; VAR_1->linesize[VAR_3] = ref->linesize[VAR_3]; } VAR_1->opaque = ref; VAR_1->age = INT_MAX; VAR_1->type = FF_BUFFER_TYPE_USER; VAR_1->reordered_opaque = VAR_0->reordered_opaque; if(VAR_0->pkt) VAR_1->pkt_pts = VAR_0->pkt->pts; else VAR_1->pkt_pts = AV_NOPTS_VALUE; return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1)\n{", "AVFilterContext *ctx = VAR_0->opaque;", "AVFilterBufferRef *ref;", "int VAR_2 = AV_PERM_WRITE;", "int VAR_3, VAR_4, VAR_5, VAR_6[4];", "unsigned VAR_7;", "if(av_image_check_size(VAR_4, VAR_5, 0, VAR_0))\nreturn -1;", "if (VAR_0->VAR_0->capabilities & CODEC_CAP_NEG_LINESIZES)\nVAR_2 |= AV_PERM_NEG_LINESIZES;", "if(VAR_1->buffer_hints & FF_BUFFER_HINTS_VALID) {", "if(VAR_1->buffer_hints & FF_BUFFER_HINTS_READABLE) VAR_2 |= AV_PERM_READ;", "if(VAR_1->buffer_hints & FF_BUFFER_HINTS_PRESERVE) VAR_2 |= AV_PERM_PRESERVE;", "if(VAR_1->buffer_hints & FF_BUFFER_HINTS_REUSABLE) VAR_2 |= AV_PERM_REUSE2;", "}", "if(VAR_1->reference) VAR_2 |= AV_PERM_READ | AV_PERM_PRESERVE;", "VAR_4 = VAR_0->width;", "VAR_5 = VAR_0->height;", "avcodec_align_dimensions2(VAR_0, &VAR_4, &VAR_5, VAR_6);", "VAR_7 = VAR_0->flags & CODEC_FLAG_EMU_EDGE ? 0 : avcodec_get_edge_width();", "VAR_4 += VAR_7 << 1;", "VAR_5 += VAR_7 << 1;", "if(!(ref = avfilter_get_video_buffer(ctx->outputs[0], VAR_2, VAR_4, VAR_5)))\nreturn -1;", "ref->video->VAR_4 = VAR_0->width;", "ref->video->VAR_5 = VAR_0->height;", "for(VAR_3 = 0; VAR_3 < 4; VAR_3 ++) {", "unsigned VAR_8 = (VAR_3 == 1 || VAR_3 == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_w : 0;", "unsigned VAR_9 = (VAR_3 == 1 || VAR_3 == 2) ? av_pix_fmt_descriptors[ref->format].log2_chroma_h : 0;", "if (ref->data[VAR_3]) {", "ref->data[VAR_3] += (VAR_7 >> VAR_8) + ((VAR_7 * ref->linesize[VAR_3]) >> VAR_9);", "}", "VAR_1->data[VAR_3] = ref->data[VAR_3];", "VAR_1->linesize[VAR_3] = ref->linesize[VAR_3];", "}", "VAR_1->opaque = ref;", "VAR_1->age = INT_MAX;", "VAR_1->type = FF_BUFFER_TYPE_USER;", "VAR_1->reordered_opaque = VAR_0->reordered_opaque;", "if(VAR_0->pkt) VAR_1->pkt_pts = VAR_0->pkt->pts;", "else VAR_1->pkt_pts = AV_NOPTS_VALUE;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 23, 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ] ]
492
static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { BdrvTrackedRequest *req; int64_t cluster_sector_num; int cluster_nb_sectors; bool retry; /* If we touch the same cluster it counts as an overlap. This guarantees * that allocating writes will be serialized and not race with each other * for the same cluster. For example, in copy-on-read it ensures that the * CoR read and write operations are atomic and guest writes cannot * interleave between them. round_to_clusters(bs, sector_num, nb_sectors, &cluster_sector_num, &cluster_nb_sectors); do { retry = false; QLIST_FOREACH(req, &bs->tracked_requests, list) { if (tracked_request_overlaps(req, cluster_sector_num, cluster_nb_sectors)) { qemu_co_queue_wait(&req->wait_queue); retry = true; break; } } } while (retry); }
true
qemu
5f8b6491f20732e0a31e64bbf75b62def579e044
static void coroutine_fn wait_for_overlapping_requests(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { BdrvTrackedRequest *req; int64_t cluster_sector_num; int cluster_nb_sectors; bool retry; /* If we touch the same cluster it counts as an overlap. This guarantees * that allocating writes will be serialized and not race with each other * for the same cluster. For example, in copy-on-read it ensures that the * CoR read and write operations are atomic and guest writes cannot * interleave between them. round_to_clusters(bs, sector_num, nb_sectors, &cluster_sector_num, &cluster_nb_sectors); do { retry = false; QLIST_FOREACH(req, &bs->tracked_requests, list) { if (tracked_request_overlaps(req, cluster_sector_num, cluster_nb_sectors)) { qemu_co_queue_wait(&req->wait_queue); retry = true; break; } } } while (retry); }
{ "code": [], "line_no": [] }
static void VAR_0 wait_for_overlapping_requests(BlockDriverState *bs, int64_t sector_num, int nb_sectors) { BdrvTrackedRequest *req; int64_t cluster_sector_num; int cluster_nb_sectors; bool retry; /* If we touch the same cluster it counts as an overlap. This guarantees * that allocating writes will be serialized and not race with each other * for the same cluster. For example, in copy-on-read it ensures that the * CoR read and write operations are atomic and guest writes cannot * interleave between them. round_to_clusters(bs, sector_num, nb_sectors, &cluster_sector_num, &cluster_nb_sectors); do { retry = false; QLIST_FOREACH(req, &bs->tracked_requests, list) { if (tracked_request_overlaps(req, cluster_sector_num, cluster_nb_sectors)) { qemu_co_queue_wait(&req->wait_queue); retry = true; break; } } } while (retry); }
[ "static void VAR_0 wait_for_overlapping_requests(BlockDriverState *bs,\nint64_t sector_num, int nb_sectors)\n{", "BdrvTrackedRequest *req;", "int64_t cluster_sector_num;", "int cluster_nb_sectors;", "bool retry;", "/* If we touch the same cluster it counts as an overlap. This guarantees\n* that allocating writes will be serialized and not race with each other\n* for the same cluster. For example, in copy-on-read it ensures that the\n* CoR read and write operations are atomic and guest writes cannot\n* interleave between them.\nround_to_clusters(bs, sector_num, nb_sectors,\n&cluster_sector_num, &cluster_nb_sectors);", "do {", "retry = false;", "QLIST_FOREACH(req, &bs->tracked_requests, list) {", "if (tracked_request_overlaps(req, cluster_sector_num,\ncluster_nb_sectors)) {", "qemu_co_queue_wait(&req->wait_queue);", "retry = true;", "break;", "}", "}", "} while (retry);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2, 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8, 9, 10, 11, 12, 13, 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18, 19 ], [ 20 ], [ 21 ], [ 22 ], [ 23 ], [ 24 ], [ 25 ], [ 26 ] ]
493
static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, const char *model, const char *name, int fd, int is_connected) { struct sockaddr_in saddr; int newfd; socklen_t saddr_len; VLANClientState *nc; NetSocketState *s; /* fd passed: multicast: "learn" dgram_dst address from bound address and save it * Because this may be "shared" socket from a "master" process, datagrams would be recv() * by ONLY ONE process: we must "clone" this dgram socket --jjo */ if (is_connected) { if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) { /* must be bound */ if (saddr.sin_addr.s_addr == 0) { fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, " "cannot setup multicast dst addr\n", fd); return NULL; } /* clone dgram socket */ newfd = net_socket_mcast_create(&saddr, NULL); if (newfd < 0) { /* error already reported by net_socket_mcast_create() */ close(fd); return NULL; } /* clone newfd to fd, close newfd */ dup2(newfd, fd); close(newfd); } else { fprintf(stderr, "qemu: error: init_dgram: fd=%d failed getsockname(): %s\n", fd, strerror(errno)); return NULL; } } nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name); snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d (%s mcast=%s:%d)", fd, is_connected ? "cloned" : "", inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); s = DO_UPCAST(NetSocketState, nc, nc); s->fd = fd; qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s); /* mcast: save bound address as dst */ if (is_connected) s->dgram_dst=saddr; return s; }
true
qemu
e5d1fca0f20babbe355957b9ba536fe6187691cc
static NetSocketState *net_socket_fd_init_dgram(VLANState *vlan, const char *model, const char *name, int fd, int is_connected) { struct sockaddr_in saddr; int newfd; socklen_t saddr_len; VLANClientState *nc; NetSocketState *s; if (is_connected) { if (getsockname(fd, (struct sockaddr *) &saddr, &saddr_len) == 0) { if (saddr.sin_addr.s_addr == 0) { fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, " "cannot setup multicast dst addr\n", fd); return NULL; } newfd = net_socket_mcast_create(&saddr, NULL); if (newfd < 0) { close(fd); return NULL; } dup2(newfd, fd); close(newfd); } else { fprintf(stderr, "qemu: error: init_dgram: fd=%d failed getsockname(): %s\n", fd, strerror(errno)); return NULL; } } nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name); snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d (%s mcast=%s:%d)", fd, is_connected ? "cloned" : "", inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port)); s = DO_UPCAST(NetSocketState, nc, nc); s->fd = fd; qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s); if (is_connected) s->dgram_dst=saddr; return s; }
{ "code": [ " return NULL;", " close(fd);", " return NULL;", " return NULL;" ], "line_no": [ 45, 57, 45, 79 ] }
static NetSocketState *FUNC_0(VLANState *vlan, const char *model, const char *name, int fd, int is_connected) { struct sockaddr_in VAR_0; int VAR_1; socklen_t saddr_len; VLANClientState *nc; NetSocketState *s; if (is_connected) { if (getsockname(fd, (struct sockaddr *) &VAR_0, &saddr_len) == 0) { if (VAR_0.sin_addr.s_addr == 0) { fprintf(stderr, "qemu: error: init_dgram: fd=%d unbound, " "cannot setup multicast dst addr\n", fd); return NULL; } VAR_1 = net_socket_mcast_create(&VAR_0, NULL); if (VAR_1 < 0) { close(fd); return NULL; } dup2(VAR_1, fd); close(VAR_1); } else { fprintf(stderr, "qemu: error: init_dgram: fd=%d failed getsockname(): %s\n", fd, strerror(errno)); return NULL; } } nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name); snprintf(nc->info_str, sizeof(nc->info_str), "socket: fd=%d (%s mcast=%s:%d)", fd, is_connected ? "cloned" : "", inet_ntoa(VAR_0.sin_addr), ntohs(VAR_0.sin_port)); s = DO_UPCAST(NetSocketState, nc, nc); s->fd = fd; qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s); if (is_connected) s->dgram_dst=VAR_0; return s; }
[ "static NetSocketState *FUNC_0(VLANState *vlan,\nconst char *model,\nconst char *name,\nint fd, int is_connected)\n{", "struct sockaddr_in VAR_0;", "int VAR_1;", "socklen_t saddr_len;", "VLANClientState *nc;", "NetSocketState *s;", "if (is_connected) {", "if (getsockname(fd, (struct sockaddr *) &VAR_0, &saddr_len) == 0) {", "if (VAR_0.sin_addr.s_addr == 0) {", "fprintf(stderr, \"qemu: error: init_dgram: fd=%d unbound, \"\n\"cannot setup multicast dst addr\\n\", fd);", "return NULL;", "}", "VAR_1 = net_socket_mcast_create(&VAR_0, NULL);", "if (VAR_1 < 0) {", "close(fd);", "return NULL;", "}", "dup2(VAR_1, fd);", "close(VAR_1);", "} else {", "fprintf(stderr,\n\"qemu: error: init_dgram: fd=%d failed getsockname(): %s\\n\",\nfd, strerror(errno));", "return NULL;", "}", "}", "nc = qemu_new_net_client(&net_dgram_socket_info, vlan, NULL, model, name);", "snprintf(nc->info_str, sizeof(nc->info_str),\n\"socket: fd=%d (%s mcast=%s:%d)\",\nfd, is_connected ? \"cloned\" : \"\",\ninet_ntoa(VAR_0.sin_addr), ntohs(VAR_0.sin_port));", "s = DO_UPCAST(NetSocketState, nc, nc);", "s->fd = fd;", "qemu_set_fd_handler(s->fd, net_socket_send_dgram, NULL, s);", "if (is_connected) s->dgram_dst=VAR_0;", "return s;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 33 ], [ 35 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 71 ], [ 73, 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 91, 93, 95, 97 ], [ 101 ], [ 105 ], [ 109 ], [ 115 ], [ 119 ], [ 121 ] ]
494
int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter) { return hbitmap_iter_next(&iter->hbi); }
false
qemu
f798184cfdcb7f92a38c5f717d675bd75e1fd3ac
int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter) { return hbitmap_iter_next(&iter->hbi); }
{ "code": [], "line_no": [] }
int64_t FUNC_0(BdrvDirtyBitmapIter *iter) { return hbitmap_iter_next(&iter->hbi); }
[ "int64_t FUNC_0(BdrvDirtyBitmapIter *iter)\n{", "return hbitmap_iter_next(&iter->hbi);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
495
static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size) { if (s->RxBufAddr + size > s->RxBufferSize) { int wrapped = MOD2(s->RxBufAddr + size, s->RxBufferSize); /* write packet data */ if (wrapped && s->RxBufferSize < 65536 && !rtl8139_RxWrap(s)) { DEBUG_PRINT((">>> RTL8139: rx packet wrapped in buffer at %d\n", size-wrapped)); if (size > wrapped) { cpu_physical_memory_write( s->RxBuf + s->RxBufAddr, buf, size-wrapped ); } /* reset buffer pointer */ s->RxBufAddr = 0; cpu_physical_memory_write( s->RxBuf + s->RxBufAddr, buf + (size-wrapped), wrapped ); s->RxBufAddr = wrapped; return; } } /* non-wrapping path or overwrapping enabled */ cpu_physical_memory_write( s->RxBuf + s->RxBufAddr, buf, size ); s->RxBufAddr += size; }
false
qemu
ccf1d14a1e37abe1f0da162c00a8941963b47a4c
static void rtl8139_write_buffer(RTL8139State *s, const void *buf, int size) { if (s->RxBufAddr + size > s->RxBufferSize) { int wrapped = MOD2(s->RxBufAddr + size, s->RxBufferSize); if (wrapped && s->RxBufferSize < 65536 && !rtl8139_RxWrap(s)) { DEBUG_PRINT((">>> RTL8139: rx packet wrapped in buffer at %d\n", size-wrapped)); if (size > wrapped) { cpu_physical_memory_write( s->RxBuf + s->RxBufAddr, buf, size-wrapped ); } s->RxBufAddr = 0; cpu_physical_memory_write( s->RxBuf + s->RxBufAddr, buf + (size-wrapped), wrapped ); s->RxBufAddr = wrapped; return; } } cpu_physical_memory_write( s->RxBuf + s->RxBufAddr, buf, size ); s->RxBufAddr += size; }
{ "code": [], "line_no": [] }
static void FUNC_0(RTL8139State *VAR_0, const void *VAR_1, int VAR_2) { if (VAR_0->RxBufAddr + VAR_2 > VAR_0->RxBufferSize) { int VAR_3 = MOD2(VAR_0->RxBufAddr + VAR_2, VAR_0->RxBufferSize); if (VAR_3 && VAR_0->RxBufferSize < 65536 && !rtl8139_RxWrap(VAR_0)) { DEBUG_PRINT((">>> RTL8139: rx packet VAR_3 in buffer at %d\n", VAR_2-VAR_3)); if (VAR_2 > VAR_3) { cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr, VAR_1, VAR_2-VAR_3 ); } VAR_0->RxBufAddr = 0; cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr, VAR_1 + (VAR_2-VAR_3), VAR_3 ); VAR_0->RxBufAddr = VAR_3; return; } } cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr, VAR_1, VAR_2 ); VAR_0->RxBufAddr += VAR_2; }
[ "static void FUNC_0(RTL8139State *VAR_0, const void *VAR_1, int VAR_2)\n{", "if (VAR_0->RxBufAddr + VAR_2 > VAR_0->RxBufferSize)\n{", "int VAR_3 = MOD2(VAR_0->RxBufAddr + VAR_2, VAR_0->RxBufferSize);", "if (VAR_3 && VAR_0->RxBufferSize < 65536 && !rtl8139_RxWrap(VAR_0))\n{", "DEBUG_PRINT((\">>> RTL8139: rx packet VAR_3 in buffer at %d\\n\", VAR_2-VAR_3));", "if (VAR_2 > VAR_3)\n{", "cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr,\nVAR_1, VAR_2-VAR_3 );", "}", "VAR_0->RxBufAddr = 0;", "cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr,\nVAR_1 + (VAR_2-VAR_3), VAR_3 );", "VAR_0->RxBufAddr = VAR_3;", "return;", "}", "}", "cpu_physical_memory_write( VAR_0->RxBuf + VAR_0->RxBufAddr, VAR_1, VAR_2 );", "VAR_0->RxBufAddr += VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9 ], [ 15, 17 ], [ 19 ], [ 23, 25 ], [ 27, 29 ], [ 31 ], [ 37 ], [ 41, 43 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 61 ], [ 65 ], [ 67 ] ]
496
int ppc_hash32_handle_mmu_fault(CPUPPCState *env, target_ulong address, int rw, int mmu_idx) { struct mmu_ctx_hash32 ctx; int access_type; int ret = 0; if (rw == 2) { /* code access */ rw = 0; access_type = ACCESS_CODE; } else { /* data access */ access_type = env->access_type; } ret = ppc_hash32_get_physical_address(env, &ctx, address, rw, access_type); if (ret == 0) { tlb_set_page(env, address & TARGET_PAGE_MASK, ctx.raddr & TARGET_PAGE_MASK, ctx.prot, mmu_idx, TARGET_PAGE_SIZE); ret = 0; } else if (ret < 0) { LOG_MMU_STATE(env); if (access_type == ACCESS_CODE) { switch (ret) { case -1: /* No matches in page tables or TLB */ env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x40000000; break; case -2: /* Access rights violation */ env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x08000000; break; case -3: /* No execute protection violation */ env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; case -4: /* Direct store exception */ /* No code fetch is allowed in direct-store areas */ env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; } } else { switch (ret) { case -1: /* No matches in page tables or TLB */ env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) { env->spr[SPR_DSISR] = 0x42000000; } else { env->spr[SPR_DSISR] = 0x40000000; } break; case -2: /* Access rights violation */ env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) { env->spr[SPR_DSISR] = 0x0A000000; } else { env->spr[SPR_DSISR] = 0x08000000; } break; case -4: /* Direct store exception */ switch (access_type) { case ACCESS_FLOAT: /* Floating point load/store */ env->exception_index = POWERPC_EXCP_ALIGN; env->error_code = POWERPC_EXCP_ALIGN_FP; env->spr[SPR_DAR] = address; break; case ACCESS_RES: /* lwarx, ldarx or stwcx. */ env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) { env->spr[SPR_DSISR] = 0x06000000; } else { env->spr[SPR_DSISR] = 0x04000000; } break; case ACCESS_EXT: /* eciwx or ecowx */ env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) { env->spr[SPR_DSISR] = 0x06100000; } else { env->spr[SPR_DSISR] = 0x04100000; } break; default: printf("DSI: invalid exception (%d)\n", ret); env->exception_index = POWERPC_EXCP_PROGRAM; env->error_code = POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; env->spr[SPR_DAR] = address; break; } break; } } #if 0 printf("%s: set exception to %d %02x\n", __func__, env->exception, env->error_code); #endif ret = 1; } return ret; }
false
qemu
91cda45b69e45a089f9989979a65db3f710c9925
int ppc_hash32_handle_mmu_fault(CPUPPCState *env, target_ulong address, int rw, int mmu_idx) { struct mmu_ctx_hash32 ctx; int access_type; int ret = 0; if (rw == 2) { rw = 0; access_type = ACCESS_CODE; } else { access_type = env->access_type; } ret = ppc_hash32_get_physical_address(env, &ctx, address, rw, access_type); if (ret == 0) { tlb_set_page(env, address & TARGET_PAGE_MASK, ctx.raddr & TARGET_PAGE_MASK, ctx.prot, mmu_idx, TARGET_PAGE_SIZE); ret = 0; } else if (ret < 0) { LOG_MMU_STATE(env); if (access_type == ACCESS_CODE) { switch (ret) { case -1: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x40000000; break; case -2: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x08000000; break; case -3: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; case -4: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; } } else { switch (ret) { case -1: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) { env->spr[SPR_DSISR] = 0x42000000; } else { env->spr[SPR_DSISR] = 0x40000000; } break; case -2: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) { env->spr[SPR_DSISR] = 0x0A000000; } else { env->spr[SPR_DSISR] = 0x08000000; } break; case -4: switch (access_type) { case ACCESS_FLOAT: env->exception_index = POWERPC_EXCP_ALIGN; env->error_code = POWERPC_EXCP_ALIGN_FP; env->spr[SPR_DAR] = address; break; case ACCESS_RES: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) { env->spr[SPR_DSISR] = 0x06000000; } else { env->spr[SPR_DSISR] = 0x04000000; } break; case ACCESS_EXT: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) { env->spr[SPR_DSISR] = 0x06100000; } else { env->spr[SPR_DSISR] = 0x04100000; } break; default: printf("DSI: invalid exception (%d)\n", ret); env->exception_index = POWERPC_EXCP_PROGRAM; env->error_code = POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; env->spr[SPR_DAR] = address; break; } break; } } #if 0 printf("%s: set exception to %d %02x\n", __func__, env->exception, env->error_code); #endif ret = 1; } return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1, int VAR_2, int VAR_3) { struct mmu_ctx_hash32 VAR_4; int VAR_5; int VAR_6 = 0; if (VAR_2 == 2) { VAR_2 = 0; VAR_5 = ACCESS_CODE; } else { VAR_5 = VAR_0->VAR_5; } VAR_6 = ppc_hash32_get_physical_address(VAR_0, &VAR_4, VAR_1, VAR_2, VAR_5); if (VAR_6 == 0) { tlb_set_page(VAR_0, VAR_1 & TARGET_PAGE_MASK, VAR_4.raddr & TARGET_PAGE_MASK, VAR_4.prot, VAR_3, TARGET_PAGE_SIZE); VAR_6 = 0; } else if (VAR_6 < 0) { LOG_MMU_STATE(VAR_0); if (VAR_5 == ACCESS_CODE) { switch (VAR_6) { case -1: VAR_0->exception_index = POWERPC_EXCP_ISI; VAR_0->error_code = 0x40000000; break; case -2: VAR_0->exception_index = POWERPC_EXCP_ISI; VAR_0->error_code = 0x08000000; break; case -3: VAR_0->exception_index = POWERPC_EXCP_ISI; VAR_0->error_code = 0x10000000; break; case -4: VAR_0->exception_index = POWERPC_EXCP_ISI; VAR_0->error_code = 0x10000000; break; } } else { switch (VAR_6) { case -1: VAR_0->exception_index = POWERPC_EXCP_DSI; VAR_0->error_code = 0; VAR_0->spr[SPR_DAR] = VAR_1; if (VAR_2 == 1) { VAR_0->spr[SPR_DSISR] = 0x42000000; } else { VAR_0->spr[SPR_DSISR] = 0x40000000; } break; case -2: VAR_0->exception_index = POWERPC_EXCP_DSI; VAR_0->error_code = 0; VAR_0->spr[SPR_DAR] = VAR_1; if (VAR_2 == 1) { VAR_0->spr[SPR_DSISR] = 0x0A000000; } else { VAR_0->spr[SPR_DSISR] = 0x08000000; } break; case -4: switch (VAR_5) { case ACCESS_FLOAT: VAR_0->exception_index = POWERPC_EXCP_ALIGN; VAR_0->error_code = POWERPC_EXCP_ALIGN_FP; VAR_0->spr[SPR_DAR] = VAR_1; break; case ACCESS_RES: VAR_0->exception_index = POWERPC_EXCP_DSI; VAR_0->error_code = 0; VAR_0->spr[SPR_DAR] = VAR_1; if (VAR_2 == 1) { VAR_0->spr[SPR_DSISR] = 0x06000000; } else { VAR_0->spr[SPR_DSISR] = 0x04000000; } break; case ACCESS_EXT: VAR_0->exception_index = POWERPC_EXCP_DSI; VAR_0->error_code = 0; VAR_0->spr[SPR_DAR] = VAR_1; if (VAR_2 == 1) { VAR_0->spr[SPR_DSISR] = 0x06100000; } else { VAR_0->spr[SPR_DSISR] = 0x04100000; } break; default: printf("DSI: invalid exception (%d)\n", VAR_6); VAR_0->exception_index = POWERPC_EXCP_PROGRAM; VAR_0->error_code = POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; VAR_0->spr[SPR_DAR] = VAR_1; break; } break; } } #if 0 printf("%s: set exception to %d %02x\n", __func__, VAR_0->exception, VAR_0->error_code); #endif VAR_6 = 1; } return VAR_6; }
[ "int FUNC_0(CPUPPCState *VAR_0, target_ulong VAR_1, int VAR_2,\nint VAR_3)\n{", "struct mmu_ctx_hash32 VAR_4;", "int VAR_5;", "int VAR_6 = 0;", "if (VAR_2 == 2) {", "VAR_2 = 0;", "VAR_5 = ACCESS_CODE;", "} else {", "VAR_5 = VAR_0->VAR_5;", "}", "VAR_6 = ppc_hash32_get_physical_address(VAR_0, &VAR_4, VAR_1, VAR_2, VAR_5);", "if (VAR_6 == 0) {", "tlb_set_page(VAR_0, VAR_1 & TARGET_PAGE_MASK,\nVAR_4.raddr & TARGET_PAGE_MASK, VAR_4.prot,\nVAR_3, TARGET_PAGE_SIZE);", "VAR_6 = 0;", "} else if (VAR_6 < 0) {", "LOG_MMU_STATE(VAR_0);", "if (VAR_5 == ACCESS_CODE) {", "switch (VAR_6) {", "case -1:\nVAR_0->exception_index = POWERPC_EXCP_ISI;", "VAR_0->error_code = 0x40000000;", "break;", "case -2:\nVAR_0->exception_index = POWERPC_EXCP_ISI;", "VAR_0->error_code = 0x08000000;", "break;", "case -3:\nVAR_0->exception_index = POWERPC_EXCP_ISI;", "VAR_0->error_code = 0x10000000;", "break;", "case -4:\nVAR_0->exception_index = POWERPC_EXCP_ISI;", "VAR_0->error_code = 0x10000000;", "break;", "}", "} else {", "switch (VAR_6) {", "case -1:\nVAR_0->exception_index = POWERPC_EXCP_DSI;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_DAR] = VAR_1;", "if (VAR_2 == 1) {", "VAR_0->spr[SPR_DSISR] = 0x42000000;", "} else {", "VAR_0->spr[SPR_DSISR] = 0x40000000;", "}", "break;", "case -2:\nVAR_0->exception_index = POWERPC_EXCP_DSI;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_DAR] = VAR_1;", "if (VAR_2 == 1) {", "VAR_0->spr[SPR_DSISR] = 0x0A000000;", "} else {", "VAR_0->spr[SPR_DSISR] = 0x08000000;", "}", "break;", "case -4:\nswitch (VAR_5) {", "case ACCESS_FLOAT:\nVAR_0->exception_index = POWERPC_EXCP_ALIGN;", "VAR_0->error_code = POWERPC_EXCP_ALIGN_FP;", "VAR_0->spr[SPR_DAR] = VAR_1;", "break;", "case ACCESS_RES:\nVAR_0->exception_index = POWERPC_EXCP_DSI;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_DAR] = VAR_1;", "if (VAR_2 == 1) {", "VAR_0->spr[SPR_DSISR] = 0x06000000;", "} else {", "VAR_0->spr[SPR_DSISR] = 0x04000000;", "}", "break;", "case ACCESS_EXT:\nVAR_0->exception_index = POWERPC_EXCP_DSI;", "VAR_0->error_code = 0;", "VAR_0->spr[SPR_DAR] = VAR_1;", "if (VAR_2 == 1) {", "VAR_0->spr[SPR_DSISR] = 0x06100000;", "} else {", "VAR_0->spr[SPR_DSISR] = 0x04100000;", "}", "break;", "default:\nprintf(\"DSI: invalid exception (%d)\\n\", VAR_6);", "VAR_0->exception_index = POWERPC_EXCP_PROGRAM;", "VAR_0->error_code =\nPOWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL;", "VAR_0->spr[SPR_DAR] = VAR_1;", "break;", "}", "break;", "}", "}", "#if 0\nprintf(\"%s: set exception to %d %02x\\n\", __func__,\nVAR_0->exception, VAR_0->error_code);", "#endif\nVAR_6 = 1;", "}", "return VAR_6;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35, 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51, 55 ], [ 57 ], [ 59 ], [ 61, 65 ], [ 67 ], [ 69 ], [ 71, 75 ], [ 77 ], [ 79 ], [ 81, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121, 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143, 147 ], [ 149, 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161, 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183, 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205, 207 ], [ 209 ], [ 211, 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227, 229, 231 ], [ 233, 235 ], [ 237 ], [ 241 ], [ 243 ] ]