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
20,123
int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) { int ret; FILE *f = fopen(filename, "rb"); if (!f) { av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, strerror(errno)); return AVERROR(errno); } fseek(f, 0, SEEK_END); *size = ftell(f); fseek(f, 0, SEEK_SET); *bufptr = av_malloc(*size + 1); if (!*bufptr) { av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n"); fclose(f); return AVERROR(ENOMEM); } ret = fread(*bufptr, 1, *size, f); if (ret < *size) { av_free(*bufptr); if (ferror(f)) { av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n", filename, strerror(errno)); ret = AVERROR(errno); } else ret = AVERROR_EOF; } else { ret = 0; (*bufptr)[(*size)++] = '\0'; } fclose(f); return ret; }
false
FFmpeg
38129c26c51b933d7db423f904ba0cd6a88ca1ed
int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) { int ret; FILE *f = fopen(filename, "rb"); if (!f) { av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename, strerror(errno)); return AVERROR(errno); } fseek(f, 0, SEEK_END); *size = ftell(f); fseek(f, 0, SEEK_SET); *bufptr = av_malloc(*size + 1); if (!*bufptr) { av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n"); fclose(f); return AVERROR(ENOMEM); } ret = fread(*bufptr, 1, *size, f); if (ret < *size) { av_free(*bufptr); if (ferror(f)) { av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n", filename, strerror(errno)); ret = AVERROR(errno); } else ret = AVERROR_EOF; } else { ret = 0; (*bufptr)[(*size)++] = '\0'; } fclose(f); return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(const char *VAR_0, char **VAR_1, size_t *VAR_2) { int VAR_3; FILE *f = fopen(VAR_0, "rb"); if (!f) { av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", VAR_0, strerror(errno)); return AVERROR(errno); } fseek(f, 0, SEEK_END); *VAR_2 = ftell(f); fseek(f, 0, SEEK_SET); *VAR_1 = av_malloc(*VAR_2 + 1); if (!*VAR_1) { av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n"); fclose(f); return AVERROR(ENOMEM); } VAR_3 = fread(*VAR_1, 1, *VAR_2, f); if (VAR_3 < *VAR_2) { av_free(*VAR_1); if (ferror(f)) { av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n", VAR_0, strerror(errno)); VAR_3 = AVERROR(errno); } else VAR_3 = AVERROR_EOF; } else { VAR_3 = 0; (*VAR_1)[(*VAR_2)++] = '\0'; } fclose(f); return VAR_3; }
[ "int FUNC_0(const char *VAR_0, char **VAR_1, size_t *VAR_2)\n{", "int VAR_3;", "FILE *f = fopen(VAR_0, \"rb\");", "if (!f) {", "av_log(NULL, AV_LOG_ERROR, \"Cannot read file '%s': %s\\n\", VAR_0,\nstrerror(errno));", "return AVERROR(errno);", "}", "fseek(f, 0, SEEK_END);", "*VAR_2 = ftell(f);", "fseek(f, 0, SEEK_SET);", "*VAR_1 = av_malloc(*VAR_2 + 1);", "if (!*VAR_1) {", "av_log(NULL, AV_LOG_ERROR, \"Could not allocate file buffer\\n\");", "fclose(f);", "return AVERROR(ENOMEM);", "}", "VAR_3 = fread(*VAR_1, 1, *VAR_2, f);", "if (VAR_3 < *VAR_2) {", "av_free(*VAR_1);", "if (ferror(f)) {", "av_log(NULL, AV_LOG_ERROR, \"Error while reading file '%s': %s\\n\",\nVAR_0, strerror(errno));", "VAR_3 = AVERROR(errno);", "} else", "VAR_3 = AVERROR_EOF;", "} else {", "VAR_3 = 0;", "(*VAR_1)[(*VAR_2)++] = '\\0';", "}", "fclose(f);", "return 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 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 ], [ 67 ], [ 69 ], [ 71 ] ]
20,124
static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, int level, int *dir_ptr, int encoding) { int a, b, c, wrap, pred, scale, ret; int16_t *dc_val; /* find prediction */ if (n < 4) { scale = s->y_dc_scale; } else { scale = s->c_dc_scale; } if(IS_3IV1) scale= 8; wrap= s->block_wrap[n]; dc_val = s->dc_val[0] + s->block_index[n]; /* B C * A X */ a = dc_val[ - 1]; b = dc_val[ - 1 - wrap]; c = dc_val[ - wrap]; /* outside slice handling (we can't do that by memset as we need the dc for error resilience) */ if(s->first_slice_line && n!=3){ if(n!=2) b=c= 1024; if(n!=1 && s->mb_x == s->resync_mb_x) b=a= 1024; } if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1){ if(n==0 || n==4 || n==5) b=1024; } if (abs(a - b) < abs(b - c)) { pred = c; *dir_ptr = 1; /* top */ } else { pred = a; *dir_ptr = 0; /* left */ } /* we assume pred is positive */ pred = FASTDIV((pred + (scale >> 1)), scale); if(encoding){ ret = level - pred; }else{ level += pred; ret= level; if(s->error_recognition>=3){ if(level<0){ av_log(s->avctx, AV_LOG_ERROR, "dc<0 at %dx%d\n", s->mb_x, s->mb_y); return -1; } if(level*scale > 2048 + scale){ av_log(s->avctx, AV_LOG_ERROR, "dc overflow at %dx%d\n", s->mb_x, s->mb_y); return -1; } } } level *=scale; if(level&(~2047)){ if(level<0) level=0; else if(!(s->workaround_bugs&FF_BUG_DC_CLIP)) level=2047; } dc_val[0]= level; return ret; }
false
FFmpeg
df8d98c4dd0853d92a16b1715d4e8abf19feabd8
static inline int ff_mpeg4_pred_dc(MpegEncContext * s, int n, int level, int *dir_ptr, int encoding) { int a, b, c, wrap, pred, scale, ret; int16_t *dc_val; if (n < 4) { scale = s->y_dc_scale; } else { scale = s->c_dc_scale; } if(IS_3IV1) scale= 8; wrap= s->block_wrap[n]; dc_val = s->dc_val[0] + s->block_index[n]; a = dc_val[ - 1]; b = dc_val[ - 1 - wrap]; c = dc_val[ - wrap]; if(s->first_slice_line && n!=3){ if(n!=2) b=c= 1024; if(n!=1 && s->mb_x == s->resync_mb_x) b=a= 1024; } if(s->mb_x == s->resync_mb_x && s->mb_y == s->resync_mb_y+1){ if(n==0 || n==4 || n==5) b=1024; } if (abs(a - b) < abs(b - c)) { pred = c; *dir_ptr = 1; } else { pred = a; *dir_ptr = 0; } pred = FASTDIV((pred + (scale >> 1)), scale); if(encoding){ ret = level - pred; }else{ level += pred; ret= level; if(s->error_recognition>=3){ if(level<0){ av_log(s->avctx, AV_LOG_ERROR, "dc<0 at %dx%d\n", s->mb_x, s->mb_y); return -1; } if(level*scale > 2048 + scale){ av_log(s->avctx, AV_LOG_ERROR, "dc overflow at %dx%d\n", s->mb_x, s->mb_y); return -1; } } } level *=scale; if(level&(~2047)){ if(level<0) level=0; else if(!(s->workaround_bugs&FF_BUG_DC_CLIP)) level=2047; } dc_val[0]= level; return ret; }
{ "code": [], "line_no": [] }
static inline int FUNC_0(MpegEncContext * VAR_0, int VAR_1, int VAR_2, int *VAR_3, int VAR_4) { int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11; int16_t *dc_val; if (VAR_1 < 4) { VAR_10 = VAR_0->y_dc_scale; } else { VAR_10 = VAR_0->c_dc_scale; } if(IS_3IV1) VAR_10= 8; VAR_8= VAR_0->block_wrap[VAR_1]; dc_val = VAR_0->dc_val[0] + VAR_0->block_index[VAR_1]; VAR_5 = dc_val[ - 1]; VAR_6 = dc_val[ - 1 - VAR_8]; VAR_7 = dc_val[ - VAR_8]; if(VAR_0->first_slice_line && VAR_1!=3){ if(VAR_1!=2) VAR_6=VAR_7= 1024; if(VAR_1!=1 && VAR_0->mb_x == VAR_0->resync_mb_x) VAR_6=VAR_5= 1024; } if(VAR_0->mb_x == VAR_0->resync_mb_x && VAR_0->mb_y == VAR_0->resync_mb_y+1){ if(VAR_1==0 || VAR_1==4 || VAR_1==5) VAR_6=1024; } if (abs(VAR_5 - VAR_6) < abs(VAR_6 - VAR_7)) { VAR_9 = VAR_7; *VAR_3 = 1; } else { VAR_9 = VAR_5; *VAR_3 = 0; } VAR_9 = FASTDIV((VAR_9 + (VAR_10 >> 1)), VAR_10); if(VAR_4){ VAR_11 = VAR_2 - VAR_9; }else{ VAR_2 += VAR_9; VAR_11= VAR_2; if(VAR_0->error_recognition>=3){ if(VAR_2<0){ av_log(VAR_0->avctx, AV_LOG_ERROR, "dc<0 at %dx%d\VAR_1", VAR_0->mb_x, VAR_0->mb_y); return -1; } if(VAR_2*VAR_10 > 2048 + VAR_10){ av_log(VAR_0->avctx, AV_LOG_ERROR, "dc overflow at %dx%d\VAR_1", VAR_0->mb_x, VAR_0->mb_y); return -1; } } } VAR_2 *=VAR_10; if(VAR_2&(~2047)){ if(VAR_2<0) VAR_2=0; else if(!(VAR_0->workaround_bugs&FF_BUG_DC_CLIP)) VAR_2=2047; } dc_val[0]= VAR_2; return VAR_11; }
[ "static inline int FUNC_0(MpegEncContext * VAR_0, int VAR_1, int VAR_2, int *VAR_3, int VAR_4)\n{", "int VAR_5, VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11;", "int16_t *dc_val;", "if (VAR_1 < 4) {", "VAR_10 = VAR_0->y_dc_scale;", "} else {", "VAR_10 = VAR_0->c_dc_scale;", "}", "if(IS_3IV1)\nVAR_10= 8;", "VAR_8= VAR_0->block_wrap[VAR_1];", "dc_val = VAR_0->dc_val[0] + VAR_0->block_index[VAR_1];", "VAR_5 = dc_val[ - 1];", "VAR_6 = dc_val[ - 1 - VAR_8];", "VAR_7 = dc_val[ - VAR_8];", "if(VAR_0->first_slice_line && VAR_1!=3){", "if(VAR_1!=2) VAR_6=VAR_7= 1024;", "if(VAR_1!=1 && VAR_0->mb_x == VAR_0->resync_mb_x) VAR_6=VAR_5= 1024;", "}", "if(VAR_0->mb_x == VAR_0->resync_mb_x && VAR_0->mb_y == VAR_0->resync_mb_y+1){", "if(VAR_1==0 || VAR_1==4 || VAR_1==5)\nVAR_6=1024;", "}", "if (abs(VAR_5 - VAR_6) < abs(VAR_6 - VAR_7)) {", "VAR_9 = VAR_7;", "*VAR_3 = 1;", "} else {", "VAR_9 = VAR_5;", "*VAR_3 = 0;", "}", "VAR_9 = FASTDIV((VAR_9 + (VAR_10 >> 1)), VAR_10);", "if(VAR_4){", "VAR_11 = VAR_2 - VAR_9;", "}else{", "VAR_2 += VAR_9;", "VAR_11= VAR_2;", "if(VAR_0->error_recognition>=3){", "if(VAR_2<0){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"dc<0 at %dx%d\\VAR_1\", VAR_0->mb_x, VAR_0->mb_y);", "return -1;", "}", "if(VAR_2*VAR_10 > 2048 + VAR_10){", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"dc overflow at %dx%d\\VAR_1\", VAR_0->mb_x, VAR_0->mb_y);", "return -1;", "}", "}", "}", "VAR_2 *=VAR_10;", "if(VAR_2&(~2047)){", "if(VAR_2<0)\nVAR_2=0;", "else if(!(VAR_0->workaround_bugs&FF_BUG_DC_CLIP))\nVAR_2=2047;", "}", "dc_val[0]= VAR_2;", "return VAR_11;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 29 ], [ 31 ], [ 41 ], [ 43 ], [ 45 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125, 127 ], [ 129, 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ] ]
20,125
void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]) { const uint32_t broadcast_addr = ~slirp->vnetwork_mask.s_addr | slirp->vnetwork_addr.s_addr; ArpTable *arptbl = &slirp->arp_table; int i; DEBUG_CALL("arp_table_add"); DEBUG_ARG("ip = 0x%x", ip_addr); DEBUG_ARGS((dfd, " hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n", ethaddr[0], ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5])); /* Check 0.0.0.0/8 invalid source-only addresses */ assert((ip_addr & htonl(~(0xf << 28))) != 0); if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) { /* Do not register broadcast addresses */ return; } /* Search for an entry */ for (i = 0; i < ARP_TABLE_SIZE; i++) { if (arptbl->table[i].ar_sip == ip_addr) { /* Update the entry */ memcpy(arptbl->table[i].ar_sha, ethaddr, ETH_ALEN); return; } } /* No entry found, create a new one */ arptbl->table[arptbl->next_victim].ar_sip = ip_addr; memcpy(arptbl->table[arptbl->next_victim].ar_sha, ethaddr, ETH_ALEN); arptbl->next_victim = (arptbl->next_victim + 1) % ARP_TABLE_SIZE; }
true
qemu
1a89b60885ccc2abf7cc50275fcee70d0347425e
void arp_table_add(Slirp *slirp, uint32_t ip_addr, uint8_t ethaddr[ETH_ALEN]) { const uint32_t broadcast_addr = ~slirp->vnetwork_mask.s_addr | slirp->vnetwork_addr.s_addr; ArpTable *arptbl = &slirp->arp_table; int i; DEBUG_CALL("arp_table_add"); DEBUG_ARG("ip = 0x%x", ip_addr); DEBUG_ARGS((dfd, " hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n", ethaddr[0], ethaddr[1], ethaddr[2], ethaddr[3], ethaddr[4], ethaddr[5])); assert((ip_addr & htonl(~(0xf << 28))) != 0); if (ip_addr == 0xffffffff || ip_addr == broadcast_addr) { return; } for (i = 0; i < ARP_TABLE_SIZE; i++) { if (arptbl->table[i].ar_sip == ip_addr) { memcpy(arptbl->table[i].ar_sha, ethaddr, ETH_ALEN); return; } } arptbl->table[arptbl->next_victim].ar_sip = ip_addr; memcpy(arptbl->table[arptbl->next_victim].ar_sha, ethaddr, ETH_ALEN); arptbl->next_victim = (arptbl->next_victim + 1) % ARP_TABLE_SIZE; }
{ "code": [ " assert((ip_addr & htonl(~(0xf << 28))) != 0);" ], "line_no": [ 29 ] }
void FUNC_0(Slirp *VAR_0, uint32_t VAR_1, uint8_t VAR_2[ETH_ALEN]) { const uint32_t VAR_3 = ~VAR_0->vnetwork_mask.s_addr | VAR_0->vnetwork_addr.s_addr; ArpTable *arptbl = &VAR_0->arp_table; int VAR_4; DEBUG_CALL("FUNC_0"); DEBUG_ARG("ip = 0x%x", VAR_1); DEBUG_ARGS((dfd, " hw addr = %02x:%02x:%02x:%02x:%02x:%02x\n", VAR_2[0], VAR_2[1], VAR_2[2], VAR_2[3], VAR_2[4], VAR_2[5])); assert((VAR_1 & htonl(~(0xf << 28))) != 0); if (VAR_1 == 0xffffffff || VAR_1 == VAR_3) { return; } for (VAR_4 = 0; VAR_4 < ARP_TABLE_SIZE; VAR_4++) { if (arptbl->table[VAR_4].ar_sip == VAR_1) { memcpy(arptbl->table[VAR_4].ar_sha, VAR_2, ETH_ALEN); return; } } arptbl->table[arptbl->next_victim].ar_sip = VAR_1; memcpy(arptbl->table[arptbl->next_victim].ar_sha, VAR_2, ETH_ALEN); arptbl->next_victim = (arptbl->next_victim + 1) % ARP_TABLE_SIZE; }
[ "void FUNC_0(Slirp *VAR_0, uint32_t VAR_1, uint8_t VAR_2[ETH_ALEN])\n{", "const uint32_t VAR_3 =\n~VAR_0->vnetwork_mask.s_addr | VAR_0->vnetwork_addr.s_addr;", "ArpTable *arptbl = &VAR_0->arp_table;", "int VAR_4;", "DEBUG_CALL(\"FUNC_0\");", "DEBUG_ARG(\"ip = 0x%x\", VAR_1);", "DEBUG_ARGS((dfd, \" hw addr = %02x:%02x:%02x:%02x:%02x:%02x\\n\",\nVAR_2[0], VAR_2[1], VAR_2[2],\nVAR_2[3], VAR_2[4], VAR_2[5]));", "assert((VAR_1 & htonl(~(0xf << 28))) != 0);", "if (VAR_1 == 0xffffffff || VAR_1 == VAR_3) {", "return;", "}", "for (VAR_4 = 0; VAR_4 < ARP_TABLE_SIZE; VAR_4++) {", "if (arptbl->table[VAR_4].ar_sip == VAR_1) {", "memcpy(arptbl->table[VAR_4].ar_sha, VAR_2, ETH_ALEN);", "return;", "}", "}", "arptbl->table[arptbl->next_victim].ar_sip = VAR_1;", "memcpy(arptbl->table[arptbl->next_victim].ar_sha, VAR_2, ETH_ALEN);", "arptbl->next_victim = (arptbl->next_victim + 1) % ARP_TABLE_SIZE;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19, 21, 23 ], [ 29 ], [ 33 ], [ 37 ], [ 39 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ] ]
20,126
static void encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *parent, int stride, int orientation){ const int w= b->width; const int h= b->height; int x, y; if(1){ int run=0; int runs[w*h]; int run_index=0; for(y=0; y<h; y++){ for(x=0; x<w; x++){ int v, p=0; int /*ll=0, */l=0, lt=0, t=0, rt=0; v= src[x + y*stride]; if(y){ t= src[x + (y-1)*stride]; if(x){ lt= src[x - 1 + (y-1)*stride]; } if(x + 1 < w){ rt= src[x + 1 + (y-1)*stride]; } } if(x){ l= src[x - 1 + y*stride]; /*if(x > 1){ if(orientation==1) ll= src[y + (x-2)*stride]; else ll= src[x - 2 + y*stride]; }*/ } if(parent){ int px= x>>1; int py= y>>1; if(px<b->parent->width && py<b->parent->height) p= parent[px + py*2*stride]; } if(!(/*ll|*/l|lt|t|rt|p)){ if(v){ runs[run_index++]= run; run=0; }else{ run++; } } } } runs[run_index++]= run; run_index=0; run= runs[run_index++]; put_symbol2(&s->c, b->state[1], run, 3); for(y=0; y<h; y++){ for(x=0; x<w; x++){ int v, p=0; int /*ll=0, */l=0, lt=0, t=0, rt=0; v= src[x + y*stride]; if(y){ t= src[x + (y-1)*stride]; if(x){ lt= src[x - 1 + (y-1)*stride]; } if(x + 1 < w){ rt= src[x + 1 + (y-1)*stride]; } } if(x){ l= src[x - 1 + y*stride]; /*if(x > 1){ if(orientation==1) ll= src[y + (x-2)*stride]; else ll= src[x - 2 + y*stride]; }*/ } if(parent){ int px= x>>1; int py= y>>1; if(px<b->parent->width && py<b->parent->height) p= parent[px + py*2*stride]; } if(/*ll|*/l|lt|t|rt|p){ int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); put_rac(&s->c, &b->state[0][context], !!v); }else{ if(!run){ run= runs[run_index++]; put_symbol2(&s->c, b->state[1], run, 3); assert(v); }else{ run--; assert(!v); } } if(v){ int context= av_log2(/*ABS(ll) + */3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); put_symbol2(&s->c, b->state[context + 2], ABS(v)-1, context-4); put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]], v<0); } } } } }
true
FFmpeg
0ecca7a49f8e254c12a3a1de048d738bfbb614c6
static void encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *parent, int stride, int orientation){ const int w= b->width; const int h= b->height; int x, y; if(1){ int run=0; int runs[w*h]; int run_index=0; for(y=0; y<h; y++){ for(x=0; x<w; x++){ int v, p=0; int l=0, lt=0, t=0, rt=0; v= src[x + y*stride]; if(y){ t= src[x + (y-1)*stride]; if(x){ lt= src[x - 1 + (y-1)*stride]; } if(x + 1 < w){ rt= src[x + 1 + (y-1)*stride]; } } if(x){ l= src[x - 1 + y*stride]; } if(parent){ int px= x>>1; int py= y>>1; if(px<b->parent->width && py<b->parent->height) p= parent[px + py*2*stride]; } if(!(l|lt|t|rt|p)){ if(v){ runs[run_index++]= run; run=0; }else{ run++; } } } } runs[run_index++]= run; run_index=0; run= runs[run_index++]; put_symbol2(&s->c, b->state[1], run, 3); for(y=0; y<h; y++){ for(x=0; x<w; x++){ int v, p=0; int l=0, lt=0, t=0, rt=0; v= src[x + y*stride]; if(y){ t= src[x + (y-1)*stride]; if(x){ lt= src[x - 1 + (y-1)*stride]; } if(x + 1 < w){ rt= src[x + 1 + (y-1)*stride]; } } if(x){ l= src[x - 1 + y*stride]; } if(parent){ int px= x>>1; int py= y>>1; if(px<b->parent->width && py<b->parent->height) p= parent[px + py*2*stride]; } if(l|lt|t|rt|p){ int context= av_log2(3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); put_rac(&s->c, &b->state[0][context], !!v); }else{ if(!run){ run= runs[run_index++]; put_symbol2(&s->c, b->state[1], run, 3); assert(v); }else{ run--; assert(!v); } } if(v){ int context= av_log2(3*ABS(l) + ABS(lt) + 2*ABS(t) + ABS(rt) + ABS(p)); put_symbol2(&s->c, b->state[context + 2], ABS(v)-1, context-4); put_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3b[l&0xFF] + 3*quant3b[t&0xFF]], v<0); } } } } }
{ "code": [ "static void encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *parent, int stride, int orientation){" ], "line_no": [ 1 ] }
static void FUNC_0(SnowContext *VAR_0, SubBand *VAR_1, DWTELEM *VAR_2, DWTELEM *VAR_3, int VAR_4, int VAR_5){ const int VAR_6= VAR_1->width; const int VAR_7= VAR_1->height; int VAR_8, VAR_9; if(1){ int VAR_10=0; int VAR_11[VAR_6*VAR_7]; int VAR_12=0; for(VAR_9=0; VAR_9<VAR_7; VAR_9++){ for(VAR_8=0; VAR_8<VAR_6; VAR_8++){ int VAR_21, VAR_21=0; int VAR_21=0, VAR_21=0, VAR_21=0, VAR_21=0; VAR_21= VAR_2[VAR_8 + VAR_9*VAR_4]; if(VAR_9){ VAR_21= VAR_2[VAR_8 + (VAR_9-1)*VAR_4]; if(VAR_8){ VAR_21= VAR_2[VAR_8 - 1 + (VAR_9-1)*VAR_4]; } if(VAR_8 + 1 < VAR_6){ VAR_21= VAR_2[VAR_8 + 1 + (VAR_9-1)*VAR_4]; } } if(VAR_8){ VAR_21= VAR_2[VAR_8 - 1 + VAR_9*VAR_4]; } if(VAR_3){ int VAR_21= VAR_8>>1; int VAR_21= VAR_9>>1; if(VAR_21<VAR_1->VAR_3->width && VAR_21<VAR_1->VAR_3->height) VAR_21= VAR_3[VAR_21 + VAR_21*2*VAR_4]; } if(!(VAR_21|VAR_21|VAR_21|VAR_21|VAR_21)){ if(VAR_21){ VAR_11[VAR_12++]= VAR_10; VAR_10=0; }else{ VAR_10++; } } } } VAR_11[VAR_12++]= VAR_10; VAR_12=0; VAR_10= VAR_11[VAR_12++]; put_symbol2(&VAR_0->c, VAR_1->state[1], VAR_10, 3); for(VAR_9=0; VAR_9<VAR_7; VAR_9++){ for(VAR_8=0; VAR_8<VAR_6; VAR_8++){ int VAR_21, VAR_21=0; int VAR_21=0, VAR_21=0, VAR_21=0, VAR_21=0; VAR_21= VAR_2[VAR_8 + VAR_9*VAR_4]; if(VAR_9){ VAR_21= VAR_2[VAR_8 + (VAR_9-1)*VAR_4]; if(VAR_8){ VAR_21= VAR_2[VAR_8 - 1 + (VAR_9-1)*VAR_4]; } if(VAR_8 + 1 < VAR_6){ VAR_21= VAR_2[VAR_8 + 1 + (VAR_9-1)*VAR_4]; } } if(VAR_8){ VAR_21= VAR_2[VAR_8 - 1 + VAR_9*VAR_4]; } if(VAR_3){ int VAR_21= VAR_8>>1; int VAR_21= VAR_9>>1; if(VAR_21<VAR_1->VAR_3->width && VAR_21<VAR_1->VAR_3->height) VAR_21= VAR_3[VAR_21 + VAR_21*2*VAR_4]; } if(VAR_21|VAR_21|VAR_21|VAR_21|VAR_21){ int VAR_22= av_log2(3*ABS(VAR_21) + ABS(VAR_21) + 2*ABS(VAR_21) + ABS(VAR_21) + ABS(VAR_21)); put_rac(&VAR_0->c, &VAR_1->state[0][VAR_22], !!VAR_21); }else{ if(!VAR_10){ VAR_10= VAR_11[VAR_12++]; put_symbol2(&VAR_0->c, VAR_1->state[1], VAR_10, 3); assert(VAR_21); }else{ VAR_10--; assert(!VAR_21); } } if(VAR_21){ int VAR_22= av_log2(3*ABS(VAR_21) + ABS(VAR_21) + 2*ABS(VAR_21) + ABS(VAR_21) + ABS(VAR_21)); put_symbol2(&VAR_0->c, VAR_1->state[VAR_22 + 2], ABS(VAR_21)-1, VAR_22-4); put_rac(&VAR_0->c, &VAR_1->state[0][16 + 1 + 3 + quant3b[VAR_21&0xFF] + 3*quant3b[VAR_21&0xFF]], VAR_21<0); } } } } }
[ "static void FUNC_0(SnowContext *VAR_0, SubBand *VAR_1, DWTELEM *VAR_2, DWTELEM *VAR_3, int VAR_4, int VAR_5){", "const int VAR_6= VAR_1->width;", "const int VAR_7= VAR_1->height;", "int VAR_8, VAR_9;", "if(1){", "int VAR_10=0;", "int VAR_11[VAR_6*VAR_7];", "int VAR_12=0;", "for(VAR_9=0; VAR_9<VAR_7; VAR_9++){", "for(VAR_8=0; VAR_8<VAR_6; VAR_8++){", "int VAR_21, VAR_21=0;", "int VAR_21=0, VAR_21=0, VAR_21=0, VAR_21=0;", "VAR_21= VAR_2[VAR_8 + VAR_9*VAR_4];", "if(VAR_9){", "VAR_21= VAR_2[VAR_8 + (VAR_9-1)*VAR_4];", "if(VAR_8){", "VAR_21= VAR_2[VAR_8 - 1 + (VAR_9-1)*VAR_4];", "}", "if(VAR_8 + 1 < VAR_6){", "VAR_21= VAR_2[VAR_8 + 1 + (VAR_9-1)*VAR_4];", "}", "}", "if(VAR_8){", "VAR_21= VAR_2[VAR_8 - 1 + VAR_9*VAR_4];", "}", "if(VAR_3){", "int VAR_21= VAR_8>>1;", "int VAR_21= VAR_9>>1;", "if(VAR_21<VAR_1->VAR_3->width && VAR_21<VAR_1->VAR_3->height)\nVAR_21= VAR_3[VAR_21 + VAR_21*2*VAR_4];", "}", "if(!(VAR_21|VAR_21|VAR_21|VAR_21|VAR_21)){", "if(VAR_21){", "VAR_11[VAR_12++]= VAR_10;", "VAR_10=0;", "}else{", "VAR_10++;", "}", "}", "}", "}", "VAR_11[VAR_12++]= VAR_10;", "VAR_12=0;", "VAR_10= VAR_11[VAR_12++];", "put_symbol2(&VAR_0->c, VAR_1->state[1], VAR_10, 3);", "for(VAR_9=0; VAR_9<VAR_7; VAR_9++){", "for(VAR_8=0; VAR_8<VAR_6; VAR_8++){", "int VAR_21, VAR_21=0;", "int VAR_21=0, VAR_21=0, VAR_21=0, VAR_21=0;", "VAR_21= VAR_2[VAR_8 + VAR_9*VAR_4];", "if(VAR_9){", "VAR_21= VAR_2[VAR_8 + (VAR_9-1)*VAR_4];", "if(VAR_8){", "VAR_21= VAR_2[VAR_8 - 1 + (VAR_9-1)*VAR_4];", "}", "if(VAR_8 + 1 < VAR_6){", "VAR_21= VAR_2[VAR_8 + 1 + (VAR_9-1)*VAR_4];", "}", "}", "if(VAR_8){", "VAR_21= VAR_2[VAR_8 - 1 + VAR_9*VAR_4];", "}", "if(VAR_3){", "int VAR_21= VAR_8>>1;", "int VAR_21= VAR_9>>1;", "if(VAR_21<VAR_1->VAR_3->width && VAR_21<VAR_1->VAR_3->height)\nVAR_21= VAR_3[VAR_21 + VAR_21*2*VAR_4];", "}", "if(VAR_21|VAR_21|VAR_21|VAR_21|VAR_21){", "int VAR_22= av_log2(3*ABS(VAR_21) + ABS(VAR_21) + 2*ABS(VAR_21) + ABS(VAR_21) + ABS(VAR_21));", "put_rac(&VAR_0->c, &VAR_1->state[0][VAR_22], !!VAR_21);", "}else{", "if(!VAR_10){", "VAR_10= VAR_11[VAR_12++];", "put_symbol2(&VAR_0->c, VAR_1->state[1], VAR_10, 3);", "assert(VAR_21);", "}else{", "VAR_10--;", "assert(!VAR_21);", "}", "}", "if(VAR_21){", "int VAR_22= av_log2(3*ABS(VAR_21) + ABS(VAR_21) + 2*ABS(VAR_21) + ABS(VAR_21) + ABS(VAR_21));", "put_symbol2(&VAR_0->c, VAR_1->state[VAR_22 + 2], ABS(VAR_21)-1, VAR_22-4);", "put_rac(&VAR_0->c, &VAR_1->state[0][16 + 1 + 3 + quant3b[VAR_21&0xFF] + 3*quant3b[VAR_21&0xFF]], VAR_21<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, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ] ]
20,127
void do_fctiwz (void) { union { double d; uint64_t i; } p; /* XXX: higher bits are not supposed to be significant. * to make tests easier, return the same as a real PowerPC 750 (aka G3) */ p.i = float64_to_int32_round_to_zero(FT0, &env->fp_status); p.i |= 0xFFF80000ULL << 32; FT0 = p.d; }
true
qemu
d9bce9d99f4656ae0b0127f7472db9067b8f84ab
void do_fctiwz (void) { union { double d; uint64_t i; } p; p.i = float64_to_int32_round_to_zero(FT0, &env->fp_status); p.i |= 0xFFF80000ULL << 32; FT0 = p.d; }
{ "code": [], "line_no": [] }
void FUNC_0 (void) { union { double d; uint64_t i; } VAR_0; VAR_0.i = float64_to_int32_round_to_zero(FT0, &env->fp_status); VAR_0.i |= 0xFFF80000ULL << 32; FT0 = VAR_0.d; }
[ "void FUNC_0 (void)\n{", "union {", "double d;", "uint64_t i;", "} VAR_0;", "VAR_0.i = float64_to_int32_round_to_zero(FT0, &env->fp_status);", "VAR_0.i |= 0xFFF80000ULL << 32;", "FT0 = VAR_0.d;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
20,128
static void bdrv_ioctl_bh_cb(void *opaque) { BdrvIoctlCompletionData *data = opaque; bdrv_co_io_em_complete(data->co, -ENOTSUP); qemu_bh_delete(data->bh); }
true
qemu
c8a9fd80719e63615dac12e3625223fb54aa8430
static void bdrv_ioctl_bh_cb(void *opaque) { BdrvIoctlCompletionData *data = opaque; bdrv_co_io_em_complete(data->co, -ENOTSUP); qemu_bh_delete(data->bh); }
{ "code": [ "static void bdrv_ioctl_bh_cb(void *opaque)", " BdrvIoctlCompletionData *data = opaque;", " bdrv_co_io_em_complete(data->co, -ENOTSUP);", " qemu_bh_delete(data->bh);" ], "line_no": [ 1, 5, 9, 11 ] }
static void FUNC_0(void *VAR_0) { BdrvIoctlCompletionData *data = VAR_0; bdrv_co_io_em_complete(data->co, -ENOTSUP); qemu_bh_delete(data->bh); }
[ "static void FUNC_0(void *VAR_0)\n{", "BdrvIoctlCompletionData *data = VAR_0;", "bdrv_co_io_em_complete(data->co, -ENOTSUP);", "qemu_bh_delete(data->bh);", "}" ]
[ 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ] ]
20,132
static int tcp_write(URLContext *h, const uint8_t *buf, int size) { TCPContext *s = h->priv_data; int ret, size1, fd_max, len; fd_set wfds; struct timeval tv; size1 = size; while (size > 0) { if (url_interrupt_cb()) return AVERROR(EINTR); fd_max = s->fd; FD_ZERO(&wfds); FD_SET(s->fd, &wfds); tv.tv_sec = 0; tv.tv_usec = 100 * 1000; ret = select(fd_max + 1, NULL, &wfds, NULL, &tv); if (ret > 0 && FD_ISSET(s->fd, &wfds)) { len = send(s->fd, buf, size, 0); if (len < 0) { if (ff_neterrno() != FF_NETERROR(EINTR) && ff_neterrno() != FF_NETERROR(EAGAIN)) return ff_neterrno(); continue; } size -= len; buf += len; } else if (ret < 0) { if (ff_neterrno() == FF_NETERROR(EINTR)) continue; return -1; } } return size1 - size; }
false
FFmpeg
d0eb91ad0451cdb6c062b2d4760bfa7f8bb4db6b
static int tcp_write(URLContext *h, const uint8_t *buf, int size) { TCPContext *s = h->priv_data; int ret, size1, fd_max, len; fd_set wfds; struct timeval tv; size1 = size; while (size > 0) { if (url_interrupt_cb()) return AVERROR(EINTR); fd_max = s->fd; FD_ZERO(&wfds); FD_SET(s->fd, &wfds); tv.tv_sec = 0; tv.tv_usec = 100 * 1000; ret = select(fd_max + 1, NULL, &wfds, NULL, &tv); if (ret > 0 && FD_ISSET(s->fd, &wfds)) { len = send(s->fd, buf, size, 0); if (len < 0) { if (ff_neterrno() != FF_NETERROR(EINTR) && ff_neterrno() != FF_NETERROR(EAGAIN)) return ff_neterrno(); continue; } size -= len; buf += len; } else if (ret < 0) { if (ff_neterrno() == FF_NETERROR(EINTR)) continue; return -1; } } return size1 - size; }
{ "code": [], "line_no": [] }
static int FUNC_0(URLContext *VAR_0, const uint8_t *VAR_1, int VAR_2) { TCPContext *s = VAR_0->priv_data; int VAR_3, VAR_4, VAR_5, VAR_6; fd_set wfds; struct timeval VAR_7; VAR_4 = VAR_2; while (VAR_2 > 0) { if (url_interrupt_cb()) return AVERROR(EINTR); VAR_5 = s->fd; FD_ZERO(&wfds); FD_SET(s->fd, &wfds); VAR_7.tv_sec = 0; VAR_7.tv_usec = 100 * 1000; VAR_3 = select(VAR_5 + 1, NULL, &wfds, NULL, &VAR_7); if (VAR_3 > 0 && FD_ISSET(s->fd, &wfds)) { VAR_6 = send(s->fd, VAR_1, VAR_2, 0); if (VAR_6 < 0) { if (ff_neterrno() != FF_NETERROR(EINTR) && ff_neterrno() != FF_NETERROR(EAGAIN)) return ff_neterrno(); continue; } VAR_2 -= VAR_6; VAR_1 += VAR_6; } else if (VAR_3 < 0) { if (ff_neterrno() == FF_NETERROR(EINTR)) continue; return -1; } } return VAR_4 - VAR_2; }
[ "static int FUNC_0(URLContext *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{", "TCPContext *s = VAR_0->priv_data;", "int VAR_3, VAR_4, VAR_5, VAR_6;", "fd_set wfds;", "struct timeval VAR_7;", "VAR_4 = VAR_2;", "while (VAR_2 > 0) {", "if (url_interrupt_cb())\nreturn AVERROR(EINTR);", "VAR_5 = s->fd;", "FD_ZERO(&wfds);", "FD_SET(s->fd, &wfds);", "VAR_7.tv_sec = 0;", "VAR_7.tv_usec = 100 * 1000;", "VAR_3 = select(VAR_5 + 1, NULL, &wfds, NULL, &VAR_7);", "if (VAR_3 > 0 && FD_ISSET(s->fd, &wfds)) {", "VAR_6 = send(s->fd, VAR_1, VAR_2, 0);", "if (VAR_6 < 0) {", "if (ff_neterrno() != FF_NETERROR(EINTR) &&\nff_neterrno() != FF_NETERROR(EAGAIN))\nreturn ff_neterrno();", "continue;", "}", "VAR_2 -= VAR_6;", "VAR_1 += VAR_6;", "} else if (VAR_3 < 0) {", "if (ff_neterrno() == FF_NETERROR(EINTR))\ncontinue;", "return -1;", "}", "}", "return VAR_4 - VAR_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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 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 ] ]
20,133
static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) { int cb_size = 1 << log2_cb_size; HEVCLocalContext *lc = &s->HEVClc; int log2_min_cb_size = s->sps->log2_min_cb_size; int length = cb_size >> 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, y; lc->cu.x = x0; lc->cu.y = y0; lc->cu.rqt_root_cbf = 1; lc->cu.pred_mode = MODE_INTRA; lc->cu.part_mode = PART_2Nx2N; lc->cu.intra_split_flag = 0; lc->cu.pcm_flag = 0; SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; for (x = 0; x < 4; x++) lc->pu.intra_pred_mode[x] = 1; if (s->pps->transquant_bypass_enable_flag) { lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(s); if (lc->cu.cu_transquant_bypass_flag) set_deblocking_bypass(s, x0, y0, log2_cb_size); } else lc->cu.cu_transquant_bypass_flag = 0; if (s->sh.slice_type != I_SLICE) { uint8_t skip_flag = ff_hevc_skip_flag_decode(s, x0, y0, x_cb, y_cb); lc->cu.pred_mode = MODE_SKIP; x = y_cb * min_cb_width + x_cb; for (y = 0; y < length; y++) { memset(&s->skip_flag[x], skip_flag, length); x += min_cb_width; } lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER; } if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) { hls_prediction_unit(s, x0, y0, cb_size, cb_size, log2_cb_size, 0); intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); if (!s->sh.disable_deblocking_filter_flag) ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size, lc->slice_or_tiles_up_boundary, lc->slice_or_tiles_left_boundary); } else { if (s->sh.slice_type != I_SLICE) lc->cu.pred_mode = ff_hevc_pred_mode_decode(s); if (lc->cu.pred_mode != MODE_INTRA || log2_cb_size == s->sps->log2_min_cb_size) { lc->cu.part_mode = ff_hevc_part_mode_decode(s, log2_cb_size); lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN && lc->cu.pred_mode == MODE_INTRA; } if (lc->cu.pred_mode == MODE_INTRA) { if (lc->cu.part_mode == PART_2Nx2N && s->sps->pcm_enabled_flag && log2_cb_size >= s->sps->pcm.log2_min_pcm_cb_size && log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) { lc->cu.pcm_flag = ff_hevc_pcm_flag_decode(s); } if (lc->cu.pcm_flag) { int ret; intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); ret = hls_pcm_sample(s, x0, y0, log2_cb_size); if (s->sps->pcm.loop_filter_disable_flag) set_deblocking_bypass(s, x0, y0, log2_cb_size); if (ret < 0) return ret; } else { intra_prediction_unit(s, x0, y0, log2_cb_size); } } else { intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); switch (lc->cu.part_mode) { case PART_2Nx2N: hls_prediction_unit(s, x0, y0, cb_size, cb_size, log2_cb_size, 0); break; case PART_2NxN: hls_prediction_unit(s, x0, y0, cb_size, cb_size / 2, log2_cb_size, 0); hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1); break; case PART_Nx2N: hls_prediction_unit(s, x0, y0, cb_size / 2, cb_size, log2_cb_size, 0); hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1); break; case PART_2NxnU: hls_prediction_unit(s, x0, y0, cb_size, cb_size / 4, log2_cb_size, 0); hls_prediction_unit(s, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1); break; case PART_2NxnD: hls_prediction_unit(s, x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0); hls_prediction_unit(s, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1); break; case PART_nLx2N: hls_prediction_unit(s, x0, y0, cb_size / 4, cb_size, log2_cb_size, 0); hls_prediction_unit(s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1); break; case PART_nRx2N: hls_prediction_unit(s, x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0); hls_prediction_unit(s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1); break; case PART_NxN: hls_prediction_unit(s, x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0); hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1); hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2); hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3); break; } } if (!lc->cu.pcm_flag) { if (lc->cu.pred_mode != MODE_INTRA && !(lc->cu.part_mode == PART_2Nx2N && lc->pu.merge_flag)) { lc->cu.rqt_root_cbf = ff_hevc_no_residual_syntax_flag_decode(s); } if (lc->cu.rqt_root_cbf) { lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : s->sps->max_transform_hierarchy_depth_inter; hls_transform_tree(s, x0, y0, x0, y0, x0, y0, log2_cb_size, log2_cb_size, 0, 0); } else { if (!s->sh.disable_deblocking_filter_flag) ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size, lc->slice_or_tiles_up_boundary, lc->slice_or_tiles_left_boundary); } } } if (s->pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) ff_hevc_set_qPy(s, x0, y0, x0, y0, log2_cb_size); x = y_cb * min_cb_width + x_cb; for (y = 0; y < length; y++) { memset(&s->qp_y_tab[x], lc->qp_y, length); x += min_cb_width; } set_ct_depth(s, x0, y0, log2_cb_size, lc->ct.depth); return 0; }
false
FFmpeg
e22ebd04bcab7f86548794556c28ecca46d9c2ac
static int hls_coding_unit(HEVCContext *s, int x0, int y0, int log2_cb_size) { int cb_size = 1 << log2_cb_size; HEVCLocalContext *lc = &s->HEVClc; int log2_min_cb_size = s->sps->log2_min_cb_size; int length = cb_size >> 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, y; lc->cu.x = x0; lc->cu.y = y0; lc->cu.rqt_root_cbf = 1; lc->cu.pred_mode = MODE_INTRA; lc->cu.part_mode = PART_2Nx2N; lc->cu.intra_split_flag = 0; lc->cu.pcm_flag = 0; SAMPLE_CTB(s->skip_flag, x_cb, y_cb) = 0; for (x = 0; x < 4; x++) lc->pu.intra_pred_mode[x] = 1; if (s->pps->transquant_bypass_enable_flag) { lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(s); if (lc->cu.cu_transquant_bypass_flag) set_deblocking_bypass(s, x0, y0, log2_cb_size); } else lc->cu.cu_transquant_bypass_flag = 0; if (s->sh.slice_type != I_SLICE) { uint8_t skip_flag = ff_hevc_skip_flag_decode(s, x0, y0, x_cb, y_cb); lc->cu.pred_mode = MODE_SKIP; x = y_cb * min_cb_width + x_cb; for (y = 0; y < length; y++) { memset(&s->skip_flag[x], skip_flag, length); x += min_cb_width; } lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER; } if (SAMPLE_CTB(s->skip_flag, x_cb, y_cb)) { hls_prediction_unit(s, x0, y0, cb_size, cb_size, log2_cb_size, 0); intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); if (!s->sh.disable_deblocking_filter_flag) ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size, lc->slice_or_tiles_up_boundary, lc->slice_or_tiles_left_boundary); } else { if (s->sh.slice_type != I_SLICE) lc->cu.pred_mode = ff_hevc_pred_mode_decode(s); if (lc->cu.pred_mode != MODE_INTRA || log2_cb_size == s->sps->log2_min_cb_size) { lc->cu.part_mode = ff_hevc_part_mode_decode(s, log2_cb_size); lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN && lc->cu.pred_mode == MODE_INTRA; } if (lc->cu.pred_mode == MODE_INTRA) { if (lc->cu.part_mode == PART_2Nx2N && s->sps->pcm_enabled_flag && log2_cb_size >= s->sps->pcm.log2_min_pcm_cb_size && log2_cb_size <= s->sps->pcm.log2_max_pcm_cb_size) { lc->cu.pcm_flag = ff_hevc_pcm_flag_decode(s); } if (lc->cu.pcm_flag) { int ret; intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); ret = hls_pcm_sample(s, x0, y0, log2_cb_size); if (s->sps->pcm.loop_filter_disable_flag) set_deblocking_bypass(s, x0, y0, log2_cb_size); if (ret < 0) return ret; } else { intra_prediction_unit(s, x0, y0, log2_cb_size); } } else { intra_prediction_unit_default_value(s, x0, y0, log2_cb_size); switch (lc->cu.part_mode) { case PART_2Nx2N: hls_prediction_unit(s, x0, y0, cb_size, cb_size, log2_cb_size, 0); break; case PART_2NxN: hls_prediction_unit(s, x0, y0, cb_size, cb_size / 2, log2_cb_size, 0); hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size, cb_size / 2, log2_cb_size, 1); break; case PART_Nx2N: hls_prediction_unit(s, x0, y0, cb_size / 2, cb_size, log2_cb_size, 0); hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size, log2_cb_size, 1); break; case PART_2NxnU: hls_prediction_unit(s, x0, y0, cb_size, cb_size / 4, log2_cb_size, 0); hls_prediction_unit(s, x0, y0 + cb_size / 4, cb_size, cb_size * 3 / 4, log2_cb_size, 1); break; case PART_2NxnD: hls_prediction_unit(s, x0, y0, cb_size, cb_size * 3 / 4, log2_cb_size, 0); hls_prediction_unit(s, x0, y0 + cb_size * 3 / 4, cb_size, cb_size / 4, log2_cb_size, 1); break; case PART_nLx2N: hls_prediction_unit(s, x0, y0, cb_size / 4, cb_size, log2_cb_size, 0); hls_prediction_unit(s, x0 + cb_size / 4, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 1); break; case PART_nRx2N: hls_prediction_unit(s, x0, y0, cb_size * 3 / 4, cb_size, log2_cb_size, 0); hls_prediction_unit(s, x0 + cb_size * 3 / 4, y0, cb_size / 4, cb_size, log2_cb_size, 1); break; case PART_NxN: hls_prediction_unit(s, x0, y0, cb_size / 2, cb_size / 2, log2_cb_size, 0); hls_prediction_unit(s, x0 + cb_size / 2, y0, cb_size / 2, cb_size / 2, log2_cb_size, 1); hls_prediction_unit(s, x0, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 2); hls_prediction_unit(s, x0 + cb_size / 2, y0 + cb_size / 2, cb_size / 2, cb_size / 2, log2_cb_size, 3); break; } } if (!lc->cu.pcm_flag) { if (lc->cu.pred_mode != MODE_INTRA && !(lc->cu.part_mode == PART_2Nx2N && lc->pu.merge_flag)) { lc->cu.rqt_root_cbf = ff_hevc_no_residual_syntax_flag_decode(s); } if (lc->cu.rqt_root_cbf) { lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? s->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : s->sps->max_transform_hierarchy_depth_inter; hls_transform_tree(s, x0, y0, x0, y0, x0, y0, log2_cb_size, log2_cb_size, 0, 0); } else { if (!s->sh.disable_deblocking_filter_flag) ff_hevc_deblocking_boundary_strengths(s, x0, y0, log2_cb_size, lc->slice_or_tiles_up_boundary, lc->slice_or_tiles_left_boundary); } } } if (s->pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) ff_hevc_set_qPy(s, x0, y0, x0, y0, log2_cb_size); x = y_cb * min_cb_width + x_cb; for (y = 0; y < length; y++) { memset(&s->qp_y_tab[x], lc->qp_y, length); x += min_cb_width; } set_ct_depth(s, x0, y0, log2_cb_size, lc->ct.depth); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2, int VAR_3) { int VAR_4 = 1 << VAR_3; HEVCLocalContext *lc = &VAR_0->HEVClc; int VAR_5 = VAR_0->sps->VAR_5; int VAR_6 = VAR_4 >> VAR_5; int VAR_7 = VAR_0->sps->VAR_7; int VAR_8 = VAR_1 >> VAR_5; int VAR_9 = VAR_2 >> VAR_5; int VAR_10, VAR_11; lc->cu.VAR_10 = VAR_1; lc->cu.VAR_11 = VAR_2; lc->cu.rqt_root_cbf = 1; lc->cu.pred_mode = MODE_INTRA; lc->cu.part_mode = PART_2Nx2N; lc->cu.intra_split_flag = 0; lc->cu.pcm_flag = 0; SAMPLE_CTB(VAR_0->skip_flag, VAR_8, VAR_9) = 0; for (VAR_10 = 0; VAR_10 < 4; VAR_10++) lc->pu.intra_pred_mode[VAR_10] = 1; if (VAR_0->pps->transquant_bypass_enable_flag) { lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(VAR_0); if (lc->cu.cu_transquant_bypass_flag) set_deblocking_bypass(VAR_0, VAR_1, VAR_2, VAR_3); } else lc->cu.cu_transquant_bypass_flag = 0; if (VAR_0->sh.slice_type != I_SLICE) { uint8_t skip_flag = ff_hevc_skip_flag_decode(VAR_0, VAR_1, VAR_2, VAR_8, VAR_9); lc->cu.pred_mode = MODE_SKIP; VAR_10 = VAR_9 * VAR_7 + VAR_8; for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) { memset(&VAR_0->skip_flag[VAR_10], skip_flag, VAR_6); VAR_10 += VAR_7; } lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER; } if (SAMPLE_CTB(VAR_0->skip_flag, VAR_8, VAR_9)) { hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4, VAR_3, 0); intra_prediction_unit_default_value(VAR_0, VAR_1, VAR_2, VAR_3); if (!VAR_0->sh.disable_deblocking_filter_flag) ff_hevc_deblocking_boundary_strengths(VAR_0, VAR_1, VAR_2, VAR_3, lc->slice_or_tiles_up_boundary, lc->slice_or_tiles_left_boundary); } else { if (VAR_0->sh.slice_type != I_SLICE) lc->cu.pred_mode = ff_hevc_pred_mode_decode(VAR_0); if (lc->cu.pred_mode != MODE_INTRA || VAR_3 == VAR_0->sps->VAR_5) { lc->cu.part_mode = ff_hevc_part_mode_decode(VAR_0, VAR_3); lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN && lc->cu.pred_mode == MODE_INTRA; } if (lc->cu.pred_mode == MODE_INTRA) { if (lc->cu.part_mode == PART_2Nx2N && VAR_0->sps->pcm_enabled_flag && VAR_3 >= VAR_0->sps->pcm.log2_min_pcm_cb_size && VAR_3 <= VAR_0->sps->pcm.log2_max_pcm_cb_size) { lc->cu.pcm_flag = ff_hevc_pcm_flag_decode(VAR_0); } if (lc->cu.pcm_flag) { int VAR_12; intra_prediction_unit_default_value(VAR_0, VAR_1, VAR_2, VAR_3); VAR_12 = hls_pcm_sample(VAR_0, VAR_1, VAR_2, VAR_3); if (VAR_0->sps->pcm.loop_filter_disable_flag) set_deblocking_bypass(VAR_0, VAR_1, VAR_2, VAR_3); if (VAR_12 < 0) return VAR_12; } else { intra_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_3); } } else { intra_prediction_unit_default_value(VAR_0, VAR_1, VAR_2, VAR_3); switch (lc->cu.part_mode) { case PART_2Nx2N: hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4, VAR_3, 0); break; case PART_2NxN: hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4 / 2, VAR_3, 0); hls_prediction_unit(VAR_0, VAR_1, VAR_2 + VAR_4 / 2, VAR_4, VAR_4 / 2, VAR_3, 1); break; case PART_Nx2N: hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4 / 2, VAR_4, VAR_3, 0); hls_prediction_unit(VAR_0, VAR_1 + VAR_4 / 2, VAR_2, VAR_4 / 2, VAR_4, VAR_3, 1); break; case PART_2NxnU: hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4 / 4, VAR_3, 0); hls_prediction_unit(VAR_0, VAR_1, VAR_2 + VAR_4 / 4, VAR_4, VAR_4 * 3 / 4, VAR_3, 1); break; case PART_2NxnD: hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4 * 3 / 4, VAR_3, 0); hls_prediction_unit(VAR_0, VAR_1, VAR_2 + VAR_4 * 3 / 4, VAR_4, VAR_4 / 4, VAR_3, 1); break; case PART_nLx2N: hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4 / 4, VAR_4, VAR_3, 0); hls_prediction_unit(VAR_0, VAR_1 + VAR_4 / 4, VAR_2, VAR_4 * 3 / 4, VAR_4, VAR_3, 1); break; case PART_nRx2N: hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4 * 3 / 4, VAR_4, VAR_3, 0); hls_prediction_unit(VAR_0, VAR_1 + VAR_4 * 3 / 4, VAR_2, VAR_4 / 4, VAR_4, VAR_3, 1); break; case PART_NxN: hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4 / 2, VAR_4 / 2, VAR_3, 0); hls_prediction_unit(VAR_0, VAR_1 + VAR_4 / 2, VAR_2, VAR_4 / 2, VAR_4 / 2, VAR_3, 1); hls_prediction_unit(VAR_0, VAR_1, VAR_2 + VAR_4 / 2, VAR_4 / 2, VAR_4 / 2, VAR_3, 2); hls_prediction_unit(VAR_0, VAR_1 + VAR_4 / 2, VAR_2 + VAR_4 / 2, VAR_4 / 2, VAR_4 / 2, VAR_3, 3); break; } } if (!lc->cu.pcm_flag) { if (lc->cu.pred_mode != MODE_INTRA && !(lc->cu.part_mode == PART_2Nx2N && lc->pu.merge_flag)) { lc->cu.rqt_root_cbf = ff_hevc_no_residual_syntax_flag_decode(VAR_0); } if (lc->cu.rqt_root_cbf) { lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ? VAR_0->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag : VAR_0->sps->max_transform_hierarchy_depth_inter; hls_transform_tree(VAR_0, VAR_1, VAR_2, VAR_1, VAR_2, VAR_1, VAR_2, VAR_3, VAR_3, 0, 0); } else { if (!VAR_0->sh.disable_deblocking_filter_flag) ff_hevc_deblocking_boundary_strengths(VAR_0, VAR_1, VAR_2, VAR_3, lc->slice_or_tiles_up_boundary, lc->slice_or_tiles_left_boundary); } } } if (VAR_0->pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0) ff_hevc_set_qPy(VAR_0, VAR_1, VAR_2, VAR_1, VAR_2, VAR_3); VAR_10 = VAR_9 * VAR_7 + VAR_8; for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) { memset(&VAR_0->qp_y_tab[VAR_10], lc->qp_y, VAR_6); VAR_10 += VAR_7; } set_ct_depth(VAR_0, VAR_1, VAR_2, VAR_3, lc->ct.depth); return 0; }
[ "static int FUNC_0(HEVCContext *VAR_0, int VAR_1, int VAR_2, int VAR_3)\n{", "int VAR_4 = 1 << VAR_3;", "HEVCLocalContext *lc = &VAR_0->HEVClc;", "int VAR_5 = VAR_0->sps->VAR_5;", "int VAR_6 = VAR_4 >> VAR_5;", "int VAR_7 = VAR_0->sps->VAR_7;", "int VAR_8 = VAR_1 >> VAR_5;", "int VAR_9 = VAR_2 >> VAR_5;", "int VAR_10, VAR_11;", "lc->cu.VAR_10 = VAR_1;", "lc->cu.VAR_11 = VAR_2;", "lc->cu.rqt_root_cbf = 1;", "lc->cu.pred_mode = MODE_INTRA;", "lc->cu.part_mode = PART_2Nx2N;", "lc->cu.intra_split_flag = 0;", "lc->cu.pcm_flag = 0;", "SAMPLE_CTB(VAR_0->skip_flag, VAR_8, VAR_9) = 0;", "for (VAR_10 = 0; VAR_10 < 4; VAR_10++)", "lc->pu.intra_pred_mode[VAR_10] = 1;", "if (VAR_0->pps->transquant_bypass_enable_flag) {", "lc->cu.cu_transquant_bypass_flag = ff_hevc_cu_transquant_bypass_flag_decode(VAR_0);", "if (lc->cu.cu_transquant_bypass_flag)\nset_deblocking_bypass(VAR_0, VAR_1, VAR_2, VAR_3);", "} else", "lc->cu.cu_transquant_bypass_flag = 0;", "if (VAR_0->sh.slice_type != I_SLICE) {", "uint8_t skip_flag = ff_hevc_skip_flag_decode(VAR_0, VAR_1, VAR_2, VAR_8, VAR_9);", "lc->cu.pred_mode = MODE_SKIP;", "VAR_10 = VAR_9 * VAR_7 + VAR_8;", "for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) {", "memset(&VAR_0->skip_flag[VAR_10], skip_flag, VAR_6);", "VAR_10 += VAR_7;", "}", "lc->cu.pred_mode = skip_flag ? MODE_SKIP : MODE_INTER;", "}", "if (SAMPLE_CTB(VAR_0->skip_flag, VAR_8, VAR_9)) {", "hls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4, VAR_3, 0);", "intra_prediction_unit_default_value(VAR_0, VAR_1, VAR_2, VAR_3);", "if (!VAR_0->sh.disable_deblocking_filter_flag)\nff_hevc_deblocking_boundary_strengths(VAR_0, VAR_1, VAR_2, VAR_3,\nlc->slice_or_tiles_up_boundary,\nlc->slice_or_tiles_left_boundary);", "} else {", "if (VAR_0->sh.slice_type != I_SLICE)\nlc->cu.pred_mode = ff_hevc_pred_mode_decode(VAR_0);", "if (lc->cu.pred_mode != MODE_INTRA ||\nVAR_3 == VAR_0->sps->VAR_5) {", "lc->cu.part_mode = ff_hevc_part_mode_decode(VAR_0, VAR_3);", "lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN &&\nlc->cu.pred_mode == MODE_INTRA;", "}", "if (lc->cu.pred_mode == MODE_INTRA) {", "if (lc->cu.part_mode == PART_2Nx2N && VAR_0->sps->pcm_enabled_flag &&\nVAR_3 >= VAR_0->sps->pcm.log2_min_pcm_cb_size &&\nVAR_3 <= VAR_0->sps->pcm.log2_max_pcm_cb_size) {", "lc->cu.pcm_flag = ff_hevc_pcm_flag_decode(VAR_0);", "}", "if (lc->cu.pcm_flag) {", "int VAR_12;", "intra_prediction_unit_default_value(VAR_0, VAR_1, VAR_2, VAR_3);", "VAR_12 = hls_pcm_sample(VAR_0, VAR_1, VAR_2, VAR_3);", "if (VAR_0->sps->pcm.loop_filter_disable_flag)\nset_deblocking_bypass(VAR_0, VAR_1, VAR_2, VAR_3);", "if (VAR_12 < 0)\nreturn VAR_12;", "} else {", "intra_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_3);", "}", "} else {", "intra_prediction_unit_default_value(VAR_0, VAR_1, VAR_2, VAR_3);", "switch (lc->cu.part_mode) {", "case PART_2Nx2N:\nhls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4, VAR_3, 0);", "break;", "case PART_2NxN:\nhls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4 / 2, VAR_3, 0);", "hls_prediction_unit(VAR_0, VAR_1, VAR_2 + VAR_4 / 2, VAR_4, VAR_4 / 2, VAR_3, 1);", "break;", "case PART_Nx2N:\nhls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4 / 2, VAR_4, VAR_3, 0);", "hls_prediction_unit(VAR_0, VAR_1 + VAR_4 / 2, VAR_2, VAR_4 / 2, VAR_4, VAR_3, 1);", "break;", "case PART_2NxnU:\nhls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4 / 4, VAR_3, 0);", "hls_prediction_unit(VAR_0, VAR_1, VAR_2 + VAR_4 / 4, VAR_4, VAR_4 * 3 / 4, VAR_3, 1);", "break;", "case PART_2NxnD:\nhls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4, VAR_4 * 3 / 4, VAR_3, 0);", "hls_prediction_unit(VAR_0, VAR_1, VAR_2 + VAR_4 * 3 / 4, VAR_4, VAR_4 / 4, VAR_3, 1);", "break;", "case PART_nLx2N:\nhls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4 / 4, VAR_4, VAR_3, 0);", "hls_prediction_unit(VAR_0, VAR_1 + VAR_4 / 4, VAR_2, VAR_4 * 3 / 4, VAR_4, VAR_3, 1);", "break;", "case PART_nRx2N:\nhls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4 * 3 / 4, VAR_4, VAR_3, 0);", "hls_prediction_unit(VAR_0, VAR_1 + VAR_4 * 3 / 4, VAR_2, VAR_4 / 4, VAR_4, VAR_3, 1);", "break;", "case PART_NxN:\nhls_prediction_unit(VAR_0, VAR_1, VAR_2, VAR_4 / 2, VAR_4 / 2, VAR_3, 0);", "hls_prediction_unit(VAR_0, VAR_1 + VAR_4 / 2, VAR_2, VAR_4 / 2, VAR_4 / 2, VAR_3, 1);", "hls_prediction_unit(VAR_0, VAR_1, VAR_2 + VAR_4 / 2, VAR_4 / 2, VAR_4 / 2, VAR_3, 2);", "hls_prediction_unit(VAR_0, VAR_1 + VAR_4 / 2, VAR_2 + VAR_4 / 2, VAR_4 / 2, VAR_4 / 2, VAR_3, 3);", "break;", "}", "}", "if (!lc->cu.pcm_flag) {", "if (lc->cu.pred_mode != MODE_INTRA &&\n!(lc->cu.part_mode == PART_2Nx2N && lc->pu.merge_flag)) {", "lc->cu.rqt_root_cbf = ff_hevc_no_residual_syntax_flag_decode(VAR_0);", "}", "if (lc->cu.rqt_root_cbf) {", "lc->cu.max_trafo_depth = lc->cu.pred_mode == MODE_INTRA ?\nVAR_0->sps->max_transform_hierarchy_depth_intra + lc->cu.intra_split_flag :\nVAR_0->sps->max_transform_hierarchy_depth_inter;", "hls_transform_tree(VAR_0, VAR_1, VAR_2, VAR_1, VAR_2, VAR_1, VAR_2, VAR_3,\nVAR_3, 0, 0);", "} else {", "if (!VAR_0->sh.disable_deblocking_filter_flag)\nff_hevc_deblocking_boundary_strengths(VAR_0, VAR_1, VAR_2, VAR_3,\nlc->slice_or_tiles_up_boundary,\nlc->slice_or_tiles_left_boundary);", "}", "}", "}", "if (VAR_0->pps->cu_qp_delta_enabled_flag && lc->tu.is_cu_qp_delta_coded == 0)\nff_hevc_set_qPy(VAR_0, VAR_1, VAR_2, VAR_1, VAR_2, VAR_3);", "VAR_10 = VAR_9 * VAR_7 + VAR_8;", "for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) {", "memset(&VAR_0->qp_y_tab[VAR_10], lc->qp_y, VAR_6);", "VAR_10 += VAR_7;", "}", "set_ct_depth(VAR_0, VAR_1, VAR_2, VAR_3, lc->ct.depth);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 91, 93, 95, 97 ], [ 99 ], [ 101, 103 ], [ 105, 107 ], [ 109 ], [ 111, 113 ], [ 115 ], [ 119 ], [ 121, 123, 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 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 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 215, 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 233 ], [ 235, 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245, 247, 249 ], [ 251, 253 ], [ 255 ], [ 257, 259, 261, 263 ], [ 265 ], [ 267 ], [ 269 ], [ 273, 275 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 291 ], [ 295 ], [ 297 ] ]
20,134
static int alloc_buffer(InputStream *ist, FrameBuffer **pbuf) { AVCodecContext *s = ist->st->codec; FrameBuffer *buf = av_mallocz(sizeof(*buf)); int ret; const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; int h_chroma_shift, v_chroma_shift; int edge = 32; // XXX should be avcodec_get_edge_width(), but that fails on svq1 int w = s->width, h = s->height; if (!buf) return AVERROR(ENOMEM); if (!(s->flags & CODEC_FLAG_EMU_EDGE)) { w += 2*edge; h += 2*edge; } avcodec_align_dimensions(s, &w, &h); if ((ret = av_image_alloc(buf->base, buf->linesize, w, h, s->pix_fmt, 32)) < 0) { av_freep(&buf); return ret; } /* XXX this shouldn't be needed, but some tests break without this line * those decoders are buggy and need to be fixed. * the following tests fail: * bethsoft-vid, cdgraphics, ansi, aasc, fraps-v1, qtrle-1bit */ memset(buf->base[0], 128, ret); avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); for (int i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { const int h_shift = i==0 ? 0 : h_chroma_shift; const int v_shift = i==0 ? 0 : v_chroma_shift; if (s->flags & CODEC_FLAG_EMU_EDGE) buf->data[i] = buf->base[i]; else buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*edge >> v_shift) + (pixel_size*edge >> h_shift), 32); } buf->w = s->width; buf->h = s->height; buf->pix_fmt = s->pix_fmt; buf->ist = ist; *pbuf = buf; return 0; }
false
FFmpeg
3715d841a619f1cbc4776d9b00575dae6fb6534a
static int alloc_buffer(InputStream *ist, FrameBuffer **pbuf) { AVCodecContext *s = ist->st->codec; FrameBuffer *buf = av_mallocz(sizeof(*buf)); int ret; const int pixel_size = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; int h_chroma_shift, v_chroma_shift; int edge = 32; int w = s->width, h = s->height; if (!buf) return AVERROR(ENOMEM); if (!(s->flags & CODEC_FLAG_EMU_EDGE)) { w += 2*edge; h += 2*edge; } avcodec_align_dimensions(s, &w, &h); if ((ret = av_image_alloc(buf->base, buf->linesize, w, h, s->pix_fmt, 32)) < 0) { av_freep(&buf); return ret; } memset(buf->base[0], 128, ret); avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift); for (int i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { const int h_shift = i==0 ? 0 : h_chroma_shift; const int v_shift = i==0 ? 0 : v_chroma_shift; if (s->flags & CODEC_FLAG_EMU_EDGE) buf->data[i] = buf->base[i]; else buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*edge >> v_shift) + (pixel_size*edge >> h_shift), 32); } buf->w = s->width; buf->h = s->height; buf->pix_fmt = s->pix_fmt; buf->ist = ist; *pbuf = buf; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(InputStream *VAR_0, FrameBuffer **VAR_1) { AVCodecContext *s = VAR_0->st->codec; FrameBuffer *buf = av_mallocz(sizeof(*buf)); int VAR_2; const int VAR_3 = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1; int VAR_4, VAR_5; int VAR_6 = 32; int VAR_7 = s->width, VAR_8 = s->height; if (!buf) return AVERROR(ENOMEM); if (!(s->flags & CODEC_FLAG_EMU_EDGE)) { VAR_7 += 2*VAR_6; VAR_8 += 2*VAR_6; } avcodec_align_dimensions(s, &VAR_7, &VAR_8); if ((VAR_2 = av_image_alloc(buf->base, buf->linesize, VAR_7, VAR_8, s->pix_fmt, 32)) < 0) { av_freep(&buf); return VAR_2; } memset(buf->base[0], 128, VAR_2); avcodec_get_chroma_sub_sample(s->pix_fmt, &VAR_4, &VAR_5); for (int i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) { const int h_shift = i==0 ? 0 : VAR_4; const int v_shift = i==0 ? 0 : VAR_5; if (s->flags & CODEC_FLAG_EMU_EDGE) buf->data[i] = buf->base[i]; else buf->data[i] = buf->base[i] + FFALIGN((buf->linesize[i]*VAR_6 >> v_shift) + (VAR_3*VAR_6 >> h_shift), 32); } buf->VAR_7 = s->width; buf->VAR_8 = s->height; buf->pix_fmt = s->pix_fmt; buf->VAR_0 = VAR_0; *VAR_1 = buf; return 0; }
[ "static int FUNC_0(InputStream *VAR_0, FrameBuffer **VAR_1)\n{", "AVCodecContext *s = VAR_0->st->codec;", "FrameBuffer *buf = av_mallocz(sizeof(*buf));", "int VAR_2;", "const int VAR_3 = av_pix_fmt_descriptors[s->pix_fmt].comp[0].step_minus1+1;", "int VAR_4, VAR_5;", "int VAR_6 = 32;", "int VAR_7 = s->width, VAR_8 = s->height;", "if (!buf)\nreturn AVERROR(ENOMEM);", "if (!(s->flags & CODEC_FLAG_EMU_EDGE)) {", "VAR_7 += 2*VAR_6;", "VAR_8 += 2*VAR_6;", "}", "avcodec_align_dimensions(s, &VAR_7, &VAR_8);", "if ((VAR_2 = av_image_alloc(buf->base, buf->linesize, VAR_7, VAR_8,\ns->pix_fmt, 32)) < 0) {", "av_freep(&buf);", "return VAR_2;", "}", "memset(buf->base[0], 128, VAR_2);", "avcodec_get_chroma_sub_sample(s->pix_fmt, &VAR_4, &VAR_5);", "for (int i = 0; i < FF_ARRAY_ELEMS(buf->data); i++) {", "const int h_shift = i==0 ? 0 : VAR_4;", "const int v_shift = i==0 ? 0 : VAR_5;", "if (s->flags & CODEC_FLAG_EMU_EDGE)\nbuf->data[i] = buf->base[i];", "else\nbuf->data[i] = buf->base[i] +\nFFALIGN((buf->linesize[i]*VAR_6 >> v_shift) +\n(VAR_3*VAR_6 >> h_shift), 32);", "}", "buf->VAR_7 = s->width;", "buf->VAR_8 = s->height;", "buf->pix_fmt = s->pix_fmt;", "buf->VAR_0 = VAR_0;", "*VAR_1 = buf;", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75, 77, 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ] ]
20,135
static av_cold int tqi_decode_init(AVCodecContext *avctx) { TqiContext *t = avctx->priv_data; ff_blockdsp_init(&t->bdsp, avctx); ff_bswapdsp_init(&t->bsdsp); ff_idctdsp_init(&t->idsp, avctx); ff_init_scantable_permutation(t->idsp.idct_permutation, FF_IDCT_PERM_NONE); ff_init_scantable(t->idsp.idct_permutation, &t->intra_scantable, ff_zigzag_direct); avctx->framerate = (AVRational){ 15, 1 }; avctx->pix_fmt = AV_PIX_FMT_YUV420P; ff_mpeg12_init_vlcs(); return 0; }
false
FFmpeg
dcc39ee10e82833ce24aa57926c00ffeb1948198
static av_cold int tqi_decode_init(AVCodecContext *avctx) { TqiContext *t = avctx->priv_data; ff_blockdsp_init(&t->bdsp, avctx); ff_bswapdsp_init(&t->bsdsp); ff_idctdsp_init(&t->idsp, avctx); ff_init_scantable_permutation(t->idsp.idct_permutation, FF_IDCT_PERM_NONE); ff_init_scantable(t->idsp.idct_permutation, &t->intra_scantable, ff_zigzag_direct); avctx->framerate = (AVRational){ 15, 1 }; avctx->pix_fmt = AV_PIX_FMT_YUV420P; ff_mpeg12_init_vlcs(); return 0; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { TqiContext *t = avctx->priv_data; ff_blockdsp_init(&t->bdsp, avctx); ff_bswapdsp_init(&t->bsdsp); ff_idctdsp_init(&t->idsp, avctx); ff_init_scantable_permutation(t->idsp.idct_permutation, FF_IDCT_PERM_NONE); ff_init_scantable(t->idsp.idct_permutation, &t->intra_scantable, ff_zigzag_direct); avctx->framerate = (AVRational){ 15, 1 }; avctx->pix_fmt = AV_PIX_FMT_YUV420P; ff_mpeg12_init_vlcs(); return 0; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "TqiContext *t = avctx->priv_data;", "ff_blockdsp_init(&t->bdsp, avctx);", "ff_bswapdsp_init(&t->bsdsp);", "ff_idctdsp_init(&t->idsp, avctx);", "ff_init_scantable_permutation(t->idsp.idct_permutation, FF_IDCT_PERM_NONE);", "ff_init_scantable(t->idsp.idct_permutation, &t->intra_scantable, ff_zigzag_direct);", "avctx->framerate = (AVRational){ 15, 1 };", "avctx->pix_fmt = AV_PIX_FMT_YUV420P;", "ff_mpeg12_init_vlcs();", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
20,137
static int pred_weight_table(H264Context *h) { int list, i; int luma_def, chroma_def; h->use_weight = 0; h->use_weight_chroma = 0; h->luma_log2_weight_denom = get_ue_golomb(&h->gb); if (h->sps.chroma_format_idc) h->chroma_log2_weight_denom = get_ue_golomb(&h->gb); luma_def = 1 << h->luma_log2_weight_denom; chroma_def = 1 << h->chroma_log2_weight_denom; for (list = 0; list < 2; list++) { h->luma_weight_flag[list] = 0; h->chroma_weight_flag[list] = 0; for (i = 0; i < h->ref_count[list]; i++) { int luma_weight_flag, chroma_weight_flag; luma_weight_flag = get_bits1(&h->gb); if (luma_weight_flag) { h->luma_weight[i][list][0] = get_se_golomb(&h->gb); h->luma_weight[i][list][1] = get_se_golomb(&h->gb); if (h->luma_weight[i][list][0] != luma_def || h->luma_weight[i][list][1] != 0) { h->use_weight = 1; h->luma_weight_flag[list] = 1; } } else { h->luma_weight[i][list][0] = luma_def; h->luma_weight[i][list][1] = 0; } if (h->sps.chroma_format_idc) { chroma_weight_flag = get_bits1(&h->gb); if (chroma_weight_flag) { int j; for (j = 0; j < 2; j++) { h->chroma_weight[i][list][j][0] = get_se_golomb(&h->gb); h->chroma_weight[i][list][j][1] = get_se_golomb(&h->gb); if (h->chroma_weight[i][list][j][0] != chroma_def || h->chroma_weight[i][list][j][1] != 0) { h->use_weight_chroma = 1; h->chroma_weight_flag[list] = 1; } } } else { int j; for (j = 0; j < 2; j++) { h->chroma_weight[i][list][j][0] = chroma_def; h->chroma_weight[i][list][j][1] = 0; } } } } if (h->slice_type_nos != AV_PICTURE_TYPE_B) break; } h->use_weight = h->use_weight || h->use_weight_chroma; return 0; }
false
FFmpeg
4baba6c813b7a1f27370e20fb1a87b05fcb39208
static int pred_weight_table(H264Context *h) { int list, i; int luma_def, chroma_def; h->use_weight = 0; h->use_weight_chroma = 0; h->luma_log2_weight_denom = get_ue_golomb(&h->gb); if (h->sps.chroma_format_idc) h->chroma_log2_weight_denom = get_ue_golomb(&h->gb); luma_def = 1 << h->luma_log2_weight_denom; chroma_def = 1 << h->chroma_log2_weight_denom; for (list = 0; list < 2; list++) { h->luma_weight_flag[list] = 0; h->chroma_weight_flag[list] = 0; for (i = 0; i < h->ref_count[list]; i++) { int luma_weight_flag, chroma_weight_flag; luma_weight_flag = get_bits1(&h->gb); if (luma_weight_flag) { h->luma_weight[i][list][0] = get_se_golomb(&h->gb); h->luma_weight[i][list][1] = get_se_golomb(&h->gb); if (h->luma_weight[i][list][0] != luma_def || h->luma_weight[i][list][1] != 0) { h->use_weight = 1; h->luma_weight_flag[list] = 1; } } else { h->luma_weight[i][list][0] = luma_def; h->luma_weight[i][list][1] = 0; } if (h->sps.chroma_format_idc) { chroma_weight_flag = get_bits1(&h->gb); if (chroma_weight_flag) { int j; for (j = 0; j < 2; j++) { h->chroma_weight[i][list][j][0] = get_se_golomb(&h->gb); h->chroma_weight[i][list][j][1] = get_se_golomb(&h->gb); if (h->chroma_weight[i][list][j][0] != chroma_def || h->chroma_weight[i][list][j][1] != 0) { h->use_weight_chroma = 1; h->chroma_weight_flag[list] = 1; } } } else { int j; for (j = 0; j < 2; j++) { h->chroma_weight[i][list][j][0] = chroma_def; h->chroma_weight[i][list][j][1] = 0; } } } } if (h->slice_type_nos != AV_PICTURE_TYPE_B) break; } h->use_weight = h->use_weight || h->use_weight_chroma; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(H264Context *VAR_0) { int VAR_1, VAR_2; int VAR_3, VAR_4; VAR_0->use_weight = 0; VAR_0->use_weight_chroma = 0; VAR_0->luma_log2_weight_denom = get_ue_golomb(&VAR_0->gb); if (VAR_0->sps.chroma_format_idc) VAR_0->chroma_log2_weight_denom = get_ue_golomb(&VAR_0->gb); VAR_3 = 1 << VAR_0->luma_log2_weight_denom; VAR_4 = 1 << VAR_0->chroma_log2_weight_denom; for (VAR_1 = 0; VAR_1 < 2; VAR_1++) { VAR_0->luma_weight_flag[VAR_1] = 0; VAR_0->chroma_weight_flag[VAR_1] = 0; for (VAR_2 = 0; VAR_2 < VAR_0->ref_count[VAR_1]; VAR_2++) { int luma_weight_flag, chroma_weight_flag; luma_weight_flag = get_bits1(&VAR_0->gb); if (luma_weight_flag) { VAR_0->luma_weight[VAR_2][VAR_1][0] = get_se_golomb(&VAR_0->gb); VAR_0->luma_weight[VAR_2][VAR_1][1] = get_se_golomb(&VAR_0->gb); if (VAR_0->luma_weight[VAR_2][VAR_1][0] != VAR_3 || VAR_0->luma_weight[VAR_2][VAR_1][1] != 0) { VAR_0->use_weight = 1; VAR_0->luma_weight_flag[VAR_1] = 1; } } else { VAR_0->luma_weight[VAR_2][VAR_1][0] = VAR_3; VAR_0->luma_weight[VAR_2][VAR_1][1] = 0; } if (VAR_0->sps.chroma_format_idc) { chroma_weight_flag = get_bits1(&VAR_0->gb); if (chroma_weight_flag) { int j; for (j = 0; j < 2; j++) { VAR_0->chroma_weight[VAR_2][VAR_1][j][0] = get_se_golomb(&VAR_0->gb); VAR_0->chroma_weight[VAR_2][VAR_1][j][1] = get_se_golomb(&VAR_0->gb); if (VAR_0->chroma_weight[VAR_2][VAR_1][j][0] != VAR_4 || VAR_0->chroma_weight[VAR_2][VAR_1][j][1] != 0) { VAR_0->use_weight_chroma = 1; VAR_0->chroma_weight_flag[VAR_1] = 1; } } } else { int j; for (j = 0; j < 2; j++) { VAR_0->chroma_weight[VAR_2][VAR_1][j][0] = VAR_4; VAR_0->chroma_weight[VAR_2][VAR_1][j][1] = 0; } } } } if (VAR_0->slice_type_nos != AV_PICTURE_TYPE_B) break; } VAR_0->use_weight = VAR_0->use_weight || VAR_0->use_weight_chroma; return 0; }
[ "static int FUNC_0(H264Context *VAR_0)\n{", "int VAR_1, VAR_2;", "int VAR_3, VAR_4;", "VAR_0->use_weight = 0;", "VAR_0->use_weight_chroma = 0;", "VAR_0->luma_log2_weight_denom = get_ue_golomb(&VAR_0->gb);", "if (VAR_0->sps.chroma_format_idc)\nVAR_0->chroma_log2_weight_denom = get_ue_golomb(&VAR_0->gb);", "VAR_3 = 1 << VAR_0->luma_log2_weight_denom;", "VAR_4 = 1 << VAR_0->chroma_log2_weight_denom;", "for (VAR_1 = 0; VAR_1 < 2; VAR_1++) {", "VAR_0->luma_weight_flag[VAR_1] = 0;", "VAR_0->chroma_weight_flag[VAR_1] = 0;", "for (VAR_2 = 0; VAR_2 < VAR_0->ref_count[VAR_1]; VAR_2++) {", "int luma_weight_flag, chroma_weight_flag;", "luma_weight_flag = get_bits1(&VAR_0->gb);", "if (luma_weight_flag) {", "VAR_0->luma_weight[VAR_2][VAR_1][0] = get_se_golomb(&VAR_0->gb);", "VAR_0->luma_weight[VAR_2][VAR_1][1] = get_se_golomb(&VAR_0->gb);", "if (VAR_0->luma_weight[VAR_2][VAR_1][0] != VAR_3 ||\nVAR_0->luma_weight[VAR_2][VAR_1][1] != 0) {", "VAR_0->use_weight = 1;", "VAR_0->luma_weight_flag[VAR_1] = 1;", "}", "} else {", "VAR_0->luma_weight[VAR_2][VAR_1][0] = VAR_3;", "VAR_0->luma_weight[VAR_2][VAR_1][1] = 0;", "}", "if (VAR_0->sps.chroma_format_idc) {", "chroma_weight_flag = get_bits1(&VAR_0->gb);", "if (chroma_weight_flag) {", "int j;", "for (j = 0; j < 2; j++) {", "VAR_0->chroma_weight[VAR_2][VAR_1][j][0] = get_se_golomb(&VAR_0->gb);", "VAR_0->chroma_weight[VAR_2][VAR_1][j][1] = get_se_golomb(&VAR_0->gb);", "if (VAR_0->chroma_weight[VAR_2][VAR_1][j][0] != VAR_4 ||\nVAR_0->chroma_weight[VAR_2][VAR_1][j][1] != 0) {", "VAR_0->use_weight_chroma = 1;", "VAR_0->chroma_weight_flag[VAR_1] = 1;", "}", "}", "} else {", "int j;", "for (j = 0; j < 2; j++) {", "VAR_0->chroma_weight[VAR_2][VAR_1][j][0] = VAR_4;", "VAR_0->chroma_weight[VAR_2][VAR_1][j][1] = 0;", "}", "}", "}", "}", "if (VAR_0->slice_type_nos != AV_PICTURE_TYPE_B)\nbreak;", "}", "VAR_0->use_weight = VAR_0->use_weight || VAR_0->use_weight_chroma;", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ] ]
20,139
static void rtl8139_cplus_transmit(RTL8139State *s) { int txcount = 0; while (rtl8139_cplus_transmit_one(s)) { ++txcount; } /* Mark transfer completed */ if (!txcount) { DPRINTF("C+ mode : transmitter queue stalled, current TxDesc = %d\n", s->currCPlusTxDesc); } else { /* update interrupt status */ s->IntrStatus |= TxOK; rtl8139_update_irq(s); } }
false
qemu
c7c35916692fe010fef25ac338443d3fe40be225
static void rtl8139_cplus_transmit(RTL8139State *s) { int txcount = 0; while (rtl8139_cplus_transmit_one(s)) { ++txcount; } if (!txcount) { DPRINTF("C+ mode : transmitter queue stalled, current TxDesc = %d\n", s->currCPlusTxDesc); } else { s->IntrStatus |= TxOK; rtl8139_update_irq(s); } }
{ "code": [], "line_no": [] }
static void FUNC_0(RTL8139State *VAR_0) { int VAR_1 = 0; while (rtl8139_cplus_transmit_one(VAR_0)) { ++VAR_1; } if (!VAR_1) { DPRINTF("C+ mode : transmitter queue stalled, current TxDesc = %d\n", VAR_0->currCPlusTxDesc); } else { VAR_0->IntrStatus |= TxOK; rtl8139_update_irq(VAR_0); } }
[ "static void FUNC_0(RTL8139State *VAR_0)\n{", "int VAR_1 = 0;", "while (rtl8139_cplus_transmit_one(VAR_0))\n{", "++VAR_1;", "}", "if (!VAR_1)\n{", "DPRINTF(\"C+ mode : transmitter queue stalled, current TxDesc = %d\\n\",\nVAR_0->currCPlusTxDesc);", "}", "else\n{", "VAR_0->IntrStatus |= TxOK;", "rtl8139_update_irq(VAR_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 ], [ 39 ], [ 41 ], [ 43 ] ]
20,140
static int local_utimensat(FsContext *s, V9fsPath *fs_path, const struct timespec *buf) { char buffer[PATH_MAX]; char *path = fs_path->data; return qemu_utimens(rpath(s, path, buffer), buf); }
false
qemu
4fa4ce7107c6ec432f185307158c5df91ce54308
static int local_utimensat(FsContext *s, V9fsPath *fs_path, const struct timespec *buf) { char buffer[PATH_MAX]; char *path = fs_path->data; return qemu_utimens(rpath(s, path, buffer), buf); }
{ "code": [], "line_no": [] }
static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, const struct timespec *VAR_2) { char VAR_3[PATH_MAX]; char *VAR_4 = VAR_1->data; return qemu_utimens(rpath(VAR_0, VAR_4, VAR_3), VAR_2); }
[ "static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nconst struct timespec *VAR_2)\n{", "char VAR_3[PATH_MAX];", "char *VAR_4 = VAR_1->data;", "return qemu_utimens(rpath(VAR_0, VAR_4, VAR_3), VAR_2);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ] ]
20,141
int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags, CPUBreakpoint **breakpoint) { #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp; bp = qemu_malloc(sizeof(*bp)); bp->pc = pc; bp->flags = flags; /* keep all GDB-injected breakpoints in front */ if (flags & BP_GDB) TAILQ_INSERT_HEAD(&env->breakpoints, bp, entry); else TAILQ_INSERT_TAIL(&env->breakpoints, bp, entry); breakpoint_invalidate(env, pc); if (breakpoint) *breakpoint = bp; return 0; #else return -ENOSYS; #endif }
false
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags, CPUBreakpoint **breakpoint) { #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp; bp = qemu_malloc(sizeof(*bp)); bp->pc = pc; bp->flags = flags; if (flags & BP_GDB) TAILQ_INSERT_HEAD(&env->breakpoints, bp, entry); else TAILQ_INSERT_TAIL(&env->breakpoints, bp, entry); breakpoint_invalidate(env, pc); if (breakpoint) *breakpoint = bp; return 0; #else return -ENOSYS; #endif }
{ "code": [], "line_no": [] }
int FUNC_0(CPUState *VAR_0, target_ulong VAR_1, int VAR_2, CPUBreakpoint **VAR_3) { #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp; bp = qemu_malloc(sizeof(*bp)); bp->VAR_1 = VAR_1; bp->VAR_2 = VAR_2; if (VAR_2 & BP_GDB) TAILQ_INSERT_HEAD(&VAR_0->breakpoints, bp, entry); else TAILQ_INSERT_TAIL(&VAR_0->breakpoints, bp, entry); breakpoint_invalidate(VAR_0, VAR_1); if (VAR_3) *VAR_3 = bp; return 0; #else return -ENOSYS; #endif }
[ "int FUNC_0(CPUState *VAR_0, target_ulong VAR_1, int VAR_2,\nCPUBreakpoint **VAR_3)\n{", "#if defined(TARGET_HAS_ICE)\nCPUBreakpoint *bp;", "bp = qemu_malloc(sizeof(*bp));", "bp->VAR_1 = VAR_1;", "bp->VAR_2 = VAR_2;", "if (VAR_2 & BP_GDB)\nTAILQ_INSERT_HEAD(&VAR_0->breakpoints, bp, entry);", "else\nTAILQ_INSERT_TAIL(&VAR_0->breakpoints, bp, entry);", "breakpoint_invalidate(VAR_0, VAR_1);", "if (VAR_3)\n*VAR_3 = bp;", "return 0;", "#else\nreturn -ENOSYS;", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9 ], [ 13 ], [ 17 ], [ 19 ], [ 25, 27 ], [ 29, 31 ], [ 35 ], [ 39, 41 ], [ 43 ], [ 45, 47 ], [ 49, 51 ] ]
20,142
static void id3v2_read_internal(AVIOContext *pb, AVDictionary **metadata, AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta) { int len, ret; uint8_t buf[ID3v2_HEADER_SIZE]; int found_header; int64_t off; do { /* save the current offset in case there's nothing to read/skip */ off = avio_tell(pb); ret = avio_read(pb, buf, ID3v2_HEADER_SIZE); if (ret != ID3v2_HEADER_SIZE) { avio_seek(pb, off, SEEK_SET); break; } found_header = ff_id3v2_match(buf, magic); if (found_header) { /* parse ID3v2 header */ len = ((buf[6] & 0x7f) << 21) | ((buf[7] & 0x7f) << 14) | ((buf[8] & 0x7f) << 7) | (buf[9] & 0x7f); id3v2_parse(pb, metadata, s, len, buf[3], buf[5], extra_meta); } else { avio_seek(pb, off, SEEK_SET); } } while (found_header); ff_metadata_conv(metadata, NULL, ff_id3v2_34_metadata_conv); ff_metadata_conv(metadata, NULL, id3v2_2_metadata_conv); ff_metadata_conv(metadata, NULL, ff_id3v2_4_metadata_conv); merge_date(metadata); }
false
FFmpeg
5331773cc33ba26b9e26ace643d926219e46a17b
static void id3v2_read_internal(AVIOContext *pb, AVDictionary **metadata, AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta) { int len, ret; uint8_t buf[ID3v2_HEADER_SIZE]; int found_header; int64_t off; do { off = avio_tell(pb); ret = avio_read(pb, buf, ID3v2_HEADER_SIZE); if (ret != ID3v2_HEADER_SIZE) { avio_seek(pb, off, SEEK_SET); break; } found_header = ff_id3v2_match(buf, magic); if (found_header) { len = ((buf[6] & 0x7f) << 21) | ((buf[7] & 0x7f) << 14) | ((buf[8] & 0x7f) << 7) | (buf[9] & 0x7f); id3v2_parse(pb, metadata, s, len, buf[3], buf[5], extra_meta); } else { avio_seek(pb, off, SEEK_SET); } } while (found_header); ff_metadata_conv(metadata, NULL, ff_id3v2_34_metadata_conv); ff_metadata_conv(metadata, NULL, id3v2_2_metadata_conv); ff_metadata_conv(metadata, NULL, ff_id3v2_4_metadata_conv); merge_date(metadata); }
{ "code": [], "line_no": [] }
static void FUNC_0(AVIOContext *VAR_0, AVDictionary **VAR_1, AVFormatContext *VAR_2, const char *VAR_3, ID3v2ExtraMeta **VAR_4) { int VAR_5, VAR_6; uint8_t buf[ID3v2_HEADER_SIZE]; int VAR_7; int64_t off; do { off = avio_tell(VAR_0); VAR_6 = avio_read(VAR_0, buf, ID3v2_HEADER_SIZE); if (VAR_6 != ID3v2_HEADER_SIZE) { avio_seek(VAR_0, off, SEEK_SET); break; } VAR_7 = ff_id3v2_match(buf, VAR_3); if (VAR_7) { VAR_5 = ((buf[6] & 0x7f) << 21) | ((buf[7] & 0x7f) << 14) | ((buf[8] & 0x7f) << 7) | (buf[9] & 0x7f); id3v2_parse(VAR_0, VAR_1, VAR_2, VAR_5, buf[3], buf[5], VAR_4); } else { avio_seek(VAR_0, off, SEEK_SET); } } while (VAR_7); ff_metadata_conv(VAR_1, NULL, ff_id3v2_34_metadata_conv); ff_metadata_conv(VAR_1, NULL, id3v2_2_metadata_conv); ff_metadata_conv(VAR_1, NULL, ff_id3v2_4_metadata_conv); merge_date(VAR_1); }
[ "static void FUNC_0(AVIOContext *VAR_0, AVDictionary **VAR_1,\nAVFormatContext *VAR_2, const char *VAR_3,\nID3v2ExtraMeta **VAR_4)\n{", "int VAR_5, VAR_6;", "uint8_t buf[ID3v2_HEADER_SIZE];", "int VAR_7;", "int64_t off;", "do {", "off = avio_tell(VAR_0);", "VAR_6 = avio_read(VAR_0, buf, ID3v2_HEADER_SIZE);", "if (VAR_6 != ID3v2_HEADER_SIZE) {", "avio_seek(VAR_0, off, SEEK_SET);", "break;", "}", "VAR_7 = ff_id3v2_match(buf, VAR_3);", "if (VAR_7) {", "VAR_5 = ((buf[6] & 0x7f) << 21) |\n((buf[7] & 0x7f) << 14) |\n((buf[8] & 0x7f) << 7) |\n(buf[9] & 0x7f);", "id3v2_parse(VAR_0, VAR_1, VAR_2, VAR_5, buf[3], buf[5], VAR_4);", "} else {", "avio_seek(VAR_0, off, SEEK_SET);", "}", "} while (VAR_7);", "ff_metadata_conv(VAR_1, NULL, ff_id3v2_34_metadata_conv);", "ff_metadata_conv(VAR_1, NULL, id3v2_2_metadata_conv);", "ff_metadata_conv(VAR_1, NULL, ff_id3v2_4_metadata_conv);", "merge_date(VAR_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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41, 43, 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ] ]
20,143
static always_inline void gen_fbcond (DisasContext *ctx, void* func, int ra, int32_t disp16) { int l1, l2; TCGv tmp; l1 = gen_new_label(); l2 = gen_new_label(); if (ra != 31) { tmp = tcg_temp_new(TCG_TYPE_I64); tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]); } else { tmp = tcg_const_i64(0); tcg_gen_helper_1_1(func, tmp, tmp); } tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 0, l1); tcg_gen_movi_i64(cpu_pc, ctx->pc); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2)); gen_set_label(l2); }
false
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
static always_inline void gen_fbcond (DisasContext *ctx, void* func, int ra, int32_t disp16) { int l1, l2; TCGv tmp; l1 = gen_new_label(); l2 = gen_new_label(); if (ra != 31) { tmp = tcg_temp_new(TCG_TYPE_I64); tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]); } else { tmp = tcg_const_i64(0); tcg_gen_helper_1_1(func, tmp, tmp); } tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 0, l1); tcg_gen_movi_i64(cpu_pc, ctx->pc); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2)); gen_set_label(l2); }
{ "code": [], "line_no": [] }
static always_inline void FUNC_0 (DisasContext *ctx, void* func, int ra, int32_t disp16) { int VAR_0, VAR_1; TCGv tmp; VAR_0 = gen_new_label(); VAR_1 = gen_new_label(); if (ra != 31) { tmp = tcg_temp_new(TCG_TYPE_I64); tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]); } else { tmp = tcg_const_i64(0); tcg_gen_helper_1_1(func, tmp, tmp); } tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 0, VAR_0); tcg_gen_movi_i64(cpu_pc, ctx->pc); tcg_gen_br(VAR_1); gen_set_label(VAR_0); tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2)); gen_set_label(VAR_1); }
[ "static always_inline void FUNC_0 (DisasContext *ctx,\nvoid* func,\nint ra, int32_t disp16)\n{", "int VAR_0, VAR_1;", "TCGv tmp;", "VAR_0 = gen_new_label();", "VAR_1 = gen_new_label();", "if (ra != 31) {", "tmp = tcg_temp_new(TCG_TYPE_I64);", "tcg_gen_helper_1_1(func, tmp, cpu_fir[ra]);", "} else {", "tmp = tcg_const_i64(0);", "tcg_gen_helper_1_1(func, tmp, tmp);", "}", "tcg_gen_brcondi_i64(TCG_COND_NE, tmp, 0, VAR_0);", "tcg_gen_movi_i64(cpu_pc, ctx->pc);", "tcg_gen_br(VAR_1);", "gen_set_label(VAR_0);", "tcg_gen_movi_i64(cpu_pc, ctx->pc + (int64_t)(disp16 << 2));", "gen_set_label(VAR_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 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ] ]
20,145
static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { IscsiLun *iscsilun = bs->opaque; struct scsi_get_lba_status *lbas = NULL; struct scsi_lba_status_descriptor *lbasd = NULL; struct IscsiTask iTask; int64_t ret; iscsi_co_init_iscsitask(iscsilun, &iTask); if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { ret = -EINVAL; goto out; } /* default to all sectors allocated */ ret = BDRV_BLOCK_DATA; ret |= (sector_num << BDRV_SECTOR_BITS) | BDRV_BLOCK_OFFSET_VALID; *pnum = nb_sectors; /* LUN does not support logical block provisioning */ if (!iscsilun->lbpme) { goto out; } retry: if (iscsi_get_lba_status_task(iscsilun->iscsi, iscsilun->lun, sector_qemu2lun(sector_num, iscsilun), 8 + 16, iscsi_co_generic_cb, &iTask) == NULL) { ret = -ENOMEM; goto out; } while (!iTask.complete) { iscsi_set_events(iscsilun); qemu_coroutine_yield(); } if (iTask.do_retry) { if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); iTask.task = NULL; } iTask.complete = 0; goto retry; } if (iTask.status != SCSI_STATUS_GOOD) { /* in case the get_lba_status_callout fails (i.e. * because the device is busy or the cmd is not * supported) we pretend all blocks are allocated * for backwards compatibility */ goto out; } lbas = scsi_datain_unmarshall(iTask.task); if (lbas == NULL) { ret = -EIO; goto out; } lbasd = &lbas->descriptors[0]; if (sector_qemu2lun(sector_num, iscsilun) != lbasd->lba) { ret = -EIO; goto out; } *pnum = sector_lun2qemu(lbasd->num_blocks, iscsilun); if (lbasd->provisioning == SCSI_PROVISIONING_TYPE_DEALLOCATED || lbasd->provisioning == SCSI_PROVISIONING_TYPE_ANCHORED) { ret &= ~BDRV_BLOCK_DATA; if (iscsilun->lbprz) { ret |= BDRV_BLOCK_ZERO; } } if (ret & BDRV_BLOCK_ZERO) { iscsi_allocationmap_clear(iscsilun, sector_num, *pnum); } else { iscsi_allocationmap_set(iscsilun, sector_num, *pnum); } if (*pnum > nb_sectors) { *pnum = nb_sectors; } out: if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); } if (ret > 0 && ret & BDRV_BLOCK_OFFSET_VALID) { *file = bs; } return ret; }
false
qemu
e1123a3b40a1a9a625a29c8ed4debb7e206ea690
static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { IscsiLun *iscsilun = bs->opaque; struct scsi_get_lba_status *lbas = NULL; struct scsi_lba_status_descriptor *lbasd = NULL; struct IscsiTask iTask; int64_t ret; iscsi_co_init_iscsitask(iscsilun, &iTask); if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { ret = -EINVAL; goto out; } ret = BDRV_BLOCK_DATA; ret |= (sector_num << BDRV_SECTOR_BITS) | BDRV_BLOCK_OFFSET_VALID; *pnum = nb_sectors; if (!iscsilun->lbpme) { goto out; } retry: if (iscsi_get_lba_status_task(iscsilun->iscsi, iscsilun->lun, sector_qemu2lun(sector_num, iscsilun), 8 + 16, iscsi_co_generic_cb, &iTask) == NULL) { ret = -ENOMEM; goto out; } while (!iTask.complete) { iscsi_set_events(iscsilun); qemu_coroutine_yield(); } if (iTask.do_retry) { if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); iTask.task = NULL; } iTask.complete = 0; goto retry; } if (iTask.status != SCSI_STATUS_GOOD) { goto out; } lbas = scsi_datain_unmarshall(iTask.task); if (lbas == NULL) { ret = -EIO; goto out; } lbasd = &lbas->descriptors[0]; if (sector_qemu2lun(sector_num, iscsilun) != lbasd->lba) { ret = -EIO; goto out; } *pnum = sector_lun2qemu(lbasd->num_blocks, iscsilun); if (lbasd->provisioning == SCSI_PROVISIONING_TYPE_DEALLOCATED || lbasd->provisioning == SCSI_PROVISIONING_TYPE_ANCHORED) { ret &= ~BDRV_BLOCK_DATA; if (iscsilun->lbprz) { ret |= BDRV_BLOCK_ZERO; } } if (ret & BDRV_BLOCK_ZERO) { iscsi_allocationmap_clear(iscsilun, sector_num, *pnum); } else { iscsi_allocationmap_set(iscsilun, sector_num, *pnum); } if (*pnum > nb_sectors) { *pnum = nb_sectors; } out: if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); } if (ret > 0 && ret & BDRV_BLOCK_OFFSET_VALID) { *file = bs; } return ret; }
{ "code": [], "line_no": [] }
static int64_t VAR_0 iscsi_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { IscsiLun *iscsilun = bs->opaque; struct scsi_get_lba_status *lbas = NULL; struct scsi_lba_status_descriptor *lbasd = NULL; struct IscsiTask iTask; int64_t ret; iscsi_co_init_iscsitask(iscsilun, &iTask); if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) { ret = -EINVAL; goto out; } ret = BDRV_BLOCK_DATA; ret |= (sector_num << BDRV_SECTOR_BITS) | BDRV_BLOCK_OFFSET_VALID; *pnum = nb_sectors; if (!iscsilun->lbpme) { goto out; } retry: if (iscsi_get_lba_status_task(iscsilun->iscsi, iscsilun->lun, sector_qemu2lun(sector_num, iscsilun), 8 + 16, iscsi_co_generic_cb, &iTask) == NULL) { ret = -ENOMEM; goto out; } while (!iTask.complete) { iscsi_set_events(iscsilun); qemu_coroutine_yield(); } if (iTask.do_retry) { if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); iTask.task = NULL; } iTask.complete = 0; goto retry; } if (iTask.status != SCSI_STATUS_GOOD) { goto out; } lbas = scsi_datain_unmarshall(iTask.task); if (lbas == NULL) { ret = -EIO; goto out; } lbasd = &lbas->descriptors[0]; if (sector_qemu2lun(sector_num, iscsilun) != lbasd->lba) { ret = -EIO; goto out; } *pnum = sector_lun2qemu(lbasd->num_blocks, iscsilun); if (lbasd->provisioning == SCSI_PROVISIONING_TYPE_DEALLOCATED || lbasd->provisioning == SCSI_PROVISIONING_TYPE_ANCHORED) { ret &= ~BDRV_BLOCK_DATA; if (iscsilun->lbprz) { ret |= BDRV_BLOCK_ZERO; } } if (ret & BDRV_BLOCK_ZERO) { iscsi_allocationmap_clear(iscsilun, sector_num, *pnum); } else { iscsi_allocationmap_set(iscsilun, sector_num, *pnum); } if (*pnum > nb_sectors) { *pnum = nb_sectors; } out: if (iTask.task != NULL) { scsi_free_scsi_task(iTask.task); } if (ret > 0 && ret & BDRV_BLOCK_OFFSET_VALID) { *file = bs; } return ret; }
[ "static int64_t VAR_0 iscsi_co_get_block_status(BlockDriverState *bs,\nint64_t sector_num,\nint nb_sectors, int *pnum,\nBlockDriverState **file)\n{", "IscsiLun *iscsilun = bs->opaque;", "struct scsi_get_lba_status *lbas = NULL;", "struct scsi_lba_status_descriptor *lbasd = NULL;", "struct IscsiTask iTask;", "int64_t ret;", "iscsi_co_init_iscsitask(iscsilun, &iTask);", "if (!is_sector_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {", "ret = -EINVAL;", "goto out;", "}", "ret = BDRV_BLOCK_DATA;", "ret |= (sector_num << BDRV_SECTOR_BITS) | BDRV_BLOCK_OFFSET_VALID;", "*pnum = nb_sectors;", "if (!iscsilun->lbpme) {", "goto out;", "}", "retry:\nif (iscsi_get_lba_status_task(iscsilun->iscsi, iscsilun->lun,\nsector_qemu2lun(sector_num, iscsilun),\n8 + 16, iscsi_co_generic_cb,\n&iTask) == NULL) {", "ret = -ENOMEM;", "goto out;", "}", "while (!iTask.complete) {", "iscsi_set_events(iscsilun);", "qemu_coroutine_yield();", "}", "if (iTask.do_retry) {", "if (iTask.task != NULL) {", "scsi_free_scsi_task(iTask.task);", "iTask.task = NULL;", "}", "iTask.complete = 0;", "goto retry;", "}", "if (iTask.status != SCSI_STATUS_GOOD) {", "goto out;", "}", "lbas = scsi_datain_unmarshall(iTask.task);", "if (lbas == NULL) {", "ret = -EIO;", "goto out;", "}", "lbasd = &lbas->descriptors[0];", "if (sector_qemu2lun(sector_num, iscsilun) != lbasd->lba) {", "ret = -EIO;", "goto out;", "}", "*pnum = sector_lun2qemu(lbasd->num_blocks, iscsilun);", "if (lbasd->provisioning == SCSI_PROVISIONING_TYPE_DEALLOCATED ||\nlbasd->provisioning == SCSI_PROVISIONING_TYPE_ANCHORED) {", "ret &= ~BDRV_BLOCK_DATA;", "if (iscsilun->lbprz) {", "ret |= BDRV_BLOCK_ZERO;", "}", "}", "if (ret & BDRV_BLOCK_ZERO) {", "iscsi_allocationmap_clear(iscsilun, sector_num, *pnum);", "} else {", "iscsi_allocationmap_set(iscsilun, sector_num, *pnum);", "}", "if (*pnum > nb_sectors) {", "*pnum = nb_sectors;", "}", "out:\nif (iTask.task != NULL) {", "scsi_free_scsi_task(iTask.task);", "}", "if (ret > 0 && ret & BDRV_BLOCK_OFFSET_VALID) {", "*file = bs;", "}", "return ret;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 33 ], [ 39 ], [ 41 ], [ 43 ], [ 49 ], [ 51 ], [ 53 ], [ 57, 59, 61, 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 149, 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ] ]
20,146
static void vnc_tight_stop(VncState *vs) { // switch back to normal output/zlib buffers vs->tight = vs->output; vs->output = vs->tight_tmp; }
false
qemu
245f7b51c0ea04fb2224b1127430a096c91aee70
static void vnc_tight_stop(VncState *vs) { vs->tight = vs->output; vs->output = vs->tight_tmp; }
{ "code": [], "line_no": [] }
static void FUNC_0(VncState *VAR_0) { VAR_0->tight = VAR_0->output; VAR_0->output = VAR_0->tight_tmp; }
[ "static void FUNC_0(VncState *VAR_0)\n{", "VAR_0->tight = VAR_0->output;", "VAR_0->output = VAR_0->tight_tmp;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 7 ], [ 9 ], [ 11 ] ]
20,147
void aio_set_fd_handler(AioContext *ctx, int fd, bool is_external, IOHandler *io_read, IOHandler *io_write, AioPollFn *io_poll, void *opaque) { abort(); }
false
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
void aio_set_fd_handler(AioContext *ctx, int fd, bool is_external, IOHandler *io_read, IOHandler *io_write, AioPollFn *io_poll, void *opaque) { abort(); }
{ "code": [], "line_no": [] }
void FUNC_0(AioContext *VAR_0, int VAR_1, bool VAR_2, IOHandler *VAR_3, IOHandler *VAR_4, AioPollFn *VAR_5, void *VAR_6) { abort(); }
[ "void FUNC_0(AioContext *VAR_0,\nint VAR_1,\nbool VAR_2,\nIOHandler *VAR_3,\nIOHandler *VAR_4,\nAioPollFn *VAR_5,\nvoid *VAR_6)\n{", "abort();", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11, 13, 15 ], [ 17 ], [ 19 ] ]
20,149
int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, uint32_t vaddr, int is_write, int mmu_idx, uint32_t *paddr, uint32_t *page_size, unsigned *access) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { return get_physical_addr_mmu(env, update_tlb, vaddr, is_write, mmu_idx, paddr, page_size, access, true); } else if (xtensa_option_bits_enabled(env->config, XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION))) { return get_physical_addr_region(env, vaddr, is_write, mmu_idx, paddr, page_size, access); } else { *paddr = vaddr; *page_size = TARGET_PAGE_SIZE; *access = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_BYPASS; return 0; } }
false
qemu
4e41d2f5830a76d3fe92b3d3b18cc9f2ee927770
int xtensa_get_physical_addr(CPUXtensaState *env, bool update_tlb, uint32_t vaddr, int is_write, int mmu_idx, uint32_t *paddr, uint32_t *page_size, unsigned *access) { if (xtensa_option_enabled(env->config, XTENSA_OPTION_MMU)) { return get_physical_addr_mmu(env, update_tlb, vaddr, is_write, mmu_idx, paddr, page_size, access, true); } else if (xtensa_option_bits_enabled(env->config, XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION))) { return get_physical_addr_region(env, vaddr, is_write, mmu_idx, paddr, page_size, access); } else { *paddr = vaddr; *page_size = TARGET_PAGE_SIZE; *access = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_BYPASS; return 0; } }
{ "code": [], "line_no": [] }
int FUNC_0(CPUXtensaState *VAR_0, bool VAR_1, uint32_t VAR_2, int VAR_3, int VAR_4, uint32_t *VAR_5, uint32_t *VAR_6, unsigned *VAR_7) { if (xtensa_option_enabled(VAR_0->config, XTENSA_OPTION_MMU)) { return get_physical_addr_mmu(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, true); } else if (xtensa_option_bits_enabled(VAR_0->config, XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION))) { return get_physical_addr_region(VAR_0, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7); } else { *VAR_5 = VAR_2; *VAR_6 = TARGET_PAGE_SIZE; *VAR_7 = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_BYPASS; return 0; } }
[ "int FUNC_0(CPUXtensaState *VAR_0, bool VAR_1,\nuint32_t VAR_2, int VAR_3, int VAR_4,\nuint32_t *VAR_5, uint32_t *VAR_6, unsigned *VAR_7)\n{", "if (xtensa_option_enabled(VAR_0->config, XTENSA_OPTION_MMU)) {", "return get_physical_addr_mmu(VAR_0, VAR_1,\nVAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, true);", "} else if (xtensa_option_bits_enabled(VAR_0->config,", "XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) |\nXTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION))) {", "return get_physical_addr_region(VAR_0, VAR_2, VAR_3, VAR_4,\nVAR_5, VAR_6, VAR_7);", "} else {", "*VAR_5 = VAR_2;", "*VAR_6 = TARGET_PAGE_SIZE;", "*VAR_7 = PAGE_READ | PAGE_WRITE | PAGE_EXEC | PAGE_CACHE_BYPASS;", "return 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 ] ]
20,150
static int usb_msd_handle_control(USBDevice *dev, int request, int value, int index, int length, uint8_t *data) { MSDState *s = (MSDState *)dev; int ret; ret = usb_desc_handle_control(dev, request, value, index, length, data); if (ret >= 0) { return ret; } ret = 0; switch (request) { case DeviceRequest | USB_REQ_GET_STATUS: data[0] = (1 << USB_DEVICE_SELF_POWERED) | (dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP); data[1] = 0x00; ret = 2; break; case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 0; } else { goto fail; } ret = 0; break; case DeviceOutRequest | USB_REQ_SET_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 1; } else { goto fail; } ret = 0; break; case DeviceRequest | USB_REQ_GET_CONFIGURATION: data[0] = 1; ret = 1; break; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: ret = 0; break; case DeviceRequest | USB_REQ_GET_INTERFACE: data[0] = 0; ret = 1; break; case DeviceOutRequest | USB_REQ_SET_INTERFACE: ret = 0; break; case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: ret = 0; break; case InterfaceOutRequest | USB_REQ_SET_INTERFACE: ret = 0; break; /* Class specific requests. */ case ClassInterfaceOutRequest | MassStorageReset: /* Reset state ready for the next CBW. */ s->mode = USB_MSDM_CBW; ret = 0; break; case ClassInterfaceRequest | GetMaxLun: data[0] = 0; ret = 1; break; default: fail: ret = USB_RET_STALL; break; } return ret; }
false
qemu
a980a065fb5e86d6dec337e6cb6ff432f1a143c9
static int usb_msd_handle_control(USBDevice *dev, int request, int value, int index, int length, uint8_t *data) { MSDState *s = (MSDState *)dev; int ret; ret = usb_desc_handle_control(dev, request, value, index, length, data); if (ret >= 0) { return ret; } ret = 0; switch (request) { case DeviceRequest | USB_REQ_GET_STATUS: data[0] = (1 << USB_DEVICE_SELF_POWERED) | (dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP); data[1] = 0x00; ret = 2; break; case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 0; } else { goto fail; } ret = 0; break; case DeviceOutRequest | USB_REQ_SET_FEATURE: if (value == USB_DEVICE_REMOTE_WAKEUP) { dev->remote_wakeup = 1; } else { goto fail; } ret = 0; break; case DeviceRequest | USB_REQ_GET_CONFIGURATION: data[0] = 1; ret = 1; break; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: ret = 0; break; case DeviceRequest | USB_REQ_GET_INTERFACE: data[0] = 0; ret = 1; break; case DeviceOutRequest | USB_REQ_SET_INTERFACE: ret = 0; break; case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: ret = 0; break; case InterfaceOutRequest | USB_REQ_SET_INTERFACE: ret = 0; break; case ClassInterfaceOutRequest | MassStorageReset: s->mode = USB_MSDM_CBW; ret = 0; break; case ClassInterfaceRequest | GetMaxLun: data[0] = 0; ret = 1; break; default: fail: ret = USB_RET_STALL; break; } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(USBDevice *VAR_0, int VAR_1, int VAR_2, int VAR_3, int VAR_4, uint8_t *VAR_5) { MSDState *s = (MSDState *)VAR_0; int VAR_6; VAR_6 = usb_desc_handle_control(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5); if (VAR_6 >= 0) { return VAR_6; } VAR_6 = 0; switch (VAR_1) { case DeviceRequest | USB_REQ_GET_STATUS: VAR_5[0] = (1 << USB_DEVICE_SELF_POWERED) | (VAR_0->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP); VAR_5[1] = 0x00; VAR_6 = 2; break; case DeviceOutRequest | USB_REQ_CLEAR_FEATURE: if (VAR_2 == USB_DEVICE_REMOTE_WAKEUP) { VAR_0->remote_wakeup = 0; } else { goto fail; } VAR_6 = 0; break; case DeviceOutRequest | USB_REQ_SET_FEATURE: if (VAR_2 == USB_DEVICE_REMOTE_WAKEUP) { VAR_0->remote_wakeup = 1; } else { goto fail; } VAR_6 = 0; break; case DeviceRequest | USB_REQ_GET_CONFIGURATION: VAR_5[0] = 1; VAR_6 = 1; break; case DeviceOutRequest | USB_REQ_SET_CONFIGURATION: VAR_6 = 0; break; case DeviceRequest | USB_REQ_GET_INTERFACE: VAR_5[0] = 0; VAR_6 = 1; break; case DeviceOutRequest | USB_REQ_SET_INTERFACE: VAR_6 = 0; break; case EndpointOutRequest | USB_REQ_CLEAR_FEATURE: VAR_6 = 0; break; case InterfaceOutRequest | USB_REQ_SET_INTERFACE: VAR_6 = 0; break; case ClassInterfaceOutRequest | MassStorageReset: s->mode = USB_MSDM_CBW; VAR_6 = 0; break; case ClassInterfaceRequest | GetMaxLun: VAR_5[0] = 0; VAR_6 = 1; break; default: fail: VAR_6 = USB_RET_STALL; break; } return VAR_6; }
[ "static int FUNC_0(USBDevice *VAR_0, int VAR_1, int VAR_2,\nint VAR_3, int VAR_4, uint8_t *VAR_5)\n{", "MSDState *s = (MSDState *)VAR_0;", "int VAR_6;", "VAR_6 = usb_desc_handle_control(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5);", "if (VAR_6 >= 0) {", "return VAR_6;", "}", "VAR_6 = 0;", "switch (VAR_1) {", "case DeviceRequest | USB_REQ_GET_STATUS:\nVAR_5[0] = (1 << USB_DEVICE_SELF_POWERED) |\n(VAR_0->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);", "VAR_5[1] = 0x00;", "VAR_6 = 2;", "break;", "case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:\nif (VAR_2 == USB_DEVICE_REMOTE_WAKEUP) {", "VAR_0->remote_wakeup = 0;", "} else {", "goto fail;", "}", "VAR_6 = 0;", "break;", "case DeviceOutRequest | USB_REQ_SET_FEATURE:\nif (VAR_2 == USB_DEVICE_REMOTE_WAKEUP) {", "VAR_0->remote_wakeup = 1;", "} else {", "goto fail;", "}", "VAR_6 = 0;", "break;", "case DeviceRequest | USB_REQ_GET_CONFIGURATION:\nVAR_5[0] = 1;", "VAR_6 = 1;", "break;", "case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:\nVAR_6 = 0;", "break;", "case DeviceRequest | USB_REQ_GET_INTERFACE:\nVAR_5[0] = 0;", "VAR_6 = 1;", "break;", "case DeviceOutRequest | USB_REQ_SET_INTERFACE:\nVAR_6 = 0;", "break;", "case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:\nVAR_6 = 0;", "break;", "case InterfaceOutRequest | USB_REQ_SET_INTERFACE:\nVAR_6 = 0;", "break;", "case ClassInterfaceOutRequest | MassStorageReset:\ns->mode = USB_MSDM_CBW;", "VAR_6 = 0;", "break;", "case ClassInterfaceRequest | GetMaxLun:\nVAR_5[0] = 0;", "VAR_6 = 1;", "break;", "default:\nfail:\nVAR_6 = USB_RET_STALL;", "break;", "}", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 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 ], [ 103 ], [ 105, 107 ], [ 109 ], [ 113, 117 ], [ 119 ], [ 121 ], [ 123, 125 ], [ 127 ], [ 129 ], [ 131, 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ] ]
20,152
static int tftp_send_oack(struct tftp_session *spt, const char *keys[], uint32_t values[], int nb, struct tftp_t *recv_tp) { struct sockaddr_in saddr, daddr; struct mbuf *m; struct tftp_t *tp; int i, n = 0; m = m_get(spt->slirp); if (!m) return -1; 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_OACK); for (i = 0; i < nb; i++) { n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s", keys[i]) + 1; n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u", values[i]) + 1; } 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 + n - sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); return 0; }
false
qemu
5379229a2708df3a1506113315214c3ce5325859
static int tftp_send_oack(struct tftp_session *spt, const char *keys[], uint32_t values[], int nb, struct tftp_t *recv_tp) { struct sockaddr_in saddr, daddr; struct mbuf *m; struct tftp_t *tp; int i, n = 0; m = m_get(spt->slirp); if (!m) return -1; 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_OACK); for (i = 0; i < nb; i++) { n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s", keys[i]) + 1; n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u", values[i]) + 1; } 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 + n - sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(struct tftp_session *VAR_0, const char *VAR_1[], uint32_t VAR_2[], int VAR_3, struct tftp_t *VAR_4) { struct sockaddr_in VAR_5, VAR_6; struct mbuf *VAR_7; struct tftp_t *VAR_8; int VAR_9, VAR_10 = 0; VAR_7 = m_get(VAR_0->slirp); if (!VAR_7) return -1; memset(VAR_7->m_data, 0, VAR_7->m_size); VAR_7->m_data += IF_MAXLINKHDR; VAR_8 = (void *)VAR_7->m_data; VAR_7->m_data += sizeof(struct udpiphdr); VAR_8->tp_op = htons(TFTP_OACK); for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9++) { VAR_10 += snprintf(VAR_8->x.tp_buf + VAR_10, sizeof(VAR_8->x.tp_buf) - VAR_10, "%s", VAR_1[VAR_9]) + 1; VAR_10 += snprintf(VAR_8->x.tp_buf + VAR_10, sizeof(VAR_8->x.tp_buf) - VAR_10, "%u", VAR_2[VAR_9]) + 1; } VAR_5.sin_addr = VAR_4->ip.ip_dst; VAR_5.sin_port = VAR_4->udp.uh_dport; VAR_6.sin_addr = VAR_0->client_ip; VAR_6.sin_port = VAR_0->client_port; VAR_7->m_len = sizeof(struct tftp_t) - 514 + VAR_10 - sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, VAR_7, &VAR_5, &VAR_6, IPTOS_LOWDELAY); return 0; }
[ "static int FUNC_0(struct tftp_session *VAR_0,\nconst char *VAR_1[], uint32_t VAR_2[], int VAR_3,\nstruct tftp_t *VAR_4)\n{", "struct sockaddr_in VAR_5, VAR_6;", "struct mbuf *VAR_7;", "struct tftp_t *VAR_8;", "int VAR_9, VAR_10 = 0;", "VAR_7 = m_get(VAR_0->slirp);", "if (!VAR_7)\nreturn -1;", "memset(VAR_7->m_data, 0, VAR_7->m_size);", "VAR_7->m_data += IF_MAXLINKHDR;", "VAR_8 = (void *)VAR_7->m_data;", "VAR_7->m_data += sizeof(struct udpiphdr);", "VAR_8->tp_op = htons(TFTP_OACK);", "for (VAR_9 = 0; VAR_9 < VAR_3; VAR_9++) {", "VAR_10 += snprintf(VAR_8->x.tp_buf + VAR_10, sizeof(VAR_8->x.tp_buf) - VAR_10, \"%s\",\nVAR_1[VAR_9]) + 1;", "VAR_10 += snprintf(VAR_8->x.tp_buf + VAR_10, sizeof(VAR_8->x.tp_buf) - VAR_10, \"%u\",\nVAR_2[VAR_9]) + 1;", "}", "VAR_5.sin_addr = VAR_4->ip.ip_dst;", "VAR_5.sin_port = VAR_4->udp.uh_dport;", "VAR_6.sin_addr = VAR_0->client_ip;", "VAR_6.sin_port = VAR_0->client_port;", "VAR_7->m_len = sizeof(struct tftp_t) - 514 + VAR_10 -\nsizeof(struct ip) - sizeof(struct udphdr);", "udp_output2(NULL, VAR_7, &VAR_5, &VAR_6, IPTOS_LOWDELAY);", "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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23, 25 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49, 51 ], [ 53 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 69, 71 ], [ 73 ], [ 77 ], [ 79 ] ]
20,153
void check_audio_video_inputs(int *has_video_ptr, int *has_audio_ptr) { int has_video, has_audio, i, j; AVFormatContext *ic; has_video = 0; has_audio = 0; for(j=0;j<nb_input_files;j++) { ic = input_files[j]; for(i=0;i<ic->nb_streams;i++) { AVCodecContext *enc = &ic->streams[i]->codec; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: has_audio = 1; break; case CODEC_TYPE_VIDEO: has_video = 1; break; default: abort(); } } } *has_video_ptr = has_video; *has_audio_ptr = has_audio; }
false
FFmpeg
c04643a2c24564aed96a5b0760de8bf02eb305c6
void check_audio_video_inputs(int *has_video_ptr, int *has_audio_ptr) { int has_video, has_audio, i, j; AVFormatContext *ic; has_video = 0; has_audio = 0; for(j=0;j<nb_input_files;j++) { ic = input_files[j]; for(i=0;i<ic->nb_streams;i++) { AVCodecContext *enc = &ic->streams[i]->codec; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: has_audio = 1; break; case CODEC_TYPE_VIDEO: has_video = 1; break; default: abort(); } } } *has_video_ptr = has_video; *has_audio_ptr = has_audio; }
{ "code": [], "line_no": [] }
void FUNC_0(int *VAR_0, int *VAR_1) { int VAR_2, VAR_3, VAR_4, VAR_5; AVFormatContext *ic; VAR_2 = 0; VAR_3 = 0; for(VAR_5=0;VAR_5<nb_input_files;VAR_5++) { ic = input_files[VAR_5]; for(VAR_4=0;VAR_4<ic->nb_streams;VAR_4++) { AVCodecContext *enc = &ic->streams[VAR_4]->codec; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: VAR_3 = 1; break; case CODEC_TYPE_VIDEO: VAR_2 = 1; break; default: abort(); } } } *VAR_0 = VAR_2; *VAR_1 = VAR_3; }
[ "void FUNC_0(int *VAR_0, int *VAR_1)\n{", "int VAR_2, VAR_3, VAR_4, VAR_5;", "AVFormatContext *ic;", "VAR_2 = 0;", "VAR_3 = 0;", "for(VAR_5=0;VAR_5<nb_input_files;VAR_5++) {", "ic = input_files[VAR_5];", "for(VAR_4=0;VAR_4<ic->nb_streams;VAR_4++) {", "AVCodecContext *enc = &ic->streams[VAR_4]->codec;", "switch(enc->codec_type) {", "case CODEC_TYPE_AUDIO:\nVAR_3 = 1;", "break;", "case CODEC_TYPE_VIDEO:\nVAR_2 = 1;", "break;", "default:\nabort();", "}", "}", "}", "*VAR_0 = VAR_2;", "*VAR_1 = VAR_3;", "}" ]
[ 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 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
20,154
static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { BDRVQcow2State *s = bs->opaque; int l2_index; uint64_t *l2_table; uint64_t entry; unsigned int nb_clusters; int ret; uint64_t alloc_cluster_offset; trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset, *bytes); assert(*bytes > 0); /* * Calculate the number of clusters to look for. We stop at L2 table * boundaries to keep things simple. */ nb_clusters = size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); /* Find L2 entry for the first involved cluster */ ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); if (ret < 0) { return ret; } entry = be64_to_cpu(l2_table[l2_index]); /* For the moment, overwrite compressed clusters one by one */ if (entry & QCOW_OFLAG_COMPRESSED) { nb_clusters = 1; } else { nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index); } /* This function is only called when there were no non-COW clusters, so if * we can't find any unallocated or COW clusters either, something is * wrong with our code. */ assert(nb_clusters > 0); qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); /* Allocate, if necessary at a given offset in the image file */ alloc_cluster_offset = start_of_cluster(s, *host_offset); ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset, &nb_clusters); if (ret < 0) { goto fail; } /* Can't extend contiguous allocation */ if (nb_clusters == 0) { *bytes = 0; return 0; } /* !*host_offset would overwrite the image header and is reserved for "no * host offset preferred". If 0 was a valid host offset, it'd trigger the * following overlap check; do that now to avoid having an invalid value in * *host_offset. */ if (!alloc_cluster_offset) { ret = qcow2_pre_write_overlap_check(bs, 0, alloc_cluster_offset, nb_clusters * s->cluster_size); assert(ret < 0); goto fail; } /* * Save info needed for meta data update. * * requested_sectors: Number of sectors from the start of the first * newly allocated cluster to the end of the (possibly shortened * before) write request. * * avail_sectors: Number of sectors from the start of the first * newly allocated to the end of the last newly allocated cluster. * * nb_sectors: The number of sectors from the start of the first * newly allocated cluster to the end of the area that the write * request actually writes to (excluding COW at the end) */ int requested_sectors = (*bytes + offset_into_cluster(s, guest_offset)) >> BDRV_SECTOR_BITS; int avail_sectors = nb_clusters << (s->cluster_bits - BDRV_SECTOR_BITS); int alloc_n_start = offset_into_cluster(s, guest_offset) >> BDRV_SECTOR_BITS; int nb_sectors = MIN(requested_sectors, avail_sectors); QCowL2Meta *old_m = *m; *m = g_malloc0(sizeof(**m)); **m = (QCowL2Meta) { .next = old_m, .alloc_offset = alloc_cluster_offset, .offset = start_of_cluster(s, guest_offset), .nb_clusters = nb_clusters, .nb_available = nb_sectors, .cow_start = { .offset = 0, .nb_sectors = alloc_n_start, }, .cow_end = { .offset = nb_sectors * BDRV_SECTOR_SIZE, .nb_sectors = avail_sectors - nb_sectors, }, }; qemu_co_queue_init(&(*m)->dependent_requests); QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); *host_offset = alloc_cluster_offset + offset_into_cluster(s, guest_offset); *bytes = MIN(*bytes, (nb_sectors * BDRV_SECTOR_SIZE) - offset_into_cluster(s, guest_offset)); assert(*bytes != 0); return 1; fail: if (*m && (*m)->nb_clusters > 0) { QLIST_REMOVE(*m, next_in_flight); } return ret; }
false
qemu
b6d36def6d9e9fd187327182d0abafc9b7085d8f
static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m) { BDRVQcow2State *s = bs->opaque; int l2_index; uint64_t *l2_table; uint64_t entry; unsigned int nb_clusters; int ret; uint64_t alloc_cluster_offset; trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset, *bytes); assert(*bytes > 0); nb_clusters = size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes); l2_index = offset_to_l2_index(s, guest_offset); nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index); if (ret < 0) { return ret; } entry = be64_to_cpu(l2_table[l2_index]); if (entry & QCOW_OFLAG_COMPRESSED) { nb_clusters = 1; } else { nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index); } assert(nb_clusters > 0); qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); alloc_cluster_offset = start_of_cluster(s, *host_offset); ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset, &nb_clusters); if (ret < 0) { goto fail; } if (nb_clusters == 0) { *bytes = 0; return 0; } if (!alloc_cluster_offset) { ret = qcow2_pre_write_overlap_check(bs, 0, alloc_cluster_offset, nb_clusters * s->cluster_size); assert(ret < 0); goto fail; } int requested_sectors = (*bytes + offset_into_cluster(s, guest_offset)) >> BDRV_SECTOR_BITS; int avail_sectors = nb_clusters << (s->cluster_bits - BDRV_SECTOR_BITS); int alloc_n_start = offset_into_cluster(s, guest_offset) >> BDRV_SECTOR_BITS; int nb_sectors = MIN(requested_sectors, avail_sectors); QCowL2Meta *old_m = *m; *m = g_malloc0(sizeof(**m)); **m = (QCowL2Meta) { .next = old_m, .alloc_offset = alloc_cluster_offset, .offset = start_of_cluster(s, guest_offset), .nb_clusters = nb_clusters, .nb_available = nb_sectors, .cow_start = { .offset = 0, .nb_sectors = alloc_n_start, }, .cow_end = { .offset = nb_sectors * BDRV_SECTOR_SIZE, .nb_sectors = avail_sectors - nb_sectors, }, }; qemu_co_queue_init(&(*m)->dependent_requests); QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight); *host_offset = alloc_cluster_offset + offset_into_cluster(s, guest_offset); *bytes = MIN(*bytes, (nb_sectors * BDRV_SECTOR_SIZE) - offset_into_cluster(s, guest_offset)); assert(*bytes != 0); return 1; fail: if (*m && (*m)->nb_clusters > 0) { QLIST_REMOVE(*m, next_in_flight); } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t *VAR_2, uint64_t *VAR_3, QCowL2Meta **VAR_4) { BDRVQcow2State *s = VAR_0->opaque; int VAR_5; uint64_t *l2_table; uint64_t entry; unsigned int VAR_6; int VAR_7; uint64_t alloc_cluster_offset; trace_qcow2_handle_alloc(qemu_coroutine_self(), VAR_1, *VAR_2, *VAR_3); assert(*VAR_3 > 0); VAR_6 = size_to_clusters(s, offset_into_cluster(s, VAR_1) + *VAR_3); VAR_5 = offset_to_l2_index(s, VAR_1); VAR_6 = MIN(VAR_6, s->l2_size - VAR_5); VAR_7 = get_cluster_table(VAR_0, VAR_1, &l2_table, &VAR_5); if (VAR_7 < 0) { return VAR_7; } entry = be64_to_cpu(l2_table[VAR_5]); if (entry & QCOW_OFLAG_COMPRESSED) { VAR_6 = 1; } else { VAR_6 = count_cow_clusters(s, VAR_6, l2_table, VAR_5); } assert(VAR_6 > 0); qcow2_cache_put(VAR_0, s->l2_table_cache, (void **) &l2_table); alloc_cluster_offset = start_of_cluster(s, *VAR_2); VAR_7 = do_alloc_cluster_offset(VAR_0, VAR_1, &alloc_cluster_offset, &VAR_6); if (VAR_7 < 0) { goto fail; } if (VAR_6 == 0) { *VAR_3 = 0; return 0; } if (!alloc_cluster_offset) { VAR_7 = qcow2_pre_write_overlap_check(VAR_0, 0, alloc_cluster_offset, VAR_6 * s->cluster_size); assert(VAR_7 < 0); goto fail; } int VAR_8 = (*VAR_3 + offset_into_cluster(s, VAR_1)) >> BDRV_SECTOR_BITS; int VAR_9 = VAR_6 << (s->cluster_bits - BDRV_SECTOR_BITS); int VAR_10 = offset_into_cluster(s, VAR_1) >> BDRV_SECTOR_BITS; int VAR_11 = MIN(VAR_8, VAR_9); QCowL2Meta *old_m = *VAR_4; *VAR_4 = g_malloc0(sizeof(**VAR_4)); **VAR_4 = (QCowL2Meta) { .next = old_m, .alloc_offset = alloc_cluster_offset, .offset = start_of_cluster(s, VAR_1), .VAR_6 = VAR_6, .nb_available = VAR_11, .cow_start = { .offset = 0, .VAR_11 = VAR_10, }, .cow_end = { .offset = VAR_11 * BDRV_SECTOR_SIZE, .VAR_11 = VAR_9 - VAR_11, }, }; qemu_co_queue_init(&(*VAR_4)->dependent_requests); QLIST_INSERT_HEAD(&s->cluster_allocs, *VAR_4, next_in_flight); *VAR_2 = alloc_cluster_offset + offset_into_cluster(s, VAR_1); *VAR_3 = MIN(*VAR_3, (VAR_11 * BDRV_SECTOR_SIZE) - offset_into_cluster(s, VAR_1)); assert(*VAR_3 != 0); return 1; fail: if (*VAR_4 && (*VAR_4)->VAR_6 > 0) { QLIST_REMOVE(*VAR_4, next_in_flight); } return VAR_7; }
[ "static int FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1,\nuint64_t *VAR_2, uint64_t *VAR_3, QCowL2Meta **VAR_4)\n{", "BDRVQcow2State *s = VAR_0->opaque;", "int VAR_5;", "uint64_t *l2_table;", "uint64_t entry;", "unsigned int VAR_6;", "int VAR_7;", "uint64_t alloc_cluster_offset;", "trace_qcow2_handle_alloc(qemu_coroutine_self(), VAR_1, *VAR_2,\n*VAR_3);", "assert(*VAR_3 > 0);", "VAR_6 =\nsize_to_clusters(s, offset_into_cluster(s, VAR_1) + *VAR_3);", "VAR_5 = offset_to_l2_index(s, VAR_1);", "VAR_6 = MIN(VAR_6, s->l2_size - VAR_5);", "VAR_7 = get_cluster_table(VAR_0, VAR_1, &l2_table, &VAR_5);", "if (VAR_7 < 0) {", "return VAR_7;", "}", "entry = be64_to_cpu(l2_table[VAR_5]);", "if (entry & QCOW_OFLAG_COMPRESSED) {", "VAR_6 = 1;", "} else {", "VAR_6 = count_cow_clusters(s, VAR_6, l2_table, VAR_5);", "}", "assert(VAR_6 > 0);", "qcow2_cache_put(VAR_0, s->l2_table_cache, (void **) &l2_table);", "alloc_cluster_offset = start_of_cluster(s, *VAR_2);", "VAR_7 = do_alloc_cluster_offset(VAR_0, VAR_1, &alloc_cluster_offset,\n&VAR_6);", "if (VAR_7 < 0) {", "goto fail;", "}", "if (VAR_6 == 0) {", "*VAR_3 = 0;", "return 0;", "}", "if (!alloc_cluster_offset) {", "VAR_7 = qcow2_pre_write_overlap_check(VAR_0, 0, alloc_cluster_offset,\nVAR_6 * s->cluster_size);", "assert(VAR_7 < 0);", "goto fail;", "}", "int VAR_8 =\n(*VAR_3 + offset_into_cluster(s, VAR_1))\n>> BDRV_SECTOR_BITS;", "int VAR_9 = VAR_6\n<< (s->cluster_bits - BDRV_SECTOR_BITS);", "int VAR_10 = offset_into_cluster(s, VAR_1)\n>> BDRV_SECTOR_BITS;", "int VAR_11 = MIN(VAR_8, VAR_9);", "QCowL2Meta *old_m = *VAR_4;", "*VAR_4 = g_malloc0(sizeof(**VAR_4));", "**VAR_4 = (QCowL2Meta) {", ".next = old_m,\n.alloc_offset = alloc_cluster_offset,\n.offset = start_of_cluster(s, VAR_1),\n.VAR_6 = VAR_6,\n.nb_available = VAR_11,\n.cow_start = {", ".offset = 0,\n.VAR_11 = VAR_10,\n},", ".cow_end = {", ".offset = VAR_11 * BDRV_SECTOR_SIZE,\n.VAR_11 = VAR_9 - VAR_11,\n},", "};", "qemu_co_queue_init(&(*VAR_4)->dependent_requests);", "QLIST_INSERT_HEAD(&s->cluster_allocs, *VAR_4, next_in_flight);", "*VAR_2 = alloc_cluster_offset + offset_into_cluster(s, VAR_1);", "*VAR_3 = MIN(*VAR_3, (VAR_11 * BDRV_SECTOR_SIZE)\n- offset_into_cluster(s, VAR_1));", "assert(*VAR_3 != 0);", "return 1;", "fail:\nif (*VAR_4 && (*VAR_4)->VAR_6 > 0) {", "QLIST_REMOVE(*VAR_4, next_in_flight);", "}", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25, 27 ], [ 29 ], [ 41, 43 ], [ 47 ], [ 49 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 89 ], [ 93 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 175, 177, 179 ], [ 181, 183 ], [ 185, 187 ], [ 189 ], [ 191 ], [ 195 ], [ 199 ], [ 201, 205, 207, 209, 211, 215 ], [ 217, 219, 221 ], [ 223 ], [ 225, 227, 229 ], [ 231 ], [ 233 ], [ 235 ], [ 239 ], [ 241, 243 ], [ 245 ], [ 249 ], [ 253, 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ] ]
20,155
static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, const char *model, const char *name, const char *ifname, const char *script, const char *downscript, const char *vhostfdname, int vnet_hdr, int fd, Error **errp) { Error *err = NULL; TAPState *s = net_tap_fd_init(peer, model, name, fd, vnet_hdr); int vhostfd; tap_set_sndbuf(s->fd, tap, &err); if (err) { error_propagate(errp, err); return; } if (tap->has_fd || tap->has_fds) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd); } else if (tap->has_helper) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s", tap->helper); } else { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "ifname=%s,script=%s,downscript=%s", ifname, script, downscript); if (strcmp(downscript, "no") != 0) { snprintf(s->down_script, sizeof(s->down_script), "%s", downscript); snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname); } } if (tap->has_vhost ? tap->vhost : vhostfdname || (tap->has_vhostforce && tap->vhostforce)) { VhostNetOptions options; options.backend_type = VHOST_BACKEND_TYPE_KERNEL; options.net_backend = &s->nc; if (tap->has_vhostfd || tap->has_vhostfds) { vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err); if (vhostfd == -1) { error_propagate(errp, err); return; } } else { vhostfd = open("/dev/vhost-net", O_RDWR); if (vhostfd < 0) { error_setg_errno(errp, errno, "tap: open vhost char device failed"); return; } } options.opaque = (void *)(uintptr_t)vhostfd; s->vhost_net = vhost_net_init(&options); if (!s->vhost_net) { error_setg(errp, "vhost-net requested but could not be initialized"); return; } } else if (tap->has_vhostfd || tap->has_vhostfds) { error_setg(errp, "vhostfd= is not valid without vhost"); } }
false
qemu
3a2d44f6dd1d6cc1e5a5ebfa736a72e035c41d1b
static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, const char *model, const char *name, const char *ifname, const char *script, const char *downscript, const char *vhostfdname, int vnet_hdr, int fd, Error **errp) { Error *err = NULL; TAPState *s = net_tap_fd_init(peer, model, name, fd, vnet_hdr); int vhostfd; tap_set_sndbuf(s->fd, tap, &err); if (err) { error_propagate(errp, err); return; } if (tap->has_fd || tap->has_fds) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd); } else if (tap->has_helper) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s", tap->helper); } else { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "ifname=%s,script=%s,downscript=%s", ifname, script, downscript); if (strcmp(downscript, "no") != 0) { snprintf(s->down_script, sizeof(s->down_script), "%s", downscript); snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname); } } if (tap->has_vhost ? tap->vhost : vhostfdname || (tap->has_vhostforce && tap->vhostforce)) { VhostNetOptions options; options.backend_type = VHOST_BACKEND_TYPE_KERNEL; options.net_backend = &s->nc; if (tap->has_vhostfd || tap->has_vhostfds) { vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err); if (vhostfd == -1) { error_propagate(errp, err); return; } } else { vhostfd = open("/dev/vhost-net", O_RDWR); if (vhostfd < 0) { error_setg_errno(errp, errno, "tap: open vhost char device failed"); return; } } options.opaque = (void *)(uintptr_t)vhostfd; s->vhost_net = vhost_net_init(&options); if (!s->vhost_net) { error_setg(errp, "vhost-net requested but could not be initialized"); return; } } else if (tap->has_vhostfd || tap->has_vhostfds) { error_setg(errp, "vhostfd= is not valid without vhost"); } }
{ "code": [], "line_no": [] }
static void FUNC_0(const NetdevTapOptions *VAR_0, NetClientState *VAR_1, const char *VAR_2, const char *VAR_3, const char *VAR_4, const char *VAR_5, const char *VAR_6, const char *VAR_7, int VAR_8, int VAR_9, Error **VAR_10) { Error *err = NULL; TAPState *s = net_tap_fd_init(VAR_1, VAR_2, VAR_3, VAR_9, VAR_8); int VAR_11; tap_set_sndbuf(s->VAR_9, VAR_0, &err); if (err) { error_propagate(VAR_10, err); return; } if (VAR_0->has_fd || VAR_0->has_fds) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "VAR_9=%d", VAR_9); } else if (VAR_0->has_helper) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s", VAR_0->helper); } else { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "VAR_4=%s,VAR_5=%s,VAR_6=%s", VAR_4, VAR_5, VAR_6); if (strcmp(VAR_6, "no") != 0) { snprintf(s->down_script, sizeof(s->down_script), "%s", VAR_6); snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", VAR_4); } } if (VAR_0->has_vhost ? VAR_0->vhost : VAR_7 || (VAR_0->has_vhostforce && VAR_0->vhostforce)) { VhostNetOptions options; options.backend_type = VHOST_BACKEND_TYPE_KERNEL; options.net_backend = &s->nc; if (VAR_0->has_vhostfd || VAR_0->has_vhostfds) { VAR_11 = monitor_fd_param(cur_mon, VAR_7, &err); if (VAR_11 == -1) { error_propagate(VAR_10, err); return; } } else { VAR_11 = open("/dev/vhost-net", O_RDWR); if (VAR_11 < 0) { error_setg_errno(VAR_10, errno, "VAR_0: open vhost char device failed"); return; } } options.opaque = (void *)(uintptr_t)VAR_11; s->vhost_net = vhost_net_init(&options); if (!s->vhost_net) { error_setg(VAR_10, "vhost-net requested but could not be initialized"); return; } } else if (VAR_0->has_vhostfd || VAR_0->has_vhostfds) { error_setg(VAR_10, "VAR_11= is not valid without vhost"); } }
[ "static void FUNC_0(const NetdevTapOptions *VAR_0, NetClientState *VAR_1,\nconst char *VAR_2, const char *VAR_3,\nconst char *VAR_4, const char *VAR_5,\nconst char *VAR_6, const char *VAR_7,\nint VAR_8, int VAR_9, Error **VAR_10)\n{", "Error *err = NULL;", "TAPState *s = net_tap_fd_init(VAR_1, VAR_2, VAR_3, VAR_9, VAR_8);", "int VAR_11;", "tap_set_sndbuf(s->VAR_9, VAR_0, &err);", "if (err) {", "error_propagate(VAR_10, err);", "return;", "}", "if (VAR_0->has_fd || VAR_0->has_fds) {", "snprintf(s->nc.info_str, sizeof(s->nc.info_str), \"VAR_9=%d\", VAR_9);", "} else if (VAR_0->has_helper) {", "snprintf(s->nc.info_str, sizeof(s->nc.info_str), \"helper=%s\",\nVAR_0->helper);", "} else {", "snprintf(s->nc.info_str, sizeof(s->nc.info_str),\n\"VAR_4=%s,VAR_5=%s,VAR_6=%s\", VAR_4, VAR_5,\nVAR_6);", "if (strcmp(VAR_6, \"no\") != 0) {", "snprintf(s->down_script, sizeof(s->down_script), \"%s\", VAR_6);", "snprintf(s->down_script_arg, sizeof(s->down_script_arg),\n\"%s\", VAR_4);", "}", "}", "if (VAR_0->has_vhost ? VAR_0->vhost :\nVAR_7 || (VAR_0->has_vhostforce && VAR_0->vhostforce)) {", "VhostNetOptions options;", "options.backend_type = VHOST_BACKEND_TYPE_KERNEL;", "options.net_backend = &s->nc;", "if (VAR_0->has_vhostfd || VAR_0->has_vhostfds) {", "VAR_11 = monitor_fd_param(cur_mon, VAR_7, &err);", "if (VAR_11 == -1) {", "error_propagate(VAR_10, err);", "return;", "}", "} else {", "VAR_11 = open(\"/dev/vhost-net\", O_RDWR);", "if (VAR_11 < 0) {", "error_setg_errno(VAR_10, errno,\n\"VAR_0: open vhost char device failed\");", "return;", "}", "}", "options.opaque = (void *)(uintptr_t)VAR_11;", "s->vhost_net = vhost_net_init(&options);", "if (!s->vhost_net) {", "error_setg(VAR_10,\n\"vhost-net requested but could not be initialized\");", "return;", "}", "} else if (VAR_0->has_vhostfd || VAR_0->has_vhostfds) {", "error_setg(VAR_10, \"VAR_11= is not valid without vhost\");", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45, 47, 49 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 67, 69 ], [ 71 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ], [ 117, 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ] ]
20,156
static int virtio_balloon_init_pci(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); VirtIODevice *vdev; vdev = virtio_balloon_init(&pci_dev->qdev); virtio_init_pci(proxy, vdev, PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BALLOON, PCI_CLASS_MEMORY_RAM, 0x00); return 0; }
false
qemu
e75ccf2c033fb0503d6cb7ddd0fd1dfa0aa4fc16
static int virtio_balloon_init_pci(PCIDevice *pci_dev) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); VirtIODevice *vdev; vdev = virtio_balloon_init(&pci_dev->qdev); virtio_init_pci(proxy, vdev, PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BALLOON, PCI_CLASS_MEMORY_RAM, 0x00); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(PCIDevice *VAR_0) { VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, VAR_0, VAR_0); VirtIODevice *vdev; vdev = virtio_balloon_init(&VAR_0->qdev); virtio_init_pci(proxy, vdev, PCI_VENDOR_ID_REDHAT_QUMRANET, PCI_DEVICE_ID_VIRTIO_BALLOON, PCI_CLASS_MEMORY_RAM, 0x00); return 0; }
[ "static int FUNC_0(PCIDevice *VAR_0)\n{", "VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, VAR_0, VAR_0);", "VirtIODevice *vdev;", "vdev = virtio_balloon_init(&VAR_0->qdev);", "virtio_init_pci(proxy, vdev,\nPCI_VENDOR_ID_REDHAT_QUMRANET,\nPCI_DEVICE_ID_VIRTIO_BALLOON,\nPCI_CLASS_MEMORY_RAM,\n0x00);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15, 17, 19, 21 ], [ 23 ], [ 25 ] ]
20,157
static void bochs_refresh_limits(BlockDriverState *bs, Error **errp) { bs->request_alignment = BDRV_SECTOR_SIZE; /* No sub-sector I/O supported */ }
false
qemu
a5b8dd2ce83208cd7d6eb4562339ecf5aae13574
static void bochs_refresh_limits(BlockDriverState *bs, Error **errp) { bs->request_alignment = BDRV_SECTOR_SIZE; }
{ "code": [], "line_no": [] }
static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1) { VAR_0->request_alignment = BDRV_SECTOR_SIZE; }
[ "static void FUNC_0(BlockDriverState *VAR_0, Error **VAR_1)\n{", "VAR_0->request_alignment = BDRV_SECTOR_SIZE;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
20,159
static void spr_write_sdr1 (void *opaque, int sprn) { DisasContext *ctx = opaque; gen_op_store_sdr1(); RET_STOP(ctx); }
false
qemu
e1833e1f96456fd8fc17463246fe0b2050e68efb
static void spr_write_sdr1 (void *opaque, int sprn) { DisasContext *ctx = opaque; gen_op_store_sdr1(); RET_STOP(ctx); }
{ "code": [], "line_no": [] }
static void FUNC_0 (void *VAR_0, int VAR_1) { DisasContext *ctx = VAR_0; gen_op_store_sdr1(); RET_STOP(ctx); }
[ "static void FUNC_0 (void *VAR_0, int VAR_1)\n{", "DisasContext *ctx = VAR_0;", "gen_op_store_sdr1();", "RET_STOP(ctx);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ] ]
20,160
static int uart_can_receive(void *opaque) { UartState *s = (UartState *)opaque; return RX_FIFO_SIZE - s->rx_count; }
false
qemu
d0ac820fe4152ea3a57fc3fa9f732cc9524017a4
static int uart_can_receive(void *opaque) { UartState *s = (UartState *)opaque; return RX_FIFO_SIZE - s->rx_count; }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0) { UartState *s = (UartState *)VAR_0; return RX_FIFO_SIZE - s->rx_count; }
[ "static int FUNC_0(void *VAR_0)\n{", "UartState *s = (UartState *)VAR_0;", "return RX_FIFO_SIZE - s->rx_count;", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ] ]
20,161
vmdk_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVVmdkState *s = bs->opaque; int ret; uint64_t n_bytes, offset_in_cluster; VmdkExtent *extent = NULL; QEMUIOVector local_qiov; uint64_t cluster_offset; uint64_t bytes_done = 0; qemu_iovec_init(&local_qiov, qiov->niov); qemu_co_mutex_lock(&s->lock); while (bytes > 0) { extent = find_extent(s, offset >> BDRV_SECTOR_BITS, extent); if (!extent) { ret = -EIO; goto fail; } ret = get_cluster_offset(bs, extent, NULL, offset, false, &cluster_offset, 0, 0); offset_in_cluster = vmdk_find_offset_in_cluster(extent, offset); n_bytes = MIN(bytes, extent->cluster_sectors * BDRV_SECTOR_SIZE - offset_in_cluster); if (ret != VMDK_OK) { /* if not allocated, try to read from parent image, if exist */ if (bs->backing && ret != VMDK_ZEROED) { if (!vmdk_is_cid_valid(bs)) { ret = -EINVAL; goto fail; } qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes); ret = bdrv_co_preadv(bs->backing->bs, offset, n_bytes, &local_qiov, 0); if (ret < 0) { goto fail; } } else { qemu_iovec_memset(qiov, bytes_done, 0, n_bytes); } } else { qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes); ret = vmdk_read_extent(extent, cluster_offset, offset_in_cluster, &local_qiov, n_bytes); if (ret) { goto fail; } } bytes -= n_bytes; offset += n_bytes; bytes_done += n_bytes; } ret = 0; fail: qemu_co_mutex_unlock(&s->lock); qemu_iovec_destroy(&local_qiov); return ret; }
false
qemu
a03ef88f77af045a2eb9629b5ce774a3fb973c5e
vmdk_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVVmdkState *s = bs->opaque; int ret; uint64_t n_bytes, offset_in_cluster; VmdkExtent *extent = NULL; QEMUIOVector local_qiov; uint64_t cluster_offset; uint64_t bytes_done = 0; qemu_iovec_init(&local_qiov, qiov->niov); qemu_co_mutex_lock(&s->lock); while (bytes > 0) { extent = find_extent(s, offset >> BDRV_SECTOR_BITS, extent); if (!extent) { ret = -EIO; goto fail; } ret = get_cluster_offset(bs, extent, NULL, offset, false, &cluster_offset, 0, 0); offset_in_cluster = vmdk_find_offset_in_cluster(extent, offset); n_bytes = MIN(bytes, extent->cluster_sectors * BDRV_SECTOR_SIZE - offset_in_cluster); if (ret != VMDK_OK) { if (bs->backing && ret != VMDK_ZEROED) { if (!vmdk_is_cid_valid(bs)) { ret = -EINVAL; goto fail; } qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes); ret = bdrv_co_preadv(bs->backing->bs, offset, n_bytes, &local_qiov, 0); if (ret < 0) { goto fail; } } else { qemu_iovec_memset(qiov, bytes_done, 0, n_bytes); } } else { qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes); ret = vmdk_read_extent(extent, cluster_offset, offset_in_cluster, &local_qiov, n_bytes); if (ret) { goto fail; } } bytes -= n_bytes; offset += n_bytes; bytes_done += n_bytes; } ret = 0; fail: qemu_co_mutex_unlock(&s->lock); qemu_iovec_destroy(&local_qiov); return ret; }
{ "code": [], "line_no": [] }
FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t VAR_2, QEMUIOVector *VAR_3, int VAR_4) { BDRVVmdkState *s = VAR_0->opaque; int VAR_5; uint64_t n_bytes, offset_in_cluster; VmdkExtent *extent = NULL; QEMUIOVector local_qiov; uint64_t cluster_offset; uint64_t bytes_done = 0; qemu_iovec_init(&local_qiov, VAR_3->niov); qemu_co_mutex_lock(&s->lock); while (VAR_2 > 0) { extent = find_extent(s, VAR_1 >> BDRV_SECTOR_BITS, extent); if (!extent) { VAR_5 = -EIO; goto fail; } VAR_5 = get_cluster_offset(VAR_0, extent, NULL, VAR_1, false, &cluster_offset, 0, 0); offset_in_cluster = vmdk_find_offset_in_cluster(extent, VAR_1); n_bytes = MIN(VAR_2, extent->cluster_sectors * BDRV_SECTOR_SIZE - offset_in_cluster); if (VAR_5 != VMDK_OK) { if (VAR_0->backing && VAR_5 != VMDK_ZEROED) { if (!vmdk_is_cid_valid(VAR_0)) { VAR_5 = -EINVAL; goto fail; } qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, VAR_3, bytes_done, n_bytes); VAR_5 = bdrv_co_preadv(VAR_0->backing->VAR_0, VAR_1, n_bytes, &local_qiov, 0); if (VAR_5 < 0) { goto fail; } } else { qemu_iovec_memset(VAR_3, bytes_done, 0, n_bytes); } } else { qemu_iovec_reset(&local_qiov); qemu_iovec_concat(&local_qiov, VAR_3, bytes_done, n_bytes); VAR_5 = vmdk_read_extent(extent, cluster_offset, offset_in_cluster, &local_qiov, n_bytes); if (VAR_5) { goto fail; } } VAR_2 -= n_bytes; VAR_1 += n_bytes; bytes_done += n_bytes; } VAR_5 = 0; fail: qemu_co_mutex_unlock(&s->lock); qemu_iovec_destroy(&local_qiov); return VAR_5; }
[ "FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t VAR_2,\nQEMUIOVector *VAR_3, int VAR_4)\n{", "BDRVVmdkState *s = VAR_0->opaque;", "int VAR_5;", "uint64_t n_bytes, offset_in_cluster;", "VmdkExtent *extent = NULL;", "QEMUIOVector local_qiov;", "uint64_t cluster_offset;", "uint64_t bytes_done = 0;", "qemu_iovec_init(&local_qiov, VAR_3->niov);", "qemu_co_mutex_lock(&s->lock);", "while (VAR_2 > 0) {", "extent = find_extent(s, VAR_1 >> BDRV_SECTOR_BITS, extent);", "if (!extent) {", "VAR_5 = -EIO;", "goto fail;", "}", "VAR_5 = get_cluster_offset(VAR_0, extent, NULL,\nVAR_1, false, &cluster_offset, 0, 0);", "offset_in_cluster = vmdk_find_offset_in_cluster(extent, VAR_1);", "n_bytes = MIN(VAR_2, extent->cluster_sectors * BDRV_SECTOR_SIZE\n- offset_in_cluster);", "if (VAR_5 != VMDK_OK) {", "if (VAR_0->backing && VAR_5 != VMDK_ZEROED) {", "if (!vmdk_is_cid_valid(VAR_0)) {", "VAR_5 = -EINVAL;", "goto fail;", "}", "qemu_iovec_reset(&local_qiov);", "qemu_iovec_concat(&local_qiov, VAR_3, bytes_done, n_bytes);", "VAR_5 = bdrv_co_preadv(VAR_0->backing->VAR_0, VAR_1, n_bytes,\n&local_qiov, 0);", "if (VAR_5 < 0) {", "goto fail;", "}", "} else {", "qemu_iovec_memset(VAR_3, bytes_done, 0, n_bytes);", "}", "} else {", "qemu_iovec_reset(&local_qiov);", "qemu_iovec_concat(&local_qiov, VAR_3, bytes_done, n_bytes);", "VAR_5 = vmdk_read_extent(extent, cluster_offset, offset_in_cluster,\n&local_qiov, n_bytes);", "if (VAR_5) {", "goto fail;", "}", "}", "VAR_2 -= n_bytes;", "VAR_1 += n_bytes;", "bytes_done += n_bytes;", "}", "VAR_5 = 0;", "fail:\nqemu_co_mutex_unlock(&s->lock);", "qemu_iovec_destroy(&local_qiov);", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 49, 51 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 77, 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 133 ], [ 135 ] ]
20,162
void cpu_ppc_store_hdecr (CPUPPCState *env, uint32_t value) { PowerPCCPU *cpu = ppc_env_get_cpu(env); _cpu_ppc_store_hdecr(cpu, cpu_ppc_load_hdecr(env), value, 0); }
false
qemu
e81a982aa5398269a2cc344091ffa4930bdd242f
void cpu_ppc_store_hdecr (CPUPPCState *env, uint32_t value) { PowerPCCPU *cpu = ppc_env_get_cpu(env); _cpu_ppc_store_hdecr(cpu, cpu_ppc_load_hdecr(env), value, 0); }
{ "code": [], "line_no": [] }
void FUNC_0 (CPUPPCState *VAR_0, uint32_t VAR_1) { PowerPCCPU *cpu = ppc_env_get_cpu(VAR_0); _cpu_ppc_store_hdecr(cpu, cpu_ppc_load_hdecr(VAR_0), VAR_1, 0); }
[ "void FUNC_0 (CPUPPCState *VAR_0, uint32_t VAR_1)\n{", "PowerPCCPU *cpu = ppc_env_get_cpu(VAR_0);", "_cpu_ppc_store_hdecr(cpu, cpu_ppc_load_hdecr(VAR_0), VAR_1, 0);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ] ]
20,163
static uint32_t syborg_virtio_readl(void *opaque, target_phys_addr_t offset) { SyborgVirtIOProxy *s = opaque; VirtIODevice *vdev = s->vdev; uint32_t ret; DPRINTF("readl 0x%x\n", (int)offset); if (offset >= SYBORG_VIRTIO_CONFIG) { return virtio_config_readl(vdev, offset - SYBORG_VIRTIO_CONFIG); } switch(offset >> 2) { case SYBORG_VIRTIO_ID: ret = SYBORG_ID_VIRTIO; break; case SYBORG_VIRTIO_DEVTYPE: ret = s->id; break; case SYBORG_VIRTIO_HOST_FEATURES: ret = vdev->get_features(vdev); ret |= vdev->binding->get_features(s); break; case SYBORG_VIRTIO_GUEST_FEATURES: ret = vdev->guest_features; break; case SYBORG_VIRTIO_QUEUE_BASE: ret = virtio_queue_get_addr(vdev, vdev->queue_sel); break; case SYBORG_VIRTIO_QUEUE_NUM: ret = virtio_queue_get_num(vdev, vdev->queue_sel); break; case SYBORG_VIRTIO_QUEUE_SEL: ret = vdev->queue_sel; break; case SYBORG_VIRTIO_STATUS: ret = vdev->status; break; case SYBORG_VIRTIO_INT_ENABLE: ret = s->int_enable; break; case SYBORG_VIRTIO_INT_STATUS: ret = vdev->isr; break; default: BADF("Bad read offset 0x%x\n", (int)offset); return 0; } return ret; }
false
qemu
8172539d21a03e982aa7f139ddc1607dc1422045
static uint32_t syborg_virtio_readl(void *opaque, target_phys_addr_t offset) { SyborgVirtIOProxy *s = opaque; VirtIODevice *vdev = s->vdev; uint32_t ret; DPRINTF("readl 0x%x\n", (int)offset); if (offset >= SYBORG_VIRTIO_CONFIG) { return virtio_config_readl(vdev, offset - SYBORG_VIRTIO_CONFIG); } switch(offset >> 2) { case SYBORG_VIRTIO_ID: ret = SYBORG_ID_VIRTIO; break; case SYBORG_VIRTIO_DEVTYPE: ret = s->id; break; case SYBORG_VIRTIO_HOST_FEATURES: ret = vdev->get_features(vdev); ret |= vdev->binding->get_features(s); break; case SYBORG_VIRTIO_GUEST_FEATURES: ret = vdev->guest_features; break; case SYBORG_VIRTIO_QUEUE_BASE: ret = virtio_queue_get_addr(vdev, vdev->queue_sel); break; case SYBORG_VIRTIO_QUEUE_NUM: ret = virtio_queue_get_num(vdev, vdev->queue_sel); break; case SYBORG_VIRTIO_QUEUE_SEL: ret = vdev->queue_sel; break; case SYBORG_VIRTIO_STATUS: ret = vdev->status; break; case SYBORG_VIRTIO_INT_ENABLE: ret = s->int_enable; break; case SYBORG_VIRTIO_INT_STATUS: ret = vdev->isr; break; default: BADF("Bad read offset 0x%x\n", (int)offset); return 0; } return ret; }
{ "code": [], "line_no": [] }
static uint32_t FUNC_0(void *opaque, target_phys_addr_t offset) { SyborgVirtIOProxy *s = opaque; VirtIODevice *vdev = s->vdev; uint32_t ret; DPRINTF("readl 0x%x\n", (int)offset); if (offset >= SYBORG_VIRTIO_CONFIG) { return virtio_config_readl(vdev, offset - SYBORG_VIRTIO_CONFIG); } switch(offset >> 2) { case SYBORG_VIRTIO_ID: ret = SYBORG_ID_VIRTIO; break; case SYBORG_VIRTIO_DEVTYPE: ret = s->id; break; case SYBORG_VIRTIO_HOST_FEATURES: ret = vdev->get_features(vdev); ret |= vdev->binding->get_features(s); break; case SYBORG_VIRTIO_GUEST_FEATURES: ret = vdev->guest_features; break; case SYBORG_VIRTIO_QUEUE_BASE: ret = virtio_queue_get_addr(vdev, vdev->queue_sel); break; case SYBORG_VIRTIO_QUEUE_NUM: ret = virtio_queue_get_num(vdev, vdev->queue_sel); break; case SYBORG_VIRTIO_QUEUE_SEL: ret = vdev->queue_sel; break; case SYBORG_VIRTIO_STATUS: ret = vdev->status; break; case SYBORG_VIRTIO_INT_ENABLE: ret = s->int_enable; break; case SYBORG_VIRTIO_INT_STATUS: ret = vdev->isr; break; default: BADF("Bad read offset 0x%x\n", (int)offset); return 0; } return ret; }
[ "static uint32_t FUNC_0(void *opaque, target_phys_addr_t offset)\n{", "SyborgVirtIOProxy *s = opaque;", "VirtIODevice *vdev = s->vdev;", "uint32_t ret;", "DPRINTF(\"readl 0x%x\\n\", (int)offset);", "if (offset >= SYBORG_VIRTIO_CONFIG) {", "return virtio_config_readl(vdev, offset - SYBORG_VIRTIO_CONFIG);", "}", "switch(offset >> 2) {", "case SYBORG_VIRTIO_ID:\nret = SYBORG_ID_VIRTIO;", "break;", "case SYBORG_VIRTIO_DEVTYPE:\nret = s->id;", "break;", "case SYBORG_VIRTIO_HOST_FEATURES:\nret = vdev->get_features(vdev);", "ret |= vdev->binding->get_features(s);", "break;", "case SYBORG_VIRTIO_GUEST_FEATURES:\nret = vdev->guest_features;", "break;", "case SYBORG_VIRTIO_QUEUE_BASE:\nret = virtio_queue_get_addr(vdev, vdev->queue_sel);", "break;", "case SYBORG_VIRTIO_QUEUE_NUM:\nret = virtio_queue_get_num(vdev, vdev->queue_sel);", "break;", "case SYBORG_VIRTIO_QUEUE_SEL:\nret = vdev->queue_sel;", "break;", "case SYBORG_VIRTIO_STATUS:\nret = vdev->status;", "break;", "case SYBORG_VIRTIO_INT_ENABLE:\nret = s->int_enable;", "break;", "case SYBORG_VIRTIO_INT_STATUS:\nret = vdev->isr;", "break;", "default:\nBADF(\"Bad read offset 0x%x\\n\", (int)offset);", "return 0;", "}", "return ret;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ] ]
20,164
static bool vring_notify(VirtIODevice *vdev, VirtQueue *vq) { uint16_t old, new; bool v; /* Always notify when queue is empty (when feature acknowledge) */ if (((vdev->guest_features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) && !vq->inuse && vring_avail_idx(vq) == vq->last_avail_idx)) { return true; } if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) { return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT); } v = vq->signalled_used_valid; vq->signalled_used_valid = true; old = vq->signalled_used; new = vq->signalled_used = vring_used_idx(vq); return !v || vring_need_event(vring_used_event(vq), new, old); }
true
qemu
a281ebc11a6917fbc27e1a93bb5772cd14e241fc
static bool vring_notify(VirtIODevice *vdev, VirtQueue *vq) { uint16_t old, new; bool v; if (((vdev->guest_features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) && !vq->inuse && vring_avail_idx(vq) == vq->last_avail_idx)) { return true; } if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) { return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT); } v = vq->signalled_used_valid; vq->signalled_used_valid = true; old = vq->signalled_used; new = vq->signalled_used = vring_used_idx(vq); return !v || vring_need_event(vring_used_event(vq), new, old); }
{ "code": [], "line_no": [] }
static bool FUNC_0(VirtIODevice *vdev, VirtQueue *vq) { uint16_t old, new; bool v; if (((vdev->guest_features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) && !vq->inuse && vring_avail_idx(vq) == vq->last_avail_idx)) { return true; } if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) { return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT); } v = vq->signalled_used_valid; vq->signalled_used_valid = true; old = vq->signalled_used; new = vq->signalled_used = vring_used_idx(vq); return !v || vring_need_event(vring_used_event(vq), new, old); }
[ "static bool FUNC_0(VirtIODevice *vdev, VirtQueue *vq)\n{", "uint16_t old, new;", "bool v;", "if (((vdev->guest_features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) &&\n!vq->inuse && vring_avail_idx(vq) == vq->last_avail_idx)) {", "return true;", "}", "if (!(vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX))) {", "return !(vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT);", "}", "v = vq->signalled_used_valid;", "vq->signalled_used_valid = true;", "old = vq->signalled_used;", "new = vq->signalled_used = vring_used_idx(vq);", "return !v || vring_need_event(vring_used_event(vq), new, old);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
20,165
static void guess_mv(ERContext *s) { uint8_t *fixed = s->er_temp_buffer; #define MV_FROZEN 3 #define MV_CHANGED 2 #define MV_UNCHANGED 1 const int mb_stride = s->mb_stride; const int mb_width = s->mb_width; const int mb_height = s->mb_height; int i, depth, num_avail; int mb_x, mb_y, mot_step, mot_stride; set_mv_strides(s, &mot_step, &mot_stride); num_avail = 0; for (i = 0; i < s->mb_num; i++) { const int mb_xy = s->mb_index2xy[i]; int f = 0; int error = s->error_status_table[mb_xy]; if (IS_INTRA(s->cur_pic.mb_type[mb_xy])) f = MV_FROZEN; // intra // FIXME check if (!(error & ER_MV_ERROR)) f = MV_FROZEN; // inter with undamaged MV fixed[mb_xy] = f; if (f == MV_FROZEN) num_avail++; } if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) || num_avail <= mb_width / 2) { for (mb_y = 0; mb_y < s->mb_height; mb_y++) { for (mb_x = 0; mb_x < s->mb_width; mb_x++) { const int mb_xy = mb_x + mb_y * s->mb_stride; int mv_dir = (s->last_pic.f && s->last_pic.f->data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD; if (IS_INTRA(s->cur_pic.mb_type[mb_xy])) continue; if (!(s->error_status_table[mb_xy] & ER_MV_ERROR)) continue; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0); } } return; } for (depth = 0; ; depth++) { int changed, pass, none_left; none_left = 1; changed = 1; for (pass = 0; (changed || pass < 2) && pass < 10; pass++) { int mb_x, mb_y; int score_sum = 0; changed = 0; for (mb_y = 0; mb_y < s->mb_height; mb_y++) { for (mb_x = 0; mb_x < s->mb_width; mb_x++) { const int mb_xy = mb_x + mb_y * s->mb_stride; int mv_predictor[8][2] = { { 0 } }; int ref[8] = { 0 }; int pred_count = 0; int j; int best_score = 256 * 256 * 256 * 64; int best_pred = 0; const int mot_index = (mb_x + mb_y * mot_stride) * mot_step; int prev_x, prev_y, prev_ref; if ((mb_x ^ mb_y ^ pass) & 1) continue; if (fixed[mb_xy] == MV_FROZEN) continue; assert(!IS_INTRA(s->cur_pic.mb_type[mb_xy])); assert(s->last_pic && s->last_pic.f->data[0]); j = 0; if (mb_x > 0 && fixed[mb_xy - 1] == MV_FROZEN) j = 1; if (mb_x + 1 < mb_width && fixed[mb_xy + 1] == MV_FROZEN) j = 1; if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_FROZEN) j = 1; if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_FROZEN) j = 1; if (j == 0) continue; j = 0; if (mb_x > 0 && fixed[mb_xy - 1 ] == MV_CHANGED) j = 1; if (mb_x + 1 < mb_width && fixed[mb_xy + 1 ] == MV_CHANGED) j = 1; if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_CHANGED) j = 1; if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_CHANGED) j = 1; if (j == 0 && pass > 1) continue; none_left = 0; if (mb_x > 0 && fixed[mb_xy - 1]) { mv_predictor[pred_count][0] = s->cur_pic.motion_val[0][mot_index - mot_step][0]; mv_predictor[pred_count][1] = s->cur_pic.motion_val[0][mot_index - mot_step][1]; ref[pred_count] = s->cur_pic.ref_index[0][4 * (mb_xy - 1)]; pred_count++; } if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) { mv_predictor[pred_count][0] = s->cur_pic.motion_val[0][mot_index + mot_step][0]; mv_predictor[pred_count][1] = s->cur_pic.motion_val[0][mot_index + mot_step][1]; ref[pred_count] = s->cur_pic.ref_index[0][4 * (mb_xy + 1)]; pred_count++; } if (mb_y > 0 && fixed[mb_xy - mb_stride]) { mv_predictor[pred_count][0] = s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][0]; mv_predictor[pred_count][1] = s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][1]; ref[pred_count] = s->cur_pic.ref_index[0][4 * (mb_xy - s->mb_stride)]; pred_count++; } if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) { mv_predictor[pred_count][0] = s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][0]; mv_predictor[pred_count][1] = s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][1]; ref[pred_count] = s->cur_pic.ref_index[0][4 * (mb_xy + s->mb_stride)]; pred_count++; } if (pred_count == 0) continue; if (pred_count > 1) { int sum_x = 0, sum_y = 0, sum_r = 0; int max_x, max_y, min_x, min_y, max_r, min_r; for (j = 0; j < pred_count; j++) { sum_x += mv_predictor[j][0]; sum_y += mv_predictor[j][1]; sum_r += ref[j]; if (j && ref[j] != ref[j - 1]) goto skip_mean_and_median; } /* mean */ mv_predictor[pred_count][0] = sum_x / j; mv_predictor[pred_count][1] = sum_y / j; ref[pred_count] = sum_r / j; /* median */ if (pred_count >= 3) { min_y = min_x = min_r = 99999; max_y = max_x = max_r = -99999; } else { min_x = min_y = max_x = max_y = min_r = max_r = 0; } for (j = 0; j < pred_count; j++) { max_x = FFMAX(max_x, mv_predictor[j][0]); max_y = FFMAX(max_y, mv_predictor[j][1]); max_r = FFMAX(max_r, ref[j]); min_x = FFMIN(min_x, mv_predictor[j][0]); min_y = FFMIN(min_y, mv_predictor[j][1]); min_r = FFMIN(min_r, ref[j]); } mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x; mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y; ref[pred_count + 1] = sum_r - max_r - min_r; if (pred_count == 4) { mv_predictor[pred_count + 1][0] /= 2; mv_predictor[pred_count + 1][1] /= 2; ref[pred_count + 1] /= 2; } pred_count += 2; } skip_mean_and_median: /* zero MV */ pred_count++; if (!fixed[mb_xy]) { if (s->avctx->codec_id == AV_CODEC_ID_H264) { // FIXME } else { ff_thread_await_progress(s->last_pic.tf, mb_y, 0); } if (!s->last_pic.motion_val[0] || !s->last_pic.ref_index[0]) goto skip_last_mv; prev_x = s->last_pic.motion_val[0][mot_index][0]; prev_y = s->last_pic.motion_val[0][mot_index][1]; prev_ref = s->last_pic.ref_index[0][4 * mb_xy]; } else { prev_x = s->cur_pic.motion_val[0][mot_index][0]; prev_y = s->cur_pic.motion_val[0][mot_index][1]; prev_ref = s->cur_pic.ref_index[0][4 * mb_xy]; } /* last MV */ mv_predictor[pred_count][0] = prev_x; mv_predictor[pred_count][1] = prev_y; ref[pred_count] = prev_ref; pred_count++; skip_last_mv: for (j = 0; j < pred_count; j++) { int *linesize = s->cur_pic.f->linesize; int score = 0; uint8_t *src = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0]; s->cur_pic.motion_val[0][mot_index][0] = s->mv[0][0][0] = mv_predictor[j][0]; s->cur_pic.motion_val[0][mot_index][1] = s->mv[0][0][1] = mv_predictor[j][1]; // predictor intra or otherwise not available if (ref[j] < 0) continue; s->decode_mb(s->opaque, ref[j], MV_DIR_FORWARD, MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0); if (mb_x > 0 && fixed[mb_xy - 1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k * linesize[0] - 1] - src[k * linesize[0]]); } if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k * linesize[0] + 15] - src[k * linesize[0] + 16]); } if (mb_y > 0 && fixed[mb_xy - mb_stride]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k - linesize[0]] - src[k]); } if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k + linesize[0] * 15] - src[k + linesize[0] * 16]); } if (score <= best_score) { // <= will favor the last MV best_score = score; best_pred = j; } } score_sum += best_score; s->mv[0][0][0] = mv_predictor[best_pred][0]; s->mv[0][0][1] = mv_predictor[best_pred][1]; for (i = 0; i < mot_step; i++) for (j = 0; j < mot_step; j++) { s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0]; s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1]; } s->decode_mb(s->opaque, ref[best_pred], MV_DIR_FORWARD, MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0); if (s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y) { fixed[mb_xy] = MV_CHANGED; changed++; } else fixed[mb_xy] = MV_UNCHANGED; } } } if (none_left) return; for (i = 0; i < s->mb_num; i++) { int mb_xy = s->mb_index2xy[i]; if (fixed[mb_xy]) fixed[mb_xy] = MV_FROZEN; } } }
true
FFmpeg
7cb66ebc0be48489785f7166c9d15eac594b0763
static void guess_mv(ERContext *s) { uint8_t *fixed = s->er_temp_buffer; #define MV_FROZEN 3 #define MV_CHANGED 2 #define MV_UNCHANGED 1 const int mb_stride = s->mb_stride; const int mb_width = s->mb_width; const int mb_height = s->mb_height; int i, depth, num_avail; int mb_x, mb_y, mot_step, mot_stride; set_mv_strides(s, &mot_step, &mot_stride); num_avail = 0; for (i = 0; i < s->mb_num; i++) { const int mb_xy = s->mb_index2xy[i]; int f = 0; int error = s->error_status_table[mb_xy]; if (IS_INTRA(s->cur_pic.mb_type[mb_xy])) f = MV_FROZEN; if (!(error & ER_MV_ERROR)) f = MV_FROZEN; fixed[mb_xy] = f; if (f == MV_FROZEN) num_avail++; } if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) || num_avail <= mb_width / 2) { for (mb_y = 0; mb_y < s->mb_height; mb_y++) { for (mb_x = 0; mb_x < s->mb_width; mb_x++) { const int mb_xy = mb_x + mb_y * s->mb_stride; int mv_dir = (s->last_pic.f && s->last_pic.f->data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD; if (IS_INTRA(s->cur_pic.mb_type[mb_xy])) continue; if (!(s->error_status_table[mb_xy] & ER_MV_ERROR)) continue; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; s->decode_mb(s->opaque, 0, mv_dir, MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0); } } return; } for (depth = 0; ; depth++) { int changed, pass, none_left; none_left = 1; changed = 1; for (pass = 0; (changed || pass < 2) && pass < 10; pass++) { int mb_x, mb_y; int score_sum = 0; changed = 0; for (mb_y = 0; mb_y < s->mb_height; mb_y++) { for (mb_x = 0; mb_x < s->mb_width; mb_x++) { const int mb_xy = mb_x + mb_y * s->mb_stride; int mv_predictor[8][2] = { { 0 } }; int ref[8] = { 0 }; int pred_count = 0; int j; int best_score = 256 * 256 * 256 * 64; int best_pred = 0; const int mot_index = (mb_x + mb_y * mot_stride) * mot_step; int prev_x, prev_y, prev_ref; if ((mb_x ^ mb_y ^ pass) & 1) continue; if (fixed[mb_xy] == MV_FROZEN) continue; assert(!IS_INTRA(s->cur_pic.mb_type[mb_xy])); assert(s->last_pic && s->last_pic.f->data[0]); j = 0; if (mb_x > 0 && fixed[mb_xy - 1] == MV_FROZEN) j = 1; if (mb_x + 1 < mb_width && fixed[mb_xy + 1] == MV_FROZEN) j = 1; if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_FROZEN) j = 1; if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_FROZEN) j = 1; if (j == 0) continue; j = 0; if (mb_x > 0 && fixed[mb_xy - 1 ] == MV_CHANGED) j = 1; if (mb_x + 1 < mb_width && fixed[mb_xy + 1 ] == MV_CHANGED) j = 1; if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_CHANGED) j = 1; if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_CHANGED) j = 1; if (j == 0 && pass > 1) continue; none_left = 0; if (mb_x > 0 && fixed[mb_xy - 1]) { mv_predictor[pred_count][0] = s->cur_pic.motion_val[0][mot_index - mot_step][0]; mv_predictor[pred_count][1] = s->cur_pic.motion_val[0][mot_index - mot_step][1]; ref[pred_count] = s->cur_pic.ref_index[0][4 * (mb_xy - 1)]; pred_count++; } if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) { mv_predictor[pred_count][0] = s->cur_pic.motion_val[0][mot_index + mot_step][0]; mv_predictor[pred_count][1] = s->cur_pic.motion_val[0][mot_index + mot_step][1]; ref[pred_count] = s->cur_pic.ref_index[0][4 * (mb_xy + 1)]; pred_count++; } if (mb_y > 0 && fixed[mb_xy - mb_stride]) { mv_predictor[pred_count][0] = s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][0]; mv_predictor[pred_count][1] = s->cur_pic.motion_val[0][mot_index - mot_stride * mot_step][1]; ref[pred_count] = s->cur_pic.ref_index[0][4 * (mb_xy - s->mb_stride)]; pred_count++; } if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) { mv_predictor[pred_count][0] = s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][0]; mv_predictor[pred_count][1] = s->cur_pic.motion_val[0][mot_index + mot_stride * mot_step][1]; ref[pred_count] = s->cur_pic.ref_index[0][4 * (mb_xy + s->mb_stride)]; pred_count++; } if (pred_count == 0) continue; if (pred_count > 1) { int sum_x = 0, sum_y = 0, sum_r = 0; int max_x, max_y, min_x, min_y, max_r, min_r; for (j = 0; j < pred_count; j++) { sum_x += mv_predictor[j][0]; sum_y += mv_predictor[j][1]; sum_r += ref[j]; if (j && ref[j] != ref[j - 1]) goto skip_mean_and_median; } mv_predictor[pred_count][0] = sum_x / j; mv_predictor[pred_count][1] = sum_y / j; ref[pred_count] = sum_r / j; if (pred_count >= 3) { min_y = min_x = min_r = 99999; max_y = max_x = max_r = -99999; } else { min_x = min_y = max_x = max_y = min_r = max_r = 0; } for (j = 0; j < pred_count; j++) { max_x = FFMAX(max_x, mv_predictor[j][0]); max_y = FFMAX(max_y, mv_predictor[j][1]); max_r = FFMAX(max_r, ref[j]); min_x = FFMIN(min_x, mv_predictor[j][0]); min_y = FFMIN(min_y, mv_predictor[j][1]); min_r = FFMIN(min_r, ref[j]); } mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x; mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y; ref[pred_count + 1] = sum_r - max_r - min_r; if (pred_count == 4) { mv_predictor[pred_count + 1][0] /= 2; mv_predictor[pred_count + 1][1] /= 2; ref[pred_count + 1] /= 2; } pred_count += 2; } skip_mean_and_median: pred_count++; if (!fixed[mb_xy]) { if (s->avctx->codec_id == AV_CODEC_ID_H264) { } else { ff_thread_await_progress(s->last_pic.tf, mb_y, 0); } if (!s->last_pic.motion_val[0] || !s->last_pic.ref_index[0]) goto skip_last_mv; prev_x = s->last_pic.motion_val[0][mot_index][0]; prev_y = s->last_pic.motion_val[0][mot_index][1]; prev_ref = s->last_pic.ref_index[0][4 * mb_xy]; } else { prev_x = s->cur_pic.motion_val[0][mot_index][0]; prev_y = s->cur_pic.motion_val[0][mot_index][1]; prev_ref = s->cur_pic.ref_index[0][4 * mb_xy]; } mv_predictor[pred_count][0] = prev_x; mv_predictor[pred_count][1] = prev_y; ref[pred_count] = prev_ref; pred_count++; skip_last_mv: for (j = 0; j < pred_count; j++) { int *linesize = s->cur_pic.f->linesize; int score = 0; uint8_t *src = s->cur_pic.f->data[0] + mb_x * 16 + mb_y * 16 * linesize[0]; s->cur_pic.motion_val[0][mot_index][0] = s->mv[0][0][0] = mv_predictor[j][0]; s->cur_pic.motion_val[0][mot_index][1] = s->mv[0][0][1] = mv_predictor[j][1]; if (ref[j] < 0) continue; s->decode_mb(s->opaque, ref[j], MV_DIR_FORWARD, MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0); if (mb_x > 0 && fixed[mb_xy - 1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k * linesize[0] - 1] - src[k * linesize[0]]); } if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k * linesize[0] + 15] - src[k * linesize[0] + 16]); } if (mb_y > 0 && fixed[mb_xy - mb_stride]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k - linesize[0]] - src[k]); } if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k + linesize[0] * 15] - src[k + linesize[0] * 16]); } if (score <= best_score) { best_score = score; best_pred = j; } } score_sum += best_score; s->mv[0][0][0] = mv_predictor[best_pred][0]; s->mv[0][0][1] = mv_predictor[best_pred][1]; for (i = 0; i < mot_step; i++) for (j = 0; j < mot_step; j++) { s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0]; s->cur_pic.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1]; } s->decode_mb(s->opaque, ref[best_pred], MV_DIR_FORWARD, MV_TYPE_16X16, &s->mv, mb_x, mb_y, 0, 0); if (s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y) { fixed[mb_xy] = MV_CHANGED; changed++; } else fixed[mb_xy] = MV_UNCHANGED; } } } if (none_left) return; for (i = 0; i < s->mb_num; i++) { int mb_xy = s->mb_index2xy[i]; if (fixed[mb_xy]) fixed[mb_xy] = MV_FROZEN; } } }
{ "code": [ " assert(!IS_INTRA(s->cur_pic.mb_type[mb_xy]));", " assert(s->last_pic && s->last_pic.f->data[0]);" ], "line_no": [ 157, 159 ] }
static void FUNC_0(ERContext *VAR_0) { uint8_t *fixed = VAR_0->er_temp_buffer; #define MV_FROZEN 3 #define MV_CHANGED 2 #define MV_UNCHANGED 1 const int VAR_1 = VAR_0->VAR_1; const int VAR_2 = VAR_0->VAR_2; const int VAR_3 = VAR_0->VAR_3; int VAR_4, VAR_5, VAR_6; int VAR_14, VAR_14, VAR_9, VAR_10; set_mv_strides(VAR_0, &VAR_9, &VAR_10); VAR_6 = 0; for (VAR_4 = 0; VAR_4 < VAR_0->mb_num; VAR_4++) { const int mb_xy = VAR_0->mb_index2xy[VAR_4]; int f = 0; int error = VAR_0->error_status_table[mb_xy]; if (IS_INTRA(VAR_0->cur_pic.mb_type[mb_xy])) f = MV_FROZEN; if (!(error & ER_MV_ERROR)) f = MV_FROZEN; fixed[mb_xy] = f; if (f == MV_FROZEN) VAR_6++; } if ((!(VAR_0->avctx->error_concealment&FF_EC_GUESS_MVS)) || VAR_6 <= VAR_2 / 2) { for (VAR_14 = 0; VAR_14 < VAR_0->VAR_3; VAR_14++) { for (VAR_14 = 0; VAR_14 < VAR_0->VAR_2; VAR_14++) { const int mb_xy = VAR_14 + VAR_14 * VAR_0->VAR_1; int mv_dir = (VAR_0->last_pic.f && VAR_0->last_pic.f->data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD; if (IS_INTRA(VAR_0->cur_pic.mb_type[mb_xy])) continue; if (!(VAR_0->error_status_table[mb_xy] & ER_MV_ERROR)) continue; VAR_0->mv[0][0][0] = 0; VAR_0->mv[0][0][1] = 0; VAR_0->decode_mb(VAR_0->opaque, 0, mv_dir, MV_TYPE_16X16, &VAR_0->mv, VAR_14, VAR_14, 0, 0); } } return; } for (VAR_5 = 0; ; VAR_5++) { int VAR_11, VAR_12, VAR_13; VAR_13 = 1; VAR_11 = 1; for (VAR_12 = 0; (VAR_11 || VAR_12 < 2) && VAR_12 < 10; VAR_12++) { int VAR_14, VAR_14; int VAR_14 = 0; VAR_11 = 0; for (VAR_14 = 0; VAR_14 < VAR_0->VAR_3; VAR_14++) { for (VAR_14 = 0; VAR_14 < VAR_0->VAR_2; VAR_14++) { const int mb_xy = VAR_14 + VAR_14 * VAR_0->VAR_1; int mv_predictor[8][2] = { { 0 } }; int ref[8] = { 0 }; int pred_count = 0; int j; int best_score = 256 * 256 * 256 * 64; int best_pred = 0; const int mot_index = (VAR_14 + VAR_14 * VAR_10) * VAR_9; int prev_x, prev_y, prev_ref; if ((VAR_14 ^ VAR_14 ^ VAR_12) & 1) continue; if (fixed[mb_xy] == MV_FROZEN) continue; assert(!IS_INTRA(VAR_0->cur_pic.mb_type[mb_xy])); assert(VAR_0->last_pic && VAR_0->last_pic.f->data[0]); j = 0; if (VAR_14 > 0 && fixed[mb_xy - 1] == MV_FROZEN) j = 1; if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1] == MV_FROZEN) j = 1; if (VAR_14 > 0 && fixed[mb_xy - VAR_1] == MV_FROZEN) j = 1; if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1] == MV_FROZEN) j = 1; if (j == 0) continue; j = 0; if (VAR_14 > 0 && fixed[mb_xy - 1 ] == MV_CHANGED) j = 1; if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1 ] == MV_CHANGED) j = 1; if (VAR_14 > 0 && fixed[mb_xy - VAR_1] == MV_CHANGED) j = 1; if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1] == MV_CHANGED) j = 1; if (j == 0 && VAR_12 > 1) continue; VAR_13 = 0; if (VAR_14 > 0 && fixed[mb_xy - 1]) { mv_predictor[pred_count][0] = VAR_0->cur_pic.motion_val[0][mot_index - VAR_9][0]; mv_predictor[pred_count][1] = VAR_0->cur_pic.motion_val[0][mot_index - VAR_9][1]; ref[pred_count] = VAR_0->cur_pic.ref_index[0][4 * (mb_xy - 1)]; pred_count++; } if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1]) { mv_predictor[pred_count][0] = VAR_0->cur_pic.motion_val[0][mot_index + VAR_9][0]; mv_predictor[pred_count][1] = VAR_0->cur_pic.motion_val[0][mot_index + VAR_9][1]; ref[pred_count] = VAR_0->cur_pic.ref_index[0][4 * (mb_xy + 1)]; pred_count++; } if (VAR_14 > 0 && fixed[mb_xy - VAR_1]) { mv_predictor[pred_count][0] = VAR_0->cur_pic.motion_val[0][mot_index - VAR_10 * VAR_9][0]; mv_predictor[pred_count][1] = VAR_0->cur_pic.motion_val[0][mot_index - VAR_10 * VAR_9][1]; ref[pred_count] = VAR_0->cur_pic.ref_index[0][4 * (mb_xy - VAR_0->VAR_1)]; pred_count++; } if (VAR_14 + 1<VAR_3 && fixed[mb_xy + VAR_1]) { mv_predictor[pred_count][0] = VAR_0->cur_pic.motion_val[0][mot_index + VAR_10 * VAR_9][0]; mv_predictor[pred_count][1] = VAR_0->cur_pic.motion_val[0][mot_index + VAR_10 * VAR_9][1]; ref[pred_count] = VAR_0->cur_pic.ref_index[0][4 * (mb_xy + VAR_0->VAR_1)]; pred_count++; } if (pred_count == 0) continue; if (pred_count > 1) { int sum_x = 0, sum_y = 0, sum_r = 0; int max_x, max_y, min_x, min_y, max_r, min_r; for (j = 0; j < pred_count; j++) { sum_x += mv_predictor[j][0]; sum_y += mv_predictor[j][1]; sum_r += ref[j]; if (j && ref[j] != ref[j - 1]) goto skip_mean_and_median; } mv_predictor[pred_count][0] = sum_x / j; mv_predictor[pred_count][1] = sum_y / j; ref[pred_count] = sum_r / j; if (pred_count >= 3) { min_y = min_x = min_r = 99999; max_y = max_x = max_r = -99999; } else { min_x = min_y = max_x = max_y = min_r = max_r = 0; } for (j = 0; j < pred_count; j++) { max_x = FFMAX(max_x, mv_predictor[j][0]); max_y = FFMAX(max_y, mv_predictor[j][1]); max_r = FFMAX(max_r, ref[j]); min_x = FFMIN(min_x, mv_predictor[j][0]); min_y = FFMIN(min_y, mv_predictor[j][1]); min_r = FFMIN(min_r, ref[j]); } mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x; mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y; ref[pred_count + 1] = sum_r - max_r - min_r; if (pred_count == 4) { mv_predictor[pred_count + 1][0] /= 2; mv_predictor[pred_count + 1][1] /= 2; ref[pred_count + 1] /= 2; } pred_count += 2; } skip_mean_and_median: pred_count++; if (!fixed[mb_xy]) { if (VAR_0->avctx->codec_id == AV_CODEC_ID_H264) { } else { ff_thread_await_progress(VAR_0->last_pic.tf, VAR_14, 0); } if (!VAR_0->last_pic.motion_val[0] || !VAR_0->last_pic.ref_index[0]) goto skip_last_mv; prev_x = VAR_0->last_pic.motion_val[0][mot_index][0]; prev_y = VAR_0->last_pic.motion_val[0][mot_index][1]; prev_ref = VAR_0->last_pic.ref_index[0][4 * mb_xy]; } else { prev_x = VAR_0->cur_pic.motion_val[0][mot_index][0]; prev_y = VAR_0->cur_pic.motion_val[0][mot_index][1]; prev_ref = VAR_0->cur_pic.ref_index[0][4 * mb_xy]; } mv_predictor[pred_count][0] = prev_x; mv_predictor[pred_count][1] = prev_y; ref[pred_count] = prev_ref; pred_count++; skip_last_mv: for (j = 0; j < pred_count; j++) { int *linesize = VAR_0->cur_pic.f->linesize; int score = 0; uint8_t *src = VAR_0->cur_pic.f->data[0] + VAR_14 * 16 + VAR_14 * 16 * linesize[0]; VAR_0->cur_pic.motion_val[0][mot_index][0] = VAR_0->mv[0][0][0] = mv_predictor[j][0]; VAR_0->cur_pic.motion_val[0][mot_index][1] = VAR_0->mv[0][0][1] = mv_predictor[j][1]; if (ref[j] < 0) continue; VAR_0->decode_mb(VAR_0->opaque, ref[j], MV_DIR_FORWARD, MV_TYPE_16X16, &VAR_0->mv, VAR_14, VAR_14, 0, 0); if (VAR_14 > 0 && fixed[mb_xy - 1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k * linesize[0] - 1] - src[k * linesize[0]]); } if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k * linesize[0] + 15] - src[k * linesize[0] + 16]); } if (VAR_14 > 0 && fixed[mb_xy - VAR_1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k - linesize[0]] - src[k]); } if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k + linesize[0] * 15] - src[k + linesize[0] * 16]); } if (score <= best_score) { best_score = score; best_pred = j; } } VAR_14 += best_score; VAR_0->mv[0][0][0] = mv_predictor[best_pred][0]; VAR_0->mv[0][0][1] = mv_predictor[best_pred][1]; for (VAR_4 = 0; VAR_4 < VAR_9; VAR_4++) for (j = 0; j < VAR_9; j++) { VAR_0->cur_pic.motion_val[0][mot_index + VAR_4 + j * VAR_10][0] = VAR_0->mv[0][0][0]; VAR_0->cur_pic.motion_val[0][mot_index + VAR_4 + j * VAR_10][1] = VAR_0->mv[0][0][1]; } VAR_0->decode_mb(VAR_0->opaque, ref[best_pred], MV_DIR_FORWARD, MV_TYPE_16X16, &VAR_0->mv, VAR_14, VAR_14, 0, 0); if (VAR_0->mv[0][0][0] != prev_x || VAR_0->mv[0][0][1] != prev_y) { fixed[mb_xy] = MV_CHANGED; VAR_11++; } else fixed[mb_xy] = MV_UNCHANGED; } } } if (VAR_13) return; for (VAR_4 = 0; VAR_4 < VAR_0->mb_num; VAR_4++) { int mb_xy = VAR_0->mb_index2xy[VAR_4]; if (fixed[mb_xy]) fixed[mb_xy] = MV_FROZEN; } } }
[ "static void FUNC_0(ERContext *VAR_0)\n{", "uint8_t *fixed = VAR_0->er_temp_buffer;", "#define MV_FROZEN 3\n#define MV_CHANGED 2\n#define MV_UNCHANGED 1\nconst int VAR_1 = VAR_0->VAR_1;", "const int VAR_2 = VAR_0->VAR_2;", "const int VAR_3 = VAR_0->VAR_3;", "int VAR_4, VAR_5, VAR_6;", "int VAR_14, VAR_14, VAR_9, VAR_10;", "set_mv_strides(VAR_0, &VAR_9, &VAR_10);", "VAR_6 = 0;", "for (VAR_4 = 0; VAR_4 < VAR_0->mb_num; VAR_4++) {", "const int mb_xy = VAR_0->mb_index2xy[VAR_4];", "int f = 0;", "int error = VAR_0->error_status_table[mb_xy];", "if (IS_INTRA(VAR_0->cur_pic.mb_type[mb_xy]))\nf = MV_FROZEN;", "if (!(error & ER_MV_ERROR))\nf = MV_FROZEN;", "fixed[mb_xy] = f;", "if (f == MV_FROZEN)\nVAR_6++;", "}", "if ((!(VAR_0->avctx->error_concealment&FF_EC_GUESS_MVS)) ||\nVAR_6 <= VAR_2 / 2) {", "for (VAR_14 = 0; VAR_14 < VAR_0->VAR_3; VAR_14++) {", "for (VAR_14 = 0; VAR_14 < VAR_0->VAR_2; VAR_14++) {", "const int mb_xy = VAR_14 + VAR_14 * VAR_0->VAR_1;", "int mv_dir = (VAR_0->last_pic.f && VAR_0->last_pic.f->data[0]) ? MV_DIR_FORWARD : MV_DIR_BACKWARD;", "if (IS_INTRA(VAR_0->cur_pic.mb_type[mb_xy]))\ncontinue;", "if (!(VAR_0->error_status_table[mb_xy] & ER_MV_ERROR))\ncontinue;", "VAR_0->mv[0][0][0] = 0;", "VAR_0->mv[0][0][1] = 0;", "VAR_0->decode_mb(VAR_0->opaque, 0, mv_dir, MV_TYPE_16X16, &VAR_0->mv,\nVAR_14, VAR_14, 0, 0);", "}", "}", "return;", "}", "for (VAR_5 = 0; ; VAR_5++) {", "int VAR_11, VAR_12, VAR_13;", "VAR_13 = 1;", "VAR_11 = 1;", "for (VAR_12 = 0; (VAR_11 || VAR_12 < 2) && VAR_12 < 10; VAR_12++) {", "int VAR_14, VAR_14;", "int VAR_14 = 0;", "VAR_11 = 0;", "for (VAR_14 = 0; VAR_14 < VAR_0->VAR_3; VAR_14++) {", "for (VAR_14 = 0; VAR_14 < VAR_0->VAR_2; VAR_14++) {", "const int mb_xy = VAR_14 + VAR_14 * VAR_0->VAR_1;", "int mv_predictor[8][2] = { { 0 } };", "int ref[8] = { 0 };", "int pred_count = 0;", "int j;", "int best_score = 256 * 256 * 256 * 64;", "int best_pred = 0;", "const int mot_index = (VAR_14 + VAR_14 * VAR_10) * VAR_9;", "int prev_x, prev_y, prev_ref;", "if ((VAR_14 ^ VAR_14 ^ VAR_12) & 1)\ncontinue;", "if (fixed[mb_xy] == MV_FROZEN)\ncontinue;", "assert(!IS_INTRA(VAR_0->cur_pic.mb_type[mb_xy]));", "assert(VAR_0->last_pic && VAR_0->last_pic.f->data[0]);", "j = 0;", "if (VAR_14 > 0 && fixed[mb_xy - 1] == MV_FROZEN)\nj = 1;", "if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1] == MV_FROZEN)\nj = 1;", "if (VAR_14 > 0 && fixed[mb_xy - VAR_1] == MV_FROZEN)\nj = 1;", "if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1] == MV_FROZEN)\nj = 1;", "if (j == 0)\ncontinue;", "j = 0;", "if (VAR_14 > 0 && fixed[mb_xy - 1 ] == MV_CHANGED)\nj = 1;", "if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1 ] == MV_CHANGED)\nj = 1;", "if (VAR_14 > 0 && fixed[mb_xy - VAR_1] == MV_CHANGED)\nj = 1;", "if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1] == MV_CHANGED)\nj = 1;", "if (j == 0 && VAR_12 > 1)\ncontinue;", "VAR_13 = 0;", "if (VAR_14 > 0 && fixed[mb_xy - 1]) {", "mv_predictor[pred_count][0] =\nVAR_0->cur_pic.motion_val[0][mot_index - VAR_9][0];", "mv_predictor[pred_count][1] =\nVAR_0->cur_pic.motion_val[0][mot_index - VAR_9][1];", "ref[pred_count] =\nVAR_0->cur_pic.ref_index[0][4 * (mb_xy - 1)];", "pred_count++;", "}", "if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1]) {", "mv_predictor[pred_count][0] =\nVAR_0->cur_pic.motion_val[0][mot_index + VAR_9][0];", "mv_predictor[pred_count][1] =\nVAR_0->cur_pic.motion_val[0][mot_index + VAR_9][1];", "ref[pred_count] =\nVAR_0->cur_pic.ref_index[0][4 * (mb_xy + 1)];", "pred_count++;", "}", "if (VAR_14 > 0 && fixed[mb_xy - VAR_1]) {", "mv_predictor[pred_count][0] =\nVAR_0->cur_pic.motion_val[0][mot_index - VAR_10 * VAR_9][0];", "mv_predictor[pred_count][1] =\nVAR_0->cur_pic.motion_val[0][mot_index - VAR_10 * VAR_9][1];", "ref[pred_count] =\nVAR_0->cur_pic.ref_index[0][4 * (mb_xy - VAR_0->VAR_1)];", "pred_count++;", "}", "if (VAR_14 + 1<VAR_3 && fixed[mb_xy + VAR_1]) {", "mv_predictor[pred_count][0] =\nVAR_0->cur_pic.motion_val[0][mot_index + VAR_10 * VAR_9][0];", "mv_predictor[pred_count][1] =\nVAR_0->cur_pic.motion_val[0][mot_index + VAR_10 * VAR_9][1];", "ref[pred_count] =\nVAR_0->cur_pic.ref_index[0][4 * (mb_xy + VAR_0->VAR_1)];", "pred_count++;", "}", "if (pred_count == 0)\ncontinue;", "if (pred_count > 1) {", "int sum_x = 0, sum_y = 0, sum_r = 0;", "int max_x, max_y, min_x, min_y, max_r, min_r;", "for (j = 0; j < pred_count; j++) {", "sum_x += mv_predictor[j][0];", "sum_y += mv_predictor[j][1];", "sum_r += ref[j];", "if (j && ref[j] != ref[j - 1])\ngoto skip_mean_and_median;", "}", "mv_predictor[pred_count][0] = sum_x / j;", "mv_predictor[pred_count][1] = sum_y / j;", "ref[pred_count] = sum_r / j;", "if (pred_count >= 3) {", "min_y = min_x = min_r = 99999;", "max_y = max_x = max_r = -99999;", "} else {", "min_x = min_y = max_x = max_y = min_r = max_r = 0;", "}", "for (j = 0; j < pred_count; j++) {", "max_x = FFMAX(max_x, mv_predictor[j][0]);", "max_y = FFMAX(max_y, mv_predictor[j][1]);", "max_r = FFMAX(max_r, ref[j]);", "min_x = FFMIN(min_x, mv_predictor[j][0]);", "min_y = FFMIN(min_y, mv_predictor[j][1]);", "min_r = FFMIN(min_r, ref[j]);", "}", "mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x;", "mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y;", "ref[pred_count + 1] = sum_r - max_r - min_r;", "if (pred_count == 4) {", "mv_predictor[pred_count + 1][0] /= 2;", "mv_predictor[pred_count + 1][1] /= 2;", "ref[pred_count + 1] /= 2;", "}", "pred_count += 2;", "}", "skip_mean_and_median:\npred_count++;", "if (!fixed[mb_xy]) {", "if (VAR_0->avctx->codec_id == AV_CODEC_ID_H264) {", "} else {", "ff_thread_await_progress(VAR_0->last_pic.tf,\nVAR_14, 0);", "}", "if (!VAR_0->last_pic.motion_val[0] ||\n!VAR_0->last_pic.ref_index[0])\ngoto skip_last_mv;", "prev_x = VAR_0->last_pic.motion_val[0][mot_index][0];", "prev_y = VAR_0->last_pic.motion_val[0][mot_index][1];", "prev_ref = VAR_0->last_pic.ref_index[0][4 * mb_xy];", "} else {", "prev_x = VAR_0->cur_pic.motion_val[0][mot_index][0];", "prev_y = VAR_0->cur_pic.motion_val[0][mot_index][1];", "prev_ref = VAR_0->cur_pic.ref_index[0][4 * mb_xy];", "}", "mv_predictor[pred_count][0] = prev_x;", "mv_predictor[pred_count][1] = prev_y;", "ref[pred_count] = prev_ref;", "pred_count++;", "skip_last_mv:\nfor (j = 0; j < pred_count; j++) {", "int *linesize = VAR_0->cur_pic.f->linesize;", "int score = 0;", "uint8_t *src = VAR_0->cur_pic.f->data[0] +\nVAR_14 * 16 + VAR_14 * 16 * linesize[0];", "VAR_0->cur_pic.motion_val[0][mot_index][0] =\nVAR_0->mv[0][0][0] = mv_predictor[j][0];", "VAR_0->cur_pic.motion_val[0][mot_index][1] =\nVAR_0->mv[0][0][1] = mv_predictor[j][1];", "if (ref[j] < 0)\ncontinue;", "VAR_0->decode_mb(VAR_0->opaque, ref[j], MV_DIR_FORWARD,\nMV_TYPE_16X16, &VAR_0->mv, VAR_14, VAR_14, 0, 0);", "if (VAR_14 > 0 && fixed[mb_xy - 1]) {", "int k;", "for (k = 0; k < 16; k++)", "score += FFABS(src[k * linesize[0] - 1] -\nsrc[k * linesize[0]]);", "}", "if (VAR_14 + 1 < VAR_2 && fixed[mb_xy + 1]) {", "int k;", "for (k = 0; k < 16; k++)", "score += FFABS(src[k * linesize[0] + 15] -\nsrc[k * linesize[0] + 16]);", "}", "if (VAR_14 > 0 && fixed[mb_xy - VAR_1]) {", "int k;", "for (k = 0; k < 16; k++)", "score += FFABS(src[k - linesize[0]] - src[k]);", "}", "if (VAR_14 + 1 < VAR_3 && fixed[mb_xy + VAR_1]) {", "int k;", "for (k = 0; k < 16; k++)", "score += FFABS(src[k + linesize[0] * 15] -\nsrc[k + linesize[0] * 16]);", "}", "if (score <= best_score) {", "best_score = score;", "best_pred = j;", "}", "}", "VAR_14 += best_score;", "VAR_0->mv[0][0][0] = mv_predictor[best_pred][0];", "VAR_0->mv[0][0][1] = mv_predictor[best_pred][1];", "for (VAR_4 = 0; VAR_4 < VAR_9; VAR_4++)", "for (j = 0; j < VAR_9; j++) {", "VAR_0->cur_pic.motion_val[0][mot_index + VAR_4 + j * VAR_10][0] = VAR_0->mv[0][0][0];", "VAR_0->cur_pic.motion_val[0][mot_index + VAR_4 + j * VAR_10][1] = VAR_0->mv[0][0][1];", "}", "VAR_0->decode_mb(VAR_0->opaque, ref[best_pred], MV_DIR_FORWARD,\nMV_TYPE_16X16, &VAR_0->mv, VAR_14, VAR_14, 0, 0);", "if (VAR_0->mv[0][0][0] != prev_x || VAR_0->mv[0][0][1] != prev_y) {", "fixed[mb_xy] = MV_CHANGED;", "VAR_11++;", "} else", "fixed[mb_xy] = MV_UNCHANGED;", "}", "}", "}", "if (VAR_13)\nreturn;", "for (VAR_4 = 0; VAR_4 < VAR_0->mb_num; VAR_4++) {", "int mb_xy = VAR_0->mb_index2xy[VAR_4];", "if (fixed[mb_xy])\nfixed[mb_xy] = MV_FROZEN;", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41, 43 ], [ 45, 47 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75, 77 ], [ 79, 81 ], [ 85 ], [ 87 ], [ 89, 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 147, 149 ], [ 153, 155 ], [ 157 ], [ 159 ], [ 163 ], [ 165, 167 ], [ 169, 171 ], [ 173, 175 ], [ 177, 179 ], [ 181, 183 ], [ 187 ], [ 189, 191 ], [ 193, 195 ], [ 197, 199 ], [ 201, 203 ], [ 205, 207 ], [ 211 ], [ 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 ], [ 293 ], [ 295 ], [ 297 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309, 311 ], [ 313 ], [ 319 ], [ 321 ], [ 323 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 373 ], [ 375 ], [ 377 ], [ 381, 385 ], [ 389 ], [ 391 ], [ 395 ], [ 397, 399 ], [ 401 ], [ 403, 405, 407 ], [ 409 ], [ 411 ], [ 413 ], [ 415 ], [ 417 ], [ 419 ], [ 421 ], [ 423 ], [ 429 ], [ 431 ], [ 433 ], [ 435 ], [ 439, 443 ], [ 445 ], [ 447 ], [ 449, 451 ], [ 455, 457 ], [ 459, 461 ], [ 467, 469 ], [ 473, 475 ], [ 479 ], [ 481 ], [ 483 ], [ 485, 487 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 497, 499 ], [ 501 ], [ 503 ], [ 505 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519, 521 ], [ 523 ], [ 527 ], [ 529 ], [ 531 ], [ 533 ], [ 535 ], [ 537 ], [ 539 ], [ 541 ], [ 545 ], [ 547 ], [ 549 ], [ 551 ], [ 553 ], [ 557, 559 ], [ 565 ], [ 567 ], [ 569 ], [ 571 ], [ 573 ], [ 575 ], [ 577 ], [ 579 ], [ 583, 585 ], [ 589 ], [ 591 ], [ 593, 595 ], [ 597 ], [ 599 ], [ 601 ] ]
20,166
void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...) { va_list ap; va_start(ap, fmt); qtest_qmpv_discard_response(s, fmt, ap); va_end(ap); }
true
qemu
0c460dac03e7919079525d8e24ef2c4c607c219d
void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...) { va_list ap; va_start(ap, fmt); qtest_qmpv_discard_response(s, fmt, ap); va_end(ap); }
{ "code": [ " qtest_qmpv_discard_response(s, fmt, ap);" ], "line_no": [ 11 ] }
void FUNC_0(QTestState *VAR_0, const char *VAR_1, ...) { va_list ap; va_start(ap, VAR_1); qtest_qmpv_discard_response(VAR_0, VAR_1, ap); va_end(ap); }
[ "void FUNC_0(QTestState *VAR_0, const char *VAR_1, ...)\n{", "va_list ap;", "va_start(ap, VAR_1);", "qtest_qmpv_discard_response(VAR_0, VAR_1, ap);", "va_end(ap);", "}" ]
[ 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
20,167
static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c, MTPObject *o) { MTPData *d = usb_mtp_data_alloc(c); off_t offset; trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path, c->argv[1], c->argv[2]); d->fd = open(o->path, O_RDONLY); if (d->fd == -1) { return NULL; } offset = c->argv[1]; if (offset > o->stat.st_size) { offset = o->stat.st_size; } lseek(d->fd, offset, SEEK_SET); d->length = c->argv[2]; if (d->length > o->stat.st_size - offset) { d->length = o->stat.st_size - offset; } return d; }
true
qemu
2dc7fdf33d28940255f171b8ea4b692d9d5b7a7d
static MTPData *usb_mtp_get_partial_object(MTPState *s, MTPControl *c, MTPObject *o) { MTPData *d = usb_mtp_data_alloc(c); off_t offset; trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path, c->argv[1], c->argv[2]); d->fd = open(o->path, O_RDONLY); if (d->fd == -1) { return NULL; } offset = c->argv[1]; if (offset > o->stat.st_size) { offset = o->stat.st_size; } lseek(d->fd, offset, SEEK_SET); d->length = c->argv[2]; if (d->length > o->stat.st_size - offset) { d->length = o->stat.st_size - offset; } return d; }
{ "code": [], "line_no": [] }
static MTPData *FUNC_0(MTPState *s, MTPControl *c, MTPObject *o) { MTPData *d = usb_mtp_data_alloc(c); off_t offset; trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path, c->argv[1], c->argv[2]); d->fd = open(o->path, O_RDONLY); if (d->fd == -1) { return NULL; } offset = c->argv[1]; if (offset > o->stat.st_size) { offset = o->stat.st_size; } lseek(d->fd, offset, SEEK_SET); d->length = c->argv[2]; if (d->length > o->stat.st_size - offset) { d->length = o->stat.st_size - offset; } return d; }
[ "static MTPData *FUNC_0(MTPState *s, MTPControl *c,\nMTPObject *o)\n{", "MTPData *d = usb_mtp_data_alloc(c);", "off_t offset;", "trace_usb_mtp_op_get_partial_object(s->dev.addr, o->handle, o->path,\nc->argv[1], c->argv[2]);", "d->fd = open(o->path, O_RDONLY);", "if (d->fd == -1) {", "return NULL;", "}", "offset = c->argv[1];", "if (offset > o->stat.st_size) {", "offset = o->stat.st_size;", "}", "lseek(d->fd, offset, SEEK_SET);", "d->length = c->argv[2];", "if (d->length > o->stat.st_size - offset) {", "d->length = o->stat.st_size - offset;", "}", "return d;", "}" ]
[ 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 ], [ 24 ], [ 26 ], [ 30 ], [ 32 ], [ 34 ], [ 36 ], [ 38 ], [ 42 ], [ 44 ], [ 46 ], [ 48 ], [ 52 ], [ 54 ] ]
20,168
static void set_int16(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { DeviceState *dev = DEVICE(obj); Property *prop = opaque; int16_t *ptr = qdev_get_prop_ptr(dev, prop); Error *local_err = NULL; int64_t value; if (dev->state != DEV_STATE_CREATED) { error_set(errp, QERR_PERMISSION_DENIED); return; } visit_type_int(v, &value, name, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (value > prop->info->min && value <= prop->info->max) { *ptr = value; } else { error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, dev->id?:"", name, value, prop->info->min, prop->info->max); } }
true
qemu
6350b0904615cc0531cc3059ea34db5c009c88aa
static void set_int16(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { DeviceState *dev = DEVICE(obj); Property *prop = opaque; int16_t *ptr = qdev_get_prop_ptr(dev, prop); Error *local_err = NULL; int64_t value; if (dev->state != DEV_STATE_CREATED) { error_set(errp, QERR_PERMISSION_DENIED); return; } visit_type_int(v, &value, name, &local_err); if (local_err) { error_propagate(errp, local_err); return; } if (value > prop->info->min && value <= prop->info->max) { *ptr = value; } else { error_set(errp, QERR_PROPERTY_VALUE_OUT_OF_RANGE, dev->id?:"", name, value, prop->info->min, prop->info->max); } }
{ "code": [ " if (value > prop->info->min && value <= prop->info->max) {", " if (value > prop->info->min && value <= prop->info->max) {", " if (value > prop->info->min && value <= prop->info->max) {" ], "line_no": [ 39, 39, 39 ] }
static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2, const char *VAR_3, Error **VAR_4) { DeviceState *dev = DEVICE(VAR_0); Property *prop = VAR_2; int16_t *ptr = qdev_get_prop_ptr(dev, prop); Error *local_err = NULL; int64_t value; if (dev->state != DEV_STATE_CREATED) { error_set(VAR_4, QERR_PERMISSION_DENIED); return; } visit_type_int(VAR_1, &value, VAR_3, &local_err); if (local_err) { error_propagate(VAR_4, local_err); return; } if (value > prop->info->min && value <= prop->info->max) { *ptr = value; } else { error_set(VAR_4, QERR_PROPERTY_VALUE_OUT_OF_RANGE, dev->id?:"", VAR_3, value, prop->info->min, prop->info->max); } }
[ "static void FUNC_0(Object *VAR_0, Visitor *VAR_1, void *VAR_2,\nconst char *VAR_3, Error **VAR_4)\n{", "DeviceState *dev = DEVICE(VAR_0);", "Property *prop = VAR_2;", "int16_t *ptr = qdev_get_prop_ptr(dev, prop);", "Error *local_err = NULL;", "int64_t value;", "if (dev->state != DEV_STATE_CREATED) {", "error_set(VAR_4, QERR_PERMISSION_DENIED);", "return;", "}", "visit_type_int(VAR_1, &value, VAR_3, &local_err);", "if (local_err) {", "error_propagate(VAR_4, local_err);", "return;", "}", "if (value > prop->info->min && value <= prop->info->max) {", "*ptr = value;", "} else {", "error_set(VAR_4, QERR_PROPERTY_VALUE_OUT_OF_RANGE,\ndev->id?:\"\", VAR_3, value, prop->info->min,\nprop->info->max);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45, 47, 49 ], [ 51 ], [ 53 ] ]
20,169
static av_cold int nvenc_encode_init(AVCodecContext *avctx) { NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS encode_session_params = { 0 }; NV_ENC_PRESET_CONFIG preset_config = { 0 }; CUcontext cu_context_curr; CUresult cu_res; GUID encoder_preset = NV_ENC_PRESET_HQ_GUID; GUID codec; NVENCSTATUS nv_status = NV_ENC_SUCCESS; int surfaceCount = 0; int i, num_mbs; int isLL = 0; int res = 0; int dw, dh; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; if (!nvenc_dyload_nvenc(avctx)) return AVERROR_EXTERNAL; avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) { res = AVERROR(ENOMEM); goto error; } ctx->last_dts = AV_NOPTS_VALUE; ctx->encode_config.version = NV_ENC_CONFIG_VER; ctx->init_encode_params.version = NV_ENC_INITIALIZE_PARAMS_VER; preset_config.version = NV_ENC_PRESET_CONFIG_VER; preset_config.presetCfg.version = NV_ENC_CONFIG_VER; encode_session_params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER; encode_session_params.apiVersion = NVENCAPI_VERSION; if (ctx->gpu >= dl_fn->nvenc_device_count) { av_log(avctx, AV_LOG_FATAL, "Requested GPU %d, but only %d GPUs are available!\n", ctx->gpu, dl_fn->nvenc_device_count); res = AVERROR(EINVAL); goto error; } ctx->cu_context = NULL; cu_res = dl_fn->cu_ctx_create(&ctx->cu_context, 0, dl_fn->nvenc_devices[ctx->gpu]); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed creating CUDA context for NVENC: 0x%x\n", (int)cu_res); res = AVERROR_EXTERNAL; goto error; } cu_res = dl_fn->cu_ctx_pop_current(&cu_context_curr); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed popping CUDA context: 0x%x\n", (int)cu_res); res = AVERROR_EXTERNAL; goto error; } encode_session_params.device = ctx->cu_context; encode_session_params.deviceType = NV_ENC_DEVICE_TYPE_CUDA; nv_status = p_nvenc->nvEncOpenEncodeSessionEx(&encode_session_params, &ctx->nvencoder); if (nv_status != NV_ENC_SUCCESS) { ctx->nvencoder = NULL; av_log(avctx, AV_LOG_FATAL, "OpenEncodeSessionEx failed: 0x%x - invalid license key?\n", (int)nv_status); res = AVERROR_EXTERNAL; goto error; } if (ctx->preset) { if (!strcmp(ctx->preset, "hp")) { encoder_preset = NV_ENC_PRESET_HP_GUID; } else if (!strcmp(ctx->preset, "hq")) { encoder_preset = NV_ENC_PRESET_HQ_GUID; } else if (!strcmp(ctx->preset, "bd")) { encoder_preset = NV_ENC_PRESET_BD_GUID; } else if (!strcmp(ctx->preset, "ll")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID; isLL = 1; } else if (!strcmp(ctx->preset, "llhp")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HP_GUID; isLL = 1; } else if (!strcmp(ctx->preset, "llhq")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; isLL = 1; } else if (!strcmp(ctx->preset, "default")) { encoder_preset = NV_ENC_PRESET_DEFAULT_GUID; } else { av_log(avctx, AV_LOG_FATAL, "Preset \"%s\" is unknown! Supported presets: hp, hq, bd, ll, llhp, llhq, default\n", ctx->preset); res = AVERROR(EINVAL); goto error; } } switch (avctx->codec->id) { case AV_CODEC_ID_H264: codec = NV_ENC_CODEC_H264_GUID; break; case AV_CODEC_ID_H265: codec = NV_ENC_CODEC_HEVC_GUID; break; default: av_log(avctx, AV_LOG_ERROR, "nvenc: Unknown codec name\n"); res = AVERROR(EINVAL); goto error; } nv_status = p_nvenc->nvEncGetEncodePresetConfig(ctx->nvencoder, codec, encoder_preset, &preset_config); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "GetEncodePresetConfig failed: 0x%x\n", (int)nv_status); res = AVERROR_EXTERNAL; goto error; } ctx->init_encode_params.encodeGUID = codec; ctx->init_encode_params.encodeHeight = avctx->height; ctx->init_encode_params.encodeWidth = avctx->width; if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den && (avctx->sample_aspect_ratio.num != 1 || avctx->sample_aspect_ratio.num != 1)) { av_reduce(&dw, &dh, avctx->width * avctx->sample_aspect_ratio.num, avctx->height * avctx->sample_aspect_ratio.den, 1024 * 1024); ctx->init_encode_params.darHeight = dh; ctx->init_encode_params.darWidth = dw; } else { ctx->init_encode_params.darHeight = avctx->height; ctx->init_encode_params.darWidth = avctx->width; } // De-compensate for hardware, dubiously, trying to compensate for // playback at 704 pixel width. if (avctx->width == 720 && (avctx->height == 480 || avctx->height == 576)) { av_reduce(&dw, &dh, ctx->init_encode_params.darWidth * 44, ctx->init_encode_params.darHeight * 45, 1024 * 1024); ctx->init_encode_params.darHeight = dh; ctx->init_encode_params.darWidth = dw; } ctx->init_encode_params.frameRateNum = avctx->time_base.den; ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame; num_mbs = ((avctx->width + 15) >> 4) * ((avctx->height + 15) >> 4); ctx->max_surface_count = (num_mbs >= 8160) ? 32 : 48; ctx->init_encode_params.enableEncodeAsync = 0; ctx->init_encode_params.enablePTD = 1; ctx->init_encode_params.presetGUID = encoder_preset; ctx->init_encode_params.encodeConfig = &ctx->encode_config; memcpy(&ctx->encode_config, &preset_config.presetCfg, sizeof(ctx->encode_config)); ctx->encode_config.version = NV_ENC_CONFIG_VER; if (avctx->refs >= 0) { /* 0 means "let the hardware decide" */ switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.maxNumRefFrames = avctx->refs; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB = avctx->refs; break; /* Earlier switch/case will return if unknown codec is passed. */ } } if (avctx->gop_size > 0) { if (avctx->max_b_frames >= 0) { /* 0 is intra-only, 1 is I/P only, 2 is one B Frame, 3 two B frames, and so on. */ ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1; } ctx->encode_config.gopLength = avctx->gop_size; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = avctx->gop_size; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = avctx->gop_size; break; /* Earlier switch/case will return if unknown codec is passed. */ } } else if (avctx->gop_size == 0) { ctx->encode_config.frameIntervalP = 0; ctx->encode_config.gopLength = 1; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = 1; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = 1; break; /* Earlier switch/case will return if unknown codec is passed. */ } } /* when there're b frames, set dts offset */ if (ctx->encode_config.frameIntervalP >= 2) ctx->last_dts = -2; if (avctx->bit_rate > 0) ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate; if (avctx->rc_max_rate > 0) ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate; if (ctx->cbr) { if (!ctx->twopass) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } else if (ctx->twopass == 1 || isLL) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_2_PASS_QUALITY; if (avctx->codec->id == AV_CODEC_ID_H264) { ctx->encode_config.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE; ctx->encode_config.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE; } if (!isLL) av_log(avctx, AV_LOG_WARNING, "Twopass mode is only known to work with low latency (ll, llhq, llhp) presets.\n"); } else { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } } else if (avctx->global_quality > 0) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; ctx->encode_config.rcParams.constQP.qpInterB = avctx->global_quality; ctx->encode_config.rcParams.constQP.qpInterP = avctx->global_quality; ctx->encode_config.rcParams.constQP.qpIntra = avctx->global_quality; avctx->qmin = -1; avctx->qmax = -1; } else if (avctx->qmin >= 0 && avctx->qmax >= 0) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR; ctx->encode_config.rcParams.enableMinQP = 1; ctx->encode_config.rcParams.enableMaxQP = 1; ctx->encode_config.rcParams.minQP.qpInterB = avctx->qmin; ctx->encode_config.rcParams.minQP.qpInterP = avctx->qmin; ctx->encode_config.rcParams.minQP.qpIntra = avctx->qmin; ctx->encode_config.rcParams.maxQP.qpInterB = avctx->qmax; ctx->encode_config.rcParams.maxQP.qpInterP = avctx->qmax; ctx->encode_config.rcParams.maxQP.qpIntra = avctx->qmax; } if (avctx->rc_buffer_size > 0) ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size; if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD; } else { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME; } switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag = 1; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag = 1; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourMatrix = avctx->colorspace; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourPrimaries = avctx->color_primaries; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.transferCharacteristics = avctx->color_trc; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = avctx->color_range == AVCOL_RANGE_JPEG; ctx->encode_config.encodeCodecConfig.h264Config.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; ctx->encode_config.encodeCodecConfig.h264Config.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; if (!ctx->profile) { switch (avctx->profile) { case FF_PROFILE_H264_BASELINE: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; break; case FF_PROFILE_H264_MAIN: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; break; case FF_PROFILE_H264_HIGH: case FF_PROFILE_UNKNOWN: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; break; default: av_log(avctx, AV_LOG_WARNING, "Unsupported profile requested, falling back to high\n"); ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; break; } } else { if (!strcmp(ctx->profile, "high")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; avctx->profile = FF_PROFILE_H264_HIGH; } else if (!strcmp(ctx->profile, "main")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; avctx->profile = FF_PROFILE_H264_MAIN; } else if (!strcmp(ctx->profile, "baseline")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; avctx->profile = FF_PROFILE_H264_BASELINE; } else { av_log(avctx, AV_LOG_FATAL, "Profile \"%s\" is unknown! Supported profiles: high, main, baseline\n", ctx->profile); res = AVERROR(EINVAL); goto error; } } if (ctx->level) { res = input_string_to_uint32(avctx, nvenc_h264_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.h264Config.level); if (res) { av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2, 5, 5.1\n", ctx->level); goto error; } } else { ctx->encode_config.encodeCodecConfig.h264Config.level = NV_ENC_LEVEL_AUTOSELECT; } break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; ctx->encode_config.encodeCodecConfig.hevcConfig.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; /* No other profile is supported in the current SDK version 5 */ ctx->encode_config.profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID; avctx->profile = FF_PROFILE_HEVC_MAIN; if (ctx->level) { res = input_string_to_uint32(avctx, nvenc_hevc_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.hevcConfig.level); if (res) { av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2\n", ctx->level); goto error; } } else { ctx->encode_config.encodeCodecConfig.hevcConfig.level = NV_ENC_LEVEL_AUTOSELECT; } if (ctx->tier) { if (!strcmp(ctx->tier, "main")) { ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_MAIN; } else if (!strcmp(ctx->tier, "high")) { ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_HIGH; } else { av_log(avctx, AV_LOG_FATAL, "Tier \"%s\" is unknown! Supported tiers: main, high\n", ctx->tier); res = AVERROR(EINVAL); goto error; } } break; /* Earlier switch/case will return if unknown codec is passed. */ } nv_status = p_nvenc->nvEncInitializeEncoder(ctx->nvencoder, &ctx->init_encode_params); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "InitializeEncoder failed: 0x%x\n", (int)nv_status); res = AVERROR_EXTERNAL; goto error; } ctx->input_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->input_surfaces)); if (!ctx->input_surfaces) { res = AVERROR(ENOMEM); goto error; } ctx->output_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->output_surfaces)); if (!ctx->output_surfaces) { res = AVERROR(ENOMEM); goto error; } for (surfaceCount = 0; surfaceCount < ctx->max_surface_count; ++surfaceCount) { NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 }; NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 }; allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER; allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER; allocSurf.width = (avctx->width + 31) & ~31; allocSurf.height = (avctx->height + 31) & ~31; allocSurf.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; switch (avctx->pix_fmt) { case AV_PIX_FMT_YUV420P: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YV12_PL; break; case AV_PIX_FMT_NV12: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_NV12_PL; break; case AV_PIX_FMT_YUV444P: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YUV444_PL; break; default: av_log(avctx, AV_LOG_FATAL, "Invalid input pixel format\n"); res = AVERROR(EINVAL); goto error; } nv_status = p_nvenc->nvEncCreateInputBuffer(ctx->nvencoder, &allocSurf); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "CreateInputBuffer failed\n"); res = AVERROR_EXTERNAL; goto error; } ctx->input_surfaces[surfaceCount].lockCount = 0; ctx->input_surfaces[surfaceCount].input_surface = allocSurf.inputBuffer; ctx->input_surfaces[surfaceCount].format = allocSurf.bufferFmt; ctx->input_surfaces[surfaceCount].width = allocSurf.width; ctx->input_surfaces[surfaceCount].height = allocSurf.height; /* 1MB is large enough to hold most output frames. NVENC increases this automaticaly if it's not enough. */ allocOut.size = 1024 * 1024; allocOut.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; nv_status = p_nvenc->nvEncCreateBitstreamBuffer(ctx->nvencoder, &allocOut); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "CreateBitstreamBuffer failed\n"); ctx->output_surfaces[surfaceCount++].output_surface = NULL; res = AVERROR_EXTERNAL; goto error; } ctx->output_surfaces[surfaceCount].output_surface = allocOut.bitstreamBuffer; ctx->output_surfaces[surfaceCount].size = allocOut.size; ctx->output_surfaces[surfaceCount].busy = 0; } if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { uint32_t outSize = 0; char tmpHeader[256]; NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; payload.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER; payload.spsppsBuffer = tmpHeader; payload.inBufferSize = sizeof(tmpHeader); payload.outSPSPPSPayloadSize = &outSize; nv_status = p_nvenc->nvEncGetSequenceParams(ctx->nvencoder, &payload); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "GetSequenceParams failed\n"); goto error; } avctx->extradata_size = outSize; avctx->extradata = av_mallocz(outSize + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { res = AVERROR(ENOMEM); goto error; } memcpy(avctx->extradata, tmpHeader, outSize); } if (ctx->encode_config.frameIntervalP > 1) avctx->has_b_frames = 2; if (ctx->encode_config.rcParams.averageBitRate > 0) avctx->bit_rate = ctx->encode_config.rcParams.averageBitRate; return 0; error: for (i = 0; i < surfaceCount; ++i) { p_nvenc->nvEncDestroyInputBuffer(ctx->nvencoder, ctx->input_surfaces[i].input_surface); if (ctx->output_surfaces[i].output_surface) p_nvenc->nvEncDestroyBitstreamBuffer(ctx->nvencoder, ctx->output_surfaces[i].output_surface); } if (ctx->nvencoder) p_nvenc->nvEncDestroyEncoder(ctx->nvencoder); if (ctx->cu_context) dl_fn->cu_ctx_destroy(ctx->cu_context); av_frame_free(&avctx->coded_frame); nvenc_unload_nvenc(avctx); ctx->nvencoder = NULL; ctx->cu_context = NULL; return res; }
false
FFmpeg
671bdd4b0977c6cc77bdc55883ac841a7c4af802
static av_cold int nvenc_encode_init(AVCodecContext *avctx) { NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS encode_session_params = { 0 }; NV_ENC_PRESET_CONFIG preset_config = { 0 }; CUcontext cu_context_curr; CUresult cu_res; GUID encoder_preset = NV_ENC_PRESET_HQ_GUID; GUID codec; NVENCSTATUS nv_status = NV_ENC_SUCCESS; int surfaceCount = 0; int i, num_mbs; int isLL = 0; int res = 0; int dw, dh; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; if (!nvenc_dyload_nvenc(avctx)) return AVERROR_EXTERNAL; avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) { res = AVERROR(ENOMEM); goto error; } ctx->last_dts = AV_NOPTS_VALUE; ctx->encode_config.version = NV_ENC_CONFIG_VER; ctx->init_encode_params.version = NV_ENC_INITIALIZE_PARAMS_VER; preset_config.version = NV_ENC_PRESET_CONFIG_VER; preset_config.presetCfg.version = NV_ENC_CONFIG_VER; encode_session_params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER; encode_session_params.apiVersion = NVENCAPI_VERSION; if (ctx->gpu >= dl_fn->nvenc_device_count) { av_log(avctx, AV_LOG_FATAL, "Requested GPU %d, but only %d GPUs are available!\n", ctx->gpu, dl_fn->nvenc_device_count); res = AVERROR(EINVAL); goto error; } ctx->cu_context = NULL; cu_res = dl_fn->cu_ctx_create(&ctx->cu_context, 0, dl_fn->nvenc_devices[ctx->gpu]); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed creating CUDA context for NVENC: 0x%x\n", (int)cu_res); res = AVERROR_EXTERNAL; goto error; } cu_res = dl_fn->cu_ctx_pop_current(&cu_context_curr); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed popping CUDA context: 0x%x\n", (int)cu_res); res = AVERROR_EXTERNAL; goto error; } encode_session_params.device = ctx->cu_context; encode_session_params.deviceType = NV_ENC_DEVICE_TYPE_CUDA; nv_status = p_nvenc->nvEncOpenEncodeSessionEx(&encode_session_params, &ctx->nvencoder); if (nv_status != NV_ENC_SUCCESS) { ctx->nvencoder = NULL; av_log(avctx, AV_LOG_FATAL, "OpenEncodeSessionEx failed: 0x%x - invalid license key?\n", (int)nv_status); res = AVERROR_EXTERNAL; goto error; } if (ctx->preset) { if (!strcmp(ctx->preset, "hp")) { encoder_preset = NV_ENC_PRESET_HP_GUID; } else if (!strcmp(ctx->preset, "hq")) { encoder_preset = NV_ENC_PRESET_HQ_GUID; } else if (!strcmp(ctx->preset, "bd")) { encoder_preset = NV_ENC_PRESET_BD_GUID; } else if (!strcmp(ctx->preset, "ll")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID; isLL = 1; } else if (!strcmp(ctx->preset, "llhp")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HP_GUID; isLL = 1; } else if (!strcmp(ctx->preset, "llhq")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; isLL = 1; } else if (!strcmp(ctx->preset, "default")) { encoder_preset = NV_ENC_PRESET_DEFAULT_GUID; } else { av_log(avctx, AV_LOG_FATAL, "Preset \"%s\" is unknown! Supported presets: hp, hq, bd, ll, llhp, llhq, default\n", ctx->preset); res = AVERROR(EINVAL); goto error; } } switch (avctx->codec->id) { case AV_CODEC_ID_H264: codec = NV_ENC_CODEC_H264_GUID; break; case AV_CODEC_ID_H265: codec = NV_ENC_CODEC_HEVC_GUID; break; default: av_log(avctx, AV_LOG_ERROR, "nvenc: Unknown codec name\n"); res = AVERROR(EINVAL); goto error; } nv_status = p_nvenc->nvEncGetEncodePresetConfig(ctx->nvencoder, codec, encoder_preset, &preset_config); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "GetEncodePresetConfig failed: 0x%x\n", (int)nv_status); res = AVERROR_EXTERNAL; goto error; } ctx->init_encode_params.encodeGUID = codec; ctx->init_encode_params.encodeHeight = avctx->height; ctx->init_encode_params.encodeWidth = avctx->width; if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den && (avctx->sample_aspect_ratio.num != 1 || avctx->sample_aspect_ratio.num != 1)) { av_reduce(&dw, &dh, avctx->width * avctx->sample_aspect_ratio.num, avctx->height * avctx->sample_aspect_ratio.den, 1024 * 1024); ctx->init_encode_params.darHeight = dh; ctx->init_encode_params.darWidth = dw; } else { ctx->init_encode_params.darHeight = avctx->height; ctx->init_encode_params.darWidth = avctx->width; } if (avctx->width == 720 && (avctx->height == 480 || avctx->height == 576)) { av_reduce(&dw, &dh, ctx->init_encode_params.darWidth * 44, ctx->init_encode_params.darHeight * 45, 1024 * 1024); ctx->init_encode_params.darHeight = dh; ctx->init_encode_params.darWidth = dw; } ctx->init_encode_params.frameRateNum = avctx->time_base.den; ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame; num_mbs = ((avctx->width + 15) >> 4) * ((avctx->height + 15) >> 4); ctx->max_surface_count = (num_mbs >= 8160) ? 32 : 48; ctx->init_encode_params.enableEncodeAsync = 0; ctx->init_encode_params.enablePTD = 1; ctx->init_encode_params.presetGUID = encoder_preset; ctx->init_encode_params.encodeConfig = &ctx->encode_config; memcpy(&ctx->encode_config, &preset_config.presetCfg, sizeof(ctx->encode_config)); ctx->encode_config.version = NV_ENC_CONFIG_VER; if (avctx->refs >= 0) { switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.maxNumRefFrames = avctx->refs; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB = avctx->refs; break; } } if (avctx->gop_size > 0) { if (avctx->max_b_frames >= 0) { ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1; } ctx->encode_config.gopLength = avctx->gop_size; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = avctx->gop_size; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = avctx->gop_size; break; } } else if (avctx->gop_size == 0) { ctx->encode_config.frameIntervalP = 0; ctx->encode_config.gopLength = 1; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = 1; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = 1; break; } } if (ctx->encode_config.frameIntervalP >= 2) ctx->last_dts = -2; if (avctx->bit_rate > 0) ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate; if (avctx->rc_max_rate > 0) ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate; if (ctx->cbr) { if (!ctx->twopass) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } else if (ctx->twopass == 1 || isLL) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_2_PASS_QUALITY; if (avctx->codec->id == AV_CODEC_ID_H264) { ctx->encode_config.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE; ctx->encode_config.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE; } if (!isLL) av_log(avctx, AV_LOG_WARNING, "Twopass mode is only known to work with low latency (ll, llhq, llhp) presets.\n"); } else { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } } else if (avctx->global_quality > 0) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; ctx->encode_config.rcParams.constQP.qpInterB = avctx->global_quality; ctx->encode_config.rcParams.constQP.qpInterP = avctx->global_quality; ctx->encode_config.rcParams.constQP.qpIntra = avctx->global_quality; avctx->qmin = -1; avctx->qmax = -1; } else if (avctx->qmin >= 0 && avctx->qmax >= 0) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR; ctx->encode_config.rcParams.enableMinQP = 1; ctx->encode_config.rcParams.enableMaxQP = 1; ctx->encode_config.rcParams.minQP.qpInterB = avctx->qmin; ctx->encode_config.rcParams.minQP.qpInterP = avctx->qmin; ctx->encode_config.rcParams.minQP.qpIntra = avctx->qmin; ctx->encode_config.rcParams.maxQP.qpInterB = avctx->qmax; ctx->encode_config.rcParams.maxQP.qpInterP = avctx->qmax; ctx->encode_config.rcParams.maxQP.qpIntra = avctx->qmax; } if (avctx->rc_buffer_size > 0) ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size; if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD; } else { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME; } switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag = 1; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag = 1; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourMatrix = avctx->colorspace; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourPrimaries = avctx->color_primaries; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.transferCharacteristics = avctx->color_trc; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = avctx->color_range == AVCOL_RANGE_JPEG; ctx->encode_config.encodeCodecConfig.h264Config.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; ctx->encode_config.encodeCodecConfig.h264Config.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; if (!ctx->profile) { switch (avctx->profile) { case FF_PROFILE_H264_BASELINE: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; break; case FF_PROFILE_H264_MAIN: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; break; case FF_PROFILE_H264_HIGH: case FF_PROFILE_UNKNOWN: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; break; default: av_log(avctx, AV_LOG_WARNING, "Unsupported profile requested, falling back to high\n"); ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; break; } } else { if (!strcmp(ctx->profile, "high")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; avctx->profile = FF_PROFILE_H264_HIGH; } else if (!strcmp(ctx->profile, "main")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; avctx->profile = FF_PROFILE_H264_MAIN; } else if (!strcmp(ctx->profile, "baseline")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; avctx->profile = FF_PROFILE_H264_BASELINE; } else { av_log(avctx, AV_LOG_FATAL, "Profile \"%s\" is unknown! Supported profiles: high, main, baseline\n", ctx->profile); res = AVERROR(EINVAL); goto error; } } if (ctx->level) { res = input_string_to_uint32(avctx, nvenc_h264_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.h264Config.level); if (res) { av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2, 5, 5.1\n", ctx->level); goto error; } } else { ctx->encode_config.encodeCodecConfig.h264Config.level = NV_ENC_LEVEL_AUTOSELECT; } break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; ctx->encode_config.encodeCodecConfig.hevcConfig.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; ctx->encode_config.profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID; avctx->profile = FF_PROFILE_HEVC_MAIN; if (ctx->level) { res = input_string_to_uint32(avctx, nvenc_hevc_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.hevcConfig.level); if (res) { av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2\n", ctx->level); goto error; } } else { ctx->encode_config.encodeCodecConfig.hevcConfig.level = NV_ENC_LEVEL_AUTOSELECT; } if (ctx->tier) { if (!strcmp(ctx->tier, "main")) { ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_MAIN; } else if (!strcmp(ctx->tier, "high")) { ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_HIGH; } else { av_log(avctx, AV_LOG_FATAL, "Tier \"%s\" is unknown! Supported tiers: main, high\n", ctx->tier); res = AVERROR(EINVAL); goto error; } } break; } nv_status = p_nvenc->nvEncInitializeEncoder(ctx->nvencoder, &ctx->init_encode_params); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "InitializeEncoder failed: 0x%x\n", (int)nv_status); res = AVERROR_EXTERNAL; goto error; } ctx->input_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->input_surfaces)); if (!ctx->input_surfaces) { res = AVERROR(ENOMEM); goto error; } ctx->output_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->output_surfaces)); if (!ctx->output_surfaces) { res = AVERROR(ENOMEM); goto error; } for (surfaceCount = 0; surfaceCount < ctx->max_surface_count; ++surfaceCount) { NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 }; NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 }; allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER; allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER; allocSurf.width = (avctx->width + 31) & ~31; allocSurf.height = (avctx->height + 31) & ~31; allocSurf.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; switch (avctx->pix_fmt) { case AV_PIX_FMT_YUV420P: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YV12_PL; break; case AV_PIX_FMT_NV12: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_NV12_PL; break; case AV_PIX_FMT_YUV444P: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YUV444_PL; break; default: av_log(avctx, AV_LOG_FATAL, "Invalid input pixel format\n"); res = AVERROR(EINVAL); goto error; } nv_status = p_nvenc->nvEncCreateInputBuffer(ctx->nvencoder, &allocSurf); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "CreateInputBuffer failed\n"); res = AVERROR_EXTERNAL; goto error; } ctx->input_surfaces[surfaceCount].lockCount = 0; ctx->input_surfaces[surfaceCount].input_surface = allocSurf.inputBuffer; ctx->input_surfaces[surfaceCount].format = allocSurf.bufferFmt; ctx->input_surfaces[surfaceCount].width = allocSurf.width; ctx->input_surfaces[surfaceCount].height = allocSurf.height; allocOut.size = 1024 * 1024; allocOut.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; nv_status = p_nvenc->nvEncCreateBitstreamBuffer(ctx->nvencoder, &allocOut); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "CreateBitstreamBuffer failed\n"); ctx->output_surfaces[surfaceCount++].output_surface = NULL; res = AVERROR_EXTERNAL; goto error; } ctx->output_surfaces[surfaceCount].output_surface = allocOut.bitstreamBuffer; ctx->output_surfaces[surfaceCount].size = allocOut.size; ctx->output_surfaces[surfaceCount].busy = 0; } if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { uint32_t outSize = 0; char tmpHeader[256]; NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; payload.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER; payload.spsppsBuffer = tmpHeader; payload.inBufferSize = sizeof(tmpHeader); payload.outSPSPPSPayloadSize = &outSize; nv_status = p_nvenc->nvEncGetSequenceParams(ctx->nvencoder, &payload); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "GetSequenceParams failed\n"); goto error; } avctx->extradata_size = outSize; avctx->extradata = av_mallocz(outSize + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { res = AVERROR(ENOMEM); goto error; } memcpy(avctx->extradata, tmpHeader, outSize); } if (ctx->encode_config.frameIntervalP > 1) avctx->has_b_frames = 2; if (ctx->encode_config.rcParams.averageBitRate > 0) avctx->bit_rate = ctx->encode_config.rcParams.averageBitRate; return 0; error: for (i = 0; i < surfaceCount; ++i) { p_nvenc->nvEncDestroyInputBuffer(ctx->nvencoder, ctx->input_surfaces[i].input_surface); if (ctx->output_surfaces[i].output_surface) p_nvenc->nvEncDestroyBitstreamBuffer(ctx->nvencoder, ctx->output_surfaces[i].output_surface); } if (ctx->nvencoder) p_nvenc->nvEncDestroyEncoder(ctx->nvencoder); if (ctx->cu_context) dl_fn->cu_ctx_destroy(ctx->cu_context); av_frame_free(&avctx->coded_frame); nvenc_unload_nvenc(avctx); ctx->nvencoder = NULL; ctx->cu_context = NULL; return res; }
{ "code": [], "line_no": [] }
static av_cold int FUNC_0(AVCodecContext *avctx) { NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS encode_session_params = { 0 }; NV_ENC_PRESET_CONFIG preset_config = { 0 }; CUcontext cu_context_curr; CUresult cu_res; GUID encoder_preset = NV_ENC_PRESET_HQ_GUID; GUID codec; NVENCSTATUS nv_status = NV_ENC_SUCCESS; int VAR_0 = 0; int VAR_1, VAR_2; int VAR_3 = 0; int VAR_4 = 0; int VAR_5, VAR_6; NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; if (!nvenc_dyload_nvenc(avctx)) return AVERROR_EXTERNAL; avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) { VAR_4 = AVERROR(ENOMEM); goto error; } ctx->last_dts = AV_NOPTS_VALUE; ctx->encode_config.version = NV_ENC_CONFIG_VER; ctx->init_encode_params.version = NV_ENC_INITIALIZE_PARAMS_VER; preset_config.version = NV_ENC_PRESET_CONFIG_VER; preset_config.presetCfg.version = NV_ENC_CONFIG_VER; encode_session_params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER; encode_session_params.apiVersion = NVENCAPI_VERSION; if (ctx->gpu >= dl_fn->nvenc_device_count) { av_log(avctx, AV_LOG_FATAL, "Requested GPU %d, but only %d GPUs are available!\n", ctx->gpu, dl_fn->nvenc_device_count); VAR_4 = AVERROR(EINVAL); goto error; } ctx->cu_context = NULL; cu_res = dl_fn->cu_ctx_create(&ctx->cu_context, 0, dl_fn->nvenc_devices[ctx->gpu]); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed creating CUDA context for NVENC: 0x%x\n", (int)cu_res); VAR_4 = AVERROR_EXTERNAL; goto error; } cu_res = dl_fn->cu_ctx_pop_current(&cu_context_curr); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed popping CUDA context: 0x%x\n", (int)cu_res); VAR_4 = AVERROR_EXTERNAL; goto error; } encode_session_params.device = ctx->cu_context; encode_session_params.deviceType = NV_ENC_DEVICE_TYPE_CUDA; nv_status = p_nvenc->nvEncOpenEncodeSessionEx(&encode_session_params, &ctx->nvencoder); if (nv_status != NV_ENC_SUCCESS) { ctx->nvencoder = NULL; av_log(avctx, AV_LOG_FATAL, "OpenEncodeSessionEx failed: 0x%x - invalid license key?\n", (int)nv_status); VAR_4 = AVERROR_EXTERNAL; goto error; } if (ctx->preset) { if (!strcmp(ctx->preset, "hp")) { encoder_preset = NV_ENC_PRESET_HP_GUID; } else if (!strcmp(ctx->preset, "hq")) { encoder_preset = NV_ENC_PRESET_HQ_GUID; } else if (!strcmp(ctx->preset, "bd")) { encoder_preset = NV_ENC_PRESET_BD_GUID; } else if (!strcmp(ctx->preset, "ll")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID; VAR_3 = 1; } else if (!strcmp(ctx->preset, "llhp")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HP_GUID; VAR_3 = 1; } else if (!strcmp(ctx->preset, "llhq")) { encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID; VAR_3 = 1; } else if (!strcmp(ctx->preset, "default")) { encoder_preset = NV_ENC_PRESET_DEFAULT_GUID; } else { av_log(avctx, AV_LOG_FATAL, "Preset \"%s\" is unknown! Supported presets: hp, hq, bd, ll, llhp, llhq, default\n", ctx->preset); VAR_4 = AVERROR(EINVAL); goto error; } } switch (avctx->codec->id) { case AV_CODEC_ID_H264: codec = NV_ENC_CODEC_H264_GUID; break; case AV_CODEC_ID_H265: codec = NV_ENC_CODEC_HEVC_GUID; break; default: av_log(avctx, AV_LOG_ERROR, "nvenc: Unknown codec name\n"); VAR_4 = AVERROR(EINVAL); goto error; } nv_status = p_nvenc->nvEncGetEncodePresetConfig(ctx->nvencoder, codec, encoder_preset, &preset_config); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "GetEncodePresetConfig failed: 0x%x\n", (int)nv_status); VAR_4 = AVERROR_EXTERNAL; goto error; } ctx->init_encode_params.encodeGUID = codec; ctx->init_encode_params.encodeHeight = avctx->height; ctx->init_encode_params.encodeWidth = avctx->width; if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den && (avctx->sample_aspect_ratio.num != 1 || avctx->sample_aspect_ratio.num != 1)) { av_reduce(&VAR_5, &VAR_6, avctx->width * avctx->sample_aspect_ratio.num, avctx->height * avctx->sample_aspect_ratio.den, 1024 * 1024); ctx->init_encode_params.darHeight = VAR_6; ctx->init_encode_params.darWidth = VAR_5; } else { ctx->init_encode_params.darHeight = avctx->height; ctx->init_encode_params.darWidth = avctx->width; } if (avctx->width == 720 && (avctx->height == 480 || avctx->height == 576)) { av_reduce(&VAR_5, &VAR_6, ctx->init_encode_params.darWidth * 44, ctx->init_encode_params.darHeight * 45, 1024 * 1024); ctx->init_encode_params.darHeight = VAR_6; ctx->init_encode_params.darWidth = VAR_5; } ctx->init_encode_params.frameRateNum = avctx->time_base.den; ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame; VAR_2 = ((avctx->width + 15) >> 4) * ((avctx->height + 15) >> 4); ctx->max_surface_count = (VAR_2 >= 8160) ? 32 : 48; ctx->init_encode_params.enableEncodeAsync = 0; ctx->init_encode_params.enablePTD = 1; ctx->init_encode_params.presetGUID = encoder_preset; ctx->init_encode_params.encodeConfig = &ctx->encode_config; memcpy(&ctx->encode_config, &preset_config.presetCfg, sizeof(ctx->encode_config)); ctx->encode_config.version = NV_ENC_CONFIG_VER; if (avctx->refs >= 0) { switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.maxNumRefFrames = avctx->refs; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB = avctx->refs; break; } } if (avctx->gop_size > 0) { if (avctx->max_b_frames >= 0) { ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1; } ctx->encode_config.gopLength = avctx->gop_size; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = avctx->gop_size; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = avctx->gop_size; break; } } else if (avctx->gop_size == 0) { ctx->encode_config.frameIntervalP = 0; ctx->encode_config.gopLength = 1; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = 1; break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = 1; break; } } if (ctx->encode_config.frameIntervalP >= 2) ctx->last_dts = -2; if (avctx->bit_rate > 0) ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate; if (avctx->rc_max_rate > 0) ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate; if (ctx->cbr) { if (!ctx->twopass) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } else if (ctx->twopass == 1 || VAR_3) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_2_PASS_QUALITY; if (avctx->codec->id == AV_CODEC_ID_H264) { ctx->encode_config.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE; ctx->encode_config.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE; } if (!VAR_3) av_log(avctx, AV_LOG_WARNING, "Twopass mode is only known to work with low latency (ll, llhq, llhp) presets.\n"); } else { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR; } } else if (avctx->global_quality > 0) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP; ctx->encode_config.rcParams.constQP.qpInterB = avctx->global_quality; ctx->encode_config.rcParams.constQP.qpInterP = avctx->global_quality; ctx->encode_config.rcParams.constQP.qpIntra = avctx->global_quality; avctx->qmin = -1; avctx->qmax = -1; } else if (avctx->qmin >= 0 && avctx->qmax >= 0) { ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR; ctx->encode_config.rcParams.enableMinQP = 1; ctx->encode_config.rcParams.enableMaxQP = 1; ctx->encode_config.rcParams.minQP.qpInterB = avctx->qmin; ctx->encode_config.rcParams.minQP.qpInterP = avctx->qmin; ctx->encode_config.rcParams.minQP.qpIntra = avctx->qmin; ctx->encode_config.rcParams.maxQP.qpInterB = avctx->qmax; ctx->encode_config.rcParams.maxQP.qpInterP = avctx->qmax; ctx->encode_config.rcParams.maxQP.qpIntra = avctx->qmax; } if (avctx->rc_buffer_size > 0) ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size; if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD; } else { ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME; } switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag = 1; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag = 1; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourMatrix = avctx->colorspace; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourPrimaries = avctx->color_primaries; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.transferCharacteristics = avctx->color_trc; ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = avctx->color_range == AVCOL_RANGE_JPEG; ctx->encode_config.encodeCodecConfig.h264Config.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; ctx->encode_config.encodeCodecConfig.h264Config.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; if (!ctx->profile) { switch (avctx->profile) { case FF_PROFILE_H264_BASELINE: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; break; case FF_PROFILE_H264_MAIN: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; break; case FF_PROFILE_H264_HIGH: case FF_PROFILE_UNKNOWN: ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; break; default: av_log(avctx, AV_LOG_WARNING, "Unsupported profile requested, falling back to high\n"); ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; break; } } else { if (!strcmp(ctx->profile, "high")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID; avctx->profile = FF_PROFILE_H264_HIGH; } else if (!strcmp(ctx->profile, "main")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID; avctx->profile = FF_PROFILE_H264_MAIN; } else if (!strcmp(ctx->profile, "baseline")) { ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID; avctx->profile = FF_PROFILE_H264_BASELINE; } else { av_log(avctx, AV_LOG_FATAL, "Profile \"%s\" is unknown! Supported profiles: high, main, baseline\n", ctx->profile); VAR_4 = AVERROR(EINVAL); goto error; } } if (ctx->level) { VAR_4 = input_string_to_uint32(avctx, nvenc_h264_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.h264Config.level); if (VAR_4) { av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2, 5, 5.1\n", ctx->level); goto error; } } else { ctx->encode_config.encodeCodecConfig.h264Config.level = NV_ENC_LEVEL_AUTOSELECT; } break; case AV_CODEC_ID_H265: ctx->encode_config.encodeCodecConfig.hevcConfig.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0; ctx->encode_config.encodeCodecConfig.hevcConfig.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1; ctx->encode_config.profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID; avctx->profile = FF_PROFILE_HEVC_MAIN; if (ctx->level) { VAR_4 = input_string_to_uint32(avctx, nvenc_hevc_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.hevcConfig.level); if (VAR_4) { av_log(avctx, AV_LOG_FATAL, "Level \"%s\" is unknown! Supported levels: auto, 1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2\n", ctx->level); goto error; } } else { ctx->encode_config.encodeCodecConfig.hevcConfig.level = NV_ENC_LEVEL_AUTOSELECT; } if (ctx->tier) { if (!strcmp(ctx->tier, "main")) { ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_MAIN; } else if (!strcmp(ctx->tier, "high")) { ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_HIGH; } else { av_log(avctx, AV_LOG_FATAL, "Tier \"%s\" is unknown! Supported tiers: main, high\n", ctx->tier); VAR_4 = AVERROR(EINVAL); goto error; } } break; } nv_status = p_nvenc->nvEncInitializeEncoder(ctx->nvencoder, &ctx->init_encode_params); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "InitializeEncoder failed: 0x%x\n", (int)nv_status); VAR_4 = AVERROR_EXTERNAL; goto error; } ctx->input_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->input_surfaces)); if (!ctx->input_surfaces) { VAR_4 = AVERROR(ENOMEM); goto error; } ctx->output_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->output_surfaces)); if (!ctx->output_surfaces) { VAR_4 = AVERROR(ENOMEM); goto error; } for (VAR_0 = 0; VAR_0 < ctx->max_surface_count; ++VAR_0) { NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 }; NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 }; allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER; allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER; allocSurf.width = (avctx->width + 31) & ~31; allocSurf.height = (avctx->height + 31) & ~31; allocSurf.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; switch (avctx->pix_fmt) { case AV_PIX_FMT_YUV420P: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YV12_PL; break; case AV_PIX_FMT_NV12: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_NV12_PL; break; case AV_PIX_FMT_YUV444P: allocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YUV444_PL; break; default: av_log(avctx, AV_LOG_FATAL, "Invalid input pixel format\n"); VAR_4 = AVERROR(EINVAL); goto error; } nv_status = p_nvenc->nvEncCreateInputBuffer(ctx->nvencoder, &allocSurf); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "CreateInputBuffer failed\n"); VAR_4 = AVERROR_EXTERNAL; goto error; } ctx->input_surfaces[VAR_0].lockCount = 0; ctx->input_surfaces[VAR_0].input_surface = allocSurf.inputBuffer; ctx->input_surfaces[VAR_0].format = allocSurf.bufferFmt; ctx->input_surfaces[VAR_0].width = allocSurf.width; ctx->input_surfaces[VAR_0].height = allocSurf.height; allocOut.size = 1024 * 1024; allocOut.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED; nv_status = p_nvenc->nvEncCreateBitstreamBuffer(ctx->nvencoder, &allocOut); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "CreateBitstreamBuffer failed\n"); ctx->output_surfaces[VAR_0++].output_surface = NULL; VAR_4 = AVERROR_EXTERNAL; goto error; } ctx->output_surfaces[VAR_0].output_surface = allocOut.bitstreamBuffer; ctx->output_surfaces[VAR_0].size = allocOut.size; ctx->output_surfaces[VAR_0].busy = 0; } if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { uint32_t outSize = 0; char VAR_7[256]; NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 }; payload.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER; payload.spsppsBuffer = VAR_7; payload.inBufferSize = sizeof(VAR_7); payload.outSPSPPSPayloadSize = &outSize; nv_status = p_nvenc->nvEncGetSequenceParams(ctx->nvencoder, &payload); if (nv_status != NV_ENC_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "GetSequenceParams failed\n"); goto error; } avctx->extradata_size = outSize; avctx->extradata = av_mallocz(outSize + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) { VAR_4 = AVERROR(ENOMEM); goto error; } memcpy(avctx->extradata, VAR_7, outSize); } if (ctx->encode_config.frameIntervalP > 1) avctx->has_b_frames = 2; if (ctx->encode_config.rcParams.averageBitRate > 0) avctx->bit_rate = ctx->encode_config.rcParams.averageBitRate; return 0; error: for (VAR_1 = 0; VAR_1 < VAR_0; ++VAR_1) { p_nvenc->nvEncDestroyInputBuffer(ctx->nvencoder, ctx->input_surfaces[VAR_1].input_surface); if (ctx->output_surfaces[VAR_1].output_surface) p_nvenc->nvEncDestroyBitstreamBuffer(ctx->nvencoder, ctx->output_surfaces[VAR_1].output_surface); } if (ctx->nvencoder) p_nvenc->nvEncDestroyEncoder(ctx->nvencoder); if (ctx->cu_context) dl_fn->cu_ctx_destroy(ctx->cu_context); av_frame_free(&avctx->coded_frame); nvenc_unload_nvenc(avctx); ctx->nvencoder = NULL; ctx->cu_context = NULL; return VAR_4; }
[ "static av_cold int FUNC_0(AVCodecContext *avctx)\n{", "NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS encode_session_params = { 0 };", "NV_ENC_PRESET_CONFIG preset_config = { 0 };", "CUcontext cu_context_curr;", "CUresult cu_res;", "GUID encoder_preset = NV_ENC_PRESET_HQ_GUID;", "GUID codec;", "NVENCSTATUS nv_status = NV_ENC_SUCCESS;", "int VAR_0 = 0;", "int VAR_1, VAR_2;", "int VAR_3 = 0;", "int VAR_4 = 0;", "int VAR_5, VAR_6;", "NvencContext *ctx = avctx->priv_data;", "NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs;", "NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs;", "if (!nvenc_dyload_nvenc(avctx))\nreturn AVERROR_EXTERNAL;", "avctx->coded_frame = av_frame_alloc();", "if (!avctx->coded_frame) {", "VAR_4 = AVERROR(ENOMEM);", "goto error;", "}", "ctx->last_dts = AV_NOPTS_VALUE;", "ctx->encode_config.version = NV_ENC_CONFIG_VER;", "ctx->init_encode_params.version = NV_ENC_INITIALIZE_PARAMS_VER;", "preset_config.version = NV_ENC_PRESET_CONFIG_VER;", "preset_config.presetCfg.version = NV_ENC_CONFIG_VER;", "encode_session_params.version = NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER;", "encode_session_params.apiVersion = NVENCAPI_VERSION;", "if (ctx->gpu >= dl_fn->nvenc_device_count) {", "av_log(avctx, AV_LOG_FATAL, \"Requested GPU %d, but only %d GPUs are available!\\n\", ctx->gpu, dl_fn->nvenc_device_count);", "VAR_4 = AVERROR(EINVAL);", "goto error;", "}", "ctx->cu_context = NULL;", "cu_res = dl_fn->cu_ctx_create(&ctx->cu_context, 0, dl_fn->nvenc_devices[ctx->gpu]);", "if (cu_res != CUDA_SUCCESS) {", "av_log(avctx, AV_LOG_FATAL, \"Failed creating CUDA context for NVENC: 0x%x\\n\", (int)cu_res);", "VAR_4 = AVERROR_EXTERNAL;", "goto error;", "}", "cu_res = dl_fn->cu_ctx_pop_current(&cu_context_curr);", "if (cu_res != CUDA_SUCCESS) {", "av_log(avctx, AV_LOG_FATAL, \"Failed popping CUDA context: 0x%x\\n\", (int)cu_res);", "VAR_4 = AVERROR_EXTERNAL;", "goto error;", "}", "encode_session_params.device = ctx->cu_context;", "encode_session_params.deviceType = NV_ENC_DEVICE_TYPE_CUDA;", "nv_status = p_nvenc->nvEncOpenEncodeSessionEx(&encode_session_params, &ctx->nvencoder);", "if (nv_status != NV_ENC_SUCCESS) {", "ctx->nvencoder = NULL;", "av_log(avctx, AV_LOG_FATAL, \"OpenEncodeSessionEx failed: 0x%x - invalid license key?\\n\", (int)nv_status);", "VAR_4 = AVERROR_EXTERNAL;", "goto error;", "}", "if (ctx->preset) {", "if (!strcmp(ctx->preset, \"hp\")) {", "encoder_preset = NV_ENC_PRESET_HP_GUID;", "} else if (!strcmp(ctx->preset, \"hq\")) {", "encoder_preset = NV_ENC_PRESET_HQ_GUID;", "} else if (!strcmp(ctx->preset, \"bd\")) {", "encoder_preset = NV_ENC_PRESET_BD_GUID;", "} else if (!strcmp(ctx->preset, \"ll\")) {", "encoder_preset = NV_ENC_PRESET_LOW_LATENCY_DEFAULT_GUID;", "VAR_3 = 1;", "} else if (!strcmp(ctx->preset, \"llhp\")) {", "encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HP_GUID;", "VAR_3 = 1;", "} else if (!strcmp(ctx->preset, \"llhq\")) {", "encoder_preset = NV_ENC_PRESET_LOW_LATENCY_HQ_GUID;", "VAR_3 = 1;", "} else if (!strcmp(ctx->preset, \"default\")) {", "encoder_preset = NV_ENC_PRESET_DEFAULT_GUID;", "} else {", "av_log(avctx, AV_LOG_FATAL, \"Preset \\\"%s\\\" is unknown! Supported presets: hp, hq, bd, ll, llhp, llhq, default\\n\", ctx->preset);", "VAR_4 = AVERROR(EINVAL);", "goto error;", "}", "}", "switch (avctx->codec->id) {", "case AV_CODEC_ID_H264:\ncodec = NV_ENC_CODEC_H264_GUID;", "break;", "case AV_CODEC_ID_H265:\ncodec = NV_ENC_CODEC_HEVC_GUID;", "break;", "default:\nav_log(avctx, AV_LOG_ERROR, \"nvenc: Unknown codec name\\n\");", "VAR_4 = AVERROR(EINVAL);", "goto error;", "}", "nv_status = p_nvenc->nvEncGetEncodePresetConfig(ctx->nvencoder, codec, encoder_preset, &preset_config);", "if (nv_status != NV_ENC_SUCCESS) {", "av_log(avctx, AV_LOG_FATAL, \"GetEncodePresetConfig failed: 0x%x\\n\", (int)nv_status);", "VAR_4 = AVERROR_EXTERNAL;", "goto error;", "}", "ctx->init_encode_params.encodeGUID = codec;", "ctx->init_encode_params.encodeHeight = avctx->height;", "ctx->init_encode_params.encodeWidth = avctx->width;", "if (avctx->sample_aspect_ratio.num && avctx->sample_aspect_ratio.den &&\n(avctx->sample_aspect_ratio.num != 1 || avctx->sample_aspect_ratio.num != 1)) {", "av_reduce(&VAR_5, &VAR_6,\navctx->width * avctx->sample_aspect_ratio.num,\navctx->height * avctx->sample_aspect_ratio.den,\n1024 * 1024);", "ctx->init_encode_params.darHeight = VAR_6;", "ctx->init_encode_params.darWidth = VAR_5;", "} else {", "ctx->init_encode_params.darHeight = avctx->height;", "ctx->init_encode_params.darWidth = avctx->width;", "}", "if (avctx->width == 720 &&\n(avctx->height == 480 || avctx->height == 576)) {", "av_reduce(&VAR_5, &VAR_6,\nctx->init_encode_params.darWidth * 44,\nctx->init_encode_params.darHeight * 45,\n1024 * 1024);", "ctx->init_encode_params.darHeight = VAR_6;", "ctx->init_encode_params.darWidth = VAR_5;", "}", "ctx->init_encode_params.frameRateNum = avctx->time_base.den;", "ctx->init_encode_params.frameRateDen = avctx->time_base.num * avctx->ticks_per_frame;", "VAR_2 = ((avctx->width + 15) >> 4) * ((avctx->height + 15) >> 4);", "ctx->max_surface_count = (VAR_2 >= 8160) ? 32 : 48;", "ctx->init_encode_params.enableEncodeAsync = 0;", "ctx->init_encode_params.enablePTD = 1;", "ctx->init_encode_params.presetGUID = encoder_preset;", "ctx->init_encode_params.encodeConfig = &ctx->encode_config;", "memcpy(&ctx->encode_config, &preset_config.presetCfg, sizeof(ctx->encode_config));", "ctx->encode_config.version = NV_ENC_CONFIG_VER;", "if (avctx->refs >= 0) {", "switch (avctx->codec->id) {", "case AV_CODEC_ID_H264:\nctx->encode_config.encodeCodecConfig.h264Config.maxNumRefFrames = avctx->refs;", "break;", "case AV_CODEC_ID_H265:\nctx->encode_config.encodeCodecConfig.hevcConfig.maxNumRefFramesInDPB = avctx->refs;", "break;", "}", "}", "if (avctx->gop_size > 0) {", "if (avctx->max_b_frames >= 0) {", "ctx->encode_config.frameIntervalP = avctx->max_b_frames + 1;", "}", "ctx->encode_config.gopLength = avctx->gop_size;", "switch (avctx->codec->id) {", "case AV_CODEC_ID_H264:\nctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = avctx->gop_size;", "break;", "case AV_CODEC_ID_H265:\nctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = avctx->gop_size;", "break;", "}", "} else if (avctx->gop_size == 0) {", "ctx->encode_config.frameIntervalP = 0;", "ctx->encode_config.gopLength = 1;", "switch (avctx->codec->id) {", "case AV_CODEC_ID_H264:\nctx->encode_config.encodeCodecConfig.h264Config.idrPeriod = 1;", "break;", "case AV_CODEC_ID_H265:\nctx->encode_config.encodeCodecConfig.hevcConfig.idrPeriod = 1;", "break;", "}", "}", "if (ctx->encode_config.frameIntervalP >= 2)\nctx->last_dts = -2;", "if (avctx->bit_rate > 0)\nctx->encode_config.rcParams.averageBitRate = avctx->bit_rate;", "if (avctx->rc_max_rate > 0)\nctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;", "if (ctx->cbr) {", "if (!ctx->twopass) {", "ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR;", "} else if (ctx->twopass == 1 || VAR_3) {", "ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_2_PASS_QUALITY;", "if (avctx->codec->id == AV_CODEC_ID_H264) {", "ctx->encode_config.encodeCodecConfig.h264Config.adaptiveTransformMode = NV_ENC_H264_ADAPTIVE_TRANSFORM_ENABLE;", "ctx->encode_config.encodeCodecConfig.h264Config.fmoMode = NV_ENC_H264_FMO_DISABLE;", "}", "if (!VAR_3)\nav_log(avctx, AV_LOG_WARNING, \"Twopass mode is only known to work with low latency (ll, llhq, llhp) presets.\\n\");", "} else {", "ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CBR;", "}", "} else if (avctx->global_quality > 0) {", "ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_CONSTQP;", "ctx->encode_config.rcParams.constQP.qpInterB = avctx->global_quality;", "ctx->encode_config.rcParams.constQP.qpInterP = avctx->global_quality;", "ctx->encode_config.rcParams.constQP.qpIntra = avctx->global_quality;", "avctx->qmin = -1;", "avctx->qmax = -1;", "} else if (avctx->qmin >= 0 && avctx->qmax >= 0) {", "ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR;", "ctx->encode_config.rcParams.enableMinQP = 1;", "ctx->encode_config.rcParams.enableMaxQP = 1;", "ctx->encode_config.rcParams.minQP.qpInterB = avctx->qmin;", "ctx->encode_config.rcParams.minQP.qpInterP = avctx->qmin;", "ctx->encode_config.rcParams.minQP.qpIntra = avctx->qmin;", "ctx->encode_config.rcParams.maxQP.qpInterB = avctx->qmax;", "ctx->encode_config.rcParams.maxQP.qpInterP = avctx->qmax;", "ctx->encode_config.rcParams.maxQP.qpIntra = avctx->qmax;", "}", "if (avctx->rc_buffer_size > 0)\nctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size;", "if (avctx->flags & CODEC_FLAG_INTERLACED_DCT) {", "ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FIELD;", "} else {", "ctx->encode_config.frameFieldMode = NV_ENC_PARAMS_FRAME_FIELD_MODE_FRAME;", "}", "switch (avctx->codec->id) {", "case AV_CODEC_ID_H264:\nctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourDescriptionPresentFlag = 1;", "ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoSignalTypePresentFlag = 1;", "ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourMatrix = avctx->colorspace;", "ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.colourPrimaries = avctx->color_primaries;", "ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.transferCharacteristics = avctx->color_trc;", "ctx->encode_config.encodeCodecConfig.h264Config.h264VUIParameters.videoFullRangeFlag = avctx->color_range == AVCOL_RANGE_JPEG;", "ctx->encode_config.encodeCodecConfig.h264Config.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;", "ctx->encode_config.encodeCodecConfig.h264Config.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1;", "if (!ctx->profile) {", "switch (avctx->profile) {", "case FF_PROFILE_H264_BASELINE:\nctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID;", "break;", "case FF_PROFILE_H264_MAIN:\nctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID;", "break;", "case FF_PROFILE_H264_HIGH:\ncase FF_PROFILE_UNKNOWN:\nctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID;", "break;", "default:\nav_log(avctx, AV_LOG_WARNING, \"Unsupported profile requested, falling back to high\\n\");", "ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID;", "break;", "}", "} else {", "if (!strcmp(ctx->profile, \"high\")) {", "ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_HIGH_GUID;", "avctx->profile = FF_PROFILE_H264_HIGH;", "} else if (!strcmp(ctx->profile, \"main\")) {", "ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_MAIN_GUID;", "avctx->profile = FF_PROFILE_H264_MAIN;", "} else if (!strcmp(ctx->profile, \"baseline\")) {", "ctx->encode_config.profileGUID = NV_ENC_H264_PROFILE_BASELINE_GUID;", "avctx->profile = FF_PROFILE_H264_BASELINE;", "} else {", "av_log(avctx, AV_LOG_FATAL, \"Profile \\\"%s\\\" is unknown! Supported profiles: high, main, baseline\\n\", ctx->profile);", "VAR_4 = AVERROR(EINVAL);", "goto error;", "}", "}", "if (ctx->level) {", "VAR_4 = input_string_to_uint32(avctx, nvenc_h264_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.h264Config.level);", "if (VAR_4) {", "av_log(avctx, AV_LOG_FATAL, \"Level \\\"%s\\\" is unknown! Supported levels: auto, 1, 1b, 1.1, 1.2, 1.3, 2, 2.1, 2.2, 3, 3.1, 3.2, 4, 4.1, 4.2, 5, 5.1\\n\", ctx->level);", "goto error;", "}", "} else {", "ctx->encode_config.encodeCodecConfig.h264Config.level = NV_ENC_LEVEL_AUTOSELECT;", "}", "break;", "case AV_CODEC_ID_H265:\nctx->encode_config.encodeCodecConfig.hevcConfig.disableSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 1 : 0;", "ctx->encode_config.encodeCodecConfig.hevcConfig.repeatSPSPPS = (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) ? 0 : 1;", "ctx->encode_config.profileGUID = NV_ENC_HEVC_PROFILE_MAIN_GUID;", "avctx->profile = FF_PROFILE_HEVC_MAIN;", "if (ctx->level) {", "VAR_4 = input_string_to_uint32(avctx, nvenc_hevc_level_pairs, ctx->level, &ctx->encode_config.encodeCodecConfig.hevcConfig.level);", "if (VAR_4) {", "av_log(avctx, AV_LOG_FATAL, \"Level \\\"%s\\\" is unknown! Supported levels: auto, 1, 2, 2.1, 3, 3.1, 4, 4.1, 5, 5.1, 5.2, 6, 6.1, 6.2\\n\", ctx->level);", "goto error;", "}", "} else {", "ctx->encode_config.encodeCodecConfig.hevcConfig.level = NV_ENC_LEVEL_AUTOSELECT;", "}", "if (ctx->tier) {", "if (!strcmp(ctx->tier, \"main\")) {", "ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_MAIN;", "} else if (!strcmp(ctx->tier, \"high\")) {", "ctx->encode_config.encodeCodecConfig.hevcConfig.tier = NV_ENC_TIER_HEVC_HIGH;", "} else {", "av_log(avctx, AV_LOG_FATAL, \"Tier \\\"%s\\\" is unknown! Supported tiers: main, high\\n\", ctx->tier);", "VAR_4 = AVERROR(EINVAL);", "goto error;", "}", "}", "break;", "}", "nv_status = p_nvenc->nvEncInitializeEncoder(ctx->nvencoder, &ctx->init_encode_params);", "if (nv_status != NV_ENC_SUCCESS) {", "av_log(avctx, AV_LOG_FATAL, \"InitializeEncoder failed: 0x%x\\n\", (int)nv_status);", "VAR_4 = AVERROR_EXTERNAL;", "goto error;", "}", "ctx->input_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->input_surfaces));", "if (!ctx->input_surfaces) {", "VAR_4 = AVERROR(ENOMEM);", "goto error;", "}", "ctx->output_surfaces = av_malloc(ctx->max_surface_count * sizeof(*ctx->output_surfaces));", "if (!ctx->output_surfaces) {", "VAR_4 = AVERROR(ENOMEM);", "goto error;", "}", "for (VAR_0 = 0; VAR_0 < ctx->max_surface_count; ++VAR_0) {", "NV_ENC_CREATE_INPUT_BUFFER allocSurf = { 0 };", "NV_ENC_CREATE_BITSTREAM_BUFFER allocOut = { 0 };", "allocSurf.version = NV_ENC_CREATE_INPUT_BUFFER_VER;", "allocOut.version = NV_ENC_CREATE_BITSTREAM_BUFFER_VER;", "allocSurf.width = (avctx->width + 31) & ~31;", "allocSurf.height = (avctx->height + 31) & ~31;", "allocSurf.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED;", "switch (avctx->pix_fmt) {", "case AV_PIX_FMT_YUV420P:\nallocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YV12_PL;", "break;", "case AV_PIX_FMT_NV12:\nallocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_NV12_PL;", "break;", "case AV_PIX_FMT_YUV444P:\nallocSurf.bufferFmt = NV_ENC_BUFFER_FORMAT_YUV444_PL;", "break;", "default:\nav_log(avctx, AV_LOG_FATAL, \"Invalid input pixel format\\n\");", "VAR_4 = AVERROR(EINVAL);", "goto error;", "}", "nv_status = p_nvenc->nvEncCreateInputBuffer(ctx->nvencoder, &allocSurf);", "if (nv_status != NV_ENC_SUCCESS) {", "av_log(avctx, AV_LOG_FATAL, \"CreateInputBuffer failed\\n\");", "VAR_4 = AVERROR_EXTERNAL;", "goto error;", "}", "ctx->input_surfaces[VAR_0].lockCount = 0;", "ctx->input_surfaces[VAR_0].input_surface = allocSurf.inputBuffer;", "ctx->input_surfaces[VAR_0].format = allocSurf.bufferFmt;", "ctx->input_surfaces[VAR_0].width = allocSurf.width;", "ctx->input_surfaces[VAR_0].height = allocSurf.height;", "allocOut.size = 1024 * 1024;", "allocOut.memoryHeap = NV_ENC_MEMORY_HEAP_SYSMEM_CACHED;", "nv_status = p_nvenc->nvEncCreateBitstreamBuffer(ctx->nvencoder, &allocOut);", "if (nv_status != NV_ENC_SUCCESS) {", "av_log(avctx, AV_LOG_FATAL, \"CreateBitstreamBuffer failed\\n\");", "ctx->output_surfaces[VAR_0++].output_surface = NULL;", "VAR_4 = AVERROR_EXTERNAL;", "goto error;", "}", "ctx->output_surfaces[VAR_0].output_surface = allocOut.bitstreamBuffer;", "ctx->output_surfaces[VAR_0].size = allocOut.size;", "ctx->output_surfaces[VAR_0].busy = 0;", "}", "if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {", "uint32_t outSize = 0;", "char VAR_7[256];", "NV_ENC_SEQUENCE_PARAM_PAYLOAD payload = { 0 };", "payload.version = NV_ENC_SEQUENCE_PARAM_PAYLOAD_VER;", "payload.spsppsBuffer = VAR_7;", "payload.inBufferSize = sizeof(VAR_7);", "payload.outSPSPPSPayloadSize = &outSize;", "nv_status = p_nvenc->nvEncGetSequenceParams(ctx->nvencoder, &payload);", "if (nv_status != NV_ENC_SUCCESS) {", "av_log(avctx, AV_LOG_FATAL, \"GetSequenceParams failed\\n\");", "goto error;", "}", "avctx->extradata_size = outSize;", "avctx->extradata = av_mallocz(outSize + FF_INPUT_BUFFER_PADDING_SIZE);", "if (!avctx->extradata) {", "VAR_4 = AVERROR(ENOMEM);", "goto error;", "}", "memcpy(avctx->extradata, VAR_7, outSize);", "}", "if (ctx->encode_config.frameIntervalP > 1)\navctx->has_b_frames = 2;", "if (ctx->encode_config.rcParams.averageBitRate > 0)\navctx->bit_rate = ctx->encode_config.rcParams.averageBitRate;", "return 0;", "error:\nfor (VAR_1 = 0; VAR_1 < VAR_0; ++VAR_1) {", "p_nvenc->nvEncDestroyInputBuffer(ctx->nvencoder, ctx->input_surfaces[VAR_1].input_surface);", "if (ctx->output_surfaces[VAR_1].output_surface)\np_nvenc->nvEncDestroyBitstreamBuffer(ctx->nvencoder, ctx->output_surfaces[VAR_1].output_surface);", "}", "if (ctx->nvencoder)\np_nvenc->nvEncDestroyEncoder(ctx->nvencoder);", "if (ctx->cu_context)\ndl_fn->cu_ctx_destroy(ctx->cu_context);", "av_frame_free(&avctx->coded_frame);", "nvenc_unload_nvenc(avctx);", "ctx->nvencoder = NULL;", "ctx->cu_context = NULL;", "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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 35 ], [ 39, 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195, 197 ], [ 199 ], [ 201, 203 ], [ 205 ], [ 207, 209 ], [ 211 ], [ 213 ], [ 215 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 233 ], [ 235 ], [ 237 ], [ 241, 243 ], [ 245, 247, 249, 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 271, 273 ], [ 275, 277, 279, 281 ], [ 283 ], [ 285 ], [ 287 ], [ 291 ], [ 293 ], [ 297 ], [ 299 ], [ 303 ], [ 305 ], [ 309 ], [ 313 ], [ 315 ], [ 317 ], [ 321 ], [ 325 ], [ 327, 329 ], [ 331 ], [ 333, 335 ], [ 337 ], [ 341 ], [ 343 ], [ 347 ], [ 349 ], [ 353 ], [ 355 ], [ 359 ], [ 361 ], [ 363, 365 ], [ 367 ], [ 369, 371 ], [ 373 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385 ], [ 387, 389 ], [ 391 ], [ 393, 395 ], [ 397 ], [ 401 ], [ 403 ], [ 409, 411 ], [ 415, 417 ], [ 421, 423 ], [ 427 ], [ 429 ], [ 431 ], [ 433 ], [ 435 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 449, 451 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463 ], [ 465 ], [ 467 ], [ 471 ], [ 473 ], [ 475 ], [ 477 ], [ 481 ], [ 483 ], [ 487 ], [ 489 ], [ 491 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 505, 507 ], [ 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519 ], [ 523 ], [ 525, 527 ], [ 529 ], [ 533 ], [ 535 ], [ 537 ], [ 541 ], [ 545 ], [ 547 ], [ 551 ], [ 553 ], [ 555, 557 ], [ 559 ], [ 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 ], [ 619 ], [ 621 ], [ 625 ], [ 627 ], [ 629 ], [ 631 ], [ 633 ], [ 635 ], [ 637 ], [ 641 ], [ 643, 645 ], [ 647 ], [ 653 ], [ 655 ], [ 659 ], [ 661 ], [ 665 ], [ 667 ], [ 669 ], [ 671 ], [ 673 ], [ 675 ], [ 677 ], [ 681 ], [ 683 ], [ 685 ], [ 687 ], [ 689 ], [ 691 ], [ 693 ], [ 695 ], [ 697 ], [ 699 ], [ 701 ], [ 705 ], [ 709 ], [ 713 ], [ 715 ], [ 717 ], [ 719 ], [ 721 ], [ 723 ], [ 727 ], [ 731 ], [ 733 ], [ 735 ], [ 737 ], [ 741 ], [ 745 ], [ 747 ], [ 749 ], [ 751 ], [ 755 ], [ 757 ], [ 759 ], [ 761 ], [ 763 ], [ 767 ], [ 769 ], [ 773 ], [ 777 ], [ 779, 781 ], [ 783 ], [ 787, 789 ], [ 791 ], [ 795, 797 ], [ 799 ], [ 803, 805 ], [ 807 ], [ 809 ], [ 811 ], [ 815 ], [ 817 ], [ 819 ], [ 821 ], [ 823 ], [ 825 ], [ 829 ], [ 831 ], [ 833 ], [ 835 ], [ 837 ], [ 843 ], [ 847 ], [ 851 ], [ 853 ], [ 855 ], [ 857 ], [ 859 ], [ 861 ], [ 863 ], [ 867 ], [ 869 ], [ 871 ], [ 873 ], [ 877 ], [ 879 ], [ 881 ], [ 883 ], [ 885 ], [ 889 ], [ 891 ], [ 893 ], [ 897 ], [ 899 ], [ 901 ], [ 903 ], [ 905 ], [ 909 ], [ 911 ], [ 915 ], [ 917 ], [ 919 ], [ 921 ], [ 925 ], [ 927 ], [ 931, 933 ], [ 937, 939 ], [ 943 ], [ 947, 951 ], [ 953 ], [ 955, 957 ], [ 959 ], [ 963, 965 ], [ 969, 971 ], [ 975 ], [ 979 ], [ 983 ], [ 985 ], [ 989 ], [ 991 ] ]
20,170
size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size, int *bytes_sent) { if (f->ops->save_page) { int ret = f->ops->save_page(f, f->opaque, block_offset, offset, size, bytes_sent); if (ret != RAM_SAVE_CONTROL_DELAYED) { if (*bytes_sent > 0) { qemu_update_position(f, *bytes_sent); } else if (ret < 0) { qemu_file_set_error(f, ret); } } return ret; } return RAM_SAVE_CONTROL_NOT_SUPP; }
true
qemu
de7b685c9e1cf606e37e7116e4c4f03a6ae2d14f
size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size, int *bytes_sent) { if (f->ops->save_page) { int ret = f->ops->save_page(f, f->opaque, block_offset, offset, size, bytes_sent); if (ret != RAM_SAVE_CONTROL_DELAYED) { if (*bytes_sent > 0) { qemu_update_position(f, *bytes_sent); } else if (ret < 0) { qemu_file_set_error(f, ret); } } return ret; } return RAM_SAVE_CONTROL_NOT_SUPP; }
{ "code": [ " if (*bytes_sent > 0) {" ], "line_no": [ 17 ] }
size_t FUNC_0(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size, int *bytes_sent) { if (f->ops->save_page) { int VAR_0 = f->ops->save_page(f, f->opaque, block_offset, offset, size, bytes_sent); if (VAR_0 != RAM_SAVE_CONTROL_DELAYED) { if (*bytes_sent > 0) { qemu_update_position(f, *bytes_sent); } else if (VAR_0 < 0) { qemu_file_set_error(f, VAR_0); } } return VAR_0; } return RAM_SAVE_CONTROL_NOT_SUPP; }
[ "size_t FUNC_0(QEMUFile *f, ram_addr_t block_offset,\nram_addr_t offset, size_t size, int *bytes_sent)\n{", "if (f->ops->save_page) {", "int VAR_0 = f->ops->save_page(f, f->opaque, block_offset,\noffset, size, bytes_sent);", "if (VAR_0 != RAM_SAVE_CONTROL_DELAYED) {", "if (*bytes_sent > 0) {", "qemu_update_position(f, *bytes_sent);", "} else if (VAR_0 < 0) {", "qemu_file_set_error(f, VAR_0);", "}", "}", "return VAR_0;", "}", "return RAM_SAVE_CONTROL_NOT_SUPP;", "}" ]
[ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ] ]
20,171
static int gif_read_packet(AVFormatContext * s1, AVPacket * pkt) { GifState *s = s1->priv_data; int ret; ret = gif_parse_next_image(s); if (ret < 0) return ret; /* XXX: avoid copying */ if (av_new_packet(pkt, s->screen_width * s->screen_height * 3)) { return AVERROR(EIO); } pkt->stream_index = 0; memcpy(pkt->data, s->image_buf, s->screen_width * s->screen_height * 3); return 0; }
true
FFmpeg
0b54f3c0878a3acaa9142e4f24942e762d97e350
static int gif_read_packet(AVFormatContext * s1, AVPacket * pkt) { GifState *s = s1->priv_data; int ret; ret = gif_parse_next_image(s); if (ret < 0) return ret; if (av_new_packet(pkt, s->screen_width * s->screen_height * 3)) { return AVERROR(EIO); } pkt->stream_index = 0; memcpy(pkt->data, s->image_buf, s->screen_width * s->screen_height * 3); return 0; }
{ "code": [ " return 0;", " return 0;", " return 0;", " return 0;", " GifState *s = s1->priv_data;", " return 0;", "static int gif_read_packet(AVFormatContext * s1,", " AVPacket * pkt)", " GifState *s = s1->priv_data;", " int ret;", " ret = gif_parse_next_image(s);", " if (ret < 0)", " return ret;", " if (av_new_packet(pkt, s->screen_width * s->screen_height * 3)) {", " return AVERROR(EIO);", " pkt->stream_index = 0;", " memcpy(pkt->data, s->image_buf, s->screen_width * s->screen_height * 3);", " return 0;", " GifState *s = s1->priv_data;", " return 0;" ], "line_no": [ 33, 33, 33, 33, 7, 33, 1, 3, 7, 9, 13, 15, 17, 23, 25, 29, 31, 33, 7, 33 ] }
static int FUNC_0(AVFormatContext * VAR_0, AVPacket * VAR_1) { GifState *s = VAR_0->priv_data; int VAR_2; VAR_2 = gif_parse_next_image(s); if (VAR_2 < 0) return VAR_2; if (av_new_packet(VAR_1, s->screen_width * s->screen_height * 3)) { return AVERROR(EIO); } VAR_1->stream_index = 0; memcpy(VAR_1->data, s->image_buf, s->screen_width * s->screen_height * 3); return 0; }
[ "static int FUNC_0(AVFormatContext * VAR_0,\nAVPacket * VAR_1)\n{", "GifState *s = VAR_0->priv_data;", "int VAR_2;", "VAR_2 = gif_parse_next_image(s);", "if (VAR_2 < 0)\nreturn VAR_2;", "if (av_new_packet(VAR_1, s->screen_width * s->screen_height * 3)) {", "return AVERROR(EIO);", "}", "VAR_1->stream_index = 0;", "memcpy(VAR_1->data, s->image_buf, s->screen_width * s->screen_height * 3);", "return 0;", "}" ]
[ 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ] ]
20,172
static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order) { int i, tmp, partition, method_type, rice_order; int rice_bits, rice_esc; int samples; method_type = get_bits(&s->gb, 2); if (method_type > 1) { av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n", method_type); rice_order = get_bits(&s->gb, 4); samples= s->blocksize >> rice_order; if (pred_order > samples) { av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n", pred_order, samples); rice_bits = 4 + method_type; rice_esc = (1 << rice_bits) - 1; decoded += pred_order; i= pred_order; for (partition = 0; partition < (1 << rice_order); partition++) { tmp = get_bits(&s->gb, rice_bits); if (tmp == rice_esc) { tmp = get_bits(&s->gb, 5); for (; i < samples; i++) *decoded++ = get_sbits_long(&s->gb, tmp); } else { for (; i < samples; i++) { *decoded++ = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0); i= 0; return 0;
true
FFmpeg
8ca9a68f1905ff871690be38348d62a25aef2a8f
static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order) { int i, tmp, partition, method_type, rice_order; int rice_bits, rice_esc; int samples; method_type = get_bits(&s->gb, 2); if (method_type > 1) { av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n", method_type); rice_order = get_bits(&s->gb, 4); samples= s->blocksize >> rice_order; if (pred_order > samples) { av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n", pred_order, samples); rice_bits = 4 + method_type; rice_esc = (1 << rice_bits) - 1; decoded += pred_order; i= pred_order; for (partition = 0; partition < (1 << rice_order); partition++) { tmp = get_bits(&s->gb, rice_bits); if (tmp == rice_esc) { tmp = get_bits(&s->gb, 5); for (; i < samples; i++) *decoded++ = get_sbits_long(&s->gb, tmp); } else { for (; i < samples; i++) { *decoded++ = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0); i= 0; return 0;
{ "code": [], "line_no": [] }
static int FUNC_0(FLACContext *VAR_0, int32_t *VAR_1, int VAR_2) { int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7; int VAR_8, VAR_9; int VAR_10; VAR_6 = get_bits(&VAR_0->gb, 2); if (VAR_6 > 1) { av_log(VAR_0->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n", VAR_6); VAR_7 = get_bits(&VAR_0->gb, 4); VAR_10= VAR_0->blocksize >> VAR_7; if (VAR_2 > VAR_10) { av_log(VAR_0->avctx, AV_LOG_ERROR, "invalid predictor order: %VAR_3 > %VAR_3\n", VAR_2, VAR_10); VAR_8 = 4 + VAR_6; VAR_9 = (1 << VAR_8) - 1; VAR_1 += VAR_2; VAR_3= VAR_2; for (VAR_5 = 0; VAR_5 < (1 << VAR_7); VAR_5++) { VAR_4 = get_bits(&VAR_0->gb, VAR_8); if (VAR_4 == VAR_9) { VAR_4 = get_bits(&VAR_0->gb, 5); for (; VAR_3 < VAR_10; VAR_3++) *VAR_1++ = get_sbits_long(&VAR_0->gb, VAR_4); } else { for (; VAR_3 < VAR_10; VAR_3++) { *VAR_1++ = get_sr_golomb_flac(&VAR_0->gb, VAR_4, INT_MAX, 0); VAR_3= 0; return 0;
[ "static int FUNC_0(FLACContext *VAR_0, int32_t *VAR_1, int VAR_2)\n{", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7;", "int VAR_8, VAR_9;", "int VAR_10;", "VAR_6 = get_bits(&VAR_0->gb, 2);", "if (VAR_6 > 1) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"illegal residual coding method %d\\n\",\nVAR_6);", "VAR_7 = get_bits(&VAR_0->gb, 4);", "VAR_10= VAR_0->blocksize >> VAR_7;", "if (VAR_2 > VAR_10) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"invalid predictor order: %VAR_3 > %VAR_3\\n\",\nVAR_2, VAR_10);", "VAR_8 = 4 + VAR_6;", "VAR_9 = (1 << VAR_8) - 1;", "VAR_1 += VAR_2;", "VAR_3= VAR_2;", "for (VAR_5 = 0; VAR_5 < (1 << VAR_7); VAR_5++) {", "VAR_4 = get_bits(&VAR_0->gb, VAR_8);", "if (VAR_4 == VAR_9) {", "VAR_4 = get_bits(&VAR_0->gb, 5);", "for (; VAR_3 < VAR_10; VAR_3++)", "*VAR_1++ = get_sbits_long(&VAR_0->gb, VAR_4);", "} else {", "for (; VAR_3 < VAR_10; VAR_3++) {", "*VAR_1++ = get_sr_golomb_flac(&VAR_0->gb, VAR_4, INT_MAX, 0);", "VAR_3= 0;", "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 ]
[ [ 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 ], [ 27 ], [ 28 ], [ 29 ] ]
20,173
static XICSState *xics_system_init(int nr_servers, int nr_irqs) { XICSState *icp = NULL; if (kvm_enabled()) { QemuOpts *machine_opts = qemu_get_machine_opts(); bool irqchip_allowed = qemu_opt_get_bool(machine_opts, "kernel_irqchip", true); bool irqchip_required = qemu_opt_get_bool(machine_opts, "kernel_irqchip", false); Error *err = NULL; if (irqchip_allowed) { icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err); } if (irqchip_required && !icp) { error_report("kernel_irqchip requested but unavailable: %s", error_get_pretty(err)); } } if (!icp) { icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort); } return icp; }
true
qemu
446f16a6906e9d05aa9ce0dde727d4f731a89298
static XICSState *xics_system_init(int nr_servers, int nr_irqs) { XICSState *icp = NULL; if (kvm_enabled()) { QemuOpts *machine_opts = qemu_get_machine_opts(); bool irqchip_allowed = qemu_opt_get_bool(machine_opts, "kernel_irqchip", true); bool irqchip_required = qemu_opt_get_bool(machine_opts, "kernel_irqchip", false); Error *err = NULL; if (irqchip_allowed) { icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err); } if (irqchip_required && !icp) { error_report("kernel_irqchip requested but unavailable: %s", error_get_pretty(err)); } } if (!icp) { icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort); } return icp; }
{ "code": [ " QemuOpts *machine_opts = qemu_get_machine_opts();", " bool irqchip_allowed = qemu_opt_get_bool(machine_opts,", " \"kernel_irqchip\", true);", " bool irqchip_required = qemu_opt_get_bool(machine_opts,", " \"kernel_irqchip\", false);", " if (irqchip_allowed) {", "static XICSState *xics_system_init(int nr_servers, int nr_irqs)", " QemuOpts *machine_opts = qemu_get_machine_opts();", " bool irqchip_allowed = qemu_opt_get_bool(machine_opts,", " \"kernel_irqchip\", true);", " bool irqchip_required = qemu_opt_get_bool(machine_opts,", " \"kernel_irqchip\", false);", " if (irqchip_allowed) {", " if (irqchip_required && !icp) {" ], "line_no": [ 11, 13, 15, 17, 19, 25, 1, 11, 13, 15, 17, 19, 25, 31 ] }
static XICSState *FUNC_0(int nr_servers, int nr_irqs) { XICSState *icp = NULL; if (kvm_enabled()) { QemuOpts *machine_opts = qemu_get_machine_opts(); bool irqchip_allowed = qemu_opt_get_bool(machine_opts, "kernel_irqchip", true); bool irqchip_required = qemu_opt_get_bool(machine_opts, "kernel_irqchip", false); Error *err = NULL; if (irqchip_allowed) { icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err); } if (irqchip_required && !icp) { error_report("kernel_irqchip requested but unavailable: %s", error_get_pretty(err)); } } if (!icp) { icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort); } return icp; }
[ "static XICSState *FUNC_0(int nr_servers, int nr_irqs)\n{", "XICSState *icp = NULL;", "if (kvm_enabled()) {", "QemuOpts *machine_opts = qemu_get_machine_opts();", "bool irqchip_allowed = qemu_opt_get_bool(machine_opts,\n\"kernel_irqchip\", true);", "bool irqchip_required = qemu_opt_get_bool(machine_opts,\n\"kernel_irqchip\", false);", "Error *err = NULL;", "if (irqchip_allowed) {", "icp = try_create_xics(TYPE_KVM_XICS, nr_servers, nr_irqs, &err);", "}", "if (irqchip_required && !icp) {", "error_report(\"kernel_irqchip requested but unavailable: %s\",\nerror_get_pretty(err));", "}", "}", "if (!icp) {", "icp = try_create_xics(TYPE_XICS, nr_servers, nr_irqs, &error_abort);", "}", "return icp;", "}" ]
[ 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13, 15 ], [ 17, 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ] ]
20,175
m48t59_t *m48t59_init_isa(uint32_t io_base, uint16_t size, int type) { M48t59ISAState *d; ISADevice *dev; m48t59_t *s; dev = isa_create("m48t59_isa"); qdev_prop_set_uint32(&dev->qdev, "type", type); qdev_prop_set_uint32(&dev->qdev, "size", size); qdev_prop_set_uint32(&dev->qdev, "io_base", io_base); qdev_init(&dev->qdev); d = DO_UPCAST(M48t59ISAState, busdev, dev); s = &d->state; if (io_base != 0) { register_ioport_read(io_base, 0x04, 1, NVRAM_readb, s); register_ioport_write(io_base, 0x04, 1, NVRAM_writeb, s); } return s; }
true
qemu
e23a1b33b53d25510320b26d9f154e19c6c99725
m48t59_t *m48t59_init_isa(uint32_t io_base, uint16_t size, int type) { M48t59ISAState *d; ISADevice *dev; m48t59_t *s; dev = isa_create("m48t59_isa"); qdev_prop_set_uint32(&dev->qdev, "type", type); qdev_prop_set_uint32(&dev->qdev, "size", size); qdev_prop_set_uint32(&dev->qdev, "io_base", io_base); qdev_init(&dev->qdev); d = DO_UPCAST(M48t59ISAState, busdev, dev); s = &d->state; if (io_base != 0) { register_ioport_read(io_base, 0x04, 1, NVRAM_readb, s); register_ioport_write(io_base, 0x04, 1, NVRAM_writeb, s); } return s; }
{ "code": [ " qdev_init(&dev->qdev);", " qdev_init(&dev->qdev);", " qdev_init(&dev->qdev);", " qdev_init(&dev->qdev);", " qdev_init(&dev->qdev);", " qdev_init(&dev->qdev);", " qdev_init(&dev->qdev);", " qdev_init(&dev->qdev);" ], "line_no": [ 21, 21, 21, 21, 21, 21, 21, 21 ] }
m48t59_t *FUNC_0(uint32_t io_base, uint16_t size, int type) { M48t59ISAState *d; ISADevice *dev; m48t59_t *s; dev = isa_create("m48t59_isa"); qdev_prop_set_uint32(&dev->qdev, "type", type); qdev_prop_set_uint32(&dev->qdev, "size", size); qdev_prop_set_uint32(&dev->qdev, "io_base", io_base); qdev_init(&dev->qdev); d = DO_UPCAST(M48t59ISAState, busdev, dev); s = &d->state; if (io_base != 0) { register_ioport_read(io_base, 0x04, 1, NVRAM_readb, s); register_ioport_write(io_base, 0x04, 1, NVRAM_writeb, s); } return s; }
[ "m48t59_t *FUNC_0(uint32_t io_base, uint16_t size, int type)\n{", "M48t59ISAState *d;", "ISADevice *dev;", "m48t59_t *s;", "dev = isa_create(\"m48t59_isa\");", "qdev_prop_set_uint32(&dev->qdev, \"type\", type);", "qdev_prop_set_uint32(&dev->qdev, \"size\", size);", "qdev_prop_set_uint32(&dev->qdev, \"io_base\", io_base);", "qdev_init(&dev->qdev);", "d = DO_UPCAST(M48t59ISAState, busdev, dev);", "s = &d->state;", "if (io_base != 0) {", "register_ioport_read(io_base, 0x04, 1, NVRAM_readb, s);", "register_ioport_write(io_base, 0x04, 1, NVRAM_writeb, s);", "}", "return s;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ] ]
20,176
static void close_decoder(QSVContext *q) { QSVFrame *cur; if (q->session) MFXVideoDECODE_Close(q->session); while (q->async_fifo && av_fifo_size(q->async_fifo)) { QSVFrame *out_frame; mfxSyncPoint *sync; av_fifo_generic_read(q->async_fifo, &out_frame, sizeof(out_frame), NULL); av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL); av_freep(&sync); } cur = q->work_frames; while (cur) { q->work_frames = cur->next; av_frame_free(&cur->frame); av_freep(&cur); cur = q->work_frames; } q->engine_ready = 0; q->reinit_pending = 0; }
true
FFmpeg
b4054100f675b395204f1a0471fba0b06fe08e9f
static void close_decoder(QSVContext *q) { QSVFrame *cur; if (q->session) MFXVideoDECODE_Close(q->session); while (q->async_fifo && av_fifo_size(q->async_fifo)) { QSVFrame *out_frame; mfxSyncPoint *sync; av_fifo_generic_read(q->async_fifo, &out_frame, sizeof(out_frame), NULL); av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL); av_freep(&sync); } cur = q->work_frames; while (cur) { q->work_frames = cur->next; av_frame_free(&cur->frame); av_freep(&cur); cur = q->work_frames; } q->engine_ready = 0; q->reinit_pending = 0; }
{ "code": [ " while (q->async_fifo && av_fifo_size(q->async_fifo)) {", " QSVFrame *out_frame;", " mfxSyncPoint *sync;", " av_fifo_generic_read(q->async_fifo, &out_frame, sizeof(out_frame), NULL);", " av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL);", " av_freep(&sync);", " av_freep(&sync);", " av_freep(&sync);", " av_freep(&sync);" ], "line_no": [ 15, 17, 19, 23, 25, 29, 29, 29, 29 ] }
static void FUNC_0(QSVContext *VAR_0) { QSVFrame *cur; if (VAR_0->session) MFXVideoDECODE_Close(VAR_0->session); while (VAR_0->async_fifo && av_fifo_size(VAR_0->async_fifo)) { QSVFrame *out_frame; mfxSyncPoint *sync; av_fifo_generic_read(VAR_0->async_fifo, &out_frame, sizeof(out_frame), NULL); av_fifo_generic_read(VAR_0->async_fifo, &sync, sizeof(sync), NULL); av_freep(&sync); } cur = VAR_0->work_frames; while (cur) { VAR_0->work_frames = cur->next; av_frame_free(&cur->frame); av_freep(&cur); cur = VAR_0->work_frames; } VAR_0->engine_ready = 0; VAR_0->reinit_pending = 0; }
[ "static void FUNC_0(QSVContext *VAR_0)\n{", "QSVFrame *cur;", "if (VAR_0->session)\nMFXVideoDECODE_Close(VAR_0->session);", "while (VAR_0->async_fifo && av_fifo_size(VAR_0->async_fifo)) {", "QSVFrame *out_frame;", "mfxSyncPoint *sync;", "av_fifo_generic_read(VAR_0->async_fifo, &out_frame, sizeof(out_frame), NULL);", "av_fifo_generic_read(VAR_0->async_fifo, &sync, sizeof(sync), NULL);", "av_freep(&sync);", "}", "cur = VAR_0->work_frames;", "while (cur) {", "VAR_0->work_frames = cur->next;", "av_frame_free(&cur->frame);", "av_freep(&cur);", "cur = VAR_0->work_frames;", "}", "VAR_0->engine_ready = 0;", "VAR_0->reinit_pending = 0;", "}" ]
[ 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ] ]
20,177
static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned int width, unsigned int height, int lumStride, int chromStride, int srcStride) { unsigned y; const unsigned chromWidth= width>>1; for(y=0; y<height; y+=2) { #ifdef HAVE_MMX asm volatile( "xorl %%eax, %%eax \n\t" "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $8, %%mm7 \n\t" // FF,00,FF,00... ".balign 16 \n\t" "1: \n\t" PREFETCH" 64(%0, %%eax, 4) \n\t" "movq (%0, %%eax, 4), %%mm0 \n\t" // UYVY UYVY(0) "movq 8(%0, %%eax, 4), %%mm1 \n\t" // UYVY UYVY(4) "movq %%mm0, %%mm2 \n\t" // UYVY UYVY(0) "movq %%mm1, %%mm3 \n\t" // UYVY UYVY(4) "pand %%mm7, %%mm0 \n\t" // U0V0 U0V0(0) "pand %%mm7, %%mm1 \n\t" // U0V0 U0V0(4) "psrlw $8, %%mm2 \n\t" // Y0Y0 Y0Y0(0) "psrlw $8, %%mm3 \n\t" // Y0Y0 Y0Y0(4) "packuswb %%mm1, %%mm0 \n\t" // UVUV UVUV(0) "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(0) MOVNTQ" %%mm2, (%1, %%eax, 2) \n\t" "movq 16(%0, %%eax, 4), %%mm1 \n\t" // UYVY UYVY(8) "movq 24(%0, %%eax, 4), %%mm2 \n\t" // UYVY UYVY(12) "movq %%mm1, %%mm3 \n\t" // UYVY UYVY(8) "movq %%mm2, %%mm4 \n\t" // UYVY UYVY(12) "pand %%mm7, %%mm1 \n\t" // U0V0 U0V0(8) "pand %%mm7, %%mm2 \n\t" // U0V0 U0V0(12) "psrlw $8, %%mm3 \n\t" // Y0Y0 Y0Y0(8) "psrlw $8, %%mm4 \n\t" // Y0Y0 Y0Y0(12) "packuswb %%mm2, %%mm1 \n\t" // UVUV UVUV(8) "packuswb %%mm4, %%mm3 \n\t" // YYYY YYYY(8) MOVNTQ" %%mm3, 8(%1, %%eax, 2) \n\t" "movq %%mm0, %%mm2 \n\t" // UVUV UVUV(0) "movq %%mm1, %%mm3 \n\t" // UVUV UVUV(8) "psrlw $8, %%mm0 \n\t" // V0V0 V0V0(0) "psrlw $8, %%mm1 \n\t" // V0V0 V0V0(8) "pand %%mm7, %%mm2 \n\t" // U0U0 U0U0(0) "pand %%mm7, %%mm3 \n\t" // U0U0 U0U0(8) "packuswb %%mm1, %%mm0 \n\t" // VVVV VVVV(0) "packuswb %%mm3, %%mm2 \n\t" // UUUU UUUU(0) MOVNTQ" %%mm0, (%3, %%eax) \n\t" MOVNTQ" %%mm2, (%2, %%eax) \n\t" "addl $8, %%eax \n\t" "cmpl %4, %%eax \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth) : "memory", "%eax" ); ydst += lumStride; src += srcStride; asm volatile( "xorl %%eax, %%eax \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 64(%0, %%eax, 4) \n\t" "movq (%0, %%eax, 4), %%mm0 \n\t" // YUYV YUYV(0) "movq 8(%0, %%eax, 4), %%mm1 \n\t" // YUYV YUYV(4) "movq 16(%0, %%eax, 4), %%mm2 \n\t" // YUYV YUYV(8) "movq 24(%0, %%eax, 4), %%mm3 \n\t" // YUYV YUYV(12) "psrlw $8, %%mm0 \n\t" // Y0Y0 Y0Y0(0) "psrlw $8, %%mm1 \n\t" // Y0Y0 Y0Y0(4) "psrlw $8, %%mm2 \n\t" // Y0Y0 Y0Y0(8) "psrlw $8, %%mm3 \n\t" // Y0Y0 Y0Y0(12) "packuswb %%mm1, %%mm0 \n\t" // YYYY YYYY(0) "packuswb %%mm3, %%mm2 \n\t" // YYYY YYYY(8) MOVNTQ" %%mm0, (%1, %%eax, 2) \n\t" MOVNTQ" %%mm2, 8(%1, %%eax, 2) \n\t" "addl $8, %%eax \n\t" "cmpl %4, %%eax \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth) : "memory", "%eax" ); #else unsigned i; for(i=0; i<chromWidth; i++) { udst[i] = src[4*i+0]; ydst[2*i+0] = src[4*i+1]; vdst[i] = src[4*i+2]; ydst[2*i+1] = src[4*i+3]; } ydst += lumStride; src += srcStride; for(i=0; i<chromWidth; i++) { ydst[2*i+0] = src[4*i+1]; ydst[2*i+1] = src[4*i+3]; } #endif udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } #ifdef HAVE_MMX asm volatile( EMMS" \n\t" SFENCE" \n\t" :::"memory"); #endif }
true
FFmpeg
7f526efd17973ec6d2204f7a47b6923e2be31363
static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned int width, unsigned int height, int lumStride, int chromStride, int srcStride) { unsigned y; const unsigned chromWidth= width>>1; for(y=0; y<height; y+=2) { #ifdef HAVE_MMX asm volatile( "xorl %%eax, %%eax \n\t" "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $8, %%mm7 \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 64(%0, %%eax, 4) \n\t" "movq (%0, %%eax, 4), %%mm0 \n\t" "movq 8(%0, %%eax, 4), %%mm1 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm7, %%mm1 \n\t" "psrlw $8, %%mm2 \n\t" "psrlw $8, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm2, (%1, %%eax, 2) \n\t" "movq 16(%0, %%eax, 4), %%mm1 \n\t" "movq 24(%0, %%eax, 4), %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "movq %%mm2, %%mm4 \n\t" "pand %%mm7, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "psrlw $8, %%mm3 \n\t" "psrlw $8, %%mm4 \n\t" "packuswb %%mm2, %%mm1 \n\t" "packuswb %%mm4, %%mm3 \n\t" MOVNTQ" %%mm3, 8(%1, %%eax, 2) \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, (%3, %%eax) \n\t" MOVNTQ" %%mm2, (%2, %%eax) \n\t" "addl $8, %%eax \n\t" "cmpl %4, %%eax \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth) : "memory", "%eax" ); ydst += lumStride; src += srcStride; asm volatile( "xorl %%eax, %%eax \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 64(%0, %%eax, 4) \n\t" "movq (%0, %%eax, 4), %%mm0 \n\t" "movq 8(%0, %%eax, 4), %%mm1 \n\t" "movq 16(%0, %%eax, 4), %%mm2 \n\t" "movq 24(%0, %%eax, 4), %%mm3 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "psrlw $8, %%mm2 \n\t" "psrlw $8, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, (%1, %%eax, 2) \n\t" MOVNTQ" %%mm2, 8(%1, %%eax, 2) \n\t" "addl $8, %%eax \n\t" "cmpl %4, %%eax \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (chromWidth) : "memory", "%eax" ); #else unsigned i; for(i=0; i<chromWidth; i++) { udst[i] = src[4*i+0]; ydst[2*i+0] = src[4*i+1]; vdst[i] = src[4*i+2]; ydst[2*i+1] = src[4*i+3]; } ydst += lumStride; src += srcStride; for(i=0; i<chromWidth; i++) { ydst[2*i+0] = src[4*i+1]; ydst[2*i+1] = src[4*i+3]; } #endif udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } #ifdef HAVE_MMX asm volatile( EMMS" \n\t" SFENCE" \n\t" :::"memory"); #endif }
{ "code": [ "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned y;", "\tconst unsigned chromWidth= width>>1;", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned y;", "\tconst unsigned chromWidth= width>>1;", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tunsigned int width, unsigned int height,", "\tint lumStride, int chromStride, int srcStride)", "\tunsigned y;", "\tconst unsigned chromWidth= width>>1;", "\t\tunsigned i;", "\tunsigned int width, unsigned int height,", "\tint lumStride, int chromStride, int srcStride)", "\tunsigned y;", "\tconst unsigned chromWidth= width>>1;", "\t\tunsigned i;", "\tunsigned int width, unsigned int height,", "\tint lumStride, int chromStride, int srcStride)", "\tunsigned y;", "\tconst unsigned chromWidth= width>>1;", "\t\tunsigned i;", "\t\tunsigned i;" ], "line_no": [ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 9, 11, 3, 3, 9, 11, 3, 3, 3, 5, 9, 11, 183, 3, 5, 9, 11, 183, 3, 5, 9, 11, 183, 183 ] }
static inline void FUNC_0(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, unsigned int width, unsigned int height, int lumStride, int chromStride, int srcStride) { unsigned VAR_0; const unsigned VAR_1= width>>1; for(VAR_0=0; VAR_0<height; VAR_0+=2) { #ifdef HAVE_MMX asm volatile( "xorl %%eax, %%eax \n\t" "pcmpeqw %%mm7, %%mm7 \n\t" "psrlw $8, %%mm7 \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 64(%0, %%eax, 4) \n\t" "movq (%0, %%eax, 4), %%mm0 \n\t" "movq 8(%0, %%eax, 4), %%mm1 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm7, %%mm1 \n\t" "psrlw $8, %%mm2 \n\t" "psrlw $8, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm2, (%1, %%eax, 2) \n\t" "movq 16(%0, %%eax, 4), %%mm1 \n\t" "movq 24(%0, %%eax, 4), %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "movq %%mm2, %%mm4 \n\t" "pand %%mm7, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "psrlw $8, %%mm3 \n\t" "psrlw $8, %%mm4 \n\t" "packuswb %%mm2, %%mm1 \n\t" "packuswb %%mm4, %%mm3 \n\t" MOVNTQ" %%mm3, 8(%1, %%eax, 2) \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm1, %%mm3 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm7, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, (%3, %%eax) \n\t" MOVNTQ" %%mm2, (%2, %%eax) \n\t" "addl $8, %%eax \n\t" "cmpl %4, %%eax \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (VAR_1) : "memory", "%eax" ); ydst += lumStride; src += srcStride; asm volatile( "xorl %%eax, %%eax \n\t" ".balign 16 \n\t" "1: \n\t" PREFETCH" 64(%0, %%eax, 4) \n\t" "movq (%0, %%eax, 4), %%mm0 \n\t" "movq 8(%0, %%eax, 4), %%mm1 \n\t" "movq 16(%0, %%eax, 4), %%mm2 \n\t" "movq 24(%0, %%eax, 4), %%mm3 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "psrlw $8, %%mm2 \n\t" "psrlw $8, %%mm3 \n\t" "packuswb %%mm1, %%mm0 \n\t" "packuswb %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, (%1, %%eax, 2) \n\t" MOVNTQ" %%mm2, 8(%1, %%eax, 2) \n\t" "addl $8, %%eax \n\t" "cmpl %4, %%eax \n\t" " jb 1b \n\t" ::"r"(src), "r"(ydst), "r"(udst), "r"(vdst), "g" (VAR_1) : "memory", "%eax" ); #else unsigned i; for(i=0; i<VAR_1; i++) { udst[i] = src[4*i+0]; ydst[2*i+0] = src[4*i+1]; vdst[i] = src[4*i+2]; ydst[2*i+1] = src[4*i+3]; } ydst += lumStride; src += srcStride; for(i=0; i<VAR_1; i++) { ydst[2*i+0] = src[4*i+1]; ydst[2*i+1] = src[4*i+3]; } #endif udst += chromStride; vdst += chromStride; ydst += lumStride; src += srcStride; } #ifdef HAVE_MMX asm volatile( EMMS" \n\t" SFENCE" \n\t" :::"memory"); #endif }
[ "static inline void FUNC_0(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,\nunsigned int width, unsigned int height,\nint lumStride, int chromStride, int srcStride)\n{", "unsigned VAR_0;", "const unsigned VAR_1= width>>1;", "for(VAR_0=0; VAR_0<height; VAR_0+=2)", "{", "#ifdef HAVE_MMX\nasm volatile(\n\"xorl %%eax, %%eax\t\t\\n\\t\"\n\"pcmpeqw %%mm7, %%mm7\t\t\\n\\t\"\n\"psrlw $8, %%mm7\t\t\\n\\t\"\n\".balign 16\t\t\t\\n\\t\"\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 64(%0, %%eax, 4)\t\\n\\t\"\n\"movq (%0, %%eax, 4), %%mm0\t\\n\\t\"\n\"movq 8(%0, %%eax, 4), %%mm1\t\\n\\t\"\n\"movq %%mm0, %%mm2\t\t\\n\\t\"\n\"movq %%mm1, %%mm3\t\t\\n\\t\"\n\"pand %%mm7, %%mm0\t\t\\n\\t\"\n\"pand %%mm7, %%mm1\t\t\\n\\t\"\n\"psrlw $8, %%mm2\t\t\\n\\t\"\n\"psrlw $8, %%mm3\t\t\\n\\t\"\n\"packuswb %%mm1, %%mm0\t\t\\n\\t\"\n\"packuswb %%mm3, %%mm2\t\t\\n\\t\"\nMOVNTQ\" %%mm2, (%1, %%eax, 2)\t\\n\\t\"\n\"movq 16(%0, %%eax, 4), %%mm1\t\\n\\t\"\n\"movq 24(%0, %%eax, 4), %%mm2\t\\n\\t\"\n\"movq %%mm1, %%mm3\t\t\\n\\t\"\n\"movq %%mm2, %%mm4\t\t\\n\\t\"\n\"pand %%mm7, %%mm1\t\t\\n\\t\"\n\"pand %%mm7, %%mm2\t\t\\n\\t\"\n\"psrlw $8, %%mm3\t\t\\n\\t\"\n\"psrlw $8, %%mm4\t\t\\n\\t\"\n\"packuswb %%mm2, %%mm1\t\t\\n\\t\"\n\"packuswb %%mm4, %%mm3\t\t\\n\\t\"\nMOVNTQ\" %%mm3, 8(%1, %%eax, 2)\t\\n\\t\"\n\"movq %%mm0, %%mm2\t\t\\n\\t\"\n\"movq %%mm1, %%mm3\t\t\\n\\t\"\n\"psrlw $8, %%mm0\t\t\\n\\t\"\n\"psrlw $8, %%mm1\t\t\\n\\t\"\n\"pand %%mm7, %%mm2\t\t\\n\\t\"\n\"pand %%mm7, %%mm3\t\t\\n\\t\"\n\"packuswb %%mm1, %%mm0\t\t\\n\\t\"\n\"packuswb %%mm3, %%mm2\t\t\\n\\t\"\nMOVNTQ\" %%mm0, (%3, %%eax)\t\\n\\t\"\nMOVNTQ\" %%mm2, (%2, %%eax)\t\\n\\t\"\n\"addl $8, %%eax\t\t\t\\n\\t\"\n\"cmpl %4, %%eax\t\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n::\"r\"(src), \"r\"(ydst), \"r\"(udst), \"r\"(vdst), \"g\" (VAR_1)\n: \"memory\", \"%eax\"\n);", "ydst += lumStride;", "src += srcStride;", "asm volatile(\n\"xorl %%eax, %%eax\t\t\\n\\t\"\n\".balign 16\t\t\t\\n\\t\"\n\"1:\t\t\t\t\\n\\t\"\nPREFETCH\" 64(%0, %%eax, 4)\t\\n\\t\"\n\"movq (%0, %%eax, 4), %%mm0\t\\n\\t\"\n\"movq 8(%0, %%eax, 4), %%mm1\t\\n\\t\"\n\"movq 16(%0, %%eax, 4), %%mm2\t\\n\\t\"\n\"movq 24(%0, %%eax, 4), %%mm3\t\\n\\t\"\n\"psrlw $8, %%mm0\t\t\\n\\t\"\n\"psrlw $8, %%mm1\t\t\\n\\t\"\n\"psrlw $8, %%mm2\t\t\\n\\t\"\n\"psrlw $8, %%mm3\t\t\\n\\t\"\n\"packuswb %%mm1, %%mm0\t\t\\n\\t\"\n\"packuswb %%mm3, %%mm2\t\t\\n\\t\"\nMOVNTQ\" %%mm0, (%1, %%eax, 2)\t\\n\\t\"\nMOVNTQ\" %%mm2, 8(%1, %%eax, 2)\t\\n\\t\"\n\"addl $8, %%eax\t\t\t\\n\\t\"\n\"cmpl %4, %%eax\t\t\t\\n\\t\"\n\" jb 1b\t\t\t\t\\n\\t\"\n::\"r\"(src), \"r\"(ydst), \"r\"(udst), \"r\"(vdst), \"g\" (VAR_1)\n: \"memory\", \"%eax\"\n);", "#else\nunsigned i;", "for(i=0; i<VAR_1; i++)", "{", "udst[i] \t= src[4*i+0];", "ydst[2*i+0] \t= src[4*i+1];", "vdst[i] \t= src[4*i+2];", "ydst[2*i+1] \t= src[4*i+3];", "}", "ydst += lumStride;", "src += srcStride;", "for(i=0; i<VAR_1; i++)", "{", "ydst[2*i+0] \t= src[4*i+1];", "ydst[2*i+1] \t= src[4*i+3];", "}", "#endif\nudst += chromStride;", "vdst += chromStride;", "ydst += lumStride;", "src += srcStride;", "}", "#ifdef HAVE_MMX\nasm volatile( EMMS\" \\n\\t\"\nSFENCE\" \\n\\t\"\n:::\"memory\");", "#endif\n}" ]
[ 1, 1, 1, 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 ]
[ [ 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, 55, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 81, 85, 87, 89, 91, 93, 95, 97, 99, 103, 105, 109, 111, 113, 115, 117, 119 ], [ 123 ], [ 125 ], [ 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 161, 163, 167, 169, 171, 175, 177, 179 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215, 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227, 229, 231, 233 ], [ 235, 237 ] ]
20,178
static inline int ape_decode_value_3860(APEContext *ctx, GetBitContext *gb, APERice *rice) { unsigned int x, overflow; overflow = get_unary(gb, 1, get_bits_left(gb)); if (ctx->fileversion > 3880) { while (overflow >= 16) { overflow -= 16; rice->k += 4; } } if (!rice->k) x = overflow; else x = (overflow << rice->k) + get_bits(gb, rice->k); rice->ksum += x - (rice->ksum + 8 >> 4); if (rice->ksum < (rice->k ? 1 << (rice->k + 4) : 0)) rice->k--; else if (rice->ksum >= (1 << (rice->k + 5)) && rice->k < 24) rice->k++; /* Convert to signed */ if (x & 1) return (x >> 1) + 1; else return -(x >> 1); }
false
FFmpeg
60ab4480423769ac3db487aba5232b187036c7ea
static inline int ape_decode_value_3860(APEContext *ctx, GetBitContext *gb, APERice *rice) { unsigned int x, overflow; overflow = get_unary(gb, 1, get_bits_left(gb)); if (ctx->fileversion > 3880) { while (overflow >= 16) { overflow -= 16; rice->k += 4; } } if (!rice->k) x = overflow; else x = (overflow << rice->k) + get_bits(gb, rice->k); rice->ksum += x - (rice->ksum + 8 >> 4); if (rice->ksum < (rice->k ? 1 << (rice->k + 4) : 0)) rice->k--; else if (rice->ksum >= (1 << (rice->k + 5)) && rice->k < 24) rice->k++; if (x & 1) return (x >> 1) + 1; else return -(x >> 1); }
{ "code": [], "line_no": [] }
static inline int FUNC_0(APEContext *VAR_0, GetBitContext *VAR_1, APERice *VAR_2) { unsigned int VAR_3, VAR_4; VAR_4 = get_unary(VAR_1, 1, get_bits_left(VAR_1)); if (VAR_0->fileversion > 3880) { while (VAR_4 >= 16) { VAR_4 -= 16; VAR_2->k += 4; } } if (!VAR_2->k) VAR_3 = VAR_4; else VAR_3 = (VAR_4 << VAR_2->k) + get_bits(VAR_1, VAR_2->k); VAR_2->ksum += VAR_3 - (VAR_2->ksum + 8 >> 4); if (VAR_2->ksum < (VAR_2->k ? 1 << (VAR_2->k + 4) : 0)) VAR_2->k--; else if (VAR_2->ksum >= (1 << (VAR_2->k + 5)) && VAR_2->k < 24) VAR_2->k++; if (VAR_3 & 1) return (VAR_3 >> 1) + 1; else return -(VAR_3 >> 1); }
[ "static inline int FUNC_0(APEContext *VAR_0, GetBitContext *VAR_1,\nAPERice *VAR_2)\n{", "unsigned int VAR_3, VAR_4;", "VAR_4 = get_unary(VAR_1, 1, get_bits_left(VAR_1));", "if (VAR_0->fileversion > 3880) {", "while (VAR_4 >= 16) {", "VAR_4 -= 16;", "VAR_2->k += 4;", "}", "}", "if (!VAR_2->k)\nVAR_3 = VAR_4;", "else\nVAR_3 = (VAR_4 << VAR_2->k) + get_bits(VAR_1, VAR_2->k);", "VAR_2->ksum += VAR_3 - (VAR_2->ksum + 8 >> 4);", "if (VAR_2->ksum < (VAR_2->k ? 1 << (VAR_2->k + 4) : 0))\nVAR_2->k--;", "else if (VAR_2->ksum >= (1 << (VAR_2->k + 5)) && VAR_2->k < 24)\nVAR_2->k++;", "if (VAR_3 & 1)\nreturn (VAR_3 >> 1) + 1;", "else\nreturn -(VAR_3 >> 1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29, 31 ], [ 33, 35 ], [ 39 ], [ 41, 43 ], [ 45, 47 ], [ 53, 55 ], [ 57, 59 ], [ 61 ] ]
20,180
int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb) { MpegEncContext *s = &ctx->m; unsigned startcode, v; int ret; int vol = 0; /* search next start code */ align_get_bits(gb); if (s->codec_tag == AV_RL32("WV1F") && show_bits(gb, 24) == 0x575630) { skip_bits(gb, 24); if (get_bits(gb, 8) == 0xF0) goto end; startcode = 0xff; for (;;) { if (get_bits_count(gb) >= gb->size_in_bits) { if (gb->size_in_bits == 8 && (ctx->divx_version >= 0 || ctx->xvid_build >= 0) || s->codec_tag == AV_RL32("QMP4")) { av_log(s->avctx, AV_LOG_VERBOSE, "frame skip %d\n", gb->size_in_bits); return FRAME_SKIPPED; // divx bug } else return -1; // end of stream /* use the bits after the test */ v = get_bits(gb, 8); startcode = ((startcode << 8) | v) & 0xffffffff; if ((startcode & 0xFFFFFF00) != 0x100) continue; // no startcode if (s->avctx->debug & FF_DEBUG_STARTCODE) { av_log(s->avctx, AV_LOG_DEBUG, "startcode: %3X ", startcode); if (startcode <= 0x11F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Start"); else if (startcode <= 0x12F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Layer Start"); else if (startcode <= 0x13F) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if (startcode <= 0x15F) av_log(s->avctx, AV_LOG_DEBUG, "FGS bp start"); else if (startcode <= 0x1AF) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if (startcode == 0x1B0) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq Start"); else if (startcode == 0x1B1) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq End"); else if (startcode == 0x1B2) av_log(s->avctx, AV_LOG_DEBUG, "User Data"); else if (startcode == 0x1B3) av_log(s->avctx, AV_LOG_DEBUG, "Group of VOP start"); else if (startcode == 0x1B4) av_log(s->avctx, AV_LOG_DEBUG, "Video Session Error"); else if (startcode == 0x1B5) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Start"); else if (startcode == 0x1B6) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Plane start"); else if (startcode == 0x1B7) av_log(s->avctx, AV_LOG_DEBUG, "slice start"); else if (startcode == 0x1B8) av_log(s->avctx, AV_LOG_DEBUG, "extension start"); else if (startcode == 0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start"); else if (startcode == 0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start"); else if (startcode == 0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start"); else if (startcode == 0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start"); else if (startcode == 0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start"); else if (startcode == 0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start"); else if (startcode == 0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start"); else if (startcode == 0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start"); else if (startcode == 0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start"); else if (startcode == 0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start"); else if (startcode == 0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start"); else if (startcode <= 0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved"); else if (startcode <= 0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start"); av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb)); if (startcode >= 0x120 && startcode <= 0x12F) { if ((ret = decode_vol_header(ctx, gb)) < 0) return ret; } else if (startcode == USER_DATA_STARTCODE) { decode_user_data(ctx, gb); } else if (startcode == GOP_STARTCODE) { mpeg4_decode_gop_header(s, gb); } else if (startcode == VOS_STARTCODE) { mpeg4_decode_profile_level(s, gb); } else if (startcode == VOP_STARTCODE) { break; align_get_bits(gb); startcode = 0xff; end: if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s->avctx->has_b_frames = !s->low_delay; return decode_vop_header(ctx, gb);
true
FFmpeg
efeb47fd5d5cbf980e52a6d5e741c3c74b94b5e2
int ff_mpeg4_decode_picture_header(Mpeg4DecContext *ctx, GetBitContext *gb) { MpegEncContext *s = &ctx->m; unsigned startcode, v; int ret; int vol = 0; align_get_bits(gb); if (s->codec_tag == AV_RL32("WV1F") && show_bits(gb, 24) == 0x575630) { skip_bits(gb, 24); if (get_bits(gb, 8) == 0xF0) goto end; startcode = 0xff; for (;;) { if (get_bits_count(gb) >= gb->size_in_bits) { if (gb->size_in_bits == 8 && (ctx->divx_version >= 0 || ctx->xvid_build >= 0) || s->codec_tag == AV_RL32("QMP4")) { av_log(s->avctx, AV_LOG_VERBOSE, "frame skip %d\n", gb->size_in_bits); return FRAME_SKIPPED; } else return -1; v = get_bits(gb, 8); startcode = ((startcode << 8) | v) & 0xffffffff; if ((startcode & 0xFFFFFF00) != 0x100) continue; if (s->avctx->debug & FF_DEBUG_STARTCODE) { av_log(s->avctx, AV_LOG_DEBUG, "startcode: %3X ", startcode); if (startcode <= 0x11F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Start"); else if (startcode <= 0x12F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Layer Start"); else if (startcode <= 0x13F) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if (startcode <= 0x15F) av_log(s->avctx, AV_LOG_DEBUG, "FGS bp start"); else if (startcode <= 0x1AF) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if (startcode == 0x1B0) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq Start"); else if (startcode == 0x1B1) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq End"); else if (startcode == 0x1B2) av_log(s->avctx, AV_LOG_DEBUG, "User Data"); else if (startcode == 0x1B3) av_log(s->avctx, AV_LOG_DEBUG, "Group of VOP start"); else if (startcode == 0x1B4) av_log(s->avctx, AV_LOG_DEBUG, "Video Session Error"); else if (startcode == 0x1B5) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Start"); else if (startcode == 0x1B6) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Plane start"); else if (startcode == 0x1B7) av_log(s->avctx, AV_LOG_DEBUG, "slice start"); else if (startcode == 0x1B8) av_log(s->avctx, AV_LOG_DEBUG, "extension start"); else if (startcode == 0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start"); else if (startcode == 0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start"); else if (startcode == 0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start"); else if (startcode == 0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start"); else if (startcode == 0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start"); else if (startcode == 0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start"); else if (startcode == 0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start"); else if (startcode == 0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start"); else if (startcode == 0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start"); else if (startcode == 0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start"); else if (startcode == 0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start"); else if (startcode <= 0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved"); else if (startcode <= 0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start"); av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(gb)); if (startcode >= 0x120 && startcode <= 0x12F) { if ((ret = decode_vol_header(ctx, gb)) < 0) return ret; } else if (startcode == USER_DATA_STARTCODE) { decode_user_data(ctx, gb); } else if (startcode == GOP_STARTCODE) { mpeg4_decode_gop_header(s, gb); } else if (startcode == VOS_STARTCODE) { mpeg4_decode_profile_level(s, gb); } else if (startcode == VOP_STARTCODE) { break; align_get_bits(gb); startcode = 0xff; end: if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s->avctx->has_b_frames = !s->low_delay; return decode_vop_header(ctx, gb);
{ "code": [], "line_no": [] }
int FUNC_0(Mpeg4DecContext *VAR_0, GetBitContext *VAR_1) { MpegEncContext *s = &VAR_0->m; unsigned VAR_2, VAR_3; int VAR_4; int VAR_5 = 0; align_get_bits(VAR_1); if (s->codec_tag == AV_RL32("WV1F") && show_bits(VAR_1, 24) == 0x575630) { skip_bits(VAR_1, 24); if (get_bits(VAR_1, 8) == 0xF0) goto end; VAR_2 = 0xff; for (;;) { if (get_bits_count(VAR_1) >= VAR_1->size_in_bits) { if (VAR_1->size_in_bits == 8 && (VAR_0->divx_version >= 0 || VAR_0->xvid_build >= 0) || s->codec_tag == AV_RL32("QMP4")) { av_log(s->avctx, AV_LOG_VERBOSE, "frame skip %d\n", VAR_1->size_in_bits); return FRAME_SKIPPED; } else return -1; VAR_3 = get_bits(VAR_1, 8); VAR_2 = ((VAR_2 << 8) | VAR_3) & 0xffffffff; if ((VAR_2 & 0xFFFFFF00) != 0x100) continue; if (s->avctx->debug & FF_DEBUG_STARTCODE) { av_log(s->avctx, AV_LOG_DEBUG, "VAR_2: %3X ", VAR_2); if (VAR_2 <= 0x11F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Start"); else if (VAR_2 <= 0x12F) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Layer Start"); else if (VAR_2 <= 0x13F) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if (VAR_2 <= 0x15F) av_log(s->avctx, AV_LOG_DEBUG, "FGS bp start"); else if (VAR_2 <= 0x1AF) av_log(s->avctx, AV_LOG_DEBUG, "Reserved"); else if (VAR_2 == 0x1B0) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq Start"); else if (VAR_2 == 0x1B1) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Seq End"); else if (VAR_2 == 0x1B2) av_log(s->avctx, AV_LOG_DEBUG, "User Data"); else if (VAR_2 == 0x1B3) av_log(s->avctx, AV_LOG_DEBUG, "Group of VOP start"); else if (VAR_2 == 0x1B4) av_log(s->avctx, AV_LOG_DEBUG, "Video Session Error"); else if (VAR_2 == 0x1B5) av_log(s->avctx, AV_LOG_DEBUG, "Visual Object Start"); else if (VAR_2 == 0x1B6) av_log(s->avctx, AV_LOG_DEBUG, "Video Object Plane start"); else if (VAR_2 == 0x1B7) av_log(s->avctx, AV_LOG_DEBUG, "slice start"); else if (VAR_2 == 0x1B8) av_log(s->avctx, AV_LOG_DEBUG, "extension start"); else if (VAR_2 == 0x1B9) av_log(s->avctx, AV_LOG_DEBUG, "fgs start"); else if (VAR_2 == 0x1BA) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object start"); else if (VAR_2 == 0x1BB) av_log(s->avctx, AV_LOG_DEBUG, "FBA Object Plane start"); else if (VAR_2 == 0x1BC) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object start"); else if (VAR_2 == 0x1BD) av_log(s->avctx, AV_LOG_DEBUG, "Mesh Object Plane start"); else if (VAR_2 == 0x1BE) av_log(s->avctx, AV_LOG_DEBUG, "Still Texture Object start"); else if (VAR_2 == 0x1BF) av_log(s->avctx, AV_LOG_DEBUG, "Texture Spatial Layer start"); else if (VAR_2 == 0x1C0) av_log(s->avctx, AV_LOG_DEBUG, "Texture SNR Layer start"); else if (VAR_2 == 0x1C1) av_log(s->avctx, AV_LOG_DEBUG, "Texture Tile start"); else if (VAR_2 == 0x1C2) av_log(s->avctx, AV_LOG_DEBUG, "Texture Shape Layer start"); else if (VAR_2 == 0x1C3) av_log(s->avctx, AV_LOG_DEBUG, "stuffing start"); else if (VAR_2 <= 0x1C5) av_log(s->avctx, AV_LOG_DEBUG, "reserved"); else if (VAR_2 <= 0x1FF) av_log(s->avctx, AV_LOG_DEBUG, "System start"); av_log(s->avctx, AV_LOG_DEBUG, " at %d\n", get_bits_count(VAR_1)); if (VAR_2 >= 0x120 && VAR_2 <= 0x12F) { if ((VAR_4 = decode_vol_header(VAR_0, VAR_1)) < 0) return VAR_4; } else if (VAR_2 == USER_DATA_STARTCODE) { decode_user_data(VAR_0, VAR_1); } else if (VAR_2 == GOP_STARTCODE) { mpeg4_decode_gop_header(s, VAR_1); } else if (VAR_2 == VOS_STARTCODE) { mpeg4_decode_profile_level(s, VAR_1); } else if (VAR_2 == VOP_STARTCODE) { break; align_get_bits(VAR_1); VAR_2 = 0xff; end: if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s->avctx->has_b_frames = !s->low_delay; return decode_vop_header(VAR_0, VAR_1);
[ "int FUNC_0(Mpeg4DecContext *VAR_0, GetBitContext *VAR_1)\n{", "MpegEncContext *s = &VAR_0->m;", "unsigned VAR_2, VAR_3;", "int VAR_4;", "int VAR_5 = 0;", "align_get_bits(VAR_1);", "if (s->codec_tag == AV_RL32(\"WV1F\") && show_bits(VAR_1, 24) == 0x575630) {", "skip_bits(VAR_1, 24);", "if (get_bits(VAR_1, 8) == 0xF0)\ngoto end;", "VAR_2 = 0xff;", "for (;;) {", "if (get_bits_count(VAR_1) >= VAR_1->size_in_bits) {", "if (VAR_1->size_in_bits == 8 &&\n(VAR_0->divx_version >= 0 || VAR_0->xvid_build >= 0) || s->codec_tag == AV_RL32(\"QMP4\")) {", "av_log(s->avctx, AV_LOG_VERBOSE, \"frame skip %d\\n\", VAR_1->size_in_bits);", "return FRAME_SKIPPED;", "} else", "return -1;", "VAR_3 = get_bits(VAR_1, 8);", "VAR_2 = ((VAR_2 << 8) | VAR_3) & 0xffffffff;", "if ((VAR_2 & 0xFFFFFF00) != 0x100)\ncontinue;", "if (s->avctx->debug & FF_DEBUG_STARTCODE) {", "av_log(s->avctx, AV_LOG_DEBUG, \"VAR_2: %3X \", VAR_2);", "if (VAR_2 <= 0x11F)\nav_log(s->avctx, AV_LOG_DEBUG, \"Video Object Start\");", "else if (VAR_2 <= 0x12F)\nav_log(s->avctx, AV_LOG_DEBUG, \"Video Object Layer Start\");", "else if (VAR_2 <= 0x13F)\nav_log(s->avctx, AV_LOG_DEBUG, \"Reserved\");", "else if (VAR_2 <= 0x15F)\nav_log(s->avctx, AV_LOG_DEBUG, \"FGS bp start\");", "else if (VAR_2 <= 0x1AF)\nav_log(s->avctx, AV_LOG_DEBUG, \"Reserved\");", "else if (VAR_2 == 0x1B0)\nav_log(s->avctx, AV_LOG_DEBUG, \"Visual Object Seq Start\");", "else if (VAR_2 == 0x1B1)\nav_log(s->avctx, AV_LOG_DEBUG, \"Visual Object Seq End\");", "else if (VAR_2 == 0x1B2)\nav_log(s->avctx, AV_LOG_DEBUG, \"User Data\");", "else if (VAR_2 == 0x1B3)\nav_log(s->avctx, AV_LOG_DEBUG, \"Group of VOP start\");", "else if (VAR_2 == 0x1B4)\nav_log(s->avctx, AV_LOG_DEBUG, \"Video Session Error\");", "else if (VAR_2 == 0x1B5)\nav_log(s->avctx, AV_LOG_DEBUG, \"Visual Object Start\");", "else if (VAR_2 == 0x1B6)\nav_log(s->avctx, AV_LOG_DEBUG, \"Video Object Plane start\");", "else if (VAR_2 == 0x1B7)\nav_log(s->avctx, AV_LOG_DEBUG, \"slice start\");", "else if (VAR_2 == 0x1B8)\nav_log(s->avctx, AV_LOG_DEBUG, \"extension start\");", "else if (VAR_2 == 0x1B9)\nav_log(s->avctx, AV_LOG_DEBUG, \"fgs start\");", "else if (VAR_2 == 0x1BA)\nav_log(s->avctx, AV_LOG_DEBUG, \"FBA Object start\");", "else if (VAR_2 == 0x1BB)\nav_log(s->avctx, AV_LOG_DEBUG, \"FBA Object Plane start\");", "else if (VAR_2 == 0x1BC)\nav_log(s->avctx, AV_LOG_DEBUG, \"Mesh Object start\");", "else if (VAR_2 == 0x1BD)\nav_log(s->avctx, AV_LOG_DEBUG, \"Mesh Object Plane start\");", "else if (VAR_2 == 0x1BE)\nav_log(s->avctx, AV_LOG_DEBUG, \"Still Texture Object start\");", "else if (VAR_2 == 0x1BF)\nav_log(s->avctx, AV_LOG_DEBUG, \"Texture Spatial Layer start\");", "else if (VAR_2 == 0x1C0)\nav_log(s->avctx, AV_LOG_DEBUG, \"Texture SNR Layer start\");", "else if (VAR_2 == 0x1C1)\nav_log(s->avctx, AV_LOG_DEBUG, \"Texture Tile start\");", "else if (VAR_2 == 0x1C2)\nav_log(s->avctx, AV_LOG_DEBUG, \"Texture Shape Layer start\");", "else if (VAR_2 == 0x1C3)\nav_log(s->avctx, AV_LOG_DEBUG, \"stuffing start\");", "else if (VAR_2 <= 0x1C5)\nav_log(s->avctx, AV_LOG_DEBUG, \"reserved\");", "else if (VAR_2 <= 0x1FF)\nav_log(s->avctx, AV_LOG_DEBUG, \"System start\");", "av_log(s->avctx, AV_LOG_DEBUG, \" at %d\\n\", get_bits_count(VAR_1));", "if (VAR_2 >= 0x120 && VAR_2 <= 0x12F) {", "if ((VAR_4 = decode_vol_header(VAR_0, VAR_1)) < 0)\nreturn VAR_4;", "} else if (VAR_2 == USER_DATA_STARTCODE) {", "decode_user_data(VAR_0, VAR_1);", "} else if (VAR_2 == GOP_STARTCODE) {", "mpeg4_decode_gop_header(s, VAR_1);", "} else if (VAR_2 == VOS_STARTCODE) {", "mpeg4_decode_profile_level(s, VAR_1);", "} else if (VAR_2 == VOP_STARTCODE) {", "break;", "align_get_bits(VAR_1);", "VAR_2 = 0xff;", "end:\nif (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY)\ns->low_delay = 1;", "s->avctx->has_b_frames = !s->low_delay;", "return decode_vop_header(VAR_0, VAR_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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 17 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 32 ], [ 34 ], [ 36 ], [ 38, 40 ], [ 42 ], [ 44 ], [ 46 ], [ 48 ], [ 55 ], [ 57 ], [ 61, 63 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75, 77 ], [ 79, 81 ], [ 83, 85 ], [ 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 ], [ 184 ], [ 191, 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 214 ], [ 216 ], [ 221, 223, 225 ], [ 227 ], [ 231 ] ]
20,182
static int asf_read_single_payload(AVFormatContext *s, AVPacket *pkt, ASFPacket *asf_pkt) { ASFContext *asf = s->priv_data; AVIOContext *pb = s->pb; int64_t offset; uint64_t size; unsigned char *p; int ret; if (!asf_pkt->data_size) { asf_pkt->data_size = asf_pkt->size_left = avio_rl32(pb); // read media object size if (asf_pkt->data_size <= 0) return AVERROR_EOF; if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0) return ret; } else avio_skip(pb, 4); // skip media object size asf_pkt->dts = avio_rl32(pb); // read presentation time if (asf->rep_data_len >= 8) avio_skip(pb, asf->rep_data_len - 8); // skip replicated data offset = avio_tell(pb); // size of the payload - size of the packet without header and padding if (asf->packet_size_internal) size = asf->packet_size_internal - offset + asf->packet_offset - asf->pad_len; else size = asf->packet_size - offset + asf->packet_offset - asf->pad_len; if (size > asf->packet_size) { av_log(s, AV_LOG_ERROR, "Error: invalid data packet size, offset %"PRId64".\n", avio_tell(pb)); return AVERROR_INVALIDDATA; } p = asf_pkt->avpkt.data + asf_pkt->data_size - asf_pkt->size_left; if (size > asf_pkt->size_left || asf_pkt->size_left <= 0) return AVERROR_INVALIDDATA; if (asf_pkt->size_left > size) asf_pkt->size_left -= size; else asf_pkt->size_left = 0; if ((ret = avio_read(pb, p, size)) < 0) return ret; if (s->key && s->keylen == 20) ff_asfcrypt_dec(s->key, p, ret); if (asf->packet_size_internal) avio_skip(pb, asf->packet_size - asf->packet_size_internal); avio_skip(pb, asf->pad_len); // skip padding return 0; }
true
FFmpeg
763c572801a3db1cc7a2f07a52fee9d2e35ec95a
static int asf_read_single_payload(AVFormatContext *s, AVPacket *pkt, ASFPacket *asf_pkt) { ASFContext *asf = s->priv_data; AVIOContext *pb = s->pb; int64_t offset; uint64_t size; unsigned char *p; int ret; if (!asf_pkt->data_size) { asf_pkt->data_size = asf_pkt->size_left = avio_rl32(pb); if (asf_pkt->data_size <= 0) return AVERROR_EOF; if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0) return ret; } else avio_skip(pb, 4); asf_pkt->dts = avio_rl32(pb); if (asf->rep_data_len >= 8) avio_skip(pb, asf->rep_data_len - 8); offset = avio_tell(pb); if (asf->packet_size_internal) size = asf->packet_size_internal - offset + asf->packet_offset - asf->pad_len; else size = asf->packet_size - offset + asf->packet_offset - asf->pad_len; if (size > asf->packet_size) { av_log(s, AV_LOG_ERROR, "Error: invalid data packet size, offset %"PRId64".\n", avio_tell(pb)); return AVERROR_INVALIDDATA; } p = asf_pkt->avpkt.data + asf_pkt->data_size - asf_pkt->size_left; if (size > asf_pkt->size_left || asf_pkt->size_left <= 0) return AVERROR_INVALIDDATA; if (asf_pkt->size_left > size) asf_pkt->size_left -= size; else asf_pkt->size_left = 0; if ((ret = avio_read(pb, p, size)) < 0) return ret; if (s->key && s->keylen == 20) ff_asfcrypt_dec(s->key, p, ret); if (asf->packet_size_internal) avio_skip(pb, asf->packet_size - asf->packet_size_internal); avio_skip(pb, asf->pad_len); return 0; }
{ "code": [ " int ret;", " if (asf_pkt->data_size <= 0)", " if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0)", " int ret;", " if (asf_pkt->data_size <= 0)", " if ((ret = av_new_packet(&asf_pkt->avpkt, asf_pkt->data_size)) < 0)" ], "line_no": [ 17, 25, 29, 17, 25, 29 ] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1, ASFPacket *VAR_2) { ASFContext *asf = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; int64_t offset; uint64_t size; unsigned char *VAR_3; int VAR_4; if (!VAR_2->data_size) { VAR_2->data_size = VAR_2->size_left = avio_rl32(pb); if (VAR_2->data_size <= 0) return AVERROR_EOF; if ((VAR_4 = av_new_packet(&VAR_2->avpkt, VAR_2->data_size)) < 0) return VAR_4; } else avio_skip(pb, 4); VAR_2->dts = avio_rl32(pb); if (asf->rep_data_len >= 8) avio_skip(pb, asf->rep_data_len - 8); offset = avio_tell(pb); if (asf->packet_size_internal) size = asf->packet_size_internal - offset + asf->packet_offset - asf->pad_len; else size = asf->packet_size - offset + asf->packet_offset - asf->pad_len; if (size > asf->packet_size) { av_log(VAR_0, AV_LOG_ERROR, "Error: invalid data packet size, offset %"PRId64".\n", avio_tell(pb)); return AVERROR_INVALIDDATA; } VAR_3 = VAR_2->avpkt.data + VAR_2->data_size - VAR_2->size_left; if (size > VAR_2->size_left || VAR_2->size_left <= 0) return AVERROR_INVALIDDATA; if (VAR_2->size_left > size) VAR_2->size_left -= size; else VAR_2->size_left = 0; if ((VAR_4 = avio_read(pb, VAR_3, size)) < 0) return VAR_4; if (VAR_0->key && VAR_0->keylen == 20) ff_asfcrypt_dec(VAR_0->key, VAR_3, VAR_4); if (asf->packet_size_internal) avio_skip(pb, asf->packet_size - asf->packet_size_internal); avio_skip(pb, asf->pad_len); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1,\nASFPacket *VAR_2)\n{", "ASFContext *asf = VAR_0->priv_data;", "AVIOContext *pb = VAR_0->pb;", "int64_t offset;", "uint64_t size;", "unsigned char *VAR_3;", "int VAR_4;", "if (!VAR_2->data_size) {", "VAR_2->data_size = VAR_2->size_left = avio_rl32(pb);", "if (VAR_2->data_size <= 0)\nreturn AVERROR_EOF;", "if ((VAR_4 = av_new_packet(&VAR_2->avpkt, VAR_2->data_size)) < 0)\nreturn VAR_4;", "} else", "avio_skip(pb, 4);", "VAR_2->dts = avio_rl32(pb);", "if (asf->rep_data_len >= 8)\navio_skip(pb, asf->rep_data_len - 8);", "offset = avio_tell(pb);", "if (asf->packet_size_internal)\nsize = asf->packet_size_internal - offset + asf->packet_offset - asf->pad_len;", "else\nsize = asf->packet_size - offset + asf->packet_offset - asf->pad_len;", "if (size > asf->packet_size) {", "av_log(VAR_0, AV_LOG_ERROR,\n\"Error: invalid data packet size, offset %\"PRId64\".\\n\",\navio_tell(pb));", "return AVERROR_INVALIDDATA;", "}", "VAR_3 = VAR_2->avpkt.data + VAR_2->data_size - VAR_2->size_left;", "if (size > VAR_2->size_left || VAR_2->size_left <= 0)\nreturn AVERROR_INVALIDDATA;", "if (VAR_2->size_left > size)\nVAR_2->size_left -= size;", "else\nVAR_2->size_left = 0;", "if ((VAR_4 = avio_read(pb, VAR_3, size)) < 0)\nreturn VAR_4;", "if (VAR_0->key && VAR_0->keylen == 20)\nff_asfcrypt_dec(VAR_0->key, VAR_3, VAR_4);", "if (asf->packet_size_internal)\navio_skip(pb, asf->packet_size - asf->packet_size_internal);", "avio_skip(pb, asf->pad_len);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 49, 51 ], [ 53, 55 ], [ 57 ], [ 59, 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75, 77 ], [ 79, 81 ], [ 83, 85 ], [ 87, 89 ], [ 91, 93 ], [ 95 ], [ 99 ], [ 101 ] ]
20,185
static int ide_qdev_init(DeviceState *qdev, DeviceInfo *base) { IDEDevice *dev = DO_UPCAST(IDEDevice, qdev, qdev); IDEDeviceInfo *info = DO_UPCAST(IDEDeviceInfo, qdev, base); IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus); if (!dev->conf.bs) { fprintf(stderr, "%s: no drive specified\n", qdev->info->name); goto err; } if (dev->unit == -1) { dev->unit = bus->master ? 1 : 0; } switch (dev->unit) { case 0: if (bus->master) { fprintf(stderr, "ide: tried to assign master twice\n"); goto err; } bus->master = dev; break; case 1: if (bus->slave) { fprintf(stderr, "ide: tried to assign slave twice\n"); goto err; } bus->slave = dev; break; default: goto err; } return info->init(dev); err: return -1; }
true
qemu
f597627ff5eb683501d65cf169f467bb4e894626
static int ide_qdev_init(DeviceState *qdev, DeviceInfo *base) { IDEDevice *dev = DO_UPCAST(IDEDevice, qdev, qdev); IDEDeviceInfo *info = DO_UPCAST(IDEDeviceInfo, qdev, base); IDEBus *bus = DO_UPCAST(IDEBus, qbus, qdev->parent_bus); if (!dev->conf.bs) { fprintf(stderr, "%s: no drive specified\n", qdev->info->name); goto err; } if (dev->unit == -1) { dev->unit = bus->master ? 1 : 0; } switch (dev->unit) { case 0: if (bus->master) { fprintf(stderr, "ide: tried to assign master twice\n"); goto err; } bus->master = dev; break; case 1: if (bus->slave) { fprintf(stderr, "ide: tried to assign slave twice\n"); goto err; } bus->slave = dev; break; default: goto err; } return info->init(dev); err: return -1; }
{ "code": [ " fprintf(stderr, \"%s: no drive specified\\n\", qdev->info->name);", " fprintf(stderr, \"ide: tried to assign master twice\\n\");", " fprintf(stderr, \"ide: tried to assign slave twice\\n\");" ], "line_no": [ 15, 33, 47 ] }
static int FUNC_0(DeviceState *VAR_0, DeviceInfo *VAR_1) { IDEDevice *dev = DO_UPCAST(IDEDevice, VAR_0, VAR_0); IDEDeviceInfo *info = DO_UPCAST(IDEDeviceInfo, VAR_0, VAR_1); IDEBus *bus = DO_UPCAST(IDEBus, qbus, VAR_0->parent_bus); if (!dev->conf.bs) { fprintf(stderr, "%s: no drive specified\n", VAR_0->info->name); goto err; } if (dev->unit == -1) { dev->unit = bus->master ? 1 : 0; } switch (dev->unit) { case 0: if (bus->master) { fprintf(stderr, "ide: tried to assign master twice\n"); goto err; } bus->master = dev; break; case 1: if (bus->slave) { fprintf(stderr, "ide: tried to assign slave twice\n"); goto err; } bus->slave = dev; break; default: goto err; } return info->init(dev); err: return -1; }
[ "static int FUNC_0(DeviceState *VAR_0, DeviceInfo *VAR_1)\n{", "IDEDevice *dev = DO_UPCAST(IDEDevice, VAR_0, VAR_0);", "IDEDeviceInfo *info = DO_UPCAST(IDEDeviceInfo, VAR_0, VAR_1);", "IDEBus *bus = DO_UPCAST(IDEBus, qbus, VAR_0->parent_bus);", "if (!dev->conf.bs) {", "fprintf(stderr, \"%s: no drive specified\\n\", VAR_0->info->name);", "goto err;", "}", "if (dev->unit == -1) {", "dev->unit = bus->master ? 1 : 0;", "}", "switch (dev->unit) {", "case 0:\nif (bus->master) {", "fprintf(stderr, \"ide: tried to assign master twice\\n\");", "goto err;", "}", "bus->master = dev;", "break;", "case 1:\nif (bus->slave) {", "fprintf(stderr, \"ide: tried to assign slave twice\\n\");", "goto err;", "}", "bus->slave = dev;", "break;", "default:\ngoto err;", "}", "return info->init(dev);", "err:\nreturn -1;", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 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 ], [ 67, 69 ], [ 71 ] ]
20,186
int net_init_vhost_user(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) { int queues; const NetdevVhostUserOptions *vhost_user_opts; CharDriverState *chr; assert(opts->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); vhost_user_opts = opts->u.vhost_user; chr = net_vhost_parse_chardev(vhost_user_opts, errp); if (!chr) { return -1; } /* verify net frontend */ if (qemu_opts_foreach(qemu_find_opts("device"), net_vhost_check_net, (char *)name, errp)) { return -1; } queues = vhost_user_opts->has_queues ? vhost_user_opts->queues : 1; if (queues < 1) { error_setg(errp, "vhost-user number of queues must be bigger than zero"); return -1; } return net_vhost_user_init(peer, "vhost_user", name, chr, queues); }
true
qemu
fff4e48ed54cc39e5942921df91300646ad37707
int net_init_vhost_user(const NetClientOptions *opts, const char *name, NetClientState *peer, Error **errp) { int queues; const NetdevVhostUserOptions *vhost_user_opts; CharDriverState *chr; assert(opts->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); vhost_user_opts = opts->u.vhost_user; chr = net_vhost_parse_chardev(vhost_user_opts, errp); if (!chr) { return -1; } if (qemu_opts_foreach(qemu_find_opts("device"), net_vhost_check_net, (char *)name, errp)) { return -1; } queues = vhost_user_opts->has_queues ? vhost_user_opts->queues : 1; if (queues < 1) { error_setg(errp, "vhost-user number of queues must be bigger than zero"); return -1; } return net_vhost_user_init(peer, "vhost_user", name, chr, queues); }
{ "code": [ " if (queues < 1) {", " \"vhost-user number of queues must be bigger than zero\");" ], "line_no": [ 45, 49 ] }
int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1, NetClientState *VAR_2, Error **VAR_3) { int VAR_4; const NetdevVhostUserOptions *VAR_5; CharDriverState *chr; assert(VAR_0->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER); VAR_5 = VAR_0->u.vhost_user; chr = net_vhost_parse_chardev(VAR_5, VAR_3); if (!chr) { return -1; } if (qemu_opts_foreach(qemu_find_opts("device"), net_vhost_check_net, (char *)VAR_1, VAR_3)) { return -1; } VAR_4 = VAR_5->has_queues ? VAR_5->VAR_4 : 1; if (VAR_4 < 1) { error_setg(VAR_3, "vhost-user number of VAR_4 must be bigger than zero"); return -1; } return net_vhost_user_init(VAR_2, "vhost_user", VAR_1, chr, VAR_4); }
[ "int FUNC_0(const NetClientOptions *VAR_0, const char *VAR_1,\nNetClientState *VAR_2, Error **VAR_3)\n{", "int VAR_4;", "const NetdevVhostUserOptions *VAR_5;", "CharDriverState *chr;", "assert(VAR_0->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER);", "VAR_5 = VAR_0->u.vhost_user;", "chr = net_vhost_parse_chardev(VAR_5, VAR_3);", "if (!chr) {", "return -1;", "}", "if (qemu_opts_foreach(qemu_find_opts(\"device\"), net_vhost_check_net,\n(char *)VAR_1, VAR_3)) {", "return -1;", "}", "VAR_4 = VAR_5->has_queues ? VAR_5->VAR_4 : 1;", "if (VAR_4 < 1) {", "error_setg(VAR_3,\n\"vhost-user number of VAR_4 must be bigger than zero\");", "return -1;", "}", "return net_vhost_user_init(VAR_2, \"vhost_user\", VAR_1, chr, VAR_4);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ] ]
20,187
static int ds1338_send(I2CSlave *i2c, uint8_t data) { DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c); if (s->addr_byte) { s->ptr = data; s->addr_byte = 0; return 0; } s->nvram[s->ptr - 8] = data; if (data < 8) { qemu_get_timedate(&s->now, s->offset); switch(data) { case 0: /* TODO: Implement CH (stop) bit. */ s->now.tm_sec = from_bcd(data & 0x7f); break; case 1: s->now.tm_min = from_bcd(data & 0x7f); break; case 2: if (data & 0x40) { if (data & 0x20) { data = from_bcd(data & 0x4f) + 11; } else { data = from_bcd(data & 0x1f) - 1; } } else { data = from_bcd(data); } s->now.tm_hour = data; break; case 3: s->now.tm_wday = from_bcd(data & 7) - 1; break; case 4: s->now.tm_mday = from_bcd(data & 0x3f); break; case 5: s->now.tm_mon = from_bcd(data & 0x1f) - 1; break; case 6: s->now.tm_year = from_bcd(data) + 100; break; case 7: /* Control register. Currently ignored. */ break; } s->offset = qemu_timedate_diff(&s->now); } s->ptr = (s->ptr + 1) & 0xff; return 0; }
true
qemu
ba4906a9b64e165a958e12f6208ca834dc7a36dc
static int ds1338_send(I2CSlave *i2c, uint8_t data) { DS1338State *s = FROM_I2C_SLAVE(DS1338State, i2c); if (s->addr_byte) { s->ptr = data; s->addr_byte = 0; return 0; } s->nvram[s->ptr - 8] = data; if (data < 8) { qemu_get_timedate(&s->now, s->offset); switch(data) { case 0: s->now.tm_sec = from_bcd(data & 0x7f); break; case 1: s->now.tm_min = from_bcd(data & 0x7f); break; case 2: if (data & 0x40) { if (data & 0x20) { data = from_bcd(data & 0x4f) + 11; } else { data = from_bcd(data & 0x1f) - 1; } } else { data = from_bcd(data); } s->now.tm_hour = data; break; case 3: s->now.tm_wday = from_bcd(data & 7) - 1; break; case 4: s->now.tm_mday = from_bcd(data & 0x3f); break; case 5: s->now.tm_mon = from_bcd(data & 0x1f) - 1; break; case 6: s->now.tm_year = from_bcd(data) + 100; break; case 7: break; } s->offset = qemu_timedate_diff(&s->now); } s->ptr = (s->ptr + 1) & 0xff; return 0; }
{ "code": [ " s->ptr = (s->ptr + 1) & 0xff;", " s->ptr = data;", " s->nvram[s->ptr - 8] = data;", " if (data < 8) {", " switch(data) {", " s->ptr = (s->ptr + 1) & 0xff;" ], "line_no": [ 99, 9, 17, 19, 23, 99 ] }
static int FUNC_0(I2CSlave *VAR_0, uint8_t VAR_1) { DS1338State *s = FROM_I2C_SLAVE(DS1338State, VAR_0); if (s->addr_byte) { s->ptr = VAR_1; s->addr_byte = 0; return 0; } s->nvram[s->ptr - 8] = VAR_1; if (VAR_1 < 8) { qemu_get_timedate(&s->now, s->offset); switch(VAR_1) { case 0: s->now.tm_sec = from_bcd(VAR_1 & 0x7f); break; case 1: s->now.tm_min = from_bcd(VAR_1 & 0x7f); break; case 2: if (VAR_1 & 0x40) { if (VAR_1 & 0x20) { VAR_1 = from_bcd(VAR_1 & 0x4f) + 11; } else { VAR_1 = from_bcd(VAR_1 & 0x1f) - 1; } } else { VAR_1 = from_bcd(VAR_1); } s->now.tm_hour = VAR_1; break; case 3: s->now.tm_wday = from_bcd(VAR_1 & 7) - 1; break; case 4: s->now.tm_mday = from_bcd(VAR_1 & 0x3f); break; case 5: s->now.tm_mon = from_bcd(VAR_1 & 0x1f) - 1; break; case 6: s->now.tm_year = from_bcd(VAR_1) + 100; break; case 7: break; } s->offset = qemu_timedate_diff(&s->now); } s->ptr = (s->ptr + 1) & 0xff; return 0; }
[ "static int FUNC_0(I2CSlave *VAR_0, uint8_t VAR_1)\n{", "DS1338State *s = FROM_I2C_SLAVE(DS1338State, VAR_0);", "if (s->addr_byte) {", "s->ptr = VAR_1;", "s->addr_byte = 0;", "return 0;", "}", "s->nvram[s->ptr - 8] = VAR_1;", "if (VAR_1 < 8) {", "qemu_get_timedate(&s->now, s->offset);", "switch(VAR_1) {", "case 0:\ns->now.tm_sec = from_bcd(VAR_1 & 0x7f);", "break;", "case 1:\ns->now.tm_min = from_bcd(VAR_1 & 0x7f);", "break;", "case 2:\nif (VAR_1 & 0x40) {", "if (VAR_1 & 0x20) {", "VAR_1 = from_bcd(VAR_1 & 0x4f) + 11;", "} else {", "VAR_1 = from_bcd(VAR_1 & 0x1f) - 1;", "}", "} else {", "VAR_1 = from_bcd(VAR_1);", "}", "s->now.tm_hour = VAR_1;", "break;", "case 3:\ns->now.tm_wday = from_bcd(VAR_1 & 7) - 1;", "break;", "case 4:\ns->now.tm_mday = from_bcd(VAR_1 & 0x3f);", "break;", "case 5:\ns->now.tm_mon = from_bcd(VAR_1 & 0x1f) - 1;", "break;", "case 6:\ns->now.tm_year = from_bcd(VAR_1) + 100;", "break;", "case 7:\nbreak;", "}", "s->offset = qemu_timedate_diff(&s->now);", "}", "s->ptr = (s->ptr + 1) & 0xff;", "return 0;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0, 1, 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, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 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, 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ] ]
20,188
static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) { int P[6][2]; const int mot_stride = s->mb_width + 2; const int mot_xy = (mb_y + 1)*mot_stride + mb_x + 1; int dmin, dmin2; int motion_fx, motion_fy, motion_bx, motion_by, motion_bx0, motion_by0; int motion_dx, motion_dy; const int motion_px= s->p_mv_table[mot_xy][0]; const int motion_py= s->p_mv_table[mot_xy][1]; const int time_pp= s->pp_time; const int time_bp= s->bp_time; const int time_pb= time_pp - time_bp; int bx, by; int mx, my, mx2, my2; uint8_t *ref_picture= s->me_scratchpad - (mb_x + 1 + (mb_y + 1)*s->linesize)*16; int16_t (*mv_table)[2]= s->b_direct_mv_table; uint16_t *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; // f_code of the prev frame /* thanks to iso-mpeg the rounding is different for the zero vector, so we need to handle that ... */ motion_fx= (motion_px*time_pb)/time_pp; motion_fy= (motion_py*time_pb)/time_pp; motion_bx0= (-motion_px*time_bp)/time_pp; motion_by0= (-motion_py*time_bp)/time_pp; motion_dx= motion_dy=0; dmin2= check_bidir_mv(s, mb_x, mb_y, motion_fx, motion_fy, motion_bx0, motion_by0, motion_fx, motion_fy, motion_bx0, motion_by0) - s->qscale; motion_bx= motion_fx - motion_px; motion_by= motion_fy - motion_py; for(by=-1; by<2; by++){ for(bx=-1; bx<2; bx++){ uint8_t *dest_y = s->me_scratchpad + (by+1)*s->linesize*16 + (bx+1)*16; uint8_t *ptr; int dxy; int src_x, src_y; const int width= s->width; const int height= s->height; dxy = ((motion_fy & 1) << 1) | (motion_fx & 1); src_x = (mb_x + bx) * 16 + (motion_fx >> 1); src_y = (mb_y + by) * 16 + (motion_fy >> 1); src_x = clip(src_x, -16, width); if (src_x == width) dxy &= ~1; src_y = clip(src_y, -16, height); if (src_y == height) dxy &= ~2; ptr = s->last_picture[0] + (src_y * s->linesize) + src_x; put_pixels_tab[dxy](dest_y , ptr , s->linesize, 16); put_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16); dxy = ((motion_by & 1) << 1) | (motion_bx & 1); src_x = (mb_x + bx) * 16 + (motion_bx >> 1); src_y = (mb_y + by) * 16 + (motion_by >> 1); src_x = clip(src_x, -16, width); if (src_x == width) dxy &= ~1; src_y = clip(src_y, -16, height); if (src_y == height) dxy &= ~2; avg_pixels_tab[dxy](dest_y , ptr , s->linesize, 16); avg_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16); } } P[0][0] = mv_table[mot_xy ][0]; P[0][1] = mv_table[mot_xy ][1]; P[1][0] = mv_table[mot_xy - 1][0]; P[1][1] = mv_table[mot_xy - 1][1]; /* special case for first line */ if ((mb_y == 0 || s->first_slice_line || s->first_gob_line)) { P[4][0] = P[1][0]; P[4][1] = P[1][1]; } else { P[2][0] = mv_table[mot_xy - mot_stride ][0]; P[2][1] = mv_table[mot_xy - mot_stride ][1]; P[3][0] = mv_table[mot_xy - mot_stride + 1 ][0]; P[3][1] = mv_table[mot_xy - mot_stride + 1 ][1]; P[4][0]= mid_pred(P[1][0], P[2][0], P[3][0]); P[4][1]= mid_pred(P[1][1], P[2][1], P[3][1]); } dmin = epzs_motion_search(s, &mx, &my, P, 0, 0, -16, -16, 15, 15, ref_picture); if(mx==0 && my==0) dmin=99999999; // not representable, due to rounding stuff if(dmin2<dmin){ dmin= dmin2; mx=0; my=0; } #if 1 mx2= mx= mx*2; my2= my= my*2; for(by=-1; by<2; by++){ if(my2+by < -32) continue; for(bx=-1; bx<2; bx++){ if(bx==0 && by==0) continue; if(mx2+bx < -32) continue; dmin2= check_bidir_mv(s, mb_x, mb_y, mx2+bx+motion_fx, my2+by+motion_fy, mx2+bx+motion_bx, my2+by+motion_by, mx2+bx+motion_fx, my2+by+motion_fy, motion_bx, motion_by) - s->qscale; if(dmin2<dmin){ dmin=dmin2; mx= mx2 + bx; my= my2 + by; } } } #else mx*=2; my*=2; #endif if(mx==0 && my==0){ motion_bx= motion_bx0; motion_by= motion_by0; } s->b_direct_mv_table[mot_xy][0]= mx; s->b_direct_mv_table[mot_xy][1]= my; s->b_direct_forw_mv_table[mot_xy][0]= motion_fx + mx; s->b_direct_forw_mv_table[mot_xy][1]= motion_fy + my; s->b_direct_back_mv_table[mot_xy][0]= motion_bx + mx; s->b_direct_back_mv_table[mot_xy][1]= motion_by + my; return dmin; }
false
FFmpeg
0d21a84605bad4e75dacb8196e5859902ed36f01
static inline int direct_search(MpegEncContext * s, int mb_x, int mb_y) { int P[6][2]; const int mot_stride = s->mb_width + 2; const int mot_xy = (mb_y + 1)*mot_stride + mb_x + 1; int dmin, dmin2; int motion_fx, motion_fy, motion_bx, motion_by, motion_bx0, motion_by0; int motion_dx, motion_dy; const int motion_px= s->p_mv_table[mot_xy][0]; const int motion_py= s->p_mv_table[mot_xy][1]; const int time_pp= s->pp_time; const int time_bp= s->bp_time; const int time_pb= time_pp - time_bp; int bx, by; int mx, my, mx2, my2; uint8_t *ref_picture= s->me_scratchpad - (mb_x + 1 + (mb_y + 1)*s->linesize)*16; int16_t (*mv_table)[2]= s->b_direct_mv_table; uint16_t *mv_penalty= s->mv_penalty[s->f_code] + MAX_MV; motion_fx= (motion_px*time_pb)/time_pp; motion_fy= (motion_py*time_pb)/time_pp; motion_bx0= (-motion_px*time_bp)/time_pp; motion_by0= (-motion_py*time_bp)/time_pp; motion_dx= motion_dy=0; dmin2= check_bidir_mv(s, mb_x, mb_y, motion_fx, motion_fy, motion_bx0, motion_by0, motion_fx, motion_fy, motion_bx0, motion_by0) - s->qscale; motion_bx= motion_fx - motion_px; motion_by= motion_fy - motion_py; for(by=-1; by<2; by++){ for(bx=-1; bx<2; bx++){ uint8_t *dest_y = s->me_scratchpad + (by+1)*s->linesize*16 + (bx+1)*16; uint8_t *ptr; int dxy; int src_x, src_y; const int width= s->width; const int height= s->height; dxy = ((motion_fy & 1) << 1) | (motion_fx & 1); src_x = (mb_x + bx) * 16 + (motion_fx >> 1); src_y = (mb_y + by) * 16 + (motion_fy >> 1); src_x = clip(src_x, -16, width); if (src_x == width) dxy &= ~1; src_y = clip(src_y, -16, height); if (src_y == height) dxy &= ~2; ptr = s->last_picture[0] + (src_y * s->linesize) + src_x; put_pixels_tab[dxy](dest_y , ptr , s->linesize, 16); put_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16); dxy = ((motion_by & 1) << 1) | (motion_bx & 1); src_x = (mb_x + bx) * 16 + (motion_bx >> 1); src_y = (mb_y + by) * 16 + (motion_by >> 1); src_x = clip(src_x, -16, width); if (src_x == width) dxy &= ~1; src_y = clip(src_y, -16, height); if (src_y == height) dxy &= ~2; avg_pixels_tab[dxy](dest_y , ptr , s->linesize, 16); avg_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16); } } P[0][0] = mv_table[mot_xy ][0]; P[0][1] = mv_table[mot_xy ][1]; P[1][0] = mv_table[mot_xy - 1][0]; P[1][1] = mv_table[mot_xy - 1][1]; if ((mb_y == 0 || s->first_slice_line || s->first_gob_line)) { P[4][0] = P[1][0]; P[4][1] = P[1][1]; } else { P[2][0] = mv_table[mot_xy - mot_stride ][0]; P[2][1] = mv_table[mot_xy - mot_stride ][1]; P[3][0] = mv_table[mot_xy - mot_stride + 1 ][0]; P[3][1] = mv_table[mot_xy - mot_stride + 1 ][1]; P[4][0]= mid_pred(P[1][0], P[2][0], P[3][0]); P[4][1]= mid_pred(P[1][1], P[2][1], P[3][1]); } dmin = epzs_motion_search(s, &mx, &my, P, 0, 0, -16, -16, 15, 15, ref_picture); if(mx==0 && my==0) dmin=99999999; if(dmin2<dmin){ dmin= dmin2; mx=0; my=0; } #if 1 mx2= mx= mx*2; my2= my= my*2; for(by=-1; by<2; by++){ if(my2+by < -32) continue; for(bx=-1; bx<2; bx++){ if(bx==0 && by==0) continue; if(mx2+bx < -32) continue; dmin2= check_bidir_mv(s, mb_x, mb_y, mx2+bx+motion_fx, my2+by+motion_fy, mx2+bx+motion_bx, my2+by+motion_by, mx2+bx+motion_fx, my2+by+motion_fy, motion_bx, motion_by) - s->qscale; if(dmin2<dmin){ dmin=dmin2; mx= mx2 + bx; my= my2 + by; } } } #else mx*=2; my*=2; #endif if(mx==0 && my==0){ motion_bx= motion_bx0; motion_by= motion_by0; } s->b_direct_mv_table[mot_xy][0]= mx; s->b_direct_mv_table[mot_xy][1]= my; s->b_direct_forw_mv_table[mot_xy][0]= motion_fx + mx; s->b_direct_forw_mv_table[mot_xy][1]= motion_fy + my; s->b_direct_back_mv_table[mot_xy][0]= motion_bx + mx; s->b_direct_back_mv_table[mot_xy][1]= motion_by + my; return dmin; }
{ "code": [], "line_no": [] }
static inline int FUNC_0(MpegEncContext * VAR_0, int VAR_1, int VAR_2) { int VAR_3[6][2]; const int VAR_4 = VAR_0->mb_width + 2; const int VAR_5 = (VAR_2 + 1)*VAR_4 + VAR_1 + 1; int VAR_6, VAR_7; int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13; int VAR_14, VAR_15; const int VAR_16= VAR_0->p_mv_table[VAR_5][0]; const int VAR_17= VAR_0->p_mv_table[VAR_5][1]; const int VAR_18= VAR_0->pp_time; const int VAR_19= VAR_0->bp_time; const int VAR_20= VAR_18 - VAR_19; int VAR_21, VAR_22; int VAR_23, VAR_24, VAR_25, VAR_26; uint8_t *ref_picture= VAR_0->me_scratchpad - (VAR_1 + 1 + (VAR_2 + 1)*VAR_0->linesize)*16; int16_t (*mv_table)[2]= VAR_0->b_direct_mv_table; uint16_t *mv_penalty= VAR_0->mv_penalty[VAR_0->f_code] + MAX_MV; VAR_8= (VAR_16*VAR_20)/VAR_18; VAR_9= (VAR_17*VAR_20)/VAR_18; VAR_12= (-VAR_16*VAR_19)/VAR_18; VAR_13= (-VAR_17*VAR_19)/VAR_18; VAR_14= VAR_15=0; VAR_7= check_bidir_mv(VAR_0, VAR_1, VAR_2, VAR_8, VAR_9, VAR_12, VAR_13, VAR_8, VAR_9, VAR_12, VAR_13) - VAR_0->qscale; VAR_10= VAR_8 - VAR_16; VAR_11= VAR_9 - VAR_17; for(VAR_22=-1; VAR_22<2; VAR_22++){ for(VAR_21=-1; VAR_21<2; VAR_21++){ uint8_t *dest_y = VAR_0->me_scratchpad + (VAR_22+1)*VAR_0->linesize*16 + (VAR_21+1)*16; uint8_t *ptr; int VAR_27; int VAR_28, VAR_29; const int VAR_30= VAR_0->VAR_30; const int VAR_31= VAR_0->VAR_31; VAR_27 = ((VAR_9 & 1) << 1) | (VAR_8 & 1); VAR_28 = (VAR_1 + VAR_21) * 16 + (VAR_8 >> 1); VAR_29 = (VAR_2 + VAR_22) * 16 + (VAR_9 >> 1); VAR_28 = clip(VAR_28, -16, VAR_30); if (VAR_28 == VAR_30) VAR_27 &= ~1; VAR_29 = clip(VAR_29, -16, VAR_31); if (VAR_29 == VAR_31) VAR_27 &= ~2; ptr = VAR_0->last_picture[0] + (VAR_29 * VAR_0->linesize) + VAR_28; put_pixels_tab[VAR_27](dest_y , ptr , VAR_0->linesize, 16); put_pixels_tab[VAR_27](dest_y + 8, ptr + 8, VAR_0->linesize, 16); VAR_27 = ((VAR_11 & 1) << 1) | (VAR_10 & 1); VAR_28 = (VAR_1 + VAR_21) * 16 + (VAR_10 >> 1); VAR_29 = (VAR_2 + VAR_22) * 16 + (VAR_11 >> 1); VAR_28 = clip(VAR_28, -16, VAR_30); if (VAR_28 == VAR_30) VAR_27 &= ~1; VAR_29 = clip(VAR_29, -16, VAR_31); if (VAR_29 == VAR_31) VAR_27 &= ~2; avg_pixels_tab[VAR_27](dest_y , ptr , VAR_0->linesize, 16); avg_pixels_tab[VAR_27](dest_y + 8, ptr + 8, VAR_0->linesize, 16); } } VAR_3[0][0] = mv_table[VAR_5 ][0]; VAR_3[0][1] = mv_table[VAR_5 ][1]; VAR_3[1][0] = mv_table[VAR_5 - 1][0]; VAR_3[1][1] = mv_table[VAR_5 - 1][1]; if ((VAR_2 == 0 || VAR_0->first_slice_line || VAR_0->first_gob_line)) { VAR_3[4][0] = VAR_3[1][0]; VAR_3[4][1] = VAR_3[1][1]; } else { VAR_3[2][0] = mv_table[VAR_5 - VAR_4 ][0]; VAR_3[2][1] = mv_table[VAR_5 - VAR_4 ][1]; VAR_3[3][0] = mv_table[VAR_5 - VAR_4 + 1 ][0]; VAR_3[3][1] = mv_table[VAR_5 - VAR_4 + 1 ][1]; VAR_3[4][0]= mid_pred(VAR_3[1][0], VAR_3[2][0], VAR_3[3][0]); VAR_3[4][1]= mid_pred(VAR_3[1][1], VAR_3[2][1], VAR_3[3][1]); } VAR_6 = epzs_motion_search(VAR_0, &VAR_23, &VAR_24, VAR_3, 0, 0, -16, -16, 15, 15, ref_picture); if(VAR_23==0 && VAR_24==0) VAR_6=99999999; if(VAR_7<VAR_6){ VAR_6= VAR_7; VAR_23=0; VAR_24=0; } #if 1 VAR_25= VAR_23= VAR_23*2; VAR_26= VAR_24= VAR_24*2; for(VAR_22=-1; VAR_22<2; VAR_22++){ if(VAR_26+VAR_22 < -32) continue; for(VAR_21=-1; VAR_21<2; VAR_21++){ if(VAR_21==0 && VAR_22==0) continue; if(VAR_25+VAR_21 < -32) continue; VAR_7= check_bidir_mv(VAR_0, VAR_1, VAR_2, VAR_25+VAR_21+VAR_8, VAR_26+VAR_22+VAR_9, VAR_25+VAR_21+VAR_10, VAR_26+VAR_22+VAR_11, VAR_25+VAR_21+VAR_8, VAR_26+VAR_22+VAR_9, VAR_10, VAR_11) - VAR_0->qscale; if(VAR_7<VAR_6){ VAR_6=VAR_7; VAR_23= VAR_25 + VAR_21; VAR_24= VAR_26 + VAR_22; } } } #else VAR_23*=2; VAR_24*=2; #endif if(VAR_23==0 && VAR_24==0){ VAR_10= VAR_12; VAR_11= VAR_13; } VAR_0->b_direct_mv_table[VAR_5][0]= VAR_23; VAR_0->b_direct_mv_table[VAR_5][1]= VAR_24; VAR_0->b_direct_forw_mv_table[VAR_5][0]= VAR_8 + VAR_23; VAR_0->b_direct_forw_mv_table[VAR_5][1]= VAR_9 + VAR_24; VAR_0->b_direct_back_mv_table[VAR_5][0]= VAR_10 + VAR_23; VAR_0->b_direct_back_mv_table[VAR_5][1]= VAR_11 + VAR_24; return VAR_6; }
[ "static inline int FUNC_0(MpegEncContext * VAR_0,\nint VAR_1, int VAR_2)\n{", "int VAR_3[6][2];", "const int VAR_4 = VAR_0->mb_width + 2;", "const int VAR_5 = (VAR_2 + 1)*VAR_4 + VAR_1 + 1;", "int VAR_6, VAR_7;", "int VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;", "int VAR_14, VAR_15;", "const int VAR_16= VAR_0->p_mv_table[VAR_5][0];", "const int VAR_17= VAR_0->p_mv_table[VAR_5][1];", "const int VAR_18= VAR_0->pp_time;", "const int VAR_19= VAR_0->bp_time;", "const int VAR_20= VAR_18 - VAR_19;", "int VAR_21, VAR_22;", "int VAR_23, VAR_24, VAR_25, VAR_26;", "uint8_t *ref_picture= VAR_0->me_scratchpad - (VAR_1 + 1 + (VAR_2 + 1)*VAR_0->linesize)*16;", "int16_t (*mv_table)[2]= VAR_0->b_direct_mv_table;", "uint16_t *mv_penalty= VAR_0->mv_penalty[VAR_0->f_code] + MAX_MV;", "VAR_8= (VAR_16*VAR_20)/VAR_18;", "VAR_9= (VAR_17*VAR_20)/VAR_18;", "VAR_12= (-VAR_16*VAR_19)/VAR_18;", "VAR_13= (-VAR_17*VAR_19)/VAR_18;", "VAR_14= VAR_15=0;", "VAR_7= check_bidir_mv(VAR_0, VAR_1, VAR_2,\nVAR_8, VAR_9,\nVAR_12, VAR_13,\nVAR_8, VAR_9,\nVAR_12, VAR_13) - VAR_0->qscale;", "VAR_10= VAR_8 - VAR_16;", "VAR_11= VAR_9 - VAR_17;", "for(VAR_22=-1; VAR_22<2; VAR_22++){", "for(VAR_21=-1; VAR_21<2; VAR_21++){", "uint8_t *dest_y = VAR_0->me_scratchpad + (VAR_22+1)*VAR_0->linesize*16 + (VAR_21+1)*16;", "uint8_t *ptr;", "int VAR_27;", "int VAR_28, VAR_29;", "const int VAR_30= VAR_0->VAR_30;", "const int VAR_31= VAR_0->VAR_31;", "VAR_27 = ((VAR_9 & 1) << 1) | (VAR_8 & 1);", "VAR_28 = (VAR_1 + VAR_21) * 16 + (VAR_8 >> 1);", "VAR_29 = (VAR_2 + VAR_22) * 16 + (VAR_9 >> 1);", "VAR_28 = clip(VAR_28, -16, VAR_30);", "if (VAR_28 == VAR_30) VAR_27 &= ~1;", "VAR_29 = clip(VAR_29, -16, VAR_31);", "if (VAR_29 == VAR_31) VAR_27 &= ~2;", "ptr = VAR_0->last_picture[0] + (VAR_29 * VAR_0->linesize) + VAR_28;", "put_pixels_tab[VAR_27](dest_y , ptr , VAR_0->linesize, 16);", "put_pixels_tab[VAR_27](dest_y + 8, ptr + 8, VAR_0->linesize, 16);", "VAR_27 = ((VAR_11 & 1) << 1) | (VAR_10 & 1);", "VAR_28 = (VAR_1 + VAR_21) * 16 + (VAR_10 >> 1);", "VAR_29 = (VAR_2 + VAR_22) * 16 + (VAR_11 >> 1);", "VAR_28 = clip(VAR_28, -16, VAR_30);", "if (VAR_28 == VAR_30) VAR_27 &= ~1;", "VAR_29 = clip(VAR_29, -16, VAR_31);", "if (VAR_29 == VAR_31) VAR_27 &= ~2;", "avg_pixels_tab[VAR_27](dest_y , ptr , VAR_0->linesize, 16);", "avg_pixels_tab[VAR_27](dest_y + 8, ptr + 8, VAR_0->linesize, 16);", "}", "}", "VAR_3[0][0] = mv_table[VAR_5 ][0];", "VAR_3[0][1] = mv_table[VAR_5 ][1];", "VAR_3[1][0] = mv_table[VAR_5 - 1][0];", "VAR_3[1][1] = mv_table[VAR_5 - 1][1];", "if ((VAR_2 == 0 || VAR_0->first_slice_line || VAR_0->first_gob_line)) {", "VAR_3[4][0] = VAR_3[1][0];", "VAR_3[4][1] = VAR_3[1][1];", "} else {", "VAR_3[2][0] = mv_table[VAR_5 - VAR_4 ][0];", "VAR_3[2][1] = mv_table[VAR_5 - VAR_4 ][1];", "VAR_3[3][0] = mv_table[VAR_5 - VAR_4 + 1 ][0];", "VAR_3[3][1] = mv_table[VAR_5 - VAR_4 + 1 ][1];", "VAR_3[4][0]= mid_pred(VAR_3[1][0], VAR_3[2][0], VAR_3[3][0]);", "VAR_3[4][1]= mid_pred(VAR_3[1][1], VAR_3[2][1], VAR_3[3][1]);", "}", "VAR_6 = epzs_motion_search(VAR_0, &VAR_23, &VAR_24, VAR_3, 0, 0, -16, -16, 15, 15, ref_picture);", "if(VAR_23==0 && VAR_24==0) VAR_6=99999999;", "if(VAR_7<VAR_6){", "VAR_6= VAR_7;", "VAR_23=0;", "VAR_24=0;", "}", "#if 1\nVAR_25= VAR_23= VAR_23*2;", "VAR_26= VAR_24= VAR_24*2;", "for(VAR_22=-1; VAR_22<2; VAR_22++){", "if(VAR_26+VAR_22 < -32) continue;", "for(VAR_21=-1; VAR_21<2; VAR_21++){", "if(VAR_21==0 && VAR_22==0) continue;", "if(VAR_25+VAR_21 < -32) continue;", "VAR_7= check_bidir_mv(VAR_0, VAR_1, VAR_2,\nVAR_25+VAR_21+VAR_8, VAR_26+VAR_22+VAR_9,\nVAR_25+VAR_21+VAR_10, VAR_26+VAR_22+VAR_11,\nVAR_25+VAR_21+VAR_8, VAR_26+VAR_22+VAR_9,\nVAR_10, VAR_11) - VAR_0->qscale;", "if(VAR_7<VAR_6){", "VAR_6=VAR_7;", "VAR_23= VAR_25 + VAR_21;", "VAR_24= VAR_26 + VAR_22;", "}", "}", "}", "#else\nVAR_23*=2; VAR_24*=2;", "#endif\nif(VAR_23==0 && VAR_24==0){", "VAR_10= VAR_12;", "VAR_11= VAR_13;", "}", "VAR_0->b_direct_mv_table[VAR_5][0]= VAR_23;", "VAR_0->b_direct_mv_table[VAR_5][1]= VAR_24;", "VAR_0->b_direct_forw_mv_table[VAR_5][0]= VAR_8 + VAR_23;", "VAR_0->b_direct_forw_mv_table[VAR_5][1]= VAR_9 + VAR_24;", "VAR_0->b_direct_back_mv_table[VAR_5][0]= VAR_10 + VAR_23;", "VAR_0->b_direct_back_mv_table[VAR_5][1]= VAR_11 + VAR_24;", "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, 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 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 55, 57, 59, 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203, 205, 207, 209, 211 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229, 231 ], [ 233, 235 ], [ 237 ], [ 239 ], [ 241 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ] ]
20,190
static int vnc_display_get_address(const char *addrstr, bool websocket, bool reverse, int displaynum, int to, bool has_ipv4, bool has_ipv6, bool ipv4, bool ipv6, SocketAddress **retaddr, Error **errp) { int ret = -1; SocketAddress *addr = NULL; addr = g_new0(SocketAddress, 1); if (strncmp(addrstr, "unix:", 5) == 0) { addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); addr->u.q_unix.data->path = g_strdup(addrstr + 5); if (websocket) { error_setg(errp, "UNIX sockets not supported with websock"); goto cleanup; } if (to) { error_setg(errp, "Port range not support with UNIX socket"); goto cleanup; } ret = 0; } else { const char *port; size_t hostlen; unsigned long long baseport = 0; InetSocketAddress *inet; port = strrchr(addrstr, ':'); if (!port) { if (websocket) { hostlen = 0; port = addrstr; } else { error_setg(errp, "no vnc port specified"); goto cleanup; } } else { hostlen = port - addrstr; port++; if (*port == '\0') { error_setg(errp, "vnc port cannot be empty"); goto cleanup; } } addr->type = SOCKET_ADDRESS_KIND_INET; inet = addr->u.inet.data = g_new0(InetSocketAddress, 1); if (addrstr[0] == '[' && addrstr[hostlen - 1] == ']') { inet->host = g_strndup(addrstr + 1, hostlen - 2); } else { inet->host = g_strndup(addrstr, hostlen); } /* plain VNC port is just an offset, for websocket * port is absolute */ if (websocket) { if (g_str_equal(addrstr, "") || g_str_equal(addrstr, "on")) { if (displaynum == -1) { error_setg(errp, "explicit websocket port is required"); goto cleanup; } inet->port = g_strdup_printf( "%d", displaynum + 5700); if (to) { inet->has_to = true; inet->to = to + 5700; } } else { inet->port = g_strdup(port); } } else { int offset = reverse ? 0 : 5900; if (parse_uint_full(port, &baseport, 10) < 0) { error_setg(errp, "can't convert to a number: %s", port); goto cleanup; } if (baseport > 65535 || baseport + offset > 65535) { error_setg(errp, "port %s out of range", port); goto cleanup; } inet->port = g_strdup_printf( "%d", (int)baseport + offset); if (to) { inet->has_to = true; inet->to = to + offset; } } inet->ipv4 = ipv4; inet->has_ipv4 = has_ipv4; inet->ipv6 = ipv6; inet->has_ipv6 = has_ipv6; ret = baseport; } *retaddr = addr; cleanup: if (ret < 0) { qapi_free_SocketAddress(addr); } return ret; }
false
qemu
dfd100f242370886bb6732f70f1f7cbd8eb9fedc
static int vnc_display_get_address(const char *addrstr, bool websocket, bool reverse, int displaynum, int to, bool has_ipv4, bool has_ipv6, bool ipv4, bool ipv6, SocketAddress **retaddr, Error **errp) { int ret = -1; SocketAddress *addr = NULL; addr = g_new0(SocketAddress, 1); if (strncmp(addrstr, "unix:", 5) == 0) { addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); addr->u.q_unix.data->path = g_strdup(addrstr + 5); if (websocket) { error_setg(errp, "UNIX sockets not supported with websock"); goto cleanup; } if (to) { error_setg(errp, "Port range not support with UNIX socket"); goto cleanup; } ret = 0; } else { const char *port; size_t hostlen; unsigned long long baseport = 0; InetSocketAddress *inet; port = strrchr(addrstr, ':'); if (!port) { if (websocket) { hostlen = 0; port = addrstr; } else { error_setg(errp, "no vnc port specified"); goto cleanup; } } else { hostlen = port - addrstr; port++; if (*port == '\0') { error_setg(errp, "vnc port cannot be empty"); goto cleanup; } } addr->type = SOCKET_ADDRESS_KIND_INET; inet = addr->u.inet.data = g_new0(InetSocketAddress, 1); if (addrstr[0] == '[' && addrstr[hostlen - 1] == ']') { inet->host = g_strndup(addrstr + 1, hostlen - 2); } else { inet->host = g_strndup(addrstr, hostlen); } if (websocket) { if (g_str_equal(addrstr, "") || g_str_equal(addrstr, "on")) { if (displaynum == -1) { error_setg(errp, "explicit websocket port is required"); goto cleanup; } inet->port = g_strdup_printf( "%d", displaynum + 5700); if (to) { inet->has_to = true; inet->to = to + 5700; } } else { inet->port = g_strdup(port); } } else { int offset = reverse ? 0 : 5900; if (parse_uint_full(port, &baseport, 10) < 0) { error_setg(errp, "can't convert to a number: %s", port); goto cleanup; } if (baseport > 65535 || baseport + offset > 65535) { error_setg(errp, "port %s out of range", port); goto cleanup; } inet->port = g_strdup_printf( "%d", (int)baseport + offset); if (to) { inet->has_to = true; inet->to = to + offset; } } inet->ipv4 = ipv4; inet->has_ipv4 = has_ipv4; inet->ipv6 = ipv6; inet->has_ipv6 = has_ipv6; ret = baseport; } *retaddr = addr; cleanup: if (ret < 0) { qapi_free_SocketAddress(addr); } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(const char *VAR_0, bool VAR_1, bool VAR_2, int VAR_3, int VAR_4, bool VAR_5, bool VAR_6, bool VAR_7, bool VAR_8, SocketAddress **VAR_9, Error **VAR_10) { int VAR_11 = -1; SocketAddress *addr = NULL; addr = g_new0(SocketAddress, 1); if (strncmp(VAR_0, "unix:", 5) == 0) { addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); addr->u.q_unix.data->path = g_strdup(VAR_0 + 5); if (VAR_1) { error_setg(VAR_10, "UNIX sockets not supported with websock"); goto cleanup; } if (VAR_4) { error_setg(VAR_10, "Port range not support with UNIX socket"); goto cleanup; } VAR_11 = 0; } else { const char *VAR_12; size_t hostlen; unsigned long long VAR_13 = 0; InetSocketAddress *inet; VAR_12 = strrchr(VAR_0, ':'); if (!VAR_12) { if (VAR_1) { hostlen = 0; VAR_12 = VAR_0; } else { error_setg(VAR_10, "no vnc VAR_12 specified"); goto cleanup; } } else { hostlen = VAR_12 - VAR_0; VAR_12++; if (*VAR_12 == '\0') { error_setg(VAR_10, "vnc VAR_12 cannot be empty"); goto cleanup; } } addr->type = SOCKET_ADDRESS_KIND_INET; inet = addr->u.inet.data = g_new0(InetSocketAddress, 1); if (VAR_0[0] == '[' && VAR_0[hostlen - 1] == ']') { inet->host = g_strndup(VAR_0 + 1, hostlen - 2); } else { inet->host = g_strndup(VAR_0, hostlen); } if (VAR_1) { if (g_str_equal(VAR_0, "") || g_str_equal(VAR_0, "on")) { if (VAR_3 == -1) { error_setg(VAR_10, "explicit VAR_1 VAR_12 is required"); goto cleanup; } inet->VAR_12 = g_strdup_printf( "%d", VAR_3 + 5700); if (VAR_4) { inet->has_to = true; inet->VAR_4 = VAR_4 + 5700; } } else { inet->VAR_12 = g_strdup(VAR_12); } } else { int VAR_14 = VAR_2 ? 0 : 5900; if (parse_uint_full(VAR_12, &VAR_13, 10) < 0) { error_setg(VAR_10, "can't convert VAR_4 a number: %s", VAR_12); goto cleanup; } if (VAR_13 > 65535 || VAR_13 + VAR_14 > 65535) { error_setg(VAR_10, "VAR_12 %s out of range", VAR_12); goto cleanup; } inet->VAR_12 = g_strdup_printf( "%d", (int)VAR_13 + VAR_14); if (VAR_4) { inet->has_to = true; inet->VAR_4 = VAR_4 + VAR_14; } } inet->VAR_7 = VAR_7; inet->VAR_5 = VAR_5; inet->VAR_8 = VAR_8; inet->VAR_6 = VAR_6; VAR_11 = VAR_13; } *VAR_9 = addr; cleanup: if (VAR_11 < 0) { qapi_free_SocketAddress(addr); } return VAR_11; }
[ "static int FUNC_0(const char *VAR_0,\nbool VAR_1,\nbool VAR_2,\nint VAR_3,\nint VAR_4,\nbool VAR_5,\nbool VAR_6,\nbool VAR_7,\nbool VAR_8,\nSocketAddress **VAR_9,\nError **VAR_10)\n{", "int VAR_11 = -1;", "SocketAddress *addr = NULL;", "addr = g_new0(SocketAddress, 1);", "if (strncmp(VAR_0, \"unix:\", 5) == 0) {", "addr->type = SOCKET_ADDRESS_KIND_UNIX;", "addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);", "addr->u.q_unix.data->path = g_strdup(VAR_0 + 5);", "if (VAR_1) {", "error_setg(VAR_10, \"UNIX sockets not supported with websock\");", "goto cleanup;", "}", "if (VAR_4) {", "error_setg(VAR_10, \"Port range not support with UNIX socket\");", "goto cleanup;", "}", "VAR_11 = 0;", "} else {", "const char *VAR_12;", "size_t hostlen;", "unsigned long long VAR_13 = 0;", "InetSocketAddress *inet;", "VAR_12 = strrchr(VAR_0, ':');", "if (!VAR_12) {", "if (VAR_1) {", "hostlen = 0;", "VAR_12 = VAR_0;", "} else {", "error_setg(VAR_10, \"no vnc VAR_12 specified\");", "goto cleanup;", "}", "} else {", "hostlen = VAR_12 - VAR_0;", "VAR_12++;", "if (*VAR_12 == '\\0') {", "error_setg(VAR_10, \"vnc VAR_12 cannot be empty\");", "goto cleanup;", "}", "}", "addr->type = SOCKET_ADDRESS_KIND_INET;", "inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);", "if (VAR_0[0] == '[' && VAR_0[hostlen - 1] == ']') {", "inet->host = g_strndup(VAR_0 + 1, hostlen - 2);", "} else {", "inet->host = g_strndup(VAR_0, hostlen);", "}", "if (VAR_1) {", "if (g_str_equal(VAR_0, \"\") ||\ng_str_equal(VAR_0, \"on\")) {", "if (VAR_3 == -1) {", "error_setg(VAR_10, \"explicit VAR_1 VAR_12 is required\");", "goto cleanup;", "}", "inet->VAR_12 = g_strdup_printf(\n\"%d\", VAR_3 + 5700);", "if (VAR_4) {", "inet->has_to = true;", "inet->VAR_4 = VAR_4 + 5700;", "}", "} else {", "inet->VAR_12 = g_strdup(VAR_12);", "}", "} else {", "int VAR_14 = VAR_2 ? 0 : 5900;", "if (parse_uint_full(VAR_12, &VAR_13, 10) < 0) {", "error_setg(VAR_10, \"can't convert VAR_4 a number: %s\", VAR_12);", "goto cleanup;", "}", "if (VAR_13 > 65535 ||\nVAR_13 + VAR_14 > 65535) {", "error_setg(VAR_10, \"VAR_12 %s out of range\", VAR_12);", "goto cleanup;", "}", "inet->VAR_12 = g_strdup_printf(\n\"%d\", (int)VAR_13 + VAR_14);", "if (VAR_4) {", "inet->has_to = true;", "inet->VAR_4 = VAR_4 + VAR_14;", "}", "}", "inet->VAR_7 = VAR_7;", "inet->VAR_5 = VAR_5;", "inet->VAR_8 = VAR_8;", "inet->VAR_6 = VAR_6;", "VAR_11 = VAR_13;", "}", "*VAR_9 = addr;", "cleanup:\nif (VAR_11 < 0) {", "qapi_free_SocketAddress(addr);", "}", "return VAR_11;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 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 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 213 ], [ 215 ], [ 219 ], [ 223, 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ] ]
20,191
static void sdhci_do_data_transfer(void *opaque) { SDHCIState *s = (SDHCIState *)opaque; SDHCI_GET_CLASS(s)->data_transfer(s); }
false
qemu
d368ba4376b2c1c24175c74b3733b8fe64dbe8a6
static void sdhci_do_data_transfer(void *opaque) { SDHCIState *s = (SDHCIState *)opaque; SDHCI_GET_CLASS(s)->data_transfer(s); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { SDHCIState *s = (SDHCIState *)VAR_0; SDHCI_GET_CLASS(s)->data_transfer(s); }
[ "static void FUNC_0(void *VAR_0)\n{", "SDHCIState *s = (SDHCIState *)VAR_0;", "SDHCI_GET_CLASS(s)->data_transfer(s);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ] ]
20,192
static void kbd_send_chars(void *opaque) { TextConsole *s = opaque; int len; uint8_t buf[16]; len = qemu_chr_can_read(s->chr); if (len > s->out_fifo.count) len = s->out_fifo.count; if (len > 0) { if (len > sizeof(buf)) len = sizeof(buf); qemu_fifo_read(&s->out_fifo, buf, len); qemu_chr_read(s->chr, buf, len); } /* characters are pending: we send them a bit later (XXX: horrible, should change char device API) */ if (s->out_fifo.count > 0) { qemu_mod_timer(s->kbd_timer, qemu_get_clock(rt_clock) + 1); } }
false
qemu
7bd427d801e1e3293a634d3c83beadaa90ffb911
static void kbd_send_chars(void *opaque) { TextConsole *s = opaque; int len; uint8_t buf[16]; len = qemu_chr_can_read(s->chr); if (len > s->out_fifo.count) len = s->out_fifo.count; if (len > 0) { if (len > sizeof(buf)) len = sizeof(buf); qemu_fifo_read(&s->out_fifo, buf, len); qemu_chr_read(s->chr, buf, len); } if (s->out_fifo.count > 0) { qemu_mod_timer(s->kbd_timer, qemu_get_clock(rt_clock) + 1); } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { TextConsole *s = VAR_0; int VAR_1; uint8_t buf[16]; VAR_1 = qemu_chr_can_read(s->chr); if (VAR_1 > s->out_fifo.count) VAR_1 = s->out_fifo.count; if (VAR_1 > 0) { if (VAR_1 > sizeof(buf)) VAR_1 = sizeof(buf); qemu_fifo_read(&s->out_fifo, buf, VAR_1); qemu_chr_read(s->chr, buf, VAR_1); } if (s->out_fifo.count > 0) { qemu_mod_timer(s->kbd_timer, qemu_get_clock(rt_clock) + 1); } }
[ "static void FUNC_0(void *VAR_0)\n{", "TextConsole *s = VAR_0;", "int VAR_1;", "uint8_t buf[16];", "VAR_1 = qemu_chr_can_read(s->chr);", "if (VAR_1 > s->out_fifo.count)\nVAR_1 = s->out_fifo.count;", "if (VAR_1 > 0) {", "if (VAR_1 > sizeof(buf))\nVAR_1 = sizeof(buf);", "qemu_fifo_read(&s->out_fifo, buf, VAR_1);", "qemu_chr_read(s->chr, buf, VAR_1);", "}", "if (s->out_fifo.count > 0) {", "qemu_mod_timer(s->kbd_timer, qemu_get_clock(rt_clock) + 1);", "}", "}" ]
[ 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 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
20,193
void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap, uint64_t start, uint64_t count, bool finish) { hbitmap_deserialize_ones(bitmap->bitmap, start, count, finish); }
false
qemu
86f6ae67e157362f3b141649874213ce01dcc622
void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap, uint64_t start, uint64_t count, bool finish) { hbitmap_deserialize_ones(bitmap->bitmap, start, count, finish); }
{ "code": [], "line_no": [] }
void FUNC_0(BdrvDirtyBitmap *VAR_0, uint64_t VAR_1, uint64_t VAR_2, bool VAR_3) { hbitmap_deserialize_ones(VAR_0->VAR_0, VAR_1, VAR_2, VAR_3); }
[ "void FUNC_0(BdrvDirtyBitmap *VAR_0,\nuint64_t VAR_1, uint64_t VAR_2,\nbool VAR_3)\n{", "hbitmap_deserialize_ones(VAR_0->VAR_0, VAR_1, VAR_2, VAR_3);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ] ]
20,194
void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) { struct mbuf *m; int proto; if (pkt_len < ETH_HLEN) return; proto = ntohs(*(uint16_t *)(pkt + 12)); switch(proto) { case ETH_P_ARP: arp_input(slirp, pkt, pkt_len); break; case ETH_P_IP: m = m_get(slirp); if (!m) return; /* Note: we add to align the IP header */ if (M_FREEROOM(m) < pkt_len + 2) { m_inc(m, pkt_len + 2); } m->m_len = pkt_len + 2; memcpy(m->m_data + 2, pkt, pkt_len); m->m_data += 2 + ETH_HLEN; m->m_len -= 2 + ETH_HLEN; ip_input(m); break; default: break; } }
false
qemu
0d6ff71ae3c7ac3a446d295ef71884a05093b37c
void slirp_input(Slirp *slirp, const uint8_t *pkt, int pkt_len) { struct mbuf *m; int proto; if (pkt_len < ETH_HLEN) return; proto = ntohs(*(uint16_t *)(pkt + 12)); switch(proto) { case ETH_P_ARP: arp_input(slirp, pkt, pkt_len); break; case ETH_P_IP: m = m_get(slirp); if (!m) return; if (M_FREEROOM(m) < pkt_len + 2) { m_inc(m, pkt_len + 2); } m->m_len = pkt_len + 2; memcpy(m->m_data + 2, pkt, pkt_len); m->m_data += 2 + ETH_HLEN; m->m_len -= 2 + ETH_HLEN; ip_input(m); break; default: break; } }
{ "code": [], "line_no": [] }
void FUNC_0(Slirp *VAR_0, const uint8_t *VAR_1, int VAR_2) { struct mbuf *VAR_3; int VAR_4; if (VAR_2 < ETH_HLEN) return; VAR_4 = ntohs(*(uint16_t *)(VAR_1 + 12)); switch(VAR_4) { case ETH_P_ARP: arp_input(VAR_0, VAR_1, VAR_2); break; case ETH_P_IP: VAR_3 = m_get(VAR_0); if (!VAR_3) return; if (M_FREEROOM(VAR_3) < VAR_2 + 2) { m_inc(VAR_3, VAR_2 + 2); } VAR_3->m_len = VAR_2 + 2; memcpy(VAR_3->m_data + 2, VAR_1, VAR_2); VAR_3->m_data += 2 + ETH_HLEN; VAR_3->m_len -= 2 + ETH_HLEN; ip_input(VAR_3); break; default: break; } }
[ "void FUNC_0(Slirp *VAR_0, const uint8_t *VAR_1, int VAR_2)\n{", "struct mbuf *VAR_3;", "int VAR_4;", "if (VAR_2 < ETH_HLEN)\nreturn;", "VAR_4 = ntohs(*(uint16_t *)(VAR_1 + 12));", "switch(VAR_4) {", "case ETH_P_ARP:\narp_input(VAR_0, VAR_1, VAR_2);", "break;", "case ETH_P_IP:\nVAR_3 = m_get(VAR_0);", "if (!VAR_3)\nreturn;", "if (M_FREEROOM(VAR_3) < VAR_2 + 2) {", "m_inc(VAR_3, VAR_2 + 2);", "}", "VAR_3->m_len = VAR_2 + 2;", "memcpy(VAR_3->m_data + 2, VAR_1, VAR_2);", "VAR_3->m_data += 2 + ETH_HLEN;", "VAR_3->m_len -= 2 + ETH_HLEN;", "ip_input(VAR_3);", "break;", "default:\nbreak;", "}", "}" ]
[ 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 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27, 29 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ] ]
20,195
struct omap_intr_handler_s *omap_inth_init(target_phys_addr_t base, unsigned long size, unsigned char nbanks, qemu_irq **pins, qemu_irq parent_irq, qemu_irq parent_fiq, omap_clk clk) { struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) g_malloc0(sizeof(struct omap_intr_handler_s) + sizeof(struct omap_intr_handler_bank_s) * nbanks); s->parent_intr[0] = parent_irq; s->parent_intr[1] = parent_fiq; s->nbanks = nbanks; s->pins = qemu_allocate_irqs(omap_set_intr, s, nbanks * 32); if (pins) *pins = s->pins; memory_region_init_io(&s->mmio, &omap_inth_mem_ops, s, "omap-intc", size); memory_region_add_subregion(get_system_memory(), base, &s->mmio); omap_inth_reset(s); return s; }
false
qemu
0919ac787641db11024912651f3bc5764d4f1286
struct omap_intr_handler_s *omap_inth_init(target_phys_addr_t base, unsigned long size, unsigned char nbanks, qemu_irq **pins, qemu_irq parent_irq, qemu_irq parent_fiq, omap_clk clk) { struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) g_malloc0(sizeof(struct omap_intr_handler_s) + sizeof(struct omap_intr_handler_bank_s) * nbanks); s->parent_intr[0] = parent_irq; s->parent_intr[1] = parent_fiq; s->nbanks = nbanks; s->pins = qemu_allocate_irqs(omap_set_intr, s, nbanks * 32); if (pins) *pins = s->pins; memory_region_init_io(&s->mmio, &omap_inth_mem_ops, s, "omap-intc", size); memory_region_add_subregion(get_system_memory(), base, &s->mmio); omap_inth_reset(s); return s; }
{ "code": [], "line_no": [] }
struct omap_intr_handler_s *FUNC_0(target_phys_addr_t VAR_0, unsigned long VAR_1, unsigned char VAR_2, qemu_irq **VAR_3, qemu_irq VAR_4, qemu_irq VAR_5, omap_clk VAR_6) { struct omap_intr_handler_s *VAR_7 = (struct omap_intr_handler_s *) g_malloc0(sizeof(struct omap_intr_handler_s) + sizeof(struct omap_intr_handler_bank_s) * VAR_2); VAR_7->parent_intr[0] = VAR_4; VAR_7->parent_intr[1] = VAR_5; VAR_7->VAR_2 = VAR_2; VAR_7->VAR_3 = qemu_allocate_irqs(omap_set_intr, VAR_7, VAR_2 * 32); if (VAR_3) *VAR_3 = VAR_7->VAR_3; memory_region_init_io(&VAR_7->mmio, &omap_inth_mem_ops, VAR_7, "omap-intc", VAR_1); memory_region_add_subregion(get_system_memory(), VAR_0, &VAR_7->mmio); omap_inth_reset(VAR_7); return VAR_7; }
[ "struct omap_intr_handler_s *FUNC_0(target_phys_addr_t VAR_0,\nunsigned long VAR_1, unsigned char VAR_2, qemu_irq **VAR_3,\nqemu_irq VAR_4, qemu_irq VAR_5, omap_clk VAR_6)\n{", "struct omap_intr_handler_s *VAR_7 = (struct omap_intr_handler_s *)\ng_malloc0(sizeof(struct omap_intr_handler_s) +\nsizeof(struct omap_intr_handler_bank_s) * VAR_2);", "VAR_7->parent_intr[0] = VAR_4;", "VAR_7->parent_intr[1] = VAR_5;", "VAR_7->VAR_2 = VAR_2;", "VAR_7->VAR_3 = qemu_allocate_irqs(omap_set_intr, VAR_7, VAR_2 * 32);", "if (VAR_3)\n*VAR_3 = VAR_7->VAR_3;", "memory_region_init_io(&VAR_7->mmio, &omap_inth_mem_ops, VAR_7, \"omap-intc\", VAR_1);", "memory_region_add_subregion(get_system_memory(), VAR_0, &VAR_7->mmio);", "omap_inth_reset(VAR_7);", "return VAR_7;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9, 11, 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 31 ], [ 33 ], [ 37 ], [ 41 ], [ 43 ] ]
20,196
static bool do_check_io_limits(BlockIOLimit *io_limits) { bool bps_flag; bool iops_flag; assert(io_limits); bps_flag = (io_limits->bps[BLOCK_IO_LIMIT_TOTAL] != 0) && ((io_limits->bps[BLOCK_IO_LIMIT_READ] != 0) || (io_limits->bps[BLOCK_IO_LIMIT_WRITE] != 0)); iops_flag = (io_limits->iops[BLOCK_IO_LIMIT_TOTAL] != 0) && ((io_limits->iops[BLOCK_IO_LIMIT_READ] != 0) || (io_limits->iops[BLOCK_IO_LIMIT_WRITE] != 0)); if (bps_flag || iops_flag) { return false; } return true; }
false
qemu
c546194f260fb3e391193cb8cc33505618077ecb
static bool do_check_io_limits(BlockIOLimit *io_limits) { bool bps_flag; bool iops_flag; assert(io_limits); bps_flag = (io_limits->bps[BLOCK_IO_LIMIT_TOTAL] != 0) && ((io_limits->bps[BLOCK_IO_LIMIT_READ] != 0) || (io_limits->bps[BLOCK_IO_LIMIT_WRITE] != 0)); iops_flag = (io_limits->iops[BLOCK_IO_LIMIT_TOTAL] != 0) && ((io_limits->iops[BLOCK_IO_LIMIT_READ] != 0) || (io_limits->iops[BLOCK_IO_LIMIT_WRITE] != 0)); if (bps_flag || iops_flag) { return false; } return true; }
{ "code": [], "line_no": [] }
static bool FUNC_0(BlockIOLimit *io_limits) { bool bps_flag; bool iops_flag; assert(io_limits); bps_flag = (io_limits->bps[BLOCK_IO_LIMIT_TOTAL] != 0) && ((io_limits->bps[BLOCK_IO_LIMIT_READ] != 0) || (io_limits->bps[BLOCK_IO_LIMIT_WRITE] != 0)); iops_flag = (io_limits->iops[BLOCK_IO_LIMIT_TOTAL] != 0) && ((io_limits->iops[BLOCK_IO_LIMIT_READ] != 0) || (io_limits->iops[BLOCK_IO_LIMIT_WRITE] != 0)); if (bps_flag || iops_flag) { return false; } return true; }
[ "static bool FUNC_0(BlockIOLimit *io_limits)\n{", "bool bps_flag;", "bool iops_flag;", "assert(io_limits);", "bps_flag = (io_limits->bps[BLOCK_IO_LIMIT_TOTAL] != 0)\n&& ((io_limits->bps[BLOCK_IO_LIMIT_READ] != 0)\n|| (io_limits->bps[BLOCK_IO_LIMIT_WRITE] != 0));", "iops_flag = (io_limits->iops[BLOCK_IO_LIMIT_TOTAL] != 0)\n&& ((io_limits->iops[BLOCK_IO_LIMIT_READ] != 0)\n|| (io_limits->iops[BLOCK_IO_LIMIT_WRITE] != 0));", "if (bps_flag || iops_flag) {", "return false;", "}", "return true;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15, 17, 19 ], [ 21, 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ] ]
20,198
static int blkdebug_co_flush(BlockDriverState *bs) { BDRVBlkdebugState *s = bs->opaque; BlkdebugRule *rule = NULL; QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { if (rule->options.inject.offset == -1) { break; } } if (rule && rule->options.inject.error) { return inject_error(bs, rule); } return bdrv_co_flush(bs->file->bs); }
false
qemu
d157ed5f7235f3d2d5596a514ad7507b18e24b88
static int blkdebug_co_flush(BlockDriverState *bs) { BDRVBlkdebugState *s = bs->opaque; BlkdebugRule *rule = NULL; QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { if (rule->options.inject.offset == -1) { break; } } if (rule && rule->options.inject.error) { return inject_error(bs, rule); } return bdrv_co_flush(bs->file->bs); }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0) { BDRVBlkdebugState *s = VAR_0->opaque; BlkdebugRule *rule = NULL; QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { if (rule->options.inject.offset == -1) { break; } } if (rule && rule->options.inject.error) { return inject_error(VAR_0, rule); } return bdrv_co_flush(VAR_0->file->VAR_0); }
[ "static int FUNC_0(BlockDriverState *VAR_0)\n{", "BDRVBlkdebugState *s = VAR_0->opaque;", "BlkdebugRule *rule = NULL;", "QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {", "if (rule->options.inject.offset == -1) {", "break;", "}", "}", "if (rule && rule->options.inject.error) {", "return inject_error(VAR_0, rule);", "}", "return bdrv_co_flush(VAR_0->file->VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ] ]
20,201
static void rtas_quiesce(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { VIOsPAPRBus *bus = spapr->vio_bus; BusChild *kid; VIOsPAPRDevice *dev = NULL; if (nargs != 0) { rtas_st(rets, 0, -3); return; } QTAILQ_FOREACH(kid, &bus->bus.children, sibling) { dev = (VIOsPAPRDevice *)kid->child; spapr_vio_quiesce_one(dev); } rtas_st(rets, 0, 0); }
false
qemu
210b580b106fa798149e28aa13c66b325a43204e
static void rtas_quiesce(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { VIOsPAPRBus *bus = spapr->vio_bus; BusChild *kid; VIOsPAPRDevice *dev = NULL; if (nargs != 0) { rtas_st(rets, 0, -3); return; } QTAILQ_FOREACH(kid, &bus->bus.children, sibling) { dev = (VIOsPAPRDevice *)kid->child; spapr_vio_quiesce_one(dev); } rtas_st(rets, 0, 0); }
{ "code": [], "line_no": [] }
static void FUNC_0(sPAPREnvironment *VAR_0, uint32_t VAR_1, uint32_t VAR_2, target_ulong VAR_3, uint32_t VAR_4, target_ulong VAR_5) { VIOsPAPRBus *bus = VAR_0->vio_bus; BusChild *kid; VIOsPAPRDevice *dev = NULL; if (VAR_2 != 0) { rtas_st(VAR_5, 0, -3); return; } QTAILQ_FOREACH(kid, &bus->bus.children, sibling) { dev = (VIOsPAPRDevice *)kid->child; spapr_vio_quiesce_one(dev); } rtas_st(VAR_5, 0, 0); }
[ "static void FUNC_0(sPAPREnvironment *VAR_0, uint32_t VAR_1,\nuint32_t VAR_2, target_ulong VAR_3,\nuint32_t VAR_4, target_ulong VAR_5)\n{", "VIOsPAPRBus *bus = VAR_0->vio_bus;", "BusChild *kid;", "VIOsPAPRDevice *dev = NULL;", "if (VAR_2 != 0) {", "rtas_st(VAR_5, 0, -3);", "return;", "}", "QTAILQ_FOREACH(kid, &bus->bus.children, sibling) {", "dev = (VIOsPAPRDevice *)kid->child;", "spapr_vio_quiesce_one(dev);", "}", "rtas_st(VAR_5, 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 ], [ 37 ], [ 39 ] ]
20,202
static int kvm_put_xsave(X86CPU *cpu) { CPUX86State *env = &cpu->env; struct kvm_xsave* xsave = env->kvm_xsave_buf; uint16_t cwd, swd, twd; int i, r; if (!kvm_has_xsave()) { return kvm_put_fpu(cpu); } memset(xsave, 0, sizeof(struct kvm_xsave)); twd = 0; swd = env->fpus & ~(7 << 11); swd |= (env->fpstt & 7) << 11; cwd = env->fpuc; for (i = 0; i < 8; ++i) { twd |= (!env->fptags[i]) << i; } xsave->region[XSAVE_FCW_FSW] = (uint32_t)(swd << 16) + cwd; xsave->region[XSAVE_FTW_FOP] = (uint32_t)(env->fpop << 16) + twd; memcpy(&xsave->region[XSAVE_CWD_RIP], &env->fpip, sizeof(env->fpip)); memcpy(&xsave->region[XSAVE_CWD_RDP], &env->fpdp, sizeof(env->fpdp)); memcpy(&xsave->region[XSAVE_ST_SPACE], env->fpregs, sizeof env->fpregs); memcpy(&xsave->region[XSAVE_XMM_SPACE], env->xmm_regs, sizeof env->xmm_regs); xsave->region[XSAVE_MXCSR] = env->mxcsr; *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV] = env->xstate_bv; memcpy(&xsave->region[XSAVE_YMMH_SPACE], env->ymmh_regs, sizeof env->ymmh_regs); memcpy(&xsave->region[XSAVE_BNDREGS], env->bnd_regs, sizeof env->bnd_regs); memcpy(&xsave->region[XSAVE_BNDCSR], &env->bndcs_regs, sizeof(env->bndcs_regs)); memcpy(&xsave->region[XSAVE_OPMASK], env->opmask_regs, sizeof env->opmask_regs); memcpy(&xsave->region[XSAVE_ZMM_Hi256], env->zmmh_regs, sizeof env->zmmh_regs); #ifdef TARGET_X86_64 memcpy(&xsave->region[XSAVE_Hi16_ZMM], env->hi16_zmm_regs, sizeof env->hi16_zmm_regs); #endif r = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_XSAVE, xsave); return r; }
false
qemu
bee818872cd9e8c07be529f75da3e48a68bf7a93
static int kvm_put_xsave(X86CPU *cpu) { CPUX86State *env = &cpu->env; struct kvm_xsave* xsave = env->kvm_xsave_buf; uint16_t cwd, swd, twd; int i, r; if (!kvm_has_xsave()) { return kvm_put_fpu(cpu); } memset(xsave, 0, sizeof(struct kvm_xsave)); twd = 0; swd = env->fpus & ~(7 << 11); swd |= (env->fpstt & 7) << 11; cwd = env->fpuc; for (i = 0; i < 8; ++i) { twd |= (!env->fptags[i]) << i; } xsave->region[XSAVE_FCW_FSW] = (uint32_t)(swd << 16) + cwd; xsave->region[XSAVE_FTW_FOP] = (uint32_t)(env->fpop << 16) + twd; memcpy(&xsave->region[XSAVE_CWD_RIP], &env->fpip, sizeof(env->fpip)); memcpy(&xsave->region[XSAVE_CWD_RDP], &env->fpdp, sizeof(env->fpdp)); memcpy(&xsave->region[XSAVE_ST_SPACE], env->fpregs, sizeof env->fpregs); memcpy(&xsave->region[XSAVE_XMM_SPACE], env->xmm_regs, sizeof env->xmm_regs); xsave->region[XSAVE_MXCSR] = env->mxcsr; *(uint64_t *)&xsave->region[XSAVE_XSTATE_BV] = env->xstate_bv; memcpy(&xsave->region[XSAVE_YMMH_SPACE], env->ymmh_regs, sizeof env->ymmh_regs); memcpy(&xsave->region[XSAVE_BNDREGS], env->bnd_regs, sizeof env->bnd_regs); memcpy(&xsave->region[XSAVE_BNDCSR], &env->bndcs_regs, sizeof(env->bndcs_regs)); memcpy(&xsave->region[XSAVE_OPMASK], env->opmask_regs, sizeof env->opmask_regs); memcpy(&xsave->region[XSAVE_ZMM_Hi256], env->zmmh_regs, sizeof env->zmmh_regs); #ifdef TARGET_X86_64 memcpy(&xsave->region[XSAVE_Hi16_ZMM], env->hi16_zmm_regs, sizeof env->hi16_zmm_regs); #endif r = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_XSAVE, xsave); return r; }
{ "code": [], "line_no": [] }
static int FUNC_0(X86CPU *VAR_0) { CPUX86State *env = &VAR_0->env; struct kvm_xsave* VAR_1 = env->kvm_xsave_buf; uint16_t cwd, swd, twd; int VAR_2, VAR_3; if (!kvm_has_xsave()) { return kvm_put_fpu(VAR_0); } memset(VAR_1, 0, sizeof(struct kvm_xsave)); twd = 0; swd = env->fpus & ~(7 << 11); swd |= (env->fpstt & 7) << 11; cwd = env->fpuc; for (VAR_2 = 0; VAR_2 < 8; ++VAR_2) { twd |= (!env->fptags[VAR_2]) << VAR_2; } VAR_1->region[XSAVE_FCW_FSW] = (uint32_t)(swd << 16) + cwd; VAR_1->region[XSAVE_FTW_FOP] = (uint32_t)(env->fpop << 16) + twd; memcpy(&VAR_1->region[XSAVE_CWD_RIP], &env->fpip, sizeof(env->fpip)); memcpy(&VAR_1->region[XSAVE_CWD_RDP], &env->fpdp, sizeof(env->fpdp)); memcpy(&VAR_1->region[XSAVE_ST_SPACE], env->fpregs, sizeof env->fpregs); memcpy(&VAR_1->region[XSAVE_XMM_SPACE], env->xmm_regs, sizeof env->xmm_regs); VAR_1->region[XSAVE_MXCSR] = env->mxcsr; *(uint64_t *)&VAR_1->region[XSAVE_XSTATE_BV] = env->xstate_bv; memcpy(&VAR_1->region[XSAVE_YMMH_SPACE], env->ymmh_regs, sizeof env->ymmh_regs); memcpy(&VAR_1->region[XSAVE_BNDREGS], env->bnd_regs, sizeof env->bnd_regs); memcpy(&VAR_1->region[XSAVE_BNDCSR], &env->bndcs_regs, sizeof(env->bndcs_regs)); memcpy(&VAR_1->region[XSAVE_OPMASK], env->opmask_regs, sizeof env->opmask_regs); memcpy(&VAR_1->region[XSAVE_ZMM_Hi256], env->zmmh_regs, sizeof env->zmmh_regs); #ifdef TARGET_X86_64 memcpy(&VAR_1->region[XSAVE_Hi16_ZMM], env->hi16_zmm_regs, sizeof env->hi16_zmm_regs); #endif VAR_3 = kvm_vcpu_ioctl(CPU(VAR_0), KVM_SET_XSAVE, VAR_1); return VAR_3; }
[ "static int FUNC_0(X86CPU *VAR_0)\n{", "CPUX86State *env = &VAR_0->env;", "struct kvm_xsave* VAR_1 = env->kvm_xsave_buf;", "uint16_t cwd, swd, twd;", "int VAR_2, VAR_3;", "if (!kvm_has_xsave()) {", "return kvm_put_fpu(VAR_0);", "}", "memset(VAR_1, 0, sizeof(struct kvm_xsave));", "twd = 0;", "swd = env->fpus & ~(7 << 11);", "swd |= (env->fpstt & 7) << 11;", "cwd = env->fpuc;", "for (VAR_2 = 0; VAR_2 < 8; ++VAR_2) {", "twd |= (!env->fptags[VAR_2]) << VAR_2;", "}", "VAR_1->region[XSAVE_FCW_FSW] = (uint32_t)(swd << 16) + cwd;", "VAR_1->region[XSAVE_FTW_FOP] = (uint32_t)(env->fpop << 16) + twd;", "memcpy(&VAR_1->region[XSAVE_CWD_RIP], &env->fpip, sizeof(env->fpip));", "memcpy(&VAR_1->region[XSAVE_CWD_RDP], &env->fpdp, sizeof(env->fpdp));", "memcpy(&VAR_1->region[XSAVE_ST_SPACE], env->fpregs,\nsizeof env->fpregs);", "memcpy(&VAR_1->region[XSAVE_XMM_SPACE], env->xmm_regs,\nsizeof env->xmm_regs);", "VAR_1->region[XSAVE_MXCSR] = env->mxcsr;", "*(uint64_t *)&VAR_1->region[XSAVE_XSTATE_BV] = env->xstate_bv;", "memcpy(&VAR_1->region[XSAVE_YMMH_SPACE], env->ymmh_regs,\nsizeof env->ymmh_regs);", "memcpy(&VAR_1->region[XSAVE_BNDREGS], env->bnd_regs,\nsizeof env->bnd_regs);", "memcpy(&VAR_1->region[XSAVE_BNDCSR], &env->bndcs_regs,\nsizeof(env->bndcs_regs));", "memcpy(&VAR_1->region[XSAVE_OPMASK], env->opmask_regs,\nsizeof env->opmask_regs);", "memcpy(&VAR_1->region[XSAVE_ZMM_Hi256], env->zmmh_regs,\nsizeof env->zmmh_regs);", "#ifdef TARGET_X86_64\nmemcpy(&VAR_1->region[XSAVE_Hi16_ZMM], env->hi16_zmm_regs,\nsizeof env->hi16_zmm_regs);", "#endif\nVAR_3 = kvm_vcpu_ioctl(CPU(VAR_0), KVM_SET_XSAVE, VAR_1);", "return 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 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 ] ]
20,203
static void virtio_blk_set_config(VirtIODevice *vdev, const uint8_t *config) { VirtIOBlock *s = VIRTIO_BLK(vdev); struct virtio_blk_config blkcfg; memcpy(&blkcfg, config, sizeof(blkcfg)); aio_context_acquire(bdrv_get_aio_context(s->bs)); bdrv_set_enable_write_cache(s->bs, blkcfg.wce != 0); aio_context_release(bdrv_get_aio_context(s->bs)); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static void virtio_blk_set_config(VirtIODevice *vdev, const uint8_t *config) { VirtIOBlock *s = VIRTIO_BLK(vdev); struct virtio_blk_config blkcfg; memcpy(&blkcfg, config, sizeof(blkcfg)); aio_context_acquire(bdrv_get_aio_context(s->bs)); bdrv_set_enable_write_cache(s->bs, blkcfg.wce != 0); aio_context_release(bdrv_get_aio_context(s->bs)); }
{ "code": [], "line_no": [] }
static void FUNC_0(VirtIODevice *VAR_0, const uint8_t *VAR_1) { VirtIOBlock *s = VIRTIO_BLK(VAR_0); struct virtio_blk_config VAR_2; memcpy(&VAR_2, VAR_1, sizeof(VAR_2)); aio_context_acquire(bdrv_get_aio_context(s->bs)); bdrv_set_enable_write_cache(s->bs, VAR_2.wce != 0); aio_context_release(bdrv_get_aio_context(s->bs)); }
[ "static void FUNC_0(VirtIODevice *VAR_0, const uint8_t *VAR_1)\n{", "VirtIOBlock *s = VIRTIO_BLK(VAR_0);", "struct virtio_blk_config VAR_2;", "memcpy(&VAR_2, VAR_1, sizeof(VAR_2));", "aio_context_acquire(bdrv_get_aio_context(s->bs));", "bdrv_set_enable_write_cache(s->bs, VAR_2.wce != 0);", "aio_context_release(bdrv_get_aio_context(s->bs));", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
20,205
static int ide_handle_rw_error(IDEState *s, int error, int op) { bool is_read = (op & IDE_RETRY_READ) != 0; BlockErrorAction action = bdrv_get_error_action(s->bs, is_read, error); if (action == BLOCK_ERROR_ACTION_STOP) { s->bus->dma->ops->set_unit(s->bus->dma, s->unit); s->bus->error_status = op; } else if (action == BLOCK_ERROR_ACTION_REPORT) { if (op & IDE_RETRY_DMA) { dma_buf_commit(s); ide_dma_error(s); } else { ide_rw_error(s); } } bdrv_error_action(s->bs, action, is_read, error); return action != BLOCK_ERROR_ACTION_IGNORE; }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static int ide_handle_rw_error(IDEState *s, int error, int op) { bool is_read = (op & IDE_RETRY_READ) != 0; BlockErrorAction action = bdrv_get_error_action(s->bs, is_read, error); if (action == BLOCK_ERROR_ACTION_STOP) { s->bus->dma->ops->set_unit(s->bus->dma, s->unit); s->bus->error_status = op; } else if (action == BLOCK_ERROR_ACTION_REPORT) { if (op & IDE_RETRY_DMA) { dma_buf_commit(s); ide_dma_error(s); } else { ide_rw_error(s); } } bdrv_error_action(s->bs, action, is_read, error); return action != BLOCK_ERROR_ACTION_IGNORE; }
{ "code": [], "line_no": [] }
static int FUNC_0(IDEState *VAR_0, int VAR_1, int VAR_2) { bool is_read = (VAR_2 & IDE_RETRY_READ) != 0; BlockErrorAction action = bdrv_get_error_action(VAR_0->bs, is_read, VAR_1); if (action == BLOCK_ERROR_ACTION_STOP) { VAR_0->bus->dma->ops->set_unit(VAR_0->bus->dma, VAR_0->unit); VAR_0->bus->error_status = VAR_2; } else if (action == BLOCK_ERROR_ACTION_REPORT) { if (VAR_2 & IDE_RETRY_DMA) { dma_buf_commit(VAR_0); ide_dma_error(VAR_0); } else { ide_rw_error(VAR_0); } } bdrv_error_action(VAR_0->bs, action, is_read, VAR_1); return action != BLOCK_ERROR_ACTION_IGNORE; }
[ "static int FUNC_0(IDEState *VAR_0, int VAR_1, int VAR_2)\n{", "bool is_read = (VAR_2 & IDE_RETRY_READ) != 0;", "BlockErrorAction action = bdrv_get_error_action(VAR_0->bs, is_read, VAR_1);", "if (action == BLOCK_ERROR_ACTION_STOP) {", "VAR_0->bus->dma->ops->set_unit(VAR_0->bus->dma, VAR_0->unit);", "VAR_0->bus->error_status = VAR_2;", "} else if (action == BLOCK_ERROR_ACTION_REPORT) {", "if (VAR_2 & IDE_RETRY_DMA) {", "dma_buf_commit(VAR_0);", "ide_dma_error(VAR_0);", "} else {", "ide_rw_error(VAR_0);", "}", "}", "bdrv_error_action(VAR_0->bs, action, is_read, VAR_1);", "return action != BLOCK_ERROR_ACTION_IGNORE;", "}" ]
[ 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 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ] ]
20,206
static int sdl_init_out (HWVoiceOut *hw, audsettings_t *as) { SDLVoiceOut *sdl = (SDLVoiceOut *) hw; SDLAudioState *s = &glob_sdl; SDL_AudioSpec req, obt; int shift; int endianess; int err; audfmt_e effective_fmt; audsettings_t obt_as; shift <<= as->nchannels == 2; req.freq = as->freq; req.format = aud_to_sdlfmt (as->fmt, &shift); req.channels = as->nchannels; req.samples = conf.nb_samples; req.callback = sdl_callback; req.userdata = sdl; if (sdl_open (&req, &obt)) { return -1; } err = sdl_to_audfmt (obt.format, &effective_fmt, &endianess); if (err) { sdl_close (s); return -1; } obt_as.freq = obt.freq; obt_as.nchannels = obt.channels; obt_as.fmt = effective_fmt; obt_as.endianness = endianess; audio_pcm_init_info (&hw->info, &obt_as); hw->samples = obt.samples; s->initialized = 1; s->exit = 0; SDL_PauseAudio (0); return 0; }
false
qemu
1ea879e5580f63414693655fcf0328559cdce138
static int sdl_init_out (HWVoiceOut *hw, audsettings_t *as) { SDLVoiceOut *sdl = (SDLVoiceOut *) hw; SDLAudioState *s = &glob_sdl; SDL_AudioSpec req, obt; int shift; int endianess; int err; audfmt_e effective_fmt; audsettings_t obt_as; shift <<= as->nchannels == 2; req.freq = as->freq; req.format = aud_to_sdlfmt (as->fmt, &shift); req.channels = as->nchannels; req.samples = conf.nb_samples; req.callback = sdl_callback; req.userdata = sdl; if (sdl_open (&req, &obt)) { return -1; } err = sdl_to_audfmt (obt.format, &effective_fmt, &endianess); if (err) { sdl_close (s); return -1; } obt_as.freq = obt.freq; obt_as.nchannels = obt.channels; obt_as.fmt = effective_fmt; obt_as.endianness = endianess; audio_pcm_init_info (&hw->info, &obt_as); hw->samples = obt.samples; s->initialized = 1; s->exit = 0; SDL_PauseAudio (0); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0 (HWVoiceOut *VAR_0, audsettings_t *VAR_1) { SDLVoiceOut *sdl = (SDLVoiceOut *) VAR_0; SDLAudioState *s = &glob_sdl; SDL_AudioSpec req, obt; int VAR_2; int VAR_3; int VAR_4; audfmt_e effective_fmt; audsettings_t obt_as; VAR_2 <<= VAR_1->nchannels == 2; req.freq = VAR_1->freq; req.format = aud_to_sdlfmt (VAR_1->fmt, &VAR_2); req.channels = VAR_1->nchannels; req.samples = conf.nb_samples; req.callback = sdl_callback; req.userdata = sdl; if (sdl_open (&req, &obt)) { return -1; } VAR_4 = sdl_to_audfmt (obt.format, &effective_fmt, &VAR_3); if (VAR_4) { sdl_close (s); return -1; } obt_as.freq = obt.freq; obt_as.nchannels = obt.channels; obt_as.fmt = effective_fmt; obt_as.endianness = VAR_3; audio_pcm_init_info (&VAR_0->info, &obt_as); VAR_0->samples = obt.samples; s->initialized = 1; s->exit = 0; SDL_PauseAudio (0); return 0; }
[ "static int FUNC_0 (HWVoiceOut *VAR_0, audsettings_t *VAR_1)\n{", "SDLVoiceOut *sdl = (SDLVoiceOut *) VAR_0;", "SDLAudioState *s = &glob_sdl;", "SDL_AudioSpec req, obt;", "int VAR_2;", "int VAR_3;", "int VAR_4;", "audfmt_e effective_fmt;", "audsettings_t obt_as;", "VAR_2 <<= VAR_1->nchannels == 2;", "req.freq = VAR_1->freq;", "req.format = aud_to_sdlfmt (VAR_1->fmt, &VAR_2);", "req.channels = VAR_1->nchannels;", "req.samples = conf.nb_samples;", "req.callback = sdl_callback;", "req.userdata = sdl;", "if (sdl_open (&req, &obt)) {", "return -1;", "}", "VAR_4 = sdl_to_audfmt (obt.format, &effective_fmt, &VAR_3);", "if (VAR_4) {", "sdl_close (s);", "return -1;", "}", "obt_as.freq = obt.freq;", "obt_as.nchannels = obt.channels;", "obt_as.fmt = effective_fmt;", "obt_as.endianness = VAR_3;", "audio_pcm_init_info (&VAR_0->info, &obt_as);", "VAR_0->samples = obt.samples;", "s->initialized = 1;", "s->exit = 0;", "SDL_PauseAudio (0);", "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 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ] ]
20,207
void qemu_spice_init(void) { QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head); const char *password, *str, *x509_dir, *addr, *x509_key_password = NULL, *x509_dh_file = NULL, *tls_ciphers = NULL; char *x509_key_file = NULL, *x509_cert_file = NULL, *x509_cacert_file = NULL; int port, tls_port, len, addr_flags; spice_image_compression_t compression; spice_wan_compression_t wan_compr; qemu_thread_get_self(&me); if (!opts) { return; } port = qemu_opt_get_number(opts, "port", 0); tls_port = qemu_opt_get_number(opts, "tls-port", 0); if (!port && !tls_port) { fprintf(stderr, "neither port nor tls-port specified for spice."); exit(1); } if (port < 0 || port > 65535) { fprintf(stderr, "spice port is out of range"); exit(1); } if (tls_port < 0 || tls_port > 65535) { fprintf(stderr, "spice tls-port is out of range"); exit(1); } password = qemu_opt_get(opts, "password"); if (tls_port) { x509_dir = qemu_opt_get(opts, "x509-dir"); if (NULL == x509_dir) { x509_dir = "."; } len = strlen(x509_dir) + 32; str = qemu_opt_get(opts, "x509-key-file"); if (str) { x509_key_file = g_strdup(str); } else { x509_key_file = g_malloc(len); snprintf(x509_key_file, len, "%s/%s", x509_dir, X509_SERVER_KEY_FILE); } str = qemu_opt_get(opts, "x509-cert-file"); if (str) { x509_cert_file = g_strdup(str); } else { x509_cert_file = g_malloc(len); snprintf(x509_cert_file, len, "%s/%s", x509_dir, X509_SERVER_CERT_FILE); } str = qemu_opt_get(opts, "x509-cacert-file"); if (str) { x509_cacert_file = g_strdup(str); } else { x509_cacert_file = g_malloc(len); snprintf(x509_cacert_file, len, "%s/%s", x509_dir, X509_CA_CERT_FILE); } x509_key_password = qemu_opt_get(opts, "x509-key-password"); x509_dh_file = qemu_opt_get(opts, "x509-dh-file"); tls_ciphers = qemu_opt_get(opts, "tls-ciphers"); } addr = qemu_opt_get(opts, "addr"); addr_flags = 0; if (qemu_opt_get_bool(opts, "ipv4", 0)) { addr_flags |= SPICE_ADDR_FLAG_IPV4_ONLY; } else if (qemu_opt_get_bool(opts, "ipv6", 0)) { addr_flags |= SPICE_ADDR_FLAG_IPV6_ONLY; } spice_server = spice_server_new(); spice_server_set_addr(spice_server, addr ? addr : "", addr_flags); if (port) { spice_server_set_port(spice_server, port); } if (tls_port) { spice_server_set_tls(spice_server, tls_port, x509_cacert_file, x509_cert_file, x509_key_file, x509_key_password, x509_dh_file, tls_ciphers); } if (password) { spice_server_set_ticket(spice_server, password, 0, 0, 0); } if (qemu_opt_get_bool(opts, "sasl", 0)) { #if SPICE_SERVER_VERSION >= 0x000900 /* 0.9.0 */ if (spice_server_set_sasl_appname(spice_server, "qemu") == -1 || spice_server_set_sasl(spice_server, 1) == -1) { fprintf(stderr, "spice: failed to enable sasl\n"); exit(1); } #else fprintf(stderr, "spice: sasl is not available (spice >= 0.9 required)\n"); exit(1); #endif } if (qemu_opt_get_bool(opts, "disable-ticketing", 0)) { auth = "none"; spice_server_set_noauth(spice_server); } #if SPICE_SERVER_VERSION >= 0x000801 if (qemu_opt_get_bool(opts, "disable-copy-paste", 0)) { spice_server_set_agent_copypaste(spice_server, false); } #endif compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ; str = qemu_opt_get(opts, "image-compression"); if (str) { compression = parse_compression(str); } spice_server_set_image_compression(spice_server, compression); wan_compr = SPICE_WAN_COMPRESSION_AUTO; str = qemu_opt_get(opts, "jpeg-wan-compression"); if (str) { wan_compr = parse_wan_compression(str); } spice_server_set_jpeg_compression(spice_server, wan_compr); wan_compr = SPICE_WAN_COMPRESSION_AUTO; str = qemu_opt_get(opts, "zlib-glz-wan-compression"); if (str) { wan_compr = parse_wan_compression(str); } spice_server_set_zlib_glz_compression(spice_server, wan_compr); str = qemu_opt_get(opts, "streaming-video"); if (str) { int streaming_video = parse_stream_video(str); spice_server_set_streaming_video(spice_server, streaming_video); } spice_server_set_agent_mouse (spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1)); spice_server_set_playback_compression (spice_server, qemu_opt_get_bool(opts, "playback-compression", 1)); qemu_opt_foreach(opts, add_channel, NULL, 0); if (0 != spice_server_init(spice_server, &core_interface)) { fprintf(stderr, "failed to initialize spice server"); exit(1); }; using_spice = 1; migration_state.notify = migration_state_notifier; add_migration_state_change_notifier(&migration_state); #ifdef SPICE_INTERFACE_MIGRATION spice_migrate.sin.base.sif = &migrate_interface.base; spice_migrate.connect_complete.cb = NULL; qemu_spice_add_interface(&spice_migrate.sin.base); #endif qemu_spice_input_init(); qemu_spice_audio_init(); g_free(x509_key_file); g_free(x509_cert_file); g_free(x509_cacert_file); }
false
qemu
4295e15aa730a95003a3639d6dad2eb1e65a59e2
void qemu_spice_init(void) { QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head); const char *password, *str, *x509_dir, *addr, *x509_key_password = NULL, *x509_dh_file = NULL, *tls_ciphers = NULL; char *x509_key_file = NULL, *x509_cert_file = NULL, *x509_cacert_file = NULL; int port, tls_port, len, addr_flags; spice_image_compression_t compression; spice_wan_compression_t wan_compr; qemu_thread_get_self(&me); if (!opts) { return; } port = qemu_opt_get_number(opts, "port", 0); tls_port = qemu_opt_get_number(opts, "tls-port", 0); if (!port && !tls_port) { fprintf(stderr, "neither port nor tls-port specified for spice."); exit(1); } if (port < 0 || port > 65535) { fprintf(stderr, "spice port is out of range"); exit(1); } if (tls_port < 0 || tls_port > 65535) { fprintf(stderr, "spice tls-port is out of range"); exit(1); } password = qemu_opt_get(opts, "password"); if (tls_port) { x509_dir = qemu_opt_get(opts, "x509-dir"); if (NULL == x509_dir) { x509_dir = "."; } len = strlen(x509_dir) + 32; str = qemu_opt_get(opts, "x509-key-file"); if (str) { x509_key_file = g_strdup(str); } else { x509_key_file = g_malloc(len); snprintf(x509_key_file, len, "%s/%s", x509_dir, X509_SERVER_KEY_FILE); } str = qemu_opt_get(opts, "x509-cert-file"); if (str) { x509_cert_file = g_strdup(str); } else { x509_cert_file = g_malloc(len); snprintf(x509_cert_file, len, "%s/%s", x509_dir, X509_SERVER_CERT_FILE); } str = qemu_opt_get(opts, "x509-cacert-file"); if (str) { x509_cacert_file = g_strdup(str); } else { x509_cacert_file = g_malloc(len); snprintf(x509_cacert_file, len, "%s/%s", x509_dir, X509_CA_CERT_FILE); } x509_key_password = qemu_opt_get(opts, "x509-key-password"); x509_dh_file = qemu_opt_get(opts, "x509-dh-file"); tls_ciphers = qemu_opt_get(opts, "tls-ciphers"); } addr = qemu_opt_get(opts, "addr"); addr_flags = 0; if (qemu_opt_get_bool(opts, "ipv4", 0)) { addr_flags |= SPICE_ADDR_FLAG_IPV4_ONLY; } else if (qemu_opt_get_bool(opts, "ipv6", 0)) { addr_flags |= SPICE_ADDR_FLAG_IPV6_ONLY; } spice_server = spice_server_new(); spice_server_set_addr(spice_server, addr ? addr : "", addr_flags); if (port) { spice_server_set_port(spice_server, port); } if (tls_port) { spice_server_set_tls(spice_server, tls_port, x509_cacert_file, x509_cert_file, x509_key_file, x509_key_password, x509_dh_file, tls_ciphers); } if (password) { spice_server_set_ticket(spice_server, password, 0, 0, 0); } if (qemu_opt_get_bool(opts, "sasl", 0)) { #if SPICE_SERVER_VERSION >= 0x000900 if (spice_server_set_sasl_appname(spice_server, "qemu") == -1 || spice_server_set_sasl(spice_server, 1) == -1) { fprintf(stderr, "spice: failed to enable sasl\n"); exit(1); } #else fprintf(stderr, "spice: sasl is not available (spice >= 0.9 required)\n"); exit(1); #endif } if (qemu_opt_get_bool(opts, "disable-ticketing", 0)) { auth = "none"; spice_server_set_noauth(spice_server); } #if SPICE_SERVER_VERSION >= 0x000801 if (qemu_opt_get_bool(opts, "disable-copy-paste", 0)) { spice_server_set_agent_copypaste(spice_server, false); } #endif compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ; str = qemu_opt_get(opts, "image-compression"); if (str) { compression = parse_compression(str); } spice_server_set_image_compression(spice_server, compression); wan_compr = SPICE_WAN_COMPRESSION_AUTO; str = qemu_opt_get(opts, "jpeg-wan-compression"); if (str) { wan_compr = parse_wan_compression(str); } spice_server_set_jpeg_compression(spice_server, wan_compr); wan_compr = SPICE_WAN_COMPRESSION_AUTO; str = qemu_opt_get(opts, "zlib-glz-wan-compression"); if (str) { wan_compr = parse_wan_compression(str); } spice_server_set_zlib_glz_compression(spice_server, wan_compr); str = qemu_opt_get(opts, "streaming-video"); if (str) { int streaming_video = parse_stream_video(str); spice_server_set_streaming_video(spice_server, streaming_video); } spice_server_set_agent_mouse (spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1)); spice_server_set_playback_compression (spice_server, qemu_opt_get_bool(opts, "playback-compression", 1)); qemu_opt_foreach(opts, add_channel, NULL, 0); if (0 != spice_server_init(spice_server, &core_interface)) { fprintf(stderr, "failed to initialize spice server"); exit(1); }; using_spice = 1; migration_state.notify = migration_state_notifier; add_migration_state_change_notifier(&migration_state); #ifdef SPICE_INTERFACE_MIGRATION spice_migrate.sin.base.sif = &migrate_interface.base; spice_migrate.connect_complete.cb = NULL; qemu_spice_add_interface(&spice_migrate.sin.base); #endif qemu_spice_input_init(); qemu_spice_audio_init(); g_free(x509_key_file); g_free(x509_cert_file); g_free(x509_cacert_file); }
{ "code": [], "line_no": [] }
void FUNC_0(void) { QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head); const char *VAR_0, *VAR_1, *VAR_2, *VAR_3, *VAR_4 = NULL, *VAR_5 = NULL, *VAR_6 = NULL; char *VAR_7 = NULL, *VAR_8 = NULL, *VAR_9 = NULL; int VAR_10, VAR_11, VAR_12, VAR_13; spice_image_compression_t compression; spice_wan_compression_t wan_compr; qemu_thread_get_self(&me); if (!opts) { return; } VAR_10 = qemu_opt_get_number(opts, "VAR_10", 0); VAR_11 = qemu_opt_get_number(opts, "tls-VAR_10", 0); if (!VAR_10 && !VAR_11) { fprintf(stderr, "neither VAR_10 nor tls-VAR_10 specified for spice."); exit(1); } if (VAR_10 < 0 || VAR_10 > 65535) { fprintf(stderr, "spice VAR_10 is out of range"); exit(1); } if (VAR_11 < 0 || VAR_11 > 65535) { fprintf(stderr, "spice tls-VAR_10 is out of range"); exit(1); } VAR_0 = qemu_opt_get(opts, "VAR_0"); if (VAR_11) { VAR_2 = qemu_opt_get(opts, "x509-dir"); if (NULL == VAR_2) { VAR_2 = "."; } VAR_12 = strlen(VAR_2) + 32; VAR_1 = qemu_opt_get(opts, "x509-key-file"); if (VAR_1) { VAR_7 = g_strdup(VAR_1); } else { VAR_7 = g_malloc(VAR_12); snprintf(VAR_7, VAR_12, "%s/%s", VAR_2, X509_SERVER_KEY_FILE); } VAR_1 = qemu_opt_get(opts, "x509-cert-file"); if (VAR_1) { VAR_8 = g_strdup(VAR_1); } else { VAR_8 = g_malloc(VAR_12); snprintf(VAR_8, VAR_12, "%s/%s", VAR_2, X509_SERVER_CERT_FILE); } VAR_1 = qemu_opt_get(opts, "x509-cacert-file"); if (VAR_1) { VAR_9 = g_strdup(VAR_1); } else { VAR_9 = g_malloc(VAR_12); snprintf(VAR_9, VAR_12, "%s/%s", VAR_2, X509_CA_CERT_FILE); } VAR_4 = qemu_opt_get(opts, "x509-key-VAR_0"); VAR_5 = qemu_opt_get(opts, "x509-dh-file"); VAR_6 = qemu_opt_get(opts, "tls-ciphers"); } VAR_3 = qemu_opt_get(opts, "VAR_3"); VAR_13 = 0; if (qemu_opt_get_bool(opts, "ipv4", 0)) { VAR_13 |= SPICE_ADDR_FLAG_IPV4_ONLY; } else if (qemu_opt_get_bool(opts, "ipv6", 0)) { VAR_13 |= SPICE_ADDR_FLAG_IPV6_ONLY; } spice_server = spice_server_new(); spice_server_set_addr(spice_server, VAR_3 ? VAR_3 : "", VAR_13); if (VAR_10) { spice_server_set_port(spice_server, VAR_10); } if (VAR_11) { spice_server_set_tls(spice_server, VAR_11, VAR_9, VAR_8, VAR_7, VAR_4, VAR_5, VAR_6); } if (VAR_0) { spice_server_set_ticket(spice_server, VAR_0, 0, 0, 0); } if (qemu_opt_get_bool(opts, "sasl", 0)) { #if SPICE_SERVER_VERSION >= 0x000900 if (spice_server_set_sasl_appname(spice_server, "qemu") == -1 || spice_server_set_sasl(spice_server, 1) == -1) { fprintf(stderr, "spice: failed to enable sasl\n"); exit(1); } #else fprintf(stderr, "spice: sasl is not available (spice >= 0.9 required)\n"); exit(1); #endif } if (qemu_opt_get_bool(opts, "disable-ticketing", 0)) { auth = "none"; spice_server_set_noauth(spice_server); } #if SPICE_SERVER_VERSION >= 0x000801 if (qemu_opt_get_bool(opts, "disable-copy-paste", 0)) { spice_server_set_agent_copypaste(spice_server, false); } #endif compression = SPICE_IMAGE_COMPRESS_AUTO_GLZ; VAR_1 = qemu_opt_get(opts, "image-compression"); if (VAR_1) { compression = parse_compression(VAR_1); } spice_server_set_image_compression(spice_server, compression); wan_compr = SPICE_WAN_COMPRESSION_AUTO; VAR_1 = qemu_opt_get(opts, "jpeg-wan-compression"); if (VAR_1) { wan_compr = parse_wan_compression(VAR_1); } spice_server_set_jpeg_compression(spice_server, wan_compr); wan_compr = SPICE_WAN_COMPRESSION_AUTO; VAR_1 = qemu_opt_get(opts, "zlib-glz-wan-compression"); if (VAR_1) { wan_compr = parse_wan_compression(VAR_1); } spice_server_set_zlib_glz_compression(spice_server, wan_compr); VAR_1 = qemu_opt_get(opts, "streaming-video"); if (VAR_1) { int VAR_14 = parse_stream_video(VAR_1); spice_server_set_streaming_video(spice_server, VAR_14); } spice_server_set_agent_mouse (spice_server, qemu_opt_get_bool(opts, "agent-mouse", 1)); spice_server_set_playback_compression (spice_server, qemu_opt_get_bool(opts, "playback-compression", 1)); qemu_opt_foreach(opts, add_channel, NULL, 0); if (0 != spice_server_init(spice_server, &core_interface)) { fprintf(stderr, "failed to initialize spice server"); exit(1); }; using_spice = 1; migration_state.notify = migration_state_notifier; add_migration_state_change_notifier(&migration_state); #ifdef SPICE_INTERFACE_MIGRATION spice_migrate.sin.base.sif = &migrate_interface.base; spice_migrate.connect_complete.cb = NULL; qemu_spice_add_interface(&spice_migrate.sin.base); #endif qemu_spice_input_init(); qemu_spice_audio_init(); g_free(VAR_7); g_free(VAR_8); g_free(VAR_9); }
[ "void FUNC_0(void)\n{", "QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);", "const char *VAR_0, *VAR_1, *VAR_2, *VAR_3,\n*VAR_4 = NULL,\n*VAR_5 = NULL,\n*VAR_6 = NULL;", "char *VAR_7 = NULL,\n*VAR_8 = NULL,\n*VAR_9 = NULL;", "int VAR_10, VAR_11, VAR_12, VAR_13;", "spice_image_compression_t compression;", "spice_wan_compression_t wan_compr;", "qemu_thread_get_self(&me);", "if (!opts) {", "return;", "}", "VAR_10 = qemu_opt_get_number(opts, \"VAR_10\", 0);", "VAR_11 = qemu_opt_get_number(opts, \"tls-VAR_10\", 0);", "if (!VAR_10 && !VAR_11) {", "fprintf(stderr, \"neither VAR_10 nor tls-VAR_10 specified for spice.\");", "exit(1);", "}", "if (VAR_10 < 0 || VAR_10 > 65535) {", "fprintf(stderr, \"spice VAR_10 is out of range\");", "exit(1);", "}", "if (VAR_11 < 0 || VAR_11 > 65535) {", "fprintf(stderr, \"spice tls-VAR_10 is out of range\");", "exit(1);", "}", "VAR_0 = qemu_opt_get(opts, \"VAR_0\");", "if (VAR_11) {", "VAR_2 = qemu_opt_get(opts, \"x509-dir\");", "if (NULL == VAR_2) {", "VAR_2 = \".\";", "}", "VAR_12 = strlen(VAR_2) + 32;", "VAR_1 = qemu_opt_get(opts, \"x509-key-file\");", "if (VAR_1) {", "VAR_7 = g_strdup(VAR_1);", "} else {", "VAR_7 = g_malloc(VAR_12);", "snprintf(VAR_7, VAR_12, \"%s/%s\", VAR_2, X509_SERVER_KEY_FILE);", "}", "VAR_1 = qemu_opt_get(opts, \"x509-cert-file\");", "if (VAR_1) {", "VAR_8 = g_strdup(VAR_1);", "} else {", "VAR_8 = g_malloc(VAR_12);", "snprintf(VAR_8, VAR_12, \"%s/%s\", VAR_2, X509_SERVER_CERT_FILE);", "}", "VAR_1 = qemu_opt_get(opts, \"x509-cacert-file\");", "if (VAR_1) {", "VAR_9 = g_strdup(VAR_1);", "} else {", "VAR_9 = g_malloc(VAR_12);", "snprintf(VAR_9, VAR_12, \"%s/%s\", VAR_2, X509_CA_CERT_FILE);", "}", "VAR_4 = qemu_opt_get(opts, \"x509-key-VAR_0\");", "VAR_5 = qemu_opt_get(opts, \"x509-dh-file\");", "VAR_6 = qemu_opt_get(opts, \"tls-ciphers\");", "}", "VAR_3 = qemu_opt_get(opts, \"VAR_3\");", "VAR_13 = 0;", "if (qemu_opt_get_bool(opts, \"ipv4\", 0)) {", "VAR_13 |= SPICE_ADDR_FLAG_IPV4_ONLY;", "} else if (qemu_opt_get_bool(opts, \"ipv6\", 0)) {", "VAR_13 |= SPICE_ADDR_FLAG_IPV6_ONLY;", "}", "spice_server = spice_server_new();", "spice_server_set_addr(spice_server, VAR_3 ? VAR_3 : \"\", VAR_13);", "if (VAR_10) {", "spice_server_set_port(spice_server, VAR_10);", "}", "if (VAR_11) {", "spice_server_set_tls(spice_server, VAR_11,\nVAR_9,\nVAR_8,\nVAR_7,\nVAR_4,\nVAR_5,\nVAR_6);", "}", "if (VAR_0) {", "spice_server_set_ticket(spice_server, VAR_0, 0, 0, 0);", "}", "if (qemu_opt_get_bool(opts, \"sasl\", 0)) {", "#if SPICE_SERVER_VERSION >= 0x000900\nif (spice_server_set_sasl_appname(spice_server, \"qemu\") == -1 ||\nspice_server_set_sasl(spice_server, 1) == -1) {", "fprintf(stderr, \"spice: failed to enable sasl\\n\");", "exit(1);", "}", "#else\nfprintf(stderr, \"spice: sasl is not available (spice >= 0.9 required)\\n\");", "exit(1);", "#endif\n}", "if (qemu_opt_get_bool(opts, \"disable-ticketing\", 0)) {", "auth = \"none\";", "spice_server_set_noauth(spice_server);", "}", "#if SPICE_SERVER_VERSION >= 0x000801\nif (qemu_opt_get_bool(opts, \"disable-copy-paste\", 0)) {", "spice_server_set_agent_copypaste(spice_server, false);", "}", "#endif\ncompression = SPICE_IMAGE_COMPRESS_AUTO_GLZ;", "VAR_1 = qemu_opt_get(opts, \"image-compression\");", "if (VAR_1) {", "compression = parse_compression(VAR_1);", "}", "spice_server_set_image_compression(spice_server, compression);", "wan_compr = SPICE_WAN_COMPRESSION_AUTO;", "VAR_1 = qemu_opt_get(opts, \"jpeg-wan-compression\");", "if (VAR_1) {", "wan_compr = parse_wan_compression(VAR_1);", "}", "spice_server_set_jpeg_compression(spice_server, wan_compr);", "wan_compr = SPICE_WAN_COMPRESSION_AUTO;", "VAR_1 = qemu_opt_get(opts, \"zlib-glz-wan-compression\");", "if (VAR_1) {", "wan_compr = parse_wan_compression(VAR_1);", "}", "spice_server_set_zlib_glz_compression(spice_server, wan_compr);", "VAR_1 = qemu_opt_get(opts, \"streaming-video\");", "if (VAR_1) {", "int VAR_14 = parse_stream_video(VAR_1);", "spice_server_set_streaming_video(spice_server, VAR_14);", "}", "spice_server_set_agent_mouse\n(spice_server, qemu_opt_get_bool(opts, \"agent-mouse\", 1));", "spice_server_set_playback_compression\n(spice_server, qemu_opt_get_bool(opts, \"playback-compression\", 1));", "qemu_opt_foreach(opts, add_channel, NULL, 0);", "if (0 != spice_server_init(spice_server, &core_interface)) {", "fprintf(stderr, \"failed to initialize spice server\");", "exit(1);", "};", "using_spice = 1;", "migration_state.notify = migration_state_notifier;", "add_migration_state_change_notifier(&migration_state);", "#ifdef SPICE_INTERFACE_MIGRATION\nspice_migrate.sin.base.sif = &migrate_interface.base;", "spice_migrate.connect_complete.cb = NULL;", "qemu_spice_add_interface(&spice_migrate.sin.base);", "#endif\nqemu_spice_input_init();", "qemu_spice_audio_init();", "g_free(VAR_7);", "g_free(VAR_8);", "g_free(VAR_9);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 143 ], [ 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 ], [ 227, 229 ], [ 231 ], [ 233 ], [ 235, 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 293, 295 ], [ 297, 299 ], [ 303 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 319 ], [ 321 ], [ 323, 325 ], [ 327 ], [ 329 ], [ 331, 335 ], [ 337 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ] ]
20,208
eth_write(void *opaque, target_phys_addr_t addr, uint64_t val64, unsigned int size) { struct fs_eth *eth = opaque; uint32_t value = val64; addr >>= 2; switch (addr) { case RW_MA0_LO: case RW_MA0_HI: eth->regs[addr] = value; eth_update_ma(eth, 0); break; case RW_MA1_LO: case RW_MA1_HI: eth->regs[addr] = value; eth_update_ma(eth, 1); break; case RW_MGM_CTRL: /* Attach an MDIO/PHY abstraction. */ if (value & 2) eth->mdio_bus.mdio = value & 1; if (eth->mdio_bus.mdc != (value & 4)) { mdio_cycle(&eth->mdio_bus); eth_validate_duplex(eth); } eth->mdio_bus.mdc = !!(value & 4); eth->regs[addr] = value; break; case RW_REC_CTRL: eth->regs[addr] = value; eth_validate_duplex(eth); break; default: eth->regs[addr] = value; D(printf ("%s %x %x\n", __func__, addr, value)); break; } }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
eth_write(void *opaque, target_phys_addr_t addr, uint64_t val64, unsigned int size) { struct fs_eth *eth = opaque; uint32_t value = val64; addr >>= 2; switch (addr) { case RW_MA0_LO: case RW_MA0_HI: eth->regs[addr] = value; eth_update_ma(eth, 0); break; case RW_MA1_LO: case RW_MA1_HI: eth->regs[addr] = value; eth_update_ma(eth, 1); break; case RW_MGM_CTRL: if (value & 2) eth->mdio_bus.mdio = value & 1; if (eth->mdio_bus.mdc != (value & 4)) { mdio_cycle(&eth->mdio_bus); eth_validate_duplex(eth); } eth->mdio_bus.mdc = !!(value & 4); eth->regs[addr] = value; break; case RW_REC_CTRL: eth->regs[addr] = value; eth_validate_duplex(eth); break; default: eth->regs[addr] = value; D(printf ("%s %x %x\n", __func__, addr, value)); break; } }
{ "code": [], "line_no": [] }
FUNC_0(void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned int VAR_3) { struct fs_eth *VAR_4 = VAR_0; uint32_t value = VAR_2; VAR_1 >>= 2; switch (VAR_1) { case RW_MA0_LO: case RW_MA0_HI: VAR_4->regs[VAR_1] = value; eth_update_ma(VAR_4, 0); break; case RW_MA1_LO: case RW_MA1_HI: VAR_4->regs[VAR_1] = value; eth_update_ma(VAR_4, 1); break; case RW_MGM_CTRL: if (value & 2) VAR_4->mdio_bus.mdio = value & 1; if (VAR_4->mdio_bus.mdc != (value & 4)) { mdio_cycle(&VAR_4->mdio_bus); eth_validate_duplex(VAR_4); } VAR_4->mdio_bus.mdc = !!(value & 4); VAR_4->regs[VAR_1] = value; break; case RW_REC_CTRL: VAR_4->regs[VAR_1] = value; eth_validate_duplex(VAR_4); break; default: VAR_4->regs[VAR_1] = value; D(printf ("%s %x %x\n", __func__, VAR_1, value)); break; } }
[ "FUNC_0(void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned int VAR_3)\n{", "struct fs_eth *VAR_4 = VAR_0;", "uint32_t value = VAR_2;", "VAR_1 >>= 2;", "switch (VAR_1)\n{", "case RW_MA0_LO:\ncase RW_MA0_HI:\nVAR_4->regs[VAR_1] = value;", "eth_update_ma(VAR_4, 0);", "break;", "case RW_MA1_LO:\ncase RW_MA1_HI:\nVAR_4->regs[VAR_1] = value;", "eth_update_ma(VAR_4, 1);", "break;", "case RW_MGM_CTRL:\nif (value & 2)\nVAR_4->mdio_bus.mdio = value & 1;", "if (VAR_4->mdio_bus.mdc != (value & 4)) {", "mdio_cycle(&VAR_4->mdio_bus);", "eth_validate_duplex(VAR_4);", "}", "VAR_4->mdio_bus.mdc = !!(value & 4);", "VAR_4->regs[VAR_1] = value;", "break;", "case RW_REC_CTRL:\nVAR_4->regs[VAR_1] = value;", "eth_validate_duplex(VAR_4);", "break;", "default:\nVAR_4->regs[VAR_1] = value;", "D(printf (\"%s %x %x\\n\",\n__func__, VAR_1, value));", "break;", "}", "}" ]
[ 0, 0, 0, 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 ], [ 41, 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 75, 77 ], [ 79, 81 ], [ 83 ], [ 85 ], [ 87 ] ]
20,209
static void strongarm_gpio_handler_update(StrongARMGPIOInfo *s) { uint32_t level, diff; int bit; level = s->olevel & s->dir; for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) { bit = ffs(diff) - 1; qemu_set_irq(s->handler[bit], (level >> bit) & 1); } s->prev_level = level; }
false
qemu
786a4ea82ec9c87e3a895cf41081029b285a5fe5
static void strongarm_gpio_handler_update(StrongARMGPIOInfo *s) { uint32_t level, diff; int bit; level = s->olevel & s->dir; for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) { bit = ffs(diff) - 1; qemu_set_irq(s->handler[bit], (level >> bit) & 1); } s->prev_level = level; }
{ "code": [], "line_no": [] }
static void FUNC_0(StrongARMGPIOInfo *VAR_0) { uint32_t level, diff; int VAR_1; level = VAR_0->olevel & VAR_0->dir; for (diff = VAR_0->prev_level ^ level; diff; diff ^= 1 << VAR_1) { VAR_1 = ffs(diff) - 1; qemu_set_irq(VAR_0->handler[VAR_1], (level >> VAR_1) & 1); } VAR_0->prev_level = level; }
[ "static void FUNC_0(StrongARMGPIOInfo *VAR_0)\n{", "uint32_t level, diff;", "int VAR_1;", "level = VAR_0->olevel & VAR_0->dir;", "for (diff = VAR_0->prev_level ^ level; diff; diff ^= 1 << VAR_1) {", "VAR_1 = ffs(diff) - 1;", "qemu_set_irq(VAR_0->handler[VAR_1], (level >> VAR_1) & 1);", "}", "VAR_0->prev_level = level;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ] ]
20,210
void ff_vc1dsp_init_altivec(VC1DSPContext* dsp) { if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_altivec; dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_altivec; dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec; dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_altivec; }
false
FFmpeg
f8bed30d8b176fa030f6737765338bb4a2bcabc9
void ff_vc1dsp_init_altivec(VC1DSPContext* dsp) { if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; dsp->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_altivec; dsp->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_altivec; dsp->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec; dsp->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_altivec; }
{ "code": [], "line_no": [] }
void FUNC_0(VC1DSPContext* VAR_0) { if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; VAR_0->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_altivec; VAR_0->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_altivec; VAR_0->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec; VAR_0->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_altivec; }
[ "void FUNC_0(VC1DSPContext* VAR_0)\n{", "if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC))\nreturn;", "VAR_0->vc1_inv_trans_8x8 = vc1_inv_trans_8x8_altivec;", "VAR_0->vc1_inv_trans_8x4 = vc1_inv_trans_8x4_altivec;", "VAR_0->put_no_rnd_vc1_chroma_pixels_tab[0] = put_no_rnd_vc1_chroma_mc8_altivec;", "VAR_0->avg_no_rnd_vc1_chroma_pixels_tab[0] = avg_no_rnd_vc1_chroma_mc8_altivec;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
20,211
static void cuda_receive_packet(CUDAState *s, const uint8_t *data, int len) { uint8_t obuf[16]; int ti, autopoll; switch(data[0]) { case CUDA_AUTOPOLL: autopoll = (data[1] != 0); if (autopoll != s->autopoll) { s->autopoll = autopoll; if (autopoll) { qemu_mod_timer(s->adb_poll_timer, qemu_get_clock(vm_clock) + (ticks_per_sec / CUDA_ADB_POLL_FREQ)); } else { qemu_del_timer(s->adb_poll_timer); } } obuf[0] = CUDA_PACKET; obuf[1] = data[1]; cuda_send_packet_to_host(s, obuf, 2); break; case CUDA_GET_TIME: case CUDA_SET_TIME: /* XXX: add time support ? */ ti = time(NULL) + RTC_OFFSET; obuf[0] = CUDA_PACKET; obuf[1] = 0; obuf[2] = 0; obuf[3] = ti >> 24; obuf[4] = ti >> 16; obuf[5] = ti >> 8; obuf[6] = ti; cuda_send_packet_to_host(s, obuf, 7); break; case CUDA_FILE_SERVER_FLAG: case CUDA_SET_DEVICE_LIST: case CUDA_SET_AUTO_RATE: case CUDA_SET_POWER_MESSAGES: obuf[0] = CUDA_PACKET; obuf[1] = 0; cuda_send_packet_to_host(s, obuf, 2); break; case CUDA_POWERDOWN: obuf[0] = CUDA_PACKET; obuf[1] = 0; cuda_send_packet_to_host(s, obuf, 2); qemu_system_shutdown_request(); break; case CUDA_RESET_SYSTEM: obuf[0] = CUDA_PACKET; obuf[1] = 0; cuda_send_packet_to_host(s, obuf, 2); qemu_system_reset_request(); break; default: break; } }
false
qemu
5703c174ff8bd2072e6cb77d87fa3e85c98bf043
static void cuda_receive_packet(CUDAState *s, const uint8_t *data, int len) { uint8_t obuf[16]; int ti, autopoll; switch(data[0]) { case CUDA_AUTOPOLL: autopoll = (data[1] != 0); if (autopoll != s->autopoll) { s->autopoll = autopoll; if (autopoll) { qemu_mod_timer(s->adb_poll_timer, qemu_get_clock(vm_clock) + (ticks_per_sec / CUDA_ADB_POLL_FREQ)); } else { qemu_del_timer(s->adb_poll_timer); } } obuf[0] = CUDA_PACKET; obuf[1] = data[1]; cuda_send_packet_to_host(s, obuf, 2); break; case CUDA_GET_TIME: case CUDA_SET_TIME: ti = time(NULL) + RTC_OFFSET; obuf[0] = CUDA_PACKET; obuf[1] = 0; obuf[2] = 0; obuf[3] = ti >> 24; obuf[4] = ti >> 16; obuf[5] = ti >> 8; obuf[6] = ti; cuda_send_packet_to_host(s, obuf, 7); break; case CUDA_FILE_SERVER_FLAG: case CUDA_SET_DEVICE_LIST: case CUDA_SET_AUTO_RATE: case CUDA_SET_POWER_MESSAGES: obuf[0] = CUDA_PACKET; obuf[1] = 0; cuda_send_packet_to_host(s, obuf, 2); break; case CUDA_POWERDOWN: obuf[0] = CUDA_PACKET; obuf[1] = 0; cuda_send_packet_to_host(s, obuf, 2); qemu_system_shutdown_request(); break; case CUDA_RESET_SYSTEM: obuf[0] = CUDA_PACKET; obuf[1] = 0; cuda_send_packet_to_host(s, obuf, 2); qemu_system_reset_request(); break; default: break; } }
{ "code": [], "line_no": [] }
static void FUNC_0(CUDAState *VAR_0, const uint8_t *VAR_1, int VAR_2) { uint8_t obuf[16]; int VAR_3, VAR_4; switch(VAR_1[0]) { case CUDA_AUTOPOLL: VAR_4 = (VAR_1[1] != 0); if (VAR_4 != VAR_0->VAR_4) { VAR_0->VAR_4 = VAR_4; if (VAR_4) { qemu_mod_timer(VAR_0->adb_poll_timer, qemu_get_clock(vm_clock) + (ticks_per_sec / CUDA_ADB_POLL_FREQ)); } else { qemu_del_timer(VAR_0->adb_poll_timer); } } obuf[0] = CUDA_PACKET; obuf[1] = VAR_1[1]; cuda_send_packet_to_host(VAR_0, obuf, 2); break; case CUDA_GET_TIME: case CUDA_SET_TIME: VAR_3 = time(NULL) + RTC_OFFSET; obuf[0] = CUDA_PACKET; obuf[1] = 0; obuf[2] = 0; obuf[3] = VAR_3 >> 24; obuf[4] = VAR_3 >> 16; obuf[5] = VAR_3 >> 8; obuf[6] = VAR_3; cuda_send_packet_to_host(VAR_0, obuf, 7); break; case CUDA_FILE_SERVER_FLAG: case CUDA_SET_DEVICE_LIST: case CUDA_SET_AUTO_RATE: case CUDA_SET_POWER_MESSAGES: obuf[0] = CUDA_PACKET; obuf[1] = 0; cuda_send_packet_to_host(VAR_0, obuf, 2); break; case CUDA_POWERDOWN: obuf[0] = CUDA_PACKET; obuf[1] = 0; cuda_send_packet_to_host(VAR_0, obuf, 2); qemu_system_shutdown_request(); break; case CUDA_RESET_SYSTEM: obuf[0] = CUDA_PACKET; obuf[1] = 0; cuda_send_packet_to_host(VAR_0, obuf, 2); qemu_system_reset_request(); break; default: break; } }
[ "static void FUNC_0(CUDAState *VAR_0,\nconst uint8_t *VAR_1, int VAR_2)\n{", "uint8_t obuf[16];", "int VAR_3, VAR_4;", "switch(VAR_1[0]) {", "case CUDA_AUTOPOLL:\nVAR_4 = (VAR_1[1] != 0);", "if (VAR_4 != VAR_0->VAR_4) {", "VAR_0->VAR_4 = VAR_4;", "if (VAR_4) {", "qemu_mod_timer(VAR_0->adb_poll_timer,\nqemu_get_clock(vm_clock) +\n(ticks_per_sec / CUDA_ADB_POLL_FREQ));", "} else {", "qemu_del_timer(VAR_0->adb_poll_timer);", "}", "}", "obuf[0] = CUDA_PACKET;", "obuf[1] = VAR_1[1];", "cuda_send_packet_to_host(VAR_0, obuf, 2);", "break;", "case CUDA_GET_TIME:\ncase CUDA_SET_TIME:\nVAR_3 = time(NULL) + RTC_OFFSET;", "obuf[0] = CUDA_PACKET;", "obuf[1] = 0;", "obuf[2] = 0;", "obuf[3] = VAR_3 >> 24;", "obuf[4] = VAR_3 >> 16;", "obuf[5] = VAR_3 >> 8;", "obuf[6] = VAR_3;", "cuda_send_packet_to_host(VAR_0, obuf, 7);", "break;", "case CUDA_FILE_SERVER_FLAG:\ncase CUDA_SET_DEVICE_LIST:\ncase CUDA_SET_AUTO_RATE:\ncase CUDA_SET_POWER_MESSAGES:\nobuf[0] = CUDA_PACKET;", "obuf[1] = 0;", "cuda_send_packet_to_host(VAR_0, obuf, 2);", "break;", "case CUDA_POWERDOWN:\nobuf[0] = CUDA_PACKET;", "obuf[1] = 0;", "cuda_send_packet_to_host(VAR_0, obuf, 2);", "qemu_system_shutdown_request();", "break;", "case CUDA_RESET_SYSTEM:\nobuf[0] = CUDA_PACKET;", "obuf[1] = 0;", "cuda_send_packet_to_host(VAR_0, obuf, 2);", "qemu_system_reset_request();", "break;", "default:\nbreak;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 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 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119 ] ]
20,212
iscsi_aio_flush(BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = iscsilun->iscsi; IscsiAIOCB *acb; acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); acb->iscsilun = iscsilun; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->task = iscsi_synchronizecache10_task(iscsi, iscsilun->lun, 0, 0, 0, 0, iscsi_synccache10_cb, acb); if (acb->task == NULL) { error_report("iSCSI: Failed to send synchronizecache10 command. %s", iscsi_get_error(iscsi)); qemu_aio_release(acb); return NULL; } iscsi_set_events(iscsilun); return &acb->common; }
false
qemu
1dde716ed6719c341c1bfa427781f0715af90cbc
iscsi_aio_flush(BlockDriverState *bs, BlockDriverCompletionFunc *cb, void *opaque) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = iscsilun->iscsi; IscsiAIOCB *acb; acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); acb->iscsilun = iscsilun; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->task = iscsi_synchronizecache10_task(iscsi, iscsilun->lun, 0, 0, 0, 0, iscsi_synccache10_cb, acb); if (acb->task == NULL) { error_report("iSCSI: Failed to send synchronizecache10 command. %s", iscsi_get_error(iscsi)); qemu_aio_release(acb); return NULL; } iscsi_set_events(iscsilun); return &acb->common; }
{ "code": [], "line_no": [] }
FUNC_0(BlockDriverState *VAR_0, BlockDriverCompletionFunc *VAR_1, void *VAR_2) { IscsiLun *iscsilun = VAR_0->VAR_2; struct iscsi_context *VAR_3 = iscsilun->VAR_3; IscsiAIOCB *acb; acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_1, VAR_2); acb->iscsilun = iscsilun; acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; acb->buf = NULL; acb->task = iscsi_synchronizecache10_task(VAR_3, iscsilun->lun, 0, 0, 0, 0, iscsi_synccache10_cb, acb); if (acb->task == NULL) { error_report("iSCSI: Failed to send synchronizecache10 command. %s", iscsi_get_error(VAR_3)); qemu_aio_release(acb); return NULL; } iscsi_set_events(iscsilun); return &acb->common; }
[ "FUNC_0(BlockDriverState *VAR_0,\nBlockDriverCompletionFunc *VAR_1, void *VAR_2)\n{", "IscsiLun *iscsilun = VAR_0->VAR_2;", "struct iscsi_context *VAR_3 = iscsilun->VAR_3;", "IscsiAIOCB *acb;", "acb = qemu_aio_get(&iscsi_aiocb_info, VAR_0, VAR_1, VAR_2);", "acb->iscsilun = iscsilun;", "acb->canceled = 0;", "acb->bh = NULL;", "acb->status = -EINPROGRESS;", "acb->buf = NULL;", "acb->task = iscsi_synchronizecache10_task(VAR_3, iscsilun->lun,\n0, 0, 0, 0,\niscsi_synccache10_cb,\nacb);", "if (acb->task == NULL) {", "error_report(\"iSCSI: Failed to send synchronizecache10 command. %s\",\niscsi_get_error(VAR_3));", "qemu_aio_release(acb);", "return NULL;", "}", "iscsi_set_events(iscsilun);", "return &acb->common;", "}" ]
[ 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 ], [ 25 ], [ 27 ], [ 31, 33, 35, 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 57 ], [ 59 ] ]
20,215
void qmp_blockdev_change_medium(bool has_device, const char *device, bool has_id, const char *id, const char *filename, bool has_format, const char *format, bool has_read_only, BlockdevChangeReadOnlyMode read_only, Error **errp) { BlockBackend *blk; BlockDriverState *medium_bs = NULL; int bdrv_flags; int rc; QDict *options = NULL; Error *err = NULL; blk = qmp_get_blk(has_device ? device : NULL, has_id ? id : NULL, errp); if (!blk) { goto fail; } if (blk_bs(blk)) { blk_update_root_state(blk); } bdrv_flags = blk_get_open_flags_from_root_state(blk); bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_PROTOCOL); if (!has_read_only) { read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; } switch (read_only) { case BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN: break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_ONLY: bdrv_flags &= ~BDRV_O_RDWR; break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_WRITE: bdrv_flags |= BDRV_O_RDWR; break; default: abort(); } if (has_format) { options = qdict_new(); qdict_put(options, "driver", qstring_from_str(format)); } medium_bs = bdrv_open(filename, NULL, options, bdrv_flags, errp); if (!medium_bs) { goto fail; } bdrv_add_key(medium_bs, NULL, &err); if (err) { error_propagate(errp, err); goto fail; } rc = do_open_tray(has_device ? device : NULL, has_id ? id : NULL, false, &err); if (rc && rc != -ENOSYS) { error_propagate(errp, err); goto fail; } error_free(err); err = NULL; qmp_x_blockdev_remove_medium(has_device, device, has_id, id, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_blockdev_insert_anon_medium(blk, medium_bs, &err); if (err) { error_propagate(errp, err); goto fail; } blk_apply_root_state(blk, medium_bs); qmp_blockdev_close_tray(has_device, device, has_id, id, errp); fail: /* If the medium has been inserted, the device has its own reference, so * ours must be relinquished; and if it has not been inserted successfully, * the reference must be relinquished anyway */ bdrv_unref(medium_bs); }
false
qemu
b85114f8cfbede8b153db68875973ef0790bf296
void qmp_blockdev_change_medium(bool has_device, const char *device, bool has_id, const char *id, const char *filename, bool has_format, const char *format, bool has_read_only, BlockdevChangeReadOnlyMode read_only, Error **errp) { BlockBackend *blk; BlockDriverState *medium_bs = NULL; int bdrv_flags; int rc; QDict *options = NULL; Error *err = NULL; blk = qmp_get_blk(has_device ? device : NULL, has_id ? id : NULL, errp); if (!blk) { goto fail; } if (blk_bs(blk)) { blk_update_root_state(blk); } bdrv_flags = blk_get_open_flags_from_root_state(blk); bdrv_flags &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_PROTOCOL); if (!has_read_only) { read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; } switch (read_only) { case BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN: break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_ONLY: bdrv_flags &= ~BDRV_O_RDWR; break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_WRITE: bdrv_flags |= BDRV_O_RDWR; break; default: abort(); } if (has_format) { options = qdict_new(); qdict_put(options, "driver", qstring_from_str(format)); } medium_bs = bdrv_open(filename, NULL, options, bdrv_flags, errp); if (!medium_bs) { goto fail; } bdrv_add_key(medium_bs, NULL, &err); if (err) { error_propagate(errp, err); goto fail; } rc = do_open_tray(has_device ? device : NULL, has_id ? id : NULL, false, &err); if (rc && rc != -ENOSYS) { error_propagate(errp, err); goto fail; } error_free(err); err = NULL; qmp_x_blockdev_remove_medium(has_device, device, has_id, id, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_blockdev_insert_anon_medium(blk, medium_bs, &err); if (err) { error_propagate(errp, err); goto fail; } blk_apply_root_state(blk, medium_bs); qmp_blockdev_close_tray(has_device, device, has_id, id, errp); fail: bdrv_unref(medium_bs); }
{ "code": [], "line_no": [] }
void FUNC_0(bool VAR_0, const char *VAR_1, bool VAR_2, const char *VAR_3, const char *VAR_4, bool VAR_5, const char *VAR_6, bool VAR_7, BlockdevChangeReadOnlyMode VAR_8, Error **VAR_9) { BlockBackend *blk; BlockDriverState *medium_bs = NULL; int VAR_10; int VAR_11; QDict *options = NULL; Error *err = NULL; blk = qmp_get_blk(VAR_0 ? VAR_1 : NULL, VAR_2 ? VAR_3 : NULL, VAR_9); if (!blk) { goto fail; } if (blk_bs(blk)) { blk_update_root_state(blk); } VAR_10 = blk_get_open_flags_from_root_state(blk); VAR_10 &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING | BDRV_O_PROTOCOL); if (!VAR_7) { VAR_8 = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; } switch (VAR_8) { case BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN: break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_ONLY: VAR_10 &= ~BDRV_O_RDWR; break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_WRITE: VAR_10 |= BDRV_O_RDWR; break; default: abort(); } if (VAR_5) { options = qdict_new(); qdict_put(options, "driver", qstring_from_str(VAR_6)); } medium_bs = bdrv_open(VAR_4, NULL, options, VAR_10, VAR_9); if (!medium_bs) { goto fail; } bdrv_add_key(medium_bs, NULL, &err); if (err) { error_propagate(VAR_9, err); goto fail; } VAR_11 = do_open_tray(VAR_0 ? VAR_1 : NULL, VAR_2 ? VAR_3 : NULL, false, &err); if (VAR_11 && VAR_11 != -ENOSYS) { error_propagate(VAR_9, err); goto fail; } error_free(err); err = NULL; qmp_x_blockdev_remove_medium(VAR_0, VAR_1, VAR_2, VAR_3, &err); if (err) { error_propagate(VAR_9, err); goto fail; } qmp_blockdev_insert_anon_medium(blk, medium_bs, &err); if (err) { error_propagate(VAR_9, err); goto fail; } blk_apply_root_state(blk, medium_bs); qmp_blockdev_close_tray(VAR_0, VAR_1, VAR_2, VAR_3, VAR_9); fail: bdrv_unref(medium_bs); }
[ "void FUNC_0(bool VAR_0, const char *VAR_1,\nbool VAR_2, const char *VAR_3,\nconst char *VAR_4,\nbool VAR_5, const char *VAR_6,\nbool VAR_7,\nBlockdevChangeReadOnlyMode VAR_8,\nError **VAR_9)\n{", "BlockBackend *blk;", "BlockDriverState *medium_bs = NULL;", "int VAR_10;", "int VAR_11;", "QDict *options = NULL;", "Error *err = NULL;", "blk = qmp_get_blk(VAR_0 ? VAR_1 : NULL,\nVAR_2 ? VAR_3 : NULL,\nVAR_9);", "if (!blk) {", "goto fail;", "}", "if (blk_bs(blk)) {", "blk_update_root_state(blk);", "}", "VAR_10 = blk_get_open_flags_from_root_state(blk);", "VAR_10 &= ~(BDRV_O_TEMPORARY | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING |\nBDRV_O_PROTOCOL);", "if (!VAR_7) {", "VAR_8 = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN;", "}", "switch (VAR_8) {", "case BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN:\nbreak;", "case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_ONLY:\nVAR_10 &= ~BDRV_O_RDWR;", "break;", "case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_WRITE:\nVAR_10 |= BDRV_O_RDWR;", "break;", "default:\nabort();", "}", "if (VAR_5) {", "options = qdict_new();", "qdict_put(options, \"driver\", qstring_from_str(VAR_6));", "}", "medium_bs = bdrv_open(VAR_4, NULL, options, VAR_10, VAR_9);", "if (!medium_bs) {", "goto fail;", "}", "bdrv_add_key(medium_bs, NULL, &err);", "if (err) {", "error_propagate(VAR_9, err);", "goto fail;", "}", "VAR_11 = do_open_tray(VAR_0 ? VAR_1 : NULL,\nVAR_2 ? VAR_3 : NULL,\nfalse, &err);", "if (VAR_11 && VAR_11 != -ENOSYS) {", "error_propagate(VAR_9, err);", "goto fail;", "}", "error_free(err);", "err = NULL;", "qmp_x_blockdev_remove_medium(VAR_0, VAR_1, VAR_2, VAR_3, &err);", "if (err) {", "error_propagate(VAR_9, err);", "goto fail;", "}", "qmp_blockdev_insert_anon_medium(blk, medium_bs, &err);", "if (err) {", "error_propagate(VAR_9, err);", "goto fail;", "}", "blk_apply_root_state(blk, medium_bs);", "qmp_blockdev_close_tray(VAR_0, VAR_1, VAR_2, VAR_3, VAR_9);", "fail:\nbdrv_unref(medium_bs);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55, 57 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71, 73 ], [ 77, 79 ], [ 81 ], [ 85, 87 ], [ 89 ], [ 93, 95 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133, 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 181 ], [ 185, 193 ], [ 195 ] ]
20,216
int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) { CPUS390XState *env = &cpu->env; uint64_t offset, data; S390PCIBusDevice *pbdev; uint8_t len; uint32_t fh; uint8_t pcias; cpu_synchronize_state(CPU(cpu)); if (env->psw.mask & PSW_MASK_PSTATE) { program_interrupt(env, PGM_PRIVILEGED, 4); return 0; } if (r2 & 0x1) { program_interrupt(env, PGM_SPECIFICATION, 4); return 0; } fh = env->regs[r2] >> 32; pcias = (env->regs[r2] >> 16) & 0xf; len = env->regs[r2] & 0xf; offset = env->regs[r2 + 1]; pbdev = s390_pci_find_dev_by_fh(fh); if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) { DPRINTF("pcistg no pci dev\n"); setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE); return 0; } if (pbdev->lgstg_blocked) { setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r2, ZPCI_PCI_ST_BLOCKED); return 0; } data = env->regs[r1]; if (pcias < 6) { if ((8 - (offset & 0x7)) < len) { program_interrupt(env, PGM_OPERAND, 4); return 0; } MemoryRegion *mr; if (trap_msix(pbdev, offset, pcias)) { offset = offset - pbdev->msix.table_offset; mr = &pbdev->pdev->msix_table_mmio; update_msix_table_msg_data(pbdev, offset, &data, len); } else { mr = pbdev->pdev->io_regions[pcias].memory; } memory_region_dispatch_write(mr, offset, data, len, MEMTXATTRS_UNSPECIFIED); } else if (pcias == 15) { if ((4 - (offset & 0x3)) < len) { program_interrupt(env, PGM_OPERAND, 4); return 0; } switch (len) { case 1: break; case 2: data = bswap16(data); break; case 4: data = bswap32(data); break; case 8: data = bswap64(data); break; default: program_interrupt(env, PGM_OPERAND, 4); return 0; } pci_host_config_write_common(pbdev->pdev, offset, pci_config_size(pbdev->pdev), data, len); } else { DPRINTF("pcistg invalid space\n"); setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r2, ZPCI_PCI_ST_INVAL_AS); return 0; } setcc(cpu, ZPCI_PCI_LS_OK); return 0; }
false
qemu
5d1abf234462d13bef3617cc2c55b6815703ddf2
int pcistg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2) { CPUS390XState *env = &cpu->env; uint64_t offset, data; S390PCIBusDevice *pbdev; uint8_t len; uint32_t fh; uint8_t pcias; cpu_synchronize_state(CPU(cpu)); if (env->psw.mask & PSW_MASK_PSTATE) { program_interrupt(env, PGM_PRIVILEGED, 4); return 0; } if (r2 & 0x1) { program_interrupt(env, PGM_SPECIFICATION, 4); return 0; } fh = env->regs[r2] >> 32; pcias = (env->regs[r2] >> 16) & 0xf; len = env->regs[r2] & 0xf; offset = env->regs[r2 + 1]; pbdev = s390_pci_find_dev_by_fh(fh); if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) { DPRINTF("pcistg no pci dev\n"); setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE); return 0; } if (pbdev->lgstg_blocked) { setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r2, ZPCI_PCI_ST_BLOCKED); return 0; } data = env->regs[r1]; if (pcias < 6) { if ((8 - (offset & 0x7)) < len) { program_interrupt(env, PGM_OPERAND, 4); return 0; } MemoryRegion *mr; if (trap_msix(pbdev, offset, pcias)) { offset = offset - pbdev->msix.table_offset; mr = &pbdev->pdev->msix_table_mmio; update_msix_table_msg_data(pbdev, offset, &data, len); } else { mr = pbdev->pdev->io_regions[pcias].memory; } memory_region_dispatch_write(mr, offset, data, len, MEMTXATTRS_UNSPECIFIED); } else if (pcias == 15) { if ((4 - (offset & 0x3)) < len) { program_interrupt(env, PGM_OPERAND, 4); return 0; } switch (len) { case 1: break; case 2: data = bswap16(data); break; case 4: data = bswap32(data); break; case 8: data = bswap64(data); break; default: program_interrupt(env, PGM_OPERAND, 4); return 0; } pci_host_config_write_common(pbdev->pdev, offset, pci_config_size(pbdev->pdev), data, len); } else { DPRINTF("pcistg invalid space\n"); setcc(cpu, ZPCI_PCI_LS_ERR); s390_set_status_code(env, r2, ZPCI_PCI_ST_INVAL_AS); return 0; } setcc(cpu, ZPCI_PCI_LS_OK); return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint8_t VAR_2) { CPUS390XState *env = &VAR_0->env; uint64_t offset, data; S390PCIBusDevice *pbdev; uint8_t len; uint32_t fh; uint8_t pcias; cpu_synchronize_state(CPU(VAR_0)); if (env->psw.mask & PSW_MASK_PSTATE) { program_interrupt(env, PGM_PRIVILEGED, 4); return 0; } if (VAR_2 & 0x1) { program_interrupt(env, PGM_SPECIFICATION, 4); return 0; } fh = env->regs[VAR_2] >> 32; pcias = (env->regs[VAR_2] >> 16) & 0xf; len = env->regs[VAR_2] & 0xf; offset = env->regs[VAR_2 + 1]; pbdev = s390_pci_find_dev_by_fh(fh); if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) { DPRINTF("pcistg no pci dev\n"); setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE); return 0; } if (pbdev->lgstg_blocked) { setcc(VAR_0, ZPCI_PCI_LS_ERR); s390_set_status_code(env, VAR_2, ZPCI_PCI_ST_BLOCKED); return 0; } data = env->regs[VAR_1]; if (pcias < 6) { if ((8 - (offset & 0x7)) < len) { program_interrupt(env, PGM_OPERAND, 4); return 0; } MemoryRegion *mr; if (trap_msix(pbdev, offset, pcias)) { offset = offset - pbdev->msix.table_offset; mr = &pbdev->pdev->msix_table_mmio; update_msix_table_msg_data(pbdev, offset, &data, len); } else { mr = pbdev->pdev->io_regions[pcias].memory; } memory_region_dispatch_write(mr, offset, data, len, MEMTXATTRS_UNSPECIFIED); } else if (pcias == 15) { if ((4 - (offset & 0x3)) < len) { program_interrupt(env, PGM_OPERAND, 4); return 0; } switch (len) { case 1: break; case 2: data = bswap16(data); break; case 4: data = bswap32(data); break; case 8: data = bswap64(data); break; default: program_interrupt(env, PGM_OPERAND, 4); return 0; } pci_host_config_write_common(pbdev->pdev, offset, pci_config_size(pbdev->pdev), data, len); } else { DPRINTF("pcistg invalid space\n"); setcc(VAR_0, ZPCI_PCI_LS_ERR); s390_set_status_code(env, VAR_2, ZPCI_PCI_ST_INVAL_AS); return 0; } setcc(VAR_0, ZPCI_PCI_LS_OK); return 0; }
[ "int FUNC_0(S390CPU *VAR_0, uint8_t VAR_1, uint8_t VAR_2)\n{", "CPUS390XState *env = &VAR_0->env;", "uint64_t offset, data;", "S390PCIBusDevice *pbdev;", "uint8_t len;", "uint32_t fh;", "uint8_t pcias;", "cpu_synchronize_state(CPU(VAR_0));", "if (env->psw.mask & PSW_MASK_PSTATE) {", "program_interrupt(env, PGM_PRIVILEGED, 4);", "return 0;", "}", "if (VAR_2 & 0x1) {", "program_interrupt(env, PGM_SPECIFICATION, 4);", "return 0;", "}", "fh = env->regs[VAR_2] >> 32;", "pcias = (env->regs[VAR_2] >> 16) & 0xf;", "len = env->regs[VAR_2] & 0xf;", "offset = env->regs[VAR_2 + 1];", "pbdev = s390_pci_find_dev_by_fh(fh);", "if (!pbdev || !(pbdev->fh & FH_MASK_ENABLE)) {", "DPRINTF(\"pcistg no pci dev\\n\");", "setcc(VAR_0, ZPCI_PCI_LS_INVAL_HANDLE);", "return 0;", "}", "if (pbdev->lgstg_blocked) {", "setcc(VAR_0, ZPCI_PCI_LS_ERR);", "s390_set_status_code(env, VAR_2, ZPCI_PCI_ST_BLOCKED);", "return 0;", "}", "data = env->regs[VAR_1];", "if (pcias < 6) {", "if ((8 - (offset & 0x7)) < len) {", "program_interrupt(env, PGM_OPERAND, 4);", "return 0;", "}", "MemoryRegion *mr;", "if (trap_msix(pbdev, offset, pcias)) {", "offset = offset - pbdev->msix.table_offset;", "mr = &pbdev->pdev->msix_table_mmio;", "update_msix_table_msg_data(pbdev, offset, &data, len);", "} else {", "mr = pbdev->pdev->io_regions[pcias].memory;", "}", "memory_region_dispatch_write(mr, offset, data, len,\nMEMTXATTRS_UNSPECIFIED);", "} else if (pcias == 15) {", "if ((4 - (offset & 0x3)) < len) {", "program_interrupt(env, PGM_OPERAND, 4);", "return 0;", "}", "switch (len) {", "case 1:\nbreak;", "case 2:\ndata = bswap16(data);", "break;", "case 4:\ndata = bswap32(data);", "break;", "case 8:\ndata = bswap64(data);", "break;", "default:\nprogram_interrupt(env, PGM_OPERAND, 4);", "return 0;", "}", "pci_host_config_write_common(pbdev->pdev, offset,\npci_config_size(pbdev->pdev),\ndata, len);", "} else {", "DPRINTF(\"pcistg invalid space\\n\");", "setcc(VAR_0, ZPCI_PCI_LS_ERR);", "s390_set_status_code(env, VAR_2, ZPCI_PCI_ST_INVAL_AS);", "return 0;", "}", "setcc(VAR_0, ZPCI_PCI_LS_OK);", "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 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125, 127 ], [ 129, 131 ], [ 133 ], [ 135, 137 ], [ 139 ], [ 141, 143 ], [ 145 ], [ 147, 149 ], [ 151 ], [ 153 ], [ 157, 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181 ] ]
20,217
static int kvm_put_msrs(CPUState *env, int level) { struct { struct kvm_msrs info; struct kvm_msr_entry entries[100]; } msr_data; struct kvm_msr_entry *msrs = msr_data.entries; int n = 0; kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_CS, env->sysenter_cs); kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_ESP, env->sysenter_esp); kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_EIP, env->sysenter_eip); if (kvm_has_msr_star(env)) kvm_msr_entry_set(&msrs[n++], MSR_STAR, env->star); if (kvm_has_msr_hsave_pa(env)) kvm_msr_entry_set(&msrs[n++], MSR_VM_HSAVE_PA, env->vm_hsave); #ifdef TARGET_X86_64 if (lm_capable_kernel) { kvm_msr_entry_set(&msrs[n++], MSR_CSTAR, env->cstar); kvm_msr_entry_set(&msrs[n++], MSR_KERNELGSBASE, env->kernelgsbase); kvm_msr_entry_set(&msrs[n++], MSR_FMASK, env->fmask); kvm_msr_entry_set(&msrs[n++], MSR_LSTAR, env->lstar); } #endif if (level == KVM_PUT_FULL_STATE) { /* * KVM is yet unable to synchronize TSC values of multiple VCPUs on * writeback. Until this is fixed, we only write the offset to SMP * guests after migration, desynchronizing the VCPUs, but avoiding * huge jump-backs that would occur without any writeback at all. */ if (smp_cpus == 1 || env->tsc != 0) { kvm_msr_entry_set(&msrs[n++], MSR_IA32_TSC, env->tsc); } kvm_msr_entry_set(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr); kvm_msr_entry_set(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr); #ifdef KVM_CAP_ASYNC_PF kvm_msr_entry_set(&msrs[n++], MSR_KVM_ASYNC_PF_EN, env->async_pf_en_msr); #endif } #ifdef KVM_CAP_MCE if (env->mcg_cap) { int i; if (level == KVM_PUT_RESET_STATE) kvm_msr_entry_set(&msrs[n++], MSR_MCG_STATUS, env->mcg_status); else if (level == KVM_PUT_FULL_STATE) { kvm_msr_entry_set(&msrs[n++], MSR_MCG_STATUS, env->mcg_status); kvm_msr_entry_set(&msrs[n++], MSR_MCG_CTL, env->mcg_ctl); for (i = 0; i < (env->mcg_cap & 0xff) * 4; i++) kvm_msr_entry_set(&msrs[n++], MSR_MC0_CTL + i, env->mce_banks[i]); } } #endif msr_data.info.nmsrs = n; return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &msr_data); }
false
qemu
b9bec74bcb16519a876ec21cd5277c526a9b512d
static int kvm_put_msrs(CPUState *env, int level) { struct { struct kvm_msrs info; struct kvm_msr_entry entries[100]; } msr_data; struct kvm_msr_entry *msrs = msr_data.entries; int n = 0; kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_CS, env->sysenter_cs); kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_ESP, env->sysenter_esp); kvm_msr_entry_set(&msrs[n++], MSR_IA32_SYSENTER_EIP, env->sysenter_eip); if (kvm_has_msr_star(env)) kvm_msr_entry_set(&msrs[n++], MSR_STAR, env->star); if (kvm_has_msr_hsave_pa(env)) kvm_msr_entry_set(&msrs[n++], MSR_VM_HSAVE_PA, env->vm_hsave); #ifdef TARGET_X86_64 if (lm_capable_kernel) { kvm_msr_entry_set(&msrs[n++], MSR_CSTAR, env->cstar); kvm_msr_entry_set(&msrs[n++], MSR_KERNELGSBASE, env->kernelgsbase); kvm_msr_entry_set(&msrs[n++], MSR_FMASK, env->fmask); kvm_msr_entry_set(&msrs[n++], MSR_LSTAR, env->lstar); } #endif if (level == KVM_PUT_FULL_STATE) { if (smp_cpus == 1 || env->tsc != 0) { kvm_msr_entry_set(&msrs[n++], MSR_IA32_TSC, env->tsc); } kvm_msr_entry_set(&msrs[n++], MSR_KVM_SYSTEM_TIME, env->system_time_msr); kvm_msr_entry_set(&msrs[n++], MSR_KVM_WALL_CLOCK, env->wall_clock_msr); #ifdef KVM_CAP_ASYNC_PF kvm_msr_entry_set(&msrs[n++], MSR_KVM_ASYNC_PF_EN, env->async_pf_en_msr); #endif } #ifdef KVM_CAP_MCE if (env->mcg_cap) { int i; if (level == KVM_PUT_RESET_STATE) kvm_msr_entry_set(&msrs[n++], MSR_MCG_STATUS, env->mcg_status); else if (level == KVM_PUT_FULL_STATE) { kvm_msr_entry_set(&msrs[n++], MSR_MCG_STATUS, env->mcg_status); kvm_msr_entry_set(&msrs[n++], MSR_MCG_CTL, env->mcg_ctl); for (i = 0; i < (env->mcg_cap & 0xff) * 4; i++) kvm_msr_entry_set(&msrs[n++], MSR_MC0_CTL + i, env->mce_banks[i]); } } #endif msr_data.info.nmsrs = n; return kvm_vcpu_ioctl(env, KVM_SET_MSRS, &msr_data); }
{ "code": [], "line_no": [] }
static int FUNC_0(CPUState *VAR_0, int VAR_1) { struct { struct kvm_msrs info; struct kvm_msr_entry entries[100]; } VAR_2; struct kvm_msr_entry *VAR_3 = VAR_2.entries; int VAR_4 = 0; kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_IA32_SYSENTER_CS, VAR_0->sysenter_cs); kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_IA32_SYSENTER_ESP, VAR_0->sysenter_esp); kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_IA32_SYSENTER_EIP, VAR_0->sysenter_eip); if (kvm_has_msr_star(VAR_0)) kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_STAR, VAR_0->star); if (kvm_has_msr_hsave_pa(VAR_0)) kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_VM_HSAVE_PA, VAR_0->vm_hsave); #ifdef TARGET_X86_64 if (lm_capable_kernel) { kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_CSTAR, VAR_0->cstar); kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_KERNELGSBASE, VAR_0->kernelgsbase); kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_FMASK, VAR_0->fmask); kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_LSTAR, VAR_0->lstar); } #endif if (VAR_1 == KVM_PUT_FULL_STATE) { if (smp_cpus == 1 || VAR_0->tsc != 0) { kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_IA32_TSC, VAR_0->tsc); } kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_KVM_SYSTEM_TIME, VAR_0->system_time_msr); kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_KVM_WALL_CLOCK, VAR_0->wall_clock_msr); #ifdef KVM_CAP_ASYNC_PF kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_KVM_ASYNC_PF_EN, VAR_0->async_pf_en_msr); #endif } #ifdef KVM_CAP_MCE if (VAR_0->mcg_cap) { int i; if (VAR_1 == KVM_PUT_RESET_STATE) kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_MCG_STATUS, VAR_0->mcg_status); else if (VAR_1 == KVM_PUT_FULL_STATE) { kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_MCG_STATUS, VAR_0->mcg_status); kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_MCG_CTL, VAR_0->mcg_ctl); for (i = 0; i < (VAR_0->mcg_cap & 0xff) * 4; i++) kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_MC0_CTL + i, VAR_0->mce_banks[i]); } } #endif VAR_2.info.nmsrs = VAR_4; return kvm_vcpu_ioctl(VAR_0, KVM_SET_MSRS, &VAR_2); }
[ "static int FUNC_0(CPUState *VAR_0, int VAR_1)\n{", "struct {", "struct kvm_msrs info;", "struct kvm_msr_entry entries[100];", "} VAR_2;", "struct kvm_msr_entry *VAR_3 = VAR_2.entries;", "int VAR_4 = 0;", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_IA32_SYSENTER_CS, VAR_0->sysenter_cs);", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_IA32_SYSENTER_ESP, VAR_0->sysenter_esp);", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_IA32_SYSENTER_EIP, VAR_0->sysenter_eip);", "if (kvm_has_msr_star(VAR_0))\nkvm_msr_entry_set(&VAR_3[VAR_4++], MSR_STAR, VAR_0->star);", "if (kvm_has_msr_hsave_pa(VAR_0))\nkvm_msr_entry_set(&VAR_3[VAR_4++], MSR_VM_HSAVE_PA, VAR_0->vm_hsave);", "#ifdef TARGET_X86_64\nif (lm_capable_kernel) {", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_CSTAR, VAR_0->cstar);", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_KERNELGSBASE, VAR_0->kernelgsbase);", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_FMASK, VAR_0->fmask);", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_LSTAR, VAR_0->lstar);", "}", "#endif\nif (VAR_1 == KVM_PUT_FULL_STATE) {", "if (smp_cpus == 1 || VAR_0->tsc != 0) {", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_IA32_TSC, VAR_0->tsc);", "}", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_KVM_SYSTEM_TIME,\nVAR_0->system_time_msr);", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_KVM_WALL_CLOCK, VAR_0->wall_clock_msr);", "#ifdef KVM_CAP_ASYNC_PF\nkvm_msr_entry_set(&VAR_3[VAR_4++], MSR_KVM_ASYNC_PF_EN, VAR_0->async_pf_en_msr);", "#endif\n}", "#ifdef KVM_CAP_MCE\nif (VAR_0->mcg_cap) {", "int i;", "if (VAR_1 == KVM_PUT_RESET_STATE)\nkvm_msr_entry_set(&VAR_3[VAR_4++], MSR_MCG_STATUS, VAR_0->mcg_status);", "else if (VAR_1 == KVM_PUT_FULL_STATE) {", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_MCG_STATUS, VAR_0->mcg_status);", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_MCG_CTL, VAR_0->mcg_ctl);", "for (i = 0; i < (VAR_0->mcg_cap & 0xff) * 4; i++)", "kvm_msr_entry_set(&VAR_3[VAR_4++], MSR_MC0_CTL + i, VAR_0->mce_banks[i]);", "}", "}", "#endif\nVAR_2.info.nmsrs = VAR_4;", "return kvm_vcpu_ioctl(VAR_0, KVM_SET_MSRS, &VAR_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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29, 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 63 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75, 77 ], [ 79, 81 ], [ 83, 85 ], [ 87 ], [ 89, 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 111 ], [ 115 ], [ 119 ] ]
20,218
static void scsi_block_realize(SCSIDevice *dev, Error **errp) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); int sg_version; int rc; if (!s->qdev.conf.bs) { error_setg(errp, "drive property not set"); return; } /* check we are using a driver managing SG_IO (version 3 and after) */ rc = bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version); if (rc < 0) { error_setg(errp, "cannot get SG_IO version number: %s. " "Is this a SCSI device?", strerror(-rc)); return; } if (sg_version < 30000) { error_setg(errp, "scsi generic interface too old"); return; } /* get device type from INQUIRY data */ rc = get_device_type(s); if (rc < 0) { error_setg(errp, "INQUIRY failed"); return; } /* Make a guess for the block size, we'll fix it when the guest sends. * READ CAPACITY. If they don't, they likely would assume these sizes * anyway. (TODO: check in /sys). */ if (s->qdev.type == TYPE_ROM || s->qdev.type == TYPE_WORM) { s->qdev.blocksize = 2048; } else { s->qdev.blocksize = 512; } /* Makes the scsi-block device not removable by using HMP and QMP eject * command. */ s->features |= (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS); scsi_realize(&s->qdev, errp); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static void scsi_block_realize(SCSIDevice *dev, Error **errp) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); int sg_version; int rc; if (!s->qdev.conf.bs) { error_setg(errp, "drive property not set"); return; } rc = bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &sg_version); if (rc < 0) { error_setg(errp, "cannot get SG_IO version number: %s. " "Is this a SCSI device?", strerror(-rc)); return; } if (sg_version < 30000) { error_setg(errp, "scsi generic interface too old"); return; } rc = get_device_type(s); if (rc < 0) { error_setg(errp, "INQUIRY failed"); return; } if (s->qdev.type == TYPE_ROM || s->qdev.type == TYPE_WORM) { s->qdev.blocksize = 2048; } else { s->qdev.blocksize = 512; } s->features |= (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS); scsi_realize(&s->qdev, errp); }
{ "code": [], "line_no": [] }
static void FUNC_0(SCSIDevice *VAR_0, Error **VAR_1) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0); int VAR_2; int VAR_3; if (!s->qdev.conf.bs) { error_setg(VAR_1, "drive property not set"); return; } VAR_3 = bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &VAR_2); if (VAR_3 < 0) { error_setg(VAR_1, "cannot get SG_IO version number: %s. " "Is this a SCSI device?", strerror(-VAR_3)); return; } if (VAR_2 < 30000) { error_setg(VAR_1, "scsi generic interface too old"); return; } VAR_3 = get_device_type(s); if (VAR_3 < 0) { error_setg(VAR_1, "INQUIRY failed"); return; } if (s->qdev.type == TYPE_ROM || s->qdev.type == TYPE_WORM) { s->qdev.blocksize = 2048; } else { s->qdev.blocksize = 512; } s->features |= (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS); scsi_realize(&s->qdev, VAR_1); }
[ "static void FUNC_0(SCSIDevice *VAR_0, Error **VAR_1)\n{", "SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0);", "int VAR_2;", "int VAR_3;", "if (!s->qdev.conf.bs) {", "error_setg(VAR_1, \"drive property not set\");", "return;", "}", "VAR_3 = bdrv_ioctl(s->qdev.conf.bs, SG_GET_VERSION_NUM, &VAR_2);", "if (VAR_3 < 0) {", "error_setg(VAR_1, \"cannot get SG_IO version number: %s. \"\n\"Is this a SCSI device?\",\nstrerror(-VAR_3));", "return;", "}", "if (VAR_2 < 30000) {", "error_setg(VAR_1, \"scsi generic interface too old\");", "return;", "}", "VAR_3 = get_device_type(s);", "if (VAR_3 < 0) {", "error_setg(VAR_1, \"INQUIRY failed\");", "return;", "}", "if (s->qdev.type == TYPE_ROM || s->qdev.type == TYPE_WORM) {", "s->qdev.blocksize = 2048;", "} else {", "s->qdev.blocksize = 512;", "}", "s->features |= (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS);", "scsi_realize(&s->qdev, VAR_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 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 25 ], [ 27 ], [ 29, 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 89 ], [ 93 ], [ 95 ] ]
20,219
static void init_proc_460 (CPUPPCState *env) { /* Time base */ gen_tbl(env); gen_spr_BookE(env); gen_spr_440(env); spr_register(env, SPR_BOOKE_MCSR, "MCSR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_440_CCR1, "CCR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_DCRIPR, "SPR_DCRIPR", &spr_read_generic, &spr_write_generic, &spr_read_generic, &spr_write_generic, 0x00000000); /* Memory management */ env->nb_tlb = 64; env->nb_ways = 1; env->id_tlbs = 0; /* XXX: TODO: allocate internal IRQ controller */ }
false
qemu
e1833e1f96456fd8fc17463246fe0b2050e68efb
static void init_proc_460 (CPUPPCState *env) { gen_tbl(env); gen_spr_BookE(env); gen_spr_440(env); spr_register(env, SPR_BOOKE_MCSR, "MCSR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_440_CCR1, "CCR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(env, SPR_DCRIPR, "SPR_DCRIPR", &spr_read_generic, &spr_write_generic, &spr_read_generic, &spr_write_generic, 0x00000000); env->nb_tlb = 64; env->nb_ways = 1; env->id_tlbs = 0; }
{ "code": [], "line_no": [] }
static void FUNC_0 (CPUPPCState *VAR_0) { gen_tbl(VAR_0); gen_spr_BookE(VAR_0); gen_spr_440(VAR_0); spr_register(VAR_0, SPR_BOOKE_MCSR, "MCSR", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(VAR_0, SPR_BOOKE_MCSRR0, "MCSRR0", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(VAR_0, SPR_BOOKE_MCSRR1, "MCSRR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(VAR_0, SPR_440_CCR1, "CCR1", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, 0x00000000); spr_register(VAR_0, SPR_DCRIPR, "SPR_DCRIPR", &spr_read_generic, &spr_write_generic, &spr_read_generic, &spr_write_generic, 0x00000000); VAR_0->nb_tlb = 64; VAR_0->nb_ways = 1; VAR_0->id_tlbs = 0; }
[ "static void FUNC_0 (CPUPPCState *VAR_0)\n{", "gen_tbl(VAR_0);", "gen_spr_BookE(VAR_0);", "gen_spr_440(VAR_0);", "spr_register(VAR_0, SPR_BOOKE_MCSR, \"MCSR\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "spr_register(VAR_0, SPR_BOOKE_MCSRR0, \"MCSRR0\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "spr_register(VAR_0, SPR_BOOKE_MCSRR1, \"MCSRR1\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "spr_register(VAR_0, SPR_440_CCR1, \"CCR1\",\nSPR_NOACCESS, SPR_NOACCESS,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "spr_register(VAR_0, SPR_DCRIPR, \"SPR_DCRIPR\",\n&spr_read_generic, &spr_write_generic,\n&spr_read_generic, &spr_write_generic,\n0x00000000);", "VAR_0->nb_tlb = 64;", "VAR_0->nb_ways = 1;", "VAR_0->id_tlbs = 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 7 ], [ 9 ], [ 11 ], [ 13, 15, 17, 19 ], [ 21, 23, 25, 27 ], [ 29, 31, 33, 35 ], [ 37, 39, 41, 43 ], [ 45, 47, 49, 51 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ] ]
20,220
static int xen_pt_status_reg_init(XenPCIPassthroughState *s, XenPTRegInfo *reg, uint32_t real_offset, uint32_t *data) { XenPTRegGroup *reg_grp_entry = NULL; XenPTReg *reg_entry = NULL; uint32_t reg_field = 0; /* find Header register group */ reg_grp_entry = xen_pt_find_reg_grp(s, PCI_CAPABILITY_LIST); if (reg_grp_entry) { /* find Capabilities Pointer register */ reg_entry = xen_pt_find_reg(reg_grp_entry, PCI_CAPABILITY_LIST); if (reg_entry) { /* check Capabilities Pointer register */ if (reg_entry->data) { reg_field |= PCI_STATUS_CAP_LIST; } else { reg_field &= ~PCI_STATUS_CAP_LIST; } } else { xen_shutdown_fatal_error("Internal error: Couldn't find XenPTReg*" " for Capabilities Pointer register." " (%s)\n", __func__); return -1; } } else { xen_shutdown_fatal_error("Internal error: Couldn't find XenPTRegGroup" " for Header. (%s)\n", __func__); return -1; } *data = reg_field; return 0; }
false
qemu
e2779de053b64f023de382fd87b3596613d47d1e
static int xen_pt_status_reg_init(XenPCIPassthroughState *s, XenPTRegInfo *reg, uint32_t real_offset, uint32_t *data) { XenPTRegGroup *reg_grp_entry = NULL; XenPTReg *reg_entry = NULL; uint32_t reg_field = 0; reg_grp_entry = xen_pt_find_reg_grp(s, PCI_CAPABILITY_LIST); if (reg_grp_entry) { reg_entry = xen_pt_find_reg(reg_grp_entry, PCI_CAPABILITY_LIST); if (reg_entry) { if (reg_entry->data) { reg_field |= PCI_STATUS_CAP_LIST; } else { reg_field &= ~PCI_STATUS_CAP_LIST; } } else { xen_shutdown_fatal_error("Internal error: Couldn't find XenPTReg*" " for Capabilities Pointer register." " (%s)\n", __func__); return -1; } } else { xen_shutdown_fatal_error("Internal error: Couldn't find XenPTRegGroup" " for Header. (%s)\n", __func__); return -1; } *data = reg_field; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(XenPCIPassthroughState *VAR_0, XenPTRegInfo *VAR_1, uint32_t VAR_2, uint32_t *VAR_3) { XenPTRegGroup *reg_grp_entry = NULL; XenPTReg *reg_entry = NULL; uint32_t reg_field = 0; reg_grp_entry = xen_pt_find_reg_grp(VAR_0, PCI_CAPABILITY_LIST); if (reg_grp_entry) { reg_entry = xen_pt_find_reg(reg_grp_entry, PCI_CAPABILITY_LIST); if (reg_entry) { if (reg_entry->VAR_3) { reg_field |= PCI_STATUS_CAP_LIST; } else { reg_field &= ~PCI_STATUS_CAP_LIST; } } else { xen_shutdown_fatal_error("Internal error: Couldn't find XenPTReg*" " for Capabilities Pointer register." " (%VAR_0)\n", __func__); return -1; } } else { xen_shutdown_fatal_error("Internal error: Couldn't find XenPTRegGroup" " for Header. (%VAR_0)\n", __func__); return -1; } *VAR_3 = reg_field; return 0; }
[ "static int FUNC_0(XenPCIPassthroughState *VAR_0,\nXenPTRegInfo *VAR_1, uint32_t VAR_2,\nuint32_t *VAR_3)\n{", "XenPTRegGroup *reg_grp_entry = NULL;", "XenPTReg *reg_entry = NULL;", "uint32_t reg_field = 0;", "reg_grp_entry = xen_pt_find_reg_grp(VAR_0, PCI_CAPABILITY_LIST);", "if (reg_grp_entry) {", "reg_entry = xen_pt_find_reg(reg_grp_entry, PCI_CAPABILITY_LIST);", "if (reg_entry) {", "if (reg_entry->VAR_3) {", "reg_field |= PCI_STATUS_CAP_LIST;", "} else {", "reg_field &= ~PCI_STATUS_CAP_LIST;", "}", "} else {", "xen_shutdown_fatal_error(\"Internal error: Couldn't find XenPTReg*\"\n\" for Capabilities Pointer register.\"\n\" (%VAR_0)\\n\", __func__);", "return -1;", "}", "} else {", "xen_shutdown_fatal_error(\"Internal error: Couldn't find XenPTRegGroup\"\n\" for Header. (%VAR_0)\\n\", __func__);", "return -1;", "}", "*VAR_3 = reg_field;", "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 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ] ]
20,221
static void virtio_ccw_save_config(DeviceState *d, QEMUFile *f) { VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); CcwDevice *ccw_dev = CCW_DEVICE(d); SubchDev *s = ccw_dev->sch; VirtIODevice *vdev = virtio_ccw_get_vdev(s); subch_device_save(s, f); if (dev->indicators != NULL) { qemu_put_be32(f, dev->indicators->len); qemu_put_be64(f, dev->indicators->addr); } else { qemu_put_be32(f, 0); qemu_put_be64(f, 0UL); } if (dev->indicators2 != NULL) { qemu_put_be32(f, dev->indicators2->len); qemu_put_be64(f, dev->indicators2->addr); } else { qemu_put_be32(f, 0); qemu_put_be64(f, 0UL); } if (dev->summary_indicator != NULL) { qemu_put_be32(f, dev->summary_indicator->len); qemu_put_be64(f, dev->summary_indicator->addr); } else { qemu_put_be32(f, 0); qemu_put_be64(f, 0UL); } qemu_put_be16(f, vdev->config_vector); qemu_put_be64(f, dev->routes.adapter.ind_offset); qemu_put_byte(f, dev->thinint_isc); qemu_put_be32(f, dev->revision); }
false
qemu
517ff12c7d000fa1f5b1e989b22fb86a286f9cc2
static void virtio_ccw_save_config(DeviceState *d, QEMUFile *f) { VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); CcwDevice *ccw_dev = CCW_DEVICE(d); SubchDev *s = ccw_dev->sch; VirtIODevice *vdev = virtio_ccw_get_vdev(s); subch_device_save(s, f); if (dev->indicators != NULL) { qemu_put_be32(f, dev->indicators->len); qemu_put_be64(f, dev->indicators->addr); } else { qemu_put_be32(f, 0); qemu_put_be64(f, 0UL); } if (dev->indicators2 != NULL) { qemu_put_be32(f, dev->indicators2->len); qemu_put_be64(f, dev->indicators2->addr); } else { qemu_put_be32(f, 0); qemu_put_be64(f, 0UL); } if (dev->summary_indicator != NULL) { qemu_put_be32(f, dev->summary_indicator->len); qemu_put_be64(f, dev->summary_indicator->addr); } else { qemu_put_be32(f, 0); qemu_put_be64(f, 0UL); } qemu_put_be16(f, vdev->config_vector); qemu_put_be64(f, dev->routes.adapter.ind_offset); qemu_put_byte(f, dev->thinint_isc); qemu_put_be32(f, dev->revision); }
{ "code": [], "line_no": [] }
static void FUNC_0(DeviceState *VAR_0, QEMUFile *VAR_1) { VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(VAR_0); CcwDevice *ccw_dev = CCW_DEVICE(VAR_0); SubchDev *s = ccw_dev->sch; VirtIODevice *vdev = virtio_ccw_get_vdev(s); subch_device_save(s, VAR_1); if (dev->indicators != NULL) { qemu_put_be32(VAR_1, dev->indicators->len); qemu_put_be64(VAR_1, dev->indicators->addr); } else { qemu_put_be32(VAR_1, 0); qemu_put_be64(VAR_1, 0UL); } if (dev->indicators2 != NULL) { qemu_put_be32(VAR_1, dev->indicators2->len); qemu_put_be64(VAR_1, dev->indicators2->addr); } else { qemu_put_be32(VAR_1, 0); qemu_put_be64(VAR_1, 0UL); } if (dev->summary_indicator != NULL) { qemu_put_be32(VAR_1, dev->summary_indicator->len); qemu_put_be64(VAR_1, dev->summary_indicator->addr); } else { qemu_put_be32(VAR_1, 0); qemu_put_be64(VAR_1, 0UL); } qemu_put_be16(VAR_1, vdev->config_vector); qemu_put_be64(VAR_1, dev->routes.adapter.ind_offset); qemu_put_byte(VAR_1, dev->thinint_isc); qemu_put_be32(VAR_1, dev->revision); }
[ "static void FUNC_0(DeviceState *VAR_0, QEMUFile *VAR_1)\n{", "VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(VAR_0);", "CcwDevice *ccw_dev = CCW_DEVICE(VAR_0);", "SubchDev *s = ccw_dev->sch;", "VirtIODevice *vdev = virtio_ccw_get_vdev(s);", "subch_device_save(s, VAR_1);", "if (dev->indicators != NULL) {", "qemu_put_be32(VAR_1, dev->indicators->len);", "qemu_put_be64(VAR_1, dev->indicators->addr);", "} else {", "qemu_put_be32(VAR_1, 0);", "qemu_put_be64(VAR_1, 0UL);", "}", "if (dev->indicators2 != NULL) {", "qemu_put_be32(VAR_1, dev->indicators2->len);", "qemu_put_be64(VAR_1, dev->indicators2->addr);", "} else {", "qemu_put_be32(VAR_1, 0);", "qemu_put_be64(VAR_1, 0UL);", "}", "if (dev->summary_indicator != NULL) {", "qemu_put_be32(VAR_1, dev->summary_indicator->len);", "qemu_put_be64(VAR_1, dev->summary_indicator->addr);", "} else {", "qemu_put_be32(VAR_1, 0);", "qemu_put_be64(VAR_1, 0UL);", "}", "qemu_put_be16(VAR_1, vdev->config_vector);", "qemu_put_be64(VAR_1, dev->routes.adapter.ind_offset);", "qemu_put_byte(VAR_1, dev->thinint_isc);", "qemu_put_be32(VAR_1, dev->revision);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ] ]
20,223
static int xen_pt_register_regions(XenPCIPassthroughState *s) { int i = 0; XenHostPCIDevice *d = &s->real_device; /* Register PIO/MMIO BARs */ for (i = 0; i < PCI_ROM_SLOT; i++) { XenHostPCIIORegion *r = &d->io_regions[i]; uint8_t type; if (r->base_addr == 0 || r->size == 0) { continue; } s->bases[i].access.u = r->base_addr; if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) { type = PCI_BASE_ADDRESS_SPACE_IO; } else { type = PCI_BASE_ADDRESS_SPACE_MEMORY; if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) { type |= PCI_BASE_ADDRESS_MEM_PREFETCH; } if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) { type |= PCI_BASE_ADDRESS_MEM_TYPE_64; } } memory_region_init_io(&s->bar[i], OBJECT(s), &ops, &s->dev, "xen-pci-pt-bar", r->size); pci_register_bar(&s->dev, i, type, &s->bar[i]); XEN_PT_LOG(&s->dev, "IO region %i registered (size=0x%08"PRIx64 " base_addr=0x%08"PRIx64" type: %#x)\n", i, r->size, r->base_addr, type); } /* Register expansion ROM address */ if (d->rom.base_addr && d->rom.size) { uint32_t bar_data = 0; /* Re-set BAR reported by OS, otherwise ROM can't be read. */ if (xen_host_pci_get_long(d, PCI_ROM_ADDRESS, &bar_data)) { return 0; } if ((bar_data & PCI_ROM_ADDRESS_MASK) == 0) { bar_data |= d->rom.base_addr & PCI_ROM_ADDRESS_MASK; xen_host_pci_set_long(d, PCI_ROM_ADDRESS, bar_data); } s->bases[PCI_ROM_SLOT].access.maddr = d->rom.base_addr; memory_region_init_rom_device(&s->rom, OBJECT(s), NULL, NULL, "xen-pci-pt-rom", d->rom.size); pci_register_bar(&s->dev, PCI_ROM_SLOT, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->rom); XEN_PT_LOG(&s->dev, "Expansion ROM registered (size=0x%08"PRIx64 " base_addr=0x%08"PRIx64")\n", d->rom.size, d->rom.base_addr); } return 0; }
false
qemu
794798e36eda77802ce7cc7d7d6b1c65751e8a76
static int xen_pt_register_regions(XenPCIPassthroughState *s) { int i = 0; XenHostPCIDevice *d = &s->real_device; for (i = 0; i < PCI_ROM_SLOT; i++) { XenHostPCIIORegion *r = &d->io_regions[i]; uint8_t type; if (r->base_addr == 0 || r->size == 0) { continue; } s->bases[i].access.u = r->base_addr; if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) { type = PCI_BASE_ADDRESS_SPACE_IO; } else { type = PCI_BASE_ADDRESS_SPACE_MEMORY; if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) { type |= PCI_BASE_ADDRESS_MEM_PREFETCH; } if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) { type |= PCI_BASE_ADDRESS_MEM_TYPE_64; } } memory_region_init_io(&s->bar[i], OBJECT(s), &ops, &s->dev, "xen-pci-pt-bar", r->size); pci_register_bar(&s->dev, i, type, &s->bar[i]); XEN_PT_LOG(&s->dev, "IO region %i registered (size=0x%08"PRIx64 " base_addr=0x%08"PRIx64" type: %#x)\n", i, r->size, r->base_addr, type); } if (d->rom.base_addr && d->rom.size) { uint32_t bar_data = 0; if (xen_host_pci_get_long(d, PCI_ROM_ADDRESS, &bar_data)) { return 0; } if ((bar_data & PCI_ROM_ADDRESS_MASK) == 0) { bar_data |= d->rom.base_addr & PCI_ROM_ADDRESS_MASK; xen_host_pci_set_long(d, PCI_ROM_ADDRESS, bar_data); } s->bases[PCI_ROM_SLOT].access.maddr = d->rom.base_addr; memory_region_init_rom_device(&s->rom, OBJECT(s), NULL, NULL, "xen-pci-pt-rom", d->rom.size); pci_register_bar(&s->dev, PCI_ROM_SLOT, PCI_BASE_ADDRESS_MEM_PREFETCH, &s->rom); XEN_PT_LOG(&s->dev, "Expansion ROM registered (size=0x%08"PRIx64 " base_addr=0x%08"PRIx64")\n", d->rom.size, d->rom.base_addr); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(XenPCIPassthroughState *VAR_0) { int VAR_1 = 0; XenHostPCIDevice *d = &VAR_0->real_device; for (VAR_1 = 0; VAR_1 < PCI_ROM_SLOT; VAR_1++) { XenHostPCIIORegion *r = &d->io_regions[VAR_1]; uint8_t type; if (r->base_addr == 0 || r->size == 0) { continue; } VAR_0->bases[VAR_1].access.u = r->base_addr; if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) { type = PCI_BASE_ADDRESS_SPACE_IO; } else { type = PCI_BASE_ADDRESS_SPACE_MEMORY; if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) { type |= PCI_BASE_ADDRESS_MEM_PREFETCH; } if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) { type |= PCI_BASE_ADDRESS_MEM_TYPE_64; } } memory_region_init_io(&VAR_0->bar[VAR_1], OBJECT(VAR_0), &ops, &VAR_0->dev, "xen-pci-pt-bar", r->size); pci_register_bar(&VAR_0->dev, VAR_1, type, &VAR_0->bar[VAR_1]); XEN_PT_LOG(&VAR_0->dev, "IO region %VAR_1 registered (size=0x%08"PRIx64 " base_addr=0x%08"PRIx64" type: %#x)\n", VAR_1, r->size, r->base_addr, type); } if (d->rom.base_addr && d->rom.size) { uint32_t bar_data = 0; if (xen_host_pci_get_long(d, PCI_ROM_ADDRESS, &bar_data)) { return 0; } if ((bar_data & PCI_ROM_ADDRESS_MASK) == 0) { bar_data |= d->rom.base_addr & PCI_ROM_ADDRESS_MASK; xen_host_pci_set_long(d, PCI_ROM_ADDRESS, bar_data); } VAR_0->bases[PCI_ROM_SLOT].access.maddr = d->rom.base_addr; memory_region_init_rom_device(&VAR_0->rom, OBJECT(VAR_0), NULL, NULL, "xen-pci-pt-rom", d->rom.size); pci_register_bar(&VAR_0->dev, PCI_ROM_SLOT, PCI_BASE_ADDRESS_MEM_PREFETCH, &VAR_0->rom); XEN_PT_LOG(&VAR_0->dev, "Expansion ROM registered (size=0x%08"PRIx64 " base_addr=0x%08"PRIx64")\n", d->rom.size, d->rom.base_addr); } return 0; }
[ "static int FUNC_0(XenPCIPassthroughState *VAR_0)\n{", "int VAR_1 = 0;", "XenHostPCIDevice *d = &VAR_0->real_device;", "for (VAR_1 = 0; VAR_1 < PCI_ROM_SLOT; VAR_1++) {", "XenHostPCIIORegion *r = &d->io_regions[VAR_1];", "uint8_t type;", "if (r->base_addr == 0 || r->size == 0) {", "continue;", "}", "VAR_0->bases[VAR_1].access.u = r->base_addr;", "if (r->type & XEN_HOST_PCI_REGION_TYPE_IO) {", "type = PCI_BASE_ADDRESS_SPACE_IO;", "} else {", "type = PCI_BASE_ADDRESS_SPACE_MEMORY;", "if (r->type & XEN_HOST_PCI_REGION_TYPE_PREFETCH) {", "type |= PCI_BASE_ADDRESS_MEM_PREFETCH;", "}", "if (r->type & XEN_HOST_PCI_REGION_TYPE_MEM_64) {", "type |= PCI_BASE_ADDRESS_MEM_TYPE_64;", "}", "}", "memory_region_init_io(&VAR_0->bar[VAR_1], OBJECT(VAR_0), &ops, &VAR_0->dev,\n\"xen-pci-pt-bar\", r->size);", "pci_register_bar(&VAR_0->dev, VAR_1, type, &VAR_0->bar[VAR_1]);", "XEN_PT_LOG(&VAR_0->dev, \"IO region %VAR_1 registered (size=0x%08\"PRIx64\n\" base_addr=0x%08\"PRIx64\" type: %#x)\\n\",\nVAR_1, r->size, r->base_addr, type);", "}", "if (d->rom.base_addr && d->rom.size) {", "uint32_t bar_data = 0;", "if (xen_host_pci_get_long(d, PCI_ROM_ADDRESS, &bar_data)) {", "return 0;", "}", "if ((bar_data & PCI_ROM_ADDRESS_MASK) == 0) {", "bar_data |= d->rom.base_addr & PCI_ROM_ADDRESS_MASK;", "xen_host_pci_set_long(d, PCI_ROM_ADDRESS, bar_data);", "}", "VAR_0->bases[PCI_ROM_SLOT].access.maddr = d->rom.base_addr;", "memory_region_init_rom_device(&VAR_0->rom, OBJECT(VAR_0), NULL, NULL,\n\"xen-pci-pt-rom\", d->rom.size);", "pci_register_bar(&VAR_0->dev, PCI_ROM_SLOT, PCI_BASE_ADDRESS_MEM_PREFETCH,\n&VAR_0->rom);", "XEN_PT_LOG(&VAR_0->dev, \"Expansion ROM registered (size=0x%08\"PRIx64\n\" base_addr=0x%08\"PRIx64\")\\n\",\nd->rom.size, d->rom.base_addr);", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 61 ], [ 65, 67, 69 ], [ 71 ], [ 77 ], [ 79 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 105, 107 ], [ 109, 111 ], [ 115, 117, 119 ], [ 121 ], [ 125 ], [ 127 ] ]
20,224
int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) { int i, ret; if (shared) { assert(pic->f.data[0]); pic->shared = 1; } else { assert(!pic->f.data[0]); if (alloc_frame_buffer(s, pic) < 0) return -1; s->linesize = pic->f.linesize[0]; s->uvlinesize = pic->f.linesize[1]; } if (!pic->qscale_table_buf) ret = alloc_picture_tables(s, pic); else ret = make_tables_writable(pic); if (ret < 0) goto fail; if (s->encoding) { pic->mb_var = (uint16_t*)pic->mb_var_buf->data; pic->mc_mb_var = (uint16_t*)pic->mc_mb_var_buf->data; pic->mb_mean = pic->mb_mean_buf->data; } pic->mbskip_table = pic->mbskip_table_buf->data; pic->qscale_table = pic->qscale_table_buf->data + 2 * s->mb_stride + 1; pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * s->mb_stride + 1; if (pic->motion_val_buf[0]) { for (i = 0; i < 2; i++) { pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4; pic->ref_index[i] = pic->ref_index_buf[i]->data; } } return 0; fail: av_log(s->avctx, AV_LOG_ERROR, "Error allocating a picture.\n"); ff_mpeg_unref_picture(s, pic); free_picture_tables(pic); return AVERROR(ENOMEM); }
false
FFmpeg
a553c6a347d3d28d7ee44c3df3d5c4ee780dba23
int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) { int i, ret; if (shared) { assert(pic->f.data[0]); pic->shared = 1; } else { assert(!pic->f.data[0]); if (alloc_frame_buffer(s, pic) < 0) return -1; s->linesize = pic->f.linesize[0]; s->uvlinesize = pic->f.linesize[1]; } if (!pic->qscale_table_buf) ret = alloc_picture_tables(s, pic); else ret = make_tables_writable(pic); if (ret < 0) goto fail; if (s->encoding) { pic->mb_var = (uint16_t*)pic->mb_var_buf->data; pic->mc_mb_var = (uint16_t*)pic->mc_mb_var_buf->data; pic->mb_mean = pic->mb_mean_buf->data; } pic->mbskip_table = pic->mbskip_table_buf->data; pic->qscale_table = pic->qscale_table_buf->data + 2 * s->mb_stride + 1; pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * s->mb_stride + 1; if (pic->motion_val_buf[0]) { for (i = 0; i < 2; i++) { pic->motion_val[i] = (int16_t (*)[2])pic->motion_val_buf[i]->data + 4; pic->ref_index[i] = pic->ref_index_buf[i]->data; } } return 0; fail: av_log(s->avctx, AV_LOG_ERROR, "Error allocating a picture.\n"); ff_mpeg_unref_picture(s, pic); free_picture_tables(pic); return AVERROR(ENOMEM); }
{ "code": [], "line_no": [] }
int FUNC_0(MpegEncContext *VAR_0, Picture *VAR_1, int VAR_2) { int VAR_3, VAR_4; if (VAR_2) { assert(VAR_1->f.data[0]); VAR_1->VAR_2 = 1; } else { assert(!VAR_1->f.data[0]); if (alloc_frame_buffer(VAR_0, VAR_1) < 0) return -1; VAR_0->linesize = VAR_1->f.linesize[0]; VAR_0->uvlinesize = VAR_1->f.linesize[1]; } if (!VAR_1->qscale_table_buf) VAR_4 = alloc_picture_tables(VAR_0, VAR_1); else VAR_4 = make_tables_writable(VAR_1); if (VAR_4 < 0) goto fail; if (VAR_0->encoding) { VAR_1->mb_var = (uint16_t*)VAR_1->mb_var_buf->data; VAR_1->mc_mb_var = (uint16_t*)VAR_1->mc_mb_var_buf->data; VAR_1->mb_mean = VAR_1->mb_mean_buf->data; } VAR_1->mbskip_table = VAR_1->mbskip_table_buf->data; VAR_1->qscale_table = VAR_1->qscale_table_buf->data + 2 * VAR_0->mb_stride + 1; VAR_1->mb_type = (uint32_t*)VAR_1->mb_type_buf->data + 2 * VAR_0->mb_stride + 1; if (VAR_1->motion_val_buf[0]) { for (VAR_3 = 0; VAR_3 < 2; VAR_3++) { VAR_1->motion_val[VAR_3] = (int16_t (*)[2])VAR_1->motion_val_buf[VAR_3]->data + 4; VAR_1->ref_index[VAR_3] = VAR_1->ref_index_buf[VAR_3]->data; } } return 0; fail: av_log(VAR_0->avctx, AV_LOG_ERROR, "Error allocating a picture.\n"); ff_mpeg_unref_picture(VAR_0, VAR_1); free_picture_tables(VAR_1); return AVERROR(ENOMEM); }
[ "int FUNC_0(MpegEncContext *VAR_0, Picture *VAR_1, int VAR_2)\n{", "int VAR_3, VAR_4;", "if (VAR_2) {", "assert(VAR_1->f.data[0]);", "VAR_1->VAR_2 = 1;", "} else {", "assert(!VAR_1->f.data[0]);", "if (alloc_frame_buffer(VAR_0, VAR_1) < 0)\nreturn -1;", "VAR_0->linesize = VAR_1->f.linesize[0];", "VAR_0->uvlinesize = VAR_1->f.linesize[1];", "}", "if (!VAR_1->qscale_table_buf)\nVAR_4 = alloc_picture_tables(VAR_0, VAR_1);", "else\nVAR_4 = make_tables_writable(VAR_1);", "if (VAR_4 < 0)\ngoto fail;", "if (VAR_0->encoding) {", "VAR_1->mb_var = (uint16_t*)VAR_1->mb_var_buf->data;", "VAR_1->mc_mb_var = (uint16_t*)VAR_1->mc_mb_var_buf->data;", "VAR_1->mb_mean = VAR_1->mb_mean_buf->data;", "}", "VAR_1->mbskip_table = VAR_1->mbskip_table_buf->data;", "VAR_1->qscale_table = VAR_1->qscale_table_buf->data + 2 * VAR_0->mb_stride + 1;", "VAR_1->mb_type = (uint32_t*)VAR_1->mb_type_buf->data + 2 * VAR_0->mb_stride + 1;", "if (VAR_1->motion_val_buf[0]) {", "for (VAR_3 = 0; VAR_3 < 2; VAR_3++) {", "VAR_1->motion_val[VAR_3] = (int16_t (*)[2])VAR_1->motion_val_buf[VAR_3]->data + 4;", "VAR_1->ref_index[VAR_3] = VAR_1->ref_index_buf[VAR_3]->data;", "}", "}", "return 0;", "fail:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Error allocating a picture.\\n\");", "ff_mpeg_unref_picture(VAR_0, VAR_1);", "free_picture_tables(VAR_1);", "return AVERROR(ENOMEM);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 21, 23 ], [ 27 ], [ 29 ], [ 31 ], [ 35, 37 ], [ 39, 41 ], [ 43, 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ] ]
20,225
PCIBus *pci_prep_init(qemu_irq *pic) { PREPPCIState *s; PCIDevice *d; int PPC_io_memory; s = qemu_mallocz(sizeof(PREPPCIState)); s->bus = pci_register_bus(NULL, "pci", prep_set_irq, prep_map_irq, pic, 0, 4); register_ioport_write(0xcf8, 4, 4, pci_prep_addr_writel, s); register_ioport_read(0xcf8, 4, 4, pci_prep_addr_readl, s); register_ioport_write(0xcfc, 4, 1, pci_host_data_writeb, s); register_ioport_write(0xcfc, 4, 2, pci_host_data_writew, s); register_ioport_write(0xcfc, 4, 4, pci_host_data_writel, s); register_ioport_read(0xcfc, 4, 1, pci_host_data_readb, s); register_ioport_read(0xcfc, 4, 2, pci_host_data_readw, s); register_ioport_read(0xcfc, 4, 4, pci_host_data_readl, s); PPC_io_memory = cpu_register_io_memory(PPC_PCIIO_read, PPC_PCIIO_write, s); cpu_register_physical_memory(0x80800000, 0x00400000, PPC_io_memory); /* PCI host bridge */ d = pci_register_device(s->bus, "PREP Host Bridge - Motorola Raven", sizeof(PCIDevice), 0, NULL, NULL); pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MOTOROLA); pci_config_set_device_id(d->config, PCI_DEVICE_ID_MOTOROLA_RAVEN); d->config[0x08] = 0x00; // revision pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; // cache_line_size d->config[0x0D] = 0x10; // latency_timer d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type d->config[0x34] = 0x00; // capabilities_pointer return s->bus; }
false
qemu
4f5e19e6c570459cd524b29b24374f03860f5149
PCIBus *pci_prep_init(qemu_irq *pic) { PREPPCIState *s; PCIDevice *d; int PPC_io_memory; s = qemu_mallocz(sizeof(PREPPCIState)); s->bus = pci_register_bus(NULL, "pci", prep_set_irq, prep_map_irq, pic, 0, 4); register_ioport_write(0xcf8, 4, 4, pci_prep_addr_writel, s); register_ioport_read(0xcf8, 4, 4, pci_prep_addr_readl, s); register_ioport_write(0xcfc, 4, 1, pci_host_data_writeb, s); register_ioport_write(0xcfc, 4, 2, pci_host_data_writew, s); register_ioport_write(0xcfc, 4, 4, pci_host_data_writel, s); register_ioport_read(0xcfc, 4, 1, pci_host_data_readb, s); register_ioport_read(0xcfc, 4, 2, pci_host_data_readw, s); register_ioport_read(0xcfc, 4, 4, pci_host_data_readl, s); PPC_io_memory = cpu_register_io_memory(PPC_PCIIO_read, PPC_PCIIO_write, s); cpu_register_physical_memory(0x80800000, 0x00400000, PPC_io_memory); d = pci_register_device(s->bus, "PREP Host Bridge - Motorola Raven", sizeof(PCIDevice), 0, NULL, NULL); pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MOTOROLA); pci_config_set_device_id(d->config, PCI_DEVICE_ID_MOTOROLA_RAVEN); d->config[0x08] = 0x00; pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; d->config[0x0D] = 0x10; d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; d->config[0x34] = 0x00; return s->bus; }
{ "code": [], "line_no": [] }
PCIBus *FUNC_0(qemu_irq *pic) { PREPPCIState *s; PCIDevice *d; int VAR_0; s = qemu_mallocz(sizeof(PREPPCIState)); s->bus = pci_register_bus(NULL, "pci", prep_set_irq, prep_map_irq, pic, 0, 4); register_ioport_write(0xcf8, 4, 4, pci_prep_addr_writel, s); register_ioport_read(0xcf8, 4, 4, pci_prep_addr_readl, s); register_ioport_write(0xcfc, 4, 1, pci_host_data_writeb, s); register_ioport_write(0xcfc, 4, 2, pci_host_data_writew, s); register_ioport_write(0xcfc, 4, 4, pci_host_data_writel, s); register_ioport_read(0xcfc, 4, 1, pci_host_data_readb, s); register_ioport_read(0xcfc, 4, 2, pci_host_data_readw, s); register_ioport_read(0xcfc, 4, 4, pci_host_data_readl, s); VAR_0 = cpu_register_io_memory(PPC_PCIIO_read, PPC_PCIIO_write, s); cpu_register_physical_memory(0x80800000, 0x00400000, VAR_0); d = pci_register_device(s->bus, "PREP Host Bridge - Motorola Raven", sizeof(PCIDevice), 0, NULL, NULL); pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MOTOROLA); pci_config_set_device_id(d->config, PCI_DEVICE_ID_MOTOROLA_RAVEN); d->config[0x08] = 0x00; pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST); d->config[0x0C] = 0x08; d->config[0x0D] = 0x10; d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; d->config[0x34] = 0x00; return s->bus; }
[ "PCIBus *FUNC_0(qemu_irq *pic)\n{", "PREPPCIState *s;", "PCIDevice *d;", "int VAR_0;", "s = qemu_mallocz(sizeof(PREPPCIState));", "s->bus = pci_register_bus(NULL, \"pci\",\nprep_set_irq, prep_map_irq, pic, 0, 4);", "register_ioport_write(0xcf8, 4, 4, pci_prep_addr_writel, s);", "register_ioport_read(0xcf8, 4, 4, pci_prep_addr_readl, s);", "register_ioport_write(0xcfc, 4, 1, pci_host_data_writeb, s);", "register_ioport_write(0xcfc, 4, 2, pci_host_data_writew, s);", "register_ioport_write(0xcfc, 4, 4, pci_host_data_writel, s);", "register_ioport_read(0xcfc, 4, 1, pci_host_data_readb, s);", "register_ioport_read(0xcfc, 4, 2, pci_host_data_readw, s);", "register_ioport_read(0xcfc, 4, 4, pci_host_data_readl, s);", "VAR_0 = cpu_register_io_memory(PPC_PCIIO_read,\nPPC_PCIIO_write, s);", "cpu_register_physical_memory(0x80800000, 0x00400000, VAR_0);", "d = pci_register_device(s->bus, \"PREP Host Bridge - Motorola Raven\",\nsizeof(PCIDevice), 0, NULL, NULL);", "pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_MOTOROLA);", "pci_config_set_device_id(d->config, PCI_DEVICE_ID_MOTOROLA_RAVEN);", "d->config[0x08] = 0x00;", "pci_config_set_class(d->config, PCI_CLASS_BRIDGE_HOST);", "d->config[0x0C] = 0x08;", "d->config[0x0D] = 0x10;", "d->config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL;", "d->config[0x34] = 0x00;", "return s->bus;", "}" ]
[ 0, 0, 0, 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 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41, 43 ], [ 45 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ] ]
20,226
static DisplaySurface *qemu_create_dummy_surface(void) { static const char msg[] = "This VM has no graphic display device."; DisplaySurface *surface = qemu_create_displaysurface(640, 480); pixman_color_t bg = color_table_rgb[0][COLOR_BLACK]; pixman_color_t fg = color_table_rgb[0][COLOR_WHITE]; pixman_image_t *glyph; int len, x, y, i; len = strlen(msg); x = (640/FONT_WIDTH - len) / 2; y = (480/FONT_HEIGHT - 1) / 2; for (i = 0; i < len; i++) { glyph = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, msg[i]); qemu_pixman_glyph_render(glyph, surface->image, &fg, &bg, x+i, y, FONT_WIDTH, FONT_HEIGHT); qemu_pixman_image_unref(glyph); } return surface; }
false
qemu
521a580d2352ad30086babcabb91e6338e47cf62
static DisplaySurface *qemu_create_dummy_surface(void) { static const char msg[] = "This VM has no graphic display device."; DisplaySurface *surface = qemu_create_displaysurface(640, 480); pixman_color_t bg = color_table_rgb[0][COLOR_BLACK]; pixman_color_t fg = color_table_rgb[0][COLOR_WHITE]; pixman_image_t *glyph; int len, x, y, i; len = strlen(msg); x = (640/FONT_WIDTH - len) / 2; y = (480/FONT_HEIGHT - 1) / 2; for (i = 0; i < len; i++) { glyph = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, msg[i]); qemu_pixman_glyph_render(glyph, surface->image, &fg, &bg, x+i, y, FONT_WIDTH, FONT_HEIGHT); qemu_pixman_image_unref(glyph); } return surface; }
{ "code": [], "line_no": [] }
static DisplaySurface *FUNC_0(void) { static const char VAR_0[] = "This VM has no graphic display device."; DisplaySurface *surface = qemu_create_displaysurface(640, 480); pixman_color_t bg = color_table_rgb[0][COLOR_BLACK]; pixman_color_t fg = color_table_rgb[0][COLOR_WHITE]; pixman_image_t *glyph; int VAR_1, VAR_2, VAR_3, VAR_4; VAR_1 = strlen(VAR_0); VAR_2 = (640/FONT_WIDTH - VAR_1) / 2; VAR_3 = (480/FONT_HEIGHT - 1) / 2; for (VAR_4 = 0; VAR_4 < VAR_1; VAR_4++) { glyph = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, VAR_0[VAR_4]); qemu_pixman_glyph_render(glyph, surface->image, &fg, &bg, VAR_2+VAR_4, VAR_3, FONT_WIDTH, FONT_HEIGHT); qemu_pixman_image_unref(glyph); } return surface; }
[ "static DisplaySurface *FUNC_0(void)\n{", "static const char VAR_0[] =\n\"This VM has no graphic display device.\";", "DisplaySurface *surface = qemu_create_displaysurface(640, 480);", "pixman_color_t bg = color_table_rgb[0][COLOR_BLACK];", "pixman_color_t fg = color_table_rgb[0][COLOR_WHITE];", "pixman_image_t *glyph;", "int VAR_1, VAR_2, VAR_3, VAR_4;", "VAR_1 = strlen(VAR_0);", "VAR_2 = (640/FONT_WIDTH - VAR_1) / 2;", "VAR_3 = (480/FONT_HEIGHT - 1) / 2;", "for (VAR_4 = 0; VAR_4 < VAR_1; VAR_4++) {", "glyph = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, VAR_0[VAR_4]);", "qemu_pixman_glyph_render(glyph, surface->image, &fg, &bg,\nVAR_2+VAR_4, VAR_3, FONT_WIDTH, FONT_HEIGHT);", "qemu_pixman_image_unref(glyph);", "}", "return surface;", "}" ]
[ 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 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
20,227
int pit_get_out(PITState *pit, int channel, int64_t current_time) { PITChannelState *s = &pit->channels[channel]; return pit_get_out1(s, current_time); }
false
qemu
64d7e9a421fea0ac50b44541f5521de455e7cd5d
int pit_get_out(PITState *pit, int channel, int64_t current_time) { PITChannelState *s = &pit->channels[channel]; return pit_get_out1(s, current_time); }
{ "code": [], "line_no": [] }
int FUNC_0(PITState *VAR_0, int VAR_1, int64_t VAR_2) { PITChannelState *s = &VAR_0->channels[VAR_1]; return pit_get_out1(s, VAR_2); }
[ "int FUNC_0(PITState *VAR_0, int VAR_1, int64_t VAR_2)\n{", "PITChannelState *s = &VAR_0->channels[VAR_1];", "return pit_get_out1(s, VAR_2);", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
20,228
void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, int64_t speed, uint32_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, bool unmap, BlockCompletionFunc *cb, void *opaque, Error **errp) { bool is_none_mode; BlockDriverState *base; if (mode == MIRROR_SYNC_MODE_INCREMENTAL) { error_setg(errp, "Sync mode 'incremental' not supported"); return; } is_none_mode = mode == MIRROR_SYNC_MODE_NONE; base = mode == MIRROR_SYNC_MODE_TOP ? backing_bs(bs) : NULL; mirror_start_job(job_id, bs, target, replaces, speed, granularity, buf_size, backing_mode, on_source_error, on_target_error, unmap, cb, opaque, errp, &mirror_job_driver, is_none_mode, base); }
false
qemu
b49f7ead8d222bcb8df0388f3177002f3e33d046
void mirror_start(const char *job_id, BlockDriverState *bs, BlockDriverState *target, const char *replaces, int64_t speed, uint32_t granularity, int64_t buf_size, MirrorSyncMode mode, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, BlockdevOnError on_target_error, bool unmap, BlockCompletionFunc *cb, void *opaque, Error **errp) { bool is_none_mode; BlockDriverState *base; if (mode == MIRROR_SYNC_MODE_INCREMENTAL) { error_setg(errp, "Sync mode 'incremental' not supported"); return; } is_none_mode = mode == MIRROR_SYNC_MODE_NONE; base = mode == MIRROR_SYNC_MODE_TOP ? backing_bs(bs) : NULL; mirror_start_job(job_id, bs, target, replaces, speed, granularity, buf_size, backing_mode, on_source_error, on_target_error, unmap, cb, opaque, errp, &mirror_job_driver, is_none_mode, base); }
{ "code": [], "line_no": [] }
void FUNC_0(const char *VAR_0, BlockDriverState *VAR_1, BlockDriverState *VAR_2, const char *VAR_3, int64_t VAR_4, uint32_t VAR_5, int64_t VAR_6, MirrorSyncMode VAR_7, BlockMirrorBackingMode VAR_8, BlockdevOnError VAR_9, BlockdevOnError VAR_10, bool VAR_11, BlockCompletionFunc *VAR_12, void *VAR_13, Error **VAR_14) { bool is_none_mode; BlockDriverState *base; if (VAR_7 == MIRROR_SYNC_MODE_INCREMENTAL) { error_setg(VAR_14, "Sync VAR_7 'incremental' not supported"); return; } is_none_mode = VAR_7 == MIRROR_SYNC_MODE_NONE; base = VAR_7 == MIRROR_SYNC_MODE_TOP ? backing_bs(VAR_1) : NULL; mirror_start_job(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14, &mirror_job_driver, is_none_mode, base); }
[ "void FUNC_0(const char *VAR_0, BlockDriverState *VAR_1,\nBlockDriverState *VAR_2, const char *VAR_3,\nint64_t VAR_4, uint32_t VAR_5, int64_t VAR_6,\nMirrorSyncMode VAR_7, BlockMirrorBackingMode VAR_8,\nBlockdevOnError VAR_9,\nBlockdevOnError VAR_10,\nbool VAR_11,\nBlockCompletionFunc *VAR_12,\nvoid *VAR_13, Error **VAR_14)\n{", "bool is_none_mode;", "BlockDriverState *base;", "if (VAR_7 == MIRROR_SYNC_MODE_INCREMENTAL) {", "error_setg(VAR_14, \"Sync VAR_7 'incremental' not supported\");", "return;", "}", "is_none_mode = VAR_7 == MIRROR_SYNC_MODE_NONE;", "base = VAR_7 == MIRROR_SYNC_MODE_TOP ? backing_bs(VAR_1) : NULL;", "mirror_start_job(VAR_0, VAR_1, VAR_2, VAR_3,\nVAR_4, VAR_5, VAR_6, VAR_8,\nVAR_9, VAR_10, VAR_11, VAR_12, VAR_13, VAR_14,\n&mirror_job_driver, is_none_mode, base);", "}" ]
[ 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 ], [ 37 ], [ 39, 41, 43, 45 ], [ 47 ] ]
20,229
static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { NFSClient *client = bs->opaque; int64_t ret; QemuOpts *opts; Error *local_err = NULL; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); return -EINVAL; } ret = nfs_client_open(client, qemu_opt_get(opts, "filename"), (flags & BDRV_O_RDWR) ? O_RDWR : O_RDONLY, errp); if (ret < 0) { return ret; } bs->total_sectors = ret; return 0; }
false
qemu
0fb6395c0cb5046432a80d608ddde7a3b2f8a9ae
static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { NFSClient *client = bs->opaque; int64_t ret; QemuOpts *opts; Error *local_err = NULL; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (error_is_set(&local_err)) { error_propagate(errp, local_err); return -EINVAL; } ret = nfs_client_open(client, qemu_opt_get(opts, "filename"), (flags & BDRV_O_RDWR) ? O_RDWR : O_RDONLY, errp); if (ret < 0) { return ret; } bs->total_sectors = ret; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2, Error **VAR_3) { NFSClient *client = VAR_0->opaque; int64_t ret; QemuOpts *opts; Error *local_err = NULL; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, VAR_1, &local_err); if (error_is_set(&local_err)) { error_propagate(VAR_3, local_err); return -EINVAL; } ret = nfs_client_open(client, qemu_opt_get(opts, "filename"), (VAR_2 & BDRV_O_RDWR) ? O_RDWR : O_RDONLY, VAR_3); if (ret < 0) { return ret; } VAR_0->total_sectors = ret; return 0; }
[ "static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3) {", "NFSClient *client = VAR_0->opaque;", "int64_t ret;", "QemuOpts *opts;", "Error *local_err = NULL;", "opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort);", "qemu_opts_absorb_qdict(opts, VAR_1, &local_err);", "if (error_is_set(&local_err)) {", "error_propagate(VAR_3, local_err);", "return -EINVAL;", "}", "ret = nfs_client_open(client, qemu_opt_get(opts, \"filename\"),\n(VAR_2 & BDRV_O_RDWR) ? O_RDWR : O_RDONLY,\nVAR_3);", "if (ret < 0) {", "return ret;", "}", "VAR_0->total_sectors = ret;", "return 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 ], [ 43 ] ]
20,230
static void memory_map_init(void) { system_memory = g_malloc(sizeof(*system_memory)); memory_region_init(system_memory, "system", INT64_MAX); address_space_init(&address_space_memory, system_memory, "memory"); system_io = g_malloc(sizeof(*system_io)); memory_region_init(system_io, "io", 65536); address_space_init(&address_space_io, system_io, "I/O"); memory_listener_register(&core_memory_listener, &address_space_memory); memory_listener_register(&io_memory_listener, &address_space_io); memory_listener_register(&tcg_memory_listener, &address_space_memory); }
false
qemu
b40acf99bef69fa8ab0f9092ff162fde945eec12
static void memory_map_init(void) { system_memory = g_malloc(sizeof(*system_memory)); memory_region_init(system_memory, "system", INT64_MAX); address_space_init(&address_space_memory, system_memory, "memory"); system_io = g_malloc(sizeof(*system_io)); memory_region_init(system_io, "io", 65536); address_space_init(&address_space_io, system_io, "I/O"); memory_listener_register(&core_memory_listener, &address_space_memory); memory_listener_register(&io_memory_listener, &address_space_io); memory_listener_register(&tcg_memory_listener, &address_space_memory); }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { system_memory = g_malloc(sizeof(*system_memory)); memory_region_init(system_memory, "system", INT64_MAX); address_space_init(&address_space_memory, system_memory, "memory"); system_io = g_malloc(sizeof(*system_io)); memory_region_init(system_io, "io", 65536); address_space_init(&address_space_io, system_io, "I/O"); memory_listener_register(&core_memory_listener, &address_space_memory); memory_listener_register(&io_memory_listener, &address_space_io); memory_listener_register(&tcg_memory_listener, &address_space_memory); }
[ "static void FUNC_0(void)\n{", "system_memory = g_malloc(sizeof(*system_memory));", "memory_region_init(system_memory, \"system\", INT64_MAX);", "address_space_init(&address_space_memory, system_memory, \"memory\");", "system_io = g_malloc(sizeof(*system_io));", "memory_region_init(system_io, \"io\", 65536);", "address_space_init(&address_space_io, system_io, \"I/O\");", "memory_listener_register(&core_memory_listener, &address_space_memory);", "memory_listener_register(&io_memory_listener, &address_space_io);", "memory_listener_register(&tcg_memory_listener, &address_space_memory);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
20,231
void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb) { int i = 0, start = 0, num_reqs = 0, niov = 0, nb_sectors = 0; int max_xfer_len = 0; int64_t sector_num = 0; if (mrb->num_reqs == 1) { submit_requests(blk, mrb, 0, 1, -1); mrb->num_reqs = 0; return; } max_xfer_len = blk_get_max_transfer_length(mrb->reqs[0]->dev->blk); max_xfer_len = MIN_NON_ZERO(max_xfer_len, BDRV_REQUEST_MAX_SECTORS); qsort(mrb->reqs, mrb->num_reqs, sizeof(*mrb->reqs), &multireq_compare); for (i = 0; i < mrb->num_reqs; i++) { VirtIOBlockReq *req = mrb->reqs[i]; if (num_reqs > 0) { /* * NOTE: We cannot merge the requests in below situations: * 1. requests are not sequential * 2. merge would exceed maximum number of IOVs * 3. merge would exceed maximum transfer length of backend device */ if (sector_num + nb_sectors != req->sector_num || niov > blk_get_max_iov(blk) - req->qiov.niov || req->qiov.size / BDRV_SECTOR_SIZE > max_xfer_len || nb_sectors > max_xfer_len - req->qiov.size / BDRV_SECTOR_SIZE) { submit_requests(blk, mrb, start, num_reqs, niov); num_reqs = 0; } } if (num_reqs == 0) { sector_num = req->sector_num; nb_sectors = niov = 0; start = i; } nb_sectors += req->qiov.size / BDRV_SECTOR_SIZE; niov += req->qiov.niov; num_reqs++; } submit_requests(blk, mrb, start, num_reqs, niov); mrb->num_reqs = 0; }
false
qemu
24ce9a20260713e86377cfa78fb8699335759f4f
void virtio_blk_submit_multireq(BlockBackend *blk, MultiReqBuffer *mrb) { int i = 0, start = 0, num_reqs = 0, niov = 0, nb_sectors = 0; int max_xfer_len = 0; int64_t sector_num = 0; if (mrb->num_reqs == 1) { submit_requests(blk, mrb, 0, 1, -1); mrb->num_reqs = 0; return; } max_xfer_len = blk_get_max_transfer_length(mrb->reqs[0]->dev->blk); max_xfer_len = MIN_NON_ZERO(max_xfer_len, BDRV_REQUEST_MAX_SECTORS); qsort(mrb->reqs, mrb->num_reqs, sizeof(*mrb->reqs), &multireq_compare); for (i = 0; i < mrb->num_reqs; i++) { VirtIOBlockReq *req = mrb->reqs[i]; if (num_reqs > 0) { if (sector_num + nb_sectors != req->sector_num || niov > blk_get_max_iov(blk) - req->qiov.niov || req->qiov.size / BDRV_SECTOR_SIZE > max_xfer_len || nb_sectors > max_xfer_len - req->qiov.size / BDRV_SECTOR_SIZE) { submit_requests(blk, mrb, start, num_reqs, niov); num_reqs = 0; } } if (num_reqs == 0) { sector_num = req->sector_num; nb_sectors = niov = 0; start = i; } nb_sectors += req->qiov.size / BDRV_SECTOR_SIZE; niov += req->qiov.niov; num_reqs++; } submit_requests(blk, mrb, start, num_reqs, niov); mrb->num_reqs = 0; }
{ "code": [], "line_no": [] }
void FUNC_0(BlockBackend *VAR_0, MultiReqBuffer *VAR_1) { int VAR_2 = 0, VAR_3 = 0, VAR_4 = 0, VAR_5 = 0, VAR_6 = 0; int VAR_7 = 0; int64_t sector_num = 0; if (VAR_1->VAR_4 == 1) { submit_requests(VAR_0, VAR_1, 0, 1, -1); VAR_1->VAR_4 = 0; return; } VAR_7 = blk_get_max_transfer_length(VAR_1->reqs[0]->dev->VAR_0); VAR_7 = MIN_NON_ZERO(VAR_7, BDRV_REQUEST_MAX_SECTORS); qsort(VAR_1->reqs, VAR_1->VAR_4, sizeof(*VAR_1->reqs), &multireq_compare); for (VAR_2 = 0; VAR_2 < VAR_1->VAR_4; VAR_2++) { VirtIOBlockReq *req = VAR_1->reqs[VAR_2]; if (VAR_4 > 0) { if (sector_num + VAR_6 != req->sector_num || VAR_5 > blk_get_max_iov(VAR_0) - req->qiov.VAR_5 || req->qiov.size / BDRV_SECTOR_SIZE > VAR_7 || VAR_6 > VAR_7 - req->qiov.size / BDRV_SECTOR_SIZE) { submit_requests(VAR_0, VAR_1, VAR_3, VAR_4, VAR_5); VAR_4 = 0; } } if (VAR_4 == 0) { sector_num = req->sector_num; VAR_6 = VAR_5 = 0; VAR_3 = VAR_2; } VAR_6 += req->qiov.size / BDRV_SECTOR_SIZE; VAR_5 += req->qiov.VAR_5; VAR_4++; } submit_requests(VAR_0, VAR_1, VAR_3, VAR_4, VAR_5); VAR_1->VAR_4 = 0; }
[ "void FUNC_0(BlockBackend *VAR_0, MultiReqBuffer *VAR_1)\n{", "int VAR_2 = 0, VAR_3 = 0, VAR_4 = 0, VAR_5 = 0, VAR_6 = 0;", "int VAR_7 = 0;", "int64_t sector_num = 0;", "if (VAR_1->VAR_4 == 1) {", "submit_requests(VAR_0, VAR_1, 0, 1, -1);", "VAR_1->VAR_4 = 0;", "return;", "}", "VAR_7 = blk_get_max_transfer_length(VAR_1->reqs[0]->dev->VAR_0);", "VAR_7 = MIN_NON_ZERO(VAR_7, BDRV_REQUEST_MAX_SECTORS);", "qsort(VAR_1->reqs, VAR_1->VAR_4, sizeof(*VAR_1->reqs),\n&multireq_compare);", "for (VAR_2 = 0; VAR_2 < VAR_1->VAR_4; VAR_2++) {", "VirtIOBlockReq *req = VAR_1->reqs[VAR_2];", "if (VAR_4 > 0) {", "if (sector_num + VAR_6 != req->sector_num ||\nVAR_5 > blk_get_max_iov(VAR_0) - req->qiov.VAR_5 ||\nreq->qiov.size / BDRV_SECTOR_SIZE > VAR_7 ||\nVAR_6 > VAR_7 - req->qiov.size / BDRV_SECTOR_SIZE) {", "submit_requests(VAR_0, VAR_1, VAR_3, VAR_4, VAR_5);", "VAR_4 = 0;", "}", "}", "if (VAR_4 == 0) {", "sector_num = req->sector_num;", "VAR_6 = VAR_5 = 0;", "VAR_3 = VAR_2;", "}", "VAR_6 += req->qiov.size / BDRV_SECTOR_SIZE;", "VAR_5 += req->qiov.VAR_5;", "VAR_4++;", "}", "submit_requests(VAR_0, VAR_1, VAR_3, VAR_4, VAR_5);", "VAR_1->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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 31, 33 ], [ 37 ], [ 39 ], [ 41 ], [ 55, 57, 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ] ]
20,232
MemoryRegion *iotlb_to_region(hwaddr index) { return address_space_memory.dispatch->sections[index & ~TARGET_PAGE_MASK].mr; }
false
qemu
53cb28cbfea038f8ad50132dc8a684e638c7d48b
MemoryRegion *iotlb_to_region(hwaddr index) { return address_space_memory.dispatch->sections[index & ~TARGET_PAGE_MASK].mr; }
{ "code": [], "line_no": [] }
MemoryRegion *FUNC_0(hwaddr index) { return address_space_memory.dispatch->sections[index & ~TARGET_PAGE_MASK].mr; }
[ "MemoryRegion *FUNC_0(hwaddr index)\n{", "return address_space_memory.dispatch->sections[index & ~TARGET_PAGE_MASK].mr;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
20,234
static void restore_native_fp_fxrstor(CPUState *env) { struct fpxstate *fp = &fpx1; int i, j, fptag; fp->fpuc = env->fpuc; fp->fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; fptag = 0; for(i = 0; i < 8; i++) fptag |= (env->fptags[i] << i); fp->fptag = fptag ^ 0xff; j = env->fpstt; for(i = 0;i < 8; i++) { memcpy(&fp->fpregs1[i * 16], &env->fpregs[j].d, 10); j = (j + 1) & 7; } if (env->cpuid_features & CPUID_SSE) { fp->mxcsr = env->mxcsr; /* XXX: check if DAZ is not available */ fp->mxcsr_mask = 0xffff; memcpy(fp->xmm_regs, env->xmm_regs, CPU_NB_REGS * 16); } asm volatile ("fxrstor %0" : "=m" (*fp)); }
false
qemu
4a1418e07bdcfaa3177739e04707ecaec75d89e1
static void restore_native_fp_fxrstor(CPUState *env) { struct fpxstate *fp = &fpx1; int i, j, fptag; fp->fpuc = env->fpuc; fp->fpus = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; fptag = 0; for(i = 0; i < 8; i++) fptag |= (env->fptags[i] << i); fp->fptag = fptag ^ 0xff; j = env->fpstt; for(i = 0;i < 8; i++) { memcpy(&fp->fpregs1[i * 16], &env->fpregs[j].d, 10); j = (j + 1) & 7; } if (env->cpuid_features & CPUID_SSE) { fp->mxcsr = env->mxcsr; fp->mxcsr_mask = 0xffff; memcpy(fp->xmm_regs, env->xmm_regs, CPU_NB_REGS * 16); } asm volatile ("fxrstor %0" : "=m" (*fp)); }
{ "code": [], "line_no": [] }
static void FUNC_0(CPUState *VAR_0) { struct fpxstate *VAR_1 = &fpx1; int VAR_2, VAR_3, VAR_4; VAR_1->fpuc = VAR_0->fpuc; VAR_1->fpus = (VAR_0->fpus & ~0x3800) | (VAR_0->fpstt & 0x7) << 11; VAR_4 = 0; for(VAR_2 = 0; VAR_2 < 8; VAR_2++) VAR_4 |= (VAR_0->fptags[VAR_2] << VAR_2); VAR_1->VAR_4 = VAR_4 ^ 0xff; VAR_3 = VAR_0->fpstt; for(VAR_2 = 0;VAR_2 < 8; VAR_2++) { memcpy(&VAR_1->fpregs1[VAR_2 * 16], &VAR_0->fpregs[VAR_3].d, 10); VAR_3 = (VAR_3 + 1) & 7; } if (VAR_0->cpuid_features & CPUID_SSE) { VAR_1->mxcsr = VAR_0->mxcsr; VAR_1->mxcsr_mask = 0xffff; memcpy(VAR_1->xmm_regs, VAR_0->xmm_regs, CPU_NB_REGS * 16); } asm volatile ("fxrstor %0" : "=m" (*VAR_1)); }
[ "static void FUNC_0(CPUState *VAR_0)\n{", "struct fpxstate *VAR_1 = &fpx1;", "int VAR_2, VAR_3, VAR_4;", "VAR_1->fpuc = VAR_0->fpuc;", "VAR_1->fpus = (VAR_0->fpus & ~0x3800) | (VAR_0->fpstt & 0x7) << 11;", "VAR_4 = 0;", "for(VAR_2 = 0; VAR_2 < 8; VAR_2++)", "VAR_4 |= (VAR_0->fptags[VAR_2] << VAR_2);", "VAR_1->VAR_4 = VAR_4 ^ 0xff;", "VAR_3 = VAR_0->fpstt;", "for(VAR_2 = 0;VAR_2 < 8; VAR_2++) {", "memcpy(&VAR_1->fpregs1[VAR_2 * 16], &VAR_0->fpregs[VAR_3].d, 10);", "VAR_3 = (VAR_3 + 1) & 7;", "}", "if (VAR_0->cpuid_features & CPUID_SSE) {", "VAR_1->mxcsr = VAR_0->mxcsr;", "VAR_1->mxcsr_mask = 0xffff;", "memcpy(VAR_1->xmm_regs, VAR_0->xmm_regs, CPU_NB_REGS * 16);", "}", "asm volatile (\"fxrstor %0\" : \"=m\" (*VAR_1));", "}" ]
[ 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 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ] ]
20,235
static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type) { int ret; struct flock fl = { .l_whence = SEEK_SET, .l_start = start, .l_len = len, .l_type = fl_type, }; ret = fcntl(fd, QEMU_SETLK, &fl); return ret == -1 ? -errno : 0; }
false
qemu
ca749954b09b89e22cd69c4949fb7e689b057963
static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type) { int ret; struct flock fl = { .l_whence = SEEK_SET, .l_start = start, .l_len = len, .l_type = fl_type, }; ret = fcntl(fd, QEMU_SETLK, &fl); return ret == -1 ? -errno : 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(int VAR_0, int64_t VAR_1, int64_t VAR_2, int VAR_3) { int VAR_4; struct flock VAR_5 = { .l_whence = SEEK_SET, .l_start = VAR_1, .l_len = VAR_2, .l_type = VAR_3, }; VAR_4 = fcntl(VAR_0, QEMU_SETLK, &VAR_5); return VAR_4 == -1 ? -errno : 0; }
[ "static int FUNC_0(int VAR_0, int64_t VAR_1, int64_t VAR_2, int VAR_3)\n{", "int VAR_4;", "struct flock VAR_5 = {", ".l_whence = SEEK_SET,\n.l_start = VAR_1,\n.l_len = VAR_2,\n.l_type = VAR_3,\n};", "VAR_4 = fcntl(VAR_0, QEMU_SETLK, &VAR_5);", "return VAR_4 == -1 ? -errno : 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9, 11, 13, 15, 17 ], [ 19 ], [ 21 ], [ 23 ] ]
20,236
static bool qemu_co_queue_do_restart(CoQueue *queue, bool single) { Coroutine *next; CoQueueNextData *data; if (QTAILQ_EMPTY(&queue->entries)) { return false; } data = g_slice_new(CoQueueNextData); data->bh = aio_bh_new(queue->ctx, qemu_co_queue_next_bh, data); QTAILQ_INIT(&data->entries); qemu_bh_schedule(data->bh); while ((next = QTAILQ_FIRST(&queue->entries)) != NULL) { QTAILQ_REMOVE(&queue->entries, next, co_queue_next); QTAILQ_INSERT_TAIL(&data->entries, next, co_queue_next); trace_qemu_co_queue_next(next); if (single) { break; } } return true; }
false
qemu
02ffb504485f0920cfc75a0982a602f824a9a4f4
static bool qemu_co_queue_do_restart(CoQueue *queue, bool single) { Coroutine *next; CoQueueNextData *data; if (QTAILQ_EMPTY(&queue->entries)) { return false; } data = g_slice_new(CoQueueNextData); data->bh = aio_bh_new(queue->ctx, qemu_co_queue_next_bh, data); QTAILQ_INIT(&data->entries); qemu_bh_schedule(data->bh); while ((next = QTAILQ_FIRST(&queue->entries)) != NULL) { QTAILQ_REMOVE(&queue->entries, next, co_queue_next); QTAILQ_INSERT_TAIL(&data->entries, next, co_queue_next); trace_qemu_co_queue_next(next); if (single) { break; } } return true; }
{ "code": [], "line_no": [] }
static bool FUNC_0(CoQueue *queue, bool single) { Coroutine *next; CoQueueNextData *data; if (QTAILQ_EMPTY(&queue->entries)) { return false; } data = g_slice_new(CoQueueNextData); data->bh = aio_bh_new(queue->ctx, qemu_co_queue_next_bh, data); QTAILQ_INIT(&data->entries); qemu_bh_schedule(data->bh); while ((next = QTAILQ_FIRST(&queue->entries)) != NULL) { QTAILQ_REMOVE(&queue->entries, next, co_queue_next); QTAILQ_INSERT_TAIL(&data->entries, next, co_queue_next); trace_qemu_co_queue_next(next); if (single) { break; } } return true; }
[ "static bool FUNC_0(CoQueue *queue, bool single)\n{", "Coroutine *next;", "CoQueueNextData *data;", "if (QTAILQ_EMPTY(&queue->entries)) {", "return false;", "}", "data = g_slice_new(CoQueueNextData);", "data->bh = aio_bh_new(queue->ctx, qemu_co_queue_next_bh, data);", "QTAILQ_INIT(&data->entries);", "qemu_bh_schedule(data->bh);", "while ((next = QTAILQ_FIRST(&queue->entries)) != NULL) {", "QTAILQ_REMOVE(&queue->entries, next, co_queue_next);", "QTAILQ_INSERT_TAIL(&data->entries, next, co_queue_next);", "trace_qemu_co_queue_next(next);", "if (single) {", "break;", "}", "}", "return true;", "}" ]
[ 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 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ] ]
20,239
void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap, uint64_t start, uint64_t count, bool finish) { hbitmap_deserialize_zeroes(bitmap->bitmap, start, count, finish); }
false
qemu
86f6ae67e157362f3b141649874213ce01dcc622
void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap, uint64_t start, uint64_t count, bool finish) { hbitmap_deserialize_zeroes(bitmap->bitmap, start, count, finish); }
{ "code": [], "line_no": [] }
void FUNC_0(BdrvDirtyBitmap *VAR_0, uint64_t VAR_1, uint64_t VAR_2, bool VAR_3) { hbitmap_deserialize_zeroes(VAR_0->VAR_0, VAR_1, VAR_2, VAR_3); }
[ "void FUNC_0(BdrvDirtyBitmap *VAR_0,\nuint64_t VAR_1, uint64_t VAR_2,\nbool VAR_3)\n{", "hbitmap_deserialize_zeroes(VAR_0->VAR_0, VAR_1, VAR_2, VAR_3);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ] ]
20,242
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb) { enum AVCodecID codec_id; unsigned v; int len, tag; int ret; int object_type_id = avio_r8(pb); avio_r8(pb); /* stream type */ avio_rb24(pb); /* buffer size db */ v = avio_rb32(pb); // TODO: fix this with codecpar #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS if (v < INT32_MAX) st->codec->rc_max_rate = v; FF_ENABLE_DEPRECATION_WARNINGS #endif st->codecpar->bit_rate = avio_rb32(pb); /* avg bitrate */ codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id); if (codec_id) st->codecpar->codec_id = codec_id; av_log(fc, AV_LOG_TRACE, "esds object type id 0x%02x\n", object_type_id); len = ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4DecSpecificDescrTag) { av_log(fc, AV_LOG_TRACE, "Specific MPEG-4 header len=%d\n", len); if (!len || (uint64_t)len > (1<<30)) return -1; av_free(st->codecpar->extradata); if ((ret = ff_get_extradata(fc, st->codecpar, pb, len)) < 0) return ret; if (st->codecpar->codec_id == AV_CODEC_ID_AAC) { MPEG4AudioConfig cfg = {0}; avpriv_mpeg4audio_get_config(&cfg, st->codecpar->extradata, st->codecpar->extradata_size * 8, 1); st->codecpar->channels = cfg.channels; if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4 st->codecpar->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index]; else if (cfg.ext_sample_rate) st->codecpar->sample_rate = cfg.ext_sample_rate; else st->codecpar->sample_rate = cfg.sample_rate; av_log(fc, AV_LOG_TRACE, "mp4a config channels %d obj %d ext obj %d " "sample rate %d ext sample rate %d\n", st->codecpar->channels, cfg.object_type, cfg.ext_object_type, cfg.sample_rate, cfg.ext_sample_rate); if (!(st->codecpar->codec_id = ff_codec_get_id(mp4_audio_types, cfg.object_type))) st->codecpar->codec_id = AV_CODEC_ID_AAC; } } return 0; }
false
FFmpeg
074775462283e59657fbd18e76435371a2b80fda
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb) { enum AVCodecID codec_id; unsigned v; int len, tag; int ret; int object_type_id = avio_r8(pb); avio_r8(pb); avio_rb24(pb); v = avio_rb32(pb); #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS if (v < INT32_MAX) st->codec->rc_max_rate = v; FF_ENABLE_DEPRECATION_WARNINGS #endif st->codecpar->bit_rate = avio_rb32(pb); codec_id= ff_codec_get_id(ff_mp4_obj_type, object_type_id); if (codec_id) st->codecpar->codec_id = codec_id; av_log(fc, AV_LOG_TRACE, "esds object type id 0x%02x\n", object_type_id); len = ff_mp4_read_descr(fc, pb, &tag); if (tag == MP4DecSpecificDescrTag) { av_log(fc, AV_LOG_TRACE, "Specific MPEG-4 header len=%d\n", len); if (!len || (uint64_t)len > (1<<30)) return -1; av_free(st->codecpar->extradata); if ((ret = ff_get_extradata(fc, st->codecpar, pb, len)) < 0) return ret; if (st->codecpar->codec_id == AV_CODEC_ID_AAC) { MPEG4AudioConfig cfg = {0}; avpriv_mpeg4audio_get_config(&cfg, st->codecpar->extradata, st->codecpar->extradata_size * 8, 1); st->codecpar->channels = cfg.channels; if (cfg.object_type == 29 && cfg.sampling_index < 3) st->codecpar->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index]; else if (cfg.ext_sample_rate) st->codecpar->sample_rate = cfg.ext_sample_rate; else st->codecpar->sample_rate = cfg.sample_rate; av_log(fc, AV_LOG_TRACE, "mp4a config channels %d obj %d ext obj %d " "sample rate %d ext sample rate %d\n", st->codecpar->channels, cfg.object_type, cfg.ext_object_type, cfg.sample_rate, cfg.ext_sample_rate); if (!(st->codecpar->codec_id = ff_codec_get_id(mp4_audio_types, cfg.object_type))) st->codecpar->codec_id = AV_CODEC_ID_AAC; } } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVIOContext *VAR_2) { enum AVCodecID VAR_3; unsigned VAR_4; int VAR_5, VAR_6; int VAR_7; int VAR_8 = avio_r8(VAR_2); avio_r8(VAR_2); avio_rb24(VAR_2); VAR_4 = avio_rb32(VAR_2); #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS if (VAR_4 < INT32_MAX) VAR_1->codec->rc_max_rate = VAR_4; FF_ENABLE_DEPRECATION_WARNINGS #endif VAR_1->codecpar->bit_rate = avio_rb32(VAR_2); VAR_3= ff_codec_get_id(ff_mp4_obj_type, VAR_8); if (VAR_3) VAR_1->codecpar->VAR_3 = VAR_3; av_log(VAR_0, AV_LOG_TRACE, "esds object type id 0x%02x\n", VAR_8); VAR_5 = ff_mp4_read_descr(VAR_0, VAR_2, &VAR_6); if (VAR_6 == MP4DecSpecificDescrTag) { av_log(VAR_0, AV_LOG_TRACE, "Specific MPEG-4 header VAR_5=%d\n", VAR_5); if (!VAR_5 || (uint64_t)VAR_5 > (1<<30)) return -1; av_free(VAR_1->codecpar->extradata); if ((VAR_7 = ff_get_extradata(VAR_0, VAR_1->codecpar, VAR_2, VAR_5)) < 0) return VAR_7; if (VAR_1->codecpar->VAR_3 == AV_CODEC_ID_AAC) { MPEG4AudioConfig cfg = {0}; avpriv_mpeg4audio_get_config(&cfg, VAR_1->codecpar->extradata, VAR_1->codecpar->extradata_size * 8, 1); VAR_1->codecpar->channels = cfg.channels; if (cfg.object_type == 29 && cfg.sampling_index < 3) VAR_1->codecpar->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index]; else if (cfg.ext_sample_rate) VAR_1->codecpar->sample_rate = cfg.ext_sample_rate; else VAR_1->codecpar->sample_rate = cfg.sample_rate; av_log(VAR_0, AV_LOG_TRACE, "mp4a config channels %d obj %d ext obj %d " "sample rate %d ext sample rate %d\n", VAR_1->codecpar->channels, cfg.object_type, cfg.ext_object_type, cfg.sample_rate, cfg.ext_sample_rate); if (!(VAR_1->codecpar->VAR_3 = ff_codec_get_id(mp4_audio_types, cfg.object_type))) VAR_1->codecpar->VAR_3 = AV_CODEC_ID_AAC; } } return 0; }
[ "int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVIOContext *VAR_2)\n{", "enum AVCodecID VAR_3;", "unsigned VAR_4;", "int VAR_5, VAR_6;", "int VAR_7;", "int VAR_8 = avio_r8(VAR_2);", "avio_r8(VAR_2);", "avio_rb24(VAR_2);", "VAR_4 = avio_rb32(VAR_2);", "#if FF_API_LAVF_AVCTX\nFF_DISABLE_DEPRECATION_WARNINGS\nif (VAR_4 < INT32_MAX)\nVAR_1->codec->rc_max_rate = VAR_4;", "FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nVAR_1->codecpar->bit_rate = avio_rb32(VAR_2);", "VAR_3= ff_codec_get_id(ff_mp4_obj_type, VAR_8);", "if (VAR_3)\nVAR_1->codecpar->VAR_3 = VAR_3;", "av_log(VAR_0, AV_LOG_TRACE, \"esds object type id 0x%02x\\n\", VAR_8);", "VAR_5 = ff_mp4_read_descr(VAR_0, VAR_2, &VAR_6);", "if (VAR_6 == MP4DecSpecificDescrTag) {", "av_log(VAR_0, AV_LOG_TRACE, \"Specific MPEG-4 header VAR_5=%d\\n\", VAR_5);", "if (!VAR_5 || (uint64_t)VAR_5 > (1<<30))\nreturn -1;", "av_free(VAR_1->codecpar->extradata);", "if ((VAR_7 = ff_get_extradata(VAR_0, VAR_1->codecpar, VAR_2, VAR_5)) < 0)\nreturn VAR_7;", "if (VAR_1->codecpar->VAR_3 == AV_CODEC_ID_AAC) {", "MPEG4AudioConfig cfg = {0};", "avpriv_mpeg4audio_get_config(&cfg, VAR_1->codecpar->extradata,\nVAR_1->codecpar->extradata_size * 8, 1);", "VAR_1->codecpar->channels = cfg.channels;", "if (cfg.object_type == 29 && cfg.sampling_index < 3)\nVAR_1->codecpar->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index];", "else if (cfg.ext_sample_rate)\nVAR_1->codecpar->sample_rate = cfg.ext_sample_rate;", "else\nVAR_1->codecpar->sample_rate = cfg.sample_rate;", "av_log(VAR_0, AV_LOG_TRACE, \"mp4a config channels %d obj %d ext obj %d \"\n\"sample rate %d ext sample rate %d\\n\", VAR_1->codecpar->channels,\ncfg.object_type, cfg.ext_object_type,\ncfg.sample_rate, cfg.ext_sample_rate);", "if (!(VAR_1->codecpar->VAR_3 = ff_codec_get_id(mp4_audio_types,\ncfg.object_type)))\nVAR_1->codecpar->VAR_3 = AV_CODEC_ID_AAC;", "}", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 27, 29, 31, 33 ], [ 35, 37, 41 ], [ 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, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ] ]
20,244
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) { ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx }; if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8) return 0; av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h); return AVERROR(EINVAL); }
false
FFmpeg
7c91b3021c7af9bea6b65f51d645f7574a883870
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx) { ImgUtils imgutils = { &imgutils_class, log_offset, log_ctx }; if ((int)w>0 && (int)h>0 && (w+128)*(uint64_t)(h+128) < INT_MAX/8) return 0; av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h); return AVERROR(EINVAL); }
{ "code": [], "line_no": [] }
int FUNC_0(unsigned int VAR_0, unsigned int VAR_1, int VAR_2, void *VAR_3) { ImgUtils imgutils = { &imgutils_class, VAR_2, VAR_3 }; if ((int)VAR_0>0 && (int)VAR_1>0 && (VAR_0+128)*(uint64_t)(VAR_1+128) < INT_MAX/8) return 0; av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", VAR_0, VAR_1); return AVERROR(EINVAL); }
[ "int FUNC_0(unsigned int VAR_0, unsigned int VAR_1, int VAR_2, void *VAR_3)\n{", "ImgUtils imgutils = { &imgutils_class, VAR_2, VAR_3 };", "if ((int)VAR_0>0 && (int)VAR_1>0 && (VAR_0+128)*(uint64_t)(VAR_1+128) < INT_MAX/8)\nreturn 0;", "av_log(&imgutils, AV_LOG_ERROR, \"Picture size %ux%u is invalid\\n\", VAR_0, VAR_1);", "return AVERROR(EINVAL);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 19 ] ]
20,245
void qemu_aio_unref(void *p) { BlockAIOCB *acb = p; assert(acb->refcnt > 0); if (--acb->refcnt == 0) { g_free(acb); } }
false
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
void qemu_aio_unref(void *p) { BlockAIOCB *acb = p; assert(acb->refcnt > 0); if (--acb->refcnt == 0) { g_free(acb); } }
{ "code": [], "line_no": [] }
void FUNC_0(void *VAR_0) { BlockAIOCB *acb = VAR_0; assert(acb->refcnt > 0); if (--acb->refcnt == 0) { g_free(acb); } }
[ "void FUNC_0(void *VAR_0)\n{", "BlockAIOCB *acb = VAR_0;", "assert(acb->refcnt > 0);", "if (--acb->refcnt == 0) {", "g_free(acb);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
20,246
void helper_store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask) { /* * We use only the 32 LSB of the incoming fpr */ uint32_t prev, new; int i; prev = env->fpscr; new = (uint32_t)arg; new &= ~0x60000000; new |= prev & 0x60000000; for (i = 0; i < 8; i++) { if (mask & (1 << i)) { env->fpscr &= ~(0xF << (4 * i)); env->fpscr |= new & (0xF << (4 * i)); } } /* Update VX and FEX */ if (fpscr_ix != 0) { env->fpscr |= 1 << FPSCR_VX; } else { env->fpscr &= ~(1 << FPSCR_VX); } if ((fpscr_ex & fpscr_eex) != 0) { env->fpscr |= 1 << FPSCR_FEX; env->exception_index = POWERPC_EXCP_PROGRAM; /* XXX: we should compute it properly */ env->error_code = POWERPC_EXCP_FP; } else { env->fpscr &= ~(1 << FPSCR_FEX); } fpscr_set_rounding_mode(env); }
false
qemu
7d08d85645def18eac2a9d672c1868a35e0bcf79
void helper_store_fpscr(CPUPPCState *env, uint64_t arg, uint32_t mask) { uint32_t prev, new; int i; prev = env->fpscr; new = (uint32_t)arg; new &= ~0x60000000; new |= prev & 0x60000000; for (i = 0; i < 8; i++) { if (mask & (1 << i)) { env->fpscr &= ~(0xF << (4 * i)); env->fpscr |= new & (0xF << (4 * i)); } } if (fpscr_ix != 0) { env->fpscr |= 1 << FPSCR_VX; } else { env->fpscr &= ~(1 << FPSCR_VX); } if ((fpscr_ex & fpscr_eex) != 0) { env->fpscr |= 1 << FPSCR_FEX; env->exception_index = POWERPC_EXCP_PROGRAM; env->error_code = POWERPC_EXCP_FP; } else { env->fpscr &= ~(1 << FPSCR_FEX); } fpscr_set_rounding_mode(env); }
{ "code": [], "line_no": [] }
void FUNC_0(CPUPPCState *VAR_0, uint64_t VAR_1, uint32_t VAR_2) { uint32_t prev, new; int VAR_3; prev = VAR_0->fpscr; new = (uint32_t)VAR_1; new &= ~0x60000000; new |= prev & 0x60000000; for (VAR_3 = 0; VAR_3 < 8; VAR_3++) { if (VAR_2 & (1 << VAR_3)) { VAR_0->fpscr &= ~(0xF << (4 * VAR_3)); VAR_0->fpscr |= new & (0xF << (4 * VAR_3)); } } if (fpscr_ix != 0) { VAR_0->fpscr |= 1 << FPSCR_VX; } else { VAR_0->fpscr &= ~(1 << FPSCR_VX); } if ((fpscr_ex & fpscr_eex) != 0) { VAR_0->fpscr |= 1 << FPSCR_FEX; VAR_0->exception_index = POWERPC_EXCP_PROGRAM; VAR_0->error_code = POWERPC_EXCP_FP; } else { VAR_0->fpscr &= ~(1 << FPSCR_FEX); } fpscr_set_rounding_mode(VAR_0); }
[ "void FUNC_0(CPUPPCState *VAR_0, uint64_t VAR_1, uint32_t VAR_2)\n{", "uint32_t prev, new;", "int VAR_3;", "prev = VAR_0->fpscr;", "new = (uint32_t)VAR_1;", "new &= ~0x60000000;", "new |= prev & 0x60000000;", "for (VAR_3 = 0; VAR_3 < 8; VAR_3++) {", "if (VAR_2 & (1 << VAR_3)) {", "VAR_0->fpscr &= ~(0xF << (4 * VAR_3));", "VAR_0->fpscr |= new & (0xF << (4 * VAR_3));", "}", "}", "if (fpscr_ix != 0) {", "VAR_0->fpscr |= 1 << FPSCR_VX;", "} else {", "VAR_0->fpscr &= ~(1 << FPSCR_VX);", "}", "if ((fpscr_ex & fpscr_eex) != 0) {", "VAR_0->fpscr |= 1 << FPSCR_FEX;", "VAR_0->exception_index = POWERPC_EXCP_PROGRAM;", "VAR_0->error_code = POWERPC_EXCP_FP;", "} else {", "VAR_0->fpscr &= ~(1 << FPSCR_FEX);", "}", "fpscr_set_rounding_mode(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 ]
[ [ 1, 3 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ] ]
20,247
static void gen_compute_branch1 (CPUState *env, DisasContext *ctx, uint32_t op, int32_t cc, int32_t offset) { target_ulong btarget; const char *opn = "cp1 cond branch"; TCGv t0 = tcg_temp_local_new(TCG_TYPE_TL); TCGv t1 = tcg_temp_local_new(TCG_TYPE_TL); if (cc != 0) check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); btarget = ctx->pc + 4 + offset; switch (op) { case OPC_BC1F: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0x1 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1f"; goto not_likely; case OPC_BC1FL: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0x1 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1fl"; goto likely; case OPC_BC1T: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0x1 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1t"; goto not_likely; case OPC_BC1TL: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0x1 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1tl"; likely: ctx->hflags |= MIPS_HFLAG_BL; tcg_gen_trunc_tl_i32(bcond, t0); break; case OPC_BC1FANY2: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0x3 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1any2f"; goto not_likely; case OPC_BC1TANY2: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0x3 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1any2t"; goto not_likely; case OPC_BC1FANY4: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0xf << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1any4f"; goto not_likely; case OPC_BC1TANY4: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0xf << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1any4t"; not_likely: ctx->hflags |= MIPS_HFLAG_BC; tcg_gen_trunc_tl_i32(bcond, t0); break; default: MIPS_INVAL(opn); generate_exception (ctx, EXCP_RI); goto out; } MIPS_DEBUG("%s: cond %02x target " TARGET_FMT_lx, opn, ctx->hflags, btarget); ctx->btarget = btarget; out: tcg_temp_free(t0); tcg_temp_free(t1); }
false
qemu
a6e92a658b99b4ab3b19b2f32352005e6190556f
static void gen_compute_branch1 (CPUState *env, DisasContext *ctx, uint32_t op, int32_t cc, int32_t offset) { target_ulong btarget; const char *opn = "cp1 cond branch"; TCGv t0 = tcg_temp_local_new(TCG_TYPE_TL); TCGv t1 = tcg_temp_local_new(TCG_TYPE_TL); if (cc != 0) check_insn(env, ctx, ISA_MIPS4 | ISA_MIPS32); btarget = ctx->pc + 4 + offset; switch (op) { case OPC_BC1F: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0x1 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1f"; goto not_likely; case OPC_BC1FL: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0x1 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1fl"; goto likely; case OPC_BC1T: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0x1 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1t"; goto not_likely; case OPC_BC1TL: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0x1 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1tl"; likely: ctx->hflags |= MIPS_HFLAG_BL; tcg_gen_trunc_tl_i32(bcond, t0); break; case OPC_BC1FANY2: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0x3 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1any2f"; goto not_likely; case OPC_BC1TANY2: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0x3 << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1any2t"; goto not_likely; case OPC_BC1FANY4: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0xf << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1any4f"; goto not_likely; case OPC_BC1TANY4: { int l1 = gen_new_label(); int l2 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0xf << cc); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, l1); tcg_gen_movi_tl(t0, 0); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(t0, 1); gen_set_label(l2); } opn = "bc1any4t"; not_likely: ctx->hflags |= MIPS_HFLAG_BC; tcg_gen_trunc_tl_i32(bcond, t0); break; default: MIPS_INVAL(opn); generate_exception (ctx, EXCP_RI); goto out; } MIPS_DEBUG("%s: cond %02x target " TARGET_FMT_lx, opn, ctx->hflags, btarget); ctx->btarget = btarget; out: tcg_temp_free(t0); tcg_temp_free(t1); }
{ "code": [], "line_no": [] }
static void FUNC_0 (CPUState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2, int32_t VAR_3, int32_t VAR_4) { target_ulong btarget; const char *VAR_5 = "cp1 cond branch"; TCGv t0 = tcg_temp_local_new(TCG_TYPE_TL); TCGv t1 = tcg_temp_local_new(TCG_TYPE_TL); if (VAR_3 != 0) check_insn(VAR_0, VAR_1, ISA_MIPS4 | ISA_MIPS32); btarget = VAR_1->pc + 4 + VAR_4; switch (VAR_2) { case OPC_BC1F: { int VAR_8 = gen_new_label(); int VAR_8 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0x1 << VAR_3); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8); tcg_gen_movi_tl(t0, 0); tcg_gen_br(VAR_8); gen_set_label(VAR_8); tcg_gen_movi_tl(t0, 1); gen_set_label(VAR_8); } VAR_5 = "bc1f"; goto not_likely; case OPC_BC1FL: { int VAR_8 = gen_new_label(); int VAR_8 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0x1 << VAR_3); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8); tcg_gen_movi_tl(t0, 0); tcg_gen_br(VAR_8); gen_set_label(VAR_8); tcg_gen_movi_tl(t0, 1); gen_set_label(VAR_8); } VAR_5 = "bc1fl"; goto likely; case OPC_BC1T: { int VAR_8 = gen_new_label(); int VAR_8 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0x1 << VAR_3); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8); tcg_gen_movi_tl(t0, 0); tcg_gen_br(VAR_8); gen_set_label(VAR_8); tcg_gen_movi_tl(t0, 1); gen_set_label(VAR_8); } VAR_5 = "bc1t"; goto not_likely; case OPC_BC1TL: { int VAR_8 = gen_new_label(); int VAR_8 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0x1 << VAR_3); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8); tcg_gen_movi_tl(t0, 0); tcg_gen_br(VAR_8); gen_set_label(VAR_8); tcg_gen_movi_tl(t0, 1); gen_set_label(VAR_8); } VAR_5 = "bc1tl"; likely: VAR_1->hflags |= MIPS_HFLAG_BL; tcg_gen_trunc_tl_i32(bcond, t0); break; case OPC_BC1FANY2: { int VAR_8 = gen_new_label(); int VAR_8 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0x3 << VAR_3); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8); tcg_gen_movi_tl(t0, 0); tcg_gen_br(VAR_8); gen_set_label(VAR_8); tcg_gen_movi_tl(t0, 1); gen_set_label(VAR_8); } VAR_5 = "bc1any2f"; goto not_likely; case OPC_BC1TANY2: { int VAR_8 = gen_new_label(); int VAR_8 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0x3 << VAR_3); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8); tcg_gen_movi_tl(t0, 0); tcg_gen_br(VAR_8); gen_set_label(VAR_8); tcg_gen_movi_tl(t0, 1); gen_set_label(VAR_8); } VAR_5 = "bc1any2t"; goto not_likely; case OPC_BC1FANY4: { int VAR_8 = gen_new_label(); int VAR_8 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_not_tl(t0, t0); tcg_gen_movi_tl(t1, 0xf << VAR_3); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8); tcg_gen_movi_tl(t0, 0); tcg_gen_br(VAR_8); gen_set_label(VAR_8); tcg_gen_movi_tl(t0, 1); gen_set_label(VAR_8); } VAR_5 = "bc1any4f"; goto not_likely; case OPC_BC1TANY4: { int VAR_8 = gen_new_label(); int VAR_8 = gen_new_label(); TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32); get_fp_cond(r_tmp1); tcg_gen_ext_i32_tl(t0, r_tmp1); tcg_temp_free(r_tmp1); tcg_gen_movi_tl(t1, 0xf << VAR_3); tcg_gen_and_tl(t0, t0, t1); tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8); tcg_gen_movi_tl(t0, 0); tcg_gen_br(VAR_8); gen_set_label(VAR_8); tcg_gen_movi_tl(t0, 1); gen_set_label(VAR_8); } VAR_5 = "bc1any4t"; not_likely: VAR_1->hflags |= MIPS_HFLAG_BC; tcg_gen_trunc_tl_i32(bcond, t0); break; default: MIPS_INVAL(VAR_5); generate_exception (VAR_1, EXCP_RI); goto out; } MIPS_DEBUG("%s: cond %02x target " TARGET_FMT_lx, VAR_5, VAR_1->hflags, btarget); VAR_1->btarget = btarget; out: tcg_temp_free(t0); tcg_temp_free(t1); }
[ "static void FUNC_0 (CPUState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2,\nint32_t VAR_3, int32_t VAR_4)\n{", "target_ulong btarget;", "const char *VAR_5 = \"cp1 cond branch\";", "TCGv t0 = tcg_temp_local_new(TCG_TYPE_TL);", "TCGv t1 = tcg_temp_local_new(TCG_TYPE_TL);", "if (VAR_3 != 0)\ncheck_insn(VAR_0, VAR_1, ISA_MIPS4 | ISA_MIPS32);", "btarget = VAR_1->pc + 4 + VAR_4;", "switch (VAR_2) {", "case OPC_BC1F:\n{", "int VAR_8 = gen_new_label();", "int VAR_8 = gen_new_label();", "TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);", "get_fp_cond(r_tmp1);", "tcg_gen_ext_i32_tl(t0, r_tmp1);", "tcg_temp_free(r_tmp1);", "tcg_gen_not_tl(t0, t0);", "tcg_gen_movi_tl(t1, 0x1 << VAR_3);", "tcg_gen_and_tl(t0, t0, t1);", "tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8);", "tcg_gen_movi_tl(t0, 0);", "tcg_gen_br(VAR_8);", "gen_set_label(VAR_8);", "tcg_gen_movi_tl(t0, 1);", "gen_set_label(VAR_8);", "}", "VAR_5 = \"bc1f\";", "goto not_likely;", "case OPC_BC1FL:\n{", "int VAR_8 = gen_new_label();", "int VAR_8 = gen_new_label();", "TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);", "get_fp_cond(r_tmp1);", "tcg_gen_ext_i32_tl(t0, r_tmp1);", "tcg_temp_free(r_tmp1);", "tcg_gen_not_tl(t0, t0);", "tcg_gen_movi_tl(t1, 0x1 << VAR_3);", "tcg_gen_and_tl(t0, t0, t1);", "tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8);", "tcg_gen_movi_tl(t0, 0);", "tcg_gen_br(VAR_8);", "gen_set_label(VAR_8);", "tcg_gen_movi_tl(t0, 1);", "gen_set_label(VAR_8);", "}", "VAR_5 = \"bc1fl\";", "goto likely;", "case OPC_BC1T:\n{", "int VAR_8 = gen_new_label();", "int VAR_8 = gen_new_label();", "TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);", "get_fp_cond(r_tmp1);", "tcg_gen_ext_i32_tl(t0, r_tmp1);", "tcg_temp_free(r_tmp1);", "tcg_gen_movi_tl(t1, 0x1 << VAR_3);", "tcg_gen_and_tl(t0, t0, t1);", "tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8);", "tcg_gen_movi_tl(t0, 0);", "tcg_gen_br(VAR_8);", "gen_set_label(VAR_8);", "tcg_gen_movi_tl(t0, 1);", "gen_set_label(VAR_8);", "}", "VAR_5 = \"bc1t\";", "goto not_likely;", "case OPC_BC1TL:\n{", "int VAR_8 = gen_new_label();", "int VAR_8 = gen_new_label();", "TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);", "get_fp_cond(r_tmp1);", "tcg_gen_ext_i32_tl(t0, r_tmp1);", "tcg_temp_free(r_tmp1);", "tcg_gen_movi_tl(t1, 0x1 << VAR_3);", "tcg_gen_and_tl(t0, t0, t1);", "tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8);", "tcg_gen_movi_tl(t0, 0);", "tcg_gen_br(VAR_8);", "gen_set_label(VAR_8);", "tcg_gen_movi_tl(t0, 1);", "gen_set_label(VAR_8);", "}", "VAR_5 = \"bc1tl\";", "likely:\nVAR_1->hflags |= MIPS_HFLAG_BL;", "tcg_gen_trunc_tl_i32(bcond, t0);", "break;", "case OPC_BC1FANY2:\n{", "int VAR_8 = gen_new_label();", "int VAR_8 = gen_new_label();", "TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);", "get_fp_cond(r_tmp1);", "tcg_gen_ext_i32_tl(t0, r_tmp1);", "tcg_temp_free(r_tmp1);", "tcg_gen_not_tl(t0, t0);", "tcg_gen_movi_tl(t1, 0x3 << VAR_3);", "tcg_gen_and_tl(t0, t0, t1);", "tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8);", "tcg_gen_movi_tl(t0, 0);", "tcg_gen_br(VAR_8);", "gen_set_label(VAR_8);", "tcg_gen_movi_tl(t0, 1);", "gen_set_label(VAR_8);", "}", "VAR_5 = \"bc1any2f\";", "goto not_likely;", "case OPC_BC1TANY2:\n{", "int VAR_8 = gen_new_label();", "int VAR_8 = gen_new_label();", "TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);", "get_fp_cond(r_tmp1);", "tcg_gen_ext_i32_tl(t0, r_tmp1);", "tcg_temp_free(r_tmp1);", "tcg_gen_movi_tl(t1, 0x3 << VAR_3);", "tcg_gen_and_tl(t0, t0, t1);", "tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8);", "tcg_gen_movi_tl(t0, 0);", "tcg_gen_br(VAR_8);", "gen_set_label(VAR_8);", "tcg_gen_movi_tl(t0, 1);", "gen_set_label(VAR_8);", "}", "VAR_5 = \"bc1any2t\";", "goto not_likely;", "case OPC_BC1FANY4:\n{", "int VAR_8 = gen_new_label();", "int VAR_8 = gen_new_label();", "TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);", "get_fp_cond(r_tmp1);", "tcg_gen_ext_i32_tl(t0, r_tmp1);", "tcg_temp_free(r_tmp1);", "tcg_gen_not_tl(t0, t0);", "tcg_gen_movi_tl(t1, 0xf << VAR_3);", "tcg_gen_and_tl(t0, t0, t1);", "tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8);", "tcg_gen_movi_tl(t0, 0);", "tcg_gen_br(VAR_8);", "gen_set_label(VAR_8);", "tcg_gen_movi_tl(t0, 1);", "gen_set_label(VAR_8);", "}", "VAR_5 = \"bc1any4f\";", "goto not_likely;", "case OPC_BC1TANY4:\n{", "int VAR_8 = gen_new_label();", "int VAR_8 = gen_new_label();", "TCGv r_tmp1 = tcg_temp_new(TCG_TYPE_I32);", "get_fp_cond(r_tmp1);", "tcg_gen_ext_i32_tl(t0, r_tmp1);", "tcg_temp_free(r_tmp1);", "tcg_gen_movi_tl(t1, 0xf << VAR_3);", "tcg_gen_and_tl(t0, t0, t1);", "tcg_gen_brcondi_tl(TCG_COND_NE, t0, 0, VAR_8);", "tcg_gen_movi_tl(t0, 0);", "tcg_gen_br(VAR_8);", "gen_set_label(VAR_8);", "tcg_gen_movi_tl(t0, 1);", "gen_set_label(VAR_8);", "}", "VAR_5 = \"bc1any4t\";", "not_likely:\nVAR_1->hflags |= MIPS_HFLAG_BC;", "tcg_gen_trunc_tl_i32(bcond, t0);", "break;", "default:\nMIPS_INVAL(VAR_5);", "generate_exception (VAR_1, EXCP_RI);", "goto out;", "}", "MIPS_DEBUG(\"%s: cond %02x target \" TARGET_FMT_lx, VAR_5,\nVAR_1->hflags, btarget);", "VAR_1->btarget = btarget;", "out:\ntcg_temp_free(t0);", "tcg_temp_free(t1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 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 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191, 193 ], [ 195 ], [ 197 ], [ 199, 201 ], [ 203 ], [ 205 ], [ 207 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241, 243 ], [ 245 ], [ 247 ], [ 249 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281, 283 ], [ 285 ], [ 287 ], [ 289 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323, 325 ], [ 327 ], [ 329 ], [ 331 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361, 363 ], [ 365 ], [ 367 ], [ 369, 371 ], [ 373 ], [ 375 ], [ 377 ], [ 379, 381 ], [ 383 ], [ 387, 389 ], [ 391 ], [ 393 ] ]
20,249
void kvm_s390_crw_mchk(void) { struct kvm_s390_irq irq = { .type = KVM_S390_MCHK, .u.mchk.cr14 = 1 << 28, .u.mchk.mcic = build_channel_report_mcic(), }; kvm_s390_floating_interrupt(&irq); }
false
qemu
b700d75eda81c371c575b759de8e260d9f147494
void kvm_s390_crw_mchk(void) { struct kvm_s390_irq irq = { .type = KVM_S390_MCHK, .u.mchk.cr14 = 1 << 28, .u.mchk.mcic = build_channel_report_mcic(), }; kvm_s390_floating_interrupt(&irq); }
{ "code": [], "line_no": [] }
void FUNC_0(void) { struct kvm_s390_irq VAR_0 = { .type = KVM_S390_MCHK, .u.mchk.cr14 = 1 << 28, .u.mchk.mcic = build_channel_report_mcic(), }; kvm_s390_floating_interrupt(&VAR_0); }
[ "void FUNC_0(void)\n{", "struct kvm_s390_irq VAR_0 = {", ".type = KVM_S390_MCHK,\n.u.mchk.cr14 = 1 << 28,\n.u.mchk.mcic = build_channel_report_mcic(),\n};", "kvm_s390_floating_interrupt(&VAR_0);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9, 11, 13 ], [ 15 ], [ 17 ] ]
20,250
void timerlistgroup_init(QEMUTimerListGroup *tlg, QEMUTimerListNotifyCB *cb, void *opaque) { QEMUClockType type; for (type = 0; type < QEMU_CLOCK_MAX; type++) { tlg->tl[type] = timerlist_new(type, cb, opaque); } }
false
qemu
c2b38b277a7882a592f4f2ec955084b2b756daaa
void timerlistgroup_init(QEMUTimerListGroup *tlg, QEMUTimerListNotifyCB *cb, void *opaque) { QEMUClockType type; for (type = 0; type < QEMU_CLOCK_MAX; type++) { tlg->tl[type] = timerlist_new(type, cb, opaque); } }
{ "code": [], "line_no": [] }
void FUNC_0(QEMUTimerListGroup *VAR_0, QEMUTimerListNotifyCB *VAR_1, void *VAR_2) { QEMUClockType type; for (type = 0; type < QEMU_CLOCK_MAX; type++) { VAR_0->tl[type] = timerlist_new(type, VAR_1, VAR_2); } }
[ "void FUNC_0(QEMUTimerListGroup *VAR_0,\nQEMUTimerListNotifyCB *VAR_1, void *VAR_2)\n{", "QEMUClockType type;", "for (type = 0; type < QEMU_CLOCK_MAX; type++) {", "VAR_0->tl[type] = timerlist_new(type, VAR_1, VAR_2);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
20,251
static ssize_t block_crypto_init_func(QCryptoBlock *block, size_t headerlen, Error **errp, void *opaque) { struct BlockCryptoCreateData *data = opaque; int ret; /* User provided size should reflect amount of space made * available to the guest, so we must take account of that * which will be used by the crypto header */ data->size += headerlen; qemu_opt_set_number(data->opts, BLOCK_OPT_SIZE, data->size, &error_abort); ret = bdrv_create_file(data->filename, data->opts, errp); if (ret < 0) { return -1; } data->blk = blk_new_open(data->filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, errp); if (!data->blk) { return -1; } return 0; }
false
qemu
375092332eeaa6e47561ce47fd36144cdaf964d0
static ssize_t block_crypto_init_func(QCryptoBlock *block, size_t headerlen, Error **errp, void *opaque) { struct BlockCryptoCreateData *data = opaque; int ret; data->size += headerlen; qemu_opt_set_number(data->opts, BLOCK_OPT_SIZE, data->size, &error_abort); ret = bdrv_create_file(data->filename, data->opts, errp); if (ret < 0) { return -1; } data->blk = blk_new_open(data->filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, errp); if (!data->blk) { return -1; } return 0; }
{ "code": [], "line_no": [] }
static ssize_t FUNC_0(QCryptoBlock *block, size_t headerlen, Error **errp, void *opaque) { struct BlockCryptoCreateData *VAR_0 = opaque; int VAR_1; VAR_0->size += headerlen; qemu_opt_set_number(VAR_0->opts, BLOCK_OPT_SIZE, VAR_0->size, &error_abort); VAR_1 = bdrv_create_file(VAR_0->filename, VAR_0->opts, errp); if (VAR_1 < 0) { return -1; } VAR_0->blk = blk_new_open(VAR_0->filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, errp); if (!VAR_0->blk) { return -1; } return 0; }
[ "static ssize_t FUNC_0(QCryptoBlock *block,\nsize_t headerlen,\nError **errp,\nvoid *opaque)\n{", "struct BlockCryptoCreateData *VAR_0 = opaque;", "int VAR_1;", "VAR_0->size += headerlen;", "qemu_opt_set_number(VAR_0->opts, BLOCK_OPT_SIZE, VAR_0->size, &error_abort);", "VAR_1 = bdrv_create_file(VAR_0->filename, VAR_0->opts, errp);", "if (VAR_1 < 0) {", "return -1;", "}", "VAR_0->blk = blk_new_open(VAR_0->filename, NULL, NULL,\nBDRV_O_RDWR | BDRV_O_PROTOCOL, errp);", "if (!VAR_0->blk) {", "return -1;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ] ]