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
|
---|---|---|---|---|---|---|---|---|---|---|
25,015 | static void memory_region_dispatch_write(MemoryRegion *mr,
hwaddr addr,
uint64_t data,
unsigned size)
{
if (!memory_region_access_valid(mr, addr, size, true)) {
return; /* FIXME: better signalling */
}
adjust_endianness(mr, &data, size);
if (!mr->ops->write) {
mr->ops->old_mmio.write[bitops_ctzl(size)](mr->opaque, addr, data);
return;
}
/* FIXME: support unaligned access */
access_with_adjusted_size(addr, &data, size,
mr->ops->impl.min_access_size,
mr->ops->impl.max_access_size,
memory_region_write_accessor, mr);
}
| false | qemu | 5bbf90be97203c472f47da070c0040b464c0460f | static void memory_region_dispatch_write(MemoryRegion *mr,
hwaddr addr,
uint64_t data,
unsigned size)
{
if (!memory_region_access_valid(mr, addr, size, true)) {
return;
}
adjust_endianness(mr, &data, size);
if (!mr->ops->write) {
mr->ops->old_mmio.write[bitops_ctzl(size)](mr->opaque, addr, data);
return;
}
access_with_adjusted_size(addr, &data, size,
mr->ops->impl.min_access_size,
mr->ops->impl.max_access_size,
memory_region_write_accessor, mr);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MemoryRegion *VAR_0,
hwaddr VAR_1,
uint64_t VAR_2,
unsigned VAR_3)
{
if (!memory_region_access_valid(VAR_0, VAR_1, VAR_3, true)) {
return;
}
adjust_endianness(VAR_0, &VAR_2, VAR_3);
if (!VAR_0->ops->write) {
VAR_0->ops->old_mmio.write[bitops_ctzl(VAR_3)](VAR_0->opaque, VAR_1, VAR_2);
return;
}
access_with_adjusted_size(VAR_1, &VAR_2, VAR_3,
VAR_0->ops->impl.min_access_size,
VAR_0->ops->impl.max_access_size,
memory_region_write_accessor, VAR_0);
}
| [
"static void FUNC_0(MemoryRegion *VAR_0,\nhwaddr VAR_1,\nuint64_t VAR_2,\nunsigned VAR_3)\n{",
"if (!memory_region_access_valid(VAR_0, VAR_1, VAR_3, true)) {",
"return;",
"}",
"adjust_endianness(VAR_0, &VAR_2, VAR_3);",
"if (!VAR_0->ops->write) {",
"VAR_0->ops->old_mmio.write[bitops_ctzl(VAR_3)](VAR_0->opaque, VAR_1, VAR_2);",
"return;",
"}",
"access_with_adjusted_size(VAR_1, &VAR_2, VAR_3,\nVAR_0->ops->impl.min_access_size,\nVAR_0->ops->impl.max_access_size,\nmemory_region_write_accessor, VAR_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
],
[
35,
37,
39,
41
],
[
43
]
] |
25,016 | int bdrv_eject(BlockDriverState *bs, int eject_flag)
{
BlockDriver *drv = bs->drv;
if (bs->locked) {
return -EBUSY;
}
if (drv && drv->bdrv_eject) {
drv->bdrv_eject(bs, eject_flag);
}
bs->tray_open = eject_flag;
return 0;
}
| false | qemu | 49aa46bb4b894ff8bdb0339ee2a5dd3fcfe93ecd | int bdrv_eject(BlockDriverState *bs, int eject_flag)
{
BlockDriver *drv = bs->drv;
if (bs->locked) {
return -EBUSY;
}
if (drv && drv->bdrv_eject) {
drv->bdrv_eject(bs, eject_flag);
}
bs->tray_open = eject_flag;
return 0;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(BlockDriverState *VAR_0, int VAR_1)
{
BlockDriver *drv = VAR_0->drv;
if (VAR_0->locked) {
return -EBUSY;
}
if (drv && drv->FUNC_0) {
drv->FUNC_0(VAR_0, VAR_1);
}
VAR_0->tray_open = VAR_1;
return 0;
}
| [
"int FUNC_0(BlockDriverState *VAR_0, int VAR_1)\n{",
"BlockDriver *drv = VAR_0->drv;",
"if (VAR_0->locked) {",
"return -EBUSY;",
"}",
"if (drv && drv->FUNC_0) {",
"drv->FUNC_0(VAR_0, VAR_1);",
"}",
"VAR_0->tray_open = VAR_1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
25,017 | static struct XenDevice *xen_be_del_xendev(int dom, int dev)
{
struct XenDevice *xendev, *xnext;
/*
* This is pretty much like QTAILQ_FOREACH(xendev, &xendevs, next) but
* we save the next pointer in xnext because we might free xendev.
*/
xnext = xendevs.tqh_first;
while (xnext) {
xendev = xnext;
xnext = xendev->next.tqe_next;
if (xendev->dom != dom) {
continue;
}
if (xendev->dev != dev && dev != -1) {
continue;
}
if (xendev->ops->free) {
xendev->ops->free(xendev);
}
if (xendev->fe) {
char token[XEN_BUFSIZE];
snprintf(token, sizeof(token), "fe:%p", xendev);
xs_unwatch(xenstore, xendev->fe, token);
g_free(xendev->fe);
}
if (xendev->evtchndev != XC_HANDLER_INITIAL_VALUE) {
xc_evtchn_close(xendev->evtchndev);
}
if (xendev->gnttabdev != XC_HANDLER_INITIAL_VALUE) {
xc_gnttab_close(xendev->gnttabdev);
}
QTAILQ_REMOVE(&xendevs, xendev, next);
g_free(xendev);
}
return NULL;
}
| false | qemu | a2db2a1edd06a50b8a862c654cf993368cf9f1d9 | static struct XenDevice *xen_be_del_xendev(int dom, int dev)
{
struct XenDevice *xendev, *xnext;
xnext = xendevs.tqh_first;
while (xnext) {
xendev = xnext;
xnext = xendev->next.tqe_next;
if (xendev->dom != dom) {
continue;
}
if (xendev->dev != dev && dev != -1) {
continue;
}
if (xendev->ops->free) {
xendev->ops->free(xendev);
}
if (xendev->fe) {
char token[XEN_BUFSIZE];
snprintf(token, sizeof(token), "fe:%p", xendev);
xs_unwatch(xenstore, xendev->fe, token);
g_free(xendev->fe);
}
if (xendev->evtchndev != XC_HANDLER_INITIAL_VALUE) {
xc_evtchn_close(xendev->evtchndev);
}
if (xendev->gnttabdev != XC_HANDLER_INITIAL_VALUE) {
xc_gnttab_close(xendev->gnttabdev);
}
QTAILQ_REMOVE(&xendevs, xendev, next);
g_free(xendev);
}
return NULL;
}
| {
"code": [],
"line_no": []
} | static struct XenDevice *FUNC_0(int VAR_0, int VAR_1)
{
struct XenDevice *VAR_2, *VAR_3;
VAR_3 = xendevs.tqh_first;
while (VAR_3) {
VAR_2 = VAR_3;
VAR_3 = VAR_2->next.tqe_next;
if (VAR_2->VAR_0 != VAR_0) {
continue;
}
if (VAR_2->VAR_1 != VAR_1 && VAR_1 != -1) {
continue;
}
if (VAR_2->ops->free) {
VAR_2->ops->free(VAR_2);
}
if (VAR_2->fe) {
char VAR_4[XEN_BUFSIZE];
snprintf(VAR_4, sizeof(VAR_4), "fe:%p", VAR_2);
xs_unwatch(xenstore, VAR_2->fe, VAR_4);
g_free(VAR_2->fe);
}
if (VAR_2->evtchndev != XC_HANDLER_INITIAL_VALUE) {
xc_evtchn_close(VAR_2->evtchndev);
}
if (VAR_2->gnttabdev != XC_HANDLER_INITIAL_VALUE) {
xc_gnttab_close(VAR_2->gnttabdev);
}
QTAILQ_REMOVE(&xendevs, VAR_2, next);
g_free(VAR_2);
}
return NULL;
}
| [
"static struct XenDevice *FUNC_0(int VAR_0, int VAR_1)\n{",
"struct XenDevice *VAR_2, *VAR_3;",
"VAR_3 = xendevs.tqh_first;",
"while (VAR_3) {",
"VAR_2 = VAR_3;",
"VAR_3 = VAR_2->next.tqe_next;",
"if (VAR_2->VAR_0 != VAR_0) {",
"continue;",
"}",
"if (VAR_2->VAR_1 != VAR_1 && VAR_1 != -1) {",
"continue;",
"}",
"if (VAR_2->ops->free) {",
"VAR_2->ops->free(VAR_2);",
"}",
"if (VAR_2->fe) {",
"char VAR_4[XEN_BUFSIZE];",
"snprintf(VAR_4, sizeof(VAR_4), \"fe:%p\", VAR_2);",
"xs_unwatch(xenstore, VAR_2->fe, VAR_4);",
"g_free(VAR_2->fe);",
"}",
"if (VAR_2->evtchndev != XC_HANDLER_INITIAL_VALUE) {",
"xc_evtchn_close(VAR_2->evtchndev);",
"}",
"if (VAR_2->gnttabdev != XC_HANDLER_INITIAL_VALUE) {",
"xc_gnttab_close(VAR_2->gnttabdev);",
"}",
"QTAILQ_REMOVE(&xendevs, VAR_2, next);",
"g_free(VAR_2);",
"}",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
]
] |
25,018 | static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, unsigned int max_pos, int depth) {
AVCodecContext *acodec, *vcodec;
ByteIOContext *ioc;
AMFDataType amf_type;
char str_val[256];
double num_val;
num_val = 0;
ioc = s->pb;
amf_type = get_byte(ioc);
switch(amf_type) {
case AMF_DATA_TYPE_NUMBER:
num_val = av_int2dbl(get_be64(ioc)); break;
case AMF_DATA_TYPE_BOOL:
num_val = get_byte(ioc); break;
case AMF_DATA_TYPE_STRING:
if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
return -1;
break;
case AMF_DATA_TYPE_OBJECT: {
unsigned int keylen;
while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) {
url_fskip(ioc, keylen); //skip key string
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out.
}
if(get_byte(ioc) != AMF_END_OF_OBJECT)
return -1;
}
break;
case AMF_DATA_TYPE_NULL:
case AMF_DATA_TYPE_UNDEFINED:
case AMF_DATA_TYPE_UNSUPPORTED:
break; //these take up no additional space
case AMF_DATA_TYPE_MIXEDARRAY:
url_fskip(ioc, 4); //skip 32-bit max array index
while(url_ftell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) {
//this is the only case in which we would want a nested parse to not skip over the object
if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0)
return -1;
}
if(get_byte(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY: {
unsigned int arraylen, i;
arraylen = get_be32(ioc);
for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) {
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1; //if we couldn't skip, bomb out.
}
}
break;
case AMF_DATA_TYPE_DATE:
url_fskip(ioc, 8 + 2); //timestamp (double) and UTC offset (int16)
break;
default: //unsupported type, we couldn't skip
return -1;
}
if(depth == 1 && key) { //only look for metadata values when we are not nested and key != NULL
acodec = astream ? astream->codec : NULL;
vcodec = vstream ? vstream->codec : NULL;
if(amf_type == AMF_DATA_TYPE_BOOL) {
if(!strcmp(key, "stereo") && acodec) acodec->channels = num_val > 0 ? 2 : 1;
} else if(amf_type == AMF_DATA_TYPE_NUMBER) {
if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
// else if(!strcmp(key, "width") && vcodec && num_val > 0) vcodec->width = num_val;
// else if(!strcmp(key, "height") && vcodec && num_val > 0) vcodec->height = num_val;
else if(!strcmp(key, "audiocodecid") && acodec) flv_set_audio_codec(s, astream, (int)num_val << FLV_AUDIO_CODECID_OFFSET);
else if(!strcmp(key, "videocodecid") && vcodec) flv_set_video_codec(s, vstream, (int)num_val);
else if(!strcmp(key, "audiosamplesize") && acodec && num_val >= 0) {
acodec->bits_per_sample = num_val;
//we may have to rewrite a previously read codecid because FLV only marks PCM endianness.
if(num_val == 8 && (acodec->codec_id == CODEC_ID_PCM_S16BE || acodec->codec_id == CODEC_ID_PCM_S16LE))
acodec->codec_id = CODEC_ID_PCM_S8;
}
else if(!strcmp(key, "audiosamplerate") && acodec && num_val >= 0) {
//some tools, like FLVTool2, write consistently approximate metadata sample rates
if (!acodec->sample_rate) {
switch((int)num_val) {
case 44000: acodec->sample_rate = 44100 ; break;
case 22000: acodec->sample_rate = 22050 ; break;
case 11000: acodec->sample_rate = 11025 ; break;
case 5000 : acodec->sample_rate = 5512 ; break;
default : acodec->sample_rate = num_val;
}
}
}
}
}
return 0;
}
| false | FFmpeg | c04c52d3a8bb323d71436512495c8ecf58be69ee | static int amf_parse_object(AVFormatContext *s, AVStream *astream, AVStream *vstream, const char *key, unsigned int max_pos, int depth) {
AVCodecContext *acodec, *vcodec;
ByteIOContext *ioc;
AMFDataType amf_type;
char str_val[256];
double num_val;
num_val = 0;
ioc = s->pb;
amf_type = get_byte(ioc);
switch(amf_type) {
case AMF_DATA_TYPE_NUMBER:
num_val = av_int2dbl(get_be64(ioc)); break;
case AMF_DATA_TYPE_BOOL:
num_val = get_byte(ioc); break;
case AMF_DATA_TYPE_STRING:
if(amf_get_string(ioc, str_val, sizeof(str_val)) < 0)
return -1;
break;
case AMF_DATA_TYPE_OBJECT: {
unsigned int keylen;
while(url_ftell(ioc) < max_pos - 2 && (keylen = get_be16(ioc))) {
url_fskip(ioc, keylen);
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1;
}
if(get_byte(ioc) != AMF_END_OF_OBJECT)
return -1;
}
break;
case AMF_DATA_TYPE_NULL:
case AMF_DATA_TYPE_UNDEFINED:
case AMF_DATA_TYPE_UNSUPPORTED:
break;
case AMF_DATA_TYPE_MIXEDARRAY:
url_fskip(ioc, 4);
while(url_ftell(ioc) < max_pos - 2 && amf_get_string(ioc, str_val, sizeof(str_val)) > 0) {
if(amf_parse_object(s, astream, vstream, str_val, max_pos, depth + 1) < 0)
return -1;
}
if(get_byte(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY: {
unsigned int arraylen, i;
arraylen = get_be32(ioc);
for(i = 0; i < arraylen && url_ftell(ioc) < max_pos - 1; i++) {
if(amf_parse_object(s, NULL, NULL, NULL, max_pos, depth + 1) < 0)
return -1;
}
}
break;
case AMF_DATA_TYPE_DATE:
url_fskip(ioc, 8 + 2);
break;
default:
return -1;
}
if(depth == 1 && key) {
acodec = astream ? astream->codec : NULL;
vcodec = vstream ? vstream->codec : NULL;
if(amf_type == AMF_DATA_TYPE_BOOL) {
if(!strcmp(key, "stereo") && acodec) acodec->channels = num_val > 0 ? 2 : 1;
} else if(amf_type == AMF_DATA_TYPE_NUMBER) {
if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE;
else if(!strcmp(key, "audiocodecid") && acodec) flv_set_audio_codec(s, astream, (int)num_val << FLV_AUDIO_CODECID_OFFSET);
else if(!strcmp(key, "videocodecid") && vcodec) flv_set_video_codec(s, vstream, (int)num_val);
else if(!strcmp(key, "audiosamplesize") && acodec && num_val >= 0) {
acodec->bits_per_sample = num_val;
if(num_val == 8 && (acodec->codec_id == CODEC_ID_PCM_S16BE || acodec->codec_id == CODEC_ID_PCM_S16LE))
acodec->codec_id = CODEC_ID_PCM_S8;
}
else if(!strcmp(key, "audiosamplerate") && acodec && num_val >= 0) {
if (!acodec->sample_rate) {
switch((int)num_val) {
case 44000: acodec->sample_rate = 44100 ; break;
case 22000: acodec->sample_rate = 22050 ; break;
case 11000: acodec->sample_rate = 11025 ; break;
case 5000 : acodec->sample_rate = 5512 ; break;
default : acodec->sample_rate = num_val;
}
}
}
}
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVStream *VAR_2, const char *VAR_3, unsigned int VAR_4, int VAR_5) {
AVCodecContext *acodec, *vcodec;
ByteIOContext *ioc;
AMFDataType amf_type;
char VAR_6[256];
double VAR_7;
VAR_7 = 0;
ioc = VAR_0->pb;
amf_type = get_byte(ioc);
switch(amf_type) {
case AMF_DATA_TYPE_NUMBER:
VAR_7 = av_int2dbl(get_be64(ioc)); break;
case AMF_DATA_TYPE_BOOL:
VAR_7 = get_byte(ioc); break;
case AMF_DATA_TYPE_STRING:
if(amf_get_string(ioc, VAR_6, sizeof(VAR_6)) < 0)
return -1;
break;
case AMF_DATA_TYPE_OBJECT: {
unsigned int VAR_8;
while(url_ftell(ioc) < VAR_4 - 2 && (VAR_8 = get_be16(ioc))) {
url_fskip(ioc, VAR_8);
if(FUNC_0(VAR_0, NULL, NULL, NULL, VAR_4, VAR_5 + 1) < 0)
return -1;
}
if(get_byte(ioc) != AMF_END_OF_OBJECT)
return -1;
}
break;
case AMF_DATA_TYPE_NULL:
case AMF_DATA_TYPE_UNDEFINED:
case AMF_DATA_TYPE_UNSUPPORTED:
break;
case AMF_DATA_TYPE_MIXEDARRAY:
url_fskip(ioc, 4);
while(url_ftell(ioc) < VAR_4 - 2 && amf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0) {
if(FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4, VAR_5 + 1) < 0)
return -1;
}
if(get_byte(ioc) != AMF_END_OF_OBJECT)
return -1;
break;
case AMF_DATA_TYPE_ARRAY: {
unsigned int VAR_9, VAR_10;
VAR_9 = get_be32(ioc);
for(VAR_10 = 0; VAR_10 < VAR_9 && url_ftell(ioc) < VAR_4 - 1; VAR_10++) {
if(FUNC_0(VAR_0, NULL, NULL, NULL, VAR_4, VAR_5 + 1) < 0)
return -1;
}
}
break;
case AMF_DATA_TYPE_DATE:
url_fskip(ioc, 8 + 2);
break;
default:
return -1;
}
if(VAR_5 == 1 && VAR_3) {
acodec = VAR_1 ? VAR_1->codec : NULL;
vcodec = VAR_2 ? VAR_2->codec : NULL;
if(amf_type == AMF_DATA_TYPE_BOOL) {
if(!strcmp(VAR_3, "stereo") && acodec) acodec->channels = VAR_7 > 0 ? 2 : 1;
} else if(amf_type == AMF_DATA_TYPE_NUMBER) {
if(!strcmp(VAR_3, "duration")) VAR_0->duration = VAR_7 * AV_TIME_BASE;
else if(!strcmp(VAR_3, "audiocodecid") && acodec) flv_set_audio_codec(VAR_0, VAR_1, (int)VAR_7 << FLV_AUDIO_CODECID_OFFSET);
else if(!strcmp(VAR_3, "videocodecid") && vcodec) flv_set_video_codec(VAR_0, VAR_2, (int)VAR_7);
else if(!strcmp(VAR_3, "audiosamplesize") && acodec && VAR_7 >= 0) {
acodec->bits_per_sample = VAR_7;
if(VAR_7 == 8 && (acodec->codec_id == CODEC_ID_PCM_S16BE || acodec->codec_id == CODEC_ID_PCM_S16LE))
acodec->codec_id = CODEC_ID_PCM_S8;
}
else if(!strcmp(VAR_3, "audiosamplerate") && acodec && VAR_7 >= 0) {
if (!acodec->sample_rate) {
switch((int)VAR_7) {
case 44000: acodec->sample_rate = 44100 ; break;
case 22000: acodec->sample_rate = 22050 ; break;
case 11000: acodec->sample_rate = 11025 ; break;
case 5000 : acodec->sample_rate = 5512 ; break;
default : acodec->sample_rate = VAR_7;
}
}
}
}
}
return 0;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, AVStream *VAR_2, const char *VAR_3, unsigned int VAR_4, int VAR_5) {",
"AVCodecContext *acodec, *vcodec;",
"ByteIOContext *ioc;",
"AMFDataType amf_type;",
"char VAR_6[256];",
"double VAR_7;",
"VAR_7 = 0;",
"ioc = VAR_0->pb;",
"amf_type = get_byte(ioc);",
"switch(amf_type) {",
"case AMF_DATA_TYPE_NUMBER:\nVAR_7 = av_int2dbl(get_be64(ioc)); break;",
"case AMF_DATA_TYPE_BOOL:\nVAR_7 = get_byte(ioc); break;",
"case AMF_DATA_TYPE_STRING:\nif(amf_get_string(ioc, VAR_6, sizeof(VAR_6)) < 0)\nreturn -1;",
"break;",
"case AMF_DATA_TYPE_OBJECT: {",
"unsigned int VAR_8;",
"while(url_ftell(ioc) < VAR_4 - 2 && (VAR_8 = get_be16(ioc))) {",
"url_fskip(ioc, VAR_8);",
"if(FUNC_0(VAR_0, NULL, NULL, NULL, VAR_4, VAR_5 + 1) < 0)\nreturn -1;",
"}",
"if(get_byte(ioc) != AMF_END_OF_OBJECT)\nreturn -1;",
"}",
"break;",
"case AMF_DATA_TYPE_NULL:\ncase AMF_DATA_TYPE_UNDEFINED:\ncase AMF_DATA_TYPE_UNSUPPORTED:\nbreak;",
"case AMF_DATA_TYPE_MIXEDARRAY:\nurl_fskip(ioc, 4);",
"while(url_ftell(ioc) < VAR_4 - 2 && amf_get_string(ioc, VAR_6, sizeof(VAR_6)) > 0) {",
"if(FUNC_0(VAR_0, VAR_1, VAR_2, VAR_6, VAR_4, VAR_5 + 1) < 0)\nreturn -1;",
"}",
"if(get_byte(ioc) != AMF_END_OF_OBJECT)\nreturn -1;",
"break;",
"case AMF_DATA_TYPE_ARRAY: {",
"unsigned int VAR_9, VAR_10;",
"VAR_9 = get_be32(ioc);",
"for(VAR_10 = 0; VAR_10 < VAR_9 && url_ftell(ioc) < VAR_4 - 1; VAR_10++) {",
"if(FUNC_0(VAR_0, NULL, NULL, NULL, VAR_4, VAR_5 + 1) < 0)\nreturn -1;",
"}",
"}",
"break;",
"case AMF_DATA_TYPE_DATE:\nurl_fskip(ioc, 8 + 2);",
"break;",
"default:\nreturn -1;",
"}",
"if(VAR_5 == 1 && VAR_3) {",
"acodec = VAR_1 ? VAR_1->codec : NULL;",
"vcodec = VAR_2 ? VAR_2->codec : NULL;",
"if(amf_type == AMF_DATA_TYPE_BOOL) {",
"if(!strcmp(VAR_3, \"stereo\") && acodec) acodec->channels = VAR_7 > 0 ? 2 : 1;",
"} else if(amf_type == AMF_DATA_TYPE_NUMBER) {",
"if(!strcmp(VAR_3, \"duration\")) VAR_0->duration = VAR_7 * AV_TIME_BASE;",
"else if(!strcmp(VAR_3, \"audiocodecid\") && acodec) flv_set_audio_codec(VAR_0, VAR_1, (int)VAR_7 << FLV_AUDIO_CODECID_OFFSET);",
"else if(!strcmp(VAR_3, \"videocodecid\") && vcodec) flv_set_video_codec(VAR_0, VAR_2, (int)VAR_7);",
"else if(!strcmp(VAR_3, \"audiosamplesize\") && acodec && VAR_7 >= 0) {",
"acodec->bits_per_sample = VAR_7;",
"if(VAR_7 == 8 && (acodec->codec_id == CODEC_ID_PCM_S16BE || acodec->codec_id == CODEC_ID_PCM_S16LE))\nacodec->codec_id = CODEC_ID_PCM_S8;",
"}",
"else if(!strcmp(VAR_3, \"audiosamplerate\") && acodec && VAR_7 >= 0) {",
"if (!acodec->sample_rate) {",
"switch((int)VAR_7) {",
"case 44000: acodec->sample_rate = 44100 ; break;",
"case 22000: acodec->sample_rate = 22050 ; break;",
"case 11000: acodec->sample_rate = 11025 ; break;",
"case 5000 : acodec->sample_rate = 5512 ; break;",
"default : acodec->sample_rate = VAR_7;",
"}",
"}",
"}",
"}",
"}",
"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
] | [
[
1
],
[
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27,
29
],
[
31,
33
],
[
35,
37,
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59,
61
],
[
63
],
[
65
],
[
67,
69,
71,
73
],
[
75,
77
],
[
79
],
[
83,
85
],
[
87
],
[
89,
91
],
[
93
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
149
],
[
151
],
[
153
],
[
155
],
[
159,
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
]
] |
25,019 | static void kvm_init_irq_routing(KVMState *s)
{
int gsi_count;
gsi_count = kvm_check_extension(s, KVM_CAP_IRQ_ROUTING);
if (gsi_count > 0) {
unsigned int gsi_bits, i;
/* Round up so we can search ints using ffs */
gsi_bits = ALIGN(gsi_count, 32);
s->used_gsi_bitmap = g_malloc0(gsi_bits / 8);
s->max_gsi = gsi_bits;
/* Mark any over-allocated bits as already in use */
for (i = gsi_count; i < gsi_bits; i++) {
set_gsi(s, i);
}
}
s->irq_routes = g_malloc0(sizeof(*s->irq_routes));
s->nr_allocated_irq_routes = 0;
kvm_arch_init_irq_routing(s);
}
| false | qemu | 4e2e4e6355959a1af011167b0db5ac7ffd3adf94 | static void kvm_init_irq_routing(KVMState *s)
{
int gsi_count;
gsi_count = kvm_check_extension(s, KVM_CAP_IRQ_ROUTING);
if (gsi_count > 0) {
unsigned int gsi_bits, i;
gsi_bits = ALIGN(gsi_count, 32);
s->used_gsi_bitmap = g_malloc0(gsi_bits / 8);
s->max_gsi = gsi_bits;
for (i = gsi_count; i < gsi_bits; i++) {
set_gsi(s, i);
}
}
s->irq_routes = g_malloc0(sizeof(*s->irq_routes));
s->nr_allocated_irq_routes = 0;
kvm_arch_init_irq_routing(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(KVMState *VAR_0)
{
int VAR_1;
VAR_1 = kvm_check_extension(VAR_0, KVM_CAP_IRQ_ROUTING);
if (VAR_1 > 0) {
unsigned int VAR_2, VAR_3;
VAR_2 = ALIGN(VAR_1, 32);
VAR_0->used_gsi_bitmap = g_malloc0(VAR_2 / 8);
VAR_0->max_gsi = VAR_2;
for (VAR_3 = VAR_1; VAR_3 < VAR_2; VAR_3++) {
set_gsi(VAR_0, VAR_3);
}
}
VAR_0->irq_routes = g_malloc0(sizeof(*VAR_0->irq_routes));
VAR_0->nr_allocated_irq_routes = 0;
kvm_arch_init_irq_routing(VAR_0);
}
| [
"static void FUNC_0(KVMState *VAR_0)\n{",
"int VAR_1;",
"VAR_1 = kvm_check_extension(VAR_0, KVM_CAP_IRQ_ROUTING);",
"if (VAR_1 > 0) {",
"unsigned int VAR_2, VAR_3;",
"VAR_2 = ALIGN(VAR_1, 32);",
"VAR_0->used_gsi_bitmap = g_malloc0(VAR_2 / 8);",
"VAR_0->max_gsi = VAR_2;",
"for (VAR_3 = VAR_1; VAR_3 < VAR_2; VAR_3++) {",
"set_gsi(VAR_0, VAR_3);",
"}",
"}",
"VAR_0->irq_routes = g_malloc0(sizeof(*VAR_0->irq_routes));",
"VAR_0->nr_allocated_irq_routes = 0;",
"kvm_arch_init_irq_routing(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39
],
[
41
],
[
45
],
[
47
]
] |
25,020 | static void uart_read_rx_fifo(UartState *s, uint32_t *c)
{
if ((s->r[R_CR] & UART_CR_RX_DIS) || !(s->r[R_CR] & UART_CR_RX_EN)) {
return;
}
if (s->rx_count) {
uint32_t rx_rpos =
(RX_FIFO_SIZE + s->rx_wpos - s->rx_count) % RX_FIFO_SIZE;
*c = s->rx_fifo[rx_rpos];
s->rx_count--;
qemu_chr_accept_input(s->chr);
} else {
*c = 0;
}
uart_update_status(s);
}
| false | qemu | af52fe862fba686713044efdf9158195f84535ab | static void uart_read_rx_fifo(UartState *s, uint32_t *c)
{
if ((s->r[R_CR] & UART_CR_RX_DIS) || !(s->r[R_CR] & UART_CR_RX_EN)) {
return;
}
if (s->rx_count) {
uint32_t rx_rpos =
(RX_FIFO_SIZE + s->rx_wpos - s->rx_count) % RX_FIFO_SIZE;
*c = s->rx_fifo[rx_rpos];
s->rx_count--;
qemu_chr_accept_input(s->chr);
} else {
*c = 0;
}
uart_update_status(s);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(UartState *VAR_0, uint32_t *VAR_1)
{
if ((VAR_0->r[R_CR] & UART_CR_RX_DIS) || !(VAR_0->r[R_CR] & UART_CR_RX_EN)) {
return;
}
if (VAR_0->rx_count) {
uint32_t rx_rpos =
(RX_FIFO_SIZE + VAR_0->rx_wpos - VAR_0->rx_count) % RX_FIFO_SIZE;
*VAR_1 = VAR_0->rx_fifo[rx_rpos];
VAR_0->rx_count--;
qemu_chr_accept_input(VAR_0->chr);
} else {
*VAR_1 = 0;
}
uart_update_status(VAR_0);
}
| [
"static void FUNC_0(UartState *VAR_0, uint32_t *VAR_1)\n{",
"if ((VAR_0->r[R_CR] & UART_CR_RX_DIS) || !(VAR_0->r[R_CR] & UART_CR_RX_EN)) {",
"return;",
"}",
"if (VAR_0->rx_count) {",
"uint32_t rx_rpos =\n(RX_FIFO_SIZE + VAR_0->rx_wpos - VAR_0->rx_count) % RX_FIFO_SIZE;",
"*VAR_1 = VAR_0->rx_fifo[rx_rpos];",
"VAR_0->rx_count--;",
"qemu_chr_accept_input(VAR_0->chr);",
"} else {",
"*VAR_1 = 0;",
"}",
"uart_update_status(VAR_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
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
25,021 | static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUAlphaState *env)
{
abi_ulong frame_addr, r26;
struct target_sigframe *frame;
int err = 0;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
err |= setup_sigcontext(&frame->sc, env, frame_addr, set);
if (ka->sa_restorer) {
r26 = ka->sa_restorer;
} else {
__put_user(INSN_MOV_R30_R16, &frame->retcode[0]);
__put_user(INSN_LDI_R0 + TARGET_NR_sigreturn,
&frame->retcode[1]);
__put_user(INSN_CALLSYS, &frame->retcode[2]);
/* imb() */
r26 = frame_addr;
}
unlock_user_struct(frame, frame_addr, 1);
if (err) {
give_sigsegv:
if (sig == TARGET_SIGSEGV) {
ka->_sa_handler = TARGET_SIG_DFL;
}
force_sig(TARGET_SIGSEGV);
}
env->ir[IR_RA] = r26;
env->ir[IR_PV] = env->pc = ka->_sa_handler;
env->ir[IR_A0] = sig;
env->ir[IR_A1] = 0;
env->ir[IR_A2] = frame_addr + offsetof(struct target_sigframe, sc);
env->ir[IR_SP] = frame_addr;
}
| false | qemu | 41ecc72ba5932381208e151bf2d2149a0342beff | static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUAlphaState *env)
{
abi_ulong frame_addr, r26;
struct target_sigframe *frame;
int err = 0;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0)) {
goto give_sigsegv;
}
err |= setup_sigcontext(&frame->sc, env, frame_addr, set);
if (ka->sa_restorer) {
r26 = ka->sa_restorer;
} else {
__put_user(INSN_MOV_R30_R16, &frame->retcode[0]);
__put_user(INSN_LDI_R0 + TARGET_NR_sigreturn,
&frame->retcode[1]);
__put_user(INSN_CALLSYS, &frame->retcode[2]);
r26 = frame_addr;
}
unlock_user_struct(frame, frame_addr, 1);
if (err) {
give_sigsegv:
if (sig == TARGET_SIGSEGV) {
ka->_sa_handler = TARGET_SIG_DFL;
}
force_sig(TARGET_SIGSEGV);
}
env->ir[IR_RA] = r26;
env->ir[IR_PV] = env->pc = ka->_sa_handler;
env->ir[IR_A0] = sig;
env->ir[IR_A1] = 0;
env->ir[IR_A2] = frame_addr + offsetof(struct target_sigframe, sc);
env->ir[IR_SP] = frame_addr;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,
target_sigset_t *VAR_2, CPUAlphaState *VAR_3)
{
abi_ulong frame_addr, r26;
struct target_sigframe *VAR_4;
int VAR_5 = 0;
frame_addr = get_sigframe(VAR_1, VAR_3, sizeof(*VAR_4));
if (!lock_user_struct(VERIFY_WRITE, VAR_4, frame_addr, 0)) {
goto give_sigsegv;
}
VAR_5 |= setup_sigcontext(&VAR_4->sc, VAR_3, frame_addr, VAR_2);
if (VAR_1->sa_restorer) {
r26 = VAR_1->sa_restorer;
} else {
__put_user(INSN_MOV_R30_R16, &VAR_4->retcode[0]);
__put_user(INSN_LDI_R0 + TARGET_NR_sigreturn,
&VAR_4->retcode[1]);
__put_user(INSN_CALLSYS, &VAR_4->retcode[2]);
r26 = frame_addr;
}
unlock_user_struct(VAR_4, frame_addr, 1);
if (VAR_5) {
give_sigsegv:
if (VAR_0 == TARGET_SIGSEGV) {
VAR_1->_sa_handler = TARGET_SIG_DFL;
}
force_sig(TARGET_SIGSEGV);
}
VAR_3->ir[IR_RA] = r26;
VAR_3->ir[IR_PV] = VAR_3->pc = VAR_1->_sa_handler;
VAR_3->ir[IR_A0] = VAR_0;
VAR_3->ir[IR_A1] = 0;
VAR_3->ir[IR_A2] = frame_addr + offsetof(struct target_sigframe, sc);
VAR_3->ir[IR_SP] = frame_addr;
}
| [
"static void FUNC_0(int VAR_0, struct target_sigaction *VAR_1,\ntarget_sigset_t *VAR_2, CPUAlphaState *VAR_3)\n{",
"abi_ulong frame_addr, r26;",
"struct target_sigframe *VAR_4;",
"int VAR_5 = 0;",
"frame_addr = get_sigframe(VAR_1, VAR_3, sizeof(*VAR_4));",
"if (!lock_user_struct(VERIFY_WRITE, VAR_4, frame_addr, 0)) {",
"goto give_sigsegv;",
"}",
"VAR_5 |= setup_sigcontext(&VAR_4->sc, VAR_3, frame_addr, VAR_2);",
"if (VAR_1->sa_restorer) {",
"r26 = VAR_1->sa_restorer;",
"} else {",
"__put_user(INSN_MOV_R30_R16, &VAR_4->retcode[0]);",
"__put_user(INSN_LDI_R0 + TARGET_NR_sigreturn,\n&VAR_4->retcode[1]);",
"__put_user(INSN_CALLSYS, &VAR_4->retcode[2]);",
"r26 = frame_addr;",
"}",
"unlock_user_struct(VAR_4, frame_addr, 1);",
"if (VAR_5) {",
"give_sigsegv:\nif (VAR_0 == TARGET_SIGSEGV) {",
"VAR_1->_sa_handler = TARGET_SIG_DFL;",
"}",
"force_sig(TARGET_SIGSEGV);",
"}",
"VAR_3->ir[IR_RA] = r26;",
"VAR_3->ir[IR_PV] = VAR_3->pc = VAR_1->_sa_handler;",
"VAR_3->ir[IR_A0] = VAR_0;",
"VAR_3->ir[IR_A1] = 0;",
"VAR_3->ir[IR_A2] = frame_addr + offsetof(struct target_sigframe, sc);",
"VAR_3->ir[IR_SP] = frame_addr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
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
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37,
39
],
[
41
],
[
45
],
[
47
],
[
51
],
[
55
],
[
57,
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
]
] |
25,022 | static void spin_kick(void *data)
{
SpinKick *kick = data;
CPUState *cpu = CPU(kick->cpu);
CPUPPCState *env = &kick->cpu->env;
SpinInfo *curspin = kick->spin;
hwaddr map_size = 64 * 1024 * 1024;
hwaddr map_start;
cpu_synchronize_state(cpu);
stl_p(&curspin->pir, env->spr[SPR_PIR]);
env->nip = ldq_p(&curspin->addr) & (map_size - 1);
env->gpr[3] = ldq_p(&curspin->r3);
env->gpr[4] = 0;
env->gpr[5] = 0;
env->gpr[6] = 0;
env->gpr[7] = map_size;
env->gpr[8] = 0;
env->gpr[9] = 0;
map_start = ldq_p(&curspin->addr) & ~(map_size - 1);
mmubooke_create_initial_mapping(env, 0, map_start, map_size);
cpu->halted = 0;
cpu->exception_index = -1;
cpu->stopped = false;
qemu_cpu_kick(cpu);
}
| false | qemu | 6d18a7a1ff9665ad48a68a692fdf0a61edefcae8 | static void spin_kick(void *data)
{
SpinKick *kick = data;
CPUState *cpu = CPU(kick->cpu);
CPUPPCState *env = &kick->cpu->env;
SpinInfo *curspin = kick->spin;
hwaddr map_size = 64 * 1024 * 1024;
hwaddr map_start;
cpu_synchronize_state(cpu);
stl_p(&curspin->pir, env->spr[SPR_PIR]);
env->nip = ldq_p(&curspin->addr) & (map_size - 1);
env->gpr[3] = ldq_p(&curspin->r3);
env->gpr[4] = 0;
env->gpr[5] = 0;
env->gpr[6] = 0;
env->gpr[7] = map_size;
env->gpr[8] = 0;
env->gpr[9] = 0;
map_start = ldq_p(&curspin->addr) & ~(map_size - 1);
mmubooke_create_initial_mapping(env, 0, map_start, map_size);
cpu->halted = 0;
cpu->exception_index = -1;
cpu->stopped = false;
qemu_cpu_kick(cpu);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0)
{
SpinKick *kick = VAR_0;
CPUState *cpu = CPU(kick->cpu);
CPUPPCState *env = &kick->cpu->env;
SpinInfo *curspin = kick->spin;
hwaddr map_size = 64 * 1024 * 1024;
hwaddr map_start;
cpu_synchronize_state(cpu);
stl_p(&curspin->pir, env->spr[SPR_PIR]);
env->nip = ldq_p(&curspin->addr) & (map_size - 1);
env->gpr[3] = ldq_p(&curspin->r3);
env->gpr[4] = 0;
env->gpr[5] = 0;
env->gpr[6] = 0;
env->gpr[7] = map_size;
env->gpr[8] = 0;
env->gpr[9] = 0;
map_start = ldq_p(&curspin->addr) & ~(map_size - 1);
mmubooke_create_initial_mapping(env, 0, map_start, map_size);
cpu->halted = 0;
cpu->exception_index = -1;
cpu->stopped = false;
qemu_cpu_kick(cpu);
}
| [
"static void FUNC_0(void *VAR_0)\n{",
"SpinKick *kick = VAR_0;",
"CPUState *cpu = CPU(kick->cpu);",
"CPUPPCState *env = &kick->cpu->env;",
"SpinInfo *curspin = kick->spin;",
"hwaddr map_size = 64 * 1024 * 1024;",
"hwaddr map_start;",
"cpu_synchronize_state(cpu);",
"stl_p(&curspin->pir, env->spr[SPR_PIR]);",
"env->nip = ldq_p(&curspin->addr) & (map_size - 1);",
"env->gpr[3] = ldq_p(&curspin->r3);",
"env->gpr[4] = 0;",
"env->gpr[5] = 0;",
"env->gpr[6] = 0;",
"env->gpr[7] = map_size;",
"env->gpr[8] = 0;",
"env->gpr[9] = 0;",
"map_start = ldq_p(&curspin->addr) & ~(map_size - 1);",
"mmubooke_create_initial_mapping(env, 0, map_start, map_size);",
"cpu->halted = 0;",
"cpu->exception_index = -1;",
"cpu->stopped = false;",
"qemu_cpu_kick(cpu);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
25,023 | static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len)
{
uint64_t end = addr + len;
if ((addr & 511) || len < 512)
if (!sd->bdrv || bdrv_read(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: read error on host side\n");
return;
}
if (end > (addr & ~511) + 512) {
memcpy(sd->buf + (addr & 511), sd->data, 512 - (addr & 511));
if (bdrv_write(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: write error on host side\n");
return;
}
if (bdrv_read(sd->bdrv, end >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: read error on host side\n");
return;
}
memcpy(sd->buf, sd->data + 512 - (addr & 511), end & 511);
if (bdrv_write(sd->bdrv, end >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: write error on host side\n");
}
} else {
memcpy(sd->buf + (addr & 511), sd->data, len);
if (!sd->bdrv || bdrv_write(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: write error on host side\n");
}
}
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void sd_blk_write(SDState *sd, uint64_t addr, uint32_t len)
{
uint64_t end = addr + len;
if ((addr & 511) || len < 512)
if (!sd->bdrv || bdrv_read(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: read error on host side\n");
return;
}
if (end > (addr & ~511) + 512) {
memcpy(sd->buf + (addr & 511), sd->data, 512 - (addr & 511));
if (bdrv_write(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: write error on host side\n");
return;
}
if (bdrv_read(sd->bdrv, end >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: read error on host side\n");
return;
}
memcpy(sd->buf, sd->data + 512 - (addr & 511), end & 511);
if (bdrv_write(sd->bdrv, end >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: write error on host side\n");
}
} else {
memcpy(sd->buf + (addr & 511), sd->data, len);
if (!sd->bdrv || bdrv_write(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {
fprintf(stderr, "sd_blk_write: write error on host side\n");
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(SDState *VAR_0, uint64_t VAR_1, uint32_t VAR_2)
{
uint64_t end = VAR_1 + VAR_2;
if ((VAR_1 & 511) || VAR_2 < 512)
if (!VAR_0->bdrv || bdrv_read(VAR_0->bdrv, VAR_1 >> 9, VAR_0->buf, 1) < 0) {
fprintf(stderr, "FUNC_0: read error on host side\n");
return;
}
if (end > (VAR_1 & ~511) + 512) {
memcpy(VAR_0->buf + (VAR_1 & 511), VAR_0->data, 512 - (VAR_1 & 511));
if (bdrv_write(VAR_0->bdrv, VAR_1 >> 9, VAR_0->buf, 1) < 0) {
fprintf(stderr, "FUNC_0: write error on host side\n");
return;
}
if (bdrv_read(VAR_0->bdrv, end >> 9, VAR_0->buf, 1) < 0) {
fprintf(stderr, "FUNC_0: read error on host side\n");
return;
}
memcpy(VAR_0->buf, VAR_0->data + 512 - (VAR_1 & 511), end & 511);
if (bdrv_write(VAR_0->bdrv, end >> 9, VAR_0->buf, 1) < 0) {
fprintf(stderr, "FUNC_0: write error on host side\n");
}
} else {
memcpy(VAR_0->buf + (VAR_1 & 511), VAR_0->data, VAR_2);
if (!VAR_0->bdrv || bdrv_write(VAR_0->bdrv, VAR_1 >> 9, VAR_0->buf, 1) < 0) {
fprintf(stderr, "FUNC_0: write error on host side\n");
}
}
}
| [
"static void FUNC_0(SDState *VAR_0, uint64_t VAR_1, uint32_t VAR_2)\n{",
"uint64_t end = VAR_1 + VAR_2;",
"if ((VAR_1 & 511) || VAR_2 < 512)\nif (!VAR_0->bdrv || bdrv_read(VAR_0->bdrv, VAR_1 >> 9, VAR_0->buf, 1) < 0) {",
"fprintf(stderr, \"FUNC_0: read error on host side\\n\");",
"return;",
"}",
"if (end > (VAR_1 & ~511) + 512) {",
"memcpy(VAR_0->buf + (VAR_1 & 511), VAR_0->data, 512 - (VAR_1 & 511));",
"if (bdrv_write(VAR_0->bdrv, VAR_1 >> 9, VAR_0->buf, 1) < 0) {",
"fprintf(stderr, \"FUNC_0: write error on host side\\n\");",
"return;",
"}",
"if (bdrv_read(VAR_0->bdrv, end >> 9, VAR_0->buf, 1) < 0) {",
"fprintf(stderr, \"FUNC_0: read error on host side\\n\");",
"return;",
"}",
"memcpy(VAR_0->buf, VAR_0->data + 512 - (VAR_1 & 511), end & 511);",
"if (bdrv_write(VAR_0->bdrv, end >> 9, VAR_0->buf, 1) < 0) {",
"fprintf(stderr, \"FUNC_0: write error on host side\\n\");",
"}",
"} else {",
"memcpy(VAR_0->buf + (VAR_1 & 511), VAR_0->data, VAR_2);",
"if (!VAR_0->bdrv || bdrv_write(VAR_0->bdrv, VAR_1 >> 9, VAR_0->buf, 1) < 0) {",
"fprintf(stderr, \"FUNC_0: write error on host side\\n\");",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
25,025 | static struct omap_uwire_s *omap_uwire_init(MemoryRegion *system_memory,
target_phys_addr_t base,
qemu_irq txirq, qemu_irq rxirq,
qemu_irq dma,
omap_clk clk)
{
struct omap_uwire_s *s = (struct omap_uwire_s *)
g_malloc0(sizeof(struct omap_uwire_s));
s->txirq = txirq;
s->rxirq = rxirq;
s->txdrq = dma;
omap_uwire_reset(s);
memory_region_init_io(&s->iomem, &omap_uwire_ops, s, "omap-uwire", 0x800);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static struct omap_uwire_s *omap_uwire_init(MemoryRegion *system_memory,
target_phys_addr_t base,
qemu_irq txirq, qemu_irq rxirq,
qemu_irq dma,
omap_clk clk)
{
struct omap_uwire_s *s = (struct omap_uwire_s *)
g_malloc0(sizeof(struct omap_uwire_s));
s->txirq = txirq;
s->rxirq = rxirq;
s->txdrq = dma;
omap_uwire_reset(s);
memory_region_init_io(&s->iomem, &omap_uwire_ops, s, "omap-uwire", 0x800);
memory_region_add_subregion(system_memory, base, &s->iomem);
return s;
}
| {
"code": [],
"line_no": []
} | static struct omap_uwire_s *FUNC_0(MemoryRegion *VAR_0,
target_phys_addr_t VAR_1,
qemu_irq VAR_2, qemu_irq VAR_3,
qemu_irq VAR_4,
omap_clk VAR_5)
{
struct omap_uwire_s *VAR_6 = (struct omap_uwire_s *)
g_malloc0(sizeof(struct omap_uwire_s));
VAR_6->VAR_2 = VAR_2;
VAR_6->VAR_3 = VAR_3;
VAR_6->txdrq = VAR_4;
omap_uwire_reset(VAR_6);
memory_region_init_io(&VAR_6->iomem, &omap_uwire_ops, VAR_6, "omap-uwire", 0x800);
memory_region_add_subregion(VAR_0, VAR_1, &VAR_6->iomem);
return VAR_6;
}
| [
"static struct omap_uwire_s *FUNC_0(MemoryRegion *VAR_0,\ntarget_phys_addr_t VAR_1,\nqemu_irq VAR_2, qemu_irq VAR_3,\nqemu_irq VAR_4,\nomap_clk VAR_5)\n{",
"struct omap_uwire_s *VAR_6 = (struct omap_uwire_s *)\ng_malloc0(sizeof(struct omap_uwire_s));",
"VAR_6->VAR_2 = VAR_2;",
"VAR_6->VAR_3 = VAR_3;",
"VAR_6->txdrq = VAR_4;",
"omap_uwire_reset(VAR_6);",
"memory_region_init_io(&VAR_6->iomem, &omap_uwire_ops, VAR_6, \"omap-uwire\", 0x800);",
"memory_region_add_subregion(VAR_0, VAR_1, &VAR_6->iomem);",
"return VAR_6;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13,
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
]
] |
25,026 | static void exception_action(CPUState *cpu)
{
#if defined(TARGET_I386)
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env1 = &x86_cpu->env;
raise_exception_err(env1, cpu->exception_index, env1->error_code);
#else
cpu_loop_exit(cpu);
#endif
}
| false | qemu | 0c33682d5f29b0a4ae53bdec4c8e52e4fae37b34 | static void exception_action(CPUState *cpu)
{
#if defined(TARGET_I386)
X86CPU *x86_cpu = X86_CPU(cpu);
CPUX86State *env1 = &x86_cpu->env;
raise_exception_err(env1, cpu->exception_index, env1->error_code);
#else
cpu_loop_exit(cpu);
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUState *VAR_0)
{
#if defined(TARGET_I386)
X86CPU *x86_cpu = X86_CPU(VAR_0);
CPUX86State *env1 = &x86_cpu->env;
raise_exception_err(env1, VAR_0->exception_index, env1->error_code);
#else
cpu_loop_exit(VAR_0);
#endif
}
| [
"static void FUNC_0(CPUState *VAR_0)\n{",
"#if defined(TARGET_I386)\nX86CPU *x86_cpu = X86_CPU(VAR_0);",
"CPUX86State *env1 = &x86_cpu->env;",
"raise_exception_err(env1, VAR_0->exception_index, env1->error_code);",
"#else\ncpu_loop_exit(VAR_0);",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9
],
[
13
],
[
15,
17
],
[
19,
21
]
] |
25,027 | void term_printf(const char *fmt, ...)
{
char buf[4096];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
qemu_chr_write(monitor_hd, buf, strlen(buf));
va_end(ap);
}
| false | qemu | 7e2515e87c41e2e658aaed466e11cbdf1ea8bcb1 | void term_printf(const char *fmt, ...)
{
char buf[4096];
va_list ap;
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
qemu_chr_write(monitor_hd, buf, strlen(buf));
va_end(ap);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(const char *VAR_0, ...)
{
char VAR_1[4096];
va_list ap;
va_start(ap, VAR_0);
vsnprintf(VAR_1, sizeof(VAR_1), VAR_0, ap);
qemu_chr_write(monitor_hd, VAR_1, strlen(VAR_1));
va_end(ap);
}
| [
"void FUNC_0(const char *VAR_0, ...)\n{",
"char VAR_1[4096];",
"va_list ap;",
"va_start(ap, VAR_0);",
"vsnprintf(VAR_1, sizeof(VAR_1), VAR_0, ap);",
"qemu_chr_write(monitor_hd, VAR_1, strlen(VAR_1));",
"va_end(ap);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
]
] |
25,028 | static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
{
switch (buf[0] >> 5) {
case 0:
cmd->xfer = buf[4];
cmd->len = 6;
break;
case 1:
case 2:
cmd->xfer = lduw_be_p(&buf[7]);
cmd->len = 10;
break;
case 4:
cmd->xfer = ldl_be_p(&buf[10]) & 0xffffffffULL;
cmd->len = 16;
break;
case 5:
cmd->xfer = ldl_be_p(&buf[6]) & 0xffffffffULL;
cmd->len = 12;
break;
default:
return -1;
}
switch (buf[0]) {
case TEST_UNIT_READY:
case REWIND:
case START_STOP:
case SET_CAPACITY:
case WRITE_FILEMARKS:
case WRITE_FILEMARKS_16:
case SPACE:
case RESERVE:
case RELEASE:
case ERASE:
case ALLOW_MEDIUM_REMOVAL:
case VERIFY_10:
case SEEK_10:
case SYNCHRONIZE_CACHE:
case SYNCHRONIZE_CACHE_16:
case LOCATE_16:
case LOCK_UNLOCK_CACHE:
case SET_CD_SPEED:
case SET_LIMITS:
case WRITE_LONG_10:
case MOVE_MEDIUM:
case UPDATE_BLOCK:
case RESERVE_TRACK:
case SET_READ_AHEAD:
case PRE_FETCH:
case PRE_FETCH_16:
case ALLOW_OVERWRITE:
cmd->xfer = 0;
break;
case MODE_SENSE:
break;
case WRITE_SAME_10:
case WRITE_SAME_16:
cmd->xfer = dev->blocksize;
break;
case READ_CAPACITY_10:
cmd->xfer = 8;
break;
case READ_BLOCK_LIMITS:
cmd->xfer = 6;
break;
case SEND_VOLUME_TAG:
/* GPCMD_SET_STREAMING from multimedia commands. */
if (dev->type == TYPE_ROM) {
cmd->xfer = buf[10] | (buf[9] << 8);
} else {
cmd->xfer = buf[9] | (buf[8] << 8);
}
break;
case WRITE_6:
/* length 0 means 256 blocks */
if (cmd->xfer == 0) {
cmd->xfer = 256;
}
case WRITE_10:
case WRITE_VERIFY_10:
case WRITE_12:
case WRITE_VERIFY_12:
case WRITE_16:
case WRITE_VERIFY_16:
cmd->xfer *= dev->blocksize;
break;
case READ_6:
case READ_REVERSE:
/* length 0 means 256 blocks */
if (cmd->xfer == 0) {
cmd->xfer = 256;
}
case READ_10:
case RECOVER_BUFFERED_DATA:
case READ_12:
case READ_16:
cmd->xfer *= dev->blocksize;
break;
case FORMAT_UNIT:
/* MMC mandates the parameter list to be 12-bytes long. Parameters
* for block devices are restricted to the header right now. */
if (dev->type == TYPE_ROM && (buf[1] & 16)) {
cmd->xfer = 12;
} else {
cmd->xfer = (buf[1] & 16) == 0 ? 0 : (buf[1] & 32 ? 8 : 4);
}
break;
case INQUIRY:
case RECEIVE_DIAGNOSTIC:
case SEND_DIAGNOSTIC:
cmd->xfer = buf[4] | (buf[3] << 8);
break;
case READ_CD:
case READ_BUFFER:
case WRITE_BUFFER:
case SEND_CUE_SHEET:
cmd->xfer = buf[8] | (buf[7] << 8) | (buf[6] << 16);
break;
case PERSISTENT_RESERVE_OUT:
cmd->xfer = ldl_be_p(&buf[5]) & 0xffffffffULL;
break;
case ERASE_12:
if (dev->type == TYPE_ROM) {
/* MMC command GET PERFORMANCE. */
cmd->xfer = scsi_get_performance_length(buf[9] | (buf[8] << 8),
buf[10], buf[1] & 0x1f);
}
break;
case MECHANISM_STATUS:
case READ_DVD_STRUCTURE:
case SEND_DVD_STRUCTURE:
case MAINTENANCE_OUT:
case MAINTENANCE_IN:
if (dev->type == TYPE_ROM) {
/* GPCMD_REPORT_KEY and GPCMD_SEND_KEY from multi media commands */
cmd->xfer = buf[9] | (buf[8] << 8);
}
break;
}
return 0;
}
| false | qemu | 28b70c9dbdce0d517ade9c04c7d7ae05c8b76d2f | static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
{
switch (buf[0] >> 5) {
case 0:
cmd->xfer = buf[4];
cmd->len = 6;
break;
case 1:
case 2:
cmd->xfer = lduw_be_p(&buf[7]);
cmd->len = 10;
break;
case 4:
cmd->xfer = ldl_be_p(&buf[10]) & 0xffffffffULL;
cmd->len = 16;
break;
case 5:
cmd->xfer = ldl_be_p(&buf[6]) & 0xffffffffULL;
cmd->len = 12;
break;
default:
return -1;
}
switch (buf[0]) {
case TEST_UNIT_READY:
case REWIND:
case START_STOP:
case SET_CAPACITY:
case WRITE_FILEMARKS:
case WRITE_FILEMARKS_16:
case SPACE:
case RESERVE:
case RELEASE:
case ERASE:
case ALLOW_MEDIUM_REMOVAL:
case VERIFY_10:
case SEEK_10:
case SYNCHRONIZE_CACHE:
case SYNCHRONIZE_CACHE_16:
case LOCATE_16:
case LOCK_UNLOCK_CACHE:
case SET_CD_SPEED:
case SET_LIMITS:
case WRITE_LONG_10:
case MOVE_MEDIUM:
case UPDATE_BLOCK:
case RESERVE_TRACK:
case SET_READ_AHEAD:
case PRE_FETCH:
case PRE_FETCH_16:
case ALLOW_OVERWRITE:
cmd->xfer = 0;
break;
case MODE_SENSE:
break;
case WRITE_SAME_10:
case WRITE_SAME_16:
cmd->xfer = dev->blocksize;
break;
case READ_CAPACITY_10:
cmd->xfer = 8;
break;
case READ_BLOCK_LIMITS:
cmd->xfer = 6;
break;
case SEND_VOLUME_TAG:
if (dev->type == TYPE_ROM) {
cmd->xfer = buf[10] | (buf[9] << 8);
} else {
cmd->xfer = buf[9] | (buf[8] << 8);
}
break;
case WRITE_6:
if (cmd->xfer == 0) {
cmd->xfer = 256;
}
case WRITE_10:
case WRITE_VERIFY_10:
case WRITE_12:
case WRITE_VERIFY_12:
case WRITE_16:
case WRITE_VERIFY_16:
cmd->xfer *= dev->blocksize;
break;
case READ_6:
case READ_REVERSE:
if (cmd->xfer == 0) {
cmd->xfer = 256;
}
case READ_10:
case RECOVER_BUFFERED_DATA:
case READ_12:
case READ_16:
cmd->xfer *= dev->blocksize;
break;
case FORMAT_UNIT:
if (dev->type == TYPE_ROM && (buf[1] & 16)) {
cmd->xfer = 12;
} else {
cmd->xfer = (buf[1] & 16) == 0 ? 0 : (buf[1] & 32 ? 8 : 4);
}
break;
case INQUIRY:
case RECEIVE_DIAGNOSTIC:
case SEND_DIAGNOSTIC:
cmd->xfer = buf[4] | (buf[3] << 8);
break;
case READ_CD:
case READ_BUFFER:
case WRITE_BUFFER:
case SEND_CUE_SHEET:
cmd->xfer = buf[8] | (buf[7] << 8) | (buf[6] << 16);
break;
case PERSISTENT_RESERVE_OUT:
cmd->xfer = ldl_be_p(&buf[5]) & 0xffffffffULL;
break;
case ERASE_12:
if (dev->type == TYPE_ROM) {
cmd->xfer = scsi_get_performance_length(buf[9] | (buf[8] << 8),
buf[10], buf[1] & 0x1f);
}
break;
case MECHANISM_STATUS:
case READ_DVD_STRUCTURE:
case SEND_DVD_STRUCTURE:
case MAINTENANCE_OUT:
case MAINTENANCE_IN:
if (dev->type == TYPE_ROM) {
cmd->xfer = buf[9] | (buf[8] << 8);
}
break;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(SCSICommand *VAR_0, SCSIDevice *VAR_1, uint8_t *VAR_2)
{
switch (VAR_2[0] >> 5) {
case 0:
VAR_0->xfer = VAR_2[4];
VAR_0->len = 6;
break;
case 1:
case 2:
VAR_0->xfer = lduw_be_p(&VAR_2[7]);
VAR_0->len = 10;
break;
case 4:
VAR_0->xfer = ldl_be_p(&VAR_2[10]) & 0xffffffffULL;
VAR_0->len = 16;
break;
case 5:
VAR_0->xfer = ldl_be_p(&VAR_2[6]) & 0xffffffffULL;
VAR_0->len = 12;
break;
default:
return -1;
}
switch (VAR_2[0]) {
case TEST_UNIT_READY:
case REWIND:
case START_STOP:
case SET_CAPACITY:
case WRITE_FILEMARKS:
case WRITE_FILEMARKS_16:
case SPACE:
case RESERVE:
case RELEASE:
case ERASE:
case ALLOW_MEDIUM_REMOVAL:
case VERIFY_10:
case SEEK_10:
case SYNCHRONIZE_CACHE:
case SYNCHRONIZE_CACHE_16:
case LOCATE_16:
case LOCK_UNLOCK_CACHE:
case SET_CD_SPEED:
case SET_LIMITS:
case WRITE_LONG_10:
case MOVE_MEDIUM:
case UPDATE_BLOCK:
case RESERVE_TRACK:
case SET_READ_AHEAD:
case PRE_FETCH:
case PRE_FETCH_16:
case ALLOW_OVERWRITE:
VAR_0->xfer = 0;
break;
case MODE_SENSE:
break;
case WRITE_SAME_10:
case WRITE_SAME_16:
VAR_0->xfer = VAR_1->blocksize;
break;
case READ_CAPACITY_10:
VAR_0->xfer = 8;
break;
case READ_BLOCK_LIMITS:
VAR_0->xfer = 6;
break;
case SEND_VOLUME_TAG:
if (VAR_1->type == TYPE_ROM) {
VAR_0->xfer = VAR_2[10] | (VAR_2[9] << 8);
} else {
VAR_0->xfer = VAR_2[9] | (VAR_2[8] << 8);
}
break;
case WRITE_6:
if (VAR_0->xfer == 0) {
VAR_0->xfer = 256;
}
case WRITE_10:
case WRITE_VERIFY_10:
case WRITE_12:
case WRITE_VERIFY_12:
case WRITE_16:
case WRITE_VERIFY_16:
VAR_0->xfer *= VAR_1->blocksize;
break;
case READ_6:
case READ_REVERSE:
if (VAR_0->xfer == 0) {
VAR_0->xfer = 256;
}
case READ_10:
case RECOVER_BUFFERED_DATA:
case READ_12:
case READ_16:
VAR_0->xfer *= VAR_1->blocksize;
break;
case FORMAT_UNIT:
if (VAR_1->type == TYPE_ROM && (VAR_2[1] & 16)) {
VAR_0->xfer = 12;
} else {
VAR_0->xfer = (VAR_2[1] & 16) == 0 ? 0 : (VAR_2[1] & 32 ? 8 : 4);
}
break;
case INQUIRY:
case RECEIVE_DIAGNOSTIC:
case SEND_DIAGNOSTIC:
VAR_0->xfer = VAR_2[4] | (VAR_2[3] << 8);
break;
case READ_CD:
case READ_BUFFER:
case WRITE_BUFFER:
case SEND_CUE_SHEET:
VAR_0->xfer = VAR_2[8] | (VAR_2[7] << 8) | (VAR_2[6] << 16);
break;
case PERSISTENT_RESERVE_OUT:
VAR_0->xfer = ldl_be_p(&VAR_2[5]) & 0xffffffffULL;
break;
case ERASE_12:
if (VAR_1->type == TYPE_ROM) {
VAR_0->xfer = scsi_get_performance_length(VAR_2[9] | (VAR_2[8] << 8),
VAR_2[10], VAR_2[1] & 0x1f);
}
break;
case MECHANISM_STATUS:
case READ_DVD_STRUCTURE:
case SEND_DVD_STRUCTURE:
case MAINTENANCE_OUT:
case MAINTENANCE_IN:
if (VAR_1->type == TYPE_ROM) {
VAR_0->xfer = VAR_2[9] | (VAR_2[8] << 8);
}
break;
}
return 0;
}
| [
"static int FUNC_0(SCSICommand *VAR_0, SCSIDevice *VAR_1, uint8_t *VAR_2)\n{",
"switch (VAR_2[0] >> 5) {",
"case 0:\nVAR_0->xfer = VAR_2[4];",
"VAR_0->len = 6;",
"break;",
"case 1:\ncase 2:\nVAR_0->xfer = lduw_be_p(&VAR_2[7]);",
"VAR_0->len = 10;",
"break;",
"case 4:\nVAR_0->xfer = ldl_be_p(&VAR_2[10]) & 0xffffffffULL;",
"VAR_0->len = 16;",
"break;",
"case 5:\nVAR_0->xfer = ldl_be_p(&VAR_2[6]) & 0xffffffffULL;",
"VAR_0->len = 12;",
"break;",
"default:\nreturn -1;",
"}",
"switch (VAR_2[0]) {",
"case TEST_UNIT_READY:\ncase REWIND:\ncase START_STOP:\ncase SET_CAPACITY:\ncase WRITE_FILEMARKS:\ncase WRITE_FILEMARKS_16:\ncase SPACE:\ncase RESERVE:\ncase RELEASE:\ncase ERASE:\ncase ALLOW_MEDIUM_REMOVAL:\ncase VERIFY_10:\ncase SEEK_10:\ncase SYNCHRONIZE_CACHE:\ncase SYNCHRONIZE_CACHE_16:\ncase LOCATE_16:\ncase LOCK_UNLOCK_CACHE:\ncase SET_CD_SPEED:\ncase SET_LIMITS:\ncase WRITE_LONG_10:\ncase MOVE_MEDIUM:\ncase UPDATE_BLOCK:\ncase RESERVE_TRACK:\ncase SET_READ_AHEAD:\ncase PRE_FETCH:\ncase PRE_FETCH_16:\ncase ALLOW_OVERWRITE:\nVAR_0->xfer = 0;",
"break;",
"case MODE_SENSE:\nbreak;",
"case WRITE_SAME_10:\ncase WRITE_SAME_16:\nVAR_0->xfer = VAR_1->blocksize;",
"break;",
"case READ_CAPACITY_10:\nVAR_0->xfer = 8;",
"break;",
"case READ_BLOCK_LIMITS:\nVAR_0->xfer = 6;",
"break;",
"case SEND_VOLUME_TAG:\nif (VAR_1->type == TYPE_ROM) {",
"VAR_0->xfer = VAR_2[10] | (VAR_2[9] << 8);",
"} else {",
"VAR_0->xfer = VAR_2[9] | (VAR_2[8] << 8);",
"}",
"break;",
"case WRITE_6:\nif (VAR_0->xfer == 0) {",
"VAR_0->xfer = 256;",
"}",
"case WRITE_10:\ncase WRITE_VERIFY_10:\ncase WRITE_12:\ncase WRITE_VERIFY_12:\ncase WRITE_16:\ncase WRITE_VERIFY_16:\nVAR_0->xfer *= VAR_1->blocksize;",
"break;",
"case READ_6:\ncase READ_REVERSE:\nif (VAR_0->xfer == 0) {",
"VAR_0->xfer = 256;",
"}",
"case READ_10:\ncase RECOVER_BUFFERED_DATA:\ncase READ_12:\ncase READ_16:\nVAR_0->xfer *= VAR_1->blocksize;",
"break;",
"case FORMAT_UNIT:\nif (VAR_1->type == TYPE_ROM && (VAR_2[1] & 16)) {",
"VAR_0->xfer = 12;",
"} else {",
"VAR_0->xfer = (VAR_2[1] & 16) == 0 ? 0 : (VAR_2[1] & 32 ? 8 : 4);",
"}",
"break;",
"case INQUIRY:\ncase RECEIVE_DIAGNOSTIC:\ncase SEND_DIAGNOSTIC:\nVAR_0->xfer = VAR_2[4] | (VAR_2[3] << 8);",
"break;",
"case READ_CD:\ncase READ_BUFFER:\ncase WRITE_BUFFER:\ncase SEND_CUE_SHEET:\nVAR_0->xfer = VAR_2[8] | (VAR_2[7] << 8) | (VAR_2[6] << 16);",
"break;",
"case PERSISTENT_RESERVE_OUT:\nVAR_0->xfer = ldl_be_p(&VAR_2[5]) & 0xffffffffULL;",
"break;",
"case ERASE_12:\nif (VAR_1->type == TYPE_ROM) {",
"VAR_0->xfer = scsi_get_performance_length(VAR_2[9] | (VAR_2[8] << 8),\nVAR_2[10], VAR_2[1] & 0x1f);",
"}",
"break;",
"case MECHANISM_STATUS:\ncase READ_DVD_STRUCTURE:\ncase SEND_DVD_STRUCTURE:\ncase MAINTENANCE_OUT:\ncase MAINTENANCE_IN:\nif (VAR_1->type == TYPE_ROM) {",
"VAR_0->xfer = VAR_2[9] | (VAR_2[8] << 8);",
"}",
"break;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
],
[
13
],
[
15,
17,
19
],
[
21
],
[
23
],
[
25,
27
],
[
29
],
[
31
],
[
33,
35
],
[
37
],
[
39
],
[
41,
43
],
[
45
],
[
49
],
[
51,
53,
55,
57,
59,
61,
63,
65,
67,
69,
71,
73,
75,
77,
79,
81,
83,
85,
87,
89,
91,
93,
95,
97,
99,
101,
103,
105
],
[
107
],
[
109,
111
],
[
113,
115,
117
],
[
119
],
[
121,
123
],
[
125
],
[
127,
129
],
[
131
],
[
133,
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149,
153
],
[
155
],
[
157
],
[
159,
161,
163,
165,
167,
169,
171
],
[
173
],
[
175,
177,
181
],
[
183
],
[
185
],
[
187,
189,
191,
193,
195
],
[
197
],
[
199,
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219,
221,
223
],
[
225
],
[
227,
229,
231,
233,
235
],
[
237
],
[
239,
241
],
[
243
],
[
245,
247
],
[
251,
253
],
[
255
],
[
257
],
[
259,
261,
263,
265,
267,
269
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
]
] |
25,029 | static void draw_slice(AVFilterLink *link, int y, int h)
{
ScaleContext *scale = link->dst->priv;
int out_h;
AVFilterPicRef *cur_pic = link->cur_pic;
uint8_t *data[4];
if (!scale->slice_dir) {
if (y != 0 && y + h != link->h) {
av_log(scale, AV_LOG_ERROR, "Slices start in the middle!\n");
return;
}
scale->slice_dir = y ? -1 : 1;
scale->slice_y = y ? link->dst->outputs[0]->h : y;
}
data[0] = cur_pic->data[0] + y * cur_pic->linesize[0];
data[1] = scale->input_is_pal ?
cur_pic->data[1] :
cur_pic->data[1] + (y>>scale->vsub) * cur_pic->linesize[1];
data[2] = cur_pic->data[2] + (y>>scale->vsub) * cur_pic->linesize[2];
data[3] = cur_pic->data[3] + y * cur_pic->linesize[3];
out_h = sws_scale(scale->sws, data, cur_pic->linesize, y, h,
link->dst->outputs[0]->outpic->data,
link->dst->outputs[0]->outpic->linesize);
if (scale->slice_dir == -1)
scale->slice_y -= out_h;
avfilter_draw_slice(link->dst->outputs[0], scale->slice_y, out_h);
if (scale->slice_dir == 1)
scale->slice_y += out_h;
}
| false | FFmpeg | 8aeb33225aed5a0da03f9145a09ca1bbd6ac6532 | static void draw_slice(AVFilterLink *link, int y, int h)
{
ScaleContext *scale = link->dst->priv;
int out_h;
AVFilterPicRef *cur_pic = link->cur_pic;
uint8_t *data[4];
if (!scale->slice_dir) {
if (y != 0 && y + h != link->h) {
av_log(scale, AV_LOG_ERROR, "Slices start in the middle!\n");
return;
}
scale->slice_dir = y ? -1 : 1;
scale->slice_y = y ? link->dst->outputs[0]->h : y;
}
data[0] = cur_pic->data[0] + y * cur_pic->linesize[0];
data[1] = scale->input_is_pal ?
cur_pic->data[1] :
cur_pic->data[1] + (y>>scale->vsub) * cur_pic->linesize[1];
data[2] = cur_pic->data[2] + (y>>scale->vsub) * cur_pic->linesize[2];
data[3] = cur_pic->data[3] + y * cur_pic->linesize[3];
out_h = sws_scale(scale->sws, data, cur_pic->linesize, y, h,
link->dst->outputs[0]->outpic->data,
link->dst->outputs[0]->outpic->linesize);
if (scale->slice_dir == -1)
scale->slice_y -= out_h;
avfilter_draw_slice(link->dst->outputs[0], scale->slice_y, out_h);
if (scale->slice_dir == 1)
scale->slice_y += out_h;
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVFilterLink *VAR_0, int VAR_1, int VAR_2)
{
ScaleContext *scale = VAR_0->dst->priv;
int VAR_3;
AVFilterPicRef *cur_pic = VAR_0->cur_pic;
uint8_t *data[4];
if (!scale->slice_dir) {
if (VAR_1 != 0 && VAR_1 + VAR_2 != VAR_0->VAR_2) {
av_log(scale, AV_LOG_ERROR, "Slices start in the middle!\n");
return;
}
scale->slice_dir = VAR_1 ? -1 : 1;
scale->slice_y = VAR_1 ? VAR_0->dst->outputs[0]->VAR_2 : VAR_1;
}
data[0] = cur_pic->data[0] + VAR_1 * cur_pic->linesize[0];
data[1] = scale->input_is_pal ?
cur_pic->data[1] :
cur_pic->data[1] + (VAR_1>>scale->vsub) * cur_pic->linesize[1];
data[2] = cur_pic->data[2] + (VAR_1>>scale->vsub) * cur_pic->linesize[2];
data[3] = cur_pic->data[3] + VAR_1 * cur_pic->linesize[3];
VAR_3 = sws_scale(scale->sws, data, cur_pic->linesize, VAR_1, VAR_2,
VAR_0->dst->outputs[0]->outpic->data,
VAR_0->dst->outputs[0]->outpic->linesize);
if (scale->slice_dir == -1)
scale->slice_y -= VAR_3;
avfilter_draw_slice(VAR_0->dst->outputs[0], scale->slice_y, VAR_3);
if (scale->slice_dir == 1)
scale->slice_y += VAR_3;
}
| [
"static void FUNC_0(AVFilterLink *VAR_0, int VAR_1, int VAR_2)\n{",
"ScaleContext *scale = VAR_0->dst->priv;",
"int VAR_3;",
"AVFilterPicRef *cur_pic = VAR_0->cur_pic;",
"uint8_t *data[4];",
"if (!scale->slice_dir) {",
"if (VAR_1 != 0 && VAR_1 + VAR_2 != VAR_0->VAR_2) {",
"av_log(scale, AV_LOG_ERROR, \"Slices start in the middle!\\n\");",
"return;",
"}",
"scale->slice_dir = VAR_1 ? -1 : 1;",
"scale->slice_y = VAR_1 ? VAR_0->dst->outputs[0]->VAR_2 : VAR_1;",
"}",
"data[0] = cur_pic->data[0] + VAR_1 * cur_pic->linesize[0];",
"data[1] = scale->input_is_pal ?\ncur_pic->data[1] :\ncur_pic->data[1] + (VAR_1>>scale->vsub) * cur_pic->linesize[1];",
"data[2] = cur_pic->data[2] + (VAR_1>>scale->vsub) * cur_pic->linesize[2];",
"data[3] = cur_pic->data[3] + VAR_1 * cur_pic->linesize[3];",
"VAR_3 = sws_scale(scale->sws, data, cur_pic->linesize, VAR_1, VAR_2,\nVAR_0->dst->outputs[0]->outpic->data,\nVAR_0->dst->outputs[0]->outpic->linesize);",
"if (scale->slice_dir == -1)\nscale->slice_y -= VAR_3;",
"avfilter_draw_slice(VAR_0->dst->outputs[0], scale->slice_y, VAR_3);",
"if (scale->slice_dir == 1)\nscale->slice_y += VAR_3;",
"}"
] | [
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
],
[
33
],
[
35,
37,
39
],
[
41
],
[
43
],
[
47,
49,
51
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
]
] |
25,030 | static void spapr_phb_finish_realize(sPAPRPHBState *sphb, Error **errp)
{
sphb->dma_window_start = 0;
sphb->dma_window_size = 0x40000000;
sphb->tcet = spapr_tce_new_table(DEVICE(sphb), sphb->dma_liobn,
sphb->dma_window_size);
if (!sphb->tcet) {
error_setg(errp, "Unable to create TCE table for %s",
sphb->dtbusname);
return ;
}
address_space_init(&sphb->iommu_as, spapr_tce_get_iommu(sphb->tcet),
sphb->dtbusname);
}
| false | qemu | cca7fad5765251fece44cd230156a101867522dd | static void spapr_phb_finish_realize(sPAPRPHBState *sphb, Error **errp)
{
sphb->dma_window_start = 0;
sphb->dma_window_size = 0x40000000;
sphb->tcet = spapr_tce_new_table(DEVICE(sphb), sphb->dma_liobn,
sphb->dma_window_size);
if (!sphb->tcet) {
error_setg(errp, "Unable to create TCE table for %s",
sphb->dtbusname);
return ;
}
address_space_init(&sphb->iommu_as, spapr_tce_get_iommu(sphb->tcet),
sphb->dtbusname);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(sPAPRPHBState *VAR_0, Error **VAR_1)
{
VAR_0->dma_window_start = 0;
VAR_0->dma_window_size = 0x40000000;
VAR_0->tcet = spapr_tce_new_table(DEVICE(VAR_0), VAR_0->dma_liobn,
VAR_0->dma_window_size);
if (!VAR_0->tcet) {
error_setg(VAR_1, "Unable to create TCE table for %s",
VAR_0->dtbusname);
return ;
}
address_space_init(&VAR_0->iommu_as, spapr_tce_get_iommu(VAR_0->tcet),
VAR_0->dtbusname);
}
| [
"static void FUNC_0(sPAPRPHBState *VAR_0, Error **VAR_1)\n{",
"VAR_0->dma_window_start = 0;",
"VAR_0->dma_window_size = 0x40000000;",
"VAR_0->tcet = spapr_tce_new_table(DEVICE(VAR_0), VAR_0->dma_liobn,\nVAR_0->dma_window_size);",
"if (!VAR_0->tcet) {",
"error_setg(VAR_1, \"Unable to create TCE table for %s\",\nVAR_0->dtbusname);",
"return ;",
"}",
"address_space_init(&VAR_0->iommu_as, spapr_tce_get_iommu(VAR_0->tcet),\nVAR_0->dtbusname);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9,
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
]
] |
25,031 | static void tcx_rblit_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
TCXState *s = opaque;
uint32_t adsr, len;
int i;
if (!(addr & 4)) {
s->tmpblit = val;
} else {
addr = (addr >> 3) & 0xfffff;
adsr = val & 0xffffff;
len = ((val >> 24) & 0x1f) + 1;
if (adsr == 0xffffff) {
memset(&s->vram[addr], s->tmpblit, len);
if (s->depth == 24) {
val = s->tmpblit & 0xffffff;
val = cpu_to_be32(val);
for (i = 0; i < len; i++) {
s->vram24[addr + i] = val;
s->cplane[addr + i] = val;
}
}
} else {
memcpy(&s->vram[addr], &s->vram[adsr], len);
if (s->depth == 24) {
memcpy(&s->vram24[addr], &s->vram24[adsr], len * 4);
memcpy(&s->cplane[addr], &s->cplane[adsr], len * 4);
}
}
memory_region_set_dirty(&s->vram_mem, addr, len);
}
}
| false | qemu | 973945804d95878375b487c0c5c9b2556c5e4543 | static void tcx_rblit_writel(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
{
TCXState *s = opaque;
uint32_t adsr, len;
int i;
if (!(addr & 4)) {
s->tmpblit = val;
} else {
addr = (addr >> 3) & 0xfffff;
adsr = val & 0xffffff;
len = ((val >> 24) & 0x1f) + 1;
if (adsr == 0xffffff) {
memset(&s->vram[addr], s->tmpblit, len);
if (s->depth == 24) {
val = s->tmpblit & 0xffffff;
val = cpu_to_be32(val);
for (i = 0; i < len; i++) {
s->vram24[addr + i] = val;
s->cplane[addr + i] = val;
}
}
} else {
memcpy(&s->vram[addr], &s->vram[adsr], len);
if (s->depth == 24) {
memcpy(&s->vram24[addr], &s->vram24[adsr], len * 4);
memcpy(&s->cplane[addr], &s->cplane[adsr], len * 4);
}
}
memory_region_set_dirty(&s->vram_mem, addr, len);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
TCXState *s = VAR_0;
uint32_t adsr, len;
int VAR_4;
if (!(VAR_1 & 4)) {
s->tmpblit = VAR_2;
} else {
VAR_1 = (VAR_1 >> 3) & 0xfffff;
adsr = VAR_2 & 0xffffff;
len = ((VAR_2 >> 24) & 0x1f) + 1;
if (adsr == 0xffffff) {
memset(&s->vram[VAR_1], s->tmpblit, len);
if (s->depth == 24) {
VAR_2 = s->tmpblit & 0xffffff;
VAR_2 = cpu_to_be32(VAR_2);
for (VAR_4 = 0; VAR_4 < len; VAR_4++) {
s->vram24[VAR_1 + VAR_4] = VAR_2;
s->cplane[VAR_1 + VAR_4] = VAR_2;
}
}
} else {
memcpy(&s->vram[VAR_1], &s->vram[adsr], len);
if (s->depth == 24) {
memcpy(&s->vram24[VAR_1], &s->vram24[adsr], len * 4);
memcpy(&s->cplane[VAR_1], &s->cplane[adsr], len * 4);
}
}
memory_region_set_dirty(&s->vram_mem, VAR_1, len);
}
}
| [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"TCXState *s = VAR_0;",
"uint32_t adsr, len;",
"int VAR_4;",
"if (!(VAR_1 & 4)) {",
"s->tmpblit = VAR_2;",
"} else {",
"VAR_1 = (VAR_1 >> 3) & 0xfffff;",
"adsr = VAR_2 & 0xffffff;",
"len = ((VAR_2 >> 24) & 0x1f) + 1;",
"if (adsr == 0xffffff) {",
"memset(&s->vram[VAR_1], s->tmpblit, len);",
"if (s->depth == 24) {",
"VAR_2 = s->tmpblit & 0xffffff;",
"VAR_2 = cpu_to_be32(VAR_2);",
"for (VAR_4 = 0; VAR_4 < len; VAR_4++) {",
"s->vram24[VAR_1 + VAR_4] = VAR_2;",
"s->cplane[VAR_1 + VAR_4] = VAR_2;",
"}",
"}",
"} else {",
"memcpy(&s->vram[VAR_1], &s->vram[adsr], len);",
"if (s->depth == 24) {",
"memcpy(&s->vram24[VAR_1], &s->vram24[adsr], len * 4);",
"memcpy(&s->cplane[VAR_1], &s->cplane[adsr], len * 4);",
"}",
"}",
"memory_region_set_dirty(&s->vram_mem, VAR_1, len);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
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
]
] |
25,032 | static CharDriverState *qemu_chr_open_mux(const char *id,
ChardevBackend *backend,
ChardevReturn *ret, Error **errp)
{
ChardevMux *mux = backend->mux;
CharDriverState *chr, *drv;
MuxDriver *d;
drv = qemu_chr_find(mux->chardev);
if (drv == NULL) {
error_setg(errp, "mux: base chardev %s not found", mux->chardev);
return NULL;
}
chr = qemu_chr_alloc();
d = g_new0(MuxDriver, 1);
chr->opaque = d;
d->drv = drv;
d->focus = -1;
chr->chr_write = mux_chr_write;
chr->chr_update_read_handler = mux_chr_update_read_handler;
chr->chr_accept_input = mux_chr_accept_input;
/* Frontend guest-open / -close notification is not support with muxes */
chr->chr_set_fe_open = NULL;
if (drv->chr_add_watch) {
chr->chr_add_watch = mux_chr_add_watch;
}
/* only default to opened state if we've realized the initial
* set of muxes
*/
chr->explicit_be_open = muxes_realized ? 0 : 1;
chr->is_mux = 1;
return chr;
}
| false | qemu | 130257dc443574a9da91dc293665be2cfc40245a | static CharDriverState *qemu_chr_open_mux(const char *id,
ChardevBackend *backend,
ChardevReturn *ret, Error **errp)
{
ChardevMux *mux = backend->mux;
CharDriverState *chr, *drv;
MuxDriver *d;
drv = qemu_chr_find(mux->chardev);
if (drv == NULL) {
error_setg(errp, "mux: base chardev %s not found", mux->chardev);
return NULL;
}
chr = qemu_chr_alloc();
d = g_new0(MuxDriver, 1);
chr->opaque = d;
d->drv = drv;
d->focus = -1;
chr->chr_write = mux_chr_write;
chr->chr_update_read_handler = mux_chr_update_read_handler;
chr->chr_accept_input = mux_chr_accept_input;
chr->chr_set_fe_open = NULL;
if (drv->chr_add_watch) {
chr->chr_add_watch = mux_chr_add_watch;
}
chr->explicit_be_open = muxes_realized ? 0 : 1;
chr->is_mux = 1;
return chr;
}
| {
"code": [],
"line_no": []
} | static CharDriverState *FUNC_0(const char *id,
ChardevBackend *backend,
ChardevReturn *ret, Error **errp)
{
ChardevMux *mux = backend->mux;
CharDriverState *chr, *drv;
MuxDriver *d;
drv = qemu_chr_find(mux->chardev);
if (drv == NULL) {
error_setg(errp, "mux: base chardev %s not found", mux->chardev);
return NULL;
}
chr = qemu_chr_alloc();
d = g_new0(MuxDriver, 1);
chr->opaque = d;
d->drv = drv;
d->focus = -1;
chr->chr_write = mux_chr_write;
chr->chr_update_read_handler = mux_chr_update_read_handler;
chr->chr_accept_input = mux_chr_accept_input;
chr->chr_set_fe_open = NULL;
if (drv->chr_add_watch) {
chr->chr_add_watch = mux_chr_add_watch;
}
chr->explicit_be_open = muxes_realized ? 0 : 1;
chr->is_mux = 1;
return chr;
}
| [
"static CharDriverState *FUNC_0(const char *id,\nChardevBackend *backend,\nChardevReturn *ret, Error **errp)\n{",
"ChardevMux *mux = backend->mux;",
"CharDriverState *chr, *drv;",
"MuxDriver *d;",
"drv = qemu_chr_find(mux->chardev);",
"if (drv == NULL) {",
"error_setg(errp, \"mux: base chardev %s not found\", mux->chardev);",
"return NULL;",
"}",
"chr = qemu_chr_alloc();",
"d = g_new0(MuxDriver, 1);",
"chr->opaque = d;",
"d->drv = drv;",
"d->focus = -1;",
"chr->chr_write = mux_chr_write;",
"chr->chr_update_read_handler = mux_chr_update_read_handler;",
"chr->chr_accept_input = mux_chr_accept_input;",
"chr->chr_set_fe_open = NULL;",
"if (drv->chr_add_watch) {",
"chr->chr_add_watch = mux_chr_add_watch;",
"}",
"chr->explicit_be_open = muxes_realized ? 0 : 1;",
"chr->is_mux = 1;",
"return chr;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
63
],
[
65
],
[
69
],
[
71
]
] |
25,033 | static void pmac_ide_transfer(DBDMA_io *io)
{
MACIOIDEState *m = io->opaque;
IDEState *s = idebus_active_if(&m->bus);
MACIO_DPRINTF("\n");
s->io_buffer_size = 0;
if (s->drive_kind == IDE_CD) {
/* Handle non-block ATAPI DMA transfers */
if (s->lba == -1) {
s->io_buffer_size = MIN(io->len, s->packet_transfer_size);
block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->io_buffer_size,
BLOCK_ACCT_READ);
MACIO_DPRINTF("non-block ATAPI DMA transfer size: %d\n",
s->io_buffer_size);
/* Copy ATAPI buffer directly to RAM and finish */
cpu_physical_memory_write(io->addr, s->io_buffer,
s->io_buffer_size);
ide_atapi_cmd_ok(s);
m->dma_active = false;
MACIO_DPRINTF("end of non-block ATAPI DMA transfer\n");
block_acct_done(bdrv_get_stats(s->bs), &s->acct);
io->dma_end(io);
return;
}
block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,
BLOCK_ACCT_READ);
pmac_ide_atapi_transfer_cb(io, 0);
return;
}
switch (s->dma_cmd) {
case IDE_DMA_READ:
block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,
BLOCK_ACCT_READ);
break;
case IDE_DMA_WRITE:
block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,
BLOCK_ACCT_WRITE);
break;
default:
break;
}
io->requests++;
pmac_ide_transfer_cb(io, 0);
}
| false | qemu | 4be746345f13e99e468c60acbd3a355e8183e3ce | static void pmac_ide_transfer(DBDMA_io *io)
{
MACIOIDEState *m = io->opaque;
IDEState *s = idebus_active_if(&m->bus);
MACIO_DPRINTF("\n");
s->io_buffer_size = 0;
if (s->drive_kind == IDE_CD) {
if (s->lba == -1) {
s->io_buffer_size = MIN(io->len, s->packet_transfer_size);
block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->io_buffer_size,
BLOCK_ACCT_READ);
MACIO_DPRINTF("non-block ATAPI DMA transfer size: %d\n",
s->io_buffer_size);
cpu_physical_memory_write(io->addr, s->io_buffer,
s->io_buffer_size);
ide_atapi_cmd_ok(s);
m->dma_active = false;
MACIO_DPRINTF("end of non-block ATAPI DMA transfer\n");
block_acct_done(bdrv_get_stats(s->bs), &s->acct);
io->dma_end(io);
return;
}
block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,
BLOCK_ACCT_READ);
pmac_ide_atapi_transfer_cb(io, 0);
return;
}
switch (s->dma_cmd) {
case IDE_DMA_READ:
block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,
BLOCK_ACCT_READ);
break;
case IDE_DMA_WRITE:
block_acct_start(bdrv_get_stats(s->bs), &s->acct, io->len,
BLOCK_ACCT_WRITE);
break;
default:
break;
}
io->requests++;
pmac_ide_transfer_cb(io, 0);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(DBDMA_io *VAR_0)
{
MACIOIDEState *m = VAR_0->opaque;
IDEState *s = idebus_active_if(&m->bus);
MACIO_DPRINTF("\n");
s->io_buffer_size = 0;
if (s->drive_kind == IDE_CD) {
if (s->lba == -1) {
s->io_buffer_size = MIN(VAR_0->len, s->packet_transfer_size);
block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->io_buffer_size,
BLOCK_ACCT_READ);
MACIO_DPRINTF("non-block ATAPI DMA transfer size: %d\n",
s->io_buffer_size);
cpu_physical_memory_write(VAR_0->addr, s->io_buffer,
s->io_buffer_size);
ide_atapi_cmd_ok(s);
m->dma_active = false;
MACIO_DPRINTF("end of non-block ATAPI DMA transfer\n");
block_acct_done(bdrv_get_stats(s->bs), &s->acct);
VAR_0->dma_end(VAR_0);
return;
}
block_acct_start(bdrv_get_stats(s->bs), &s->acct, VAR_0->len,
BLOCK_ACCT_READ);
pmac_ide_atapi_transfer_cb(VAR_0, 0);
return;
}
switch (s->dma_cmd) {
case IDE_DMA_READ:
block_acct_start(bdrv_get_stats(s->bs), &s->acct, VAR_0->len,
BLOCK_ACCT_READ);
break;
case IDE_DMA_WRITE:
block_acct_start(bdrv_get_stats(s->bs), &s->acct, VAR_0->len,
BLOCK_ACCT_WRITE);
break;
default:
break;
}
VAR_0->requests++;
pmac_ide_transfer_cb(VAR_0, 0);
}
| [
"static void FUNC_0(DBDMA_io *VAR_0)\n{",
"MACIOIDEState *m = VAR_0->opaque;",
"IDEState *s = idebus_active_if(&m->bus);",
"MACIO_DPRINTF(\"\\n\");",
"s->io_buffer_size = 0;",
"if (s->drive_kind == IDE_CD) {",
"if (s->lba == -1) {",
"s->io_buffer_size = MIN(VAR_0->len, s->packet_transfer_size);",
"block_acct_start(bdrv_get_stats(s->bs), &s->acct, s->io_buffer_size,\nBLOCK_ACCT_READ);",
"MACIO_DPRINTF(\"non-block ATAPI DMA transfer size: %d\\n\",\ns->io_buffer_size);",
"cpu_physical_memory_write(VAR_0->addr, s->io_buffer,\ns->io_buffer_size);",
"ide_atapi_cmd_ok(s);",
"m->dma_active = false;",
"MACIO_DPRINTF(\"end of non-block ATAPI DMA transfer\\n\");",
"block_acct_done(bdrv_get_stats(s->bs), &s->acct);",
"VAR_0->dma_end(VAR_0);",
"return;",
"}",
"block_acct_start(bdrv_get_stats(s->bs), &s->acct, VAR_0->len,\nBLOCK_ACCT_READ);",
"pmac_ide_atapi_transfer_cb(VAR_0, 0);",
"return;",
"}",
"switch (s->dma_cmd) {",
"case IDE_DMA_READ:\nblock_acct_start(bdrv_get_stats(s->bs), &s->acct, VAR_0->len,\nBLOCK_ACCT_READ);",
"break;",
"case IDE_DMA_WRITE:\nblock_acct_start(bdrv_get_stats(s->bs), &s->acct, VAR_0->len,\nBLOCK_ACCT_WRITE);",
"break;",
"default:\nbreak;",
"}",
"VAR_0->requests++;",
"pmac_ide_transfer_cb(VAR_0, 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
15
],
[
17
],
[
23
],
[
25
],
[
27,
29
],
[
31,
33
],
[
39,
41
],
[
43
],
[
45
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61,
63
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75,
77,
79
],
[
81
],
[
83,
85,
87
],
[
89
],
[
91,
93
],
[
95
],
[
99
],
[
101
],
[
103
]
] |
25,034 | static void do_cpu_set(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
int index = qdict_get_int(qdict, "index");
if (mon_set_cpu(index) < 0)
qemu_error_new(QERR_INVALID_CPU_INDEX);
}
| false | qemu | cc0c4185e54867ef93c4b4dc0a8f3ecbc20ece42 | static void do_cpu_set(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
int index = qdict_get_int(qdict, "index");
if (mon_set_cpu(index) < 0)
qemu_error_new(QERR_INVALID_CPU_INDEX);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)
{
int VAR_3 = qdict_get_int(VAR_1, "VAR_3");
if (mon_set_cpu(VAR_3) < 0)
qemu_error_new(QERR_INVALID_CPU_INDEX);
}
| [
"static void FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)\n{",
"int VAR_3 = qdict_get_int(VAR_1, \"VAR_3\");",
"if (mon_set_cpu(VAR_3) < 0)\nqemu_error_new(QERR_INVALID_CPU_INDEX);",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7,
9
],
[
11
]
] |
25,035 | static int get_phys_addr_lpae(CPUARMState *env, target_ulong address,
int access_type, ARMMMUIdx mmu_idx,
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
target_ulong *page_size_ptr)
{
CPUState *cs = CPU(arm_env_get_cpu(env));
/* Read an LPAE long-descriptor translation table. */
MMUFaultType fault_type = translation_fault;
uint32_t level = 1;
uint32_t epd;
int32_t tsz;
uint32_t tg;
uint64_t ttbr;
int ttbr_select;
hwaddr descaddr, descmask;
uint32_t tableattrs;
target_ulong page_size;
uint32_t attrs;
int32_t granule_sz = 9;
int32_t va_size = 32;
int32_t tbi = 0;
TCR *tcr = regime_tcr(env, mmu_idx);
int ap, ns, xn, pxn;
/* TODO:
* This code assumes we're either a 64-bit EL1 or a 32-bit PL1;
* it doesn't handle the different format TCR for TCR_EL2, TCR_EL3,
* and VTCR_EL2, or the fact that those regimes don't have a split
* TTBR0/TTBR1. Attribute and permission bit handling should also
* be checked when adding support for those page table walks.
*/
if (arm_el_is_aa64(env, regime_el(env, mmu_idx))) {
va_size = 64;
if (extract64(address, 55, 1))
tbi = extract64(tcr->raw_tcr, 38, 1);
else
tbi = extract64(tcr->raw_tcr, 37, 1);
tbi *= 8;
}
/* Determine whether this address is in the region controlled by
* TTBR0 or TTBR1 (or if it is in neither region and should fault).
* This is a Non-secure PL0/1 stage 1 translation, so controlled by
* TTBCR/TTBR0/TTBR1 in accordance with ARM ARM DDI0406C table B-32:
*/
uint32_t t0sz = extract32(tcr->raw_tcr, 0, 6);
if (va_size == 64) {
t0sz = MIN(t0sz, 39);
t0sz = MAX(t0sz, 16);
}
uint32_t t1sz = extract32(tcr->raw_tcr, 16, 6);
if (va_size == 64) {
t1sz = MIN(t1sz, 39);
t1sz = MAX(t1sz, 16);
}
if (t0sz && !extract64(address, va_size - t0sz, t0sz - tbi)) {
/* there is a ttbr0 region and we are in it (high bits all zero) */
ttbr_select = 0;
} else if (t1sz && !extract64(~address, va_size - t1sz, t1sz - tbi)) {
/* there is a ttbr1 region and we are in it (high bits all one) */
ttbr_select = 1;
} else if (!t0sz) {
/* ttbr0 region is "everything not in the ttbr1 region" */
ttbr_select = 0;
} else if (!t1sz) {
/* ttbr1 region is "everything not in the ttbr0 region" */
ttbr_select = 1;
} else {
/* in the gap between the two regions, this is a Translation fault */
fault_type = translation_fault;
goto do_fault;
}
/* Note that QEMU ignores shareability and cacheability attributes,
* so we don't need to do anything with the SH, ORGN, IRGN fields
* in the TTBCR. Similarly, TTBCR:A1 selects whether we get the
* ASID from TTBR0 or TTBR1, but QEMU's TLB doesn't currently
* implement any ASID-like capability so we can ignore it (instead
* we will always flush the TLB any time the ASID is changed).
*/
if (ttbr_select == 0) {
ttbr = regime_ttbr(env, mmu_idx, 0);
epd = extract32(tcr->raw_tcr, 7, 1);
tsz = t0sz;
tg = extract32(tcr->raw_tcr, 14, 2);
if (tg == 1) { /* 64KB pages */
granule_sz = 13;
}
if (tg == 2) { /* 16KB pages */
granule_sz = 11;
}
} else {
ttbr = regime_ttbr(env, mmu_idx, 1);
epd = extract32(tcr->raw_tcr, 23, 1);
tsz = t1sz;
tg = extract32(tcr->raw_tcr, 30, 2);
if (tg == 3) { /* 64KB pages */
granule_sz = 13;
}
if (tg == 1) { /* 16KB pages */
granule_sz = 11;
}
}
/* Here we should have set up all the parameters for the translation:
* va_size, ttbr, epd, tsz, granule_sz, tbi
*/
if (epd) {
/* Translation table walk disabled => Translation fault on TLB miss */
goto do_fault;
}
/* The starting level depends on the virtual address size (which can be
* up to 48 bits) and the translation granule size. It indicates the number
* of strides (granule_sz bits at a time) needed to consume the bits
* of the input address. In the pseudocode this is:
* level = 4 - RoundUp((inputsize - grainsize) / stride)
* where their 'inputsize' is our 'va_size - tsz', 'grainsize' is
* our 'granule_sz + 3' and 'stride' is our 'granule_sz'.
* Applying the usual "rounded up m/n is (m+n-1)/n" and simplifying:
* = 4 - (va_size - tsz - granule_sz - 3 + granule_sz - 1) / granule_sz
* = 4 - (va_size - tsz - 4) / granule_sz;
*/
level = 4 - (va_size - tsz - 4) / granule_sz;
/* Clear the vaddr bits which aren't part of the within-region address,
* so that we don't have to special case things when calculating the
* first descriptor address.
*/
if (tsz) {
address &= (1ULL << (va_size - tsz)) - 1;
}
descmask = (1ULL << (granule_sz + 3)) - 1;
/* Now we can extract the actual base address from the TTBR */
descaddr = extract64(ttbr, 0, 48);
descaddr &= ~((1ULL << (va_size - tsz - (granule_sz * (4 - level)))) - 1);
/* Secure accesses start with the page table in secure memory and
* can be downgraded to non-secure at any step. Non-secure accesses
* remain non-secure. We implement this by just ORing in the NSTable/NS
* bits at each step.
*/
tableattrs = regime_is_secure(env, mmu_idx) ? 0 : (1 << 4);
for (;;) {
uint64_t descriptor;
bool nstable;
descaddr |= (address >> (granule_sz * (4 - level))) & descmask;
descaddr &= ~7ULL;
nstable = extract32(tableattrs, 4, 1);
descriptor = arm_ldq_ptw(cs, descaddr, !nstable);
if (!(descriptor & 1) ||
(!(descriptor & 2) && (level == 3))) {
/* Invalid, or the Reserved level 3 encoding */
goto do_fault;
}
descaddr = descriptor & 0xfffffff000ULL;
if ((descriptor & 2) && (level < 3)) {
/* Table entry. The top five bits are attributes which may
* propagate down through lower levels of the table (and
* which are all arranged so that 0 means "no effect", so
* we can gather them up by ORing in the bits at each level).
*/
tableattrs |= extract64(descriptor, 59, 5);
level++;
continue;
}
/* Block entry at level 1 or 2, or page entry at level 3.
* These are basically the same thing, although the number
* of bits we pull in from the vaddr varies.
*/
page_size = (1ULL << ((granule_sz * (4 - level)) + 3));
descaddr |= (address & (page_size - 1));
/* Extract attributes from the descriptor and merge with table attrs */
attrs = extract64(descriptor, 2, 10)
| (extract64(descriptor, 52, 12) << 10);
attrs |= extract32(tableattrs, 0, 2) << 11; /* XN, PXN */
attrs |= extract32(tableattrs, 3, 1) << 5; /* APTable[1] => AP[2] */
/* The sense of AP[1] vs APTable[0] is reversed, as APTable[0] == 1
* means "force PL1 access only", which means forcing AP[1] to 0.
*/
if (extract32(tableattrs, 2, 1)) {
attrs &= ~(1 << 4);
}
attrs |= nstable << 3; /* NS */
break;
}
/* Here descaddr is the final physical address, and attributes
* are all in attrs.
*/
fault_type = access_fault;
if ((attrs & (1 << 8)) == 0) {
/* Access flag */
goto do_fault;
}
ap = extract32(attrs, 4, 2);
ns = extract32(attrs, 3, 1);
xn = extract32(attrs, 12, 1);
pxn = extract32(attrs, 11, 1);
*prot = get_S1prot(env, mmu_idx, va_size == 64, ap, ns, xn, pxn);
fault_type = permission_fault;
if (!(*prot & (1 << access_type))) {
goto do_fault;
}
if (ns) {
/* The NS bit will (as required by the architecture) have no effect if
* the CPU doesn't support TZ or this is a non-secure translation
* regime, because the attribute will already be non-secure.
*/
txattrs->secure = false;
}
*phys_ptr = descaddr;
*page_size_ptr = page_size;
return 0;
do_fault:
/* Long-descriptor format IFSR/DFSR value */
return (1 << 9) | (fault_type << 2) | level;
}
| false | qemu | 88e8add8b6656c349a96b447b074688d02dc5415 | static int get_phys_addr_lpae(CPUARMState *env, target_ulong address,
int access_type, ARMMMUIdx mmu_idx,
hwaddr *phys_ptr, MemTxAttrs *txattrs, int *prot,
target_ulong *page_size_ptr)
{
CPUState *cs = CPU(arm_env_get_cpu(env));
MMUFaultType fault_type = translation_fault;
uint32_t level = 1;
uint32_t epd;
int32_t tsz;
uint32_t tg;
uint64_t ttbr;
int ttbr_select;
hwaddr descaddr, descmask;
uint32_t tableattrs;
target_ulong page_size;
uint32_t attrs;
int32_t granule_sz = 9;
int32_t va_size = 32;
int32_t tbi = 0;
TCR *tcr = regime_tcr(env, mmu_idx);
int ap, ns, xn, pxn;
if (arm_el_is_aa64(env, regime_el(env, mmu_idx))) {
va_size = 64;
if (extract64(address, 55, 1))
tbi = extract64(tcr->raw_tcr, 38, 1);
else
tbi = extract64(tcr->raw_tcr, 37, 1);
tbi *= 8;
}
uint32_t t0sz = extract32(tcr->raw_tcr, 0, 6);
if (va_size == 64) {
t0sz = MIN(t0sz, 39);
t0sz = MAX(t0sz, 16);
}
uint32_t t1sz = extract32(tcr->raw_tcr, 16, 6);
if (va_size == 64) {
t1sz = MIN(t1sz, 39);
t1sz = MAX(t1sz, 16);
}
if (t0sz && !extract64(address, va_size - t0sz, t0sz - tbi)) {
ttbr_select = 0;
} else if (t1sz && !extract64(~address, va_size - t1sz, t1sz - tbi)) {
ttbr_select = 1;
} else if (!t0sz) {
ttbr_select = 0;
} else if (!t1sz) {
ttbr_select = 1;
} else {
fault_type = translation_fault;
goto do_fault;
}
if (ttbr_select == 0) {
ttbr = regime_ttbr(env, mmu_idx, 0);
epd = extract32(tcr->raw_tcr, 7, 1);
tsz = t0sz;
tg = extract32(tcr->raw_tcr, 14, 2);
if (tg == 1) {
granule_sz = 13;
}
if (tg == 2) {
granule_sz = 11;
}
} else {
ttbr = regime_ttbr(env, mmu_idx, 1);
epd = extract32(tcr->raw_tcr, 23, 1);
tsz = t1sz;
tg = extract32(tcr->raw_tcr, 30, 2);
if (tg == 3) {
granule_sz = 13;
}
if (tg == 1) {
granule_sz = 11;
}
}
if (epd) {
goto do_fault;
}
level = 4 - (va_size - tsz - 4) / granule_sz;
if (tsz) {
address &= (1ULL << (va_size - tsz)) - 1;
}
descmask = (1ULL << (granule_sz + 3)) - 1;
descaddr = extract64(ttbr, 0, 48);
descaddr &= ~((1ULL << (va_size - tsz - (granule_sz * (4 - level)))) - 1);
tableattrs = regime_is_secure(env, mmu_idx) ? 0 : (1 << 4);
for (;;) {
uint64_t descriptor;
bool nstable;
descaddr |= (address >> (granule_sz * (4 - level))) & descmask;
descaddr &= ~7ULL;
nstable = extract32(tableattrs, 4, 1);
descriptor = arm_ldq_ptw(cs, descaddr, !nstable);
if (!(descriptor & 1) ||
(!(descriptor & 2) && (level == 3))) {
goto do_fault;
}
descaddr = descriptor & 0xfffffff000ULL;
if ((descriptor & 2) && (level < 3)) {
tableattrs |= extract64(descriptor, 59, 5);
level++;
continue;
}
page_size = (1ULL << ((granule_sz * (4 - level)) + 3));
descaddr |= (address & (page_size - 1));
attrs = extract64(descriptor, 2, 10)
| (extract64(descriptor, 52, 12) << 10);
attrs |= extract32(tableattrs, 0, 2) << 11;
attrs |= extract32(tableattrs, 3, 1) << 5;
if (extract32(tableattrs, 2, 1)) {
attrs &= ~(1 << 4);
}
attrs |= nstable << 3;
break;
}
fault_type = access_fault;
if ((attrs & (1 << 8)) == 0) {
goto do_fault;
}
ap = extract32(attrs, 4, 2);
ns = extract32(attrs, 3, 1);
xn = extract32(attrs, 12, 1);
pxn = extract32(attrs, 11, 1);
*prot = get_S1prot(env, mmu_idx, va_size == 64, ap, ns, xn, pxn);
fault_type = permission_fault;
if (!(*prot & (1 << access_type))) {
goto do_fault;
}
if (ns) {
txattrs->secure = false;
}
*phys_ptr = descaddr;
*page_size_ptr = page_size;
return 0;
do_fault:
return (1 << 9) | (fault_type << 2) | level;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(CPUARMState *VAR_0, target_ulong VAR_1,
int VAR_2, ARMMMUIdx VAR_3,
hwaddr *VAR_4, MemTxAttrs *VAR_5, int *VAR_6,
target_ulong *VAR_7)
{
CPUState *cs = CPU(arm_env_get_cpu(VAR_0));
MMUFaultType fault_type = translation_fault;
uint32_t level = 1;
uint32_t epd;
int32_t tsz;
uint32_t tg;
uint64_t ttbr;
int VAR_8;
hwaddr descaddr, descmask;
uint32_t tableattrs;
target_ulong page_size;
uint32_t attrs;
int32_t granule_sz = 9;
int32_t va_size = 32;
int32_t tbi = 0;
TCR *tcr = regime_tcr(VAR_0, VAR_3);
int VAR_9, VAR_10, VAR_11, VAR_12;
if (arm_el_is_aa64(VAR_0, regime_el(VAR_0, VAR_3))) {
va_size = 64;
if (extract64(VAR_1, 55, 1))
tbi = extract64(tcr->raw_tcr, 38, 1);
else
tbi = extract64(tcr->raw_tcr, 37, 1);
tbi *= 8;
}
uint32_t t0sz = extract32(tcr->raw_tcr, 0, 6);
if (va_size == 64) {
t0sz = MIN(t0sz, 39);
t0sz = MAX(t0sz, 16);
}
uint32_t t1sz = extract32(tcr->raw_tcr, 16, 6);
if (va_size == 64) {
t1sz = MIN(t1sz, 39);
t1sz = MAX(t1sz, 16);
}
if (t0sz && !extract64(VAR_1, va_size - t0sz, t0sz - tbi)) {
VAR_8 = 0;
} else if (t1sz && !extract64(~VAR_1, va_size - t1sz, t1sz - tbi)) {
VAR_8 = 1;
} else if (!t0sz) {
VAR_8 = 0;
} else if (!t1sz) {
VAR_8 = 1;
} else {
fault_type = translation_fault;
goto do_fault;
}
if (VAR_8 == 0) {
ttbr = regime_ttbr(VAR_0, VAR_3, 0);
epd = extract32(tcr->raw_tcr, 7, 1);
tsz = t0sz;
tg = extract32(tcr->raw_tcr, 14, 2);
if (tg == 1) {
granule_sz = 13;
}
if (tg == 2) {
granule_sz = 11;
}
} else {
ttbr = regime_ttbr(VAR_0, VAR_3, 1);
epd = extract32(tcr->raw_tcr, 23, 1);
tsz = t1sz;
tg = extract32(tcr->raw_tcr, 30, 2);
if (tg == 3) {
granule_sz = 13;
}
if (tg == 1) {
granule_sz = 11;
}
}
if (epd) {
goto do_fault;
}
level = 4 - (va_size - tsz - 4) / granule_sz;
if (tsz) {
VAR_1 &= (1ULL << (va_size - tsz)) - 1;
}
descmask = (1ULL << (granule_sz + 3)) - 1;
descaddr = extract64(ttbr, 0, 48);
descaddr &= ~((1ULL << (va_size - tsz - (granule_sz * (4 - level)))) - 1);
tableattrs = regime_is_secure(VAR_0, VAR_3) ? 0 : (1 << 4);
for (;;) {
uint64_t descriptor;
bool nstable;
descaddr |= (VAR_1 >> (granule_sz * (4 - level))) & descmask;
descaddr &= ~7ULL;
nstable = extract32(tableattrs, 4, 1);
descriptor = arm_ldq_ptw(cs, descaddr, !nstable);
if (!(descriptor & 1) ||
(!(descriptor & 2) && (level == 3))) {
goto do_fault;
}
descaddr = descriptor & 0xfffffff000ULL;
if ((descriptor & 2) && (level < 3)) {
tableattrs |= extract64(descriptor, 59, 5);
level++;
continue;
}
page_size = (1ULL << ((granule_sz * (4 - level)) + 3));
descaddr |= (VAR_1 & (page_size - 1));
attrs = extract64(descriptor, 2, 10)
| (extract64(descriptor, 52, 12) << 10);
attrs |= extract32(tableattrs, 0, 2) << 11;
attrs |= extract32(tableattrs, 3, 1) << 5;
if (extract32(tableattrs, 2, 1)) {
attrs &= ~(1 << 4);
}
attrs |= nstable << 3;
break;
}
fault_type = access_fault;
if ((attrs & (1 << 8)) == 0) {
goto do_fault;
}
VAR_9 = extract32(attrs, 4, 2);
VAR_10 = extract32(attrs, 3, 1);
VAR_11 = extract32(attrs, 12, 1);
VAR_12 = extract32(attrs, 11, 1);
*VAR_6 = get_S1prot(VAR_0, VAR_3, va_size == 64, VAR_9, VAR_10, VAR_11, VAR_12);
fault_type = permission_fault;
if (!(*VAR_6 & (1 << VAR_2))) {
goto do_fault;
}
if (VAR_10) {
VAR_5->secure = false;
}
*VAR_4 = descaddr;
*VAR_7 = page_size;
return 0;
do_fault:
return (1 << 9) | (fault_type << 2) | level;
}
| [
"static int FUNC_0(CPUARMState *VAR_0, target_ulong VAR_1,\nint VAR_2, ARMMMUIdx VAR_3,\nhwaddr *VAR_4, MemTxAttrs *VAR_5, int *VAR_6,\ntarget_ulong *VAR_7)\n{",
"CPUState *cs = CPU(arm_env_get_cpu(VAR_0));",
"MMUFaultType fault_type = translation_fault;",
"uint32_t level = 1;",
"uint32_t epd;",
"int32_t tsz;",
"uint32_t tg;",
"uint64_t ttbr;",
"int VAR_8;",
"hwaddr descaddr, descmask;",
"uint32_t tableattrs;",
"target_ulong page_size;",
"uint32_t attrs;",
"int32_t granule_sz = 9;",
"int32_t va_size = 32;",
"int32_t tbi = 0;",
"TCR *tcr = regime_tcr(VAR_0, VAR_3);",
"int VAR_9, VAR_10, VAR_11, VAR_12;",
"if (arm_el_is_aa64(VAR_0, regime_el(VAR_0, VAR_3))) {",
"va_size = 64;",
"if (extract64(VAR_1, 55, 1))\ntbi = extract64(tcr->raw_tcr, 38, 1);",
"else\ntbi = extract64(tcr->raw_tcr, 37, 1);",
"tbi *= 8;",
"}",
"uint32_t t0sz = extract32(tcr->raw_tcr, 0, 6);",
"if (va_size == 64) {",
"t0sz = MIN(t0sz, 39);",
"t0sz = MAX(t0sz, 16);",
"}",
"uint32_t t1sz = extract32(tcr->raw_tcr, 16, 6);",
"if (va_size == 64) {",
"t1sz = MIN(t1sz, 39);",
"t1sz = MAX(t1sz, 16);",
"}",
"if (t0sz && !extract64(VAR_1, va_size - t0sz, t0sz - tbi)) {",
"VAR_8 = 0;",
"} else if (t1sz && !extract64(~VAR_1, va_size - t1sz, t1sz - tbi)) {",
"VAR_8 = 1;",
"} else if (!t0sz) {",
"VAR_8 = 0;",
"} else if (!t1sz) {",
"VAR_8 = 1;",
"} else {",
"fault_type = translation_fault;",
"goto do_fault;",
"}",
"if (VAR_8 == 0) {",
"ttbr = regime_ttbr(VAR_0, VAR_3, 0);",
"epd = extract32(tcr->raw_tcr, 7, 1);",
"tsz = t0sz;",
"tg = extract32(tcr->raw_tcr, 14, 2);",
"if (tg == 1) {",
"granule_sz = 13;",
"}",
"if (tg == 2) {",
"granule_sz = 11;",
"}",
"} else {",
"ttbr = regime_ttbr(VAR_0, VAR_3, 1);",
"epd = extract32(tcr->raw_tcr, 23, 1);",
"tsz = t1sz;",
"tg = extract32(tcr->raw_tcr, 30, 2);",
"if (tg == 3) {",
"granule_sz = 13;",
"}",
"if (tg == 1) {",
"granule_sz = 11;",
"}",
"}",
"if (epd) {",
"goto do_fault;",
"}",
"level = 4 - (va_size - tsz - 4) / granule_sz;",
"if (tsz) {",
"VAR_1 &= (1ULL << (va_size - tsz)) - 1;",
"}",
"descmask = (1ULL << (granule_sz + 3)) - 1;",
"descaddr = extract64(ttbr, 0, 48);",
"descaddr &= ~((1ULL << (va_size - tsz - (granule_sz * (4 - level)))) - 1);",
"tableattrs = regime_is_secure(VAR_0, VAR_3) ? 0 : (1 << 4);",
"for (;;) {",
"uint64_t descriptor;",
"bool nstable;",
"descaddr |= (VAR_1 >> (granule_sz * (4 - level))) & descmask;",
"descaddr &= ~7ULL;",
"nstable = extract32(tableattrs, 4, 1);",
"descriptor = arm_ldq_ptw(cs, descaddr, !nstable);",
"if (!(descriptor & 1) ||\n(!(descriptor & 2) && (level == 3))) {",
"goto do_fault;",
"}",
"descaddr = descriptor & 0xfffffff000ULL;",
"if ((descriptor & 2) && (level < 3)) {",
"tableattrs |= extract64(descriptor, 59, 5);",
"level++;",
"continue;",
"}",
"page_size = (1ULL << ((granule_sz * (4 - level)) + 3));",
"descaddr |= (VAR_1 & (page_size - 1));",
"attrs = extract64(descriptor, 2, 10)\n| (extract64(descriptor, 52, 12) << 10);",
"attrs |= extract32(tableattrs, 0, 2) << 11;",
"attrs |= extract32(tableattrs, 3, 1) << 5;",
"if (extract32(tableattrs, 2, 1)) {",
"attrs &= ~(1 << 4);",
"}",
"attrs |= nstable << 3;",
"break;",
"}",
"fault_type = access_fault;",
"if ((attrs & (1 << 8)) == 0) {",
"goto do_fault;",
"}",
"VAR_9 = extract32(attrs, 4, 2);",
"VAR_10 = extract32(attrs, 3, 1);",
"VAR_11 = extract32(attrs, 12, 1);",
"VAR_12 = extract32(attrs, 11, 1);",
"*VAR_6 = get_S1prot(VAR_0, VAR_3, va_size == 64, VAR_9, VAR_10, VAR_11, VAR_12);",
"fault_type = permission_fault;",
"if (!(*VAR_6 & (1 << VAR_2))) {",
"goto do_fault;",
"}",
"if (VAR_10) {",
"VAR_5->secure = false;",
"}",
"*VAR_4 = descaddr;",
"*VAR_7 = page_size;",
"return 0;",
"do_fault:\nreturn (1 << 9) | (fault_type << 2) | level;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
63
],
[
65
],
[
67,
69
],
[
71,
73
],
[
75
],
[
77
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
121
],
[
123
],
[
127
],
[
129
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
161
],
[
163
],
[
165
],
[
167
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
221
],
[
225
],
[
227
],
[
253
],
[
265
],
[
267
],
[
269
],
[
273
],
[
279
],
[
281
],
[
295
],
[
297
],
[
299
],
[
301
],
[
305
],
[
307
],
[
309
],
[
311
],
[
313,
315
],
[
319
],
[
321
],
[
323
],
[
327
],
[
339
],
[
341
],
[
343
],
[
345
],
[
355
],
[
357
],
[
361,
363
],
[
365
],
[
367
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
393
],
[
395
],
[
399
],
[
401
],
[
405
],
[
407
],
[
409
],
[
411
],
[
415
],
[
419
],
[
421
],
[
423
],
[
425
],
[
429
],
[
439
],
[
441
],
[
443
],
[
445
],
[
447
],
[
451,
455
],
[
457
]
] |
25,036 | static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,
const char *name, size_t size, Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
const QObject *qobj = qmp_input_get_object(qiv, name);
if (!qobj || qobject_type(qobj) != QTYPE_QDICT) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"QDict");
return;
}
qmp_input_push(qiv, qobj, errp);
if (error_is_set(errp)) {
return;
}
if (obj) {
*obj = g_malloc0(size);
}
}
| true | qemu | 8b714d3747e6870db85dd9382adb8ee371633092 | static void qmp_input_start_struct(Visitor *v, void **obj, const char *kind,
const char *name, size_t size, Error **errp)
{
QmpInputVisitor *qiv = to_qiv(v);
const QObject *qobj = qmp_input_get_object(qiv, name);
if (!qobj || qobject_type(qobj) != QTYPE_QDICT) {
error_set(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"QDict");
return;
}
qmp_input_push(qiv, qobj, errp);
if (error_is_set(errp)) {
return;
}
if (obj) {
*obj = g_malloc0(size);
}
}
| {
"code": [
" qmp_input_push(qiv, qobj, errp);",
" if (error_is_set(errp)) {"
],
"line_no": [
25,
27
]
} | static void FUNC_0(Visitor *VAR_0, void **VAR_1, const char *VAR_2,
const char *VAR_3, size_t VAR_4, Error **VAR_5)
{
QmpInputVisitor *qiv = to_qiv(VAR_0);
const QObject *VAR_6 = qmp_input_get_object(qiv, VAR_3);
if (!VAR_6 || qobject_type(VAR_6) != QTYPE_QDICT) {
error_set(VAR_5, QERR_INVALID_PARAMETER_TYPE, VAR_3 ? VAR_3 : "null",
"QDict");
return;
}
qmp_input_push(qiv, VAR_6, VAR_5);
if (error_is_set(VAR_5)) {
return;
}
if (VAR_1) {
*VAR_1 = g_malloc0(VAR_4);
}
}
| [
"static void FUNC_0(Visitor *VAR_0, void **VAR_1, const char *VAR_2,\nconst char *VAR_3, size_t VAR_4, Error **VAR_5)\n{",
"QmpInputVisitor *qiv = to_qiv(VAR_0);",
"const QObject *VAR_6 = qmp_input_get_object(qiv, VAR_3);",
"if (!VAR_6 || qobject_type(VAR_6) != QTYPE_QDICT) {",
"error_set(VAR_5, QERR_INVALID_PARAMETER_TYPE, VAR_3 ? VAR_3 : \"null\",\n\"QDict\");",
"return;",
"}",
"qmp_input_push(qiv, VAR_6, VAR_5);",
"if (error_is_set(VAR_5)) {",
"return;",
"}",
"if (VAR_1) {",
"*VAR_1 = g_malloc0(VAR_4);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
]
] |
25,037 | static int join_request_frame(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
JoinContext *s = ctx->priv;
AVFilterBufferRef *buf;
JoinBufferPriv *priv;
int linesize = INT_MAX;
int perms = ~0;
int nb_samples;
int i, j, ret;
/* get a frame on each input */
for (i = 0; i < ctx->nb_inputs; i++) {
AVFilterLink *inlink = ctx->inputs[i];
if (!s->input_frames[i] &&
(ret = ff_request_frame(inlink)) < 0)
return ret;
/* request the same number of samples on all inputs */
if (i == 0) {
nb_samples = s->input_frames[0]->audio->nb_samples;
for (j = 1; !i && j < ctx->nb_inputs; j++)
ctx->inputs[j]->request_samples = nb_samples;
}
}
for (i = 0; i < s->nb_channels; i++) {
ChannelMap *ch = &s->channels[i];
AVFilterBufferRef *cur_buf = s->input_frames[ch->input];
s->data[i] = cur_buf->extended_data[ch->in_channel_idx];
linesize = FFMIN(linesize, cur_buf->linesize[0]);
perms &= cur_buf->perms;
}
buf = avfilter_get_audio_buffer_ref_from_arrays(s->data, linesize, perms,
nb_samples, outlink->format,
outlink->channel_layout);
if (!buf)
return AVERROR(ENOMEM);
buf->buf->free = join_free_buffer;
buf->pts = s->input_frames[0]->pts;
if (!(priv = av_mallocz(sizeof(*priv))))
goto fail;
if (!(priv->in_buffers = av_mallocz(sizeof(*priv->in_buffers) * ctx->nb_inputs)))
goto fail;
for (i = 0; i < ctx->nb_inputs; i++)
priv->in_buffers[i] = s->input_frames[i];
priv->nb_in_buffers = ctx->nb_inputs;
buf->buf->priv = priv;
ff_filter_samples(outlink, buf);
memset(s->input_frames, 0, sizeof(*s->input_frames) * ctx->nb_inputs);
return 0;
fail:
avfilter_unref_buffer(buf);
if (priv)
av_freep(&priv->in_buffers);
av_freep(&priv);
return AVERROR(ENOMEM);
}
| true | FFmpeg | fd2784c3b5e5ea13dd308b1eeeef0dd3c22a3d4a | static int join_request_frame(AVFilterLink *outlink)
{
AVFilterContext *ctx = outlink->src;
JoinContext *s = ctx->priv;
AVFilterBufferRef *buf;
JoinBufferPriv *priv;
int linesize = INT_MAX;
int perms = ~0;
int nb_samples;
int i, j, ret;
for (i = 0; i < ctx->nb_inputs; i++) {
AVFilterLink *inlink = ctx->inputs[i];
if (!s->input_frames[i] &&
(ret = ff_request_frame(inlink)) < 0)
return ret;
if (i == 0) {
nb_samples = s->input_frames[0]->audio->nb_samples;
for (j = 1; !i && j < ctx->nb_inputs; j++)
ctx->inputs[j]->request_samples = nb_samples;
}
}
for (i = 0; i < s->nb_channels; i++) {
ChannelMap *ch = &s->channels[i];
AVFilterBufferRef *cur_buf = s->input_frames[ch->input];
s->data[i] = cur_buf->extended_data[ch->in_channel_idx];
linesize = FFMIN(linesize, cur_buf->linesize[0]);
perms &= cur_buf->perms;
}
buf = avfilter_get_audio_buffer_ref_from_arrays(s->data, linesize, perms,
nb_samples, outlink->format,
outlink->channel_layout);
if (!buf)
return AVERROR(ENOMEM);
buf->buf->free = join_free_buffer;
buf->pts = s->input_frames[0]->pts;
if (!(priv = av_mallocz(sizeof(*priv))))
goto fail;
if (!(priv->in_buffers = av_mallocz(sizeof(*priv->in_buffers) * ctx->nb_inputs)))
goto fail;
for (i = 0; i < ctx->nb_inputs; i++)
priv->in_buffers[i] = s->input_frames[i];
priv->nb_in_buffers = ctx->nb_inputs;
buf->buf->priv = priv;
ff_filter_samples(outlink, buf);
memset(s->input_frames, 0, sizeof(*s->input_frames) * ctx->nb_inputs);
return 0;
fail:
avfilter_unref_buffer(buf);
if (priv)
av_freep(&priv->in_buffers);
av_freep(&priv);
return AVERROR(ENOMEM);
}
| {
"code": [
" int nb_samples;"
],
"line_no": [
17
]
} | static int FUNC_0(AVFilterLink *VAR_0)
{
AVFilterContext *ctx = VAR_0->src;
JoinContext *s = ctx->priv;
AVFilterBufferRef *buf;
JoinBufferPriv *priv;
int VAR_1 = INT_MAX;
int VAR_2 = ~0;
int VAR_3;
int VAR_4, VAR_5, VAR_6;
for (VAR_4 = 0; VAR_4 < ctx->nb_inputs; VAR_4++) {
AVFilterLink *inlink = ctx->inputs[VAR_4];
if (!s->input_frames[VAR_4] &&
(VAR_6 = ff_request_frame(inlink)) < 0)
return VAR_6;
if (VAR_4 == 0) {
VAR_3 = s->input_frames[0]->audio->VAR_3;
for (VAR_5 = 1; !VAR_4 && VAR_5 < ctx->nb_inputs; VAR_5++)
ctx->inputs[VAR_5]->request_samples = VAR_3;
}
}
for (VAR_4 = 0; VAR_4 < s->nb_channels; VAR_4++) {
ChannelMap *ch = &s->channels[VAR_4];
AVFilterBufferRef *cur_buf = s->input_frames[ch->input];
s->data[VAR_4] = cur_buf->extended_data[ch->in_channel_idx];
VAR_1 = FFMIN(VAR_1, cur_buf->VAR_1[0]);
VAR_2 &= cur_buf->VAR_2;
}
buf = avfilter_get_audio_buffer_ref_from_arrays(s->data, VAR_1, VAR_2,
VAR_3, VAR_0->format,
VAR_0->channel_layout);
if (!buf)
return AVERROR(ENOMEM);
buf->buf->free = join_free_buffer;
buf->pts = s->input_frames[0]->pts;
if (!(priv = av_mallocz(sizeof(*priv))))
goto fail;
if (!(priv->in_buffers = av_mallocz(sizeof(*priv->in_buffers) * ctx->nb_inputs)))
goto fail;
for (VAR_4 = 0; VAR_4 < ctx->nb_inputs; VAR_4++)
priv->in_buffers[VAR_4] = s->input_frames[VAR_4];
priv->nb_in_buffers = ctx->nb_inputs;
buf->buf->priv = priv;
ff_filter_samples(VAR_0, buf);
memset(s->input_frames, 0, sizeof(*s->input_frames) * ctx->nb_inputs);
return 0;
fail:
avfilter_unref_buffer(buf);
if (priv)
av_freep(&priv->in_buffers);
av_freep(&priv);
return AVERROR(ENOMEM);
}
| [
"static int FUNC_0(AVFilterLink *VAR_0)\n{",
"AVFilterContext *ctx = VAR_0->src;",
"JoinContext *s = ctx->priv;",
"AVFilterBufferRef *buf;",
"JoinBufferPriv *priv;",
"int VAR_1 = INT_MAX;",
"int VAR_2 = ~0;",
"int VAR_3;",
"int VAR_4, VAR_5, VAR_6;",
"for (VAR_4 = 0; VAR_4 < ctx->nb_inputs; VAR_4++) {",
"AVFilterLink *inlink = ctx->inputs[VAR_4];",
"if (!s->input_frames[VAR_4] &&\n(VAR_6 = ff_request_frame(inlink)) < 0)\nreturn VAR_6;",
"if (VAR_4 == 0) {",
"VAR_3 = s->input_frames[0]->audio->VAR_3;",
"for (VAR_5 = 1; !VAR_4 && VAR_5 < ctx->nb_inputs; VAR_5++)",
"ctx->inputs[VAR_5]->request_samples = VAR_3;",
"}",
"}",
"for (VAR_4 = 0; VAR_4 < s->nb_channels; VAR_4++) {",
"ChannelMap *ch = &s->channels[VAR_4];",
"AVFilterBufferRef *cur_buf = s->input_frames[ch->input];",
"s->data[VAR_4] = cur_buf->extended_data[ch->in_channel_idx];",
"VAR_1 = FFMIN(VAR_1, cur_buf->VAR_1[0]);",
"VAR_2 &= cur_buf->VAR_2;",
"}",
"buf = avfilter_get_audio_buffer_ref_from_arrays(s->data, VAR_1, VAR_2,\nVAR_3, VAR_0->format,\nVAR_0->channel_layout);",
"if (!buf)\nreturn AVERROR(ENOMEM);",
"buf->buf->free = join_free_buffer;",
"buf->pts = s->input_frames[0]->pts;",
"if (!(priv = av_mallocz(sizeof(*priv))))\ngoto fail;",
"if (!(priv->in_buffers = av_mallocz(sizeof(*priv->in_buffers) * ctx->nb_inputs)))\ngoto fail;",
"for (VAR_4 = 0; VAR_4 < ctx->nb_inputs; VAR_4++)",
"priv->in_buffers[VAR_4] = s->input_frames[VAR_4];",
"priv->nb_in_buffers = ctx->nb_inputs;",
"buf->buf->priv = priv;",
"ff_filter_samples(VAR_0, buf);",
"memset(s->input_frames, 0, sizeof(*s->input_frames) * ctx->nb_inputs);",
"return 0;",
"fail:\navfilter_unref_buffer(buf);",
"if (priv)\nav_freep(&priv->in_buffers);",
"av_freep(&priv);",
"return AVERROR(ENOMEM);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
25
],
[
27
],
[
31,
33,
35
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75,
77,
79
],
[
81,
83
],
[
87
],
[
89
],
[
93,
95
],
[
97,
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
117
],
[
121
],
[
125,
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
]
] |
25,038 | static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
//FIXME Optimize (just quickly writen not opti..)
int i;
for (i=0; i<dstW; i++)
{
int val=1<<18;
int j;
for (j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
dest[i]= av_clip_uint8(val>>19);
}
if (uDest)
for (i=0; i<chrDstW; i++)
{
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++)
{
u += chrSrc[j][i] * chrFilter[j];
v += chrSrc[j][i + 2048] * chrFilter[j];
}
uDest[i]= av_clip_uint8(u>>19);
vDest[i]= av_clip_uint8(v>>19);
}
}
| true | FFmpeg | 8b2fce0d3f5a56c40c28899c9237210ca8f9cf75 | static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
{
int i;
for (i=0; i<dstW; i++)
{
int val=1<<18;
int j;
for (j=0; j<lumFilterSize; j++)
val += lumSrc[j][i] * lumFilter[j];
dest[i]= av_clip_uint8(val>>19);
}
if (uDest)
for (i=0; i<chrDstW; i++)
{
int u=1<<18;
int v=1<<18;
int j;
for (j=0; j<chrFilterSize; j++)
{
u += chrSrc[j][i] * chrFilter[j];
v += chrSrc[j][i + 2048] * chrFilter[j];
}
uDest[i]= av_clip_uint8(u>>19);
vDest[i]= av_clip_uint8(v>>19);
}
}
| {
"code": [
" v += chrSrc[j][i + 2048] * chrFilter[j];",
" v += chrSrc[j][i + 2048] * chrFilter[j];",
" v += chrSrc[j][i + 2048] * chrFilter[j];"
],
"line_no": [
51,
51,
51
]
} | static inline void FUNC_0(int16_t *VAR_0, int16_t **VAR_1, int VAR_2,
int16_t *VAR_3, int16_t **VAR_4, int VAR_5,
uint8_t *VAR_6, uint8_t *VAR_7, uint8_t *VAR_8, int VAR_9, int VAR_10)
{
int VAR_11;
for (VAR_11=0; VAR_11<VAR_9; VAR_11++)
{
int VAR_12=1<<18;
int VAR_16;
for (VAR_16=0; VAR_16<VAR_2; VAR_16++)
VAR_12 += VAR_1[VAR_16][VAR_11] * VAR_0[VAR_16];
VAR_6[VAR_11]= av_clip_uint8(VAR_12>>19);
}
if (VAR_7)
for (VAR_11=0; VAR_11<VAR_10; VAR_11++)
{
int VAR_14=1<<18;
int VAR_15=1<<18;
int VAR_16;
for (VAR_16=0; VAR_16<VAR_5; VAR_16++)
{
VAR_14 += VAR_4[VAR_16][VAR_11] * VAR_3[VAR_16];
VAR_15 += VAR_4[VAR_16][VAR_11 + 2048] * VAR_3[VAR_16];
}
VAR_7[VAR_11]= av_clip_uint8(VAR_14>>19);
VAR_8[VAR_11]= av_clip_uint8(VAR_15>>19);
}
}
| [
"static inline void FUNC_0(int16_t *VAR_0, int16_t **VAR_1, int VAR_2,\nint16_t *VAR_3, int16_t **VAR_4, int VAR_5,\nuint8_t *VAR_6, uint8_t *VAR_7, uint8_t *VAR_8, int VAR_9, int VAR_10)\n{",
"int VAR_11;",
"for (VAR_11=0; VAR_11<VAR_9; VAR_11++)",
"{",
"int VAR_12=1<<18;",
"int VAR_16;",
"for (VAR_16=0; VAR_16<VAR_2; VAR_16++)",
"VAR_12 += VAR_1[VAR_16][VAR_11] * VAR_0[VAR_16];",
"VAR_6[VAR_11]= av_clip_uint8(VAR_12>>19);",
"}",
"if (VAR_7)\nfor (VAR_11=0; VAR_11<VAR_10; VAR_11++)",
"{",
"int VAR_14=1<<18;",
"int VAR_15=1<<18;",
"int VAR_16;",
"for (VAR_16=0; VAR_16<VAR_5; VAR_16++)",
"{",
"VAR_14 += VAR_4[VAR_16][VAR_11] * VAR_3[VAR_16];",
"VAR_15 += VAR_4[VAR_16][VAR_11 + 2048] * VAR_3[VAR_16];",
"}",
"VAR_7[VAR_11]= av_clip_uint8(VAR_14>>19);",
"VAR_8[VAR_11]= av_clip_uint8(VAR_15>>19);",
"}",
"}"
] | [
0,
0,
0,
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
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
33,
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
]
] |
25,039 | static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
target_ulong id, start, r3;
PowerPCCPU *cpu;
if (nargs != 3 || nret != 1) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
id = rtas_ld(args, 0);
start = rtas_ld(args, 1);
r3 = rtas_ld(args, 2);
cpu = spapr_find_cpu(id);
if (cpu != NULL) {
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
if (!cs->halted) {
rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
return;
}
/* This will make sure qemu state is up to date with kvm, and
* mark it dirty so our changes get flushed back before the
* new cpu enters */
kvm_cpu_synchronize_state(cs);
env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);
/* Enable Power-saving mode Exit Cause exceptions for the new CPU */
env->spr[SPR_LPCR] |= pcc->lpcr_pm;
env->nip = start;
env->gpr[3] = r3;
cs->halted = 0;
spapr_cpu_set_endianness(cpu);
spapr_cpu_update_tb_offset(cpu);
qemu_cpu_kick(cs);
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
return;
}
/* Didn't find a matching cpu */
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
} | true | qemu | 9a94ee5bb15793ef69692998ef57794a33074134 | static void rtas_start_cpu(PowerPCCPU *cpu_, sPAPRMachineState *spapr,
uint32_t token, uint32_t nargs,
target_ulong args,
uint32_t nret, target_ulong rets)
{
target_ulong id, start, r3;
PowerPCCPU *cpu;
if (nargs != 3 || nret != 1) {
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
return;
}
id = rtas_ld(args, 0);
start = rtas_ld(args, 1);
r3 = rtas_ld(args, 2);
cpu = spapr_find_cpu(id);
if (cpu != NULL) {
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
if (!cs->halted) {
rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
return;
}
kvm_cpu_synchronize_state(cs);
env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);
env->spr[SPR_LPCR] |= pcc->lpcr_pm;
env->nip = start;
env->gpr[3] = r3;
cs->halted = 0;
spapr_cpu_set_endianness(cpu);
spapr_cpu_update_tb_offset(cpu);
qemu_cpu_kick(cs);
rtas_st(rets, 0, RTAS_OUT_SUCCESS);
return;
}
rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(PowerPCCPU *VAR_0, sPAPRMachineState *VAR_1,
uint32_t VAR_2, uint32_t VAR_3,
target_ulong VAR_4,
uint32_t VAR_5, target_ulong VAR_6)
{
target_ulong id, start, r3;
PowerPCCPU *cpu;
if (VAR_3 != 3 || VAR_5 != 1) {
rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR);
return;
}
id = rtas_ld(VAR_4, 0);
start = rtas_ld(VAR_4, 1);
r3 = rtas_ld(VAR_4, 2);
cpu = spapr_find_cpu(id);
if (cpu != NULL) {
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
if (!cs->halted) {
rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR);
return;
}
kvm_cpu_synchronize_state(cs);
env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);
env->spr[SPR_LPCR] |= pcc->lpcr_pm;
env->nip = start;
env->gpr[3] = r3;
cs->halted = 0;
spapr_cpu_set_endianness(cpu);
spapr_cpu_update_tb_offset(cpu);
qemu_cpu_kick(cs);
rtas_st(VAR_6, 0, RTAS_OUT_SUCCESS);
return;
}
rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR);
} | [
"static void FUNC_0(PowerPCCPU *VAR_0, sPAPRMachineState *VAR_1,\nuint32_t VAR_2, uint32_t VAR_3,\ntarget_ulong VAR_4,\nuint32_t VAR_5, target_ulong VAR_6)\n{",
"target_ulong id, start, r3;",
"PowerPCCPU *cpu;",
"if (VAR_3 != 3 || VAR_5 != 1) {",
"rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR);",
"return;",
"}",
"id = rtas_ld(VAR_4, 0);",
"start = rtas_ld(VAR_4, 1);",
"r3 = rtas_ld(VAR_4, 2);",
"cpu = spapr_find_cpu(id);",
"if (cpu != NULL) {",
"CPUState *cs = CPU(cpu);",
"CPUPPCState *env = &cpu->env;",
"if (!cs->halted) {",
"rtas_st(VAR_6, 0, RTAS_OUT_HW_ERROR);",
"return;",
"}",
"kvm_cpu_synchronize_state(cs);",
"env->msr = (1ULL << MSR_SF) | (1ULL << MSR_ME);",
"env->spr[SPR_LPCR] |= pcc->lpcr_pm;",
"env->nip = start;",
"env->gpr[3] = r3;",
"cs->halted = 0;",
"spapr_cpu_set_endianness(cpu);",
"spapr_cpu_update_tb_offset(cpu);",
"qemu_cpu_kick(cs);",
"rtas_st(VAR_6, 0, RTAS_OUT_SUCCESS);",
"return;",
"}",
"rtas_st(VAR_6, 0, RTAS_OUT_PARAM_ERROR);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
],
[
41
],
[
46
],
[
48
],
[
50
],
[
52
],
[
62
],
[
66
],
[
72
],
[
76
],
[
78
],
[
80
],
[
82
],
[
84
],
[
88
],
[
92
],
[
94
],
[
96
],
[
102
],
[
104
]
] |
25,040 | static void check_decode_result(int *got_output, int ret)
{
if (*got_output || ret<0)
decode_error_stat[ret<0] ++;
if (ret < 0 && exit_on_error)
exit_program(1);
}
| true | FFmpeg | b69b43e2c471c4febbffaf313875396256b6a51e | static void check_decode_result(int *got_output, int ret)
{
if (*got_output || ret<0)
decode_error_stat[ret<0] ++;
if (ret < 0 && exit_on_error)
exit_program(1);
}
| {
"code": [
"static void check_decode_result(int *got_output, int ret)"
],
"line_no": [
1
]
} | static void FUNC_0(int *VAR_0, int VAR_1)
{
if (*VAR_0 || VAR_1<0)
decode_error_stat[VAR_1<0] ++;
if (VAR_1 < 0 && exit_on_error)
exit_program(1);
}
| [
"static void FUNC_0(int *VAR_0, int VAR_1)\n{",
"if (*VAR_0 || VAR_1<0)\ndecode_error_stat[VAR_1<0] ++;",
"if (VAR_1 < 0 && exit_on_error)\nexit_program(1);",
"}"
] | [
1,
0,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
11,
13
],
[
15
]
] |
25,041 | int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
const VMStateDescription *vmsd,
void *opaque, int alias_id,
int required_for_version,
Error **errp)
{
SaveStateEntry *se;
/* If this triggers, alias support can be dropped for the vmsd. */
assert(alias_id == -1 || required_for_version >= vmsd->minimum_version_id);
se = g_new0(SaveStateEntry, 1);
se->version_id = vmsd->version_id;
se->section_id = savevm_state.global_section_id++;
se->opaque = opaque;
se->vmsd = vmsd;
se->alias_id = alias_id;
if (dev) {
char *id = qdev_get_dev_path(dev);
if (id) {
if (snprintf(se->idstr, sizeof(se->idstr), "%s/", id) >=
sizeof(se->idstr)) {
error_setg(errp, "Path too long for VMState (%s)", id);
g_free(se);
return -1;
}
se->compat = g_new0(CompatEntry, 1);
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name);
se->compat->instance_id = instance_id == -1 ?
calculate_compat_instance_id(vmsd->name) : instance_id;
instance_id = -1;
}
}
pstrcat(se->idstr, sizeof(se->idstr), vmsd->name);
if (instance_id == -1) {
se->instance_id = calculate_new_instance_id(se->idstr);
} else {
se->instance_id = instance_id;
}
assert(!se->compat || se->instance_id == 0);
savevm_state_handler_insert(se);
return 0;
} | true | qemu | 128e4e108949b35dbe351fe122a3e34b834e185a | int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
const VMStateDescription *vmsd,
void *opaque, int alias_id,
int required_for_version,
Error **errp)
{
SaveStateEntry *se;
assert(alias_id == -1 || required_for_version >= vmsd->minimum_version_id);
se = g_new0(SaveStateEntry, 1);
se->version_id = vmsd->version_id;
se->section_id = savevm_state.global_section_id++;
se->opaque = opaque;
se->vmsd = vmsd;
se->alias_id = alias_id;
if (dev) {
char *id = qdev_get_dev_path(dev);
if (id) {
if (snprintf(se->idstr, sizeof(se->idstr), "%s/", id) >=
sizeof(se->idstr)) {
error_setg(errp, "Path too long for VMState (%s)", id);
g_free(se);
return -1;
}
se->compat = g_new0(CompatEntry, 1);
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), vmsd->name);
se->compat->instance_id = instance_id == -1 ?
calculate_compat_instance_id(vmsd->name) : instance_id;
instance_id = -1;
}
}
pstrcat(se->idstr, sizeof(se->idstr), vmsd->name);
if (instance_id == -1) {
se->instance_id = calculate_new_instance_id(se->idstr);
} else {
se->instance_id = instance_id;
}
assert(!se->compat || se->instance_id == 0);
savevm_state_handler_insert(se);
return 0;
} | {
"code": [],
"line_no": []
} | int FUNC_0(DeviceState *VAR_0, int VAR_1,
const VMStateDescription *VAR_2,
void *VAR_3, int VAR_4,
int VAR_5,
Error **VAR_6)
{
SaveStateEntry *se;
assert(VAR_4 == -1 || VAR_5 >= VAR_2->minimum_version_id);
se = g_new0(SaveStateEntry, 1);
se->version_id = VAR_2->version_id;
se->section_id = savevm_state.global_section_id++;
se->VAR_3 = VAR_3;
se->VAR_2 = VAR_2;
se->VAR_4 = VAR_4;
if (VAR_0) {
char *VAR_7 = qdev_get_dev_path(VAR_0);
if (VAR_7) {
if (snprintf(se->idstr, sizeof(se->idstr), "%s/", VAR_7) >=
sizeof(se->idstr)) {
error_setg(VAR_6, "Path too long for VMState (%s)", VAR_7);
g_free(se);
return -1;
}
se->compat = g_new0(CompatEntry, 1);
pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), VAR_2->name);
se->compat->VAR_1 = VAR_1 == -1 ?
calculate_compat_instance_id(VAR_2->name) : VAR_1;
VAR_1 = -1;
}
}
pstrcat(se->idstr, sizeof(se->idstr), VAR_2->name);
if (VAR_1 == -1) {
se->VAR_1 = calculate_new_instance_id(se->idstr);
} else {
se->VAR_1 = VAR_1;
}
assert(!se->compat || se->VAR_1 == 0);
savevm_state_handler_insert(se);
return 0;
} | [
"int FUNC_0(DeviceState *VAR_0, int VAR_1,\nconst VMStateDescription *VAR_2,\nvoid *VAR_3, int VAR_4,\nint VAR_5,\nError **VAR_6)\n{",
"SaveStateEntry *se;",
"assert(VAR_4 == -1 || VAR_5 >= VAR_2->minimum_version_id);",
"se = g_new0(SaveStateEntry, 1);",
"se->version_id = VAR_2->version_id;",
"se->section_id = savevm_state.global_section_id++;",
"se->VAR_3 = VAR_3;",
"se->VAR_2 = VAR_2;",
"se->VAR_4 = VAR_4;",
"if (VAR_0) {",
"char *VAR_7 = qdev_get_dev_path(VAR_0);",
"if (VAR_7) {",
"if (snprintf(se->idstr, sizeof(se->idstr), \"%s/\", VAR_7) >=\nsizeof(se->idstr)) {",
"error_setg(VAR_6, \"Path too long for VMState (%s)\", VAR_7);",
"g_free(se);",
"return -1;",
"}",
"se->compat = g_new0(CompatEntry, 1);",
"pstrcpy(se->compat->idstr, sizeof(se->compat->idstr), VAR_2->name);",
"se->compat->VAR_1 = VAR_1 == -1 ?\ncalculate_compat_instance_id(VAR_2->name) : VAR_1;",
"VAR_1 = -1;",
"}",
"}",
"pstrcat(se->idstr, sizeof(se->idstr), VAR_2->name);",
"if (VAR_1 == -1) {",
"se->VAR_1 = calculate_new_instance_id(se->idstr);",
"} else {",
"se->VAR_1 = VAR_1;",
"}",
"assert(!se->compat || se->VAR_1 == 0);",
"savevm_state_handler_insert(se);",
"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
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
50
],
[
54
],
[
56
],
[
61
],
[
63
],
[
65,
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
]
] |
25,042 | static void test_qemu_strtoll_max(void)
{
const char *str = g_strdup_printf("%lld", LLONG_MAX);
char f = 'X';
const char *endptr = &f;
int64_t res = 999;
int err;
err = qemu_strtoll(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, LLONG_MAX);
g_assert(endptr == str + strlen(str));
}
| true | qemu | d6f723b513a0c3c4e58343b7c52a2f9850861fa0 | static void test_qemu_strtoll_max(void)
{
const char *str = g_strdup_printf("%lld", LLONG_MAX);
char f = 'X';
const char *endptr = &f;
int64_t res = 999;
int err;
err = qemu_strtoll(str, &endptr, 0, &res);
g_assert_cmpint(err, ==, 0);
g_assert_cmpint(res, ==, LLONG_MAX);
g_assert(endptr == str + strlen(str));
}
| {
"code": [
" const char *str = g_strdup_printf(\"%lld\", LLONG_MAX);",
" const char *str = g_strdup_printf(\"%lld\", LLONG_MAX);"
],
"line_no": [
5,
5
]
} | static void FUNC_0(void)
{
const char *VAR_0 = g_strdup_printf("%lld", LLONG_MAX);
char VAR_1 = 'X';
const char *VAR_2 = &VAR_1;
int64_t res = 999;
int VAR_3;
VAR_3 = qemu_strtoll(VAR_0, &VAR_2, 0, &res);
g_assert_cmpint(VAR_3, ==, 0);
g_assert_cmpint(res, ==, LLONG_MAX);
g_assert(VAR_2 == VAR_0 + strlen(VAR_0));
}
| [
"static void FUNC_0(void)\n{",
"const char *VAR_0 = g_strdup_printf(\"%lld\", LLONG_MAX);",
"char VAR_1 = 'X';",
"const char *VAR_2 = &VAR_1;",
"int64_t res = 999;",
"int VAR_3;",
"VAR_3 = qemu_strtoll(VAR_0, &VAR_2, 0, &res);",
"g_assert_cmpint(VAR_3, ==, 0);",
"g_assert_cmpint(res, ==, LLONG_MAX);",
"g_assert(VAR_2 == VAR_0 + strlen(VAR_0));",
"}"
] | [
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
]
] |
25,043 | static int mace_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int16_t **samples;
MACEContext *ctx = avctx->priv_data;
int i, j, k, l, ret;
int is_mace3 = (avctx->codec_id == AV_CODEC_ID_MACE3);
/* get output buffer */
frame->nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
samples = (int16_t **)frame->extended_data;
for(i = 0; i < avctx->channels; i++) {
int16_t *output = samples[i];
for (j=0; j < buf_size / (avctx->channels << is_mace3); j++)
for (k=0; k < (1 << is_mace3); k++) {
uint8_t pkt = buf[(i << is_mace3) +
(j*avctx->channels << is_mace3) + k];
uint8_t val[2][3] = {{pkt >> 5, (pkt >> 3) & 3, pkt & 7 },
{pkt & 7 , (pkt >> 3) & 3, pkt >> 5}};
for (l=0; l < 3; l++) {
if (is_mace3)
chomp3(&ctx->chd[i], output, val[1][l], l);
else
chomp6(&ctx->chd[i], output, val[0][l], l);
output += 1 << (1-is_mace3);
*got_frame_ptr = 1;
return buf_size; | true | FFmpeg | 2e59ffbb7964214e192a9f77c4445ff29c6510d7 | static int mace_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
int16_t **samples;
MACEContext *ctx = avctx->priv_data;
int i, j, k, l, ret;
int is_mace3 = (avctx->codec_id == AV_CODEC_ID_MACE3);
frame->nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
return ret;
samples = (int16_t **)frame->extended_data;
for(i = 0; i < avctx->channels; i++) {
int16_t *output = samples[i];
for (j=0; j < buf_size / (avctx->channels << is_mace3); j++)
for (k=0; k < (1 << is_mace3); k++) {
uint8_t pkt = buf[(i << is_mace3) +
(j*avctx->channels << is_mace3) + k];
uint8_t val[2][3] = {{pkt >> 5, (pkt >> 3) & 3, pkt & 7 },
{pkt & 7 , (pkt >> 3) & 3, pkt >> 5}};
for (l=0; l < 3; l++) {
if (is_mace3)
chomp3(&ctx->chd[i], output, val[1][l], l);
else
chomp6(&ctx->chd[i], output, val[0][l], l);
output += 1 << (1-is_mace3);
*got_frame_ptr = 1;
return buf_size; | {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,
int *VAR_2, AVPacket *VAR_3)
{
AVFrame *frame = VAR_1;
const uint8_t *VAR_4 = VAR_3->VAR_1;
int VAR_5 = VAR_3->size;
int16_t **samples;
MACEContext *ctx = VAR_0->priv_data;
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;
int VAR_11 = (VAR_0->codec_id == AV_CODEC_ID_MACE3);
frame->nb_samples = 3 * (VAR_5 << (1 - VAR_11)) / VAR_0->channels;
if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0)
return VAR_10;
samples = (int16_t **)frame->extended_data;
for(VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {
int16_t *output = samples[VAR_6];
for (VAR_7=0; VAR_7 < VAR_5 / (VAR_0->channels << VAR_11); VAR_7++)
for (VAR_8=0; VAR_8 < (1 << VAR_11); VAR_8++) {
uint8_t pkt = VAR_4[(VAR_6 << VAR_11) +
(VAR_7*VAR_0->channels << VAR_11) + VAR_8];
uint8_t val[2][3] = {{pkt >> 5, (pkt >> 3) & 3, pkt & 7 },
{pkt & 7 , (pkt >> 3) & 3, pkt >> 5}};
for (VAR_9=0; VAR_9 < 3; VAR_9++) {
if (VAR_11)
chomp3(&ctx->chd[VAR_6], output, val[1][VAR_9], VAR_9);
else
chomp6(&ctx->chd[VAR_6], output, val[0][VAR_9], VAR_9);
output += 1 << (1-VAR_11);
*VAR_2 = 1;
return VAR_5; | [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1,\nint *VAR_2, AVPacket *VAR_3)\n{",
"AVFrame *frame = VAR_1;",
"const uint8_t *VAR_4 = VAR_3->VAR_1;",
"int VAR_5 = VAR_3->size;",
"int16_t **samples;",
"MACEContext *ctx = VAR_0->priv_data;",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10;",
"int VAR_11 = (VAR_0->codec_id == AV_CODEC_ID_MACE3);",
"frame->nb_samples = 3 * (VAR_5 << (1 - VAR_11)) / VAR_0->channels;",
"if ((VAR_10 = ff_get_buffer(VAR_0, frame, 0)) < 0)\nreturn VAR_10;",
"samples = (int16_t **)frame->extended_data;",
"for(VAR_6 = 0; VAR_6 < VAR_0->channels; VAR_6++) {",
"int16_t *output = samples[VAR_6];",
"for (VAR_7=0; VAR_7 < VAR_5 / (VAR_0->channels << VAR_11); VAR_7++)",
"for (VAR_8=0; VAR_8 < (1 << VAR_11); VAR_8++) {",
"uint8_t pkt = VAR_4[(VAR_6 << VAR_11) +\n(VAR_7*VAR_0->channels << VAR_11) + VAR_8];",
"uint8_t val[2][3] = {{pkt >> 5, (pkt >> 3) & 3, pkt & 7 },",
"{pkt & 7 , (pkt >> 3) & 3, pkt >> 5}};",
"for (VAR_9=0; VAR_9 < 3; VAR_9++) {",
"if (VAR_11)\nchomp3(&ctx->chd[VAR_6], output, val[1][VAR_9], VAR_9);",
"else\nchomp6(&ctx->chd[VAR_6], output, val[0][VAR_9], VAR_9);",
"output += 1 << (1-VAR_11);",
"*VAR_2 = 1;",
"return VAR_5;"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
2,
3
],
[
4
],
[
5
],
[
6
],
[
7
],
[
8
],
[
9
],
[
10
],
[
12
],
[
13,
14
],
[
15
],
[
16
],
[
17
],
[
18
],
[
19
],
[
20,
21
],
[
22
],
[
23
],
[
24
],
[
25,
26
],
[
27,
28
],
[
29
],
[
30
],
[
31
]
] |
25,044 | static av_cold int rv30_decode_init(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
int ret;
r->rv30 = 1;
if ((ret = ff_rv34_decode_init(avctx)) < 0)
return ret;
if(avctx->extradata_size < 2){
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
return -1;
r->max_rpr = avctx->extradata[1] & 7;
r->parse_slice_header = rv30_parse_slice_header;
r->decode_intra_types = rv30_decode_intra_types;
r->decode_mb_info = rv30_decode_mb_info;
r->loop_filter = rv30_loop_filter;
r->luma_dc_quant_i = rv30_luma_dc_quant;
r->luma_dc_quant_p = rv30_luma_dc_quant;
return 0;
| true | FFmpeg | be524ffc16bf14cab0ad112b0dcb48d09a2a40ff | static av_cold int rv30_decode_init(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
int ret;
r->rv30 = 1;
if ((ret = ff_rv34_decode_init(avctx)) < 0)
return ret;
if(avctx->extradata_size < 2){
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
return -1;
r->max_rpr = avctx->extradata[1] & 7;
r->parse_slice_header = rv30_parse_slice_header;
r->decode_intra_types = rv30_decode_intra_types;
r->decode_mb_info = rv30_decode_mb_info;
r->loop_filter = rv30_loop_filter;
r->luma_dc_quant_i = rv30_luma_dc_quant;
r->luma_dc_quant_p = rv30_luma_dc_quant;
return 0;
| {
"code": [],
"line_no": []
} | static av_cold int FUNC_0(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
int VAR_0;
r->rv30 = 1;
if ((VAR_0 = ff_rv34_decode_init(avctx)) < 0)
return VAR_0;
if(avctx->extradata_size < 2){
av_log(avctx, AV_LOG_ERROR, "Extradata is too small.\n");
return -1;
r->max_rpr = avctx->extradata[1] & 7;
r->parse_slice_header = rv30_parse_slice_header;
r->decode_intra_types = rv30_decode_intra_types;
r->decode_mb_info = rv30_decode_mb_info;
r->loop_filter = rv30_loop_filter;
r->luma_dc_quant_i = rv30_luma_dc_quant;
r->luma_dc_quant_p = rv30_luma_dc_quant;
return 0;
| [
"static av_cold int FUNC_0(AVCodecContext *avctx)\n{",
"RV34DecContext *r = avctx->priv_data;",
"int VAR_0;",
"r->rv30 = 1;",
"if ((VAR_0 = ff_rv34_decode_init(avctx)) < 0)\nreturn VAR_0;",
"if(avctx->extradata_size < 2){",
"av_log(avctx, AV_LOG_ERROR, \"Extradata is too small.\\n\");",
"return -1;",
"r->max_rpr = avctx->extradata[1] & 7;",
"r->parse_slice_header = rv30_parse_slice_header;",
"r->decode_intra_types = rv30_decode_intra_types;",
"r->decode_mb_info = rv30_decode_mb_info;",
"r->loop_filter = rv30_loop_filter;",
"r->luma_dc_quant_i = rv30_luma_dc_quant;",
"r->luma_dc_quant_p = rv30_luma_dc_quant;",
"return 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
],
[
26
],
[
34
],
[
36
],
[
38
],
[
40
],
[
42
],
[
44
],
[
46
]
] |
25,045 | static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
{
unsigned int i;
x86_def_t *def;
char *s = g_strdup(cpu_model);
char *featurestr, *name = strtok(s, ",");
/* Features to be added*/
uint32_t plus_features = 0, plus_ext_features = 0;
uint32_t plus_ext2_features = 0, plus_ext3_features = 0;
uint32_t plus_kvm_features = 0, plus_svm_features = 0;
/* Features to be removed */
uint32_t minus_features = 0, minus_ext_features = 0;
uint32_t minus_ext2_features = 0, minus_ext3_features = 0;
uint32_t minus_kvm_features = 0, minus_svm_features = 0;
uint32_t numvalue;
for (def = x86_defs; def; def = def->next)
if (!strcmp(name, def->name))
break;
if (kvm_enabled() && strcmp(name, "host") == 0) {
cpu_x86_fill_host(x86_cpu_def);
} else if (!def) {
goto error;
} else {
memcpy(x86_cpu_def, def, sizeof(*def));
}
plus_kvm_features = ~0; /* not supported bits will be filtered out later */
add_flagname_to_bitmaps("hypervisor", &plus_features,
&plus_ext_features, &plus_ext2_features, &plus_ext3_features,
&plus_kvm_features, &plus_svm_features);
featurestr = strtok(NULL, ",");
while (featurestr) {
char *val;
if (featurestr[0] == '+') {
add_flagname_to_bitmaps(featurestr + 1, &plus_features,
&plus_ext_features, &plus_ext2_features,
&plus_ext3_features, &plus_kvm_features,
&plus_svm_features);
} else if (featurestr[0] == '-') {
add_flagname_to_bitmaps(featurestr + 1, &minus_features,
&minus_ext_features, &minus_ext2_features,
&minus_ext3_features, &minus_kvm_features,
&minus_svm_features);
} else if ((val = strchr(featurestr, '='))) {
*val = 0; val++;
if (!strcmp(featurestr, "family")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->family = numvalue;
} else if (!strcmp(featurestr, "model")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err || numvalue > 0xff) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->model = numvalue;
} else if (!strcmp(featurestr, "stepping")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err || numvalue > 0xf) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->stepping = numvalue ;
} else if (!strcmp(featurestr, "level")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->level = numvalue;
} else if (!strcmp(featurestr, "xlevel")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
if (numvalue < 0x80000000) {
numvalue += 0x80000000;
}
x86_cpu_def->xlevel = numvalue;
} else if (!strcmp(featurestr, "vendor")) {
if (strlen(val) != 12) {
fprintf(stderr, "vendor string must be 12 chars long\n");
goto error;
}
x86_cpu_def->vendor1 = 0;
x86_cpu_def->vendor2 = 0;
x86_cpu_def->vendor3 = 0;
for(i = 0; i < 4; i++) {
x86_cpu_def->vendor1 |= ((uint8_t)val[i ]) << (8 * i);
x86_cpu_def->vendor2 |= ((uint8_t)val[i + 4]) << (8 * i);
x86_cpu_def->vendor3 |= ((uint8_t)val[i + 8]) << (8 * i);
}
x86_cpu_def->vendor_override = 1;
} else if (!strcmp(featurestr, "model_id")) {
pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id),
val);
} else if (!strcmp(featurestr, "tsc_freq")) {
int64_t tsc_freq;
char *err;
tsc_freq = strtosz_suffix_unit(val, &err,
STRTOSZ_DEFSUFFIX_B, 1000);
if (!*val || *err) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->tsc_khz = tsc_freq / 1000;
} else {
fprintf(stderr, "unrecognized feature %s\n", featurestr);
goto error;
}
} else if (!strcmp(featurestr, "check")) {
check_cpuid = 1;
} else if (!strcmp(featurestr, "enforce")) {
check_cpuid = enforce_cpuid = 1;
} else {
fprintf(stderr, "feature string `%s' not in format (+feature|-feature|feature=xyz)\n", featurestr);
goto error;
}
featurestr = strtok(NULL, ",");
}
x86_cpu_def->features |= plus_features;
x86_cpu_def->ext_features |= plus_ext_features;
x86_cpu_def->ext2_features |= plus_ext2_features;
x86_cpu_def->ext3_features |= plus_ext3_features;
x86_cpu_def->kvm_features |= plus_kvm_features;
x86_cpu_def->svm_features |= plus_svm_features;
x86_cpu_def->features &= ~minus_features;
x86_cpu_def->ext_features &= ~minus_ext_features;
x86_cpu_def->ext2_features &= ~minus_ext2_features;
x86_cpu_def->ext3_features &= ~minus_ext3_features;
x86_cpu_def->kvm_features &= ~minus_kvm_features;
x86_cpu_def->svm_features &= ~minus_svm_features;
if (check_cpuid) {
if (check_features_against_host(x86_cpu_def) && enforce_cpuid)
goto error;
}
g_free(s);
return 0;
error:
g_free(s);
return -1;
}
| true | qemu | 04c5b17a74c9d6c309181079f8949665b43b0164 | static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
{
unsigned int i;
x86_def_t *def;
char *s = g_strdup(cpu_model);
char *featurestr, *name = strtok(s, ",");
uint32_t plus_features = 0, plus_ext_features = 0;
uint32_t plus_ext2_features = 0, plus_ext3_features = 0;
uint32_t plus_kvm_features = 0, plus_svm_features = 0;
uint32_t minus_features = 0, minus_ext_features = 0;
uint32_t minus_ext2_features = 0, minus_ext3_features = 0;
uint32_t minus_kvm_features = 0, minus_svm_features = 0;
uint32_t numvalue;
for (def = x86_defs; def; def = def->next)
if (!strcmp(name, def->name))
break;
if (kvm_enabled() && strcmp(name, "host") == 0) {
cpu_x86_fill_host(x86_cpu_def);
} else if (!def) {
goto error;
} else {
memcpy(x86_cpu_def, def, sizeof(*def));
}
plus_kvm_features = ~0;
add_flagname_to_bitmaps("hypervisor", &plus_features,
&plus_ext_features, &plus_ext2_features, &plus_ext3_features,
&plus_kvm_features, &plus_svm_features);
featurestr = strtok(NULL, ",");
while (featurestr) {
char *val;
if (featurestr[0] == '+') {
add_flagname_to_bitmaps(featurestr + 1, &plus_features,
&plus_ext_features, &plus_ext2_features,
&plus_ext3_features, &plus_kvm_features,
&plus_svm_features);
} else if (featurestr[0] == '-') {
add_flagname_to_bitmaps(featurestr + 1, &minus_features,
&minus_ext_features, &minus_ext2_features,
&minus_ext3_features, &minus_kvm_features,
&minus_svm_features);
} else if ((val = strchr(featurestr, '='))) {
*val = 0; val++;
if (!strcmp(featurestr, "family")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->family = numvalue;
} else if (!strcmp(featurestr, "model")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err || numvalue > 0xff) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->model = numvalue;
} else if (!strcmp(featurestr, "stepping")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err || numvalue > 0xf) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->stepping = numvalue ;
} else if (!strcmp(featurestr, "level")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->level = numvalue;
} else if (!strcmp(featurestr, "xlevel")) {
char *err;
numvalue = strtoul(val, &err, 0);
if (!*val || *err) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
if (numvalue < 0x80000000) {
numvalue += 0x80000000;
}
x86_cpu_def->xlevel = numvalue;
} else if (!strcmp(featurestr, "vendor")) {
if (strlen(val) != 12) {
fprintf(stderr, "vendor string must be 12 chars long\n");
goto error;
}
x86_cpu_def->vendor1 = 0;
x86_cpu_def->vendor2 = 0;
x86_cpu_def->vendor3 = 0;
for(i = 0; i < 4; i++) {
x86_cpu_def->vendor1 |= ((uint8_t)val[i ]) << (8 * i);
x86_cpu_def->vendor2 |= ((uint8_t)val[i + 4]) << (8 * i);
x86_cpu_def->vendor3 |= ((uint8_t)val[i + 8]) << (8 * i);
}
x86_cpu_def->vendor_override = 1;
} else if (!strcmp(featurestr, "model_id")) {
pstrcpy(x86_cpu_def->model_id, sizeof(x86_cpu_def->model_id),
val);
} else if (!strcmp(featurestr, "tsc_freq")) {
int64_t tsc_freq;
char *err;
tsc_freq = strtosz_suffix_unit(val, &err,
STRTOSZ_DEFSUFFIX_B, 1000);
if (!*val || *err) {
fprintf(stderr, "bad numerical value %s\n", val);
goto error;
}
x86_cpu_def->tsc_khz = tsc_freq / 1000;
} else {
fprintf(stderr, "unrecognized feature %s\n", featurestr);
goto error;
}
} else if (!strcmp(featurestr, "check")) {
check_cpuid = 1;
} else if (!strcmp(featurestr, "enforce")) {
check_cpuid = enforce_cpuid = 1;
} else {
fprintf(stderr, "feature string `%s' not in format (+feature|-feature|feature=xyz)\n", featurestr);
goto error;
}
featurestr = strtok(NULL, ",");
}
x86_cpu_def->features |= plus_features;
x86_cpu_def->ext_features |= plus_ext_features;
x86_cpu_def->ext2_features |= plus_ext2_features;
x86_cpu_def->ext3_features |= plus_ext3_features;
x86_cpu_def->kvm_features |= plus_kvm_features;
x86_cpu_def->svm_features |= plus_svm_features;
x86_cpu_def->features &= ~minus_features;
x86_cpu_def->ext_features &= ~minus_ext_features;
x86_cpu_def->ext2_features &= ~minus_ext2_features;
x86_cpu_def->ext3_features &= ~minus_ext3_features;
x86_cpu_def->kvm_features &= ~minus_kvm_features;
x86_cpu_def->svm_features &= ~minus_svm_features;
if (check_cpuid) {
if (check_features_against_host(x86_cpu_def) && enforce_cpuid)
goto error;
}
g_free(s);
return 0;
error:
g_free(s);
return -1;
}
| {
"code": [
" if (!strcmp(name, def->name))",
" if (kvm_enabled() && strcmp(name, \"host\") == 0) {"
],
"line_no": [
37,
41
]
} | static int FUNC_0(x86_def_t *VAR_0, const char *VAR_1)
{
unsigned int VAR_2;
x86_def_t *def;
char *VAR_3 = g_strdup(VAR_1);
char *VAR_4, *VAR_5 = strtok(VAR_3, ",");
uint32_t plus_features = 0, plus_ext_features = 0;
uint32_t plus_ext2_features = 0, plus_ext3_features = 0;
uint32_t plus_kvm_features = 0, plus_svm_features = 0;
uint32_t minus_features = 0, minus_ext_features = 0;
uint32_t minus_ext2_features = 0, minus_ext3_features = 0;
uint32_t minus_kvm_features = 0, minus_svm_features = 0;
uint32_t numvalue;
for (def = x86_defs; def; def = def->next)
if (!strcmp(VAR_5, def->VAR_5))
break;
if (kvm_enabled() && strcmp(VAR_5, "host") == 0) {
cpu_x86_fill_host(VAR_0);
} else if (!def) {
goto error;
} else {
memcpy(VAR_0, def, sizeof(*def));
}
plus_kvm_features = ~0;
add_flagname_to_bitmaps("hypervisor", &plus_features,
&plus_ext_features, &plus_ext2_features, &plus_ext3_features,
&plus_kvm_features, &plus_svm_features);
VAR_4 = strtok(NULL, ",");
while (VAR_4) {
char *VAR_6;
if (VAR_4[0] == '+') {
add_flagname_to_bitmaps(VAR_4 + 1, &plus_features,
&plus_ext_features, &plus_ext2_features,
&plus_ext3_features, &plus_kvm_features,
&plus_svm_features);
} else if (VAR_4[0] == '-') {
add_flagname_to_bitmaps(VAR_4 + 1, &minus_features,
&minus_ext_features, &minus_ext2_features,
&minus_ext3_features, &minus_kvm_features,
&minus_svm_features);
} else if ((VAR_6 = strchr(VAR_4, '='))) {
*VAR_6 = 0; VAR_6++;
if (!strcmp(VAR_4, "family")) {
char *VAR_8;
numvalue = strtoul(VAR_6, &VAR_8, 0);
if (!*VAR_6 || *VAR_8) {
fprintf(stderr, "bad numerical value %VAR_3\n", VAR_6);
goto error;
}
VAR_0->family = numvalue;
} else if (!strcmp(VAR_4, "model")) {
char *VAR_8;
numvalue = strtoul(VAR_6, &VAR_8, 0);
if (!*VAR_6 || *VAR_8 || numvalue > 0xff) {
fprintf(stderr, "bad numerical value %VAR_3\n", VAR_6);
goto error;
}
VAR_0->model = numvalue;
} else if (!strcmp(VAR_4, "stepping")) {
char *VAR_8;
numvalue = strtoul(VAR_6, &VAR_8, 0);
if (!*VAR_6 || *VAR_8 || numvalue > 0xf) {
fprintf(stderr, "bad numerical value %VAR_3\n", VAR_6);
goto error;
}
VAR_0->stepping = numvalue ;
} else if (!strcmp(VAR_4, "level")) {
char *VAR_8;
numvalue = strtoul(VAR_6, &VAR_8, 0);
if (!*VAR_6 || *VAR_8) {
fprintf(stderr, "bad numerical value %VAR_3\n", VAR_6);
goto error;
}
VAR_0->level = numvalue;
} else if (!strcmp(VAR_4, "xlevel")) {
char *VAR_8;
numvalue = strtoul(VAR_6, &VAR_8, 0);
if (!*VAR_6 || *VAR_8) {
fprintf(stderr, "bad numerical value %VAR_3\n", VAR_6);
goto error;
}
if (numvalue < 0x80000000) {
numvalue += 0x80000000;
}
VAR_0->xlevel = numvalue;
} else if (!strcmp(VAR_4, "vendor")) {
if (strlen(VAR_6) != 12) {
fprintf(stderr, "vendor string must be 12 chars long\n");
goto error;
}
VAR_0->vendor1 = 0;
VAR_0->vendor2 = 0;
VAR_0->vendor3 = 0;
for(VAR_2 = 0; VAR_2 < 4; VAR_2++) {
VAR_0->vendor1 |= ((uint8_t)VAR_6[VAR_2 ]) << (8 * VAR_2);
VAR_0->vendor2 |= ((uint8_t)VAR_6[VAR_2 + 4]) << (8 * VAR_2);
VAR_0->vendor3 |= ((uint8_t)VAR_6[VAR_2 + 8]) << (8 * VAR_2);
}
VAR_0->vendor_override = 1;
} else if (!strcmp(VAR_4, "model_id")) {
pstrcpy(VAR_0->model_id, sizeof(VAR_0->model_id),
VAR_6);
} else if (!strcmp(VAR_4, "tsc_freq")) {
int64_t tsc_freq;
char *VAR_8;
tsc_freq = strtosz_suffix_unit(VAR_6, &VAR_8,
STRTOSZ_DEFSUFFIX_B, 1000);
if (!*VAR_6 || *VAR_8) {
fprintf(stderr, "bad numerical value %VAR_3\n", VAR_6);
goto error;
}
VAR_0->tsc_khz = tsc_freq / 1000;
} else {
fprintf(stderr, "unrecognized feature %VAR_3\n", VAR_4);
goto error;
}
} else if (!strcmp(VAR_4, "check")) {
check_cpuid = 1;
} else if (!strcmp(VAR_4, "enforce")) {
check_cpuid = enforce_cpuid = 1;
} else {
fprintf(stderr, "feature string `%VAR_3' not in format (+feature|-feature|feature=xyz)\n", VAR_4);
goto error;
}
VAR_4 = strtok(NULL, ",");
}
VAR_0->features |= plus_features;
VAR_0->ext_features |= plus_ext_features;
VAR_0->ext2_features |= plus_ext2_features;
VAR_0->ext3_features |= plus_ext3_features;
VAR_0->kvm_features |= plus_kvm_features;
VAR_0->svm_features |= plus_svm_features;
VAR_0->features &= ~minus_features;
VAR_0->ext_features &= ~minus_ext_features;
VAR_0->ext2_features &= ~minus_ext2_features;
VAR_0->ext3_features &= ~minus_ext3_features;
VAR_0->kvm_features &= ~minus_kvm_features;
VAR_0->svm_features &= ~minus_svm_features;
if (check_cpuid) {
if (check_features_against_host(VAR_0) && enforce_cpuid)
goto error;
}
g_free(VAR_3);
return 0;
error:
g_free(VAR_3);
return -1;
}
| [
"static int FUNC_0(x86_def_t *VAR_0, const char *VAR_1)\n{",
"unsigned int VAR_2;",
"x86_def_t *def;",
"char *VAR_3 = g_strdup(VAR_1);",
"char *VAR_4, *VAR_5 = strtok(VAR_3, \",\");",
"uint32_t plus_features = 0, plus_ext_features = 0;",
"uint32_t plus_ext2_features = 0, plus_ext3_features = 0;",
"uint32_t plus_kvm_features = 0, plus_svm_features = 0;",
"uint32_t minus_features = 0, minus_ext_features = 0;",
"uint32_t minus_ext2_features = 0, minus_ext3_features = 0;",
"uint32_t minus_kvm_features = 0, minus_svm_features = 0;",
"uint32_t numvalue;",
"for (def = x86_defs; def; def = def->next)",
"if (!strcmp(VAR_5, def->VAR_5))\nbreak;",
"if (kvm_enabled() && strcmp(VAR_5, \"host\") == 0) {",
"cpu_x86_fill_host(VAR_0);",
"} else if (!def) {",
"goto error;",
"} else {",
"memcpy(VAR_0, def, sizeof(*def));",
"}",
"plus_kvm_features = ~0;",
"add_flagname_to_bitmaps(\"hypervisor\", &plus_features,\n&plus_ext_features, &plus_ext2_features, &plus_ext3_features,\n&plus_kvm_features, &plus_svm_features);",
"VAR_4 = strtok(NULL, \",\");",
"while (VAR_4) {",
"char *VAR_6;",
"if (VAR_4[0] == '+') {",
"add_flagname_to_bitmaps(VAR_4 + 1, &plus_features,\n&plus_ext_features, &plus_ext2_features,\n&plus_ext3_features, &plus_kvm_features,\n&plus_svm_features);",
"} else if (VAR_4[0] == '-') {",
"add_flagname_to_bitmaps(VAR_4 + 1, &minus_features,\n&minus_ext_features, &minus_ext2_features,\n&minus_ext3_features, &minus_kvm_features,\n&minus_svm_features);",
"} else if ((VAR_6 = strchr(VAR_4, '='))) {",
"*VAR_6 = 0; VAR_6++;",
"if (!strcmp(VAR_4, \"family\")) {",
"char *VAR_8;",
"numvalue = strtoul(VAR_6, &VAR_8, 0);",
"if (!*VAR_6 || *VAR_8) {",
"fprintf(stderr, \"bad numerical value %VAR_3\\n\", VAR_6);",
"goto error;",
"}",
"VAR_0->family = numvalue;",
"} else if (!strcmp(VAR_4, \"model\")) {",
"char *VAR_8;",
"numvalue = strtoul(VAR_6, &VAR_8, 0);",
"if (!*VAR_6 || *VAR_8 || numvalue > 0xff) {",
"fprintf(stderr, \"bad numerical value %VAR_3\\n\", VAR_6);",
"goto error;",
"}",
"VAR_0->model = numvalue;",
"} else if (!strcmp(VAR_4, \"stepping\")) {",
"char *VAR_8;",
"numvalue = strtoul(VAR_6, &VAR_8, 0);",
"if (!*VAR_6 || *VAR_8 || numvalue > 0xf) {",
"fprintf(stderr, \"bad numerical value %VAR_3\\n\", VAR_6);",
"goto error;",
"}",
"VAR_0->stepping = numvalue ;",
"} else if (!strcmp(VAR_4, \"level\")) {",
"char *VAR_8;",
"numvalue = strtoul(VAR_6, &VAR_8, 0);",
"if (!*VAR_6 || *VAR_8) {",
"fprintf(stderr, \"bad numerical value %VAR_3\\n\", VAR_6);",
"goto error;",
"}",
"VAR_0->level = numvalue;",
"} else if (!strcmp(VAR_4, \"xlevel\")) {",
"char *VAR_8;",
"numvalue = strtoul(VAR_6, &VAR_8, 0);",
"if (!*VAR_6 || *VAR_8) {",
"fprintf(stderr, \"bad numerical value %VAR_3\\n\", VAR_6);",
"goto error;",
"}",
"if (numvalue < 0x80000000) {",
"numvalue += 0x80000000;",
"}",
"VAR_0->xlevel = numvalue;",
"} else if (!strcmp(VAR_4, \"vendor\")) {",
"if (strlen(VAR_6) != 12) {",
"fprintf(stderr, \"vendor string must be 12 chars long\\n\");",
"goto error;",
"}",
"VAR_0->vendor1 = 0;",
"VAR_0->vendor2 = 0;",
"VAR_0->vendor3 = 0;",
"for(VAR_2 = 0; VAR_2 < 4; VAR_2++) {",
"VAR_0->vendor1 |= ((uint8_t)VAR_6[VAR_2 ]) << (8 * VAR_2);",
"VAR_0->vendor2 |= ((uint8_t)VAR_6[VAR_2 + 4]) << (8 * VAR_2);",
"VAR_0->vendor3 |= ((uint8_t)VAR_6[VAR_2 + 8]) << (8 * VAR_2);",
"}",
"VAR_0->vendor_override = 1;",
"} else if (!strcmp(VAR_4, \"model_id\")) {",
"pstrcpy(VAR_0->model_id, sizeof(VAR_0->model_id),\nVAR_6);",
"} else if (!strcmp(VAR_4, \"tsc_freq\")) {",
"int64_t tsc_freq;",
"char *VAR_8;",
"tsc_freq = strtosz_suffix_unit(VAR_6, &VAR_8,\nSTRTOSZ_DEFSUFFIX_B, 1000);",
"if (!*VAR_6 || *VAR_8) {",
"fprintf(stderr, \"bad numerical value %VAR_3\\n\", VAR_6);",
"goto error;",
"}",
"VAR_0->tsc_khz = tsc_freq / 1000;",
"} else {",
"fprintf(stderr, \"unrecognized feature %VAR_3\\n\", VAR_4);",
"goto error;",
"}",
"} else if (!strcmp(VAR_4, \"check\")) {",
"check_cpuid = 1;",
"} else if (!strcmp(VAR_4, \"enforce\")) {",
"check_cpuid = enforce_cpuid = 1;",
"} else {",
"fprintf(stderr, \"feature string `%VAR_3' not in format (+feature|-feature|feature=xyz)\\n\", VAR_4);",
"goto error;",
"}",
"VAR_4 = strtok(NULL, \",\");",
"}",
"VAR_0->features |= plus_features;",
"VAR_0->ext_features |= plus_ext_features;",
"VAR_0->ext2_features |= plus_ext2_features;",
"VAR_0->ext3_features |= plus_ext3_features;",
"VAR_0->kvm_features |= plus_kvm_features;",
"VAR_0->svm_features |= plus_svm_features;",
"VAR_0->features &= ~minus_features;",
"VAR_0->ext_features &= ~minus_ext_features;",
"VAR_0->ext2_features &= ~minus_ext2_features;",
"VAR_0->ext3_features &= ~minus_ext3_features;",
"VAR_0->kvm_features &= ~minus_kvm_features;",
"VAR_0->svm_features &= ~minus_svm_features;",
"if (check_cpuid) {",
"if (check_features_against_host(VAR_0) && enforce_cpuid)\ngoto error;",
"}",
"g_free(VAR_3);",
"return 0;",
"error:\ng_free(VAR_3);",
"return -1;",
"}"
] | [
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
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37,
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
57
],
[
61,
63,
65
],
[
69
],
[
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
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215
],
[
217,
219
],
[
221
],
[
223
],
[
225
],
[
229,
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297,
299
],
[
301
],
[
303
],
[
305
],
[
309,
311
],
[
313
],
[
315
]
] |
25,046 | static int virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
{
VirtIOGPU *g = opaque;
if (idx > g->conf.max_outputs) {
return -1;
}
g->req_state[idx].x = info->xoff;
g->req_state[idx].y = info->yoff;
g->req_state[idx].width = info->width;
g->req_state[idx].height = info->height;
if (info->width && info->height) {
g->enabled_output_bitmask |= (1 << idx);
} else {
g->enabled_output_bitmask &= ~(1 << idx);
}
/* send event to guest */
virtio_gpu_notify_event(g, VIRTIO_GPU_EVENT_DISPLAY);
return 0;
}
| true | qemu | 6b860806c0dd881373ead661c0f3499eca2c3995 | static int virtio_gpu_ui_info(void *opaque, uint32_t idx, QemuUIInfo *info)
{
VirtIOGPU *g = opaque;
if (idx > g->conf.max_outputs) {
return -1;
}
g->req_state[idx].x = info->xoff;
g->req_state[idx].y = info->yoff;
g->req_state[idx].width = info->width;
g->req_state[idx].height = info->height;
if (info->width && info->height) {
g->enabled_output_bitmask |= (1 << idx);
} else {
g->enabled_output_bitmask &= ~(1 << idx);
}
virtio_gpu_notify_event(g, VIRTIO_GPU_EVENT_DISPLAY);
return 0;
}
| {
"code": [
" if (idx > g->conf.max_outputs) {"
],
"line_no": [
9
]
} | static int FUNC_0(void *VAR_0, uint32_t VAR_1, QemuUIInfo *VAR_2)
{
VirtIOGPU *g = VAR_0;
if (VAR_1 > g->conf.max_outputs) {
return -1;
}
g->req_state[VAR_1].x = VAR_2->xoff;
g->req_state[VAR_1].y = VAR_2->yoff;
g->req_state[VAR_1].width = VAR_2->width;
g->req_state[VAR_1].height = VAR_2->height;
if (VAR_2->width && VAR_2->height) {
g->enabled_output_bitmask |= (1 << VAR_1);
} else {
g->enabled_output_bitmask &= ~(1 << VAR_1);
}
virtio_gpu_notify_event(g, VIRTIO_GPU_EVENT_DISPLAY);
return 0;
}
| [
"static int FUNC_0(void *VAR_0, uint32_t VAR_1, QemuUIInfo *VAR_2)\n{",
"VirtIOGPU *g = VAR_0;",
"if (VAR_1 > g->conf.max_outputs) {",
"return -1;",
"}",
"g->req_state[VAR_1].x = VAR_2->xoff;",
"g->req_state[VAR_1].y = VAR_2->yoff;",
"g->req_state[VAR_1].width = VAR_2->width;",
"g->req_state[VAR_1].height = VAR_2->height;",
"if (VAR_2->width && VAR_2->height) {",
"g->enabled_output_bitmask |= (1 << VAR_1);",
"} else {",
"g->enabled_output_bitmask &= ~(1 << VAR_1);",
"}",
"virtio_gpu_notify_event(g, VIRTIO_GPU_EVENT_DISPLAY);",
"return 0;",
"}"
] | [
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
41
],
[
43
],
[
45
]
] |
25,047 | void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(dev));
PowerPCCPU *cpu = POWERPC_CPU(core->threads);
int id = ppc_get_vcpu_dt_id(cpu);
sPAPRDRConnector *drc =
spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, id);
sPAPRDRConnectorClass *drck;
Error *local_err = NULL;
g_assert(drc);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->detach(drc, dev, spapr_core_release, NULL, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
spapr_hotplug_req_remove_by_index(drc);
}
| true | qemu | 44d691f7d9b6ebab102a31aa87fe59da8f7feff9 | void spapr_core_unplug(HotplugHandler *hotplug_dev, DeviceState *dev,
Error **errp)
{
sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(dev));
PowerPCCPU *cpu = POWERPC_CPU(core->threads);
int id = ppc_get_vcpu_dt_id(cpu);
sPAPRDRConnector *drc =
spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, id);
sPAPRDRConnectorClass *drck;
Error *local_err = NULL;
g_assert(drc);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->detach(drc, dev, spapr_core_release, NULL, &local_err);
if (local_err) {
error_propagate(errp, local_err);
return;
}
spapr_hotplug_req_remove_by_index(drc);
}
| {
"code": [
" sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(dev));",
" PowerPCCPU *cpu = POWERPC_CPU(core->threads);",
" int id = ppc_get_vcpu_dt_id(cpu);",
" spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, id);"
],
"line_no": [
7,
9,
11,
15
]
} | void FUNC_0(HotplugHandler *VAR_0, DeviceState *VAR_1,
Error **VAR_2)
{
sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(VAR_1));
PowerPCCPU *cpu = POWERPC_CPU(core->threads);
int VAR_3 = ppc_get_vcpu_dt_id(cpu);
sPAPRDRConnector *drc =
spapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, VAR_3);
sPAPRDRConnectorClass *drck;
Error *local_err = NULL;
g_assert(drc);
drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);
drck->detach(drc, VAR_1, spapr_core_release, NULL, &local_err);
if (local_err) {
error_propagate(VAR_2, local_err);
return;
}
spapr_hotplug_req_remove_by_index(drc);
}
| [
"void FUNC_0(HotplugHandler *VAR_0, DeviceState *VAR_1,\nError **VAR_2)\n{",
"sPAPRCPUCore *core = SPAPR_CPU_CORE(OBJECT(VAR_1));",
"PowerPCCPU *cpu = POWERPC_CPU(core->threads);",
"int VAR_3 = ppc_get_vcpu_dt_id(cpu);",
"sPAPRDRConnector *drc =\nspapr_dr_connector_by_id(SPAPR_DR_CONNECTOR_TYPE_CPU, VAR_3);",
"sPAPRDRConnectorClass *drck;",
"Error *local_err = NULL;",
"g_assert(drc);",
"drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);",
"drck->detach(drc, VAR_1, spapr_core_release, NULL, &local_err);",
"if (local_err) {",
"error_propagate(VAR_2, local_err);",
"return;",
"}",
"spapr_hotplug_req_remove_by_index(drc);",
"}"
] | [
0,
1,
1,
1,
1,
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
]
] |
25,048 | static void qobject_input_check_struct(Visitor *v, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
assert(tos && !tos->entry);
if (qiv->strict) {
GHashTable *const top_ht = tos->h;
if (top_ht) {
GHashTableIter iter;
const char *key;
g_hash_table_iter_init(&iter, top_ht);
if (g_hash_table_iter_next(&iter, (void **)&key, NULL)) {
error_setg(errp, "Parameter '%s' is unexpected", key);
}
}
}
}
| true | qemu | a9fc37f6bc3f2ab90585cb16493da9f6dcfbfbcf | static void qobject_input_check_struct(Visitor *v, Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
assert(tos && !tos->entry);
if (qiv->strict) {
GHashTable *const top_ht = tos->h;
if (top_ht) {
GHashTableIter iter;
const char *key;
g_hash_table_iter_init(&iter, top_ht);
if (g_hash_table_iter_next(&iter, (void **)&key, NULL)) {
error_setg(errp, "Parameter '%s' is unexpected", key);
}
}
}
}
| {
"code": [
" error_setg(errp, \"Parameter '%s' is unexpected\", key);"
],
"line_no": [
29
]
} | static void FUNC_0(Visitor *VAR_0, Error **VAR_1)
{
QObjectInputVisitor *qiv = to_qiv(VAR_0);
StackObject *tos = QSLIST_FIRST(&qiv->stack);
assert(tos && !tos->entry);
if (qiv->strict) {
GHashTable *const top_ht = tos->h;
if (top_ht) {
GHashTableIter iter;
const char *VAR_2;
g_hash_table_iter_init(&iter, top_ht);
if (g_hash_table_iter_next(&iter, (void **)&VAR_2, NULL)) {
error_setg(VAR_1, "Parameter '%s' is unexpected", VAR_2);
}
}
}
}
| [
"static void FUNC_0(Visitor *VAR_0, Error **VAR_1)\n{",
"QObjectInputVisitor *qiv = to_qiv(VAR_0);",
"StackObject *tos = QSLIST_FIRST(&qiv->stack);",
"assert(tos && !tos->entry);",
"if (qiv->strict) {",
"GHashTable *const top_ht = tos->h;",
"if (top_ht) {",
"GHashTableIter iter;",
"const char *VAR_2;",
"g_hash_table_iter_init(&iter, top_ht);",
"if (g_hash_table_iter_next(&iter, (void **)&VAR_2, NULL)) {",
"error_setg(VAR_1, \"Parameter '%s' is unexpected\", VAR_2);",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
25,050 | static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
const uint8_t **buf, int buf_size)
{
AVCodecContext *avctx = s->avctx;
const int field_pic = s->picture_structure != PICT_FRAME;
int ret;
s->resync_mb_x =
s->resync_mb_y = -1;
assert(mb_y < s->mb_height);
init_get_bits(&s->gb, *buf, buf_size * 8);
ff_mpeg1_clean_buffers(s);
s->interlaced_dct = 0;
s->qscale = get_qscale(s);
if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n");
return AVERROR_INVALIDDATA;
}
/* extra slice info */
while (get_bits1(&s->gb) != 0)
skip_bits(&s->gb, 8);
s->mb_x = 0;
if (mb_y == 0 && s->codec_tag == AV_RL32("SLIF")) {
skip_bits1(&s->gb);
} else {
while (get_bits_left(&s->gb) > 0) {
int code = get_vlc2(&s->gb, ff_mbincr_vlc.table,
MBINCR_VLC_BITS, 2);
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
return AVERROR_INVALIDDATA;
}
if (code >= 33) {
if (code == 33)
s->mb_x += 33;
/* otherwise, stuffing, nothing to do */
} else {
s->mb_x += code;
break;
}
}
}
if (s->mb_x >= (unsigned) s->mb_width) {
av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n");
return AVERROR_INVALIDDATA;
}
if (avctx->hwaccel) {
const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */
int start_code = -1;
buf_end = avpriv_find_start_code(buf_start + 2, *buf + buf_size, &start_code);
if (buf_end < *buf + buf_size)
buf_end -= 4;
s->mb_y = mb_y;
if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_end - buf_start) < 0)
return DECODE_SLICE_ERROR;
*buf = buf_end;
return DECODE_SLICE_OK;
}
s->resync_mb_x = s->mb_x;
s->resync_mb_y = s->mb_y = mb_y;
s->mb_skip_run = 0;
ff_init_block_index(s);
if (s->mb_y == 0 && s->mb_x == 0 && (s->first_field || s->picture_structure == PICT_FRAME)) {
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG,
"qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
s->qscale,
s->mpeg_f_code[0][0], s->mpeg_f_code[0][1],
s->mpeg_f_code[1][0], s->mpeg_f_code[1][1],
s->pict_type == AV_PICTURE_TYPE_I ? "I" :
(s->pict_type == AV_PICTURE_TYPE_P ? "P" :
(s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")),
s->progressive_sequence ? "ps" : "",
s->progressive_frame ? "pf" : "",
s->alternate_scan ? "alt" : "",
s->top_field_first ? "top" : "",
s->intra_dc_precision, s->picture_structure,
s->frame_pred_frame_dct, s->concealment_motion_vectors,
s->q_scale_type, s->intra_vlc_format,
s->repeat_first_field, s->chroma_420_type ? "420" : "");
}
}
for (;;) {
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
// If 1, we memcpy blocks in xvmcvideo.
if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1)
ff_xvmc_init_block(s); // set s->block
FF_ENABLE_DEPRECATION_WARNINGS
#endif /* FF_API_XVMC */
if ((ret = mpeg_decode_mb(s, s->block)) < 0)
return ret;
// Note motion_val is normally NULL unless we want to extract the MVs.
if (s->current_picture.motion_val[0] && !s->encoding) {
const int wrap = s->b8_stride;
int xy = s->mb_x * 2 + s->mb_y * 2 * wrap;
int b8_xy = 4 * (s->mb_x + s->mb_y * s->mb_stride);
int motion_x, motion_y, dir, i;
for (i = 0; i < 2; i++) {
for (dir = 0; dir < 2; dir++) {
if (s->mb_intra ||
(dir == 1 && s->pict_type != AV_PICTURE_TYPE_B)) {
motion_x = motion_y = 0;
} else if (s->mv_type == MV_TYPE_16X16 ||
(s->mv_type == MV_TYPE_FIELD && field_pic)) {
motion_x = s->mv[dir][0][0];
motion_y = s->mv[dir][0][1];
} else { /* if ((s->mv_type == MV_TYPE_FIELD) || (s->mv_type == MV_TYPE_16X8)) */
motion_x = s->mv[dir][i][0];
motion_y = s->mv[dir][i][1];
}
s->current_picture.motion_val[dir][xy][0] = motion_x;
s->current_picture.motion_val[dir][xy][1] = motion_y;
s->current_picture.motion_val[dir][xy + 1][0] = motion_x;
s->current_picture.motion_val[dir][xy + 1][1] = motion_y;
s->current_picture.ref_index [dir][b8_xy] =
s->current_picture.ref_index [dir][b8_xy + 1] = s->field_select[dir][i];
assert(s->field_select[dir][i] == 0 ||
s->field_select[dir][i] == 1);
}
xy += wrap;
b8_xy += 2;
}
}
s->dest[0] += 16;
s->dest[1] += 16 >> s->chroma_x_shift;
s->dest[2] += 16 >> s->chroma_x_shift;
ff_mpv_decode_mb(s, s->block);
if (++s->mb_x >= s->mb_width) {
const int mb_size = 16;
ff_mpeg_draw_horiz_band(s, mb_size * (s->mb_y >> field_pic), mb_size);
ff_mpv_report_decode_progress(s);
s->mb_x = 0;
s->mb_y += 1 << field_pic;
if (s->mb_y >= s->mb_height) {
int left = get_bits_left(&s->gb);
int is_d10 = s->chroma_format == 2 &&
s->pict_type == AV_PICTURE_TYPE_I &&
avctx->profile == 0 && avctx->level == 5 &&
s->intra_dc_precision == 2 &&
s->q_scale_type == 1 && s->alternate_scan == 0 &&
s->progressive_frame == 0
/* vbv_delay == 0xBBB || 0xE10 */;
if (left < 0 ||
(left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) ||
((avctx->err_recognition & AV_EF_BUFFER) && left > 8)) {
av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n",
left, show_bits(&s->gb, FFMIN(left, 23)));
return AVERROR_INVALIDDATA;
} else
goto eos;
}
ff_init_block_index(s);
}
/* skip mb handling */
if (s->mb_skip_run == -1) {
/* read increment again */
s->mb_skip_run = 0;
for (;;) {
int code = get_vlc2(&s->gb, ff_mbincr_vlc.table,
MBINCR_VLC_BITS, 2);
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n");
return AVERROR_INVALIDDATA;
}
if (code >= 33) {
if (code == 33) {
s->mb_skip_run += 33;
} else if (code == 35) {
if (s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n");
return AVERROR_INVALIDDATA;
}
goto eos; /* end of slice */
}
/* otherwise, stuffing, nothing to do */
} else {
s->mb_skip_run += code;
break;
}
}
if (s->mb_skip_run) {
int i;
if (s->pict_type == AV_PICTURE_TYPE_I) {
av_log(s->avctx, AV_LOG_ERROR,
"skipped MB in I-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
/* skip mb */
s->mb_intra = 0;
for (i = 0; i < 12; i++)
s->block_last_index[i] = -1;
if (s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else
s->mv_type = MV_TYPE_FIELD;
if (s->pict_type == AV_PICTURE_TYPE_P) {
/* if P type, zero motion vector is implied */
s->mv_dir = MV_DIR_FORWARD;
s->mv[0][0][0] = s->mv[0][0][1] = 0;
s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
s->field_select[0][0] = (s->picture_structure - 1) & 1;
} else {
/* if B type, reuse previous vectors and directions */
s->mv[0][0][0] = s->last_mv[0][0][0];
s->mv[0][0][1] = s->last_mv[0][0][1];
s->mv[1][0][0] = s->last_mv[1][0][0];
s->mv[1][0][1] = s->last_mv[1][0][1];
}
}
}
}
eos: // end of slice
*buf += (get_bits_count(&s->gb) - 1) / 8;
ff_dlog(s, "y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y);
return 0;
}
| false | FFmpeg | dcc39ee10e82833ce24aa57926c00ffeb1948198 | static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
const uint8_t **buf, int buf_size)
{
AVCodecContext *avctx = s->avctx;
const int field_pic = s->picture_structure != PICT_FRAME;
int ret;
s->resync_mb_x =
s->resync_mb_y = -1;
assert(mb_y < s->mb_height);
init_get_bits(&s->gb, *buf, buf_size * 8);
ff_mpeg1_clean_buffers(s);
s->interlaced_dct = 0;
s->qscale = get_qscale(s);
if (s->qscale == 0) {
av_log(s->avctx, AV_LOG_ERROR, "qscale == 0\n");
return AVERROR_INVALIDDATA;
}
while (get_bits1(&s->gb) != 0)
skip_bits(&s->gb, 8);
s->mb_x = 0;
if (mb_y == 0 && s->codec_tag == AV_RL32("SLIF")) {
skip_bits1(&s->gb);
} else {
while (get_bits_left(&s->gb) > 0) {
int code = get_vlc2(&s->gb, ff_mbincr_vlc.table,
MBINCR_VLC_BITS, 2);
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
return AVERROR_INVALIDDATA;
}
if (code >= 33) {
if (code == 33)
s->mb_x += 33;
} else {
s->mb_x += code;
break;
}
}
}
if (s->mb_x >= (unsigned) s->mb_width) {
av_log(s->avctx, AV_LOG_ERROR, "initial skip overflow\n");
return AVERROR_INVALIDDATA;
}
if (avctx->hwaccel) {
const uint8_t *buf_end, *buf_start = *buf - 4;
int start_code = -1;
buf_end = avpriv_find_start_code(buf_start + 2, *buf + buf_size, &start_code);
if (buf_end < *buf + buf_size)
buf_end -= 4;
s->mb_y = mb_y;
if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_end - buf_start) < 0)
return DECODE_SLICE_ERROR;
*buf = buf_end;
return DECODE_SLICE_OK;
}
s->resync_mb_x = s->mb_x;
s->resync_mb_y = s->mb_y = mb_y;
s->mb_skip_run = 0;
ff_init_block_index(s);
if (s->mb_y == 0 && s->mb_x == 0 && (s->first_field || s->picture_structure == PICT_FRAME)) {
if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(s->avctx, AV_LOG_DEBUG,
"qp:%d fc:%2d%2d%2d%2d %s %s %s %s %s dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %s\n",
s->qscale,
s->mpeg_f_code[0][0], s->mpeg_f_code[0][1],
s->mpeg_f_code[1][0], s->mpeg_f_code[1][1],
s->pict_type == AV_PICTURE_TYPE_I ? "I" :
(s->pict_type == AV_PICTURE_TYPE_P ? "P" :
(s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")),
s->progressive_sequence ? "ps" : "",
s->progressive_frame ? "pf" : "",
s->alternate_scan ? "alt" : "",
s->top_field_first ? "top" : "",
s->intra_dc_precision, s->picture_structure,
s->frame_pred_frame_dct, s->concealment_motion_vectors,
s->q_scale_type, s->intra_vlc_format,
s->repeat_first_field, s->chroma_420_type ? "420" : "");
}
}
for (;;) {
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration > 1)
ff_xvmc_init_block(s);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if ((ret = mpeg_decode_mb(s, s->block)) < 0)
return ret;
if (s->current_picture.motion_val[0] && !s->encoding) {
const int wrap = s->b8_stride;
int xy = s->mb_x * 2 + s->mb_y * 2 * wrap;
int b8_xy = 4 * (s->mb_x + s->mb_y * s->mb_stride);
int motion_x, motion_y, dir, i;
for (i = 0; i < 2; i++) {
for (dir = 0; dir < 2; dir++) {
if (s->mb_intra ||
(dir == 1 && s->pict_type != AV_PICTURE_TYPE_B)) {
motion_x = motion_y = 0;
} else if (s->mv_type == MV_TYPE_16X16 ||
(s->mv_type == MV_TYPE_FIELD && field_pic)) {
motion_x = s->mv[dir][0][0];
motion_y = s->mv[dir][0][1];
} else {
motion_x = s->mv[dir][i][0];
motion_y = s->mv[dir][i][1];
}
s->current_picture.motion_val[dir][xy][0] = motion_x;
s->current_picture.motion_val[dir][xy][1] = motion_y;
s->current_picture.motion_val[dir][xy + 1][0] = motion_x;
s->current_picture.motion_val[dir][xy + 1][1] = motion_y;
s->current_picture.ref_index [dir][b8_xy] =
s->current_picture.ref_index [dir][b8_xy + 1] = s->field_select[dir][i];
assert(s->field_select[dir][i] == 0 ||
s->field_select[dir][i] == 1);
}
xy += wrap;
b8_xy += 2;
}
}
s->dest[0] += 16;
s->dest[1] += 16 >> s->chroma_x_shift;
s->dest[2] += 16 >> s->chroma_x_shift;
ff_mpv_decode_mb(s, s->block);
if (++s->mb_x >= s->mb_width) {
const int mb_size = 16;
ff_mpeg_draw_horiz_band(s, mb_size * (s->mb_y >> field_pic), mb_size);
ff_mpv_report_decode_progress(s);
s->mb_x = 0;
s->mb_y += 1 << field_pic;
if (s->mb_y >= s->mb_height) {
int left = get_bits_left(&s->gb);
int is_d10 = s->chroma_format == 2 &&
s->pict_type == AV_PICTURE_TYPE_I &&
avctx->profile == 0 && avctx->level == 5 &&
s->intra_dc_precision == 2 &&
s->q_scale_type == 1 && s->alternate_scan == 0 &&
s->progressive_frame == 0
;
if (left < 0 ||
(left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) ||
((avctx->err_recognition & AV_EF_BUFFER) && left > 8)) {
av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n",
left, show_bits(&s->gb, FFMIN(left, 23)));
return AVERROR_INVALIDDATA;
} else
goto eos;
}
ff_init_block_index(s);
}
if (s->mb_skip_run == -1) {
s->mb_skip_run = 0;
for (;;) {
int code = get_vlc2(&s->gb, ff_mbincr_vlc.table,
MBINCR_VLC_BITS, 2);
if (code < 0) {
av_log(s->avctx, AV_LOG_ERROR, "mb incr damaged\n");
return AVERROR_INVALIDDATA;
}
if (code >= 33) {
if (code == 33) {
s->mb_skip_run += 33;
} else if (code == 35) {
if (s->mb_skip_run != 0 || show_bits(&s->gb, 15) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "slice mismatch\n");
return AVERROR_INVALIDDATA;
}
goto eos;
}
} else {
s->mb_skip_run += code;
break;
}
}
if (s->mb_skip_run) {
int i;
if (s->pict_type == AV_PICTURE_TYPE_I) {
av_log(s->avctx, AV_LOG_ERROR,
"skipped MB in I-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
s->mb_intra = 0;
for (i = 0; i < 12; i++)
s->block_last_index[i] = -1;
if (s->picture_structure == PICT_FRAME)
s->mv_type = MV_TYPE_16X16;
else
s->mv_type = MV_TYPE_FIELD;
if (s->pict_type == AV_PICTURE_TYPE_P) {
s->mv_dir = MV_DIR_FORWARD;
s->mv[0][0][0] = s->mv[0][0][1] = 0;
s->last_mv[0][0][0] = s->last_mv[0][0][1] = 0;
s->last_mv[0][1][0] = s->last_mv[0][1][1] = 0;
s->field_select[0][0] = (s->picture_structure - 1) & 1;
} else {
s->mv[0][0][0] = s->last_mv[0][0][0];
s->mv[0][0][1] = s->last_mv[0][0][1];
s->mv[1][0][0] = s->last_mv[1][0][0];
s->mv[1][0][1] = s->last_mv[1][0][1];
}
}
}
}
eos:
*buf += (get_bits_count(&s->gb) - 1) / 8;
ff_dlog(s, "y %d %d %d %d\n", s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y);
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(MpegEncContext *VAR_0, int VAR_1,
const uint8_t **VAR_2, int VAR_3)
{
AVCodecContext *avctx = VAR_0->avctx;
const int VAR_4 = VAR_0->picture_structure != PICT_FRAME;
int VAR_5;
VAR_0->resync_mb_x =
VAR_0->resync_mb_y = -1;
assert(VAR_1 < VAR_0->mb_height);
init_get_bits(&VAR_0->gb, *VAR_2, VAR_3 * 8);
ff_mpeg1_clean_buffers(VAR_0);
VAR_0->interlaced_dct = 0;
VAR_0->qscale = get_qscale(VAR_0);
if (VAR_0->qscale == 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "qscale == 0\n");
return AVERROR_INVALIDDATA;
}
while (get_bits1(&VAR_0->gb) != 0)
skip_bits(&VAR_0->gb, 8);
VAR_0->mb_x = 0;
if (VAR_1 == 0 && VAR_0->codec_tag == AV_RL32("SLIF")) {
skip_bits1(&VAR_0->gb);
} else {
while (get_bits_left(&VAR_0->gb) > 0) {
int VAR_19 = get_vlc2(&VAR_0->gb, ff_mbincr_vlc.table,
MBINCR_VLC_BITS, 2);
if (VAR_19 < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "first mb_incr damaged\n");
return AVERROR_INVALIDDATA;
}
if (VAR_19 >= 33) {
if (VAR_19 == 33)
VAR_0->mb_x += 33;
} else {
VAR_0->mb_x += VAR_19;
break;
}
}
}
if (VAR_0->mb_x >= (unsigned) VAR_0->mb_width) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "initial skip overflow\n");
return AVERROR_INVALIDDATA;
}
if (avctx->hwaccel) {
const uint8_t *VAR_7, *buf_start = *VAR_2 - 4;
int VAR_8 = -1;
VAR_7 = avpriv_find_start_code(buf_start + 2, *VAR_2 + VAR_3, &VAR_8);
if (VAR_7 < *VAR_2 + VAR_3)
VAR_7 -= 4;
VAR_0->VAR_1 = VAR_1;
if (avctx->hwaccel->decode_slice(avctx, buf_start, VAR_7 - buf_start) < 0)
return DECODE_SLICE_ERROR;
*VAR_2 = VAR_7;
return DECODE_SLICE_OK;
}
VAR_0->resync_mb_x = VAR_0->mb_x;
VAR_0->resync_mb_y = VAR_0->VAR_1 = VAR_1;
VAR_0->mb_skip_run = 0;
ff_init_block_index(VAR_0);
if (VAR_0->VAR_1 == 0 && VAR_0->mb_x == 0 && (VAR_0->first_field || VAR_0->picture_structure == PICT_FRAME)) {
if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) {
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"qp:%d fc:%2d%2d%2d%2d %VAR_0 %VAR_0 %VAR_0 %VAR_0 %VAR_0 dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %VAR_0\n",
VAR_0->qscale,
VAR_0->mpeg_f_code[0][0], VAR_0->mpeg_f_code[0][1],
VAR_0->mpeg_f_code[1][0], VAR_0->mpeg_f_code[1][1],
VAR_0->pict_type == AV_PICTURE_TYPE_I ? "I" :
(VAR_0->pict_type == AV_PICTURE_TYPE_P ? "P" :
(VAR_0->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")),
VAR_0->progressive_sequence ? "ps" : "",
VAR_0->progressive_frame ? "pf" : "",
VAR_0->alternate_scan ? "alt" : "",
VAR_0->top_field_first ? "top" : "",
VAR_0->intra_dc_precision, VAR_0->picture_structure,
VAR_0->frame_pred_frame_dct, VAR_0->concealment_motion_vectors,
VAR_0->q_scale_type, VAR_0->intra_vlc_format,
VAR_0->repeat_first_field, VAR_0->chroma_420_type ? "420" : "");
}
}
for (;;) {
#if FF_API_XVMC
FF_DISABLE_DEPRECATION_WARNINGS
if (CONFIG_MPEG_XVMC_DECODER && VAR_0->avctx->xvmc_acceleration > 1)
ff_xvmc_init_block(VAR_0);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if ((VAR_5 = mpeg_decode_mb(VAR_0, VAR_0->block)) < 0)
return VAR_5;
if (VAR_0->current_picture.motion_val[0] && !VAR_0->encoding) {
const int VAR_9 = VAR_0->b8_stride;
int VAR_10 = VAR_0->mb_x * 2 + VAR_0->VAR_1 * 2 * VAR_9;
int VAR_11 = 4 * (VAR_0->mb_x + VAR_0->VAR_1 * VAR_0->mb_stride);
int VAR_12, VAR_13, VAR_14, VAR_19;
for (VAR_19 = 0; VAR_19 < 2; VAR_19++) {
for (VAR_14 = 0; VAR_14 < 2; VAR_14++) {
if (VAR_0->mb_intra ||
(VAR_14 == 1 && VAR_0->pict_type != AV_PICTURE_TYPE_B)) {
VAR_12 = VAR_13 = 0;
} else if (VAR_0->mv_type == MV_TYPE_16X16 ||
(VAR_0->mv_type == MV_TYPE_FIELD && VAR_4)) {
VAR_12 = VAR_0->mv[VAR_14][0][0];
VAR_13 = VAR_0->mv[VAR_14][0][1];
} else {
VAR_12 = VAR_0->mv[VAR_14][VAR_19][0];
VAR_13 = VAR_0->mv[VAR_14][VAR_19][1];
}
VAR_0->current_picture.motion_val[VAR_14][VAR_10][0] = VAR_12;
VAR_0->current_picture.motion_val[VAR_14][VAR_10][1] = VAR_13;
VAR_0->current_picture.motion_val[VAR_14][VAR_10 + 1][0] = VAR_12;
VAR_0->current_picture.motion_val[VAR_14][VAR_10 + 1][1] = VAR_13;
VAR_0->current_picture.ref_index [VAR_14][VAR_11] =
VAR_0->current_picture.ref_index [VAR_14][VAR_11 + 1] = VAR_0->field_select[VAR_14][VAR_19];
assert(VAR_0->field_select[VAR_14][VAR_19] == 0 ||
VAR_0->field_select[VAR_14][VAR_19] == 1);
}
VAR_10 += VAR_9;
VAR_11 += 2;
}
}
VAR_0->dest[0] += 16;
VAR_0->dest[1] += 16 >> VAR_0->chroma_x_shift;
VAR_0->dest[2] += 16 >> VAR_0->chroma_x_shift;
ff_mpv_decode_mb(VAR_0, VAR_0->block);
if (++VAR_0->mb_x >= VAR_0->mb_width) {
const int VAR_16 = 16;
ff_mpeg_draw_horiz_band(VAR_0, VAR_16 * (VAR_0->VAR_1 >> VAR_4), VAR_16);
ff_mpv_report_decode_progress(VAR_0);
VAR_0->mb_x = 0;
VAR_0->VAR_1 += 1 << VAR_4;
if (VAR_0->VAR_1 >= VAR_0->mb_height) {
int VAR_17 = get_bits_left(&VAR_0->gb);
int VAR_18 = VAR_0->chroma_format == 2 &&
VAR_0->pict_type == AV_PICTURE_TYPE_I &&
avctx->profile == 0 && avctx->level == 5 &&
VAR_0->intra_dc_precision == 2 &&
VAR_0->q_scale_type == 1 && VAR_0->alternate_scan == 0 &&
VAR_0->progressive_frame == 0
;
if (VAR_17 < 0 ||
(VAR_17 && show_bits(&VAR_0->gb, FFMIN(VAR_17, 23)) && !VAR_18) ||
((avctx->err_recognition & AV_EF_BUFFER) && VAR_17 > 8)) {
av_log(avctx, AV_LOG_ERROR, "end mismatch VAR_17=%d %0X\n",
VAR_17, show_bits(&VAR_0->gb, FFMIN(VAR_17, 23)));
return AVERROR_INVALIDDATA;
} else
goto eos;
}
ff_init_block_index(VAR_0);
}
if (VAR_0->mb_skip_run == -1) {
VAR_0->mb_skip_run = 0;
for (;;) {
int VAR_19 = get_vlc2(&VAR_0->gb, ff_mbincr_vlc.table,
MBINCR_VLC_BITS, 2);
if (VAR_19 < 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "mb incr damaged\n");
return AVERROR_INVALIDDATA;
}
if (VAR_19 >= 33) {
if (VAR_19 == 33) {
VAR_0->mb_skip_run += 33;
} else if (VAR_19 == 35) {
if (VAR_0->mb_skip_run != 0 || show_bits(&VAR_0->gb, 15) != 0) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "slice mismatch\n");
return AVERROR_INVALIDDATA;
}
goto eos;
}
} else {
VAR_0->mb_skip_run += VAR_19;
break;
}
}
if (VAR_0->mb_skip_run) {
int VAR_19;
if (VAR_0->pict_type == AV_PICTURE_TYPE_I) {
av_log(VAR_0->avctx, AV_LOG_ERROR,
"skipped MB in I-frame at %d %d\n", VAR_0->mb_x, VAR_0->VAR_1);
return AVERROR_INVALIDDATA;
}
VAR_0->mb_intra = 0;
for (VAR_19 = 0; VAR_19 < 12; VAR_19++)
VAR_0->block_last_index[VAR_19] = -1;
if (VAR_0->picture_structure == PICT_FRAME)
VAR_0->mv_type = MV_TYPE_16X16;
else
VAR_0->mv_type = MV_TYPE_FIELD;
if (VAR_0->pict_type == AV_PICTURE_TYPE_P) {
VAR_0->mv_dir = MV_DIR_FORWARD;
VAR_0->mv[0][0][0] = VAR_0->mv[0][0][1] = 0;
VAR_0->last_mv[0][0][0] = VAR_0->last_mv[0][0][1] = 0;
VAR_0->last_mv[0][1][0] = VAR_0->last_mv[0][1][1] = 0;
VAR_0->field_select[0][0] = (VAR_0->picture_structure - 1) & 1;
} else {
VAR_0->mv[0][0][0] = VAR_0->last_mv[0][0][0];
VAR_0->mv[0][0][1] = VAR_0->last_mv[0][0][1];
VAR_0->mv[1][0][0] = VAR_0->last_mv[1][0][0];
VAR_0->mv[1][0][1] = VAR_0->last_mv[1][0][1];
}
}
}
}
eos:
*VAR_2 += (get_bits_count(&VAR_0->gb) - 1) / 8;
ff_dlog(VAR_0, "y %d %d %d %d\n", VAR_0->resync_mb_x, VAR_0->resync_mb_y, VAR_0->mb_x, VAR_0->VAR_1);
return 0;
}
| [
"static int FUNC_0(MpegEncContext *VAR_0, int VAR_1,\nconst uint8_t **VAR_2, int VAR_3)\n{",
"AVCodecContext *avctx = VAR_0->avctx;",
"const int VAR_4 = VAR_0->picture_structure != PICT_FRAME;",
"int VAR_5;",
"VAR_0->resync_mb_x =\nVAR_0->resync_mb_y = -1;",
"assert(VAR_1 < VAR_0->mb_height);",
"init_get_bits(&VAR_0->gb, *VAR_2, VAR_3 * 8);",
"ff_mpeg1_clean_buffers(VAR_0);",
"VAR_0->interlaced_dct = 0;",
"VAR_0->qscale = get_qscale(VAR_0);",
"if (VAR_0->qscale == 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"qscale == 0\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"while (get_bits1(&VAR_0->gb) != 0)\nskip_bits(&VAR_0->gb, 8);",
"VAR_0->mb_x = 0;",
"if (VAR_1 == 0 && VAR_0->codec_tag == AV_RL32(\"SLIF\")) {",
"skip_bits1(&VAR_0->gb);",
"} else {",
"while (get_bits_left(&VAR_0->gb) > 0) {",
"int VAR_19 = get_vlc2(&VAR_0->gb, ff_mbincr_vlc.table,\nMBINCR_VLC_BITS, 2);",
"if (VAR_19 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"first mb_incr damaged\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_19 >= 33) {",
"if (VAR_19 == 33)\nVAR_0->mb_x += 33;",
"} else {",
"VAR_0->mb_x += VAR_19;",
"break;",
"}",
"}",
"}",
"if (VAR_0->mb_x >= (unsigned) VAR_0->mb_width) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"initial skip overflow\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (avctx->hwaccel) {",
"const uint8_t *VAR_7, *buf_start = *VAR_2 - 4;",
"int VAR_8 = -1;",
"VAR_7 = avpriv_find_start_code(buf_start + 2, *VAR_2 + VAR_3, &VAR_8);",
"if (VAR_7 < *VAR_2 + VAR_3)\nVAR_7 -= 4;",
"VAR_0->VAR_1 = VAR_1;",
"if (avctx->hwaccel->decode_slice(avctx, buf_start, VAR_7 - buf_start) < 0)\nreturn DECODE_SLICE_ERROR;",
"*VAR_2 = VAR_7;",
"return DECODE_SLICE_OK;",
"}",
"VAR_0->resync_mb_x = VAR_0->mb_x;",
"VAR_0->resync_mb_y = VAR_0->VAR_1 = VAR_1;",
"VAR_0->mb_skip_run = 0;",
"ff_init_block_index(VAR_0);",
"if (VAR_0->VAR_1 == 0 && VAR_0->mb_x == 0 && (VAR_0->first_field || VAR_0->picture_structure == PICT_FRAME)) {",
"if (VAR_0->avctx->debug & FF_DEBUG_PICT_INFO) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"qp:%d fc:%2d%2d%2d%2d %VAR_0 %VAR_0 %VAR_0 %VAR_0 %VAR_0 dc:%d pstruct:%d fdct:%d cmv:%d qtype:%d ivlc:%d rff:%d %VAR_0\\n\",\nVAR_0->qscale,\nVAR_0->mpeg_f_code[0][0], VAR_0->mpeg_f_code[0][1],\nVAR_0->mpeg_f_code[1][0], VAR_0->mpeg_f_code[1][1],\nVAR_0->pict_type == AV_PICTURE_TYPE_I ? \"I\" :\n(VAR_0->pict_type == AV_PICTURE_TYPE_P ? \"P\" :\n(VAR_0->pict_type == AV_PICTURE_TYPE_B ? \"B\" : \"S\")),\nVAR_0->progressive_sequence ? \"ps\" : \"\",\nVAR_0->progressive_frame ? \"pf\" : \"\",\nVAR_0->alternate_scan ? \"alt\" : \"\",\nVAR_0->top_field_first ? \"top\" : \"\",\nVAR_0->intra_dc_precision, VAR_0->picture_structure,\nVAR_0->frame_pred_frame_dct, VAR_0->concealment_motion_vectors,\nVAR_0->q_scale_type, VAR_0->intra_vlc_format,\nVAR_0->repeat_first_field, VAR_0->chroma_420_type ? \"420\" : \"\");",
"}",
"}",
"for (;;) {",
"#if FF_API_XVMC\nFF_DISABLE_DEPRECATION_WARNINGS\nif (CONFIG_MPEG_XVMC_DECODER && VAR_0->avctx->xvmc_acceleration > 1)\nff_xvmc_init_block(VAR_0);",
"FF_ENABLE_DEPRECATION_WARNINGS\n#endif\nif ((VAR_5 = mpeg_decode_mb(VAR_0, VAR_0->block)) < 0)\nreturn VAR_5;",
"if (VAR_0->current_picture.motion_val[0] && !VAR_0->encoding) {",
"const int VAR_9 = VAR_0->b8_stride;",
"int VAR_10 = VAR_0->mb_x * 2 + VAR_0->VAR_1 * 2 * VAR_9;",
"int VAR_11 = 4 * (VAR_0->mb_x + VAR_0->VAR_1 * VAR_0->mb_stride);",
"int VAR_12, VAR_13, VAR_14, VAR_19;",
"for (VAR_19 = 0; VAR_19 < 2; VAR_19++) {",
"for (VAR_14 = 0; VAR_14 < 2; VAR_14++) {",
"if (VAR_0->mb_intra ||\n(VAR_14 == 1 && VAR_0->pict_type != AV_PICTURE_TYPE_B)) {",
"VAR_12 = VAR_13 = 0;",
"} else if (VAR_0->mv_type == MV_TYPE_16X16 ||",
"(VAR_0->mv_type == MV_TYPE_FIELD && VAR_4)) {",
"VAR_12 = VAR_0->mv[VAR_14][0][0];",
"VAR_13 = VAR_0->mv[VAR_14][0][1];",
"} else {",
"VAR_12 = VAR_0->mv[VAR_14][VAR_19][0];",
"VAR_13 = VAR_0->mv[VAR_14][VAR_19][1];",
"}",
"VAR_0->current_picture.motion_val[VAR_14][VAR_10][0] = VAR_12;",
"VAR_0->current_picture.motion_val[VAR_14][VAR_10][1] = VAR_13;",
"VAR_0->current_picture.motion_val[VAR_14][VAR_10 + 1][0] = VAR_12;",
"VAR_0->current_picture.motion_val[VAR_14][VAR_10 + 1][1] = VAR_13;",
"VAR_0->current_picture.ref_index [VAR_14][VAR_11] =\nVAR_0->current_picture.ref_index [VAR_14][VAR_11 + 1] = VAR_0->field_select[VAR_14][VAR_19];",
"assert(VAR_0->field_select[VAR_14][VAR_19] == 0 ||\nVAR_0->field_select[VAR_14][VAR_19] == 1);",
"}",
"VAR_10 += VAR_9;",
"VAR_11 += 2;",
"}",
"}",
"VAR_0->dest[0] += 16;",
"VAR_0->dest[1] += 16 >> VAR_0->chroma_x_shift;",
"VAR_0->dest[2] += 16 >> VAR_0->chroma_x_shift;",
"ff_mpv_decode_mb(VAR_0, VAR_0->block);",
"if (++VAR_0->mb_x >= VAR_0->mb_width) {",
"const int VAR_16 = 16;",
"ff_mpeg_draw_horiz_band(VAR_0, VAR_16 * (VAR_0->VAR_1 >> VAR_4), VAR_16);",
"ff_mpv_report_decode_progress(VAR_0);",
"VAR_0->mb_x = 0;",
"VAR_0->VAR_1 += 1 << VAR_4;",
"if (VAR_0->VAR_1 >= VAR_0->mb_height) {",
"int VAR_17 = get_bits_left(&VAR_0->gb);",
"int VAR_18 = VAR_0->chroma_format == 2 &&\nVAR_0->pict_type == AV_PICTURE_TYPE_I &&\navctx->profile == 0 && avctx->level == 5 &&\nVAR_0->intra_dc_precision == 2 &&\nVAR_0->q_scale_type == 1 && VAR_0->alternate_scan == 0 &&\nVAR_0->progressive_frame == 0\n;",
"if (VAR_17 < 0 ||\n(VAR_17 && show_bits(&VAR_0->gb, FFMIN(VAR_17, 23)) && !VAR_18) ||\n((avctx->err_recognition & AV_EF_BUFFER) && VAR_17 > 8)) {",
"av_log(avctx, AV_LOG_ERROR, \"end mismatch VAR_17=%d %0X\\n\",\nVAR_17, show_bits(&VAR_0->gb, FFMIN(VAR_17, 23)));",
"return AVERROR_INVALIDDATA;",
"} else",
"goto eos;",
"}",
"ff_init_block_index(VAR_0);",
"}",
"if (VAR_0->mb_skip_run == -1) {",
"VAR_0->mb_skip_run = 0;",
"for (;;) {",
"int VAR_19 = get_vlc2(&VAR_0->gb, ff_mbincr_vlc.table,\nMBINCR_VLC_BITS, 2);",
"if (VAR_19 < 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"mb incr damaged\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"if (VAR_19 >= 33) {",
"if (VAR_19 == 33) {",
"VAR_0->mb_skip_run += 33;",
"} else if (VAR_19 == 35) {",
"if (VAR_0->mb_skip_run != 0 || show_bits(&VAR_0->gb, 15) != 0) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"slice mismatch\\n\");",
"return AVERROR_INVALIDDATA;",
"}",
"goto eos;",
"}",
"} else {",
"VAR_0->mb_skip_run += VAR_19;",
"break;",
"}",
"}",
"if (VAR_0->mb_skip_run) {",
"int VAR_19;",
"if (VAR_0->pict_type == AV_PICTURE_TYPE_I) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"skipped MB in I-frame at %d %d\\n\", VAR_0->mb_x, VAR_0->VAR_1);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_0->mb_intra = 0;",
"for (VAR_19 = 0; VAR_19 < 12; VAR_19++)",
"VAR_0->block_last_index[VAR_19] = -1;",
"if (VAR_0->picture_structure == PICT_FRAME)\nVAR_0->mv_type = MV_TYPE_16X16;",
"else\nVAR_0->mv_type = MV_TYPE_FIELD;",
"if (VAR_0->pict_type == AV_PICTURE_TYPE_P) {",
"VAR_0->mv_dir = MV_DIR_FORWARD;",
"VAR_0->mv[0][0][0] = VAR_0->mv[0][0][1] = 0;",
"VAR_0->last_mv[0][0][0] = VAR_0->last_mv[0][0][1] = 0;",
"VAR_0->last_mv[0][1][0] = VAR_0->last_mv[0][1][1] = 0;",
"VAR_0->field_select[0][0] = (VAR_0->picture_structure - 1) & 1;",
"} else {",
"VAR_0->mv[0][0][0] = VAR_0->last_mv[0][0][0];",
"VAR_0->mv[0][0][1] = VAR_0->last_mv[0][0][1];",
"VAR_0->mv[1][0][0] = VAR_0->last_mv[1][0][0];",
"VAR_0->mv[1][0][1] = VAR_0->last_mv[1][0][1];",
"}",
"}",
"}",
"}",
"eos:\n*VAR_2 += (get_bits_count(&VAR_0->gb) - 1) / 8;",
"ff_dlog(VAR_0, \"y %d %d %d %d\\n\", VAR_0->resync_mb_x, VAR_0->resync_mb_y, VAR_0->mb_x, VAR_0->VAR_1);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
15,
17
],
[
21
],
[
25
],
[
29
],
[
31
],
[
35
],
[
39
],
[
41
],
[
43
],
[
45
],
[
51,
53
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
109
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123
],
[
125
],
[
127,
129
],
[
131
],
[
133
],
[
135
],
[
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
151
],
[
153,
155,
157,
159,
161,
163,
165,
167,
169,
171,
173,
175,
177,
179,
181,
183
],
[
185
],
[
187
],
[
191
],
[
193,
195,
199,
201
],
[
203,
205,
209,
211
],
[
217
],
[
219
],
[
221
],
[
223
],
[
225
],
[
229
],
[
231
],
[
233,
235
],
[
237
],
[
239
],
[
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265,
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
285
],
[
287
],
[
289
],
[
293
],
[
297
],
[
299
],
[
303
],
[
305
],
[
309
],
[
311
],
[
315
],
[
317
],
[
319,
321,
323,
325,
327,
329,
331
],
[
335,
337,
339
],
[
341,
343
],
[
345
],
[
347
],
[
349
],
[
351
],
[
355
],
[
357
],
[
363
],
[
367
],
[
369
],
[
371,
373
],
[
375
],
[
377
],
[
379
],
[
381
],
[
383
],
[
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421,
423
],
[
425
],
[
427
],
[
433
],
[
435
],
[
437
],
[
439,
441
],
[
443,
445
],
[
447
],
[
451
],
[
453
],
[
455
],
[
457
],
[
459
],
[
461
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481,
483
],
[
485
],
[
487
],
[
489
]
] |
25,052 | create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)
{
size_t *sizes = calloc(nr_iov, sizeof(size_t));
size_t count = 0;
void *buf, *p;
int i;
for (i = 0; i < nr_iov; i++) {
char *arg = argv[i];
long long len;
len = cvtnum(arg);
if (len < 0) {
printf("non-numeric length argument -- %s\n", arg);
return NULL;
}
/* should be SIZE_T_MAX, but that doesn't exist */
if (len > UINT_MAX) {
printf("too large length argument -- %s\n", arg);
return NULL;
}
if (len & 0x1ff) {
printf("length argument %lld is not sector aligned\n",
len);
return NULL;
}
sizes[i] = len;
count += len;
}
qemu_iovec_init(qiov, nr_iov);
buf = p = qemu_io_alloc(count, pattern);
for (i = 0; i < nr_iov; i++) {
qemu_iovec_add(qiov, p, sizes[i]);
p += sizes[i];
}
free(sizes);
return buf;
}
| true | qemu | 40a0d7c395f4d18a8061ba075d8f9aab2fa0ec2a | create_iovec(QEMUIOVector *qiov, char **argv, int nr_iov, int pattern)
{
size_t *sizes = calloc(nr_iov, sizeof(size_t));
size_t count = 0;
void *buf, *p;
int i;
for (i = 0; i < nr_iov; i++) {
char *arg = argv[i];
long long len;
len = cvtnum(arg);
if (len < 0) {
printf("non-numeric length argument -- %s\n", arg);
return NULL;
}
if (len > UINT_MAX) {
printf("too large length argument -- %s\n", arg);
return NULL;
}
if (len & 0x1ff) {
printf("length argument %lld is not sector aligned\n",
len);
return NULL;
}
sizes[i] = len;
count += len;
}
qemu_iovec_init(qiov, nr_iov);
buf = p = qemu_io_alloc(count, pattern);
for (i = 0; i < nr_iov; i++) {
qemu_iovec_add(qiov, p, sizes[i]);
p += sizes[i];
}
free(sizes);
return buf;
}
| {
"code": [
"\tvoid *buf, *p;",
"\t\t\treturn NULL;",
"\t\t\treturn NULL;",
"\t\t\treturn NULL;"
],
"line_no": [
9,
29,
29,
29
]
} | FUNC_0(QEMUIOVector *VAR_0, char **VAR_1, int VAR_2, int VAR_3)
{
size_t *sizes = calloc(VAR_2, sizeof(size_t));
size_t count = 0;
void *VAR_4, *VAR_5;
int VAR_6;
for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {
char *VAR_7 = VAR_1[VAR_6];
long long VAR_8;
VAR_8 = cvtnum(VAR_7);
if (VAR_8 < 0) {
printf("non-numeric length argument -- %s\n", VAR_7);
return NULL;
}
if (VAR_8 > UINT_MAX) {
printf("too large length argument -- %s\n", VAR_7);
return NULL;
}
if (VAR_8 & 0x1ff) {
printf("length argument %lld is not sector aligned\n",
VAR_8);
return NULL;
}
sizes[VAR_6] = VAR_8;
count += VAR_8;
}
qemu_iovec_init(VAR_0, VAR_2);
VAR_4 = VAR_5 = qemu_io_alloc(count, VAR_3);
for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {
qemu_iovec_add(VAR_0, VAR_5, sizes[VAR_6]);
VAR_5 += sizes[VAR_6];
}
free(sizes);
return VAR_4;
}
| [
"FUNC_0(QEMUIOVector *VAR_0, char **VAR_1, int VAR_2, int VAR_3)\n{",
"size_t *sizes = calloc(VAR_2, sizeof(size_t));",
"size_t count = 0;",
"void *VAR_4, *VAR_5;",
"int VAR_6;",
"for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {",
"char *VAR_7 = VAR_1[VAR_6];",
"long long VAR_8;",
"VAR_8 = cvtnum(VAR_7);",
"if (VAR_8 < 0) {",
"printf(\"non-numeric length argument -- %s\\n\", VAR_7);",
"return NULL;",
"}",
"if (VAR_8 > UINT_MAX) {",
"printf(\"too large length argument -- %s\\n\", VAR_7);",
"return NULL;",
"}",
"if (VAR_8 & 0x1ff) {",
"printf(\"length argument %lld is not sector aligned\\n\",\nVAR_8);",
"return NULL;",
"}",
"sizes[VAR_6] = VAR_8;",
"count += VAR_8;",
"}",
"qemu_iovec_init(VAR_0, VAR_2);",
"VAR_4 = VAR_5 = qemu_io_alloc(count, VAR_3);",
"for (VAR_6 = 0; VAR_6 < VAR_2; VAR_6++) {",
"qemu_iovec_add(VAR_0, VAR_5, sizes[VAR_6]);",
"VAR_5 += sizes[VAR_6];",
"}",
"free(sizes);",
"return VAR_4;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49,
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
67
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
]
] |
25,053 | static int vid_probe(AVProbeData *p)
{
// little-endian VID tag, file starts with "VID\0"
if (AV_RL32(p->buf) != MKTAG('V', 'I', 'D', 0))
return 0;
return AVPROBE_SCORE_MAX;
} | true | FFmpeg | f66f3819b96847cd28589b718dbcd03b782e7a5c | static int vid_probe(AVProbeData *p)
{
if (AV_RL32(p->buf) != MKTAG('V', 'I', 'D', 0))
return 0;
return AVPROBE_SCORE_MAX;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
if (AV_RL32(VAR_0->buf) != MKTAG('V', 'I', 'D', 0))
return 0;
return AVPROBE_SCORE_MAX;
} | [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"if (AV_RL32(VAR_0->buf) != MKTAG('V', 'I', 'D', 0))\nreturn 0;",
"return AVPROBE_SCORE_MAX;",
"}"
] | [
0,
0,
0,
0
] | [
[
1,
2
],
[
4,
5
],
[
6
],
[
7
]
] |
25,054 | void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
int i;
for (i = 0; ; i++) {
(*cpu_fprintf)(f, "PowerPC %-16s PVR %08x\n",
ppc_defs[i].name, ppc_defs[i].pvr);
if (strcmp(ppc_defs[i].name, "default") == 0)
break;
}
}
| true | qemu | 068abdc8a57023eeafe1025b964a50f8a39929b4 | void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
{
int i;
for (i = 0; ; i++) {
(*cpu_fprintf)(f, "PowerPC %-16s PVR %08x\n",
ppc_defs[i].name, ppc_defs[i].pvr);
if (strcmp(ppc_defs[i].name, "default") == 0)
break;
}
}
| {
"code": [
" int i;",
" for (i = 0; ; i++) {",
" if (strcmp(ppc_defs[i].name, \"default\") == 0)",
" break;"
],
"line_no": [
5,
9,
15,
17
]
} | void FUNC_0 (FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))
{
int VAR_3;
for (VAR_3 = 0; ; VAR_3++) {
(*VAR_1)(VAR_2, "PowerPC %-16s PVR %08x\n",
ppc_defs[VAR_3].name, ppc_defs[VAR_3].pvr);
if (strcmp(ppc_defs[VAR_3].name, "default") == 0)
break;
}
}
| [
"void FUNC_0 (FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))\n{",
"int VAR_3;",
"for (VAR_3 = 0; ; VAR_3++) {",
"(*VAR_1)(VAR_2, \"PowerPC %-16s PVR %08x\\n\",\nppc_defs[VAR_3].name, ppc_defs[VAR_3].pvr);",
"if (strcmp(ppc_defs[VAR_3].name, \"default\") == 0)\nbreak;",
"}",
"}"
] | [
0,
1,
1,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
21
]
] |
25,055 | void object_delete(Object *obj)
{
object_unparent(obj);
g_assert(obj->ref == 1);
object_unref(obj);
g_free(obj);
}
| true | qemu | fde9bf4470d4a3b6ee1da0dee2370ab028b6314a | void object_delete(Object *obj)
{
object_unparent(obj);
g_assert(obj->ref == 1);
object_unref(obj);
g_free(obj);
}
| {
"code": [
" g_free(obj);"
],
"line_no": [
11
]
} | void FUNC_0(Object *VAR_0)
{
object_unparent(VAR_0);
g_assert(VAR_0->ref == 1);
object_unref(VAR_0);
g_free(VAR_0);
}
| [
"void FUNC_0(Object *VAR_0)\n{",
"object_unparent(VAR_0);",
"g_assert(VAR_0->ref == 1);",
"object_unref(VAR_0);",
"g_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
1,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
]
] |
25,056 | static int mpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
uint8_t *buf_end, *buf_ptr;
int ret, start_code, input_size;
AVFrame *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
dprintf("fill_buffer\n");
*data_size = 0;
/* special case for last picture */
if (buf_size == 0) {
if (s2->picture_number > 0) {
*picture= *(AVFrame*)&s2->next_picture;
*data_size = sizeof(AVFrame);
}
return 0;
}
if(s2->flags&CODEC_FLAG_TRUNCATED){
int next;
next= mpeg1_find_frame_end(s2, buf, buf_size);
if( ff_combine_frame(s2, next, &buf, &buf_size) < 0 )
return buf_size;
}
buf_ptr = buf;
buf_end = buf + buf_size;
#if 0
if (s->repeat_field % 2 == 1) {
s->repeat_field++;
//fprintf(stderr,"\nRepeating last frame: %d -> %d! pict: %d %d", avctx->frame_number-1, avctx->frame_number,
// s2->picture_number, s->repeat_field);
if (avctx->flags & CODEC_FLAG_REPEAT_FIELD) {
*data_size = sizeof(AVPicture);
goto the_end;
}
}
#endif
for(;;) {
/* find start next code */
start_code = find_start_code(&buf_ptr, buf_end);
if (start_code < 0){
printf("missing end of picture\n");
return FFMAX(1, buf_ptr - buf - s2->parse_context.last_index);
}
/* prepare data for next start code */
input_size = buf_end - buf_ptr;
switch(start_code) {
case SEQ_START_CODE:
mpeg1_decode_sequence(avctx, buf_ptr,
input_size);
break;
case PICTURE_START_CODE:
/* we have a complete image : we try to decompress it */
mpeg1_decode_picture(avctx,
buf_ptr, input_size);
break;
case EXT_START_CODE:
mpeg_decode_extension(avctx,
buf_ptr, input_size);
break;
case USER_START_CODE:
mpeg_decode_user_data(avctx,
buf_ptr, input_size);
break;
default:
if (start_code >= SLICE_MIN_START_CODE &&
start_code <= SLICE_MAX_START_CODE) {
/* skip b frames if we dont have reference frames */
if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break;
/* skip b frames if we are in a hurry */
if(avctx->hurry_up && s2->pict_type==B_TYPE) break;
/* skip everything if we are in a hurry>=5 */
if(avctx->hurry_up>=5) break;
if (!s->mpeg_enc_ctx_allocated) break;
ret = mpeg_decode_slice(avctx, picture,
start_code, &buf_ptr, input_size);
if (ret == DECODE_SLICE_EOP) {
if(s2->last_picture_ptr) //FIXME merge with the stuff in mpeg_decode_slice
*data_size = sizeof(AVPicture);
return FFMAX(1, buf_ptr - buf - s2->parse_context.last_index);
}else if(ret < 0){
if(ret == DECODE_SLICE_ERROR)
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
fprintf(stderr,"Error while decoding slice\n");
if(ret==DECODE_SLICE_FATAL_ERROR) return -1;
}
}
break;
}
}
}
| false | FFmpeg | bb463d81020a2f3c5cf3403e18f980171773f48a | static int mpeg_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
Mpeg1Context *s = avctx->priv_data;
uint8_t *buf_end, *buf_ptr;
int ret, start_code, input_size;
AVFrame *picture = data;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
dprintf("fill_buffer\n");
*data_size = 0;
if (buf_size == 0) {
if (s2->picture_number > 0) {
*picture= *(AVFrame*)&s2->next_picture;
*data_size = sizeof(AVFrame);
}
return 0;
}
if(s2->flags&CODEC_FLAG_TRUNCATED){
int next;
next= mpeg1_find_frame_end(s2, buf, buf_size);
if( ff_combine_frame(s2, next, &buf, &buf_size) < 0 )
return buf_size;
}
buf_ptr = buf;
buf_end = buf + buf_size;
#if 0
if (s->repeat_field % 2 == 1) {
s->repeat_field++;
if (avctx->flags & CODEC_FLAG_REPEAT_FIELD) {
*data_size = sizeof(AVPicture);
goto the_end;
}
}
#endif
for(;;) {
start_code = find_start_code(&buf_ptr, buf_end);
if (start_code < 0){
printf("missing end of picture\n");
return FFMAX(1, buf_ptr - buf - s2->parse_context.last_index);
}
input_size = buf_end - buf_ptr;
switch(start_code) {
case SEQ_START_CODE:
mpeg1_decode_sequence(avctx, buf_ptr,
input_size);
break;
case PICTURE_START_CODE:
mpeg1_decode_picture(avctx,
buf_ptr, input_size);
break;
case EXT_START_CODE:
mpeg_decode_extension(avctx,
buf_ptr, input_size);
break;
case USER_START_CODE:
mpeg_decode_user_data(avctx,
buf_ptr, input_size);
break;
default:
if (start_code >= SLICE_MIN_START_CODE &&
start_code <= SLICE_MAX_START_CODE) {
if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break;
if(avctx->hurry_up && s2->pict_type==B_TYPE) break;
if(avctx->hurry_up>=5) break;
if (!s->mpeg_enc_ctx_allocated) break;
ret = mpeg_decode_slice(avctx, picture,
start_code, &buf_ptr, input_size);
if (ret == DECODE_SLICE_EOP) {
if(s2->last_picture_ptr)
*data_size = sizeof(AVPicture);
return FFMAX(1, buf_ptr - buf - s2->parse_context.last_index);
}else if(ret < 0){
if(ret == DECODE_SLICE_ERROR)
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
fprintf(stderr,"Error while decoding slice\n");
if(ret==DECODE_SLICE_FATAL_ERROR) return -1;
}
}
break;
}
}
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
Mpeg1Context *s = VAR_0->priv_data;
uint8_t *buf_end, *buf_ptr;
int VAR_5, VAR_6, VAR_7;
AVFrame *picture = VAR_1;
MpegEncContext *s2 = &s->mpeg_enc_ctx;
dprintf("fill_buffer\n");
*VAR_2 = 0;
if (VAR_4 == 0) {
if (s2->picture_number > 0) {
*picture= *(AVFrame*)&s2->next_picture;
*VAR_2 = sizeof(AVFrame);
}
return 0;
}
if(s2->flags&CODEC_FLAG_TRUNCATED){
int VAR_8;
VAR_8= mpeg1_find_frame_end(s2, VAR_3, VAR_4);
if( ff_combine_frame(s2, VAR_8, &VAR_3, &VAR_4) < 0 )
return VAR_4;
}
buf_ptr = VAR_3;
buf_end = VAR_3 + VAR_4;
#if 0
if (s->repeat_field % 2 == 1) {
s->repeat_field++;
if (VAR_0->flags & CODEC_FLAG_REPEAT_FIELD) {
*VAR_2 = sizeof(AVPicture);
goto the_end;
}
}
#endif
for(;;) {
VAR_6 = find_start_code(&buf_ptr, buf_end);
if (VAR_6 < 0){
printf("missing end of picture\n");
return FFMAX(1, buf_ptr - VAR_3 - s2->parse_context.last_index);
}
VAR_7 = buf_end - buf_ptr;
switch(VAR_6) {
case SEQ_START_CODE:
mpeg1_decode_sequence(VAR_0, buf_ptr,
VAR_7);
break;
case PICTURE_START_CODE:
mpeg1_decode_picture(VAR_0,
buf_ptr, VAR_7);
break;
case EXT_START_CODE:
mpeg_decode_extension(VAR_0,
buf_ptr, VAR_7);
break;
case USER_START_CODE:
mpeg_decode_user_data(VAR_0,
buf_ptr, VAR_7);
break;
default:
if (VAR_6 >= SLICE_MIN_START_CODE &&
VAR_6 <= SLICE_MAX_START_CODE) {
if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break;
if(VAR_0->hurry_up && s2->pict_type==B_TYPE) break;
if(VAR_0->hurry_up>=5) break;
if (!s->mpeg_enc_ctx_allocated) break;
VAR_5 = mpeg_decode_slice(VAR_0, picture,
VAR_6, &buf_ptr, VAR_7);
if (VAR_5 == DECODE_SLICE_EOP) {
if(s2->last_picture_ptr)
*VAR_2 = sizeof(AVPicture);
return FFMAX(1, buf_ptr - VAR_3 - s2->parse_context.last_index);
}else if(VAR_5 < 0){
if(VAR_5 == DECODE_SLICE_ERROR)
ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);
fprintf(stderr,"Error while decoding slice\n");
if(VAR_5==DECODE_SLICE_FATAL_ERROR) return -1;
}
}
break;
}
}
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"Mpeg1Context *s = VAR_0->priv_data;",
"uint8_t *buf_end, *buf_ptr;",
"int VAR_5, VAR_6, VAR_7;",
"AVFrame *picture = VAR_1;",
"MpegEncContext *s2 = &s->mpeg_enc_ctx;",
"dprintf(\"fill_buffer\\n\");",
"*VAR_2 = 0;",
"if (VAR_4 == 0) {",
"if (s2->picture_number > 0) {",
"*picture= *(AVFrame*)&s2->next_picture;",
"*VAR_2 = sizeof(AVFrame);",
"}",
"return 0;",
"}",
"if(s2->flags&CODEC_FLAG_TRUNCATED){",
"int VAR_8;",
"VAR_8= mpeg1_find_frame_end(s2, VAR_3, VAR_4);",
"if( ff_combine_frame(s2, VAR_8, &VAR_3, &VAR_4) < 0 )\nreturn VAR_4;",
"}",
"buf_ptr = VAR_3;",
"buf_end = VAR_3 + VAR_4;",
"#if 0\nif (s->repeat_field % 2 == 1) {",
"s->repeat_field++;",
"if (VAR_0->flags & CODEC_FLAG_REPEAT_FIELD) {",
"*VAR_2 = sizeof(AVPicture);",
"goto the_end;",
"}",
"}",
"#endif\nfor(;;) {",
"VAR_6 = find_start_code(&buf_ptr, buf_end);",
"if (VAR_6 < 0){",
"printf(\"missing end of picture\\n\");",
"return FFMAX(1, buf_ptr - VAR_3 - s2->parse_context.last_index);",
"}",
"VAR_7 = buf_end - buf_ptr;",
"switch(VAR_6) {",
"case SEQ_START_CODE:\nmpeg1_decode_sequence(VAR_0, buf_ptr,\nVAR_7);",
"break;",
"case PICTURE_START_CODE:\nmpeg1_decode_picture(VAR_0,\nbuf_ptr, VAR_7);",
"break;",
"case EXT_START_CODE:\nmpeg_decode_extension(VAR_0,\nbuf_ptr, VAR_7);",
"break;",
"case USER_START_CODE:\nmpeg_decode_user_data(VAR_0,\nbuf_ptr, VAR_7);",
"break;",
"default:\nif (VAR_6 >= SLICE_MIN_START_CODE &&\nVAR_6 <= SLICE_MAX_START_CODE) {",
"if(s2->last_picture_ptr==NULL && s2->pict_type==B_TYPE) break;",
"if(VAR_0->hurry_up && s2->pict_type==B_TYPE) break;",
"if(VAR_0->hurry_up>=5) break;",
"if (!s->mpeg_enc_ctx_allocated) break;",
"VAR_5 = mpeg_decode_slice(VAR_0, picture,\nVAR_6, &buf_ptr, VAR_7);",
"if (VAR_5 == DECODE_SLICE_EOP) {",
"if(s2->last_picture_ptr)\n*VAR_2 = sizeof(AVPicture);",
"return FFMAX(1, buf_ptr - VAR_3 - s2->parse_context.last_index);",
"}else if(VAR_5 < 0){",
"if(VAR_5 == DECODE_SLICE_ERROR)\nff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR|DC_ERROR|MV_ERROR);",
"fprintf(stderr,\"Error while decoding slice\\n\");",
"if(VAR_5==DECODE_SLICE_FATAL_ERROR) return -1;",
"}",
"}",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
53
],
[
57,
59
],
[
61
],
[
65
],
[
67
],
[
71,
73
],
[
75
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91,
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
111
],
[
113
],
[
115,
117,
119
],
[
121
],
[
125,
129,
131
],
[
133
],
[
135,
137,
139
],
[
141
],
[
143,
145,
147
],
[
149
],
[
151,
153,
155
],
[
161
],
[
165
],
[
169
],
[
173
],
[
177,
179
],
[
183
],
[
185,
187
],
[
189
],
[
191
],
[
193,
195
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
]
] |
25,057 | static struct scsi_task *iscsi_do_inquiry(struct iscsi_context *iscsi, int lun,
int evpd, int pc)
{
int full_size;
struct scsi_task *task = NULL;
task = iscsi_inquiry_sync(iscsi, lun, evpd, pc, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
goto fail;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
/* we need more data for the full list */
task = iscsi_inquiry_sync(iscsi, lun, evpd, pc, full_size);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
goto fail;
}
}
return task;
fail:
error_report("iSCSI: Inquiry command failed : %s",
iscsi_get_error(iscsi));
if (task) {
scsi_free_scsi_task(task);
return NULL;
}
return NULL;
}
| true | qemu | f2917853f715b0ef55df29eb2ffea29dc69ce814 | static struct scsi_task *iscsi_do_inquiry(struct iscsi_context *iscsi, int lun,
int evpd, int pc)
{
int full_size;
struct scsi_task *task = NULL;
task = iscsi_inquiry_sync(iscsi, lun, evpd, pc, 64);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
goto fail;
}
full_size = scsi_datain_getfullsize(task);
if (full_size > task->datain.size) {
scsi_free_scsi_task(task);
task = iscsi_inquiry_sync(iscsi, lun, evpd, pc, full_size);
if (task == NULL || task->status != SCSI_STATUS_GOOD) {
goto fail;
}
}
return task;
fail:
error_report("iSCSI: Inquiry command failed : %s",
iscsi_get_error(iscsi));
if (task) {
scsi_free_scsi_task(task);
return NULL;
}
return NULL;
}
| {
"code": [
" int evpd, int pc)",
" error_report(\"iSCSI: Inquiry command failed : %s\",",
" iscsi_get_error(iscsi));"
],
"line_no": [
3,
47,
49
]
} | static struct scsi_task *FUNC_0(struct iscsi_context *VAR_0, int VAR_1,
int VAR_2, int VAR_3)
{
int VAR_4;
struct scsi_task *VAR_5 = NULL;
VAR_5 = iscsi_inquiry_sync(VAR_0, VAR_1, VAR_2, VAR_3, 64);
if (VAR_5 == NULL || VAR_5->status != SCSI_STATUS_GOOD) {
goto fail;
}
VAR_4 = scsi_datain_getfullsize(VAR_5);
if (VAR_4 > VAR_5->datain.size) {
scsi_free_scsi_task(VAR_5);
VAR_5 = iscsi_inquiry_sync(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);
if (VAR_5 == NULL || VAR_5->status != SCSI_STATUS_GOOD) {
goto fail;
}
}
return VAR_5;
fail:
error_report("iSCSI: Inquiry command failed : %s",
iscsi_get_error(VAR_0));
if (VAR_5) {
scsi_free_scsi_task(VAR_5);
return NULL;
}
return NULL;
}
| [
"static struct scsi_task *FUNC_0(struct iscsi_context *VAR_0, int VAR_1,\nint VAR_2, int VAR_3)\n{",
"int VAR_4;",
"struct scsi_task *VAR_5 = NULL;",
"VAR_5 = iscsi_inquiry_sync(VAR_0, VAR_1, VAR_2, VAR_3, 64);",
"if (VAR_5 == NULL || VAR_5->status != SCSI_STATUS_GOOD) {",
"goto fail;",
"}",
"VAR_4 = scsi_datain_getfullsize(VAR_5);",
"if (VAR_4 > VAR_5->datain.size) {",
"scsi_free_scsi_task(VAR_5);",
"VAR_5 = iscsi_inquiry_sync(VAR_0, VAR_1, VAR_2, VAR_3, VAR_4);",
"if (VAR_5 == NULL || VAR_5->status != SCSI_STATUS_GOOD) {",
"goto fail;",
"}",
"}",
"return VAR_5;",
"fail:\nerror_report(\"iSCSI: Inquiry command failed : %s\",\niscsi_get_error(VAR_0));",
"if (VAR_5) {",
"scsi_free_scsi_task(VAR_5);",
"return NULL;",
"}",
"return NULL;",
"}"
] | [
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
45,
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
]
] |
25,059 | static target_ulong h_add_logical_lan_buffer(CPUPPCState *env,
sPAPREnvironment *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong reg = args[0];
target_ulong buf = args[1];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
vlan_bd_t bd;
dprintf("H_ADD_LOGICAL_LAN_BUFFER(0x" TARGET_FMT_lx
", 0x" TARGET_FMT_lx ")\n", reg, buf);
if (!sdev) {
hcall_dprintf("Bad device\n");
return H_PARAMETER;
}
if ((check_bd(dev, buf, 4) < 0)
|| (VLAN_BD_LEN(buf) < 16)) {
hcall_dprintf("Bad buffer enqueued\n");
return H_PARAMETER;
}
if (!dev->isopen || dev->rx_bufs >= VLAN_MAX_BUFS) {
return H_RESOURCE;
}
do {
dev->add_buf_ptr += 8;
if (dev->add_buf_ptr >= SPAPR_VIO_TCE_PAGE_SIZE) {
dev->add_buf_ptr = VLAN_RX_BDS_OFF;
}
bd = ldq_tce(sdev, dev->buf_list + dev->add_buf_ptr);
} while (bd & VLAN_BD_VALID);
stq_tce(sdev, dev->buf_list + dev->add_buf_ptr, buf);
dev->rx_bufs++;
dprintf("h_add_logical_lan_buffer(): Added buf ptr=%d rx_bufs=%d"
" bd=0x%016llx\n", dev->add_buf_ptr, dev->rx_bufs,
(unsigned long long)buf);
return H_SUCCESS;
}
| true | qemu | ad0ebb91cd8b5fdc4a583b03645677771f420a46 | static target_ulong h_add_logical_lan_buffer(CPUPPCState *env,
sPAPREnvironment *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong reg = args[0];
target_ulong buf = args[1];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
vlan_bd_t bd;
dprintf("H_ADD_LOGICAL_LAN_BUFFER(0x" TARGET_FMT_lx
", 0x" TARGET_FMT_lx ")\n", reg, buf);
if (!sdev) {
hcall_dprintf("Bad device\n");
return H_PARAMETER;
}
if ((check_bd(dev, buf, 4) < 0)
|| (VLAN_BD_LEN(buf) < 16)) {
hcall_dprintf("Bad buffer enqueued\n");
return H_PARAMETER;
}
if (!dev->isopen || dev->rx_bufs >= VLAN_MAX_BUFS) {
return H_RESOURCE;
}
do {
dev->add_buf_ptr += 8;
if (dev->add_buf_ptr >= SPAPR_VIO_TCE_PAGE_SIZE) {
dev->add_buf_ptr = VLAN_RX_BDS_OFF;
}
bd = ldq_tce(sdev, dev->buf_list + dev->add_buf_ptr);
} while (bd & VLAN_BD_VALID);
stq_tce(sdev, dev->buf_list + dev->add_buf_ptr, buf);
dev->rx_bufs++;
dprintf("h_add_logical_lan_buffer(): Added buf ptr=%d rx_bufs=%d"
" bd=0x%016llx\n", dev->add_buf_ptr, dev->rx_bufs,
(unsigned long long)buf);
return H_SUCCESS;
}
| {
"code": [
" if (dev->add_buf_ptr >= SPAPR_VIO_TCE_PAGE_SIZE) {",
" bd = ldq_tce(sdev, dev->buf_list + dev->add_buf_ptr);",
" stq_tce(sdev, dev->buf_list + dev->add_buf_ptr, buf);",
" return H_PARAMETER;",
" return H_PARAMETER;",
" return H_SUCCESS;",
" return H_SUCCESS;"
],
"line_no": [
63,
71,
77,
33,
33,
93,
93
]
} | static target_ulong FUNC_0(CPUPPCState *env,
sPAPREnvironment *spapr,
target_ulong opcode,
target_ulong *args)
{
target_ulong reg = args[0];
target_ulong buf = args[1];
VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);
VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;
vlan_bd_t bd;
dprintf("H_ADD_LOGICAL_LAN_BUFFER(0x" TARGET_FMT_lx
", 0x" TARGET_FMT_lx ")\n", reg, buf);
if (!sdev) {
hcall_dprintf("Bad device\n");
return H_PARAMETER;
}
if ((check_bd(dev, buf, 4) < 0)
|| (VLAN_BD_LEN(buf) < 16)) {
hcall_dprintf("Bad buffer enqueued\n");
return H_PARAMETER;
}
if (!dev->isopen || dev->rx_bufs >= VLAN_MAX_BUFS) {
return H_RESOURCE;
}
do {
dev->add_buf_ptr += 8;
if (dev->add_buf_ptr >= SPAPR_VIO_TCE_PAGE_SIZE) {
dev->add_buf_ptr = VLAN_RX_BDS_OFF;
}
bd = ldq_tce(sdev, dev->buf_list + dev->add_buf_ptr);
} while (bd & VLAN_BD_VALID);
stq_tce(sdev, dev->buf_list + dev->add_buf_ptr, buf);
dev->rx_bufs++;
dprintf("FUNC_0(): Added buf ptr=%d rx_bufs=%d"
" bd=0x%016llx\n", dev->add_buf_ptr, dev->rx_bufs,
(unsigned long long)buf);
return H_SUCCESS;
}
| [
"static target_ulong FUNC_0(CPUPPCState *env,\nsPAPREnvironment *spapr,\ntarget_ulong opcode,\ntarget_ulong *args)\n{",
"target_ulong reg = args[0];",
"target_ulong buf = args[1];",
"VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg);",
"VIOsPAPRVLANDevice *dev = (VIOsPAPRVLANDevice *)sdev;",
"vlan_bd_t bd;",
"dprintf(\"H_ADD_LOGICAL_LAN_BUFFER(0x\" TARGET_FMT_lx\n\", 0x\" TARGET_FMT_lx \")\\n\", reg, buf);",
"if (!sdev) {",
"hcall_dprintf(\"Bad device\\n\");",
"return H_PARAMETER;",
"}",
"if ((check_bd(dev, buf, 4) < 0)\n|| (VLAN_BD_LEN(buf) < 16)) {",
"hcall_dprintf(\"Bad buffer enqueued\\n\");",
"return H_PARAMETER;",
"}",
"if (!dev->isopen || dev->rx_bufs >= VLAN_MAX_BUFS) {",
"return H_RESOURCE;",
"}",
"do {",
"dev->add_buf_ptr += 8;",
"if (dev->add_buf_ptr >= SPAPR_VIO_TCE_PAGE_SIZE) {",
"dev->add_buf_ptr = VLAN_RX_BDS_OFF;",
"}",
"bd = ldq_tce(sdev, dev->buf_list + dev->add_buf_ptr);",
"} while (bd & VLAN_BD_VALID);",
"stq_tce(sdev, dev->buf_list + dev->add_buf_ptr, buf);",
"dev->rx_bufs++;",
"dprintf(\"FUNC_0(): Added buf ptr=%d rx_bufs=%d\"\n\" bd=0x%016llx\\n\", dev->add_buf_ptr, dev->rx_bufs,\n(unsigned long long)buf);",
"return H_SUCCESS;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
0,
1,
0,
0,
1,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
81
],
[
85,
87,
89
],
[
93
],
[
95
]
] |
25,060 | static uint32_t unassigned_mem_readw(void *opaque, target_phys_addr_t addr)
{
#ifdef DEBUG_UNASSIGNED
printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
#endif
#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
do_unassigned_access(addr, 0, 0, 0, 2);
#endif
return 0;
}
| true | qemu | b14ef7c9ab41ea824c3ccadb070ad95567cca84e | static uint32_t unassigned_mem_readw(void *opaque, target_phys_addr_t addr)
{
#ifdef DEBUG_UNASSIGNED
printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
#endif
#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
do_unassigned_access(addr, 0, 0, 0, 2);
#endif
return 0;
}
| {
"code": [
" do_unassigned_access(addr, 0, 0, 0, 2);"
],
"line_no": [
13
]
} | static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)
{
#ifdef DEBUG_UNASSIGNED
printf("Unassigned mem read " TARGET_FMT_plx "\n", addr);
#endif
#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)
do_unassigned_access(addr, 0, 0, 0, 2);
#endif
return 0;
}
| [
"static uint32_t FUNC_0(void *opaque, target_phys_addr_t addr)\n{",
"#ifdef DEBUG_UNASSIGNED\nprintf(\"Unassigned mem read \" TARGET_FMT_plx \"\\n\", addr);",
"#endif\n#if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE)\ndo_unassigned_access(addr, 0, 0, 0, 2);",
"#endif\nreturn 0;",
"}"
] | [
0,
0,
1,
0,
0
] | [
[
1,
3
],
[
5,
7
],
[
9,
11,
13
],
[
15,
17
],
[
19
]
] |
25,061 | static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
int n, c, sample_size, v, ret;
const short *samples;
unsigned char *dst;
const uint8_t *samples_uint8_t;
const int16_t *samples_int16_t;
const int32_t *samples_int32_t;
const int64_t *samples_int64_t;
const uint16_t *samples_uint16_t;
const uint32_t *samples_uint32_t;
sample_size = av_get_bits_per_sample(avctx->codec->id) / 8;
n = frame->nb_samples * avctx->channels;
samples = (const short *)frame->data[0];
if ((ret = ff_alloc_packet2(avctx, avpkt, n * sample_size)))
return ret;
dst = avpkt->data;
switch (avctx->codec->id) {
case AV_CODEC_ID_PCM_U32LE:
ENCODE(uint32_t, le32, samples, dst, n, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_U32BE:
ENCODE(uint32_t, be32, samples, dst, n, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_S24LE:
ENCODE(int32_t, le24, samples, dst, n, 8, 0)
break;
case AV_CODEC_ID_PCM_S24LE_PLANAR:
ENCODE_PLANAR(int32_t, le24, dst, n, 8, 0)
break;
case AV_CODEC_ID_PCM_S24BE:
ENCODE(int32_t, be24, samples, dst, n, 8, 0)
break;
case AV_CODEC_ID_PCM_U24LE:
ENCODE(uint32_t, le24, samples, dst, n, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_U24BE:
ENCODE(uint32_t, be24, samples, dst, n, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_S24DAUD:
for (; n > 0; n--) {
uint32_t tmp = ff_reverse[(*samples >> 8) & 0xff] +
(ff_reverse[*samples & 0xff] << 8);
tmp <<= 4; // sync flags would go here
bytestream_put_be24(&dst, tmp);
samples++;
}
break;
case AV_CODEC_ID_PCM_U16LE:
ENCODE(uint16_t, le16, samples, dst, n, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_U16BE:
ENCODE(uint16_t, be16, samples, dst, n, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_S8:
ENCODE(uint8_t, byte, samples, dst, n, 0, -128)
break;
case AV_CODEC_ID_PCM_S8_PLANAR:
ENCODE_PLANAR(uint8_t, byte, dst, n, 0, -128)
break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_F64LE:
ENCODE(int64_t, le64, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_F32LE:
ENCODE(int32_t, le32, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S32LE_PLANAR:
ENCODE_PLANAR(int32_t, le32, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE:
ENCODE(int16_t, le16, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE_PLANAR:
ENCODE_PLANAR(int16_t, le16, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
case AV_CODEC_ID_PCM_S16BE:
#else
case AV_CODEC_ID_PCM_F64BE:
ENCODE(int64_t, be64, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
ENCODE(int32_t, be32, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16BE:
ENCODE(int16_t, be16, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16BE_PLANAR:
ENCODE_PLANAR(int16_t, be16, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64LE:
case AV_CODEC_ID_PCM_F32LE:
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_S16LE:
#endif /* HAVE_BIGENDIAN */
case AV_CODEC_ID_PCM_U8:
memcpy(dst, samples, n * sample_size);
break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_S16BE_PLANAR:
#else
case AV_CODEC_ID_PCM_S16LE_PLANAR:
case AV_CODEC_ID_PCM_S32LE_PLANAR:
#endif /* HAVE_BIGENDIAN */
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
const uint8_t *src = frame->extended_data[c];
bytestream_put_buffer(&dst, src, n * sample_size);
}
break;
case AV_CODEC_ID_PCM_ALAW:
for (; n > 0; n--) {
v = *samples++;
*dst++ = linear_to_alaw[(v + 32768) >> 2];
}
break;
case AV_CODEC_ID_PCM_MULAW:
for (; n > 0; n--) {
v = *samples++;
*dst++ = linear_to_ulaw[(v + 32768) >> 2];
}
break;
default:
return -1;
}
*got_packet_ptr = 1;
return 0;
}
| false | FFmpeg | bcaf64b605442e1622d16da89d4ec0e7730b8a8c | static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
int n, c, sample_size, v, ret;
const short *samples;
unsigned char *dst;
const uint8_t *samples_uint8_t;
const int16_t *samples_int16_t;
const int32_t *samples_int32_t;
const int64_t *samples_int64_t;
const uint16_t *samples_uint16_t;
const uint32_t *samples_uint32_t;
sample_size = av_get_bits_per_sample(avctx->codec->id) / 8;
n = frame->nb_samples * avctx->channels;
samples = (const short *)frame->data[0];
if ((ret = ff_alloc_packet2(avctx, avpkt, n * sample_size)))
return ret;
dst = avpkt->data;
switch (avctx->codec->id) {
case AV_CODEC_ID_PCM_U32LE:
ENCODE(uint32_t, le32, samples, dst, n, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_U32BE:
ENCODE(uint32_t, be32, samples, dst, n, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_S24LE:
ENCODE(int32_t, le24, samples, dst, n, 8, 0)
break;
case AV_CODEC_ID_PCM_S24LE_PLANAR:
ENCODE_PLANAR(int32_t, le24, dst, n, 8, 0)
break;
case AV_CODEC_ID_PCM_S24BE:
ENCODE(int32_t, be24, samples, dst, n, 8, 0)
break;
case AV_CODEC_ID_PCM_U24LE:
ENCODE(uint32_t, le24, samples, dst, n, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_U24BE:
ENCODE(uint32_t, be24, samples, dst, n, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_S24DAUD:
for (; n > 0; n--) {
uint32_t tmp = ff_reverse[(*samples >> 8) & 0xff] +
(ff_reverse[*samples & 0xff] << 8);
tmp <<= 4;
bytestream_put_be24(&dst, tmp);
samples++;
}
break;
case AV_CODEC_ID_PCM_U16LE:
ENCODE(uint16_t, le16, samples, dst, n, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_U16BE:
ENCODE(uint16_t, be16, samples, dst, n, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_S8:
ENCODE(uint8_t, byte, samples, dst, n, 0, -128)
break;
case AV_CODEC_ID_PCM_S8_PLANAR:
ENCODE_PLANAR(uint8_t, byte, dst, n, 0, -128)
break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_F64LE:
ENCODE(int64_t, le64, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_F32LE:
ENCODE(int32_t, le32, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S32LE_PLANAR:
ENCODE_PLANAR(int32_t, le32, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE:
ENCODE(int16_t, le16, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE_PLANAR:
ENCODE_PLANAR(int16_t, le16, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
case AV_CODEC_ID_PCM_S16BE:
#else
case AV_CODEC_ID_PCM_F64BE:
ENCODE(int64_t, be64, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
ENCODE(int32_t, be32, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16BE:
ENCODE(int16_t, be16, samples, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_S16BE_PLANAR:
ENCODE_PLANAR(int16_t, be16, dst, n, 0, 0)
break;
case AV_CODEC_ID_PCM_F64LE:
case AV_CODEC_ID_PCM_F32LE:
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_S16LE:
#endif
case AV_CODEC_ID_PCM_U8:
memcpy(dst, samples, n * sample_size);
break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_S16BE_PLANAR:
#else
case AV_CODEC_ID_PCM_S16LE_PLANAR:
case AV_CODEC_ID_PCM_S32LE_PLANAR:
#endif
n /= avctx->channels;
for (c = 0; c < avctx->channels; c++) {
const uint8_t *src = frame->extended_data[c];
bytestream_put_buffer(&dst, src, n * sample_size);
}
break;
case AV_CODEC_ID_PCM_ALAW:
for (; n > 0; n--) {
v = *samples++;
*dst++ = linear_to_alaw[(v + 32768) >> 2];
}
break;
case AV_CODEC_ID_PCM_MULAW:
for (; n > 0; n--) {
v = *samples++;
*dst++ = linear_to_ulaw[(v + 32768) >> 2];
}
break;
default:
return -1;
}
*got_packet_ptr = 1;
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,
const AVFrame *VAR_2, int *VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;
const short *VAR_9;
unsigned char *VAR_10;
const uint8_t *VAR_11;
const int16_t *VAR_12;
const int32_t *VAR_13;
const int64_t *VAR_14;
const uint16_t *VAR_15;
const uint32_t *VAR_16;
VAR_6 = av_get_bits_per_sample(VAR_0->codec->id) / 8;
VAR_4 = VAR_2->nb_samples * VAR_0->channels;
VAR_9 = (const short *)VAR_2->data[0];
if ((VAR_8 = ff_alloc_packet2(VAR_0, VAR_1, VAR_4 * VAR_6)))
return VAR_8;
VAR_10 = VAR_1->data;
switch (VAR_0->codec->id) {
case AV_CODEC_ID_PCM_U32LE:
ENCODE(uint32_t, le32, VAR_9, VAR_10, VAR_4, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_U32BE:
ENCODE(uint32_t, be32, VAR_9, VAR_10, VAR_4, 0, 0x80000000)
break;
case AV_CODEC_ID_PCM_S24LE:
ENCODE(int32_t, le24, VAR_9, VAR_10, VAR_4, 8, 0)
break;
case AV_CODEC_ID_PCM_S24LE_PLANAR:
ENCODE_PLANAR(int32_t, le24, VAR_10, VAR_4, 8, 0)
break;
case AV_CODEC_ID_PCM_S24BE:
ENCODE(int32_t, be24, VAR_9, VAR_10, VAR_4, 8, 0)
break;
case AV_CODEC_ID_PCM_U24LE:
ENCODE(uint32_t, le24, VAR_9, VAR_10, VAR_4, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_U24BE:
ENCODE(uint32_t, be24, VAR_9, VAR_10, VAR_4, 8, 0x800000)
break;
case AV_CODEC_ID_PCM_S24DAUD:
for (; VAR_4 > 0; VAR_4--) {
uint32_t tmp = ff_reverse[(*VAR_9 >> 8) & 0xff] +
(ff_reverse[*VAR_9 & 0xff] << 8);
tmp <<= 4;
bytestream_put_be24(&VAR_10, tmp);
VAR_9++;
}
break;
case AV_CODEC_ID_PCM_U16LE:
ENCODE(uint16_t, le16, VAR_9, VAR_10, VAR_4, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_U16BE:
ENCODE(uint16_t, be16, VAR_9, VAR_10, VAR_4, 0, 0x8000)
break;
case AV_CODEC_ID_PCM_S8:
ENCODE(uint8_t, byte, VAR_9, VAR_10, VAR_4, 0, -128)
break;
case AV_CODEC_ID_PCM_S8_PLANAR:
ENCODE_PLANAR(uint8_t, byte, VAR_10, VAR_4, 0, -128)
break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_F64LE:
ENCODE(int64_t, le64, VAR_9, VAR_10, VAR_4, 0, 0)
break;
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_F32LE:
ENCODE(int32_t, le32, VAR_9, VAR_10, VAR_4, 0, 0)
break;
case AV_CODEC_ID_PCM_S32LE_PLANAR:
ENCODE_PLANAR(int32_t, le32, VAR_10, VAR_4, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE:
ENCODE(int16_t, le16, VAR_9, VAR_10, VAR_4, 0, 0)
break;
case AV_CODEC_ID_PCM_S16LE_PLANAR:
ENCODE_PLANAR(int16_t, le16, VAR_10, VAR_4, 0, 0)
break;
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
case AV_CODEC_ID_PCM_S16BE:
#else
case AV_CODEC_ID_PCM_F64BE:
ENCODE(int64_t, be64, VAR_9, VAR_10, VAR_4, 0, 0)
break;
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_S32BE:
ENCODE(int32_t, be32, VAR_9, VAR_10, VAR_4, 0, 0)
break;
case AV_CODEC_ID_PCM_S16BE:
ENCODE(int16_t, be16, VAR_9, VAR_10, VAR_4, 0, 0)
break;
case AV_CODEC_ID_PCM_S16BE_PLANAR:
ENCODE_PLANAR(int16_t, be16, VAR_10, VAR_4, 0, 0)
break;
case AV_CODEC_ID_PCM_F64LE:
case AV_CODEC_ID_PCM_F32LE:
case AV_CODEC_ID_PCM_S32LE:
case AV_CODEC_ID_PCM_S16LE:
#endif
case AV_CODEC_ID_PCM_U8:
memcpy(VAR_10, VAR_9, VAR_4 * VAR_6);
break;
#if HAVE_BIGENDIAN
case AV_CODEC_ID_PCM_S16BE_PLANAR:
#else
case AV_CODEC_ID_PCM_S16LE_PLANAR:
case AV_CODEC_ID_PCM_S32LE_PLANAR:
#endif
VAR_4 /= VAR_0->channels;
for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {
const uint8_t *src = VAR_2->extended_data[VAR_5];
bytestream_put_buffer(&VAR_10, src, VAR_4 * VAR_6);
}
break;
case AV_CODEC_ID_PCM_ALAW:
for (; VAR_4 > 0; VAR_4--) {
VAR_7 = *VAR_9++;
*VAR_10++ = linear_to_alaw[(VAR_7 + 32768) >> 2];
}
break;
case AV_CODEC_ID_PCM_MULAW:
for (; VAR_4 > 0; VAR_4--) {
VAR_7 = *VAR_9++;
*VAR_10++ = linear_to_ulaw[(VAR_7 + 32768) >> 2];
}
break;
default:
return -1;
}
*VAR_3 = 1;
return 0;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8;",
"const short *VAR_9;",
"unsigned char *VAR_10;",
"const uint8_t *VAR_11;",
"const int16_t *VAR_12;",
"const int32_t *VAR_13;",
"const int64_t *VAR_14;",
"const uint16_t *VAR_15;",
"const uint32_t *VAR_16;",
"VAR_6 = av_get_bits_per_sample(VAR_0->codec->id) / 8;",
"VAR_4 = VAR_2->nb_samples * VAR_0->channels;",
"VAR_9 = (const short *)VAR_2->data[0];",
"if ((VAR_8 = ff_alloc_packet2(VAR_0, VAR_1, VAR_4 * VAR_6)))\nreturn VAR_8;",
"VAR_10 = VAR_1->data;",
"switch (VAR_0->codec->id) {",
"case AV_CODEC_ID_PCM_U32LE:\nENCODE(uint32_t, le32, VAR_9, VAR_10, VAR_4, 0, 0x80000000)\nbreak;",
"case AV_CODEC_ID_PCM_U32BE:\nENCODE(uint32_t, be32, VAR_9, VAR_10, VAR_4, 0, 0x80000000)\nbreak;",
"case AV_CODEC_ID_PCM_S24LE:\nENCODE(int32_t, le24, VAR_9, VAR_10, VAR_4, 8, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S24LE_PLANAR:\nENCODE_PLANAR(int32_t, le24, VAR_10, VAR_4, 8, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S24BE:\nENCODE(int32_t, be24, VAR_9, VAR_10, VAR_4, 8, 0)\nbreak;",
"case AV_CODEC_ID_PCM_U24LE:\nENCODE(uint32_t, le24, VAR_9, VAR_10, VAR_4, 8, 0x800000)\nbreak;",
"case AV_CODEC_ID_PCM_U24BE:\nENCODE(uint32_t, be24, VAR_9, VAR_10, VAR_4, 8, 0x800000)\nbreak;",
"case AV_CODEC_ID_PCM_S24DAUD:\nfor (; VAR_4 > 0; VAR_4--) {",
"uint32_t tmp = ff_reverse[(*VAR_9 >> 8) & 0xff] +\n(ff_reverse[*VAR_9 & 0xff] << 8);",
"tmp <<= 4;",
"bytestream_put_be24(&VAR_10, tmp);",
"VAR_9++;",
"}",
"break;",
"case AV_CODEC_ID_PCM_U16LE:\nENCODE(uint16_t, le16, VAR_9, VAR_10, VAR_4, 0, 0x8000)\nbreak;",
"case AV_CODEC_ID_PCM_U16BE:\nENCODE(uint16_t, be16, VAR_9, VAR_10, VAR_4, 0, 0x8000)\nbreak;",
"case AV_CODEC_ID_PCM_S8:\nENCODE(uint8_t, byte, VAR_9, VAR_10, VAR_4, 0, -128)\nbreak;",
"case AV_CODEC_ID_PCM_S8_PLANAR:\nENCODE_PLANAR(uint8_t, byte, VAR_10, VAR_4, 0, -128)\nbreak;",
"#if HAVE_BIGENDIAN\ncase AV_CODEC_ID_PCM_F64LE:\nENCODE(int64_t, le64, VAR_9, VAR_10, VAR_4, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S32LE:\ncase AV_CODEC_ID_PCM_F32LE:\nENCODE(int32_t, le32, VAR_9, VAR_10, VAR_4, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S32LE_PLANAR:\nENCODE_PLANAR(int32_t, le32, VAR_10, VAR_4, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S16LE:\nENCODE(int16_t, le16, VAR_9, VAR_10, VAR_4, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S16LE_PLANAR:\nENCODE_PLANAR(int16_t, le16, VAR_10, VAR_4, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_F64BE:\ncase AV_CODEC_ID_PCM_F32BE:\ncase AV_CODEC_ID_PCM_S32BE:\ncase AV_CODEC_ID_PCM_S16BE:\n#else\ncase AV_CODEC_ID_PCM_F64BE:\nENCODE(int64_t, be64, VAR_9, VAR_10, VAR_4, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_F32BE:\ncase AV_CODEC_ID_PCM_S32BE:\nENCODE(int32_t, be32, VAR_9, VAR_10, VAR_4, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S16BE:\nENCODE(int16_t, be16, VAR_9, VAR_10, VAR_4, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_S16BE_PLANAR:\nENCODE_PLANAR(int16_t, be16, VAR_10, VAR_4, 0, 0)\nbreak;",
"case AV_CODEC_ID_PCM_F64LE:\ncase AV_CODEC_ID_PCM_F32LE:\ncase AV_CODEC_ID_PCM_S32LE:\ncase AV_CODEC_ID_PCM_S16LE:\n#endif\ncase AV_CODEC_ID_PCM_U8:\nmemcpy(VAR_10, VAR_9, VAR_4 * VAR_6);",
"break;",
"#if HAVE_BIGENDIAN\ncase AV_CODEC_ID_PCM_S16BE_PLANAR:\n#else\ncase AV_CODEC_ID_PCM_S16LE_PLANAR:\ncase AV_CODEC_ID_PCM_S32LE_PLANAR:\n#endif\nVAR_4 /= VAR_0->channels;",
"for (VAR_5 = 0; VAR_5 < VAR_0->channels; VAR_5++) {",
"const uint8_t *src = VAR_2->extended_data[VAR_5];",
"bytestream_put_buffer(&VAR_10, src, VAR_4 * VAR_6);",
"}",
"break;",
"case AV_CODEC_ID_PCM_ALAW:\nfor (; VAR_4 > 0; VAR_4--) {",
"VAR_7 = *VAR_9++;",
"*VAR_10++ = linear_to_alaw[(VAR_7 + 32768) >> 2];",
"}",
"break;",
"case AV_CODEC_ID_PCM_MULAW:\nfor (; VAR_4 > 0; VAR_4--) {",
"VAR_7 = *VAR_9++;",
"*VAR_10++ = linear_to_ulaw[(VAR_7 + 32768) >> 2];",
"}",
"break;",
"default:\nreturn -1;",
"}",
"*VAR_3 = 1;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
35,
37
],
[
39
],
[
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
],
[
111,
113,
115
],
[
117,
119,
121
],
[
123,
125,
127
],
[
129,
131,
133,
135
],
[
137,
139,
141,
143
],
[
145,
147,
149
],
[
151,
153,
155
],
[
157,
159,
161
],
[
163,
165,
167,
169,
171,
173,
175,
177
],
[
179,
181,
183,
185
],
[
187,
189,
191
],
[
193,
195,
197
],
[
199,
201,
203,
205,
207,
209,
211
],
[
213
],
[
215,
217,
219,
221,
223,
225,
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239,
241
],
[
243
],
[
245
],
[
247
],
[
249
],
[
251,
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263,
265
],
[
267
],
[
271
],
[
273
],
[
275
]
] |
25,062 | static int RENAME(epzs_motion_search)(MpegEncContext * s,
int *mx_ptr, int *my_ptr,
int P[10][2], int pred_x, int pred_y, uint8_t *src_data[3],
uint8_t *ref_data[3], int stride, int uvstride, int16_t (*last_mv)[2],
int ref_mv_scale, uint8_t * const mv_penalty)
{
int best[2]={0, 0};
int d, dmin;
const int shift= 1+s->quarter_sample;
uint32_t *map= s->me.map;
int map_generation;
const int penalty_factor= s->me.penalty_factor;
const int size=0;
const int h=16;
const int ref_mv_stride= s->mb_stride; //pass as arg FIXME
const int ref_mv_xy= s->mb_x + s->mb_y*ref_mv_stride; //add to last_mv beforepassing FIXME
me_cmp_func cmp, chroma_cmp;
LOAD_COMMON
cmp= s->dsp.me_cmp[size];
chroma_cmp= s->dsp.me_cmp[size+1];
map_generation= update_map_generation(s);
CMP(dmin, 0, 0, size);
map[0]= map_generation;
score_map[0]= dmin;
/* first line */
if (s->first_slice_line) {
CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
}else{
if(dmin<256 && ( P_LEFT[0] |P_LEFT[1]
|P_TOP[0] |P_TOP[1]
|P_TOPRIGHT[0]|P_TOPRIGHT[1])==0){
*mx_ptr= 0;
*my_ptr= 0;
s->me.skip=1;
return dmin;
}
CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
if(dmin>256*2){
CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
CHECK_MV(P_LEFT[0] >>shift, P_LEFT[1] >>shift)
CHECK_MV(P_TOP[0] >>shift, P_TOP[1] >>shift)
CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
}
}
if(dmin>256*4){
if(s->me.pre_pass){
CHECK_CLIPED_MV((last_mv[ref_mv_xy-1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy-1][1]*ref_mv_scale + (1<<15))>>16)
if(!s->first_slice_line)
CHECK_CLIPED_MV((last_mv[ref_mv_xy-ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy-ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
}else{
CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
if(s->end_mb_y == s->mb_height || s->mb_y+1<s->end_mb_y) //FIXME replace at least with last_slice_line
CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
}
}
if(s->avctx->last_predictor_count){
const int count= s->avctx->last_predictor_count;
const int xstart= FFMAX(0, s->mb_x - count);
const int ystart= FFMAX(0, s->mb_y - count);
const int xend= FFMIN(s->mb_width , s->mb_x + count + 1);
const int yend= FFMIN(s->mb_height, s->mb_y + count + 1);
int mb_y;
for(mb_y=ystart; mb_y<yend; mb_y++){
int mb_x;
for(mb_x=xstart; mb_x<xend; mb_x++){
const int xy= mb_x + 1 + (mb_y + 1)*ref_mv_stride;
int mx= (last_mv[xy][0]*ref_mv_scale + (1<<15))>>16;
int my= (last_mv[xy][1]*ref_mv_scale + (1<<15))>>16;
if(mx>xmax || mx<xmin || my>ymax || my<ymin) continue;
CHECK_MV(mx,my)
}
}
}
//check(best[0],best[1],0, b0)
if(s->me.dia_size==-1)
dmin= RENAME(funny_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
else if(s->me.dia_size<-1)
dmin= RENAME(sab_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
else if(s->me.dia_size<2)
dmin= RENAME(small_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
else
dmin= RENAME(var_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
//check(best[0],best[1],0, b1)
*mx_ptr= best[0];
*my_ptr= best[1];
// printf("%d %d %d \n", best[0], best[1], dmin);
return dmin;
}
| false | FFmpeg | 80ee9fc0e305b815b4b67bbf8fa9ceccdc1d369e | static int RENAME(epzs_motion_search)(MpegEncContext * s,
int *mx_ptr, int *my_ptr,
int P[10][2], int pred_x, int pred_y, uint8_t *src_data[3],
uint8_t *ref_data[3], int stride, int uvstride, int16_t (*last_mv)[2],
int ref_mv_scale, uint8_t * const mv_penalty)
{
int best[2]={0, 0};
int d, dmin;
const int shift= 1+s->quarter_sample;
uint32_t *map= s->me.map;
int map_generation;
const int penalty_factor= s->me.penalty_factor;
const int size=0;
const int h=16;
const int ref_mv_stride= s->mb_stride;
const int ref_mv_xy= s->mb_x + s->mb_y*ref_mv_stride;
me_cmp_func cmp, chroma_cmp;
LOAD_COMMON
cmp= s->dsp.me_cmp[size];
chroma_cmp= s->dsp.me_cmp[size+1];
map_generation= update_map_generation(s);
CMP(dmin, 0, 0, size);
map[0]= map_generation;
score_map[0]= dmin;
if (s->first_slice_line) {
CHECK_MV(P_LEFT[0]>>shift, P_LEFT[1]>>shift)
CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
}else{
if(dmin<256 && ( P_LEFT[0] |P_LEFT[1]
|P_TOP[0] |P_TOP[1]
|P_TOPRIGHT[0]|P_TOPRIGHT[1])==0){
*mx_ptr= 0;
*my_ptr= 0;
s->me.skip=1;
return dmin;
}
CHECK_MV(P_MEDIAN[0]>>shift, P_MEDIAN[1]>>shift)
if(dmin>256*2){
CHECK_CLIPED_MV((last_mv[ref_mv_xy][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy][1]*ref_mv_scale + (1<<15))>>16)
CHECK_MV(P_LEFT[0] >>shift, P_LEFT[1] >>shift)
CHECK_MV(P_TOP[0] >>shift, P_TOP[1] >>shift)
CHECK_MV(P_TOPRIGHT[0]>>shift, P_TOPRIGHT[1]>>shift)
}
}
if(dmin>256*4){
if(s->me.pre_pass){
CHECK_CLIPED_MV((last_mv[ref_mv_xy-1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy-1][1]*ref_mv_scale + (1<<15))>>16)
if(!s->first_slice_line)
CHECK_CLIPED_MV((last_mv[ref_mv_xy-ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy-ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
}else{
CHECK_CLIPED_MV((last_mv[ref_mv_xy+1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+1][1]*ref_mv_scale + (1<<15))>>16)
if(s->end_mb_y == s->mb_height || s->mb_y+1<s->end_mb_y)
CHECK_CLIPED_MV((last_mv[ref_mv_xy+ref_mv_stride][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[ref_mv_xy+ref_mv_stride][1]*ref_mv_scale + (1<<15))>>16)
}
}
if(s->avctx->last_predictor_count){
const int count= s->avctx->last_predictor_count;
const int xstart= FFMAX(0, s->mb_x - count);
const int ystart= FFMAX(0, s->mb_y - count);
const int xend= FFMIN(s->mb_width , s->mb_x + count + 1);
const int yend= FFMIN(s->mb_height, s->mb_y + count + 1);
int mb_y;
for(mb_y=ystart; mb_y<yend; mb_y++){
int mb_x;
for(mb_x=xstart; mb_x<xend; mb_x++){
const int xy= mb_x + 1 + (mb_y + 1)*ref_mv_stride;
int mx= (last_mv[xy][0]*ref_mv_scale + (1<<15))>>16;
int my= (last_mv[xy][1]*ref_mv_scale + (1<<15))>>16;
if(mx>xmax || mx<xmin || my>ymax || my<ymin) continue;
CHECK_MV(mx,my)
}
}
}
if(s->me.dia_size==-1)
dmin= RENAME(funny_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
else if(s->me.dia_size<-1)
dmin= RENAME(sab_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
else if(s->me.dia_size<2)
dmin= RENAME(small_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
else
dmin= RENAME(var_diamond_search)(s, best, dmin, src_data, ref_data, stride, uvstride,
pred_x, pred_y, penalty_factor,
shift, map, map_generation, size, h, mv_penalty);
*mx_ptr= best[0];
*my_ptr= best[1];
return dmin;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(epzs_motion_search)(MpegEncContext * s,
int *mx_ptr, int *my_ptr,
int P[10][2], int pred_x, int pred_y, uint8_t *src_data[3],
uint8_t *ref_data[3], int stride, int uvstride, int16_t (*last_mv)[2],
int ref_mv_scale, uint8_t * const mv_penalty)
{
int VAR_0[2]={0, 0};
int VAR_1, VAR_2;
const int VAR_3= 1+s->quarter_sample;
uint32_t *map= s->me.map;
int VAR_4;
const int VAR_5= s->me.VAR_5;
const int VAR_6=0;
const int VAR_7=16;
const int VAR_8= s->mb_stride;
const int VAR_9= s->VAR_16 + s->VAR_15*VAR_8;
me_cmp_func cmp, chroma_cmp;
LOAD_COMMON
cmp= s->dsp.me_cmp[VAR_6];
chroma_cmp= s->dsp.me_cmp[VAR_6+1];
VAR_4= update_map_generation(s);
CMP(VAR_2, 0, 0, VAR_6);
map[0]= VAR_4;
score_map[0]= VAR_2;
if (s->first_slice_line) {
CHECK_MV(P_LEFT[0]>>VAR_3, P_LEFT[1]>>VAR_3)
CHECK_CLIPED_MV((last_mv[VAR_9][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[VAR_9][1]*ref_mv_scale + (1<<15))>>16)
}else{
if(VAR_2<256 && ( P_LEFT[0] |P_LEFT[1]
|P_TOP[0] |P_TOP[1]
|P_TOPRIGHT[0]|P_TOPRIGHT[1])==0){
*mx_ptr= 0;
*my_ptr= 0;
s->me.skip=1;
return VAR_2;
}
CHECK_MV(P_MEDIAN[0]>>VAR_3, P_MEDIAN[1]>>VAR_3)
if(VAR_2>256*2){
CHECK_CLIPED_MV((last_mv[VAR_9][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[VAR_9][1]*ref_mv_scale + (1<<15))>>16)
CHECK_MV(P_LEFT[0] >>VAR_3, P_LEFT[1] >>VAR_3)
CHECK_MV(P_TOP[0] >>VAR_3, P_TOP[1] >>VAR_3)
CHECK_MV(P_TOPRIGHT[0]>>VAR_3, P_TOPRIGHT[1]>>VAR_3)
}
}
if(VAR_2>256*4){
if(s->me.pre_pass){
CHECK_CLIPED_MV((last_mv[VAR_9-1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[VAR_9-1][1]*ref_mv_scale + (1<<15))>>16)
if(!s->first_slice_line)
CHECK_CLIPED_MV((last_mv[VAR_9-VAR_8][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[VAR_9-VAR_8][1]*ref_mv_scale + (1<<15))>>16)
}else{
CHECK_CLIPED_MV((last_mv[VAR_9+1][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[VAR_9+1][1]*ref_mv_scale + (1<<15))>>16)
if(s->end_mb_y == s->mb_height || s->VAR_15+1<s->end_mb_y)
CHECK_CLIPED_MV((last_mv[VAR_9+VAR_8][0]*ref_mv_scale + (1<<15))>>16,
(last_mv[VAR_9+VAR_8][1]*ref_mv_scale + (1<<15))>>16)
}
}
if(s->avctx->last_predictor_count){
const int VAR_10= s->avctx->last_predictor_count;
const int VAR_11= FFMAX(0, s->VAR_16 - VAR_10);
const int VAR_12= FFMAX(0, s->VAR_15 - VAR_10);
const int VAR_13= FFMIN(s->mb_width , s->VAR_16 + VAR_10 + 1);
const int VAR_14= FFMIN(s->mb_height, s->VAR_15 + VAR_10 + 1);
int VAR_15;
for(VAR_15=VAR_12; VAR_15<VAR_14; VAR_15++){
int VAR_16;
for(VAR_16=VAR_11; VAR_16<VAR_13; VAR_16++){
const int VAR_17= VAR_16 + 1 + (VAR_15 + 1)*VAR_8;
int VAR_18= (last_mv[VAR_17][0]*ref_mv_scale + (1<<15))>>16;
int VAR_19= (last_mv[VAR_17][1]*ref_mv_scale + (1<<15))>>16;
if(VAR_18>xmax || VAR_18<xmin || VAR_19>ymax || VAR_19<ymin) continue;
CHECK_MV(VAR_18,VAR_19)
}
}
}
if(s->me.dia_size==-1)
VAR_2= FUNC_0(funny_diamond_search)(s, VAR_0, VAR_2, src_data, ref_data, stride, uvstride,
pred_x, pred_y, VAR_5,
VAR_3, map, VAR_4, VAR_6, VAR_7, mv_penalty);
else if(s->me.dia_size<-1)
VAR_2= FUNC_0(sab_diamond_search)(s, VAR_0, VAR_2, src_data, ref_data, stride, uvstride,
pred_x, pred_y, VAR_5,
VAR_3, map, VAR_4, VAR_6, VAR_7, mv_penalty);
else if(s->me.dia_size<2)
VAR_2= FUNC_0(small_diamond_search)(s, VAR_0, VAR_2, src_data, ref_data, stride, uvstride,
pred_x, pred_y, VAR_5,
VAR_3, map, VAR_4, VAR_6, VAR_7, mv_penalty);
else
VAR_2= FUNC_0(var_diamond_search)(s, VAR_0, VAR_2, src_data, ref_data, stride, uvstride,
pred_x, pred_y, VAR_5,
VAR_3, map, VAR_4, VAR_6, VAR_7, mv_penalty);
*mx_ptr= VAR_0[0];
*my_ptr= VAR_0[1];
return VAR_2;
}
| [
"static int FUNC_0(epzs_motion_search)(MpegEncContext * s,\nint *mx_ptr, int *my_ptr,\nint P[10][2], int pred_x, int pred_y, uint8_t *src_data[3],\nuint8_t *ref_data[3], int stride, int uvstride, int16_t (*last_mv)[2],\nint ref_mv_scale, uint8_t * const mv_penalty)\n{",
"int VAR_0[2]={0, 0};",
"int VAR_1, VAR_2;",
"const int VAR_3= 1+s->quarter_sample;",
"uint32_t *map= s->me.map;",
"int VAR_4;",
"const int VAR_5= s->me.VAR_5;",
"const int VAR_6=0;",
"const int VAR_7=16;",
"const int VAR_8= s->mb_stride;",
"const int VAR_9= s->VAR_16 + s->VAR_15*VAR_8;",
"me_cmp_func cmp, chroma_cmp;",
"LOAD_COMMON\ncmp= s->dsp.me_cmp[VAR_6];",
"chroma_cmp= s->dsp.me_cmp[VAR_6+1];",
"VAR_4= update_map_generation(s);",
"CMP(VAR_2, 0, 0, VAR_6);",
"map[0]= VAR_4;",
"score_map[0]= VAR_2;",
"if (s->first_slice_line) {",
"CHECK_MV(P_LEFT[0]>>VAR_3, P_LEFT[1]>>VAR_3)\nCHECK_CLIPED_MV((last_mv[VAR_9][0]*ref_mv_scale + (1<<15))>>16,\n(last_mv[VAR_9][1]*ref_mv_scale + (1<<15))>>16)\n}else{",
"if(VAR_2<256 && ( P_LEFT[0] |P_LEFT[1]\n|P_TOP[0] |P_TOP[1]\n|P_TOPRIGHT[0]|P_TOPRIGHT[1])==0){",
"*mx_ptr= 0;",
"*my_ptr= 0;",
"s->me.skip=1;",
"return VAR_2;",
"}",
"CHECK_MV(P_MEDIAN[0]>>VAR_3, P_MEDIAN[1]>>VAR_3)\nif(VAR_2>256*2){",
"CHECK_CLIPED_MV((last_mv[VAR_9][0]*ref_mv_scale + (1<<15))>>16,\n(last_mv[VAR_9][1]*ref_mv_scale + (1<<15))>>16)\nCHECK_MV(P_LEFT[0] >>VAR_3, P_LEFT[1] >>VAR_3)\nCHECK_MV(P_TOP[0] >>VAR_3, P_TOP[1] >>VAR_3)\nCHECK_MV(P_TOPRIGHT[0]>>VAR_3, P_TOPRIGHT[1]>>VAR_3)\n}",
"}",
"if(VAR_2>256*4){",
"if(s->me.pre_pass){",
"CHECK_CLIPED_MV((last_mv[VAR_9-1][0]*ref_mv_scale + (1<<15))>>16,\n(last_mv[VAR_9-1][1]*ref_mv_scale + (1<<15))>>16)\nif(!s->first_slice_line)\nCHECK_CLIPED_MV((last_mv[VAR_9-VAR_8][0]*ref_mv_scale + (1<<15))>>16,\n(last_mv[VAR_9-VAR_8][1]*ref_mv_scale + (1<<15))>>16)\n}else{",
"CHECK_CLIPED_MV((last_mv[VAR_9+1][0]*ref_mv_scale + (1<<15))>>16,\n(last_mv[VAR_9+1][1]*ref_mv_scale + (1<<15))>>16)\nif(s->end_mb_y == s->mb_height || s->VAR_15+1<s->end_mb_y)\nCHECK_CLIPED_MV((last_mv[VAR_9+VAR_8][0]*ref_mv_scale + (1<<15))>>16,\n(last_mv[VAR_9+VAR_8][1]*ref_mv_scale + (1<<15))>>16)\n}",
"}",
"if(s->avctx->last_predictor_count){",
"const int VAR_10= s->avctx->last_predictor_count;",
"const int VAR_11= FFMAX(0, s->VAR_16 - VAR_10);",
"const int VAR_12= FFMAX(0, s->VAR_15 - VAR_10);",
"const int VAR_13= FFMIN(s->mb_width , s->VAR_16 + VAR_10 + 1);",
"const int VAR_14= FFMIN(s->mb_height, s->VAR_15 + VAR_10 + 1);",
"int VAR_15;",
"for(VAR_15=VAR_12; VAR_15<VAR_14; VAR_15++){",
"int VAR_16;",
"for(VAR_16=VAR_11; VAR_16<VAR_13; VAR_16++){",
"const int VAR_17= VAR_16 + 1 + (VAR_15 + 1)*VAR_8;",
"int VAR_18= (last_mv[VAR_17][0]*ref_mv_scale + (1<<15))>>16;",
"int VAR_19= (last_mv[VAR_17][1]*ref_mv_scale + (1<<15))>>16;",
"if(VAR_18>xmax || VAR_18<xmin || VAR_19>ymax || VAR_19<ymin) continue;",
"CHECK_MV(VAR_18,VAR_19)\n}",
"}",
"}",
"if(s->me.dia_size==-1)\nVAR_2= FUNC_0(funny_diamond_search)(s, VAR_0, VAR_2, src_data, ref_data, stride, uvstride,\npred_x, pred_y, VAR_5,\nVAR_3, map, VAR_4, VAR_6, VAR_7, mv_penalty);",
"else if(s->me.dia_size<-1)\nVAR_2= FUNC_0(sab_diamond_search)(s, VAR_0, VAR_2, src_data, ref_data, stride, uvstride,\npred_x, pred_y, VAR_5,\nVAR_3, map, VAR_4, VAR_6, VAR_7, mv_penalty);",
"else if(s->me.dia_size<2)\nVAR_2= FUNC_0(small_diamond_search)(s, VAR_0, VAR_2, src_data, ref_data, stride, uvstride,\npred_x, pred_y, VAR_5,\nVAR_3, map, VAR_4, VAR_6, VAR_7, mv_penalty);",
"else\nVAR_2= FUNC_0(var_diamond_search)(s, VAR_0, VAR_2, src_data, ref_data, stride, uvstride,\npred_x, pred_y, VAR_5,\nVAR_3, map, VAR_4, VAR_6, VAR_7, mv_penalty);",
"*mx_ptr= VAR_0[0];",
"*my_ptr= VAR_0[1];",
"return 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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35,
39
],
[
41
],
[
45
],
[
49
],
[
51
],
[
53
],
[
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,
121,
123,
125,
127,
129
],
[
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
165
],
[
167,
169
],
[
171
],
[
173
],
[
179,
181,
183,
185
],
[
187,
189,
191,
193
],
[
195,
197,
199,
201
],
[
203,
205,
207,
209
],
[
215
],
[
217
],
[
223
],
[
225
]
] |
25,063 | static void megasas_complete_frame(MegasasState *s, uint64_t context)
{
PCIDevice *pci_dev = PCI_DEVICE(s);
int tail, queue_offset;
/* Decrement busy count */
s->busy--;
if (s->reply_queue_pa) {
/*
* Put command on the reply queue.
* Context is opaque, but emulation is running in
* little endian. So convert it.
*/
tail = s->reply_queue_head;
if (megasas_use_queue64(s)) {
queue_offset = tail * sizeof(uint64_t);
stq_le_phys(&address_space_memory,
s->reply_queue_pa + queue_offset, context);
} else {
queue_offset = tail * sizeof(uint32_t);
stl_le_phys(&address_space_memory,
s->reply_queue_pa + queue_offset, context);
}
s->reply_queue_head = megasas_next_index(s, tail, s->fw_cmds);
s->reply_queue_tail = ldl_le_phys(&address_space_memory,
s->consumer_pa);
trace_megasas_qf_complete(context, s->reply_queue_head,
s->reply_queue_tail, s->busy, s->doorbell);
}
if (megasas_intr_enabled(s)) {
/* Notify HBA */
s->doorbell++;
if (s->doorbell == 1) {
if (msix_enabled(pci_dev)) {
trace_megasas_msix_raise(0);
msix_notify(pci_dev, 0);
} else if (msi_enabled(pci_dev)) {
trace_megasas_msi_raise(0);
msi_notify(pci_dev, 0);
} else {
trace_megasas_irq_raise();
pci_irq_assert(pci_dev);
}
}
} else {
trace_megasas_qf_complete_noirq(context);
}
}
| true | qemu | 6df5718bd3ec56225c44cf96440c723c1b611b87 | static void megasas_complete_frame(MegasasState *s, uint64_t context)
{
PCIDevice *pci_dev = PCI_DEVICE(s);
int tail, queue_offset;
s->busy--;
if (s->reply_queue_pa) {
tail = s->reply_queue_head;
if (megasas_use_queue64(s)) {
queue_offset = tail * sizeof(uint64_t);
stq_le_phys(&address_space_memory,
s->reply_queue_pa + queue_offset, context);
} else {
queue_offset = tail * sizeof(uint32_t);
stl_le_phys(&address_space_memory,
s->reply_queue_pa + queue_offset, context);
}
s->reply_queue_head = megasas_next_index(s, tail, s->fw_cmds);
s->reply_queue_tail = ldl_le_phys(&address_space_memory,
s->consumer_pa);
trace_megasas_qf_complete(context, s->reply_queue_head,
s->reply_queue_tail, s->busy, s->doorbell);
}
if (megasas_intr_enabled(s)) {
s->doorbell++;
if (s->doorbell == 1) {
if (msix_enabled(pci_dev)) {
trace_megasas_msix_raise(0);
msix_notify(pci_dev, 0);
} else if (msi_enabled(pci_dev)) {
trace_megasas_msi_raise(0);
msi_notify(pci_dev, 0);
} else {
trace_megasas_irq_raise();
pci_irq_assert(pci_dev);
}
}
} else {
trace_megasas_qf_complete_noirq(context);
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(MegasasState *VAR_0, uint64_t VAR_1)
{
PCIDevice *pci_dev = PCI_DEVICE(VAR_0);
int VAR_2, VAR_3;
VAR_0->busy--;
if (VAR_0->reply_queue_pa) {
VAR_2 = VAR_0->reply_queue_head;
if (megasas_use_queue64(VAR_0)) {
VAR_3 = VAR_2 * sizeof(uint64_t);
stq_le_phys(&address_space_memory,
VAR_0->reply_queue_pa + VAR_3, VAR_1);
} else {
VAR_3 = VAR_2 * sizeof(uint32_t);
stl_le_phys(&address_space_memory,
VAR_0->reply_queue_pa + VAR_3, VAR_1);
}
VAR_0->reply_queue_head = megasas_next_index(VAR_0, VAR_2, VAR_0->fw_cmds);
VAR_0->reply_queue_tail = ldl_le_phys(&address_space_memory,
VAR_0->consumer_pa);
trace_megasas_qf_complete(VAR_1, VAR_0->reply_queue_head,
VAR_0->reply_queue_tail, VAR_0->busy, VAR_0->doorbell);
}
if (megasas_intr_enabled(VAR_0)) {
VAR_0->doorbell++;
if (VAR_0->doorbell == 1) {
if (msix_enabled(pci_dev)) {
trace_megasas_msix_raise(0);
msix_notify(pci_dev, 0);
} else if (msi_enabled(pci_dev)) {
trace_megasas_msi_raise(0);
msi_notify(pci_dev, 0);
} else {
trace_megasas_irq_raise();
pci_irq_assert(pci_dev);
}
}
} else {
trace_megasas_qf_complete_noirq(VAR_1);
}
}
| [
"static void FUNC_0(MegasasState *VAR_0, uint64_t VAR_1)\n{",
"PCIDevice *pci_dev = PCI_DEVICE(VAR_0);",
"int VAR_2, VAR_3;",
"VAR_0->busy--;",
"if (VAR_0->reply_queue_pa) {",
"VAR_2 = VAR_0->reply_queue_head;",
"if (megasas_use_queue64(VAR_0)) {",
"VAR_3 = VAR_2 * sizeof(uint64_t);",
"stq_le_phys(&address_space_memory,\nVAR_0->reply_queue_pa + VAR_3, VAR_1);",
"} else {",
"VAR_3 = VAR_2 * sizeof(uint32_t);",
"stl_le_phys(&address_space_memory,\nVAR_0->reply_queue_pa + VAR_3, VAR_1);",
"}",
"VAR_0->reply_queue_head = megasas_next_index(VAR_0, VAR_2, VAR_0->fw_cmds);",
"VAR_0->reply_queue_tail = ldl_le_phys(&address_space_memory,\nVAR_0->consumer_pa);",
"trace_megasas_qf_complete(VAR_1, VAR_0->reply_queue_head,\nVAR_0->reply_queue_tail, VAR_0->busy, VAR_0->doorbell);",
"}",
"if (megasas_intr_enabled(VAR_0)) {",
"VAR_0->doorbell++;",
"if (VAR_0->doorbell == 1) {",
"if (msix_enabled(pci_dev)) {",
"trace_megasas_msix_raise(0);",
"msix_notify(pci_dev, 0);",
"} else if (msi_enabled(pci_dev)) {",
"trace_megasas_msi_raise(0);",
"msi_notify(pci_dev, 0);",
"} else {",
"trace_megasas_irq_raise();",
"pci_irq_assert(pci_dev);",
"}",
"}",
"} else {",
"trace_megasas_qf_complete_noirq(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
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
17
],
[
29
],
[
31
],
[
33
],
[
35,
37
],
[
39
],
[
41
],
[
43,
45
],
[
47
],
[
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
63
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
]
] |
25,064 | static int decode_residual_block(AVSContext *h, GetBitContext *gb,
const dec_2dvlc_t *r, int esc_golomb_order,
int qp, uint8_t *dst, int stride) {
int i, level_code, esc_code, level, run, mask;
DCTELEM level_buf[64];
uint8_t run_buf[64];
DCTELEM *block = h->block;
for(i=0;i<65;i++) {
level_code = get_ue_code(gb,r->golomb_order);
if(level_code >= ESCAPE_CODE) {
run = ((level_code - ESCAPE_CODE) >> 1) + 1;
esc_code = get_ue_code(gb,esc_golomb_order);
level = esc_code + (run > r->max_run ? 1 : r->level_add[run]);
while(level > r->inc_limit)
r++;
mask = -(level_code & 1);
level = (level^mask) - mask;
} else {
level = r->rltab[level_code][0];
if(!level) //end of block signal
break;
run = r->rltab[level_code][1];
r += r->rltab[level_code][2];
}
level_buf[i] = level;
run_buf[i] = run;
}
if(dequant(h,level_buf, run_buf, block, ff_cavs_dequant_mul[qp],
ff_cavs_dequant_shift[qp], i))
return -1;
h->s.dsp.cavs_idct8_add(dst,block,stride);
return 0;
}
| true | FFmpeg | 6138ed777db101c26d19b96e6a27b8499ab9f4e7 | static int decode_residual_block(AVSContext *h, GetBitContext *gb,
const dec_2dvlc_t *r, int esc_golomb_order,
int qp, uint8_t *dst, int stride) {
int i, level_code, esc_code, level, run, mask;
DCTELEM level_buf[64];
uint8_t run_buf[64];
DCTELEM *block = h->block;
for(i=0;i<65;i++) {
level_code = get_ue_code(gb,r->golomb_order);
if(level_code >= ESCAPE_CODE) {
run = ((level_code - ESCAPE_CODE) >> 1) + 1;
esc_code = get_ue_code(gb,esc_golomb_order);
level = esc_code + (run > r->max_run ? 1 : r->level_add[run]);
while(level > r->inc_limit)
r++;
mask = -(level_code & 1);
level = (level^mask) - mask;
} else {
level = r->rltab[level_code][0];
if(!level)
break;
run = r->rltab[level_code][1];
r += r->rltab[level_code][2];
}
level_buf[i] = level;
run_buf[i] = run;
}
if(dequant(h,level_buf, run_buf, block, ff_cavs_dequant_mul[qp],
ff_cavs_dequant_shift[qp], i))
return -1;
h->s.dsp.cavs_idct8_add(dst,block,stride);
return 0;
}
| {
"code": [
" DCTELEM level_buf[64];",
" uint8_t run_buf[64];"
],
"line_no": [
9,
11
]
} | static int FUNC_0(AVSContext *VAR_0, GetBitContext *VAR_1,
const dec_2dvlc_t *VAR_2, int VAR_3,
int VAR_4, uint8_t *VAR_5, int VAR_6) {
int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;
DCTELEM level_buf[64];
uint8_t run_buf[64];
DCTELEM *block = VAR_0->block;
for(VAR_7=0;VAR_7<65;VAR_7++) {
VAR_8 = get_ue_code(VAR_1,VAR_2->golomb_order);
if(VAR_8 >= ESCAPE_CODE) {
VAR_11 = ((VAR_8 - ESCAPE_CODE) >> 1) + 1;
VAR_9 = get_ue_code(VAR_1,VAR_3);
VAR_10 = VAR_9 + (VAR_11 > VAR_2->max_run ? 1 : VAR_2->level_add[VAR_11]);
while(VAR_10 > VAR_2->inc_limit)
VAR_2++;
VAR_12 = -(VAR_8 & 1);
VAR_10 = (VAR_10^VAR_12) - VAR_12;
} else {
VAR_10 = VAR_2->rltab[VAR_8][0];
if(!VAR_10)
break;
VAR_11 = VAR_2->rltab[VAR_8][1];
VAR_2 += VAR_2->rltab[VAR_8][2];
}
level_buf[VAR_7] = VAR_10;
run_buf[VAR_7] = VAR_11;
}
if(dequant(VAR_0,level_buf, run_buf, block, ff_cavs_dequant_mul[VAR_4],
ff_cavs_dequant_shift[VAR_4], VAR_7))
return -1;
VAR_0->s.dsp.cavs_idct8_add(VAR_5,block,VAR_6);
return 0;
}
| [
"static int FUNC_0(AVSContext *VAR_0, GetBitContext *VAR_1,\nconst dec_2dvlc_t *VAR_2, int VAR_3,\nint VAR_4, uint8_t *VAR_5, int VAR_6) {",
"int VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12;",
"DCTELEM level_buf[64];",
"uint8_t run_buf[64];",
"DCTELEM *block = VAR_0->block;",
"for(VAR_7=0;VAR_7<65;VAR_7++) {",
"VAR_8 = get_ue_code(VAR_1,VAR_2->golomb_order);",
"if(VAR_8 >= ESCAPE_CODE) {",
"VAR_11 = ((VAR_8 - ESCAPE_CODE) >> 1) + 1;",
"VAR_9 = get_ue_code(VAR_1,VAR_3);",
"VAR_10 = VAR_9 + (VAR_11 > VAR_2->max_run ? 1 : VAR_2->level_add[VAR_11]);",
"while(VAR_10 > VAR_2->inc_limit)\nVAR_2++;",
"VAR_12 = -(VAR_8 & 1);",
"VAR_10 = (VAR_10^VAR_12) - VAR_12;",
"} else {",
"VAR_10 = VAR_2->rltab[VAR_8][0];",
"if(!VAR_10)\nbreak;",
"VAR_11 = VAR_2->rltab[VAR_8][1];",
"VAR_2 += VAR_2->rltab[VAR_8][2];",
"}",
"level_buf[VAR_7] = VAR_10;",
"run_buf[VAR_7] = VAR_11;",
"}",
"if(dequant(VAR_0,level_buf, run_buf, block, ff_cavs_dequant_mul[VAR_4],\nff_cavs_dequant_shift[VAR_4], VAR_7))\nreturn -1;",
"VAR_0->s.dsp.cavs_idct8_add(VAR_5,block,VAR_6);",
"return 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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
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
]
] |
25,065 | int ff_thread_decode_frame(AVCodecContext *avctx,
AVFrame *picture, int *got_picture_ptr,
AVPacket *avpkt)
{
FrameThreadContext *fctx = avctx->internal->thread_ctx;
int finished = fctx->next_finished;
PerThreadContext *p;
int err;
/* release the async lock, permitting blocked hwaccel threads to
* go forward while we are in this function */
async_unlock(fctx);
/*
* Submit a packet to the next decoding thread.
*/
p = &fctx->threads[fctx->next_decoding];
err = update_context_from_user(p->avctx, avctx);
if (err)
goto finish;
err = submit_packet(p, avpkt);
if (err)
goto finish;
/*
* If we're still receiving the initial packets, don't return a frame.
*/
if (fctx->next_decoding > (avctx->thread_count-1-(avctx->codec_id == AV_CODEC_ID_FFV1)))
fctx->delaying = 0;
if (fctx->delaying) {
*got_picture_ptr=0;
if (avpkt->size) {
err = avpkt->size;
goto finish;
}
}
/*
* Return the next available frame from the oldest thread.
* If we're at the end of the stream, then we have to skip threads that
* didn't output a frame, because we don't want to accidentally signal
* EOF (avpkt->size == 0 && *got_picture_ptr == 0).
*/
do {
p = &fctx->threads[finished++];
if (atomic_load(&p->state) != STATE_INPUT_READY) {
pthread_mutex_lock(&p->progress_mutex);
while (atomic_load_explicit(&p->state, memory_order_relaxed) != STATE_INPUT_READY)
pthread_cond_wait(&p->output_cond, &p->progress_mutex);
pthread_mutex_unlock(&p->progress_mutex);
}
av_frame_move_ref(picture, p->frame);
*got_picture_ptr = p->got_frame;
picture->pkt_dts = p->avpkt.dts;
if (p->result < 0)
err = p->result;
/*
* A later call with avkpt->size == 0 may loop over all threads,
* including this one, searching for a frame to return before being
* stopped by the "finished != fctx->next_finished" condition.
* Make sure we don't mistakenly return the same frame again.
*/
p->got_frame = 0;
if (finished >= avctx->thread_count) finished = 0;
} while (!avpkt->size && !*got_picture_ptr && finished != fctx->next_finished);
update_context_from_thread(avctx, p->avctx, 1);
if (fctx->next_decoding >= avctx->thread_count) fctx->next_decoding = 0;
fctx->next_finished = finished;
/* return the size of the consumed packet if no error occurred */
if (err >= 0)
err = avpkt->size;
finish:
async_lock(fctx);
return err;
}
| true | FFmpeg | 1269cd5b6f540bef5913bf134d2f461aac50d70b | int ff_thread_decode_frame(AVCodecContext *avctx,
AVFrame *picture, int *got_picture_ptr,
AVPacket *avpkt)
{
FrameThreadContext *fctx = avctx->internal->thread_ctx;
int finished = fctx->next_finished;
PerThreadContext *p;
int err;
async_unlock(fctx);
p = &fctx->threads[fctx->next_decoding];
err = update_context_from_user(p->avctx, avctx);
if (err)
goto finish;
err = submit_packet(p, avpkt);
if (err)
goto finish;
if (fctx->next_decoding > (avctx->thread_count-1-(avctx->codec_id == AV_CODEC_ID_FFV1)))
fctx->delaying = 0;
if (fctx->delaying) {
*got_picture_ptr=0;
if (avpkt->size) {
err = avpkt->size;
goto finish;
}
}
do {
p = &fctx->threads[finished++];
if (atomic_load(&p->state) != STATE_INPUT_READY) {
pthread_mutex_lock(&p->progress_mutex);
while (atomic_load_explicit(&p->state, memory_order_relaxed) != STATE_INPUT_READY)
pthread_cond_wait(&p->output_cond, &p->progress_mutex);
pthread_mutex_unlock(&p->progress_mutex);
}
av_frame_move_ref(picture, p->frame);
*got_picture_ptr = p->got_frame;
picture->pkt_dts = p->avpkt.dts;
if (p->result < 0)
err = p->result;
p->got_frame = 0;
if (finished >= avctx->thread_count) finished = 0;
} while (!avpkt->size && !*got_picture_ptr && finished != fctx->next_finished);
update_context_from_thread(avctx, p->avctx, 1);
if (fctx->next_decoding >= avctx->thread_count) fctx->next_decoding = 0;
fctx->next_finished = finished;
if (err >= 0)
err = avpkt->size;
finish:
async_lock(fctx);
return err;
}
| {
"code": [
" err = update_context_from_user(p->avctx, avctx);",
" if (err)",
" goto finish;",
" err = submit_packet(p, avpkt);"
],
"line_no": [
37,
39,
41,
43
]
} | int FUNC_0(AVCodecContext *VAR_0,
AVFrame *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{
FrameThreadContext *fctx = VAR_0->internal->thread_ctx;
int VAR_4 = fctx->next_finished;
PerThreadContext *p;
int VAR_5;
async_unlock(fctx);
p = &fctx->threads[fctx->next_decoding];
VAR_5 = update_context_from_user(p->VAR_0, VAR_0);
if (VAR_5)
goto finish;
VAR_5 = submit_packet(p, VAR_3);
if (VAR_5)
goto finish;
if (fctx->next_decoding > (VAR_0->thread_count-1-(VAR_0->codec_id == AV_CODEC_ID_FFV1)))
fctx->delaying = 0;
if (fctx->delaying) {
*VAR_2=0;
if (VAR_3->size) {
VAR_5 = VAR_3->size;
goto finish;
}
}
do {
p = &fctx->threads[VAR_4++];
if (atomic_load(&p->state) != STATE_INPUT_READY) {
pthread_mutex_lock(&p->progress_mutex);
while (atomic_load_explicit(&p->state, memory_order_relaxed) != STATE_INPUT_READY)
pthread_cond_wait(&p->output_cond, &p->progress_mutex);
pthread_mutex_unlock(&p->progress_mutex);
}
av_frame_move_ref(VAR_1, p->frame);
*VAR_2 = p->got_frame;
VAR_1->pkt_dts = p->VAR_3.dts;
if (p->result < 0)
VAR_5 = p->result;
p->got_frame = 0;
if (VAR_4 >= VAR_0->thread_count) VAR_4 = 0;
} while (!VAR_3->size && !*VAR_2 && VAR_4 != fctx->next_finished);
update_context_from_thread(VAR_0, p->VAR_0, 1);
if (fctx->next_decoding >= VAR_0->thread_count) fctx->next_decoding = 0;
fctx->next_finished = VAR_4;
if (VAR_5 >= 0)
VAR_5 = VAR_3->size;
finish:
async_lock(fctx);
return VAR_5;
}
| [
"int FUNC_0(AVCodecContext *VAR_0,\nAVFrame *VAR_1, int *VAR_2,\nAVPacket *VAR_3)\n{",
"FrameThreadContext *fctx = VAR_0->internal->thread_ctx;",
"int VAR_4 = fctx->next_finished;",
"PerThreadContext *p;",
"int VAR_5;",
"async_unlock(fctx);",
"p = &fctx->threads[fctx->next_decoding];",
"VAR_5 = update_context_from_user(p->VAR_0, VAR_0);",
"if (VAR_5)\ngoto finish;",
"VAR_5 = submit_packet(p, VAR_3);",
"if (VAR_5)\ngoto finish;",
"if (fctx->next_decoding > (VAR_0->thread_count-1-(VAR_0->codec_id == AV_CODEC_ID_FFV1)))\nfctx->delaying = 0;",
"if (fctx->delaying) {",
"*VAR_2=0;",
"if (VAR_3->size) {",
"VAR_5 = VAR_3->size;",
"goto finish;",
"}",
"}",
"do {",
"p = &fctx->threads[VAR_4++];",
"if (atomic_load(&p->state) != STATE_INPUT_READY) {",
"pthread_mutex_lock(&p->progress_mutex);",
"while (atomic_load_explicit(&p->state, memory_order_relaxed) != STATE_INPUT_READY)\npthread_cond_wait(&p->output_cond, &p->progress_mutex);",
"pthread_mutex_unlock(&p->progress_mutex);",
"}",
"av_frame_move_ref(VAR_1, p->frame);",
"*VAR_2 = p->got_frame;",
"VAR_1->pkt_dts = p->VAR_3.dts;",
"if (p->result < 0)\nVAR_5 = p->result;",
"p->got_frame = 0;",
"if (VAR_4 >= VAR_0->thread_count) VAR_4 = 0;",
"} while (!VAR_3->size && !*VAR_2 && VAR_4 != fctx->next_finished);",
"update_context_from_thread(VAR_0, p->VAR_0, 1);",
"if (fctx->next_decoding >= VAR_0->thread_count) fctx->next_decoding = 0;",
"fctx->next_finished = VAR_4;",
"if (VAR_5 >= 0)\nVAR_5 = VAR_3->size;",
"finish:\nasync_lock(fctx);",
"return VAR_5;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
23
],
[
35
],
[
37
],
[
39,
41
],
[
43
],
[
45,
47
],
[
59,
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
95
],
[
97
],
[
101
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
115
],
[
117
],
[
119
],
[
123,
125
],
[
141
],
[
145
],
[
147
],
[
151
],
[
155
],
[
159
],
[
165,
167
],
[
169,
171
],
[
173
],
[
175
]
] |
25,067 | static void gen_tlbld_6xx(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_6xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
#endif
}
| true | qemu | 9b2fadda3e0196ffd485adde4fe9cdd6fae35300 | static void gen_tlbld_6xx(DisasContext *ctx)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(ctx->pr)) {
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_6xx_tlbd(cpu_env, cpu_gpr[rB(ctx->opcode)]);
#endif
}
| {
"code": [
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
"#endif",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
" if (unlikely(ctx->pr)) {",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#else",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
"#if defined(CONFIG_USER_ONLY)",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
" if (unlikely(ctx->pr)) {",
" gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC);",
"#endif"
],
"line_no": [
13,
7,
11,
13,
7,
11,
13,
7,
13,
5,
9,
11,
21,
5,
9,
11,
21,
21,
5,
9,
11,
7,
11,
13,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
11,
21,
7,
13,
21,
7,
11,
13,
21,
7,
13,
21,
7,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
11,
21,
11,
21,
11,
21,
11,
21,
5,
7,
9,
11,
13,
21,
7,
11,
13,
21,
5,
7,
9,
11,
13,
21,
5,
7,
9,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
5,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21,
7,
11,
13,
21
]
} | static void FUNC_0(DisasContext *VAR_0)
{
#if defined(CONFIG_USER_ONLY)
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
#else
if (unlikely(VAR_0->pr)) {
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);
return;
}
gen_helper_6xx_tlbd(cpu_env, cpu_gpr[rB(VAR_0->opcode)]);
#endif
}
| [
"static void FUNC_0(DisasContext *VAR_0)\n{",
"#if defined(CONFIG_USER_ONLY)\ngen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"#else\nif (unlikely(VAR_0->pr)) {",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_OPC);",
"return;",
"}",
"gen_helper_6xx_tlbd(cpu_env, cpu_gpr[rB(VAR_0->opcode)]);",
"#endif\n}"
] | [
0,
1,
1,
1,
0,
0,
0,
1
] | [
[
1,
3
],
[
5,
7
],
[
9,
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21,
23
]
] |
25,068 | static int ehci_process_itd(EHCIState *ehci,
EHCIitd *itd)
{
USBDevice *dev;
USBEndpoint *ep;
int ret;
uint32_t i, len, pid, dir, devaddr, endp;
uint32_t pg, off, ptr1, ptr2, max, mult;
dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION);
devaddr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR);
endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP);
max = get_field(itd->bufptr[1], ITD_BUFPTR_MAXPKT);
mult = get_field(itd->bufptr[2], ITD_BUFPTR_MULT);
for(i = 0; i < 8; i++) {
if (itd->transact[i] & ITD_XACT_ACTIVE) {
pg = get_field(itd->transact[i], ITD_XACT_PGSEL);
off = itd->transact[i] & ITD_XACT_OFFSET_MASK;
ptr1 = (itd->bufptr[pg] & ITD_BUFPTR_MASK);
ptr2 = (itd->bufptr[pg+1] & ITD_BUFPTR_MASK);
len = get_field(itd->transact[i], ITD_XACT_LENGTH);
if (len > max * mult) {
len = max * mult;
}
if (len > BUFF_SIZE) {
return USB_RET_PROCERR;
}
pci_dma_sglist_init(&ehci->isgl, &ehci->dev, 2);
if (off + len > 4096) {
/* transfer crosses page border */
uint32_t len2 = off + len - 4096;
uint32_t len1 = len - len2;
qemu_sglist_add(&ehci->isgl, ptr1 + off, len1);
qemu_sglist_add(&ehci->isgl, ptr2, len2);
} else {
qemu_sglist_add(&ehci->isgl, ptr1 + off, len);
}
pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT;
dev = ehci_find_device(ehci, devaddr);
ep = usb_ep_get(dev, pid, endp);
usb_packet_setup(&ehci->ipacket, pid, ep);
usb_packet_map(&ehci->ipacket, &ehci->isgl);
ret = usb_handle_packet(dev, &ehci->ipacket);
usb_packet_unmap(&ehci->ipacket);
qemu_sglist_destroy(&ehci->isgl);
#if 0
/* In isoch, there is no facility to indicate a NAK so let's
* instead just complete a zero-byte transaction. Setting
* DBERR seems too draconian.
*/
if (ret == USB_RET_NAK) {
if (ehci->isoch_pause > 0) {
DPRINTF("ISOCH: received a NAK but paused so returning\n");
ehci->isoch_pause--;
return 0;
} else if (ehci->isoch_pause == -1) {
DPRINTF("ISOCH: recv NAK & isoch pause inactive, setting\n");
// Pause frindex for up to 50 msec waiting for data from
// remote
ehci->isoch_pause = 50;
return 0;
} else {
DPRINTF("ISOCH: isoch pause timeout! return 0\n");
ret = 0;
}
} else {
DPRINTF("ISOCH: received ACK, clearing pause\n");
ehci->isoch_pause = -1;
}
#else
if (ret == USB_RET_NAK) {
ret = 0;
}
#endif
if (ret >= 0) {
if (!dir) {
/* OUT */
set_field(&itd->transact[i], len - ret, ITD_XACT_LENGTH);
} else {
/* IN */
set_field(&itd->transact[i], ret, ITD_XACT_LENGTH);
}
if (itd->transact[i] & ITD_XACT_IOC) {
ehci_record_interrupt(ehci, USBSTS_INT);
}
}
itd->transact[i] &= ~ITD_XACT_ACTIVE;
}
}
return 0;
}
| true | qemu | aa0568ff2559d7717f4684af6a83d0bd1a125f56 | static int ehci_process_itd(EHCIState *ehci,
EHCIitd *itd)
{
USBDevice *dev;
USBEndpoint *ep;
int ret;
uint32_t i, len, pid, dir, devaddr, endp;
uint32_t pg, off, ptr1, ptr2, max, mult;
dir =(itd->bufptr[1] & ITD_BUFPTR_DIRECTION);
devaddr = get_field(itd->bufptr[0], ITD_BUFPTR_DEVADDR);
endp = get_field(itd->bufptr[0], ITD_BUFPTR_EP);
max = get_field(itd->bufptr[1], ITD_BUFPTR_MAXPKT);
mult = get_field(itd->bufptr[2], ITD_BUFPTR_MULT);
for(i = 0; i < 8; i++) {
if (itd->transact[i] & ITD_XACT_ACTIVE) {
pg = get_field(itd->transact[i], ITD_XACT_PGSEL);
off = itd->transact[i] & ITD_XACT_OFFSET_MASK;
ptr1 = (itd->bufptr[pg] & ITD_BUFPTR_MASK);
ptr2 = (itd->bufptr[pg+1] & ITD_BUFPTR_MASK);
len = get_field(itd->transact[i], ITD_XACT_LENGTH);
if (len > max * mult) {
len = max * mult;
}
if (len > BUFF_SIZE) {
return USB_RET_PROCERR;
}
pci_dma_sglist_init(&ehci->isgl, &ehci->dev, 2);
if (off + len > 4096) {
uint32_t len2 = off + len - 4096;
uint32_t len1 = len - len2;
qemu_sglist_add(&ehci->isgl, ptr1 + off, len1);
qemu_sglist_add(&ehci->isgl, ptr2, len2);
} else {
qemu_sglist_add(&ehci->isgl, ptr1 + off, len);
}
pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT;
dev = ehci_find_device(ehci, devaddr);
ep = usb_ep_get(dev, pid, endp);
usb_packet_setup(&ehci->ipacket, pid, ep);
usb_packet_map(&ehci->ipacket, &ehci->isgl);
ret = usb_handle_packet(dev, &ehci->ipacket);
usb_packet_unmap(&ehci->ipacket);
qemu_sglist_destroy(&ehci->isgl);
#if 0
if (ret == USB_RET_NAK) {
if (ehci->isoch_pause > 0) {
DPRINTF("ISOCH: received a NAK but paused so returning\n");
ehci->isoch_pause--;
return 0;
} else if (ehci->isoch_pause == -1) {
DPRINTF("ISOCH: recv NAK & isoch pause inactive, setting\n");
ehci->isoch_pause = 50;
return 0;
} else {
DPRINTF("ISOCH: isoch pause timeout! return 0\n");
ret = 0;
}
} else {
DPRINTF("ISOCH: received ACK, clearing pause\n");
ehci->isoch_pause = -1;
}
#else
if (ret == USB_RET_NAK) {
ret = 0;
}
#endif
if (ret >= 0) {
if (!dir) {
set_field(&itd->transact[i], len - ret, ITD_XACT_LENGTH);
} else {
set_field(&itd->transact[i], ret, ITD_XACT_LENGTH);
}
if (itd->transact[i] & ITD_XACT_IOC) {
ehci_record_interrupt(ehci, USBSTS_INT);
}
}
itd->transact[i] &= ~ITD_XACT_ACTIVE;
}
}
return 0;
}
| {
"code": [
" usb_packet_setup(&ehci->ipacket, pid, ep);",
" usb_packet_map(&ehci->ipacket, &ehci->isgl);",
" ret = usb_handle_packet(dev, &ehci->ipacket);",
" usb_packet_unmap(&ehci->ipacket);"
],
"line_no": [
93,
95,
99,
103
]
} | static int FUNC_0(EHCIState *VAR_0,
EHCIitd *VAR_1)
{
USBDevice *dev;
USBEndpoint *ep;
int VAR_2;
uint32_t i, len, pid, dir, devaddr, endp;
uint32_t pg, off, ptr1, ptr2, max, mult;
dir =(VAR_1->bufptr[1] & ITD_BUFPTR_DIRECTION);
devaddr = get_field(VAR_1->bufptr[0], ITD_BUFPTR_DEVADDR);
endp = get_field(VAR_1->bufptr[0], ITD_BUFPTR_EP);
max = get_field(VAR_1->bufptr[1], ITD_BUFPTR_MAXPKT);
mult = get_field(VAR_1->bufptr[2], ITD_BUFPTR_MULT);
for(i = 0; i < 8; i++) {
if (VAR_1->transact[i] & ITD_XACT_ACTIVE) {
pg = get_field(VAR_1->transact[i], ITD_XACT_PGSEL);
off = VAR_1->transact[i] & ITD_XACT_OFFSET_MASK;
ptr1 = (VAR_1->bufptr[pg] & ITD_BUFPTR_MASK);
ptr2 = (VAR_1->bufptr[pg+1] & ITD_BUFPTR_MASK);
len = get_field(VAR_1->transact[i], ITD_XACT_LENGTH);
if (len > max * mult) {
len = max * mult;
}
if (len > BUFF_SIZE) {
return USB_RET_PROCERR;
}
pci_dma_sglist_init(&VAR_0->isgl, &VAR_0->dev, 2);
if (off + len > 4096) {
uint32_t len2 = off + len - 4096;
uint32_t len1 = len - len2;
qemu_sglist_add(&VAR_0->isgl, ptr1 + off, len1);
qemu_sglist_add(&VAR_0->isgl, ptr2, len2);
} else {
qemu_sglist_add(&VAR_0->isgl, ptr1 + off, len);
}
pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT;
dev = ehci_find_device(VAR_0, devaddr);
ep = usb_ep_get(dev, pid, endp);
usb_packet_setup(&VAR_0->ipacket, pid, ep);
usb_packet_map(&VAR_0->ipacket, &VAR_0->isgl);
VAR_2 = usb_handle_packet(dev, &VAR_0->ipacket);
usb_packet_unmap(&VAR_0->ipacket);
qemu_sglist_destroy(&VAR_0->isgl);
#if 0
if (VAR_2 == USB_RET_NAK) {
if (VAR_0->isoch_pause > 0) {
DPRINTF("ISOCH: received a NAK but paused so returning\n");
VAR_0->isoch_pause--;
return 0;
} else if (VAR_0->isoch_pause == -1) {
DPRINTF("ISOCH: recv NAK & isoch pause inactive, setting\n");
VAR_0->isoch_pause = 50;
return 0;
} else {
DPRINTF("ISOCH: isoch pause timeout! return 0\n");
VAR_2 = 0;
}
} else {
DPRINTF("ISOCH: received ACK, clearing pause\n");
VAR_0->isoch_pause = -1;
}
#else
if (VAR_2 == USB_RET_NAK) {
VAR_2 = 0;
}
#endif
if (VAR_2 >= 0) {
if (!dir) {
set_field(&VAR_1->transact[i], len - VAR_2, ITD_XACT_LENGTH);
} else {
set_field(&VAR_1->transact[i], VAR_2, ITD_XACT_LENGTH);
}
if (VAR_1->transact[i] & ITD_XACT_IOC) {
ehci_record_interrupt(VAR_0, USBSTS_INT);
}
}
VAR_1->transact[i] &= ~ITD_XACT_ACTIVE;
}
}
return 0;
}
| [
"static int FUNC_0(EHCIState *VAR_0,\nEHCIitd *VAR_1)\n{",
"USBDevice *dev;",
"USBEndpoint *ep;",
"int VAR_2;",
"uint32_t i, len, pid, dir, devaddr, endp;",
"uint32_t pg, off, ptr1, ptr2, max, mult;",
"dir =(VAR_1->bufptr[1] & ITD_BUFPTR_DIRECTION);",
"devaddr = get_field(VAR_1->bufptr[0], ITD_BUFPTR_DEVADDR);",
"endp = get_field(VAR_1->bufptr[0], ITD_BUFPTR_EP);",
"max = get_field(VAR_1->bufptr[1], ITD_BUFPTR_MAXPKT);",
"mult = get_field(VAR_1->bufptr[2], ITD_BUFPTR_MULT);",
"for(i = 0; i < 8; i++) {",
"if (VAR_1->transact[i] & ITD_XACT_ACTIVE) {",
"pg = get_field(VAR_1->transact[i], ITD_XACT_PGSEL);",
"off = VAR_1->transact[i] & ITD_XACT_OFFSET_MASK;",
"ptr1 = (VAR_1->bufptr[pg] & ITD_BUFPTR_MASK);",
"ptr2 = (VAR_1->bufptr[pg+1] & ITD_BUFPTR_MASK);",
"len = get_field(VAR_1->transact[i], ITD_XACT_LENGTH);",
"if (len > max * mult) {",
"len = max * mult;",
"}",
"if (len > BUFF_SIZE) {",
"return USB_RET_PROCERR;",
"}",
"pci_dma_sglist_init(&VAR_0->isgl, &VAR_0->dev, 2);",
"if (off + len > 4096) {",
"uint32_t len2 = off + len - 4096;",
"uint32_t len1 = len - len2;",
"qemu_sglist_add(&VAR_0->isgl, ptr1 + off, len1);",
"qemu_sglist_add(&VAR_0->isgl, ptr2, len2);",
"} else {",
"qemu_sglist_add(&VAR_0->isgl, ptr1 + off, len);",
"}",
"pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT;",
"dev = ehci_find_device(VAR_0, devaddr);",
"ep = usb_ep_get(dev, pid, endp);",
"usb_packet_setup(&VAR_0->ipacket, pid, ep);",
"usb_packet_map(&VAR_0->ipacket, &VAR_0->isgl);",
"VAR_2 = usb_handle_packet(dev, &VAR_0->ipacket);",
"usb_packet_unmap(&VAR_0->ipacket);",
"qemu_sglist_destroy(&VAR_0->isgl);",
"#if 0\nif (VAR_2 == USB_RET_NAK) {",
"if (VAR_0->isoch_pause > 0) {",
"DPRINTF(\"ISOCH: received a NAK but paused so returning\\n\");",
"VAR_0->isoch_pause--;",
"return 0;",
"} else if (VAR_0->isoch_pause == -1) {",
"DPRINTF(\"ISOCH: recv NAK & isoch pause inactive, setting\\n\");",
"VAR_0->isoch_pause = 50;",
"return 0;",
"} else {",
"DPRINTF(\"ISOCH: isoch pause timeout! return 0\\n\");",
"VAR_2 = 0;",
"}",
"} else {",
"DPRINTF(\"ISOCH: received ACK, clearing pause\\n\");",
"VAR_0->isoch_pause = -1;",
"}",
"#else\nif (VAR_2 == USB_RET_NAK) {",
"VAR_2 = 0;",
"}",
"#endif\nif (VAR_2 >= 0) {",
"if (!dir) {",
"set_field(&VAR_1->transact[i], len - VAR_2, ITD_XACT_LENGTH);",
"} else {",
"set_field(&VAR_1->transact[i], VAR_2, ITD_XACT_LENGTH);",
"}",
"if (VAR_1->transact[i] & ITD_XACT_IOC) {",
"ehci_record_interrupt(VAR_0, USBSTS_INT);",
"}",
"}",
"VAR_1->transact[i] &= ~ITD_XACT_ACTIVE;",
"}",
"}",
"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,
1,
1,
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85
],
[
89
],
[
91
],
[
93
],
[
95
],
[
99
],
[
103
],
[
105
],
[
109,
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159,
161
],
[
163
],
[
165
],
[
167,
171
],
[
173
],
[
177
],
[
179
],
[
183
],
[
185
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
]
] |
25,069 | static int swf_probe(AVProbeData *p)
{
/* check file header */
if (p->buf_size <= 16)
return 0;
if ((p->buf[0] == 'F' || p->buf[0] == 'C') && p->buf[1] == 'W' &&
p->buf[2] == 'S')
return AVPROBE_SCORE_MAX;
else
return 0;
}
| false | FFmpeg | 87e8788680e16c51f6048af26f3f7830c35207a5 | static int swf_probe(AVProbeData *p)
{
if (p->buf_size <= 16)
return 0;
if ((p->buf[0] == 'F' || p->buf[0] == 'C') && p->buf[1] == 'W' &&
p->buf[2] == 'S')
return AVPROBE_SCORE_MAX;
else
return 0;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVProbeData *VAR_0)
{
if (VAR_0->buf_size <= 16)
return 0;
if ((VAR_0->buf[0] == 'F' || VAR_0->buf[0] == 'C') && VAR_0->buf[1] == 'W' &&
VAR_0->buf[2] == 'S')
return AVPROBE_SCORE_MAX;
else
return 0;
}
| [
"static int FUNC_0(AVProbeData *VAR_0)\n{",
"if (VAR_0->buf_size <= 16)\nreturn 0;",
"if ((VAR_0->buf[0] == 'F' || VAR_0->buf[0] == 'C') && VAR_0->buf[1] == 'W' &&\nVAR_0->buf[2] == 'S')\nreturn AVPROBE_SCORE_MAX;",
"else\nreturn 0;",
"}"
] | [
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
7,
9
],
[
11,
13,
15
],
[
17,
19
],
[
21
]
] |
25,070 | static int16_t *precalc_coefs(double dist25, int depth)
{
int i;
double gamma, simil, C;
int16_t *ct = av_malloc((512<<LUT_BITS)*sizeof(int16_t));
if (!ct)
return NULL;
gamma = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001);
for (i = -255<<LUT_BITS; i <= 255<<LUT_BITS; i++) {
double f = ((i<<(9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0; // midpoint of the bin
simil = 1.0 - FFABS(f) / 255.0;
C = pow(simil, gamma) * 256.0 * f;
ct[(256<<LUT_BITS)+i] = lrint(C);
}
ct[0] = !!dist25;
return ct;
}
| false | FFmpeg | 4240e6a92117811509be3e5f360a44dde8618040 | static int16_t *precalc_coefs(double dist25, int depth)
{
int i;
double gamma, simil, C;
int16_t *ct = av_malloc((512<<LUT_BITS)*sizeof(int16_t));
if (!ct)
return NULL;
gamma = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001);
for (i = -255<<LUT_BITS; i <= 255<<LUT_BITS; i++) {
double f = ((i<<(9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0;
simil = 1.0 - FFABS(f) / 255.0;
C = pow(simil, gamma) * 256.0 * f;
ct[(256<<LUT_BITS)+i] = lrint(C);
}
ct[0] = !!dist25;
return ct;
}
| {
"code": [],
"line_no": []
} | static int16_t *FUNC_0(double dist25, int depth)
{
int VAR_0;
double VAR_1, VAR_2, VAR_3;
int16_t *ct = av_malloc((512<<LUT_BITS)*sizeof(int16_t));
if (!ct)
return NULL;
VAR_1 = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001);
for (VAR_0 = -255<<LUT_BITS; VAR_0 <= 255<<LUT_BITS; VAR_0++) {
double f = ((VAR_0<<(9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0;
VAR_2 = 1.0 - FFABS(f) / 255.0;
VAR_3 = pow(VAR_2, VAR_1) * 256.0 * f;
ct[(256<<LUT_BITS)+VAR_0] = lrint(VAR_3);
}
ct[0] = !!dist25;
return ct;
}
| [
"static int16_t *FUNC_0(double dist25, int depth)\n{",
"int VAR_0;",
"double VAR_1, VAR_2, VAR_3;",
"int16_t *ct = av_malloc((512<<LUT_BITS)*sizeof(int16_t));",
"if (!ct)\nreturn NULL;",
"VAR_1 = log(0.25) / log(1.0 - FFMIN(dist25,252.0)/255.0 - 0.00001);",
"for (VAR_0 = -255<<LUT_BITS; VAR_0 <= 255<<LUT_BITS; VAR_0++) {",
"double f = ((VAR_0<<(9-LUT_BITS)) + (1<<(8-LUT_BITS)) - 1) / 512.0;",
"VAR_2 = 1.0 - FFABS(f) / 255.0;",
"VAR_3 = pow(VAR_2, VAR_1) * 256.0 * f;",
"ct[(256<<LUT_BITS)+VAR_0] = lrint(VAR_3);",
"}",
"ct[0] = !!dist25;",
"return ct;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11,
13
],
[
17
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
35
],
[
37
],
[
39
]
] |
25,072 | static void avc_biwgt_4x2_msa(uint8_t *src,
int32_t src_stride,
uint8_t *dst,
int32_t dst_stride,
int32_t log2_denom,
int32_t src_weight,
int32_t dst_weight,
int32_t offset_in)
{
uint32_t load0, load1, out0, out1;
v16i8 src_wgt, dst_wgt, wgt;
v16i8 src0, src1, dst0, dst1;
v8i16 temp0, temp1, denom, offset, add_val;
int32_t val = 128 * (src_weight + dst_weight);
offset_in = ((offset_in + 1) | 1) << log2_denom;
src_wgt = __msa_fill_b(src_weight);
dst_wgt = __msa_fill_b(dst_weight);
offset = __msa_fill_h(offset_in);
denom = __msa_fill_h(log2_denom + 1);
add_val = __msa_fill_h(val);
offset += add_val;
wgt = __msa_ilvev_b(dst_wgt, src_wgt);
load0 = LOAD_WORD(src);
src += src_stride;
load1 = LOAD_WORD(src);
src0 = (v16i8) __msa_fill_w(load0);
src1 = (v16i8) __msa_fill_w(load1);
load0 = LOAD_WORD(dst);
load1 = LOAD_WORD(dst + dst_stride);
dst0 = (v16i8) __msa_fill_w(load0);
dst1 = (v16i8) __msa_fill_w(load1);
XORI_B_4VECS_SB(src0, src1, dst0, dst1, src0, src1, dst0, dst1, 128);
ILVR_B_2VECS_SH(src0, src1, dst0, dst1, temp0, temp1);
temp0 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp0);
temp1 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp1);
temp0 >>= denom;
temp1 >>= denom;
temp0 = CLIP_UNSIGNED_CHAR_H(temp0);
temp1 = CLIP_UNSIGNED_CHAR_H(temp1);
dst0 = __msa_pckev_b((v16i8) temp0, (v16i8) temp0);
dst1 = __msa_pckev_b((v16i8) temp1, (v16i8) temp1);
out0 = __msa_copy_u_w((v4i32) dst0, 0);
out1 = __msa_copy_u_w((v4i32) dst1, 0);
STORE_WORD(dst, out0);
dst += dst_stride;
STORE_WORD(dst, out1);
}
| false | FFmpeg | bcd7bf7eeb09a395cc01698842d1b8be9af483fc | static void avc_biwgt_4x2_msa(uint8_t *src,
int32_t src_stride,
uint8_t *dst,
int32_t dst_stride,
int32_t log2_denom,
int32_t src_weight,
int32_t dst_weight,
int32_t offset_in)
{
uint32_t load0, load1, out0, out1;
v16i8 src_wgt, dst_wgt, wgt;
v16i8 src0, src1, dst0, dst1;
v8i16 temp0, temp1, denom, offset, add_val;
int32_t val = 128 * (src_weight + dst_weight);
offset_in = ((offset_in + 1) | 1) << log2_denom;
src_wgt = __msa_fill_b(src_weight);
dst_wgt = __msa_fill_b(dst_weight);
offset = __msa_fill_h(offset_in);
denom = __msa_fill_h(log2_denom + 1);
add_val = __msa_fill_h(val);
offset += add_val;
wgt = __msa_ilvev_b(dst_wgt, src_wgt);
load0 = LOAD_WORD(src);
src += src_stride;
load1 = LOAD_WORD(src);
src0 = (v16i8) __msa_fill_w(load0);
src1 = (v16i8) __msa_fill_w(load1);
load0 = LOAD_WORD(dst);
load1 = LOAD_WORD(dst + dst_stride);
dst0 = (v16i8) __msa_fill_w(load0);
dst1 = (v16i8) __msa_fill_w(load1);
XORI_B_4VECS_SB(src0, src1, dst0, dst1, src0, src1, dst0, dst1, 128);
ILVR_B_2VECS_SH(src0, src1, dst0, dst1, temp0, temp1);
temp0 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp0);
temp1 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp1);
temp0 >>= denom;
temp1 >>= denom;
temp0 = CLIP_UNSIGNED_CHAR_H(temp0);
temp1 = CLIP_UNSIGNED_CHAR_H(temp1);
dst0 = __msa_pckev_b((v16i8) temp0, (v16i8) temp0);
dst1 = __msa_pckev_b((v16i8) temp1, (v16i8) temp1);
out0 = __msa_copy_u_w((v4i32) dst0, 0);
out1 = __msa_copy_u_w((v4i32) dst1, 0);
STORE_WORD(dst, out0);
dst += dst_stride;
STORE_WORD(dst, out1);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(uint8_t *VAR_0,
int32_t VAR_1,
uint8_t *VAR_2,
int32_t VAR_3,
int32_t VAR_4,
int32_t VAR_5,
int32_t VAR_6,
int32_t VAR_7)
{
uint32_t load0, load1, out0, out1;
v16i8 src_wgt, dst_wgt, wgt;
v16i8 src0, src1, dst0, dst1;
v8i16 temp0, temp1, denom, offset, add_val;
int32_t val = 128 * (VAR_5 + VAR_6);
VAR_7 = ((VAR_7 + 1) | 1) << VAR_4;
src_wgt = __msa_fill_b(VAR_5);
dst_wgt = __msa_fill_b(VAR_6);
offset = __msa_fill_h(VAR_7);
denom = __msa_fill_h(VAR_4 + 1);
add_val = __msa_fill_h(val);
offset += add_val;
wgt = __msa_ilvev_b(dst_wgt, src_wgt);
load0 = LOAD_WORD(VAR_0);
VAR_0 += VAR_1;
load1 = LOAD_WORD(VAR_0);
src0 = (v16i8) __msa_fill_w(load0);
src1 = (v16i8) __msa_fill_w(load1);
load0 = LOAD_WORD(VAR_2);
load1 = LOAD_WORD(VAR_2 + VAR_3);
dst0 = (v16i8) __msa_fill_w(load0);
dst1 = (v16i8) __msa_fill_w(load1);
XORI_B_4VECS_SB(src0, src1, dst0, dst1, src0, src1, dst0, dst1, 128);
ILVR_B_2VECS_SH(src0, src1, dst0, dst1, temp0, temp1);
temp0 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp0);
temp1 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp1);
temp0 >>= denom;
temp1 >>= denom;
temp0 = CLIP_UNSIGNED_CHAR_H(temp0);
temp1 = CLIP_UNSIGNED_CHAR_H(temp1);
dst0 = __msa_pckev_b((v16i8) temp0, (v16i8) temp0);
dst1 = __msa_pckev_b((v16i8) temp1, (v16i8) temp1);
out0 = __msa_copy_u_w((v4i32) dst0, 0);
out1 = __msa_copy_u_w((v4i32) dst1, 0);
STORE_WORD(VAR_2, out0);
VAR_2 += VAR_3;
STORE_WORD(VAR_2, out1);
}
| [
"static void FUNC_0(uint8_t *VAR_0,\nint32_t VAR_1,\nuint8_t *VAR_2,\nint32_t VAR_3,\nint32_t VAR_4,\nint32_t VAR_5,\nint32_t VAR_6,\nint32_t VAR_7)\n{",
"uint32_t load0, load1, out0, out1;",
"v16i8 src_wgt, dst_wgt, wgt;",
"v16i8 src0, src1, dst0, dst1;",
"v8i16 temp0, temp1, denom, offset, add_val;",
"int32_t val = 128 * (VAR_5 + VAR_6);",
"VAR_7 = ((VAR_7 + 1) | 1) << VAR_4;",
"src_wgt = __msa_fill_b(VAR_5);",
"dst_wgt = __msa_fill_b(VAR_6);",
"offset = __msa_fill_h(VAR_7);",
"denom = __msa_fill_h(VAR_4 + 1);",
"add_val = __msa_fill_h(val);",
"offset += add_val;",
"wgt = __msa_ilvev_b(dst_wgt, src_wgt);",
"load0 = LOAD_WORD(VAR_0);",
"VAR_0 += VAR_1;",
"load1 = LOAD_WORD(VAR_0);",
"src0 = (v16i8) __msa_fill_w(load0);",
"src1 = (v16i8) __msa_fill_w(load1);",
"load0 = LOAD_WORD(VAR_2);",
"load1 = LOAD_WORD(VAR_2 + VAR_3);",
"dst0 = (v16i8) __msa_fill_w(load0);",
"dst1 = (v16i8) __msa_fill_w(load1);",
"XORI_B_4VECS_SB(src0, src1, dst0, dst1, src0, src1, dst0, dst1, 128);",
"ILVR_B_2VECS_SH(src0, src1, dst0, dst1, temp0, temp1);",
"temp0 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp0);",
"temp1 = __msa_dpadd_s_h(offset, wgt, (v16i8) temp1);",
"temp0 >>= denom;",
"temp1 >>= denom;",
"temp0 = CLIP_UNSIGNED_CHAR_H(temp0);",
"temp1 = CLIP_UNSIGNED_CHAR_H(temp1);",
"dst0 = __msa_pckev_b((v16i8) temp0, (v16i8) temp0);",
"dst1 = __msa_pckev_b((v16i8) temp1, (v16i8) temp1);",
"out0 = __msa_copy_u_w((v4i32) dst0, 0);",
"out1 = __msa_copy_u_w((v4i32) dst1, 0);",
"STORE_WORD(VAR_2, out0);",
"VAR_2 += VAR_3;",
"STORE_WORD(VAR_2, out1);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
43
],
[
45
],
[
49
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79
],
[
83
],
[
87
],
[
89
],
[
93
],
[
95
],
[
99
],
[
101
],
[
105
],
[
107
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
]
] |
25,073 | static int asf_read_value(AVFormatContext *s, uint8_t *name, uint16_t name_len,
uint16_t val_len, int type, AVDictionary **met)
{
int ret;
uint8_t *value;
uint16_t buflen = 2 * val_len + 1;
AVIOContext *pb = s->pb;
value = av_malloc(buflen);
if (!value)
return AVERROR(ENOMEM);
if (type == ASF_UNICODE) {
// get_asf_string reads UTF-16 and converts it to UTF-8 which needs longer buffer
if ((ret = get_asf_string(pb, val_len, value, buflen)) < 0)
goto failed;
if (av_dict_set(met, name, value, 0) < 0)
av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n");
} else {
char buf[256];
if (val_len > sizeof(buf)) {
ret = AVERROR_INVALIDDATA;
goto failed;
}
if ((ret = avio_read(pb, value, val_len)) < 0)
goto failed;
if (ret < 2 * val_len)
value[ret] = '\0';
else
value[2 * val_len - 1] = '\0';
snprintf(buf, sizeof(buf), "%s", value);
if (av_dict_set(met, name, buf, 0) < 0)
av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n");
}
av_freep(&value);
return 0;
failed:
av_freep(&value);
return ret;
}
| true | FFmpeg | fdbc544d29176ba69d67dd879df4696f0a19052e | static int asf_read_value(AVFormatContext *s, uint8_t *name, uint16_t name_len,
uint16_t val_len, int type, AVDictionary **met)
{
int ret;
uint8_t *value;
uint16_t buflen = 2 * val_len + 1;
AVIOContext *pb = s->pb;
value = av_malloc(buflen);
if (!value)
return AVERROR(ENOMEM);
if (type == ASF_UNICODE) {
if ((ret = get_asf_string(pb, val_len, value, buflen)) < 0)
goto failed;
if (av_dict_set(met, name, value, 0) < 0)
av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n");
} else {
char buf[256];
if (val_len > sizeof(buf)) {
ret = AVERROR_INVALIDDATA;
goto failed;
}
if ((ret = avio_read(pb, value, val_len)) < 0)
goto failed;
if (ret < 2 * val_len)
value[ret] = '\0';
else
value[2 * val_len - 1] = '\0';
snprintf(buf, sizeof(buf), "%s", value);
if (av_dict_set(met, name, buf, 0) < 0)
av_log(s, AV_LOG_WARNING, "av_dict_set failed.\n");
}
av_freep(&value);
return 0;
failed:
av_freep(&value);
return ret;
}
| {
"code": [
"static int asf_read_value(AVFormatContext *s, uint8_t *name, uint16_t name_len,"
],
"line_no": [
1
]
} | static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, uint16_t VAR_2,
uint16_t VAR_3, int VAR_4, AVDictionary **VAR_5)
{
int VAR_6;
uint8_t *value;
uint16_t buflen = 2 * VAR_3 + 1;
AVIOContext *pb = VAR_0->pb;
value = av_malloc(buflen);
if (!value)
return AVERROR(ENOMEM);
if (VAR_4 == ASF_UNICODE) {
if ((VAR_6 = get_asf_string(pb, VAR_3, value, buflen)) < 0)
goto failed;
if (av_dict_set(VAR_5, VAR_1, value, 0) < 0)
av_log(VAR_0, AV_LOG_WARNING, "av_dict_set failed.\n");
} else {
char VAR_7[256];
if (VAR_3 > sizeof(VAR_7)) {
VAR_6 = AVERROR_INVALIDDATA;
goto failed;
}
if ((VAR_6 = avio_read(pb, value, VAR_3)) < 0)
goto failed;
if (VAR_6 < 2 * VAR_3)
value[VAR_6] = '\0';
else
value[2 * VAR_3 - 1] = '\0';
snprintf(VAR_7, sizeof(VAR_7), "%VAR_0", value);
if (av_dict_set(VAR_5, VAR_1, VAR_7, 0) < 0)
av_log(VAR_0, AV_LOG_WARNING, "av_dict_set failed.\n");
}
av_freep(&value);
return 0;
failed:
av_freep(&value);
return VAR_6;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, uint8_t *VAR_1, uint16_t VAR_2,\nuint16_t VAR_3, int VAR_4, AVDictionary **VAR_5)\n{",
"int VAR_6;",
"uint8_t *value;",
"uint16_t buflen = 2 * VAR_3 + 1;",
"AVIOContext *pb = VAR_0->pb;",
"value = av_malloc(buflen);",
"if (!value)\nreturn AVERROR(ENOMEM);",
"if (VAR_4 == ASF_UNICODE) {",
"if ((VAR_6 = get_asf_string(pb, VAR_3, value, buflen)) < 0)\ngoto failed;",
"if (av_dict_set(VAR_5, VAR_1, value, 0) < 0)\nav_log(VAR_0, AV_LOG_WARNING, \"av_dict_set failed.\\n\");",
"} else {",
"char VAR_7[256];",
"if (VAR_3 > sizeof(VAR_7)) {",
"VAR_6 = AVERROR_INVALIDDATA;",
"goto failed;",
"}",
"if ((VAR_6 = avio_read(pb, value, VAR_3)) < 0)\ngoto failed;",
"if (VAR_6 < 2 * VAR_3)\nvalue[VAR_6] = '\\0';",
"else\nvalue[2 * VAR_3 - 1] = '\\0';",
"snprintf(VAR_7, sizeof(VAR_7), \"%VAR_0\", value);",
"if (av_dict_set(VAR_5, VAR_1, VAR_7, 0) < 0)\nav_log(VAR_0, AV_LOG_WARNING, \"av_dict_set failed.\\n\");",
"}",
"av_freep(&value);",
"return 0;",
"failed:\nav_freep(&value);",
"return VAR_6;",
"}"
] | [
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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19,
21
],
[
23
],
[
27,
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55,
57
],
[
59
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
75,
77
],
[
79
],
[
81
]
] |
25,074 | static int vdi_check(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix)
{
/* TODO: additional checks possible. */
BDRVVdiState *s = (BDRVVdiState *)bs->opaque;
uint32_t blocks_allocated = 0;
uint32_t block;
uint32_t *bmap;
logout("\n");
if (fix) {
return -ENOTSUP;
}
bmap = g_try_malloc(s->header.blocks_in_image * sizeof(uint32_t));
if (s->header.blocks_in_image && bmap == NULL) {
res->check_errors++;
return -ENOMEM;
}
memset(bmap, 0xff, s->header.blocks_in_image * sizeof(uint32_t));
/* Check block map and value of blocks_allocated. */
for (block = 0; block < s->header.blocks_in_image; block++) {
uint32_t bmap_entry = le32_to_cpu(s->bmap[block]);
if (VDI_IS_ALLOCATED(bmap_entry)) {
if (bmap_entry < s->header.blocks_in_image) {
blocks_allocated++;
if (!VDI_IS_ALLOCATED(bmap[bmap_entry])) {
bmap[bmap_entry] = bmap_entry;
} else {
fprintf(stderr, "ERROR: block index %" PRIu32
" also used by %" PRIu32 "\n", bmap[bmap_entry], bmap_entry);
res->corruptions++;
}
} else {
fprintf(stderr, "ERROR: block index %" PRIu32
" too large, is %" PRIu32 "\n", block, bmap_entry);
res->corruptions++;
}
}
}
if (blocks_allocated != s->header.blocks_allocated) {
fprintf(stderr, "ERROR: allocated blocks mismatch, is %" PRIu32
", should be %" PRIu32 "\n",
blocks_allocated, s->header.blocks_allocated);
res->corruptions++;
}
g_free(bmap);
return 0;
}
| true | qemu | 5839e53bbc0fec56021d758aab7610df421ed8c8 | static int vdi_check(BlockDriverState *bs, BdrvCheckResult *res,
BdrvCheckMode fix)
{
BDRVVdiState *s = (BDRVVdiState *)bs->opaque;
uint32_t blocks_allocated = 0;
uint32_t block;
uint32_t *bmap;
logout("\n");
if (fix) {
return -ENOTSUP;
}
bmap = g_try_malloc(s->header.blocks_in_image * sizeof(uint32_t));
if (s->header.blocks_in_image && bmap == NULL) {
res->check_errors++;
return -ENOMEM;
}
memset(bmap, 0xff, s->header.blocks_in_image * sizeof(uint32_t));
for (block = 0; block < s->header.blocks_in_image; block++) {
uint32_t bmap_entry = le32_to_cpu(s->bmap[block]);
if (VDI_IS_ALLOCATED(bmap_entry)) {
if (bmap_entry < s->header.blocks_in_image) {
blocks_allocated++;
if (!VDI_IS_ALLOCATED(bmap[bmap_entry])) {
bmap[bmap_entry] = bmap_entry;
} else {
fprintf(stderr, "ERROR: block index %" PRIu32
" also used by %" PRIu32 "\n", bmap[bmap_entry], bmap_entry);
res->corruptions++;
}
} else {
fprintf(stderr, "ERROR: block index %" PRIu32
" too large, is %" PRIu32 "\n", block, bmap_entry);
res->corruptions++;
}
}
}
if (blocks_allocated != s->header.blocks_allocated) {
fprintf(stderr, "ERROR: allocated blocks mismatch, is %" PRIu32
", should be %" PRIu32 "\n",
blocks_allocated, s->header.blocks_allocated);
res->corruptions++;
}
g_free(bmap);
return 0;
}
| {
"code": [
" bmap = g_try_malloc(s->header.blocks_in_image * sizeof(uint32_t));"
],
"line_no": [
29
]
} | static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,
BdrvCheckMode VAR_2)
{
BDRVVdiState *s = (BDRVVdiState *)VAR_0->opaque;
uint32_t blocks_allocated = 0;
uint32_t block;
uint32_t *bmap;
logout("\n");
if (VAR_2) {
return -ENOTSUP;
}
bmap = g_try_malloc(s->header.blocks_in_image * sizeof(uint32_t));
if (s->header.blocks_in_image && bmap == NULL) {
VAR_1->check_errors++;
return -ENOMEM;
}
memset(bmap, 0xff, s->header.blocks_in_image * sizeof(uint32_t));
for (block = 0; block < s->header.blocks_in_image; block++) {
uint32_t bmap_entry = le32_to_cpu(s->bmap[block]);
if (VDI_IS_ALLOCATED(bmap_entry)) {
if (bmap_entry < s->header.blocks_in_image) {
blocks_allocated++;
if (!VDI_IS_ALLOCATED(bmap[bmap_entry])) {
bmap[bmap_entry] = bmap_entry;
} else {
fprintf(stderr, "ERROR: block index %" PRIu32
" also used by %" PRIu32 "\n", bmap[bmap_entry], bmap_entry);
VAR_1->corruptions++;
}
} else {
fprintf(stderr, "ERROR: block index %" PRIu32
" too large, is %" PRIu32 "\n", block, bmap_entry);
VAR_1->corruptions++;
}
}
}
if (blocks_allocated != s->header.blocks_allocated) {
fprintf(stderr, "ERROR: allocated blocks mismatch, is %" PRIu32
", should be %" PRIu32 "\n",
blocks_allocated, s->header.blocks_allocated);
VAR_1->corruptions++;
}
g_free(bmap);
return 0;
}
| [
"static int FUNC_0(BlockDriverState *VAR_0, BdrvCheckResult *VAR_1,\nBdrvCheckMode VAR_2)\n{",
"BDRVVdiState *s = (BDRVVdiState *)VAR_0->opaque;",
"uint32_t blocks_allocated = 0;",
"uint32_t block;",
"uint32_t *bmap;",
"logout(\"\\n\");",
"if (VAR_2) {",
"return -ENOTSUP;",
"}",
"bmap = g_try_malloc(s->header.blocks_in_image * sizeof(uint32_t));",
"if (s->header.blocks_in_image && bmap == NULL) {",
"VAR_1->check_errors++;",
"return -ENOMEM;",
"}",
"memset(bmap, 0xff, s->header.blocks_in_image * sizeof(uint32_t));",
"for (block = 0; block < s->header.blocks_in_image; block++) {",
"uint32_t bmap_entry = le32_to_cpu(s->bmap[block]);",
"if (VDI_IS_ALLOCATED(bmap_entry)) {",
"if (bmap_entry < s->header.blocks_in_image) {",
"blocks_allocated++;",
"if (!VDI_IS_ALLOCATED(bmap[bmap_entry])) {",
"bmap[bmap_entry] = bmap_entry;",
"} else {",
"fprintf(stderr, \"ERROR: block index %\" PRIu32\n\" also used by %\" PRIu32 \"\\n\", bmap[bmap_entry], bmap_entry);",
"VAR_1->corruptions++;",
"}",
"} else {",
"fprintf(stderr, \"ERROR: block index %\" PRIu32\n\" too large, is %\" PRIu32 \"\\n\", block, bmap_entry);",
"VAR_1->corruptions++;",
"}",
"}",
"}",
"if (blocks_allocated != s->header.blocks_allocated) {",
"fprintf(stderr, \"ERROR: allocated blocks mismatch, is %\" PRIu32\n\", should be %\" PRIu32 \"\\n\",\nblocks_allocated, s->header.blocks_allocated);",
"VAR_1->corruptions++;",
"}",
"g_free(bmap);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41
],
[
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
],
[
99
],
[
103
],
[
105
]
] |
25,076 | static void uart_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
LM32UartState *s = opaque;
unsigned char ch = value;
trace_lm32_uart_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_RXTX:
if (s->chr) {
qemu_chr_fe_write_all(s->chr, &ch, 1);
}
break;
case R_IER:
case R_LCR:
case R_MCR:
case R_DIV:
s->regs[addr] = value;
break;
case R_IIR:
case R_LSR:
case R_MSR:
error_report("lm32_uart: write access to read only register 0x"
TARGET_FMT_plx, addr << 2);
break;
default:
error_report("lm32_uart: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
uart_update_irq(s);
} | true | qemu | 6ab3fc32ea640026726bc5f9f4db622d0954fb8a | static void uart_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
LM32UartState *s = opaque;
unsigned char ch = value;
trace_lm32_uart_memory_write(addr, value);
addr >>= 2;
switch (addr) {
case R_RXTX:
if (s->chr) {
qemu_chr_fe_write_all(s->chr, &ch, 1);
}
break;
case R_IER:
case R_LCR:
case R_MCR:
case R_DIV:
s->regs[addr] = value;
break;
case R_IIR:
case R_LSR:
case R_MSR:
error_report("lm32_uart: write access to read only register 0x"
TARGET_FMT_plx, addr << 2);
break;
default:
error_report("lm32_uart: write access to unknown register 0x"
TARGET_FMT_plx, addr << 2);
break;
}
uart_update_irq(s);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(void *VAR_0, hwaddr VAR_1,
uint64_t VAR_2, unsigned VAR_3)
{
LM32UartState *s = VAR_0;
unsigned char VAR_4 = VAR_2;
trace_lm32_uart_memory_write(VAR_1, VAR_2);
VAR_1 >>= 2;
switch (VAR_1) {
case R_RXTX:
if (s->chr) {
qemu_chr_fe_write_all(s->chr, &VAR_4, 1);
}
break;
case R_IER:
case R_LCR:
case R_MCR:
case R_DIV:
s->regs[VAR_1] = VAR_2;
break;
case R_IIR:
case R_LSR:
case R_MSR:
error_report("lm32_uart: write access to read only register 0x"
TARGET_FMT_plx, VAR_1 << 2);
break;
default:
error_report("lm32_uart: write access to unknown register 0x"
TARGET_FMT_plx, VAR_1 << 2);
break;
}
uart_update_irq(s);
} | [
"static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{",
"LM32UartState *s = VAR_0;",
"unsigned char VAR_4 = VAR_2;",
"trace_lm32_uart_memory_write(VAR_1, VAR_2);",
"VAR_1 >>= 2;",
"switch (VAR_1) {",
"case R_RXTX:\nif (s->chr) {",
"qemu_chr_fe_write_all(s->chr, &VAR_4, 1);",
"}",
"break;",
"case R_IER:\ncase R_LCR:\ncase R_MCR:\ncase R_DIV:\ns->regs[VAR_1] = VAR_2;",
"break;",
"case R_IIR:\ncase R_LSR:\ncase R_MSR:\nerror_report(\"lm32_uart: write access to read only register 0x\"\nTARGET_FMT_plx, VAR_1 << 2);",
"break;",
"default:\nerror_report(\"lm32_uart: write access to unknown register 0x\"\nTARGET_FMT_plx, VAR_1 << 2);",
"break;",
"}",
"uart_update_irq(s);",
"}"
] | [
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
],
[
17
],
[
19
],
[
21,
23
],
[
27
],
[
29
],
[
31
],
[
33,
35,
37,
39,
41
],
[
43
],
[
45,
47,
49,
51,
53
],
[
55
],
[
57,
59,
61
],
[
63
],
[
65
],
[
67
],
[
69
]
] |
25,078 | static void test_opts_parse_size(void)
{
Error *err = NULL;
QemuOpts *opts;
/* Lower limit zero */
opts = qemu_opts_parse(&opts_list_02, "size1=0", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
/* Note: precision is 53 bits since we're parsing with strtod() */
/* Around limit of precision: 2^53-1, 2^53, 2^54 */
opts = qemu_opts_parse(&opts_list_02,
"size1=9007199254740991,"
"size2=9007199254740992,"
"size3=9007199254740993",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 3);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1),
==, 0x1fffffffffffff);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1),
==, 0x20000000000000);
g_assert_cmphex(qemu_opt_get_size(opts, "size3", 1),
==, 0x20000000000000);
/* Close to signed upper limit 0x7ffffffffffffc00 (53 msbs set) */
opts = qemu_opts_parse(&opts_list_02,
"size1=9223372036854774784," /* 7ffffffffffffc00 */
"size2=9223372036854775295", /* 7ffffffffffffdff */
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1),
==, 0x7ffffffffffffc00);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1),
==, 0x7ffffffffffffc00);
/* Close to actual upper limit 0xfffffffffffff800 (53 msbs set) */
opts = qemu_opts_parse(&opts_list_02,
"size1=18446744073709549568," /* fffffffffffff800 */
"size2=18446744073709550591", /* fffffffffffffbff */
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1),
==, 0xfffffffffffff800);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1),
==, 0xfffffffffffff800);
/* Beyond limits */
opts = qemu_opts_parse(&opts_list_02, "size1=-1", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_02,
"size1=18446744073709550592", /* fffffffffffffc00 */
false, &error_abort);
/* BUG: should reject */
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
/* Suffixes */
opts = qemu_opts_parse(&opts_list_02, "size1=8b,size2=1.5k,size3=2M",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 3);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, 8);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 1536);
g_assert_cmphex(qemu_opt_get_size(opts, "size3", 0), ==, 2 * M_BYTE);
opts = qemu_opts_parse(&opts_list_02, "size1=0.1G,size2=16777215T",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, G_BYTE / 10);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0),
==, 16777215 * T_BYTE);
/* Beyond limit with suffix */
opts = qemu_opts_parse(&opts_list_02, "size1=16777216T",
false, &error_abort);
/* BUG: should reject */
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
/* Trailing crap */
opts = qemu_opts_parse(&opts_list_02, "size1=16E", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_02, "size1=16Gi", false, &error_abort);
/* BUG: should reject */
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 16 * G_BYTE);
qemu_opts_reset(&opts_list_02);
}
| true | qemu | 75cdcd1553e74b5edc58aed23e3b2da8dabb1876 | static void test_opts_parse_size(void)
{
Error *err = NULL;
QemuOpts *opts;
opts = qemu_opts_parse(&opts_list_02, "size1=0", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_02,
"size1=9007199254740991,"
"size2=9007199254740992,"
"size3=9007199254740993",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 3);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1),
==, 0x1fffffffffffff);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1),
==, 0x20000000000000);
g_assert_cmphex(qemu_opt_get_size(opts, "size3", 1),
==, 0x20000000000000);
opts = qemu_opts_parse(&opts_list_02,
"size1=9223372036854774784,"
"size2=9223372036854775295",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1),
==, 0x7ffffffffffffc00);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1),
==, 0x7ffffffffffffc00);
opts = qemu_opts_parse(&opts_list_02,
"size1=18446744073709549568,"
"size2=18446744073709550591",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1),
==, 0xfffffffffffff800);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1),
==, 0xfffffffffffff800);
opts = qemu_opts_parse(&opts_list_02, "size1=-1", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_02,
"size1=18446744073709550592",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_02, "size1=8b,size2=1.5k,size3=2M",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 3);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, 8);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 1536);
g_assert_cmphex(qemu_opt_get_size(opts, "size3", 0), ==, 2 * M_BYTE);
opts = qemu_opts_parse(&opts_list_02, "size1=0.1G,size2=16777215T",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, G_BYTE / 10);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0),
==, 16777215 * T_BYTE);
opts = qemu_opts_parse(&opts_list_02, "size1=16777216T",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_02, "size1=16E", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_02, "size1=16Gi", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 16 * G_BYTE);
qemu_opts_reset(&opts_list_02);
}
| {
"code": [
" false, &error_abort);",
" g_assert_cmpuint(opts_count(opts), ==, 1);",
" g_assert_cmpuint(qemu_opt_get_size(opts, \"size1\", 1), ==, 0);",
" false, &error_abort);",
" g_assert_cmpuint(opts_count(opts), ==, 1);",
" g_assert_cmpuint(qemu_opt_get_size(opts, \"size1\", 1), ==, 0);",
" opts = qemu_opts_parse(&opts_list_02, \"size1=16Gi\", false, &error_abort);",
" g_assert_cmpuint(opts_count(opts), ==, 1);",
" g_assert_cmpuint(qemu_opt_get_size(opts, \"size1\", 1), ==, 16 * G_BYTE);"
],
"line_no": [
35,
15,
17,
35,
15,
17,
169,
15,
175
]
} | static void FUNC_0(void)
{
Error *err = NULL;
QemuOpts *opts;
opts = qemu_opts_parse(&opts_list_02, "size1=0", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_02,
"size1=9007199254740991,"
"size2=9007199254740992,"
"size3=9007199254740993",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 3);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1),
==, 0x1fffffffffffff);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1),
==, 0x20000000000000);
g_assert_cmphex(qemu_opt_get_size(opts, "size3", 1),
==, 0x20000000000000);
opts = qemu_opts_parse(&opts_list_02,
"size1=9223372036854774784,"
"size2=9223372036854775295",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1),
==, 0x7ffffffffffffc00);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1),
==, 0x7ffffffffffffc00);
opts = qemu_opts_parse(&opts_list_02,
"size1=18446744073709549568,"
"size2=18446744073709550591",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 1),
==, 0xfffffffffffff800);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 1),
==, 0xfffffffffffff800);
opts = qemu_opts_parse(&opts_list_02, "size1=-1", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_02,
"size1=18446744073709550592",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_02, "size1=8b,size2=1.5k,size3=2M",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 3);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, 8);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0), ==, 1536);
g_assert_cmphex(qemu_opt_get_size(opts, "size3", 0), ==, 2 * M_BYTE);
opts = qemu_opts_parse(&opts_list_02, "size1=0.1G,size2=16777215T",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 2);
g_assert_cmphex(qemu_opt_get_size(opts, "size1", 0), ==, G_BYTE / 10);
g_assert_cmphex(qemu_opt_get_size(opts, "size2", 0),
==, 16777215 * T_BYTE);
opts = qemu_opts_parse(&opts_list_02, "size1=16777216T",
false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 0);
opts = qemu_opts_parse(&opts_list_02, "size1=16E", false, &err);
error_free_or_abort(&err);
g_assert(!opts);
opts = qemu_opts_parse(&opts_list_02, "size1=16Gi", false, &error_abort);
g_assert_cmpuint(opts_count(opts), ==, 1);
g_assert_cmpuint(qemu_opt_get_size(opts, "size1", 1), ==, 16 * G_BYTE);
qemu_opts_reset(&opts_list_02);
}
| [
"static void FUNC_0(void)\n{",
"Error *err = NULL;",
"QemuOpts *opts;",
"opts = qemu_opts_parse(&opts_list_02, \"size1=0\", false, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 1);",
"g_assert_cmpuint(qemu_opt_get_size(opts, \"size1\", 1), ==, 0);",
"opts = qemu_opts_parse(&opts_list_02,\n\"size1=9007199254740991,\"\n\"size2=9007199254740992,\"\n\"size3=9007199254740993\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 3);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size1\", 1),\n==, 0x1fffffffffffff);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size2\", 1),\n==, 0x20000000000000);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size3\", 1),\n==, 0x20000000000000);",
"opts = qemu_opts_parse(&opts_list_02,\n\"size1=9223372036854774784,\"\n\"size2=9223372036854775295\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 2);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size1\", 1),\n==, 0x7ffffffffffffc00);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size2\", 1),\n==, 0x7ffffffffffffc00);",
"opts = qemu_opts_parse(&opts_list_02,\n\"size1=18446744073709549568,\"\n\"size2=18446744073709550591\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 2);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size1\", 1),\n==, 0xfffffffffffff800);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size2\", 1),\n==, 0xfffffffffffff800);",
"opts = qemu_opts_parse(&opts_list_02, \"size1=-1\", false, &err);",
"error_free_or_abort(&err);",
"g_assert(!opts);",
"opts = qemu_opts_parse(&opts_list_02,\n\"size1=18446744073709550592\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 1);",
"g_assert_cmpuint(qemu_opt_get_size(opts, \"size1\", 1), ==, 0);",
"opts = qemu_opts_parse(&opts_list_02, \"size1=8b,size2=1.5k,size3=2M\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 3);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size1\", 0), ==, 8);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size2\", 0), ==, 1536);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size3\", 0), ==, 2 * M_BYTE);",
"opts = qemu_opts_parse(&opts_list_02, \"size1=0.1G,size2=16777215T\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 2);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size1\", 0), ==, G_BYTE / 10);",
"g_assert_cmphex(qemu_opt_get_size(opts, \"size2\", 0),\n==, 16777215 * T_BYTE);",
"opts = qemu_opts_parse(&opts_list_02, \"size1=16777216T\",\nfalse, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 1);",
"g_assert_cmpuint(qemu_opt_get_size(opts, \"size1\", 1), ==, 0);",
"opts = qemu_opts_parse(&opts_list_02, \"size1=16E\", false, &err);",
"error_free_or_abort(&err);",
"g_assert(!opts);",
"opts = qemu_opts_parse(&opts_list_02, \"size1=16Gi\", false, &error_abort);",
"g_assert_cmpuint(opts_count(opts), ==, 1);",
"g_assert_cmpuint(qemu_opt_get_size(opts, \"size1\", 1), ==, 16 * G_BYTE);",
"qemu_opts_reset(&opts_list_02);",
"}"
] | [
0,
0,
0,
0,
1,
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,
1,
0,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
13
],
[
15
],
[
17
],
[
27,
29,
31,
33,
35
],
[
37
],
[
39,
41
],
[
43,
45
],
[
47,
49
],
[
55,
57,
59,
61
],
[
63
],
[
65,
67
],
[
69,
71
],
[
77,
79,
81,
83
],
[
85
],
[
87,
89
],
[
91,
93
],
[
99
],
[
101
],
[
103
],
[
105,
107,
109
],
[
113
],
[
115
],
[
121,
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133,
135
],
[
137
],
[
139
],
[
141,
143
],
[
149,
151
],
[
155
],
[
157
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
179
],
[
181
]
] |
25,079 | static int usbredir_post_load(void *priv, int version_id)
{
USBRedirDevice *dev = priv;
switch (dev->device_info.speed) {
case usb_redir_speed_low:
dev->dev.speed = USB_SPEED_LOW;
break;
case usb_redir_speed_full:
dev->dev.speed = USB_SPEED_FULL;
break;
case usb_redir_speed_high:
dev->dev.speed = USB_SPEED_HIGH;
break;
case usb_redir_speed_super:
dev->dev.speed = USB_SPEED_SUPER;
break;
default:
dev->dev.speed = USB_SPEED_FULL;
dev->dev.speedmask = (1 << dev->dev.speed);
usbredir_setup_usb_eps(dev);
usbredir_check_bulk_receiving(dev); | true | qemu | 3713e1485e6eace7d48b9c790602cfd92c616e5f | static int usbredir_post_load(void *priv, int version_id)
{
USBRedirDevice *dev = priv;
switch (dev->device_info.speed) {
case usb_redir_speed_low:
dev->dev.speed = USB_SPEED_LOW;
break;
case usb_redir_speed_full:
dev->dev.speed = USB_SPEED_FULL;
break;
case usb_redir_speed_high:
dev->dev.speed = USB_SPEED_HIGH;
break;
case usb_redir_speed_super:
dev->dev.speed = USB_SPEED_SUPER;
break;
default:
dev->dev.speed = USB_SPEED_FULL;
dev->dev.speedmask = (1 << dev->dev.speed);
usbredir_setup_usb_eps(dev);
usbredir_check_bulk_receiving(dev); | {
"code": [],
"line_no": []
} | static int FUNC_0(void *VAR_0, int VAR_1)
{
USBRedirDevice *dev = VAR_0;
switch (dev->device_info.speed) {
case usb_redir_speed_low:
dev->dev.speed = USB_SPEED_LOW;
break;
case usb_redir_speed_full:
dev->dev.speed = USB_SPEED_FULL;
break;
case usb_redir_speed_high:
dev->dev.speed = USB_SPEED_HIGH;
break;
case usb_redir_speed_super:
dev->dev.speed = USB_SPEED_SUPER;
break;
default:
dev->dev.speed = USB_SPEED_FULL;
dev->dev.speedmask = (1 << dev->dev.speed);
usbredir_setup_usb_eps(dev);
usbredir_check_bulk_receiving(dev); | [
"static int FUNC_0(void *VAR_0, int VAR_1)\n{",
"USBRedirDevice *dev = VAR_0;",
"switch (dev->device_info.speed) {",
"case usb_redir_speed_low:\ndev->dev.speed = USB_SPEED_LOW;",
"break;",
"case usb_redir_speed_full:\ndev->dev.speed = USB_SPEED_FULL;",
"break;",
"case usb_redir_speed_high:\ndev->dev.speed = USB_SPEED_HIGH;",
"break;",
"case usb_redir_speed_super:\ndev->dev.speed = USB_SPEED_SUPER;",
"break;",
"default:\ndev->dev.speed = USB_SPEED_FULL;",
"dev->dev.speedmask = (1 << dev->dev.speed);",
"usbredir_setup_usb_eps(dev);",
"usbredir_check_bulk_receiving(dev);"
] | [
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
]
] |
25,080 | static void smc_decode_stream(SmcContext *s)
{
int width = s->avctx->width;
int height = s->avctx->height;
int stride = s->frame.linesize[0];
int i;
int stream_ptr = 0;
int chunk_size;
unsigned char opcode;
int n_blocks;
unsigned int color_flags;
unsigned int color_flags_a;
unsigned int color_flags_b;
unsigned int flag_mask;
unsigned char *pixels = s->frame.data[0];
int image_size = height * s->frame.linesize[0];
int row_ptr = 0;
int pixel_ptr = 0;
int pixel_x, pixel_y;
int row_inc = stride - 4;
int block_ptr;
int prev_block_ptr;
int prev_block_ptr1, prev_block_ptr2;
int prev_block_flag;
int total_blocks;
int color_table_index; /* indexes to color pair, quad, or octet tables */
int pixel;
int color_pair_index = 0;
int color_quad_index = 0;
int color_octet_index = 0;
/* make the palette available */
memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
stream_ptr += 4;
if (chunk_size != s->size)
av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
chunk_size, s->size);
chunk_size = s->size;
total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
/* traverse through the blocks */
while (total_blocks) {
/* sanity checks */
/* make sure stream ptr hasn't gone out of bounds */
if (stream_ptr > chunk_size) {
av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n",
stream_ptr, chunk_size);
return;
}
/* make sure the row pointer hasn't gone wild */
if (row_ptr >= image_size) {
av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (row ptr = %d, height = %d)\n",
row_ptr, image_size);
return;
}
opcode = s->buf[stream_ptr++];
switch (opcode & 0xF0) {
/* skip n blocks */
case 0x00:
case 0x10:
n_blocks = GET_BLOCK_COUNT();
while (n_blocks--) {
ADVANCE_BLOCK();
}
break;
/* repeat last block n times */
case 0x20:
case 0x30:
n_blocks = GET_BLOCK_COUNT();
/* sanity check */
if ((row_ptr == 0) && (pixel_ptr == 0)) {
av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but no blocks rendered yet\n",
opcode & 0xF0);
break;
}
/* figure out where the previous block started */
if (pixel_ptr == 0)
prev_block_ptr1 =
(row_ptr - s->avctx->width * 4) + s->avctx->width - 4;
else
prev_block_ptr1 = row_ptr + pixel_ptr - 4;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
prev_block_ptr = prev_block_ptr1;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = pixels[prev_block_ptr++];
}
block_ptr += row_inc;
prev_block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
/* repeat previous pair of blocks n times */
case 0x40:
case 0x50:
n_blocks = GET_BLOCK_COUNT();
n_blocks *= 2;
/* sanity check */
if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) {
av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
opcode & 0xF0);
break;
}
/* figure out where the previous 2 blocks started */
if (pixel_ptr == 0)
prev_block_ptr1 = (row_ptr - s->avctx->width * 4) +
s->avctx->width - 4 * 2;
else if (pixel_ptr == 4)
prev_block_ptr1 = (row_ptr - s->avctx->width * 4) + row_inc;
else
prev_block_ptr1 = row_ptr + pixel_ptr - 4 * 2;
if (pixel_ptr == 0)
prev_block_ptr2 = (row_ptr - s->avctx->width * 4) + row_inc;
else
prev_block_ptr2 = row_ptr + pixel_ptr - 4;
prev_block_flag = 0;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
if (prev_block_flag)
prev_block_ptr = prev_block_ptr2;
else
prev_block_ptr = prev_block_ptr1;
prev_block_flag = !prev_block_flag;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = pixels[prev_block_ptr++];
}
block_ptr += row_inc;
prev_block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
/* 1-color block encoding */
case 0x60:
case 0x70:
n_blocks = GET_BLOCK_COUNT();
pixel = s->buf[stream_ptr++];
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = pixel;
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
/* 2-color block encoding */
case 0x80:
case 0x90:
n_blocks = (opcode & 0x0F) + 1;
/* figure out which color pair to use to paint the 2-color block */
if ((opcode & 0xF0) == 0x80) {
/* fetch the next 2 colors from bytestream and store in next
* available entry in the color pair table */
for (i = 0; i < CPAIR; i++) {
pixel = s->buf[stream_ptr++];
color_table_index = CPAIR * color_pair_index + i;
s->color_pairs[color_table_index] = pixel;
}
/* this is the base index to use for this block */
color_table_index = CPAIR * color_pair_index;
color_pair_index++;
/* wraparound */
if (color_pair_index == COLORS_PER_TABLE)
color_pair_index = 0;
} else
color_table_index = CPAIR * s->buf[stream_ptr++];
while (n_blocks--) {
color_flags = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
flag_mask = 0x8000;
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
if (color_flags & flag_mask)
pixel = color_table_index + 1;
else
pixel = color_table_index;
flag_mask >>= 1;
pixels[block_ptr++] = s->color_pairs[pixel];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
/* 4-color block encoding */
case 0xA0:
case 0xB0:
n_blocks = (opcode & 0x0F) + 1;
/* figure out which color quad to use to paint the 4-color block */
if ((opcode & 0xF0) == 0xA0) {
/* fetch the next 4 colors from bytestream and store in next
* available entry in the color quad table */
for (i = 0; i < CQUAD; i++) {
pixel = s->buf[stream_ptr++];
color_table_index = CQUAD * color_quad_index + i;
s->color_quads[color_table_index] = pixel;
}
/* this is the base index to use for this block */
color_table_index = CQUAD * color_quad_index;
color_quad_index++;
/* wraparound */
if (color_quad_index == COLORS_PER_TABLE)
color_quad_index = 0;
} else
color_table_index = CQUAD * s->buf[stream_ptr++];
while (n_blocks--) {
color_flags = AV_RB32(&s->buf[stream_ptr]);
stream_ptr += 4;
/* flag mask actually acts as a bit shift count here */
flag_mask = 30;
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixel = color_table_index +
((color_flags >> flag_mask) & 0x03);
flag_mask -= 2;
pixels[block_ptr++] = s->color_quads[pixel];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
/* 8-color block encoding */
case 0xC0:
case 0xD0:
n_blocks = (opcode & 0x0F) + 1;
/* figure out which color octet to use to paint the 8-color block */
if ((opcode & 0xF0) == 0xC0) {
/* fetch the next 8 colors from bytestream and store in next
* available entry in the color octet table */
for (i = 0; i < COCTET; i++) {
pixel = s->buf[stream_ptr++];
color_table_index = COCTET * color_octet_index + i;
s->color_octets[color_table_index] = pixel;
}
/* this is the base index to use for this block */
color_table_index = COCTET * color_octet_index;
color_octet_index++;
/* wraparound */
if (color_octet_index == COLORS_PER_TABLE)
color_octet_index = 0;
} else
color_table_index = COCTET * s->buf[stream_ptr++];
while (n_blocks--) {
/*
For this input of 6 hex bytes:
01 23 45 67 89 AB
Mangle it to this output:
flags_a = xx012456, flags_b = xx89A37B
*/
/* build the color flags */
color_flags_a =
((AV_RB16(s->buf + stream_ptr ) & 0xFFF0) << 8) |
(AV_RB16(s->buf + stream_ptr + 2) >> 4);
color_flags_b =
((AV_RB16(s->buf + stream_ptr + 4) & 0xFFF0) << 8) |
((s->buf[stream_ptr + 1] & 0x0F) << 8) |
((s->buf[stream_ptr + 3] & 0x0F) << 4) |
(s->buf[stream_ptr + 5] & 0x0F);
stream_ptr += 6;
color_flags = color_flags_a;
/* flag mask actually acts as a bit shift count here */
flag_mask = 21;
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
/* reload flags at third row (iteration pixel_y == 2) */
if (pixel_y == 2) {
color_flags = color_flags_b;
flag_mask = 21;
}
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixel = color_table_index +
((color_flags >> flag_mask) & 0x07);
flag_mask -= 3;
pixels[block_ptr++] = s->color_octets[pixel];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
/* 16-color block encoding (every pixel is a different color) */
case 0xE0:
n_blocks = (opcode & 0x0F) + 1;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = s->buf[stream_ptr++];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0xF0:
av_log(s->avctx, AV_LOG_INFO, "0xF0 opcode seen in SMC chunk (contact the developers)\n");
break;
}
}
}
| true | FFmpeg | 1007a805a486a1348a0543ac2dd99d823148d25c | static void smc_decode_stream(SmcContext *s)
{
int width = s->avctx->width;
int height = s->avctx->height;
int stride = s->frame.linesize[0];
int i;
int stream_ptr = 0;
int chunk_size;
unsigned char opcode;
int n_blocks;
unsigned int color_flags;
unsigned int color_flags_a;
unsigned int color_flags_b;
unsigned int flag_mask;
unsigned char *pixels = s->frame.data[0];
int image_size = height * s->frame.linesize[0];
int row_ptr = 0;
int pixel_ptr = 0;
int pixel_x, pixel_y;
int row_inc = stride - 4;
int block_ptr;
int prev_block_ptr;
int prev_block_ptr1, prev_block_ptr2;
int prev_block_flag;
int total_blocks;
int color_table_index;
int pixel;
int color_pair_index = 0;
int color_quad_index = 0;
int color_octet_index = 0;
memcpy(s->frame.data[1], s->pal, AVPALETTE_SIZE);
chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
stream_ptr += 4;
if (chunk_size != s->size)
av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
chunk_size, s->size);
chunk_size = s->size;
total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
while (total_blocks) {
if (stream_ptr > chunk_size) {
av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n",
stream_ptr, chunk_size);
return;
}
if (row_ptr >= image_size) {
av_log(s->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (row ptr = %d, height = %d)\n",
row_ptr, image_size);
return;
}
opcode = s->buf[stream_ptr++];
switch (opcode & 0xF0) {
case 0x00:
case 0x10:
n_blocks = GET_BLOCK_COUNT();
while (n_blocks--) {
ADVANCE_BLOCK();
}
break;
case 0x20:
case 0x30:
n_blocks = GET_BLOCK_COUNT();
if ((row_ptr == 0) && (pixel_ptr == 0)) {
av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but no blocks rendered yet\n",
opcode & 0xF0);
break;
}
if (pixel_ptr == 0)
prev_block_ptr1 =
(row_ptr - s->avctx->width * 4) + s->avctx->width - 4;
else
prev_block_ptr1 = row_ptr + pixel_ptr - 4;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
prev_block_ptr = prev_block_ptr1;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = pixels[prev_block_ptr++];
}
block_ptr += row_inc;
prev_block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0x40:
case 0x50:
n_blocks = GET_BLOCK_COUNT();
n_blocks *= 2;
if ((row_ptr == 0) && (pixel_ptr < 2 * 4)) {
av_log(s->avctx, AV_LOG_INFO, "encountered repeat block opcode (%02X) but not enough blocks rendered yet\n",
opcode & 0xF0);
break;
}
if (pixel_ptr == 0)
prev_block_ptr1 = (row_ptr - s->avctx->width * 4) +
s->avctx->width - 4 * 2;
else if (pixel_ptr == 4)
prev_block_ptr1 = (row_ptr - s->avctx->width * 4) + row_inc;
else
prev_block_ptr1 = row_ptr + pixel_ptr - 4 * 2;
if (pixel_ptr == 0)
prev_block_ptr2 = (row_ptr - s->avctx->width * 4) + row_inc;
else
prev_block_ptr2 = row_ptr + pixel_ptr - 4;
prev_block_flag = 0;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
if (prev_block_flag)
prev_block_ptr = prev_block_ptr2;
else
prev_block_ptr = prev_block_ptr1;
prev_block_flag = !prev_block_flag;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = pixels[prev_block_ptr++];
}
block_ptr += row_inc;
prev_block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0x60:
case 0x70:
n_blocks = GET_BLOCK_COUNT();
pixel = s->buf[stream_ptr++];
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = pixel;
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0x80:
case 0x90:
n_blocks = (opcode & 0x0F) + 1;
if ((opcode & 0xF0) == 0x80) {
for (i = 0; i < CPAIR; i++) {
pixel = s->buf[stream_ptr++];
color_table_index = CPAIR * color_pair_index + i;
s->color_pairs[color_table_index] = pixel;
}
color_table_index = CPAIR * color_pair_index;
color_pair_index++;
if (color_pair_index == COLORS_PER_TABLE)
color_pair_index = 0;
} else
color_table_index = CPAIR * s->buf[stream_ptr++];
while (n_blocks--) {
color_flags = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
flag_mask = 0x8000;
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
if (color_flags & flag_mask)
pixel = color_table_index + 1;
else
pixel = color_table_index;
flag_mask >>= 1;
pixels[block_ptr++] = s->color_pairs[pixel];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0xA0:
case 0xB0:
n_blocks = (opcode & 0x0F) + 1;
if ((opcode & 0xF0) == 0xA0) {
for (i = 0; i < CQUAD; i++) {
pixel = s->buf[stream_ptr++];
color_table_index = CQUAD * color_quad_index + i;
s->color_quads[color_table_index] = pixel;
}
color_table_index = CQUAD * color_quad_index;
color_quad_index++;
if (color_quad_index == COLORS_PER_TABLE)
color_quad_index = 0;
} else
color_table_index = CQUAD * s->buf[stream_ptr++];
while (n_blocks--) {
color_flags = AV_RB32(&s->buf[stream_ptr]);
stream_ptr += 4;
flag_mask = 30;
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixel = color_table_index +
((color_flags >> flag_mask) & 0x03);
flag_mask -= 2;
pixels[block_ptr++] = s->color_quads[pixel];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0xC0:
case 0xD0:
n_blocks = (opcode & 0x0F) + 1;
if ((opcode & 0xF0) == 0xC0) {
for (i = 0; i < COCTET; i++) {
pixel = s->buf[stream_ptr++];
color_table_index = COCTET * color_octet_index + i;
s->color_octets[color_table_index] = pixel;
}
color_table_index = COCTET * color_octet_index;
color_octet_index++;
if (color_octet_index == COLORS_PER_TABLE)
color_octet_index = 0;
} else
color_table_index = COCTET * s->buf[stream_ptr++];
while (n_blocks--) {
color_flags_a =
((AV_RB16(s->buf + stream_ptr ) & 0xFFF0) << 8) |
(AV_RB16(s->buf + stream_ptr + 2) >> 4);
color_flags_b =
((AV_RB16(s->buf + stream_ptr + 4) & 0xFFF0) << 8) |
((s->buf[stream_ptr + 1] & 0x0F) << 8) |
((s->buf[stream_ptr + 3] & 0x0F) << 4) |
(s->buf[stream_ptr + 5] & 0x0F);
stream_ptr += 6;
color_flags = color_flags_a;
flag_mask = 21;
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
if (pixel_y == 2) {
color_flags = color_flags_b;
flag_mask = 21;
}
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixel = color_table_index +
((color_flags >> flag_mask) & 0x07);
flag_mask -= 3;
pixels[block_ptr++] = s->color_octets[pixel];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0xE0:
n_blocks = (opcode & 0x0F) + 1;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
for (pixel_x = 0; pixel_x < 4; pixel_x++) {
pixels[block_ptr++] = s->buf[stream_ptr++];
}
block_ptr += row_inc;
}
ADVANCE_BLOCK();
}
break;
case 0xF0:
av_log(s->avctx, AV_LOG_INFO, "0xF0 opcode seen in SMC chunk (contact the developers)\n");
break;
}
}
}
| {
"code": [
" while (n_blocks--) {"
],
"line_no": [
137
]
} | static void FUNC_0(SmcContext *VAR_0)
{
int VAR_1 = VAR_0->avctx->VAR_1;
int VAR_2 = VAR_0->avctx->VAR_2;
int VAR_3 = VAR_0->frame.linesize[0];
int VAR_4;
int VAR_5 = 0;
int VAR_6;
unsigned char VAR_7;
int VAR_8;
unsigned int VAR_9;
unsigned int VAR_10;
unsigned int VAR_11;
unsigned int VAR_12;
unsigned char *VAR_13 = VAR_0->frame.data[0];
int VAR_14 = VAR_2 * VAR_0->frame.linesize[0];
int VAR_15 = 0;
int VAR_16 = 0;
int VAR_17, VAR_18;
int VAR_19 = VAR_3 - 4;
int VAR_20;
int VAR_21;
int VAR_22, VAR_23;
int VAR_24;
int VAR_25;
int VAR_26;
int VAR_27;
int VAR_28 = 0;
int VAR_29 = 0;
int VAR_30 = 0;
memcpy(VAR_0->frame.data[1], VAR_0->pal, AVPALETTE_SIZE);
VAR_6 = AV_RB32(&VAR_0->buf[VAR_5]) & 0x00FFFFFF;
VAR_5 += 4;
if (VAR_6 != VAR_0->size)
av_log(VAR_0->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
VAR_6, VAR_0->size);
VAR_6 = VAR_0->size;
VAR_25 = ((VAR_0->avctx->VAR_1 + 3) / 4) * ((VAR_0->avctx->VAR_2 + 3) / 4);
while (VAR_25) {
if (VAR_5 > VAR_6) {
av_log(VAR_0->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\n",
VAR_5, VAR_6);
return;
}
if (VAR_15 >= VAR_14) {
av_log(VAR_0->avctx, AV_LOG_INFO, "SMC decoder just went out of bounds (row ptr = %d, VAR_2 = %d)\n",
VAR_15, VAR_14);
return;
}
VAR_7 = VAR_0->buf[VAR_5++];
switch (VAR_7 & 0xF0) {
case 0x00:
case 0x10:
VAR_8 = GET_BLOCK_COUNT();
while (VAR_8--) {
ADVANCE_BLOCK();
}
break;
case 0x20:
case 0x30:
VAR_8 = GET_BLOCK_COUNT();
if ((VAR_15 == 0) && (VAR_16 == 0)) {
av_log(VAR_0->avctx, AV_LOG_INFO, "encountered repeat block VAR_7 (%02X) but no blocks rendered yet\n",
VAR_7 & 0xF0);
break;
}
if (VAR_16 == 0)
VAR_22 =
(VAR_15 - VAR_0->avctx->VAR_1 * 4) + VAR_0->avctx->VAR_1 - 4;
else
VAR_22 = VAR_15 + VAR_16 - 4;
while (VAR_8--) {
VAR_20 = VAR_15 + VAR_16;
VAR_21 = VAR_22;
for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {
for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {
VAR_13[VAR_20++] = VAR_13[VAR_21++];
}
VAR_20 += VAR_19;
VAR_21 += VAR_19;
}
ADVANCE_BLOCK();
}
break;
case 0x40:
case 0x50:
VAR_8 = GET_BLOCK_COUNT();
VAR_8 *= 2;
if ((VAR_15 == 0) && (VAR_16 < 2 * 4)) {
av_log(VAR_0->avctx, AV_LOG_INFO, "encountered repeat block VAR_7 (%02X) but not enough blocks rendered yet\n",
VAR_7 & 0xF0);
break;
}
if (VAR_16 == 0)
VAR_22 = (VAR_15 - VAR_0->avctx->VAR_1 * 4) +
VAR_0->avctx->VAR_1 - 4 * 2;
else if (VAR_16 == 4)
VAR_22 = (VAR_15 - VAR_0->avctx->VAR_1 * 4) + VAR_19;
else
VAR_22 = VAR_15 + VAR_16 - 4 * 2;
if (VAR_16 == 0)
VAR_23 = (VAR_15 - VAR_0->avctx->VAR_1 * 4) + VAR_19;
else
VAR_23 = VAR_15 + VAR_16 - 4;
VAR_24 = 0;
while (VAR_8--) {
VAR_20 = VAR_15 + VAR_16;
if (VAR_24)
VAR_21 = VAR_23;
else
VAR_21 = VAR_22;
VAR_24 = !VAR_24;
for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {
for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {
VAR_13[VAR_20++] = VAR_13[VAR_21++];
}
VAR_20 += VAR_19;
VAR_21 += VAR_19;
}
ADVANCE_BLOCK();
}
break;
case 0x60:
case 0x70:
VAR_8 = GET_BLOCK_COUNT();
VAR_27 = VAR_0->buf[VAR_5++];
while (VAR_8--) {
VAR_20 = VAR_15 + VAR_16;
for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {
for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {
VAR_13[VAR_20++] = VAR_27;
}
VAR_20 += VAR_19;
}
ADVANCE_BLOCK();
}
break;
case 0x80:
case 0x90:
VAR_8 = (VAR_7 & 0x0F) + 1;
if ((VAR_7 & 0xF0) == 0x80) {
for (VAR_4 = 0; VAR_4 < CPAIR; VAR_4++) {
VAR_27 = VAR_0->buf[VAR_5++];
VAR_26 = CPAIR * VAR_28 + VAR_4;
VAR_0->color_pairs[VAR_26] = VAR_27;
}
VAR_26 = CPAIR * VAR_28;
VAR_28++;
if (VAR_28 == COLORS_PER_TABLE)
VAR_28 = 0;
} else
VAR_26 = CPAIR * VAR_0->buf[VAR_5++];
while (VAR_8--) {
VAR_9 = AV_RB16(&VAR_0->buf[VAR_5]);
VAR_5 += 2;
VAR_12 = 0x8000;
VAR_20 = VAR_15 + VAR_16;
for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {
for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {
if (VAR_9 & VAR_12)
VAR_27 = VAR_26 + 1;
else
VAR_27 = VAR_26;
VAR_12 >>= 1;
VAR_13[VAR_20++] = VAR_0->color_pairs[VAR_27];
}
VAR_20 += VAR_19;
}
ADVANCE_BLOCK();
}
break;
case 0xA0:
case 0xB0:
VAR_8 = (VAR_7 & 0x0F) + 1;
if ((VAR_7 & 0xF0) == 0xA0) {
for (VAR_4 = 0; VAR_4 < CQUAD; VAR_4++) {
VAR_27 = VAR_0->buf[VAR_5++];
VAR_26 = CQUAD * VAR_29 + VAR_4;
VAR_0->color_quads[VAR_26] = VAR_27;
}
VAR_26 = CQUAD * VAR_29;
VAR_29++;
if (VAR_29 == COLORS_PER_TABLE)
VAR_29 = 0;
} else
VAR_26 = CQUAD * VAR_0->buf[VAR_5++];
while (VAR_8--) {
VAR_9 = AV_RB32(&VAR_0->buf[VAR_5]);
VAR_5 += 4;
VAR_12 = 30;
VAR_20 = VAR_15 + VAR_16;
for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {
for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {
VAR_27 = VAR_26 +
((VAR_9 >> VAR_12) & 0x03);
VAR_12 -= 2;
VAR_13[VAR_20++] = VAR_0->color_quads[VAR_27];
}
VAR_20 += VAR_19;
}
ADVANCE_BLOCK();
}
break;
case 0xC0:
case 0xD0:
VAR_8 = (VAR_7 & 0x0F) + 1;
if ((VAR_7 & 0xF0) == 0xC0) {
for (VAR_4 = 0; VAR_4 < COCTET; VAR_4++) {
VAR_27 = VAR_0->buf[VAR_5++];
VAR_26 = COCTET * VAR_30 + VAR_4;
VAR_0->color_octets[VAR_26] = VAR_27;
}
VAR_26 = COCTET * VAR_30;
VAR_30++;
if (VAR_30 == COLORS_PER_TABLE)
VAR_30 = 0;
} else
VAR_26 = COCTET * VAR_0->buf[VAR_5++];
while (VAR_8--) {
VAR_10 =
((AV_RB16(VAR_0->buf + VAR_5 ) & 0xFFF0) << 8) |
(AV_RB16(VAR_0->buf + VAR_5 + 2) >> 4);
VAR_11 =
((AV_RB16(VAR_0->buf + VAR_5 + 4) & 0xFFF0) << 8) |
((VAR_0->buf[VAR_5 + 1] & 0x0F) << 8) |
((VAR_0->buf[VAR_5 + 3] & 0x0F) << 4) |
(VAR_0->buf[VAR_5 + 5] & 0x0F);
VAR_5 += 6;
VAR_9 = VAR_10;
VAR_12 = 21;
VAR_20 = VAR_15 + VAR_16;
for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {
if (VAR_18 == 2) {
VAR_9 = VAR_11;
VAR_12 = 21;
}
for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {
VAR_27 = VAR_26 +
((VAR_9 >> VAR_12) & 0x07);
VAR_12 -= 3;
VAR_13[VAR_20++] = VAR_0->color_octets[VAR_27];
}
VAR_20 += VAR_19;
}
ADVANCE_BLOCK();
}
break;
case 0xE0:
VAR_8 = (VAR_7 & 0x0F) + 1;
while (VAR_8--) {
VAR_20 = VAR_15 + VAR_16;
for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {
for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {
VAR_13[VAR_20++] = VAR_0->buf[VAR_5++];
}
VAR_20 += VAR_19;
}
ADVANCE_BLOCK();
}
break;
case 0xF0:
av_log(VAR_0->avctx, AV_LOG_INFO, "0xF0 VAR_7 seen in SMC chunk (contact the developers)\n");
break;
}
}
}
| [
"static void FUNC_0(SmcContext *VAR_0)\n{",
"int VAR_1 = VAR_0->avctx->VAR_1;",
"int VAR_2 = VAR_0->avctx->VAR_2;",
"int VAR_3 = VAR_0->frame.linesize[0];",
"int VAR_4;",
"int VAR_5 = 0;",
"int VAR_6;",
"unsigned char VAR_7;",
"int VAR_8;",
"unsigned int VAR_9;",
"unsigned int VAR_10;",
"unsigned int VAR_11;",
"unsigned int VAR_12;",
"unsigned char *VAR_13 = VAR_0->frame.data[0];",
"int VAR_14 = VAR_2 * VAR_0->frame.linesize[0];",
"int VAR_15 = 0;",
"int VAR_16 = 0;",
"int VAR_17, VAR_18;",
"int VAR_19 = VAR_3 - 4;",
"int VAR_20;",
"int VAR_21;",
"int VAR_22, VAR_23;",
"int VAR_24;",
"int VAR_25;",
"int VAR_26;",
"int VAR_27;",
"int VAR_28 = 0;",
"int VAR_29 = 0;",
"int VAR_30 = 0;",
"memcpy(VAR_0->frame.data[1], VAR_0->pal, AVPALETTE_SIZE);",
"VAR_6 = AV_RB32(&VAR_0->buf[VAR_5]) & 0x00FFFFFF;",
"VAR_5 += 4;",
"if (VAR_6 != VAR_0->size)\nav_log(VAR_0->avctx, AV_LOG_INFO, \"warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\\n\",",
"VAR_6, VAR_0->size);",
"VAR_6 = VAR_0->size;",
"VAR_25 = ((VAR_0->avctx->VAR_1 + 3) / 4) * ((VAR_0->avctx->VAR_2 + 3) / 4);",
"while (VAR_25) {",
"if (VAR_5 > VAR_6) {",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"SMC decoder just went out of bounds (stream ptr = %d, chunk size = %d)\\n\",\nVAR_5, VAR_6);",
"return;",
"}",
"if (VAR_15 >= VAR_14) {",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"SMC decoder just went out of bounds (row ptr = %d, VAR_2 = %d)\\n\",\nVAR_15, VAR_14);",
"return;",
"}",
"VAR_7 = VAR_0->buf[VAR_5++];",
"switch (VAR_7 & 0xF0) {",
"case 0x00:\ncase 0x10:\nVAR_8 = GET_BLOCK_COUNT();",
"while (VAR_8--) {",
"ADVANCE_BLOCK();",
"}",
"break;",
"case 0x20:\ncase 0x30:\nVAR_8 = GET_BLOCK_COUNT();",
"if ((VAR_15 == 0) && (VAR_16 == 0)) {",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"encountered repeat block VAR_7 (%02X) but no blocks rendered yet\\n\",\nVAR_7 & 0xF0);",
"break;",
"}",
"if (VAR_16 == 0)\nVAR_22 =\n(VAR_15 - VAR_0->avctx->VAR_1 * 4) + VAR_0->avctx->VAR_1 - 4;",
"else\nVAR_22 = VAR_15 + VAR_16 - 4;",
"while (VAR_8--) {",
"VAR_20 = VAR_15 + VAR_16;",
"VAR_21 = VAR_22;",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {",
"for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {",
"VAR_13[VAR_20++] = VAR_13[VAR_21++];",
"}",
"VAR_20 += VAR_19;",
"VAR_21 += VAR_19;",
"}",
"ADVANCE_BLOCK();",
"}",
"break;",
"case 0x40:\ncase 0x50:\nVAR_8 = GET_BLOCK_COUNT();",
"VAR_8 *= 2;",
"if ((VAR_15 == 0) && (VAR_16 < 2 * 4)) {",
"av_log(VAR_0->avctx, AV_LOG_INFO, \"encountered repeat block VAR_7 (%02X) but not enough blocks rendered yet\\n\",\nVAR_7 & 0xF0);",
"break;",
"}",
"if (VAR_16 == 0)\nVAR_22 = (VAR_15 - VAR_0->avctx->VAR_1 * 4) +\nVAR_0->avctx->VAR_1 - 4 * 2;",
"else if (VAR_16 == 4)\nVAR_22 = (VAR_15 - VAR_0->avctx->VAR_1 * 4) + VAR_19;",
"else\nVAR_22 = VAR_15 + VAR_16 - 4 * 2;",
"if (VAR_16 == 0)\nVAR_23 = (VAR_15 - VAR_0->avctx->VAR_1 * 4) + VAR_19;",
"else\nVAR_23 = VAR_15 + VAR_16 - 4;",
"VAR_24 = 0;",
"while (VAR_8--) {",
"VAR_20 = VAR_15 + VAR_16;",
"if (VAR_24)\nVAR_21 = VAR_23;",
"else\nVAR_21 = VAR_22;",
"VAR_24 = !VAR_24;",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {",
"for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {",
"VAR_13[VAR_20++] = VAR_13[VAR_21++];",
"}",
"VAR_20 += VAR_19;",
"VAR_21 += VAR_19;",
"}",
"ADVANCE_BLOCK();",
"}",
"break;",
"case 0x60:\ncase 0x70:\nVAR_8 = GET_BLOCK_COUNT();",
"VAR_27 = VAR_0->buf[VAR_5++];",
"while (VAR_8--) {",
"VAR_20 = VAR_15 + VAR_16;",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {",
"for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {",
"VAR_13[VAR_20++] = VAR_27;",
"}",
"VAR_20 += VAR_19;",
"}",
"ADVANCE_BLOCK();",
"}",
"break;",
"case 0x80:\ncase 0x90:\nVAR_8 = (VAR_7 & 0x0F) + 1;",
"if ((VAR_7 & 0xF0) == 0x80) {",
"for (VAR_4 = 0; VAR_4 < CPAIR; VAR_4++) {",
"VAR_27 = VAR_0->buf[VAR_5++];",
"VAR_26 = CPAIR * VAR_28 + VAR_4;",
"VAR_0->color_pairs[VAR_26] = VAR_27;",
"}",
"VAR_26 = CPAIR * VAR_28;",
"VAR_28++;",
"if (VAR_28 == COLORS_PER_TABLE)\nVAR_28 = 0;",
"} else",
"VAR_26 = CPAIR * VAR_0->buf[VAR_5++];",
"while (VAR_8--) {",
"VAR_9 = AV_RB16(&VAR_0->buf[VAR_5]);",
"VAR_5 += 2;",
"VAR_12 = 0x8000;",
"VAR_20 = VAR_15 + VAR_16;",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {",
"for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {",
"if (VAR_9 & VAR_12)\nVAR_27 = VAR_26 + 1;",
"else\nVAR_27 = VAR_26;",
"VAR_12 >>= 1;",
"VAR_13[VAR_20++] = VAR_0->color_pairs[VAR_27];",
"}",
"VAR_20 += VAR_19;",
"}",
"ADVANCE_BLOCK();",
"}",
"break;",
"case 0xA0:\ncase 0xB0:\nVAR_8 = (VAR_7 & 0x0F) + 1;",
"if ((VAR_7 & 0xF0) == 0xA0) {",
"for (VAR_4 = 0; VAR_4 < CQUAD; VAR_4++) {",
"VAR_27 = VAR_0->buf[VAR_5++];",
"VAR_26 = CQUAD * VAR_29 + VAR_4;",
"VAR_0->color_quads[VAR_26] = VAR_27;",
"}",
"VAR_26 = CQUAD * VAR_29;",
"VAR_29++;",
"if (VAR_29 == COLORS_PER_TABLE)\nVAR_29 = 0;",
"} else",
"VAR_26 = CQUAD * VAR_0->buf[VAR_5++];",
"while (VAR_8--) {",
"VAR_9 = AV_RB32(&VAR_0->buf[VAR_5]);",
"VAR_5 += 4;",
"VAR_12 = 30;",
"VAR_20 = VAR_15 + VAR_16;",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {",
"for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {",
"VAR_27 = VAR_26 +\n((VAR_9 >> VAR_12) & 0x03);",
"VAR_12 -= 2;",
"VAR_13[VAR_20++] = VAR_0->color_quads[VAR_27];",
"}",
"VAR_20 += VAR_19;",
"}",
"ADVANCE_BLOCK();",
"}",
"break;",
"case 0xC0:\ncase 0xD0:\nVAR_8 = (VAR_7 & 0x0F) + 1;",
"if ((VAR_7 & 0xF0) == 0xC0) {",
"for (VAR_4 = 0; VAR_4 < COCTET; VAR_4++) {",
"VAR_27 = VAR_0->buf[VAR_5++];",
"VAR_26 = COCTET * VAR_30 + VAR_4;",
"VAR_0->color_octets[VAR_26] = VAR_27;",
"}",
"VAR_26 = COCTET * VAR_30;",
"VAR_30++;",
"if (VAR_30 == COLORS_PER_TABLE)\nVAR_30 = 0;",
"} else",
"VAR_26 = COCTET * VAR_0->buf[VAR_5++];",
"while (VAR_8--) {",
"VAR_10 =\n((AV_RB16(VAR_0->buf + VAR_5 ) & 0xFFF0) << 8) |\n(AV_RB16(VAR_0->buf + VAR_5 + 2) >> 4);",
"VAR_11 =\n((AV_RB16(VAR_0->buf + VAR_5 + 4) & 0xFFF0) << 8) |\n((VAR_0->buf[VAR_5 + 1] & 0x0F) << 8) |\n((VAR_0->buf[VAR_5 + 3] & 0x0F) << 4) |\n(VAR_0->buf[VAR_5 + 5] & 0x0F);",
"VAR_5 += 6;",
"VAR_9 = VAR_10;",
"VAR_12 = 21;",
"VAR_20 = VAR_15 + VAR_16;",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {",
"if (VAR_18 == 2) {",
"VAR_9 = VAR_11;",
"VAR_12 = 21;",
"}",
"for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {",
"VAR_27 = VAR_26 +\n((VAR_9 >> VAR_12) & 0x07);",
"VAR_12 -= 3;",
"VAR_13[VAR_20++] = VAR_0->color_octets[VAR_27];",
"}",
"VAR_20 += VAR_19;",
"}",
"ADVANCE_BLOCK();",
"}",
"break;",
"case 0xE0:\nVAR_8 = (VAR_7 & 0x0F) + 1;",
"while (VAR_8--) {",
"VAR_20 = VAR_15 + VAR_16;",
"for (VAR_18 = 0; VAR_18 < 4; VAR_18++) {",
"for (VAR_17 = 0; VAR_17 < 4; VAR_17++) {",
"VAR_13[VAR_20++] = VAR_0->buf[VAR_5++];",
"}",
"VAR_20 += VAR_19;",
"}",
"ADVANCE_BLOCK();",
"}",
"break;",
"case 0xF0:\nav_log(VAR_0->avctx, AV_LOG_INFO, \"0xF0 VAR_7 seen in SMC chunk (contact the developers)\\n\");",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
71
],
[
75
],
[
77
],
[
79,
81
],
[
83
],
[
87
],
[
89
],
[
95
],
[
101
],
[
103,
105
],
[
107
],
[
109
],
[
113
],
[
115,
117
],
[
119
],
[
121
],
[
125
],
[
127
],
[
131,
133,
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
149,
151,
153
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
173,
175,
177
],
[
179,
181
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
215,
217,
219
],
[
221
],
[
227
],
[
229,
231
],
[
233
],
[
235
],
[
241,
243,
245
],
[
247,
249
],
[
251,
253
],
[
257,
259
],
[
261,
263
],
[
267
],
[
269
],
[
271
],
[
273,
275
],
[
277,
279
],
[
281
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303
],
[
309,
311,
313
],
[
315
],
[
319
],
[
321
],
[
323
],
[
325
],
[
327
],
[
329
],
[
331
],
[
333
],
[
335
],
[
337
],
[
339
],
[
345,
347,
349
],
[
355
],
[
361
],
[
363
],
[
365
],
[
367
],
[
369
],
[
373
],
[
375
],
[
379,
381
],
[
383
],
[
385
],
[
389
],
[
391
],
[
393
],
[
395
],
[
397
],
[
399
],
[
401
],
[
403,
405
],
[
407,
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
421
],
[
423
],
[
425
],
[
431,
433,
435
],
[
441
],
[
447
],
[
449
],
[
451
],
[
453
],
[
455
],
[
459
],
[
461
],
[
465,
467
],
[
469
],
[
471
],
[
475
],
[
477
],
[
479
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491,
493
],
[
495
],
[
497
],
[
499
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
515,
517,
519
],
[
525
],
[
531
],
[
533
],
[
535
],
[
537
],
[
539
],
[
543
],
[
545
],
[
549,
551
],
[
553
],
[
555
],
[
559
],
[
575,
577,
579
],
[
581,
583,
585,
587,
589
],
[
591
],
[
595
],
[
599
],
[
601
],
[
603
],
[
607
],
[
609
],
[
611
],
[
613
],
[
615
],
[
617,
619
],
[
621
],
[
623
],
[
625
],
[
627
],
[
629
],
[
631
],
[
633
],
[
635
],
[
641,
643
],
[
647
],
[
649
],
[
651
],
[
653
],
[
655
],
[
657
],
[
659
],
[
661
],
[
663
],
[
665
],
[
667
],
[
671,
673
],
[
675
],
[
677
],
[
679
],
[
681
]
] |
25,082 | static void vhost_scsi_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->exit = vhost_scsi_exit;
dc->props = vhost_scsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->init = vhost_scsi_init;
vdc->get_features = vhost_scsi_get_features;
vdc->set_config = vhost_scsi_set_config;
vdc->set_status = vhost_scsi_set_status;
}
| true | qemu | e3c9d76acc984218264bbc6435b0c09f959ed9b8 | static void vhost_scsi_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass);
dc->exit = vhost_scsi_exit;
dc->props = vhost_scsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->init = vhost_scsi_init;
vdc->get_features = vhost_scsi_get_features;
vdc->set_config = vhost_scsi_set_config;
vdc->set_status = vhost_scsi_set_status;
}
| {
"code": [
" dc->exit = vhost_scsi_exit;"
],
"line_no": [
9
]
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(VAR_0);
dc->exit = vhost_scsi_exit;
dc->props = vhost_scsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->init = vhost_scsi_init;
vdc->get_features = vhost_scsi_get_features;
vdc->set_config = vhost_scsi_set_config;
vdc->set_status = vhost_scsi_set_status;
}
| [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(VAR_0);",
"dc->exit = vhost_scsi_exit;",
"dc->props = vhost_scsi_properties;",
"set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);",
"vdc->init = vhost_scsi_init;",
"vdc->get_features = vhost_scsi_get_features;",
"vdc->set_config = vhost_scsi_set_config;",
"vdc->set_status = vhost_scsi_set_status;",
"}"
] | [
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
]
] |
25,083 | ivshmem_client_parse_args(IvshmemClientArgs *args, int argc, char *argv[])
{
int c;
while ((c = getopt(argc, argv,
"h" /* help */
"v" /* verbose */
"S:" /* unix_sock_path */
)) != -1) {
switch (c) {
case 'h': /* help */
ivshmem_client_usage(argv[0], 0);
break;
case 'v': /* verbose */
args->verbose = 1;
break;
case 'S': /* unix_sock_path */
args->unix_sock_path = strdup(optarg);
break;
default:
ivshmem_client_usage(argv[0], 1);
break;
}
}
}
| true | qemu | 45b00c44ceffeac8143fb8857a12677234114f2b | ivshmem_client_parse_args(IvshmemClientArgs *args, int argc, char *argv[])
{
int c;
while ((c = getopt(argc, argv,
"h"
"v"
"S:"
)) != -1) {
switch (c) {
case 'h':
ivshmem_client_usage(argv[0], 0);
break;
case 'v':
args->verbose = 1;
break;
case 'S':
args->unix_sock_path = strdup(optarg);
break;
default:
ivshmem_client_usage(argv[0], 1);
break;
}
}
}
| {
"code": [
" args->unix_sock_path = strdup(optarg);"
],
"line_no": [
41
]
} | FUNC_0(IvshmemClientArgs *VAR_0, int VAR_1, char *VAR_2[])
{
int VAR_3;
while ((VAR_3 = getopt(VAR_1, VAR_2,
"h"
"v"
"S:"
)) != -1) {
switch (VAR_3) {
case 'h':
ivshmem_client_usage(VAR_2[0], 0);
break;
case 'v':
VAR_0->verbose = 1;
break;
case 'S':
VAR_0->unix_sock_path = strdup(optarg);
break;
default:
ivshmem_client_usage(VAR_2[0], 1);
break;
}
}
}
| [
"FUNC_0(IvshmemClientArgs *VAR_0, int VAR_1, char *VAR_2[])\n{",
"int VAR_3;",
"while ((VAR_3 = getopt(VAR_1, VAR_2,\n\"h\"\n\"v\"\n\"S:\"\n)) != -1) {",
"switch (VAR_3) {",
"case 'h':\nivshmem_client_usage(VAR_2[0], 0);",
"break;",
"case 'v':\nVAR_0->verbose = 1;",
"break;",
"case 'S':\nVAR_0->unix_sock_path = strdup(optarg);",
"break;",
"default:\nivshmem_client_usage(VAR_2[0], 1);",
"break;",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11,
13,
15,
17
],
[
21
],
[
23,
25
],
[
27
],
[
31,
33
],
[
35
],
[
39,
41
],
[
43
],
[
47,
49
],
[
51
],
[
53
],
[
55
],
[
57
]
] |
25,084 | static int estimate_sid_gain(G723_1_Context *p)
{
int i, shift, seg, seg2, t, val, val_add, x, y;
shift = 16 - p->cur_gain * 2;
if (shift > 0)
t = p->sid_gain << shift;
else
t = p->sid_gain >> -shift;
x = av_clipl_int32(t * (int64_t)cng_filt[0] >> 16);
if (x >= cng_bseg[2])
return 0x3F;
if (x >= cng_bseg[1]) {
shift = 4;
seg = 3;
} else {
shift = 3;
seg = (x >= cng_bseg[0]);
}
seg2 = FFMIN(seg, 3);
val = 1 << shift;
val_add = val >> 1;
for (i = 0; i < shift; i++) {
t = seg * 32 + (val << seg2);
t *= t;
if (x >= t)
val += val_add;
else
val -= val_add;
val_add >>= 1;
}
t = seg * 32 + (val << seg2);
y = t * t - x;
if (y <= 0) {
t = seg * 32 + (val + 1 << seg2);
t = t * t - x;
val = (seg2 - 1 << 4) + val;
if (t >= y)
val++;
} else {
t = seg * 32 + (val - 1 << seg2);
t = t * t - x;
val = (seg2 - 1 << 4) + val;
if (t >= y)
val--;
}
return val;
}
| true | FFmpeg | c4c0245686bc2fcc545644101c7b328fed71f268 | static int estimate_sid_gain(G723_1_Context *p)
{
int i, shift, seg, seg2, t, val, val_add, x, y;
shift = 16 - p->cur_gain * 2;
if (shift > 0)
t = p->sid_gain << shift;
else
t = p->sid_gain >> -shift;
x = av_clipl_int32(t * (int64_t)cng_filt[0] >> 16);
if (x >= cng_bseg[2])
return 0x3F;
if (x >= cng_bseg[1]) {
shift = 4;
seg = 3;
} else {
shift = 3;
seg = (x >= cng_bseg[0]);
}
seg2 = FFMIN(seg, 3);
val = 1 << shift;
val_add = val >> 1;
for (i = 0; i < shift; i++) {
t = seg * 32 + (val << seg2);
t *= t;
if (x >= t)
val += val_add;
else
val -= val_add;
val_add >>= 1;
}
t = seg * 32 + (val << seg2);
y = t * t - x;
if (y <= 0) {
t = seg * 32 + (val + 1 << seg2);
t = t * t - x;
val = (seg2 - 1 << 4) + val;
if (t >= y)
val++;
} else {
t = seg * 32 + (val - 1 << seg2);
t = t * t - x;
val = (seg2 - 1 << 4) + val;
if (t >= y)
val--;
}
return val;
}
| {
"code": [
" val = (seg2 - 1 << 4) + val;",
" val = (seg2 - 1 << 4) + val;"
],
"line_no": [
81,
81
]
} | static int FUNC_0(G723_1_Context *VAR_0)
{
int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
VAR_2 = 16 - VAR_0->cur_gain * 2;
if (VAR_2 > 0)
VAR_5 = VAR_0->sid_gain << VAR_2;
else
VAR_5 = VAR_0->sid_gain >> -VAR_2;
VAR_8 = av_clipl_int32(VAR_5 * (int64_t)cng_filt[0] >> 16);
if (VAR_8 >= cng_bseg[2])
return 0x3F;
if (VAR_8 >= cng_bseg[1]) {
VAR_2 = 4;
VAR_3 = 3;
} else {
VAR_2 = 3;
VAR_3 = (VAR_8 >= cng_bseg[0]);
}
VAR_4 = FFMIN(VAR_3, 3);
VAR_6 = 1 << VAR_2;
VAR_7 = VAR_6 >> 1;
for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) {
VAR_5 = VAR_3 * 32 + (VAR_6 << VAR_4);
VAR_5 *= VAR_5;
if (VAR_8 >= VAR_5)
VAR_6 += VAR_7;
else
VAR_6 -= VAR_7;
VAR_7 >>= 1;
}
VAR_5 = VAR_3 * 32 + (VAR_6 << VAR_4);
VAR_9 = VAR_5 * VAR_5 - VAR_8;
if (VAR_9 <= 0) {
VAR_5 = VAR_3 * 32 + (VAR_6 + 1 << VAR_4);
VAR_5 = VAR_5 * VAR_5 - VAR_8;
VAR_6 = (VAR_4 - 1 << 4) + VAR_6;
if (VAR_5 >= VAR_9)
VAR_6++;
} else {
VAR_5 = VAR_3 * 32 + (VAR_6 - 1 << VAR_4);
VAR_5 = VAR_5 * VAR_5 - VAR_8;
VAR_6 = (VAR_4 - 1 << 4) + VAR_6;
if (VAR_5 >= VAR_9)
VAR_6--;
}
return VAR_6;
}
| [
"static int FUNC_0(G723_1_Context *VAR_0)\n{",
"int VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"VAR_2 = 16 - VAR_0->cur_gain * 2;",
"if (VAR_2 > 0)\nVAR_5 = VAR_0->sid_gain << VAR_2;",
"else\nVAR_5 = VAR_0->sid_gain >> -VAR_2;",
"VAR_8 = av_clipl_int32(VAR_5 * (int64_t)cng_filt[0] >> 16);",
"if (VAR_8 >= cng_bseg[2])\nreturn 0x3F;",
"if (VAR_8 >= cng_bseg[1]) {",
"VAR_2 = 4;",
"VAR_3 = 3;",
"} else {",
"VAR_2 = 3;",
"VAR_3 = (VAR_8 >= cng_bseg[0]);",
"}",
"VAR_4 = FFMIN(VAR_3, 3);",
"VAR_6 = 1 << VAR_2;",
"VAR_7 = VAR_6 >> 1;",
"for (VAR_1 = 0; VAR_1 < VAR_2; VAR_1++) {",
"VAR_5 = VAR_3 * 32 + (VAR_6 << VAR_4);",
"VAR_5 *= VAR_5;",
"if (VAR_8 >= VAR_5)\nVAR_6 += VAR_7;",
"else\nVAR_6 -= VAR_7;",
"VAR_7 >>= 1;",
"}",
"VAR_5 = VAR_3 * 32 + (VAR_6 << VAR_4);",
"VAR_9 = VAR_5 * VAR_5 - VAR_8;",
"if (VAR_9 <= 0) {",
"VAR_5 = VAR_3 * 32 + (VAR_6 + 1 << VAR_4);",
"VAR_5 = VAR_5 * VAR_5 - VAR_8;",
"VAR_6 = (VAR_4 - 1 << 4) + VAR_6;",
"if (VAR_5 >= VAR_9)\nVAR_6++;",
"} else {",
"VAR_5 = VAR_3 * 32 + (VAR_6 - 1 << VAR_4);",
"VAR_5 = VAR_5 * VAR_5 - VAR_8;",
"VAR_6 = (VAR_4 - 1 << 4) + VAR_6;",
"if (VAR_5 >= VAR_9)\nVAR_6--;",
"}",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15,
17
],
[
19
],
[
23,
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57,
59
],
[
61,
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83,
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95,
97
],
[
99
],
[
103
],
[
105
]
] |
25,085 | static int decode_exp_vlc(WMACodecContext *s, int ch)
{
int last_exp, n, code;
const uint16_t *ptr;
float v, max_scale;
uint32_t *q, *q_end, iv;
const float *ptab = pow_tab + 60;
const uint32_t *iptab = (const uint32_t*)ptab;
ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
q = (uint32_t *)s->exponents[ch];
q_end = q + s->block_len;
max_scale = 0;
if (s->version == 1) {
last_exp = get_bits(&s->gb, 5) + 10;
v = ptab[last_exp];
iv = iptab[last_exp];
max_scale = v;
n = *ptr++;
switch (n & 3) do {
case 0: *q++ = iv;
case 3: *q++ = iv;
case 2: *q++ = iv;
case 1: *q++ = iv;
} while ((n -= 4) > 0);
}else
last_exp = 36;
while (q < q_end) {
code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX);
if (code < 0){
av_log(s->avctx, AV_LOG_ERROR, "Exponent vlc invalid\n");
return -1;
}
/* NOTE: this offset is the same as MPEG4 AAC ! */
last_exp += code - 60;
if ((unsigned)last_exp + 60 > FF_ARRAY_ELEMS(pow_tab)) {
av_log(s->avctx, AV_LOG_ERROR, "Exponent out of range: %d\n",
last_exp);
return -1;
}
v = ptab[last_exp];
iv = iptab[last_exp];
if (v > max_scale)
max_scale = v;
n = *ptr++;
switch (n & 3) do {
case 0: *q++ = iv;
case 3: *q++ = iv;
case 2: *q++ = iv;
case 1: *q++ = iv;
} while ((n -= 4) > 0);
}
s->max_exponent[ch] = max_scale;
return 0;
}
| true | FFmpeg | b4bccf3e4e58f6fe58043791ca09db01a4343fac | static int decode_exp_vlc(WMACodecContext *s, int ch)
{
int last_exp, n, code;
const uint16_t *ptr;
float v, max_scale;
uint32_t *q, *q_end, iv;
const float *ptab = pow_tab + 60;
const uint32_t *iptab = (const uint32_t*)ptab;
ptr = s->exponent_bands[s->frame_len_bits - s->block_len_bits];
q = (uint32_t *)s->exponents[ch];
q_end = q + s->block_len;
max_scale = 0;
if (s->version == 1) {
last_exp = get_bits(&s->gb, 5) + 10;
v = ptab[last_exp];
iv = iptab[last_exp];
max_scale = v;
n = *ptr++;
switch (n & 3) do {
case 0: *q++ = iv;
case 3: *q++ = iv;
case 2: *q++ = iv;
case 1: *q++ = iv;
} while ((n -= 4) > 0);
}else
last_exp = 36;
while (q < q_end) {
code = get_vlc2(&s->gb, s->exp_vlc.table, EXPVLCBITS, EXPMAX);
if (code < 0){
av_log(s->avctx, AV_LOG_ERROR, "Exponent vlc invalid\n");
return -1;
}
last_exp += code - 60;
if ((unsigned)last_exp + 60 > FF_ARRAY_ELEMS(pow_tab)) {
av_log(s->avctx, AV_LOG_ERROR, "Exponent out of range: %d\n",
last_exp);
return -1;
}
v = ptab[last_exp];
iv = iptab[last_exp];
if (v > max_scale)
max_scale = v;
n = *ptr++;
switch (n & 3) do {
case 0: *q++ = iv;
case 3: *q++ = iv;
case 2: *q++ = iv;
case 1: *q++ = iv;
} while ((n -= 4) > 0);
}
s->max_exponent[ch] = max_scale;
return 0;
}
| {
"code": [
" if ((unsigned)last_exp + 60 > FF_ARRAY_ELEMS(pow_tab)) {"
],
"line_no": [
73
]
} | static int FUNC_0(WMACodecContext *VAR_0, int VAR_1)
{
int VAR_2, VAR_3, VAR_4;
const uint16_t *VAR_5;
float VAR_6, VAR_7;
uint32_t *q, *q_end, iv;
const float *VAR_8 = pow_tab + 60;
const uint32_t *VAR_9 = (const uint32_t*)VAR_8;
VAR_5 = VAR_0->exponent_bands[VAR_0->frame_len_bits - VAR_0->block_len_bits];
q = (uint32_t *)VAR_0->exponents[VAR_1];
q_end = q + VAR_0->block_len;
VAR_7 = 0;
if (VAR_0->version == 1) {
VAR_2 = get_bits(&VAR_0->gb, 5) + 10;
VAR_6 = VAR_8[VAR_2];
iv = VAR_9[VAR_2];
VAR_7 = VAR_6;
VAR_3 = *VAR_5++;
switch (VAR_3 & 3) do {
case 0: *q++ = iv;
case 3: *q++ = iv;
case 2: *q++ = iv;
case 1: *q++ = iv;
} while ((VAR_3 -= 4) > 0);
}else
VAR_2 = 36;
while (q < q_end) {
VAR_4 = get_vlc2(&VAR_0->gb, VAR_0->exp_vlc.table, EXPVLCBITS, EXPMAX);
if (VAR_4 < 0){
av_log(VAR_0->avctx, AV_LOG_ERROR, "Exponent vlc invalid\VAR_3");
return -1;
}
VAR_2 += VAR_4 - 60;
if ((unsigned)VAR_2 + 60 > FF_ARRAY_ELEMS(pow_tab)) {
av_log(VAR_0->avctx, AV_LOG_ERROR, "Exponent out of range: %d\VAR_3",
VAR_2);
return -1;
}
VAR_6 = VAR_8[VAR_2];
iv = VAR_9[VAR_2];
if (VAR_6 > VAR_7)
VAR_7 = VAR_6;
VAR_3 = *VAR_5++;
switch (VAR_3 & 3) do {
case 0: *q++ = iv;
case 3: *q++ = iv;
case 2: *q++ = iv;
case 1: *q++ = iv;
} while ((VAR_3 -= 4) > 0);
}
VAR_0->max_exponent[VAR_1] = VAR_7;
return 0;
}
| [
"static int FUNC_0(WMACodecContext *VAR_0, int VAR_1)\n{",
"int VAR_2, VAR_3, VAR_4;",
"const uint16_t *VAR_5;",
"float VAR_6, VAR_7;",
"uint32_t *q, *q_end, iv;",
"const float *VAR_8 = pow_tab + 60;",
"const uint32_t *VAR_9 = (const uint32_t*)VAR_8;",
"VAR_5 = VAR_0->exponent_bands[VAR_0->frame_len_bits - VAR_0->block_len_bits];",
"q = (uint32_t *)VAR_0->exponents[VAR_1];",
"q_end = q + VAR_0->block_len;",
"VAR_7 = 0;",
"if (VAR_0->version == 1) {",
"VAR_2 = get_bits(&VAR_0->gb, 5) + 10;",
"VAR_6 = VAR_8[VAR_2];",
"iv = VAR_9[VAR_2];",
"VAR_7 = VAR_6;",
"VAR_3 = *VAR_5++;",
"switch (VAR_3 & 3) do {",
"case 0: *q++ = iv;",
"case 3: *q++ = iv;",
"case 2: *q++ = iv;",
"case 1: *q++ = iv;",
"} while ((VAR_3 -= 4) > 0);",
"}else",
"VAR_2 = 36;",
"while (q < q_end) {",
"VAR_4 = get_vlc2(&VAR_0->gb, VAR_0->exp_vlc.table, EXPVLCBITS, EXPMAX);",
"if (VAR_4 < 0){",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Exponent vlc invalid\\VAR_3\");",
"return -1;",
"}",
"VAR_2 += VAR_4 - 60;",
"if ((unsigned)VAR_2 + 60 > FF_ARRAY_ELEMS(pow_tab)) {",
"av_log(VAR_0->avctx, AV_LOG_ERROR, \"Exponent out of range: %d\\VAR_3\",\nVAR_2);",
"return -1;",
"}",
"VAR_6 = VAR_8[VAR_2];",
"iv = VAR_9[VAR_2];",
"if (VAR_6 > VAR_7)\nVAR_7 = VAR_6;",
"VAR_3 = *VAR_5++;",
"switch (VAR_3 & 3) do {",
"case 0: *q++ = iv;",
"case 3: *q++ = iv;",
"case 2: *q++ = iv;",
"case 1: *q++ = iv;",
"} while ((VAR_3 -= 4) > 0);",
"}",
"VAR_0->max_exponent[VAR_1] = VAR_7;",
"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,
1,
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
],
[
51
],
[
53
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75,
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87,
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
]
] |
25,086 | static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
{
BC_STATUS ret;
BC_DTS_STATUS decoder_status;
CopyRet rec_ret;
CHDContext *priv = avctx->priv_data;
HANDLE dev = priv->dev;
int len = avpkt->size;
uint8_t pic_type = 0;
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: decode_frame\n");
if (len) {
int32_t tx_free = (int32_t)DtsTxFreeSize(dev);
if (priv->parser) {
uint8_t *pout;
int psize = len;
H264Context *h = priv->parser->priv_data;
while (psize)
ret = av_parser_parse2(priv->parser, avctx, &pout, &psize,
avpkt->data, len, avctx->pkt->pts,
avctx->pkt->dts, len - psize);
av_log(avctx, AV_LOG_VERBOSE,
"CrystalHD: parser picture type %d\n",
h->s.picture_structure);
pic_type = h->s.picture_structure;
}
if (len < tx_free - 1024) {
/*
* Despite being notionally opaque, either libcrystalhd or
* the hardware itself will mangle pts values that are too
* small or too large. The docs claim it should be in units
* of 100ns. Given that we're nominally dealing with a black
* box on both sides, any transform we do has no guarantee of
* avoiding mangling so we need to build a mapping to values
* we know will not be mangled.
*/
uint64_t pts = opaque_list_push(priv, avctx->pkt->pts, pic_type);
if (!pts) {
return AVERROR(ENOMEM);
}
av_log(priv->avctx, AV_LOG_VERBOSE,
"input \"pts\": %"PRIu64"\n", pts);
ret = DtsProcInput(dev, avpkt->data, len, pts, 0);
if (ret == BC_STS_BUSY) {
av_log(avctx, AV_LOG_WARNING,
"CrystalHD: ProcInput returned busy\n");
usleep(BASE_WAIT);
return AVERROR(EBUSY);
} else if (ret != BC_STS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR,
"CrystalHD: ProcInput failed: %u\n", ret);
return -1;
}
avctx->has_b_frames++;
} else {
av_log(avctx, AV_LOG_WARNING, "CrystalHD: Input buffer full\n");
len = 0; // We didn't consume any bytes.
}
} else {
av_log(avctx, AV_LOG_INFO, "CrystalHD: No more input data\n");
}
if (priv->skip_next_output) {
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Skipping next output.\n");
priv->skip_next_output = 0;
avctx->has_b_frames--;
return len;
}
ret = DtsGetDriverStatus(dev, &decoder_status);
if (ret != BC_STS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "CrystalHD: GetDriverStatus failed\n");
return -1;
}
/*
* No frames ready. Don't try to extract.
*
* Empirical testing shows that ReadyListCount can be a damn lie,
* and ProcOut still fails when count > 0. The same testing showed
* that two more iterations were needed before ProcOutput would
* succeed.
*/
if (priv->output_ready < 2) {
if (decoder_status.ReadyListCount != 0)
priv->output_ready++;
usleep(BASE_WAIT);
av_log(avctx, AV_LOG_INFO, "CrystalHD: Filling pipeline.\n");
return len;
} else if (decoder_status.ReadyListCount == 0) {
/*
* After the pipeline is established, if we encounter a lack of frames
* that probably means we're not giving the hardware enough time to
* decode them, so start increasing the wait time at the end of a
* decode call.
*/
usleep(BASE_WAIT);
priv->decode_wait += WAIT_UNIT;
av_log(avctx, AV_LOG_INFO, "CrystalHD: No frames ready. Returning\n");
return len;
}
do {
rec_ret = receive_frame(avctx, data, data_size, 0);
if (rec_ret == RET_OK && *data_size == 0) {
/*
* This case is for when the encoded fields are stored
* separately and we get a separate avpkt for each one. To keep
* the pipeline stable, we should return nothing and wait for
* the next time round to grab the second field.
* H.264 PAFF is an example of this.
*/
av_log(avctx, AV_LOG_VERBOSE, "Returning after first field.\n");
avctx->has_b_frames--;
} else if (rec_ret == RET_COPY_NEXT_FIELD) {
/*
* This case is for when the encoded fields are stored in a
* single avpkt but the hardware returns then separately. Unless
* we grab the second field before returning, we'll slip another
* frame in the pipeline and if that happens a lot, we're sunk.
* So we have to get that second field now.
* Interlaced mpeg2 and vc1 are examples of this.
*/
av_log(avctx, AV_LOG_VERBOSE, "Trying to get second field.\n");
while (1) {
usleep(priv->decode_wait);
ret = DtsGetDriverStatus(dev, &decoder_status);
if (ret == BC_STS_SUCCESS &&
decoder_status.ReadyListCount > 0) {
rec_ret = receive_frame(avctx, data, data_size, 1);
if ((rec_ret == RET_OK && *data_size > 0) ||
rec_ret == RET_ERROR)
break;
}
}
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Got second field.\n");
} else if (rec_ret == RET_SKIP_NEXT_COPY) {
/*
* Two input packets got turned into a field pair. Gawd.
*/
av_log(avctx, AV_LOG_VERBOSE,
"Don't output on next decode call.\n");
priv->skip_next_output = 1;
}
/*
* If rec_ret == RET_COPY_AGAIN, that means that either we just handled
* a FMT_CHANGE event and need to go around again for the actual frame,
* we got a busy status and need to try again, or we're dealing with
* packed b-frames, where the hardware strangely returns the packed
* p-frame twice. We choose to keep the second copy as it carries the
* valid pts.
*/
} while (rec_ret == RET_COPY_AGAIN);
usleep(priv->decode_wait);
return len;
}
| true | FFmpeg | ae7a4a1594e3624f7c844dec44266d2dc74a6be2 | static int decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
{
BC_STATUS ret;
BC_DTS_STATUS decoder_status;
CopyRet rec_ret;
CHDContext *priv = avctx->priv_data;
HANDLE dev = priv->dev;
int len = avpkt->size;
uint8_t pic_type = 0;
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: decode_frame\n");
if (len) {
int32_t tx_free = (int32_t)DtsTxFreeSize(dev);
if (priv->parser) {
uint8_t *pout;
int psize = len;
H264Context *h = priv->parser->priv_data;
while (psize)
ret = av_parser_parse2(priv->parser, avctx, &pout, &psize,
avpkt->data, len, avctx->pkt->pts,
avctx->pkt->dts, len - psize);
av_log(avctx, AV_LOG_VERBOSE,
"CrystalHD: parser picture type %d\n",
h->s.picture_structure);
pic_type = h->s.picture_structure;
}
if (len < tx_free - 1024) {
uint64_t pts = opaque_list_push(priv, avctx->pkt->pts, pic_type);
if (!pts) {
return AVERROR(ENOMEM);
}
av_log(priv->avctx, AV_LOG_VERBOSE,
"input \"pts\": %"PRIu64"\n", pts);
ret = DtsProcInput(dev, avpkt->data, len, pts, 0);
if (ret == BC_STS_BUSY) {
av_log(avctx, AV_LOG_WARNING,
"CrystalHD: ProcInput returned busy\n");
usleep(BASE_WAIT);
return AVERROR(EBUSY);
} else if (ret != BC_STS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR,
"CrystalHD: ProcInput failed: %u\n", ret);
return -1;
}
avctx->has_b_frames++;
} else {
av_log(avctx, AV_LOG_WARNING, "CrystalHD: Input buffer full\n");
len = 0;
}
} else {
av_log(avctx, AV_LOG_INFO, "CrystalHD: No more input data\n");
}
if (priv->skip_next_output) {
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Skipping next output.\n");
priv->skip_next_output = 0;
avctx->has_b_frames--;
return len;
}
ret = DtsGetDriverStatus(dev, &decoder_status);
if (ret != BC_STS_SUCCESS) {
av_log(avctx, AV_LOG_ERROR, "CrystalHD: GetDriverStatus failed\n");
return -1;
}
if (priv->output_ready < 2) {
if (decoder_status.ReadyListCount != 0)
priv->output_ready++;
usleep(BASE_WAIT);
av_log(avctx, AV_LOG_INFO, "CrystalHD: Filling pipeline.\n");
return len;
} else if (decoder_status.ReadyListCount == 0) {
usleep(BASE_WAIT);
priv->decode_wait += WAIT_UNIT;
av_log(avctx, AV_LOG_INFO, "CrystalHD: No frames ready. Returning\n");
return len;
}
do {
rec_ret = receive_frame(avctx, data, data_size, 0);
if (rec_ret == RET_OK && *data_size == 0) {
av_log(avctx, AV_LOG_VERBOSE, "Returning after first field.\n");
avctx->has_b_frames--;
} else if (rec_ret == RET_COPY_NEXT_FIELD) {
av_log(avctx, AV_LOG_VERBOSE, "Trying to get second field.\n");
while (1) {
usleep(priv->decode_wait);
ret = DtsGetDriverStatus(dev, &decoder_status);
if (ret == BC_STS_SUCCESS &&
decoder_status.ReadyListCount > 0) {
rec_ret = receive_frame(avctx, data, data_size, 1);
if ((rec_ret == RET_OK && *data_size > 0) ||
rec_ret == RET_ERROR)
break;
}
}
av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: Got second field.\n");
} else if (rec_ret == RET_SKIP_NEXT_COPY) {
av_log(avctx, AV_LOG_VERBOSE,
"Don't output on next decode call.\n");
priv->skip_next_output = 1;
}
} while (rec_ret == RET_COPY_AGAIN);
usleep(priv->decode_wait);
return len;
}
| {
"code": [
" rec_ret = receive_frame(avctx, data, data_size, 0);",
" rec_ret = receive_frame(avctx, data, data_size, 1);"
],
"line_no": [
215,
267
]
} | static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3)
{
BC_STATUS ret;
BC_DTS_STATUS decoder_status;
CopyRet rec_ret;
CHDContext *priv = VAR_0->priv_data;
HANDLE dev = priv->dev;
int VAR_4 = VAR_3->size;
uint8_t pic_type = 0;
av_log(VAR_0, AV_LOG_VERBOSE, "CrystalHD: decode_frame\n");
if (VAR_4) {
int32_t tx_free = (int32_t)DtsTxFreeSize(dev);
if (priv->parser) {
uint8_t *pout;
int VAR_5 = VAR_4;
H264Context *h = priv->parser->priv_data;
while (VAR_5)
ret = av_parser_parse2(priv->parser, VAR_0, &pout, &VAR_5,
VAR_3->VAR_1, VAR_4, VAR_0->pkt->pts,
VAR_0->pkt->dts, VAR_4 - VAR_5);
av_log(VAR_0, AV_LOG_VERBOSE,
"CrystalHD: parser picture type %d\n",
h->s.picture_structure);
pic_type = h->s.picture_structure;
}
if (VAR_4 < tx_free - 1024) {
uint64_t pts = opaque_list_push(priv, VAR_0->pkt->pts, pic_type);
if (!pts) {
return AVERROR(ENOMEM);
}
av_log(priv->VAR_0, AV_LOG_VERBOSE,
"input \"pts\": %"PRIu64"\n", pts);
ret = DtsProcInput(dev, VAR_3->VAR_1, VAR_4, pts, 0);
if (ret == BC_STS_BUSY) {
av_log(VAR_0, AV_LOG_WARNING,
"CrystalHD: ProcInput returned busy\n");
usleep(BASE_WAIT);
return AVERROR(EBUSY);
} else if (ret != BC_STS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR,
"CrystalHD: ProcInput failed: %u\n", ret);
return -1;
}
VAR_0->has_b_frames++;
} else {
av_log(VAR_0, AV_LOG_WARNING, "CrystalHD: Input buffer full\n");
VAR_4 = 0;
}
} else {
av_log(VAR_0, AV_LOG_INFO, "CrystalHD: No more input VAR_1\n");
}
if (priv->skip_next_output) {
av_log(VAR_0, AV_LOG_VERBOSE, "CrystalHD: Skipping next output.\n");
priv->skip_next_output = 0;
VAR_0->has_b_frames--;
return VAR_4;
}
ret = DtsGetDriverStatus(dev, &decoder_status);
if (ret != BC_STS_SUCCESS) {
av_log(VAR_0, AV_LOG_ERROR, "CrystalHD: GetDriverStatus failed\n");
return -1;
}
if (priv->output_ready < 2) {
if (decoder_status.ReadyListCount != 0)
priv->output_ready++;
usleep(BASE_WAIT);
av_log(VAR_0, AV_LOG_INFO, "CrystalHD: Filling pipeline.\n");
return VAR_4;
} else if (decoder_status.ReadyListCount == 0) {
usleep(BASE_WAIT);
priv->decode_wait += WAIT_UNIT;
av_log(VAR_0, AV_LOG_INFO, "CrystalHD: No frames ready. Returning\n");
return VAR_4;
}
do {
rec_ret = receive_frame(VAR_0, VAR_1, VAR_2, 0);
if (rec_ret == RET_OK && *VAR_2 == 0) {
av_log(VAR_0, AV_LOG_VERBOSE, "Returning after first field.\n");
VAR_0->has_b_frames--;
} else if (rec_ret == RET_COPY_NEXT_FIELD) {
av_log(VAR_0, AV_LOG_VERBOSE, "Trying to get second field.\n");
while (1) {
usleep(priv->decode_wait);
ret = DtsGetDriverStatus(dev, &decoder_status);
if (ret == BC_STS_SUCCESS &&
decoder_status.ReadyListCount > 0) {
rec_ret = receive_frame(VAR_0, VAR_1, VAR_2, 1);
if ((rec_ret == RET_OK && *VAR_2 > 0) ||
rec_ret == RET_ERROR)
break;
}
}
av_log(VAR_0, AV_LOG_VERBOSE, "CrystalHD: Got second field.\n");
} else if (rec_ret == RET_SKIP_NEXT_COPY) {
av_log(VAR_0, AV_LOG_VERBOSE,
"Don't output on next FUNC_0 call.\n");
priv->skip_next_output = 1;
}
} while (rec_ret == RET_COPY_AGAIN);
usleep(priv->decode_wait);
return VAR_4;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, AVPacket *VAR_3)\n{",
"BC_STATUS ret;",
"BC_DTS_STATUS decoder_status;",
"CopyRet rec_ret;",
"CHDContext *priv = VAR_0->priv_data;",
"HANDLE dev = priv->dev;",
"int VAR_4 = VAR_3->size;",
"uint8_t pic_type = 0;",
"av_log(VAR_0, AV_LOG_VERBOSE, \"CrystalHD: decode_frame\\n\");",
"if (VAR_4) {",
"int32_t tx_free = (int32_t)DtsTxFreeSize(dev);",
"if (priv->parser) {",
"uint8_t *pout;",
"int VAR_5 = VAR_4;",
"H264Context *h = priv->parser->priv_data;",
"while (VAR_5)\nret = av_parser_parse2(priv->parser, VAR_0, &pout, &VAR_5,\nVAR_3->VAR_1, VAR_4, VAR_0->pkt->pts,\nVAR_0->pkt->dts, VAR_4 - VAR_5);",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"CrystalHD: parser picture type %d\\n\",\nh->s.picture_structure);",
"pic_type = h->s.picture_structure;",
"}",
"if (VAR_4 < tx_free - 1024) {",
"uint64_t pts = opaque_list_push(priv, VAR_0->pkt->pts, pic_type);",
"if (!pts) {",
"return AVERROR(ENOMEM);",
"}",
"av_log(priv->VAR_0, AV_LOG_VERBOSE,\n\"input \\\"pts\\\": %\"PRIu64\"\\n\", pts);",
"ret = DtsProcInput(dev, VAR_3->VAR_1, VAR_4, pts, 0);",
"if (ret == BC_STS_BUSY) {",
"av_log(VAR_0, AV_LOG_WARNING,\n\"CrystalHD: ProcInput returned busy\\n\");",
"usleep(BASE_WAIT);",
"return AVERROR(EBUSY);",
"} else if (ret != BC_STS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR,\n\"CrystalHD: ProcInput failed: %u\\n\", ret);",
"return -1;",
"}",
"VAR_0->has_b_frames++;",
"} else {",
"av_log(VAR_0, AV_LOG_WARNING, \"CrystalHD: Input buffer full\\n\");",
"VAR_4 = 0;",
"}",
"} else {",
"av_log(VAR_0, AV_LOG_INFO, \"CrystalHD: No more input VAR_1\\n\");",
"}",
"if (priv->skip_next_output) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"CrystalHD: Skipping next output.\\n\");",
"priv->skip_next_output = 0;",
"VAR_0->has_b_frames--;",
"return VAR_4;",
"}",
"ret = DtsGetDriverStatus(dev, &decoder_status);",
"if (ret != BC_STS_SUCCESS) {",
"av_log(VAR_0, AV_LOG_ERROR, \"CrystalHD: GetDriverStatus failed\\n\");",
"return -1;",
"}",
"if (priv->output_ready < 2) {",
"if (decoder_status.ReadyListCount != 0)\npriv->output_ready++;",
"usleep(BASE_WAIT);",
"av_log(VAR_0, AV_LOG_INFO, \"CrystalHD: Filling pipeline.\\n\");",
"return VAR_4;",
"} else if (decoder_status.ReadyListCount == 0) {",
"usleep(BASE_WAIT);",
"priv->decode_wait += WAIT_UNIT;",
"av_log(VAR_0, AV_LOG_INFO, \"CrystalHD: No frames ready. Returning\\n\");",
"return VAR_4;",
"}",
"do {",
"rec_ret = receive_frame(VAR_0, VAR_1, VAR_2, 0);",
"if (rec_ret == RET_OK && *VAR_2 == 0) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"Returning after first field.\\n\");",
"VAR_0->has_b_frames--;",
"} else if (rec_ret == RET_COPY_NEXT_FIELD) {",
"av_log(VAR_0, AV_LOG_VERBOSE, \"Trying to get second field.\\n\");",
"while (1) {",
"usleep(priv->decode_wait);",
"ret = DtsGetDriverStatus(dev, &decoder_status);",
"if (ret == BC_STS_SUCCESS &&\ndecoder_status.ReadyListCount > 0) {",
"rec_ret = receive_frame(VAR_0, VAR_1, VAR_2, 1);",
"if ((rec_ret == RET_OK && *VAR_2 > 0) ||\nrec_ret == RET_ERROR)\nbreak;",
"}",
"}",
"av_log(VAR_0, AV_LOG_VERBOSE, \"CrystalHD: Got second field.\\n\");",
"} else if (rec_ret == RET_SKIP_NEXT_COPY) {",
"av_log(VAR_0, AV_LOG_VERBOSE,\n\"Don't output on next FUNC_0 call.\\n\");",
"priv->skip_next_output = 1;",
"}",
"} while (rec_ret == RET_COPY_AGAIN);",
"usleep(priv->decode_wait);",
"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,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
41,
43,
45,
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
61
],
[
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
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
175
],
[
177,
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
201
],
[
203
],
[
205
],
[
207
],
[
209
],
[
213
],
[
215
],
[
217
],
[
233
],
[
235
],
[
237
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263,
265
],
[
267
],
[
269,
271,
273
],
[
275
],
[
277
],
[
279
],
[
281
],
[
289,
291
],
[
293
],
[
295
],
[
313
],
[
315
],
[
317
],
[
319
]
] |
25,087 | static int au_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
int ret;
ret= av_get_packet(s->pb, pkt, BLOCK_SIZE *
s->streams[0]->codec->channels *
av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3);
if (ret < 0)
return ret;
pkt->stream_index = 0;
/* note: we need to modify the packet size here to handle the last
packet */
pkt->size = ret;
return 0;
} | true | FFmpeg | 7effbee66cf457c62f795d9b9ed3a1110b364b89 | static int au_read_packet(AVFormatContext *s,
AVPacket *pkt)
{
int ret;
ret= av_get_packet(s->pb, pkt, BLOCK_SIZE *
s->streams[0]->codec->channels *
av_get_bits_per_sample(s->streams[0]->codec->codec_id) >> 3);
if (ret < 0)
return ret;
pkt->stream_index = 0;
pkt->size = ret;
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0,
AVPacket *VAR_1)
{
int VAR_2;
VAR_2= av_get_packet(VAR_0->pb, VAR_1, BLOCK_SIZE *
VAR_0->streams[0]->codec->channels *
av_get_bits_per_sample(VAR_0->streams[0]->codec->codec_id) >> 3);
if (VAR_2 < 0)
return VAR_2;
VAR_1->stream_index = 0;
VAR_1->size = VAR_2;
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0,\nAVPacket *VAR_1)\n{",
"int VAR_2;",
"VAR_2= av_get_packet(VAR_0->pb, VAR_1, BLOCK_SIZE *\nVAR_0->streams[0]->codec->channels *\nav_get_bits_per_sample(VAR_0->streams[0]->codec->codec_id) >> 3);",
"if (VAR_2 < 0)\nreturn VAR_2;",
"VAR_1->stream_index = 0;",
"VAR_1->size = VAR_2;",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
11,
13,
15
],
[
17,
19
],
[
22
],
[
30
],
[
32
],
[
34
]
] |
25,088 | static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag = track->enc->codec_tag;
if (track->mode == MODE_MP4 || track->mode == MODE_PSP) {
if (!codec_get_tag(ff_mp4_obj_type, track->enc->codec_id))
return 0;
if (track->enc->codec_id == CODEC_ID_H264) tag = MKTAG('a','v','c','1');
else if (track->enc->codec_id == CODEC_ID_AC3) tag = MKTAG('a','c','-','3');
else if (track->enc->codec_id == CODEC_ID_DIRAC) tag = MKTAG('d','r','a','c');
else if (track->enc->codec_id == CODEC_ID_MOV_TEXT) tag = MKTAG('t','x','3','g');
else if (track->enc->codec_type == CODEC_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
else if (track->enc->codec_type == CODEC_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
} else if (track->mode == MODE_IPOD) {
if (track->enc->codec_type == CODEC_TYPE_SUBTITLE &&
(tag == MKTAG('t','x','3','g') ||
tag == MKTAG('t','e','x','t')))
track->tag = tag; // keep original tag
else
tag = codec_get_tag(codec_ipod_tags, track->enc->codec_id);
if (!match_ext(s->filename, "m4a") && !match_ext(s->filename, "m4v"))
av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
"Quicktime/Ipod might not play the file\n");
} else if (track->mode & MODE_3GP) {
tag = codec_get_tag(codec_3gp_tags, track->enc->codec_id);
} else if (!tag || (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
(tag == MKTAG('d','v','c','p') ||
track->enc->codec_id == CODEC_ID_RAWVIDEO))) {
if (track->enc->codec_id == CODEC_ID_DVVIDEO) {
if (track->enc->height == 480) /* NTSC */
if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
else tag = MKTAG('d','v','c',' ');
else if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
else if (track->enc->pix_fmt == PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
else tag = MKTAG('d','v','p','p');
} else if (track->enc->codec_id == CODEC_ID_RAWVIDEO) {
tag = codec_get_tag(mov_pix_fmt_tags, track->enc->pix_fmt);
if (!tag) // restore tag
tag = track->enc->codec_tag;
} else {
if (track->enc->codec_type == CODEC_TYPE_VIDEO) {
tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id);
if (!tag) { // if no mac fcc found, try with Microsoft tags
tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id);
if (tag)
av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, "
"the file may be unplayable!\n");
}
} else if (track->enc->codec_type == CODEC_TYPE_AUDIO) {
tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id);
if (!tag) { // if no mac fcc found, try with Microsoft tags
int ms_tag = codec_get_tag(codec_wav_tags, track->enc->codec_id);
if (ms_tag) {
tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff));
av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, "
"the file may be unplayable!\n");
}
}
} else if (track->enc->codec_type == CODEC_TYPE_SUBTITLE) {
tag = codec_get_tag(ff_codec_movsubtitle_tags, track->enc->codec_id);
}
}
}
return tag;
}
| false | FFmpeg | 50d2d05d3436922e89fcdfdd87411669eab61c02 | static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag = track->enc->codec_tag;
if (track->mode == MODE_MP4 || track->mode == MODE_PSP) {
if (!codec_get_tag(ff_mp4_obj_type, track->enc->codec_id))
return 0;
if (track->enc->codec_id == CODEC_ID_H264) tag = MKTAG('a','v','c','1');
else if (track->enc->codec_id == CODEC_ID_AC3) tag = MKTAG('a','c','-','3');
else if (track->enc->codec_id == CODEC_ID_DIRAC) tag = MKTAG('d','r','a','c');
else if (track->enc->codec_id == CODEC_ID_MOV_TEXT) tag = MKTAG('t','x','3','g');
else if (track->enc->codec_type == CODEC_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
else if (track->enc->codec_type == CODEC_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
} else if (track->mode == MODE_IPOD) {
if (track->enc->codec_type == CODEC_TYPE_SUBTITLE &&
(tag == MKTAG('t','x','3','g') ||
tag == MKTAG('t','e','x','t')))
track->tag = tag;
else
tag = codec_get_tag(codec_ipod_tags, track->enc->codec_id);
if (!match_ext(s->filename, "m4a") && !match_ext(s->filename, "m4v"))
av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
"Quicktime/Ipod might not play the file\n");
} else if (track->mode & MODE_3GP) {
tag = codec_get_tag(codec_3gp_tags, track->enc->codec_id);
} else if (!tag || (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
(tag == MKTAG('d','v','c','p') ||
track->enc->codec_id == CODEC_ID_RAWVIDEO))) {
if (track->enc->codec_id == CODEC_ID_DVVIDEO) {
if (track->enc->height == 480)
if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n');
else tag = MKTAG('d','v','c',' ');
else if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p');
else if (track->enc->pix_fmt == PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p');
else tag = MKTAG('d','v','p','p');
} else if (track->enc->codec_id == CODEC_ID_RAWVIDEO) {
tag = codec_get_tag(mov_pix_fmt_tags, track->enc->pix_fmt);
if (!tag)
tag = track->enc->codec_tag;
} else {
if (track->enc->codec_type == CODEC_TYPE_VIDEO) {
tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id);
if (!tag) {
tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id);
if (tag)
av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, "
"the file may be unplayable!\n");
}
} else if (track->enc->codec_type == CODEC_TYPE_AUDIO) {
tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id);
if (!tag) {
int ms_tag = codec_get_tag(codec_wav_tags, track->enc->codec_id);
if (ms_tag) {
tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff));
av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, "
"the file may be unplayable!\n");
}
}
} else if (track->enc->codec_type == CODEC_TYPE_SUBTITLE) {
tag = codec_get_tag(ff_codec_movsubtitle_tags, track->enc->codec_id);
}
}
}
return tag;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, MOVTrack *VAR_1)
{
int VAR_2 = VAR_1->enc->codec_tag;
if (VAR_1->mode == MODE_MP4 || VAR_1->mode == MODE_PSP) {
if (!codec_get_tag(ff_mp4_obj_type, VAR_1->enc->codec_id))
return 0;
if (VAR_1->enc->codec_id == CODEC_ID_H264) VAR_2 = MKTAG('a','v','c','1');
else if (VAR_1->enc->codec_id == CODEC_ID_AC3) VAR_2 = MKTAG('a','c','-','3');
else if (VAR_1->enc->codec_id == CODEC_ID_DIRAC) VAR_2 = MKTAG('d','r','a','c');
else if (VAR_1->enc->codec_id == CODEC_ID_MOV_TEXT) VAR_2 = MKTAG('t','x','3','g');
else if (VAR_1->enc->codec_type == CODEC_TYPE_VIDEO) VAR_2 = MKTAG('m','p','4','v');
else if (VAR_1->enc->codec_type == CODEC_TYPE_AUDIO) VAR_2 = MKTAG('m','p','4','a');
} else if (VAR_1->mode == MODE_IPOD) {
if (VAR_1->enc->codec_type == CODEC_TYPE_SUBTITLE &&
(VAR_2 == MKTAG('t','x','3','g') ||
VAR_2 == MKTAG('t','e','x','t')))
VAR_1->VAR_2 = VAR_2;
else
VAR_2 = codec_get_tag(codec_ipod_tags, VAR_1->enc->codec_id);
if (!match_ext(VAR_0->filename, "m4a") && !match_ext(VAR_0->filename, "m4v"))
av_log(VAR_0, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
"Quicktime/Ipod might not play the file\n");
} else if (VAR_1->mode & MODE_3GP) {
VAR_2 = codec_get_tag(codec_3gp_tags, VAR_1->enc->codec_id);
} else if (!VAR_2 || (VAR_1->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&
(VAR_2 == MKTAG('d','v','c','p') ||
VAR_1->enc->codec_id == CODEC_ID_RAWVIDEO))) {
if (VAR_1->enc->codec_id == CODEC_ID_DVVIDEO) {
if (VAR_1->enc->height == 480)
if (VAR_1->enc->pix_fmt == PIX_FMT_YUV422P) VAR_2 = MKTAG('d','v','5','n');
else VAR_2 = MKTAG('d','v','c',' ');
else if (VAR_1->enc->pix_fmt == PIX_FMT_YUV422P) VAR_2 = MKTAG('d','v','5','p');
else if (VAR_1->enc->pix_fmt == PIX_FMT_YUV420P) VAR_2 = MKTAG('d','v','c','p');
else VAR_2 = MKTAG('d','v','p','p');
} else if (VAR_1->enc->codec_id == CODEC_ID_RAWVIDEO) {
VAR_2 = codec_get_tag(mov_pix_fmt_tags, VAR_1->enc->pix_fmt);
if (!VAR_2)
VAR_2 = VAR_1->enc->codec_tag;
} else {
if (VAR_1->enc->codec_type == CODEC_TYPE_VIDEO) {
VAR_2 = codec_get_tag(codec_movvideo_tags, VAR_1->enc->codec_id);
if (!VAR_2) {
VAR_2 = codec_get_tag(codec_bmp_tags, VAR_1->enc->codec_id);
if (VAR_2)
av_log(VAR_0, AV_LOG_INFO, "Warning, using MS style video codec VAR_2, "
"the file may be unplayable!\n");
}
} else if (VAR_1->enc->codec_type == CODEC_TYPE_AUDIO) {
VAR_2 = codec_get_tag(codec_movaudio_tags, VAR_1->enc->codec_id);
if (!VAR_2) {
int VAR_3 = codec_get_tag(codec_wav_tags, VAR_1->enc->codec_id);
if (VAR_3) {
VAR_2 = MKTAG('m', 'VAR_0', ((VAR_3 >> 8) & 0xff), (VAR_3 & 0xff));
av_log(VAR_0, AV_LOG_INFO, "Warning, using MS style audio codec VAR_2, "
"the file may be unplayable!\n");
}
}
} else if (VAR_1->enc->codec_type == CODEC_TYPE_SUBTITLE) {
VAR_2 = codec_get_tag(ff_codec_movsubtitle_tags, VAR_1->enc->codec_id);
}
}
}
return VAR_2;
}
| [
"static int FUNC_0(AVFormatContext *VAR_0, MOVTrack *VAR_1)\n{",
"int VAR_2 = VAR_1->enc->codec_tag;",
"if (VAR_1->mode == MODE_MP4 || VAR_1->mode == MODE_PSP) {",
"if (!codec_get_tag(ff_mp4_obj_type, VAR_1->enc->codec_id))\nreturn 0;",
"if (VAR_1->enc->codec_id == CODEC_ID_H264) VAR_2 = MKTAG('a','v','c','1');",
"else if (VAR_1->enc->codec_id == CODEC_ID_AC3) VAR_2 = MKTAG('a','c','-','3');",
"else if (VAR_1->enc->codec_id == CODEC_ID_DIRAC) VAR_2 = MKTAG('d','r','a','c');",
"else if (VAR_1->enc->codec_id == CODEC_ID_MOV_TEXT) VAR_2 = MKTAG('t','x','3','g');",
"else if (VAR_1->enc->codec_type == CODEC_TYPE_VIDEO) VAR_2 = MKTAG('m','p','4','v');",
"else if (VAR_1->enc->codec_type == CODEC_TYPE_AUDIO) VAR_2 = MKTAG('m','p','4','a');",
"} else if (VAR_1->mode == MODE_IPOD) {",
"if (VAR_1->enc->codec_type == CODEC_TYPE_SUBTITLE &&\n(VAR_2 == MKTAG('t','x','3','g') ||\nVAR_2 == MKTAG('t','e','x','t')))\nVAR_1->VAR_2 = VAR_2;",
"else\nVAR_2 = codec_get_tag(codec_ipod_tags, VAR_1->enc->codec_id);",
"if (!match_ext(VAR_0->filename, \"m4a\") && !match_ext(VAR_0->filename, \"m4v\"))\nav_log(VAR_0, AV_LOG_WARNING, \"Warning, extension is not .m4a nor .m4v \"\n\"Quicktime/Ipod might not play the file\\n\");",
"} else if (VAR_1->mode & MODE_3GP) {",
"VAR_2 = codec_get_tag(codec_3gp_tags, VAR_1->enc->codec_id);",
"} else if (!VAR_2 || (VAR_1->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL &&",
"(VAR_2 == MKTAG('d','v','c','p') ||\nVAR_1->enc->codec_id == CODEC_ID_RAWVIDEO))) {",
"if (VAR_1->enc->codec_id == CODEC_ID_DVVIDEO) {",
"if (VAR_1->enc->height == 480)\nif (VAR_1->enc->pix_fmt == PIX_FMT_YUV422P) VAR_2 = MKTAG('d','v','5','n');",
"else VAR_2 = MKTAG('d','v','c',' ');",
"else if (VAR_1->enc->pix_fmt == PIX_FMT_YUV422P) VAR_2 = MKTAG('d','v','5','p');",
"else if (VAR_1->enc->pix_fmt == PIX_FMT_YUV420P) VAR_2 = MKTAG('d','v','c','p');",
"else VAR_2 = MKTAG('d','v','p','p');",
"} else if (VAR_1->enc->codec_id == CODEC_ID_RAWVIDEO) {",
"VAR_2 = codec_get_tag(mov_pix_fmt_tags, VAR_1->enc->pix_fmt);",
"if (!VAR_2)\nVAR_2 = VAR_1->enc->codec_tag;",
"} else {",
"if (VAR_1->enc->codec_type == CODEC_TYPE_VIDEO) {",
"VAR_2 = codec_get_tag(codec_movvideo_tags, VAR_1->enc->codec_id);",
"if (!VAR_2) {",
"VAR_2 = codec_get_tag(codec_bmp_tags, VAR_1->enc->codec_id);",
"if (VAR_2)\nav_log(VAR_0, AV_LOG_INFO, \"Warning, using MS style video codec VAR_2, \"\n\"the file may be unplayable!\\n\");",
"}",
"} else if (VAR_1->enc->codec_type == CODEC_TYPE_AUDIO) {",
"VAR_2 = codec_get_tag(codec_movaudio_tags, VAR_1->enc->codec_id);",
"if (!VAR_2) {",
"int VAR_3 = codec_get_tag(codec_wav_tags, VAR_1->enc->codec_id);",
"if (VAR_3) {",
"VAR_2 = MKTAG('m', 'VAR_0', ((VAR_3 >> 8) & 0xff), (VAR_3 & 0xff));",
"av_log(VAR_0, AV_LOG_INFO, \"Warning, using MS style audio codec VAR_2, \"\n\"the file may be unplayable!\\n\");",
"}",
"}",
"} else if (VAR_1->enc->codec_type == CODEC_TYPE_SUBTITLE) {",
"VAR_2 = codec_get_tag(ff_codec_movsubtitle_tags, VAR_1->enc->codec_id);",
"}",
"}",
"}",
"return 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,
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,
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
],
[
121
],
[
123
],
[
125
],
[
127
]
] |
25,092 | static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
{
NvencContext *ctx = avctx->priv_data;
if (avctx->bit_rate > 0) {
ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate;
} else if (ctx->encode_config.rcParams.averageBitRate > 0) {
ctx->encode_config.rcParams.maxBitRate = ctx->encode_config.rcParams.averageBitRate;
}
if (avctx->rc_max_rate > 0)
ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
if (ctx->rc < 0) {
if (ctx->flags & NVENC_ONE_PASS)
ctx->twopass = 0;
if (ctx->flags & NVENC_TWO_PASSES)
ctx->twopass = 1;
if (ctx->twopass < 0)
ctx->twopass = (ctx->flags & NVENC_LOWLATENCY) != 0;
if (ctx->cbr) {
if (ctx->twopass) {
ctx->rc = NV_ENC_PARAMS_RC_2_PASS_QUALITY;
} else {
ctx->rc = NV_ENC_PARAMS_RC_CBR;
}
} else if (avctx->global_quality > 0) {
ctx->rc = NV_ENC_PARAMS_RC_CONSTQP;
} else if (ctx->twopass) {
ctx->rc = NV_ENC_PARAMS_RC_2_PASS_VBR;
} else if (avctx->qmin >= 0 && avctx->qmax >= 0) {
ctx->rc = NV_ENC_PARAMS_RC_VBR_MINQP;
}
}
if (ctx->flags & NVENC_LOSSLESS) {
set_lossless(avctx);
} else if (ctx->rc >= 0) {
nvenc_override_rate_control(avctx);
} else {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR;
set_vbr(avctx);
}
if (avctx->rc_buffer_size > 0) {
ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size;
} else if (ctx->encode_config.rcParams.averageBitRate > 0) {
ctx->encode_config.rcParams.vbvBufferSize = 2 * ctx->encode_config.rcParams.averageBitRate;
}
if (ctx->aq) {
ctx->encode_config.rcParams.enableAQ = 1;
ctx->encode_config.rcParams.aqStrength = ctx->aq_strength;
av_log(avctx, AV_LOG_VERBOSE, "AQ enabled.\n");
}
if (ctx->temporal_aq) {
ctx->encode_config.rcParams.enableTemporalAQ = 1;
av_log(avctx, AV_LOG_VERBOSE, "Temporal AQ enabled.\n");
}
if (ctx->rc_lookahead) {
int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) -
ctx->encode_config.frameIntervalP - 4;
if (lkd_bound < 0) {
av_log(avctx, AV_LOG_WARNING,
"Lookahead not enabled. Increase buffer delay (-delay).\n");
} else {
ctx->encode_config.rcParams.enableLookahead = 1;
ctx->encode_config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound);
ctx->encode_config.rcParams.disableIadapt = ctx->no_scenecut;
ctx->encode_config.rcParams.disableBadapt = !ctx->b_adapt;
av_log(avctx, AV_LOG_VERBOSE,
"Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n",
ctx->encode_config.rcParams.lookaheadDepth,
ctx->encode_config.rcParams.disableIadapt ? "disabled" : "enabled",
ctx->encode_config.rcParams.disableBadapt ? "disabled" : "enabled");
}
}
if (ctx->strict_gop) {
ctx->encode_config.rcParams.strictGOPTarget = 1;
av_log(avctx, AV_LOG_VERBOSE, "Strict GOP target enabled.\n");
}
if (ctx->nonref_p)
ctx->encode_config.rcParams.enableNonRefP = 1;
if (ctx->zerolatency)
ctx->encode_config.rcParams.zeroReorderDelay = 1;
if (ctx->quality)
ctx->encode_config.rcParams.targetQuality = ctx->quality;
}
| false | FFmpeg | 67db4ff3b66e96a20ddf1c264d07e146334ae88e | static av_cold void nvenc_setup_rate_control(AVCodecContext *avctx)
{
NvencContext *ctx = avctx->priv_data;
if (avctx->bit_rate > 0) {
ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate;
} else if (ctx->encode_config.rcParams.averageBitRate > 0) {
ctx->encode_config.rcParams.maxBitRate = ctx->encode_config.rcParams.averageBitRate;
}
if (avctx->rc_max_rate > 0)
ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
if (ctx->rc < 0) {
if (ctx->flags & NVENC_ONE_PASS)
ctx->twopass = 0;
if (ctx->flags & NVENC_TWO_PASSES)
ctx->twopass = 1;
if (ctx->twopass < 0)
ctx->twopass = (ctx->flags & NVENC_LOWLATENCY) != 0;
if (ctx->cbr) {
if (ctx->twopass) {
ctx->rc = NV_ENC_PARAMS_RC_2_PASS_QUALITY;
} else {
ctx->rc = NV_ENC_PARAMS_RC_CBR;
}
} else if (avctx->global_quality > 0) {
ctx->rc = NV_ENC_PARAMS_RC_CONSTQP;
} else if (ctx->twopass) {
ctx->rc = NV_ENC_PARAMS_RC_2_PASS_VBR;
} else if (avctx->qmin >= 0 && avctx->qmax >= 0) {
ctx->rc = NV_ENC_PARAMS_RC_VBR_MINQP;
}
}
if (ctx->flags & NVENC_LOSSLESS) {
set_lossless(avctx);
} else if (ctx->rc >= 0) {
nvenc_override_rate_control(avctx);
} else {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR;
set_vbr(avctx);
}
if (avctx->rc_buffer_size > 0) {
ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size;
} else if (ctx->encode_config.rcParams.averageBitRate > 0) {
ctx->encode_config.rcParams.vbvBufferSize = 2 * ctx->encode_config.rcParams.averageBitRate;
}
if (ctx->aq) {
ctx->encode_config.rcParams.enableAQ = 1;
ctx->encode_config.rcParams.aqStrength = ctx->aq_strength;
av_log(avctx, AV_LOG_VERBOSE, "AQ enabled.\n");
}
if (ctx->temporal_aq) {
ctx->encode_config.rcParams.enableTemporalAQ = 1;
av_log(avctx, AV_LOG_VERBOSE, "Temporal AQ enabled.\n");
}
if (ctx->rc_lookahead) {
int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) -
ctx->encode_config.frameIntervalP - 4;
if (lkd_bound < 0) {
av_log(avctx, AV_LOG_WARNING,
"Lookahead not enabled. Increase buffer delay (-delay).\n");
} else {
ctx->encode_config.rcParams.enableLookahead = 1;
ctx->encode_config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound);
ctx->encode_config.rcParams.disableIadapt = ctx->no_scenecut;
ctx->encode_config.rcParams.disableBadapt = !ctx->b_adapt;
av_log(avctx, AV_LOG_VERBOSE,
"Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n",
ctx->encode_config.rcParams.lookaheadDepth,
ctx->encode_config.rcParams.disableIadapt ? "disabled" : "enabled",
ctx->encode_config.rcParams.disableBadapt ? "disabled" : "enabled");
}
}
if (ctx->strict_gop) {
ctx->encode_config.rcParams.strictGOPTarget = 1;
av_log(avctx, AV_LOG_VERBOSE, "Strict GOP target enabled.\n");
}
if (ctx->nonref_p)
ctx->encode_config.rcParams.enableNonRefP = 1;
if (ctx->zerolatency)
ctx->encode_config.rcParams.zeroReorderDelay = 1;
if (ctx->quality)
ctx->encode_config.rcParams.targetQuality = ctx->quality;
}
| {
"code": [],
"line_no": []
} | static av_cold void FUNC_0(AVCodecContext *avctx)
{
NvencContext *ctx = avctx->priv_data;
if (avctx->bit_rate > 0) {
ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate;
} else if (ctx->encode_config.rcParams.averageBitRate > 0) {
ctx->encode_config.rcParams.maxBitRate = ctx->encode_config.rcParams.averageBitRate;
}
if (avctx->rc_max_rate > 0)
ctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;
if (ctx->rc < 0) {
if (ctx->flags & NVENC_ONE_PASS)
ctx->twopass = 0;
if (ctx->flags & NVENC_TWO_PASSES)
ctx->twopass = 1;
if (ctx->twopass < 0)
ctx->twopass = (ctx->flags & NVENC_LOWLATENCY) != 0;
if (ctx->cbr) {
if (ctx->twopass) {
ctx->rc = NV_ENC_PARAMS_RC_2_PASS_QUALITY;
} else {
ctx->rc = NV_ENC_PARAMS_RC_CBR;
}
} else if (avctx->global_quality > 0) {
ctx->rc = NV_ENC_PARAMS_RC_CONSTQP;
} else if (ctx->twopass) {
ctx->rc = NV_ENC_PARAMS_RC_2_PASS_VBR;
} else if (avctx->qmin >= 0 && avctx->qmax >= 0) {
ctx->rc = NV_ENC_PARAMS_RC_VBR_MINQP;
}
}
if (ctx->flags & NVENC_LOSSLESS) {
set_lossless(avctx);
} else if (ctx->rc >= 0) {
nvenc_override_rate_control(avctx);
} else {
ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR;
set_vbr(avctx);
}
if (avctx->rc_buffer_size > 0) {
ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size;
} else if (ctx->encode_config.rcParams.averageBitRate > 0) {
ctx->encode_config.rcParams.vbvBufferSize = 2 * ctx->encode_config.rcParams.averageBitRate;
}
if (ctx->aq) {
ctx->encode_config.rcParams.enableAQ = 1;
ctx->encode_config.rcParams.aqStrength = ctx->aq_strength;
av_log(avctx, AV_LOG_VERBOSE, "AQ enabled.\n");
}
if (ctx->temporal_aq) {
ctx->encode_config.rcParams.enableTemporalAQ = 1;
av_log(avctx, AV_LOG_VERBOSE, "Temporal AQ enabled.\n");
}
if (ctx->rc_lookahead) {
int VAR_0 = FFMIN(ctx->nb_surfaces, ctx->async_depth) -
ctx->encode_config.frameIntervalP - 4;
if (VAR_0 < 0) {
av_log(avctx, AV_LOG_WARNING,
"Lookahead not enabled. Increase buffer delay (-delay).\n");
} else {
ctx->encode_config.rcParams.enableLookahead = 1;
ctx->encode_config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, VAR_0);
ctx->encode_config.rcParams.disableIadapt = ctx->no_scenecut;
ctx->encode_config.rcParams.disableBadapt = !ctx->b_adapt;
av_log(avctx, AV_LOG_VERBOSE,
"Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n",
ctx->encode_config.rcParams.lookaheadDepth,
ctx->encode_config.rcParams.disableIadapt ? "disabled" : "enabled",
ctx->encode_config.rcParams.disableBadapt ? "disabled" : "enabled");
}
}
if (ctx->strict_gop) {
ctx->encode_config.rcParams.strictGOPTarget = 1;
av_log(avctx, AV_LOG_VERBOSE, "Strict GOP target enabled.\n");
}
if (ctx->nonref_p)
ctx->encode_config.rcParams.enableNonRefP = 1;
if (ctx->zerolatency)
ctx->encode_config.rcParams.zeroReorderDelay = 1;
if (ctx->quality)
ctx->encode_config.rcParams.targetQuality = ctx->quality;
}
| [
"static av_cold void FUNC_0(AVCodecContext *avctx)\n{",
"NvencContext *ctx = avctx->priv_data;",
"if (avctx->bit_rate > 0) {",
"ctx->encode_config.rcParams.averageBitRate = avctx->bit_rate;",
"} else if (ctx->encode_config.rcParams.averageBitRate > 0) {",
"ctx->encode_config.rcParams.maxBitRate = ctx->encode_config.rcParams.averageBitRate;",
"}",
"if (avctx->rc_max_rate > 0)\nctx->encode_config.rcParams.maxBitRate = avctx->rc_max_rate;",
"if (ctx->rc < 0) {",
"if (ctx->flags & NVENC_ONE_PASS)\nctx->twopass = 0;",
"if (ctx->flags & NVENC_TWO_PASSES)\nctx->twopass = 1;",
"if (ctx->twopass < 0)\nctx->twopass = (ctx->flags & NVENC_LOWLATENCY) != 0;",
"if (ctx->cbr) {",
"if (ctx->twopass) {",
"ctx->rc = NV_ENC_PARAMS_RC_2_PASS_QUALITY;",
"} else {",
"ctx->rc = NV_ENC_PARAMS_RC_CBR;",
"}",
"} else if (avctx->global_quality > 0) {",
"ctx->rc = NV_ENC_PARAMS_RC_CONSTQP;",
"} else if (ctx->twopass) {",
"ctx->rc = NV_ENC_PARAMS_RC_2_PASS_VBR;",
"} else if (avctx->qmin >= 0 && avctx->qmax >= 0) {",
"ctx->rc = NV_ENC_PARAMS_RC_VBR_MINQP;",
"}",
"}",
"if (ctx->flags & NVENC_LOSSLESS) {",
"set_lossless(avctx);",
"} else if (ctx->rc >= 0) {",
"nvenc_override_rate_control(avctx);",
"} else {",
"ctx->encode_config.rcParams.rateControlMode = NV_ENC_PARAMS_RC_VBR;",
"set_vbr(avctx);",
"}",
"if (avctx->rc_buffer_size > 0) {",
"ctx->encode_config.rcParams.vbvBufferSize = avctx->rc_buffer_size;",
"} else if (ctx->encode_config.rcParams.averageBitRate > 0) {",
"ctx->encode_config.rcParams.vbvBufferSize = 2 * ctx->encode_config.rcParams.averageBitRate;",
"}",
"if (ctx->aq) {",
"ctx->encode_config.rcParams.enableAQ = 1;",
"ctx->encode_config.rcParams.aqStrength = ctx->aq_strength;",
"av_log(avctx, AV_LOG_VERBOSE, \"AQ enabled.\\n\");",
"}",
"if (ctx->temporal_aq) {",
"ctx->encode_config.rcParams.enableTemporalAQ = 1;",
"av_log(avctx, AV_LOG_VERBOSE, \"Temporal AQ enabled.\\n\");",
"}",
"if (ctx->rc_lookahead) {",
"int VAR_0 = FFMIN(ctx->nb_surfaces, ctx->async_depth) -\nctx->encode_config.frameIntervalP - 4;",
"if (VAR_0 < 0) {",
"av_log(avctx, AV_LOG_WARNING,\n\"Lookahead not enabled. Increase buffer delay (-delay).\\n\");",
"} else {",
"ctx->encode_config.rcParams.enableLookahead = 1;",
"ctx->encode_config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, VAR_0);",
"ctx->encode_config.rcParams.disableIadapt = ctx->no_scenecut;",
"ctx->encode_config.rcParams.disableBadapt = !ctx->b_adapt;",
"av_log(avctx, AV_LOG_VERBOSE,\n\"Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\\n\",\nctx->encode_config.rcParams.lookaheadDepth,\nctx->encode_config.rcParams.disableIadapt ? \"disabled\" : \"enabled\",\nctx->encode_config.rcParams.disableBadapt ? \"disabled\" : \"enabled\");",
"}",
"}",
"if (ctx->strict_gop) {",
"ctx->encode_config.rcParams.strictGOPTarget = 1;",
"av_log(avctx, AV_LOG_VERBOSE, \"Strict GOP target enabled.\\n\");",
"}",
"if (ctx->nonref_p)\nctx->encode_config.rcParams.enableNonRefP = 1;",
"if (ctx->zerolatency)\nctx->encode_config.rcParams.zeroReorderDelay = 1;",
"if (ctx->quality)\nctx->encode_config.rcParams.targetQuality = ctx->quality;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
33,
35
],
[
39,
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
119
],
[
121
],
[
123
],
[
127
],
[
129,
131
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151,
153,
155,
157,
159
],
[
161
],
[
163
],
[
167
],
[
169
],
[
171
],
[
173
],
[
177,
179
],
[
183,
185
],
[
189,
191
],
[
193
]
] |
25,093 | int ff_rv34_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
AVFrame *pict = data;
SliceInfo si;
int i;
int slice_count;
uint8_t *slices_hdr = NULL;
int last = 0;
/* no supplementary picture */
if (buf_size == 0) {
/* special case for last picture */
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
if(!avctx->slice_count){
slice_count = (*buf++) + 1;
slices_hdr = buf + 4;
buf += 8 * slice_count;
}else
slice_count = avctx->slice_count;
for(i=0; i<slice_count; i++){
int offset= get_slice_offset(avctx, slices_hdr, i);
int size;
if(i+1 == slice_count)
size= buf_size - offset;
else
size= get_slice_offset(avctx, slices_hdr, i+1) - offset;
r->si.end = s->mb_width * s->mb_height;
if(i+1 < slice_count){
init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8);
if(r->parse_slice_header(r, &r->s.gb, &si) < 0){
if(i+2 < slice_count)
size = get_slice_offset(avctx, slices_hdr, i+2) - offset;
else
size = buf_size - offset;
}else
r->si.end = si.start;
}
last = rv34_decode_slice(r, r->si.end, buf + offset, size);
s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;
if(last)
break;
}
if(last){
if(r->loop_filter)
r->loop_filter(r);
ff_er_frame_end(s);
MPV_frame_end(s);
if (s->pict_type == FF_B_TYPE || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr;
} else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr;
}
if(s->last_picture_ptr || s->low_delay){
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
s->current_picture_ptr= NULL; //so we can detect if frame_end wasnt called (find some nicer solution...)
}
return buf_size;
}
| false | FFmpeg | de8cac167d52557aa0aced5c013c98f44ade98cf | int ff_rv34_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
AVFrame *pict = data;
SliceInfo si;
int i;
int slice_count;
uint8_t *slices_hdr = NULL;
int last = 0;
if (buf_size == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*data_size = sizeof(AVFrame);
}
return 0;
}
if(!avctx->slice_count){
slice_count = (*buf++) + 1;
slices_hdr = buf + 4;
buf += 8 * slice_count;
}else
slice_count = avctx->slice_count;
for(i=0; i<slice_count; i++){
int offset= get_slice_offset(avctx, slices_hdr, i);
int size;
if(i+1 == slice_count)
size= buf_size - offset;
else
size= get_slice_offset(avctx, slices_hdr, i+1) - offset;
r->si.end = s->mb_width * s->mb_height;
if(i+1 < slice_count){
init_get_bits(&s->gb, buf+get_slice_offset(avctx, slices_hdr, i+1), (buf_size-get_slice_offset(avctx, slices_hdr, i+1))*8);
if(r->parse_slice_header(r, &r->s.gb, &si) < 0){
if(i+2 < slice_count)
size = get_slice_offset(avctx, slices_hdr, i+2) - offset;
else
size = buf_size - offset;
}else
r->si.end = si.start;
}
last = rv34_decode_slice(r, r->si.end, buf + offset, size);
s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;
if(last)
break;
}
if(last){
if(r->loop_filter)
r->loop_filter(r);
ff_er_frame_end(s);
MPV_frame_end(s);
if (s->pict_type == FF_B_TYPE || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr;
} else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr;
}
if(s->last_picture_ptr || s->low_delay){
*data_size = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
s->current_picture_ptr= NULL;
}
return buf_size;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
RV34DecContext *r = VAR_0->priv_data;
MpegEncContext *s = &r->s;
AVFrame *pict = VAR_1;
SliceInfo si;
int VAR_5;
int VAR_6;
uint8_t *slices_hdr = NULL;
int VAR_7 = 0;
if (VAR_4 == 0) {
if (s->low_delay==0 && s->next_picture_ptr) {
*pict= *(AVFrame*)s->next_picture_ptr;
s->next_picture_ptr= NULL;
*VAR_2 = sizeof(AVFrame);
}
return 0;
}
if(!VAR_0->VAR_6){
VAR_6 = (*VAR_3++) + 1;
slices_hdr = VAR_3 + 4;
VAR_3 += 8 * VAR_6;
}else
VAR_6 = VAR_0->VAR_6;
for(VAR_5=0; VAR_5<VAR_6; VAR_5++){
int VAR_8= get_slice_offset(VAR_0, slices_hdr, VAR_5);
int VAR_9;
if(VAR_5+1 == VAR_6)
VAR_9= VAR_4 - VAR_8;
else
VAR_9= get_slice_offset(VAR_0, slices_hdr, VAR_5+1) - VAR_8;
r->si.end = s->mb_width * s->mb_height;
if(VAR_5+1 < VAR_6){
init_get_bits(&s->gb, VAR_3+get_slice_offset(VAR_0, slices_hdr, VAR_5+1), (VAR_4-get_slice_offset(VAR_0, slices_hdr, VAR_5+1))*8);
if(r->parse_slice_header(r, &r->s.gb, &si) < 0){
if(VAR_5+2 < VAR_6)
VAR_9 = get_slice_offset(VAR_0, slices_hdr, VAR_5+2) - VAR_8;
else
VAR_9 = VAR_4 - VAR_8;
}else
r->si.end = si.start;
}
VAR_7 = rv34_decode_slice(r, r->si.end, VAR_3 + VAR_8, VAR_9);
s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;
if(VAR_7)
break;
}
if(VAR_7){
if(r->loop_filter)
r->loop_filter(r);
ff_er_frame_end(s);
MPV_frame_end(s);
if (s->pict_type == FF_B_TYPE || s->low_delay) {
*pict= *(AVFrame*)s->current_picture_ptr;
} else if (s->last_picture_ptr != NULL) {
*pict= *(AVFrame*)s->last_picture_ptr;
}
if(s->last_picture_ptr || s->low_delay){
*VAR_2 = sizeof(AVFrame);
ff_print_debug_info(s, pict);
}
s->current_picture_ptr= NULL;
}
return VAR_4;
}
| [
"int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"RV34DecContext *r = VAR_0->priv_data;",
"MpegEncContext *s = &r->s;",
"AVFrame *pict = VAR_1;",
"SliceInfo si;",
"int VAR_5;",
"int VAR_6;",
"uint8_t *slices_hdr = NULL;",
"int VAR_7 = 0;",
"if (VAR_4 == 0) {",
"if (s->low_delay==0 && s->next_picture_ptr) {",
"*pict= *(AVFrame*)s->next_picture_ptr;",
"s->next_picture_ptr= NULL;",
"*VAR_2 = sizeof(AVFrame);",
"}",
"return 0;",
"}",
"if(!VAR_0->VAR_6){",
"VAR_6 = (*VAR_3++) + 1;",
"slices_hdr = VAR_3 + 4;",
"VAR_3 += 8 * VAR_6;",
"}else",
"VAR_6 = VAR_0->VAR_6;",
"for(VAR_5=0; VAR_5<VAR_6; VAR_5++){",
"int VAR_8= get_slice_offset(VAR_0, slices_hdr, VAR_5);",
"int VAR_9;",
"if(VAR_5+1 == VAR_6)\nVAR_9= VAR_4 - VAR_8;",
"else\nVAR_9= get_slice_offset(VAR_0, slices_hdr, VAR_5+1) - VAR_8;",
"r->si.end = s->mb_width * s->mb_height;",
"if(VAR_5+1 < VAR_6){",
"init_get_bits(&s->gb, VAR_3+get_slice_offset(VAR_0, slices_hdr, VAR_5+1), (VAR_4-get_slice_offset(VAR_0, slices_hdr, VAR_5+1))*8);",
"if(r->parse_slice_header(r, &r->s.gb, &si) < 0){",
"if(VAR_5+2 < VAR_6)\nVAR_9 = get_slice_offset(VAR_0, slices_hdr, VAR_5+2) - VAR_8;",
"else\nVAR_9 = VAR_4 - VAR_8;",
"}else",
"r->si.end = si.start;",
"}",
"VAR_7 = rv34_decode_slice(r, r->si.end, VAR_3 + VAR_8, VAR_9);",
"s->mb_num_left = r->s.mb_x + r->s.mb_y*r->s.mb_width - r->si.start;",
"if(VAR_7)\nbreak;",
"}",
"if(VAR_7){",
"if(r->loop_filter)\nr->loop_filter(r);",
"ff_er_frame_end(s);",
"MPV_frame_end(s);",
"if (s->pict_type == FF_B_TYPE || s->low_delay) {",
"*pict= *(AVFrame*)s->current_picture_ptr;",
"} else if (s->last_picture_ptr != NULL) {",
"*pict= *(AVFrame*)s->last_picture_ptr;",
"}",
"if(s->last_picture_ptr || s->low_delay){",
"*VAR_2 = sizeof(AVFrame);",
"ff_print_debug_info(s, pict);",
"}",
"s->current_picture_ptr= 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
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
29
],
[
33
],
[
35
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71,
73
],
[
75,
77
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89,
91
],
[
93,
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107,
109
],
[
111
],
[
115
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
]
] |
25,094 | static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, int imgh)
{
int x, y, Y, U, V, A;
uint8_t *lum, *cb, *cr;
int dstx, dsty, dstw, dsth;
const AVPicture *src = &rect->pict;
dstw = av_clip(rect->w, 0, imgw);
dsth = av_clip(rect->h, 0, imgh);
dstx = av_clip(rect->x, 0, imgw - dstw);
dsty = av_clip(rect->y, 0, imgh - dsth);
lum = dst->data[0] + dstx + dsty * dst->linesize[0];
cb = dst->data[1] + dstx/2 + (dsty >> 1) * dst->linesize[1];
cr = dst->data[2] + dstx/2 + (dsty >> 1) * dst->linesize[2];
for (y = 0; y<dsth; y++) {
for (x = 0; x<dstw; x++) {
Y = src->data[0][x + y*src->linesize[0]];
A = src->data[3][x + y*src->linesize[3]];
lum[0] = ALPHA_BLEND(A, lum[0], Y, 0);
lum++;
}
lum += dst->linesize[0] - dstw;
}
for (y = 0; y<dsth/2; y++) {
for (x = 0; x<dstw/2; x++) {
U = src->data[1][x + y*src->linesize[1]];
V = src->data[2][x + y*src->linesize[2]];
A = src->data[3][2*x + 2*y *src->linesize[3]]
+ src->data[3][2*x + 1 + 2*y *src->linesize[3]]
+ src->data[3][2*x + 1 + (2*y+1)*src->linesize[3]]
+ src->data[3][2*x + (2*y+1)*src->linesize[3]];
cb[0] = ALPHA_BLEND(A>>2, cb[0], U, 0);
cr[0] = ALPHA_BLEND(A>>2, cr[0], V, 0);
cb++;
cr++;
}
cb += dst->linesize[1] - dstw/2;
cr += dst->linesize[2] - dstw/2;
}
}
| false | FFmpeg | 03037a4aad8b92c00ef2f115605ad20fc4410fe5 | static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, int imgh)
{
int x, y, Y, U, V, A;
uint8_t *lum, *cb, *cr;
int dstx, dsty, dstw, dsth;
const AVPicture *src = &rect->pict;
dstw = av_clip(rect->w, 0, imgw);
dsth = av_clip(rect->h, 0, imgh);
dstx = av_clip(rect->x, 0, imgw - dstw);
dsty = av_clip(rect->y, 0, imgh - dsth);
lum = dst->data[0] + dstx + dsty * dst->linesize[0];
cb = dst->data[1] + dstx/2 + (dsty >> 1) * dst->linesize[1];
cr = dst->data[2] + dstx/2 + (dsty >> 1) * dst->linesize[2];
for (y = 0; y<dsth; y++) {
for (x = 0; x<dstw; x++) {
Y = src->data[0][x + y*src->linesize[0]];
A = src->data[3][x + y*src->linesize[3]];
lum[0] = ALPHA_BLEND(A, lum[0], Y, 0);
lum++;
}
lum += dst->linesize[0] - dstw;
}
for (y = 0; y<dsth/2; y++) {
for (x = 0; x<dstw/2; x++) {
U = src->data[1][x + y*src->linesize[1]];
V = src->data[2][x + y*src->linesize[2]];
A = src->data[3][2*x + 2*y *src->linesize[3]]
+ src->data[3][2*x + 1 + 2*y *src->linesize[3]]
+ src->data[3][2*x + 1 + (2*y+1)*src->linesize[3]]
+ src->data[3][2*x + (2*y+1)*src->linesize[3]];
cb[0] = ALPHA_BLEND(A>>2, cb[0], U, 0);
cr[0] = ALPHA_BLEND(A>>2, cr[0], V, 0);
cb++;
cr++;
}
cb += dst->linesize[1] - dstw/2;
cr += dst->linesize[2] - dstw/2;
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(AVPicture *VAR_0, const AVSubtitleRect *VAR_1, int VAR_2, int VAR_3)
{
int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;
uint8_t *lum, *cb, *cr;
int VAR_10, VAR_11, VAR_12, VAR_13;
const AVPicture *VAR_14 = &VAR_1->pict;
VAR_12 = av_clip(VAR_1->w, 0, VAR_2);
VAR_13 = av_clip(VAR_1->h, 0, VAR_3);
VAR_10 = av_clip(VAR_1->VAR_4, 0, VAR_2 - VAR_12);
VAR_11 = av_clip(VAR_1->VAR_5, 0, VAR_3 - VAR_13);
lum = VAR_0->data[0] + VAR_10 + VAR_11 * VAR_0->linesize[0];
cb = VAR_0->data[1] + VAR_10/2 + (VAR_11 >> 1) * VAR_0->linesize[1];
cr = VAR_0->data[2] + VAR_10/2 + (VAR_11 >> 1) * VAR_0->linesize[2];
for (VAR_5 = 0; VAR_5<VAR_13; VAR_5++) {
for (VAR_4 = 0; VAR_4<VAR_12; VAR_4++) {
VAR_6 = VAR_14->data[0][VAR_4 + VAR_5*VAR_14->linesize[0]];
VAR_9 = VAR_14->data[3][VAR_4 + VAR_5*VAR_14->linesize[3]];
lum[0] = ALPHA_BLEND(VAR_9, lum[0], VAR_6, 0);
lum++;
}
lum += VAR_0->linesize[0] - VAR_12;
}
for (VAR_5 = 0; VAR_5<VAR_13/2; VAR_5++) {
for (VAR_4 = 0; VAR_4<VAR_12/2; VAR_4++) {
VAR_7 = VAR_14->data[1][VAR_4 + VAR_5*VAR_14->linesize[1]];
VAR_8 = VAR_14->data[2][VAR_4 + VAR_5*VAR_14->linesize[2]];
VAR_9 = VAR_14->data[3][2*VAR_4 + 2*VAR_5 *VAR_14->linesize[3]]
+ VAR_14->data[3][2*VAR_4 + 1 + 2*VAR_5 *VAR_14->linesize[3]]
+ VAR_14->data[3][2*VAR_4 + 1 + (2*VAR_5+1)*VAR_14->linesize[3]]
+ VAR_14->data[3][2*VAR_4 + (2*VAR_5+1)*VAR_14->linesize[3]];
cb[0] = ALPHA_BLEND(VAR_9>>2, cb[0], VAR_7, 0);
cr[0] = ALPHA_BLEND(VAR_9>>2, cr[0], VAR_8, 0);
cb++;
cr++;
}
cb += VAR_0->linesize[1] - VAR_12/2;
cr += VAR_0->linesize[2] - VAR_12/2;
}
}
| [
"static void FUNC_0(AVPicture *VAR_0, const AVSubtitleRect *VAR_1, int VAR_2, int VAR_3)\n{",
"int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;",
"uint8_t *lum, *cb, *cr;",
"int VAR_10, VAR_11, VAR_12, VAR_13;",
"const AVPicture *VAR_14 = &VAR_1->pict;",
"VAR_12 = av_clip(VAR_1->w, 0, VAR_2);",
"VAR_13 = av_clip(VAR_1->h, 0, VAR_3);",
"VAR_10 = av_clip(VAR_1->VAR_4, 0, VAR_2 - VAR_12);",
"VAR_11 = av_clip(VAR_1->VAR_5, 0, VAR_3 - VAR_13);",
"lum = VAR_0->data[0] + VAR_10 + VAR_11 * VAR_0->linesize[0];",
"cb = VAR_0->data[1] + VAR_10/2 + (VAR_11 >> 1) * VAR_0->linesize[1];",
"cr = VAR_0->data[2] + VAR_10/2 + (VAR_11 >> 1) * VAR_0->linesize[2];",
"for (VAR_5 = 0; VAR_5<VAR_13; VAR_5++) {",
"for (VAR_4 = 0; VAR_4<VAR_12; VAR_4++) {",
"VAR_6 = VAR_14->data[0][VAR_4 + VAR_5*VAR_14->linesize[0]];",
"VAR_9 = VAR_14->data[3][VAR_4 + VAR_5*VAR_14->linesize[3]];",
"lum[0] = ALPHA_BLEND(VAR_9, lum[0], VAR_6, 0);",
"lum++;",
"}",
"lum += VAR_0->linesize[0] - VAR_12;",
"}",
"for (VAR_5 = 0; VAR_5<VAR_13/2; VAR_5++) {",
"for (VAR_4 = 0; VAR_4<VAR_12/2; VAR_4++) {",
"VAR_7 = VAR_14->data[1][VAR_4 + VAR_5*VAR_14->linesize[1]];",
"VAR_8 = VAR_14->data[2][VAR_4 + VAR_5*VAR_14->linesize[2]];",
"VAR_9 = VAR_14->data[3][2*VAR_4 + 2*VAR_5 *VAR_14->linesize[3]]\n+ VAR_14->data[3][2*VAR_4 + 1 + 2*VAR_5 *VAR_14->linesize[3]]\n+ VAR_14->data[3][2*VAR_4 + 1 + (2*VAR_5+1)*VAR_14->linesize[3]]\n+ VAR_14->data[3][2*VAR_4 + (2*VAR_5+1)*VAR_14->linesize[3]];",
"cb[0] = ALPHA_BLEND(VAR_9>>2, cb[0], VAR_7, 0);",
"cr[0] = ALPHA_BLEND(VAR_9>>2, cr[0], VAR_8, 0);",
"cb++;",
"cr++;",
"}",
"cb += VAR_0->linesize[1] - VAR_12/2;",
"cr += VAR_0->linesize[2] - VAR_12/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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59,
61,
63,
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
]
] |
25,096 | int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
{
int len;
if (size < 0)
return -1;
if (s->read_packet && s->write_flag) {
len = s->read_packet(s->opaque, buf, size);
if (len > 0)
s->pos += len;
return len;
}
len = s->buf_end - s->buf_ptr;
if (len == 0) {
/* Reset the buf_end pointer to the start of the buffer, to make sure
* the fill_buffer call tries to read as much data as fits into the
* full buffer, instead of just what space is left after buf_end.
* This avoids returning partial packets at the end of the buffer,
* for packet based inputs.
*/
s->buf_end = s->buf_ptr = s->buffer;
fill_buffer(s);
len = s->buf_end - s->buf_ptr;
}
if (len > size)
len = size;
memcpy(buf, s->buf_ptr, len);
s->buf_ptr += len;
if (!len) {
if (s->error) return s->error;
if (avio_feof(s)) return AVERROR_EOF;
}
return len;
}
| false | FFmpeg | a606f27f4c610708fa96e35eed7b7537d3d8f712 | int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
{
int len;
if (size < 0)
return -1;
if (s->read_packet && s->write_flag) {
len = s->read_packet(s->opaque, buf, size);
if (len > 0)
s->pos += len;
return len;
}
len = s->buf_end - s->buf_ptr;
if (len == 0) {
s->buf_end = s->buf_ptr = s->buffer;
fill_buffer(s);
len = s->buf_end - s->buf_ptr;
}
if (len > size)
len = size;
memcpy(buf, s->buf_ptr, len);
s->buf_ptr += len;
if (!len) {
if (s->error) return s->error;
if (avio_feof(s)) return AVERROR_EOF;
}
return len;
}
| {
"code": [],
"line_no": []
} | int FUNC_0(AVIOContext *VAR_0, unsigned char *VAR_1, int VAR_2)
{
int VAR_3;
if (VAR_2 < 0)
return -1;
if (VAR_0->read_packet && VAR_0->write_flag) {
VAR_3 = VAR_0->read_packet(VAR_0->opaque, VAR_1, VAR_2);
if (VAR_3 > 0)
VAR_0->pos += VAR_3;
return VAR_3;
}
VAR_3 = VAR_0->buf_end - VAR_0->buf_ptr;
if (VAR_3 == 0) {
VAR_0->buf_end = VAR_0->buf_ptr = VAR_0->buffer;
fill_buffer(VAR_0);
VAR_3 = VAR_0->buf_end - VAR_0->buf_ptr;
}
if (VAR_3 > VAR_2)
VAR_3 = VAR_2;
memcpy(VAR_1, VAR_0->buf_ptr, VAR_3);
VAR_0->buf_ptr += VAR_3;
if (!VAR_3) {
if (VAR_0->error) return VAR_0->error;
if (avio_feof(VAR_0)) return AVERROR_EOF;
}
return VAR_3;
}
| [
"int FUNC_0(AVIOContext *VAR_0, unsigned char *VAR_1, int VAR_2)\n{",
"int VAR_3;",
"if (VAR_2 < 0)\nreturn -1;",
"if (VAR_0->read_packet && VAR_0->write_flag) {",
"VAR_3 = VAR_0->read_packet(VAR_0->opaque, VAR_1, VAR_2);",
"if (VAR_3 > 0)\nVAR_0->pos += VAR_3;",
"return VAR_3;",
"}",
"VAR_3 = VAR_0->buf_end - VAR_0->buf_ptr;",
"if (VAR_3 == 0) {",
"VAR_0->buf_end = VAR_0->buf_ptr = VAR_0->buffer;",
"fill_buffer(VAR_0);",
"VAR_3 = VAR_0->buf_end - VAR_0->buf_ptr;",
"}",
"if (VAR_3 > VAR_2)\nVAR_3 = VAR_2;",
"memcpy(VAR_1, VAR_0->buf_ptr, VAR_3);",
"VAR_0->buf_ptr += VAR_3;",
"if (!VAR_3) {",
"if (VAR_0->error) return VAR_0->error;",
"if (avio_feof(VAR_0)) return AVERROR_EOF;",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53,
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
]
] |
25,097 | static int sp5x_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
#if 0
MJpegDecodeContext *s = avctx->priv_data;
#endif
const int qscale = 5;
uint8_t *buf_ptr, *buf_end, *recoded;
int i = 0, j = 0;
/* no supplementary picture */
if (buf_size == 0)
return 0;
if (!avctx->width || !avctx->height)
return -1;
buf_ptr = buf;
buf_end = buf + buf_size;
#if 1
recoded = av_mallocz(buf_size + 1024);
if (!recoded)
return -1;
/* SOI */
recoded[j++] = 0xFF;
recoded[j++] = 0xD8;
memcpy(recoded+j, &sp5x_data_dqt[0], sizeof(sp5x_data_dqt));
memcpy(recoded+j+5, &sp5x_quant_table[qscale * 2], 64);
memcpy(recoded+j+70, &sp5x_quant_table[(qscale * 2) + 1], 64);
j += sizeof(sp5x_data_dqt);
memcpy(recoded+j, &sp5x_data_dht[0], sizeof(sp5x_data_dht));
j += sizeof(sp5x_data_dht);
memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof));
recoded[j+5] = (avctx->coded_height >> 8) & 0xFF;
recoded[j+6] = avctx->coded_height & 0xFF;
recoded[j+7] = (avctx->coded_width >> 8) & 0xFF;
recoded[j+8] = avctx->coded_width & 0xFF;
j += sizeof(sp5x_data_sof);
memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos));
j += sizeof(sp5x_data_sos);
for (i = 14; i < buf_size && j < buf_size+1024-2; i++)
{
recoded[j++] = buf[i];
if (buf[i] == 0xff)
recoded[j++] = 0;
}
/* EOI */
recoded[j++] = 0xFF;
recoded[j++] = 0xD9;
i = mjpeg_decode_frame(avctx, data, data_size, recoded, j);
av_free(recoded);
#else
/* SOF */
s->bits = 8;
s->width = avctx->coded_width;
s->height = avctx->coded_height;
s->nb_components = 3;
s->component_id[0] = 0;
s->h_count[0] = 2;
s->v_count[0] = 2;
s->quant_index[0] = 0;
s->component_id[1] = 1;
s->h_count[1] = 1;
s->v_count[1] = 1;
s->quant_index[1] = 1;
s->component_id[2] = 2;
s->h_count[2] = 1;
s->v_count[2] = 1;
s->quant_index[2] = 1;
s->h_max = 2;
s->v_max = 2;
s->qscale_table = av_mallocz((s->width+15)/16);
avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV420P : PIX_FMT_YUVJ420;
s->interlaced = 0;
s->picture.reference = 0;
if (avctx->get_buffer(avctx, &s->picture) < 0)
{
fprintf(stderr, "get_buffer() failed\n");
return -1;
}
s->picture.pict_type = I_TYPE;
s->picture.key_frame = 1;
for (i = 0; i < 3; i++)
s->linesize[i] = s->picture.linesize[i] << s->interlaced;
/* DQT */
for (i = 0; i < 64; i++)
{
j = s->scantable.permutated[i];
s->quant_matrixes[0][j] = sp5x_quant_table[(qscale * 2) + i];
}
s->qscale[0] = FFMAX(
s->quant_matrixes[0][s->scantable.permutated[1]],
s->quant_matrixes[0][s->scantable.permutated[8]]) >> 1;
for (i = 0; i < 64; i++)
{
j = s->scantable.permutated[i];
s->quant_matrixes[1][j] = sp5x_quant_table[(qscale * 2) + 1 + i];
}
s->qscale[1] = FFMAX(
s->quant_matrixes[1][s->scantable.permutated[1]],
s->quant_matrixes[1][s->scantable.permutated[8]]) >> 1;
/* DHT */
/* SOS */
s->comp_index[0] = 0;
s->nb_blocks[0] = s->h_count[0] * s->v_count[0];
s->h_scount[0] = s->h_count[0];
s->v_scount[0] = s->v_count[0];
s->dc_index[0] = 0;
s->ac_index[0] = 0;
s->comp_index[1] = 1;
s->nb_blocks[1] = s->h_count[1] * s->v_count[1];
s->h_scount[1] = s->h_count[1];
s->v_scount[1] = s->v_count[1];
s->dc_index[1] = 1;
s->ac_index[1] = 1;
s->comp_index[2] = 2;
s->nb_blocks[2] = s->h_count[2] * s->v_count[2];
s->h_scount[2] = s->h_count[2];
s->v_scount[2] = s->v_count[2];
s->dc_index[2] = 1;
s->ac_index[2] = 1;
for (i = 0; i < 3; i++)
s->last_dc[i] = 1024;
s->mb_width = (s->width * s->h_max * 8 -1) / (s->h_max * 8);
s->mb_height = (s->height * s->v_max * 8 -1) / (s->v_max * 8);
init_get_bits(&s->gb, buf+14, (buf_size-14)*8);
return mjpeg_decode_scan(s);
#endif
return i;
}
| false | FFmpeg | 934982c4ace1a3d5d627b518782ed092a456c49e | static int sp5x_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
#if 0
MJpegDecodeContext *s = avctx->priv_data;
#endif
const int qscale = 5;
uint8_t *buf_ptr, *buf_end, *recoded;
int i = 0, j = 0;
if (buf_size == 0)
return 0;
if (!avctx->width || !avctx->height)
return -1;
buf_ptr = buf;
buf_end = buf + buf_size;
#if 1
recoded = av_mallocz(buf_size + 1024);
if (!recoded)
return -1;
recoded[j++] = 0xFF;
recoded[j++] = 0xD8;
memcpy(recoded+j, &sp5x_data_dqt[0], sizeof(sp5x_data_dqt));
memcpy(recoded+j+5, &sp5x_quant_table[qscale * 2], 64);
memcpy(recoded+j+70, &sp5x_quant_table[(qscale * 2) + 1], 64);
j += sizeof(sp5x_data_dqt);
memcpy(recoded+j, &sp5x_data_dht[0], sizeof(sp5x_data_dht));
j += sizeof(sp5x_data_dht);
memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof));
recoded[j+5] = (avctx->coded_height >> 8) & 0xFF;
recoded[j+6] = avctx->coded_height & 0xFF;
recoded[j+7] = (avctx->coded_width >> 8) & 0xFF;
recoded[j+8] = avctx->coded_width & 0xFF;
j += sizeof(sp5x_data_sof);
memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos));
j += sizeof(sp5x_data_sos);
for (i = 14; i < buf_size && j < buf_size+1024-2; i++)
{
recoded[j++] = buf[i];
if (buf[i] == 0xff)
recoded[j++] = 0;
}
recoded[j++] = 0xFF;
recoded[j++] = 0xD9;
i = mjpeg_decode_frame(avctx, data, data_size, recoded, j);
av_free(recoded);
#else
s->bits = 8;
s->width = avctx->coded_width;
s->height = avctx->coded_height;
s->nb_components = 3;
s->component_id[0] = 0;
s->h_count[0] = 2;
s->v_count[0] = 2;
s->quant_index[0] = 0;
s->component_id[1] = 1;
s->h_count[1] = 1;
s->v_count[1] = 1;
s->quant_index[1] = 1;
s->component_id[2] = 2;
s->h_count[2] = 1;
s->v_count[2] = 1;
s->quant_index[2] = 1;
s->h_max = 2;
s->v_max = 2;
s->qscale_table = av_mallocz((s->width+15)/16);
avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV420P : PIX_FMT_YUVJ420;
s->interlaced = 0;
s->picture.reference = 0;
if (avctx->get_buffer(avctx, &s->picture) < 0)
{
fprintf(stderr, "get_buffer() failed\n");
return -1;
}
s->picture.pict_type = I_TYPE;
s->picture.key_frame = 1;
for (i = 0; i < 3; i++)
s->linesize[i] = s->picture.linesize[i] << s->interlaced;
for (i = 0; i < 64; i++)
{
j = s->scantable.permutated[i];
s->quant_matrixes[0][j] = sp5x_quant_table[(qscale * 2) + i];
}
s->qscale[0] = FFMAX(
s->quant_matrixes[0][s->scantable.permutated[1]],
s->quant_matrixes[0][s->scantable.permutated[8]]) >> 1;
for (i = 0; i < 64; i++)
{
j = s->scantable.permutated[i];
s->quant_matrixes[1][j] = sp5x_quant_table[(qscale * 2) + 1 + i];
}
s->qscale[1] = FFMAX(
s->quant_matrixes[1][s->scantable.permutated[1]],
s->quant_matrixes[1][s->scantable.permutated[8]]) >> 1;
s->comp_index[0] = 0;
s->nb_blocks[0] = s->h_count[0] * s->v_count[0];
s->h_scount[0] = s->h_count[0];
s->v_scount[0] = s->v_count[0];
s->dc_index[0] = 0;
s->ac_index[0] = 0;
s->comp_index[1] = 1;
s->nb_blocks[1] = s->h_count[1] * s->v_count[1];
s->h_scount[1] = s->h_count[1];
s->v_scount[1] = s->v_count[1];
s->dc_index[1] = 1;
s->ac_index[1] = 1;
s->comp_index[2] = 2;
s->nb_blocks[2] = s->h_count[2] * s->v_count[2];
s->h_scount[2] = s->h_count[2];
s->v_scount[2] = s->v_count[2];
s->dc_index[2] = 1;
s->ac_index[2] = 1;
for (i = 0; i < 3; i++)
s->last_dc[i] = 1024;
s->mb_width = (s->width * s->h_max * 8 -1) / (s->h_max * 8);
s->mb_height = (s->height * s->v_max * 8 -1) / (s->v_max * 8);
init_get_bits(&s->gb, buf+14, (buf_size-14)*8);
return mjpeg_decode_scan(s);
#endif
return i;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVCodecContext *VAR_0,
void *VAR_1, int *VAR_2,
uint8_t *VAR_3, int VAR_4)
{
#if 0
MJpegDecodeContext *s = VAR_0->priv_data;
#endif
const int VAR_5 = 5;
uint8_t *buf_ptr, *buf_end, *recoded;
int VAR_6 = 0, VAR_7 = 0;
if (VAR_4 == 0)
return 0;
if (!VAR_0->width || !VAR_0->height)
return -1;
buf_ptr = VAR_3;
buf_end = VAR_3 + VAR_4;
#if 1
recoded = av_mallocz(VAR_4 + 1024);
if (!recoded)
return -1;
recoded[VAR_7++] = 0xFF;
recoded[VAR_7++] = 0xD8;
memcpy(recoded+VAR_7, &sp5x_data_dqt[0], sizeof(sp5x_data_dqt));
memcpy(recoded+VAR_7+5, &sp5x_quant_table[VAR_5 * 2], 64);
memcpy(recoded+VAR_7+70, &sp5x_quant_table[(VAR_5 * 2) + 1], 64);
VAR_7 += sizeof(sp5x_data_dqt);
memcpy(recoded+VAR_7, &sp5x_data_dht[0], sizeof(sp5x_data_dht));
VAR_7 += sizeof(sp5x_data_dht);
memcpy(recoded+VAR_7, &sp5x_data_sof[0], sizeof(sp5x_data_sof));
recoded[VAR_7+5] = (VAR_0->coded_height >> 8) & 0xFF;
recoded[VAR_7+6] = VAR_0->coded_height & 0xFF;
recoded[VAR_7+7] = (VAR_0->coded_width >> 8) & 0xFF;
recoded[VAR_7+8] = VAR_0->coded_width & 0xFF;
VAR_7 += sizeof(sp5x_data_sof);
memcpy(recoded+VAR_7, &sp5x_data_sos[0], sizeof(sp5x_data_sos));
VAR_7 += sizeof(sp5x_data_sos);
for (VAR_6 = 14; VAR_6 < VAR_4 && VAR_7 < VAR_4+1024-2; VAR_6++)
{
recoded[VAR_7++] = VAR_3[VAR_6];
if (VAR_3[VAR_6] == 0xff)
recoded[VAR_7++] = 0;
}
recoded[VAR_7++] = 0xFF;
recoded[VAR_7++] = 0xD9;
VAR_6 = mjpeg_decode_frame(VAR_0, VAR_1, VAR_2, recoded, VAR_7);
av_free(recoded);
#else
s->bits = 8;
s->width = VAR_0->coded_width;
s->height = VAR_0->coded_height;
s->nb_components = 3;
s->component_id[0] = 0;
s->h_count[0] = 2;
s->v_count[0] = 2;
s->quant_index[0] = 0;
s->component_id[1] = 1;
s->h_count[1] = 1;
s->v_count[1] = 1;
s->quant_index[1] = 1;
s->component_id[2] = 2;
s->h_count[2] = 1;
s->v_count[2] = 1;
s->quant_index[2] = 1;
s->h_max = 2;
s->v_max = 2;
s->qscale_table = av_mallocz((s->width+15)/16);
VAR_0->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV420P : PIX_FMT_YUVJ420;
s->interlaced = 0;
s->picture.reference = 0;
if (VAR_0->get_buffer(VAR_0, &s->picture) < 0)
{
fprintf(stderr, "get_buffer() failed\n");
return -1;
}
s->picture.pict_type = I_TYPE;
s->picture.key_frame = 1;
for (VAR_6 = 0; VAR_6 < 3; VAR_6++)
s->linesize[VAR_6] = s->picture.linesize[VAR_6] << s->interlaced;
for (VAR_6 = 0; VAR_6 < 64; VAR_6++)
{
VAR_7 = s->scantable.permutated[VAR_6];
s->quant_matrixes[0][VAR_7] = sp5x_quant_table[(VAR_5 * 2) + VAR_6];
}
s->VAR_5[0] = FFMAX(
s->quant_matrixes[0][s->scantable.permutated[1]],
s->quant_matrixes[0][s->scantable.permutated[8]]) >> 1;
for (VAR_6 = 0; VAR_6 < 64; VAR_6++)
{
VAR_7 = s->scantable.permutated[VAR_6];
s->quant_matrixes[1][VAR_7] = sp5x_quant_table[(VAR_5 * 2) + 1 + VAR_6];
}
s->VAR_5[1] = FFMAX(
s->quant_matrixes[1][s->scantable.permutated[1]],
s->quant_matrixes[1][s->scantable.permutated[8]]) >> 1;
s->comp_index[0] = 0;
s->nb_blocks[0] = s->h_count[0] * s->v_count[0];
s->h_scount[0] = s->h_count[0];
s->v_scount[0] = s->v_count[0];
s->dc_index[0] = 0;
s->ac_index[0] = 0;
s->comp_index[1] = 1;
s->nb_blocks[1] = s->h_count[1] * s->v_count[1];
s->h_scount[1] = s->h_count[1];
s->v_scount[1] = s->v_count[1];
s->dc_index[1] = 1;
s->ac_index[1] = 1;
s->comp_index[2] = 2;
s->nb_blocks[2] = s->h_count[2] * s->v_count[2];
s->h_scount[2] = s->h_count[2];
s->v_scount[2] = s->v_count[2];
s->dc_index[2] = 1;
s->ac_index[2] = 1;
for (VAR_6 = 0; VAR_6 < 3; VAR_6++)
s->last_dc[VAR_6] = 1024;
s->mb_width = (s->width * s->h_max * 8 -1) / (s->h_max * 8);
s->mb_height = (s->height * s->v_max * 8 -1) / (s->v_max * 8);
init_get_bits(&s->gb, VAR_3+14, (VAR_4-14)*8);
return mjpeg_decode_scan(s);
#endif
return VAR_6;
}
| [
"static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{",
"#if 0\nMJpegDecodeContext *s = VAR_0->priv_data;",
"#endif\nconst int VAR_5 = 5;",
"uint8_t *buf_ptr, *buf_end, *recoded;",
"int VAR_6 = 0, VAR_7 = 0;",
"if (VAR_4 == 0)\nreturn 0;",
"if (!VAR_0->width || !VAR_0->height)\nreturn -1;",
"buf_ptr = VAR_3;",
"buf_end = VAR_3 + VAR_4;",
"#if 1\nrecoded = av_mallocz(VAR_4 + 1024);",
"if (!recoded)\nreturn -1;",
"recoded[VAR_7++] = 0xFF;",
"recoded[VAR_7++] = 0xD8;",
"memcpy(recoded+VAR_7, &sp5x_data_dqt[0], sizeof(sp5x_data_dqt));",
"memcpy(recoded+VAR_7+5, &sp5x_quant_table[VAR_5 * 2], 64);",
"memcpy(recoded+VAR_7+70, &sp5x_quant_table[(VAR_5 * 2) + 1], 64);",
"VAR_7 += sizeof(sp5x_data_dqt);",
"memcpy(recoded+VAR_7, &sp5x_data_dht[0], sizeof(sp5x_data_dht));",
"VAR_7 += sizeof(sp5x_data_dht);",
"memcpy(recoded+VAR_7, &sp5x_data_sof[0], sizeof(sp5x_data_sof));",
"recoded[VAR_7+5] = (VAR_0->coded_height >> 8) & 0xFF;",
"recoded[VAR_7+6] = VAR_0->coded_height & 0xFF;",
"recoded[VAR_7+7] = (VAR_0->coded_width >> 8) & 0xFF;",
"recoded[VAR_7+8] = VAR_0->coded_width & 0xFF;",
"VAR_7 += sizeof(sp5x_data_sof);",
"memcpy(recoded+VAR_7, &sp5x_data_sos[0], sizeof(sp5x_data_sos));",
"VAR_7 += sizeof(sp5x_data_sos);",
"for (VAR_6 = 14; VAR_6 < VAR_4 && VAR_7 < VAR_4+1024-2; VAR_6++)",
"{",
"recoded[VAR_7++] = VAR_3[VAR_6];",
"if (VAR_3[VAR_6] == 0xff)\nrecoded[VAR_7++] = 0;",
"}",
"recoded[VAR_7++] = 0xFF;",
"recoded[VAR_7++] = 0xD9;",
"VAR_6 = mjpeg_decode_frame(VAR_0, VAR_1, VAR_2, recoded, VAR_7);",
"av_free(recoded);",
"#else\ns->bits = 8;",
"s->width = VAR_0->coded_width;",
"s->height = VAR_0->coded_height;",
"s->nb_components = 3;",
"s->component_id[0] = 0;",
"s->h_count[0] = 2;",
"s->v_count[0] = 2;",
"s->quant_index[0] = 0;",
"s->component_id[1] = 1;",
"s->h_count[1] = 1;",
"s->v_count[1] = 1;",
"s->quant_index[1] = 1;",
"s->component_id[2] = 2;",
"s->h_count[2] = 1;",
"s->v_count[2] = 1;",
"s->quant_index[2] = 1;",
"s->h_max = 2;",
"s->v_max = 2;",
"s->qscale_table = av_mallocz((s->width+15)/16);",
"VAR_0->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV420P : PIX_FMT_YUVJ420;",
"s->interlaced = 0;",
"s->picture.reference = 0;",
"if (VAR_0->get_buffer(VAR_0, &s->picture) < 0)\n{",
"fprintf(stderr, \"get_buffer() failed\\n\");",
"return -1;",
"}",
"s->picture.pict_type = I_TYPE;",
"s->picture.key_frame = 1;",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++)",
"s->linesize[VAR_6] = s->picture.linesize[VAR_6] << s->interlaced;",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++)",
"{",
"VAR_7 = s->scantable.permutated[VAR_6];",
"s->quant_matrixes[0][VAR_7] = sp5x_quant_table[(VAR_5 * 2) + VAR_6];",
"}",
"s->VAR_5[0] = FFMAX(\ns->quant_matrixes[0][s->scantable.permutated[1]],\ns->quant_matrixes[0][s->scantable.permutated[8]]) >> 1;",
"for (VAR_6 = 0; VAR_6 < 64; VAR_6++)",
"{",
"VAR_7 = s->scantable.permutated[VAR_6];",
"s->quant_matrixes[1][VAR_7] = sp5x_quant_table[(VAR_5 * 2) + 1 + VAR_6];",
"}",
"s->VAR_5[1] = FFMAX(\ns->quant_matrixes[1][s->scantable.permutated[1]],\ns->quant_matrixes[1][s->scantable.permutated[8]]) >> 1;",
"s->comp_index[0] = 0;",
"s->nb_blocks[0] = s->h_count[0] * s->v_count[0];",
"s->h_scount[0] = s->h_count[0];",
"s->v_scount[0] = s->v_count[0];",
"s->dc_index[0] = 0;",
"s->ac_index[0] = 0;",
"s->comp_index[1] = 1;",
"s->nb_blocks[1] = s->h_count[1] * s->v_count[1];",
"s->h_scount[1] = s->h_count[1];",
"s->v_scount[1] = s->v_count[1];",
"s->dc_index[1] = 1;",
"s->ac_index[1] = 1;",
"s->comp_index[2] = 2;",
"s->nb_blocks[2] = s->h_count[2] * s->v_count[2];",
"s->h_scount[2] = s->h_count[2];",
"s->v_scount[2] = s->v_count[2];",
"s->dc_index[2] = 1;",
"s->ac_index[2] = 1;",
"for (VAR_6 = 0; VAR_6 < 3; VAR_6++)",
"s->last_dc[VAR_6] = 1024;",
"s->mb_width = (s->width * s->h_max * 8 -1) / (s->h_max * 8);",
"s->mb_height = (s->height * s->v_max * 8 -1) / (s->v_max * 8);",
"init_get_bits(&s->gb, VAR_3+14, (VAR_4-14)*8);",
"return mjpeg_decode_scan(s);",
"#endif\nreturn 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
],
[
25,
27
],
[
31,
33
],
[
37
],
[
39
],
[
43,
45
],
[
47,
49
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103,
105
],
[
107
],
[
113
],
[
115
],
[
119
],
[
123
],
[
127,
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
169
],
[
171
],
[
173
],
[
177
],
[
179,
181
],
[
183
],
[
185
],
[
187
],
[
191
],
[
193
],
[
197
],
[
199
],
[
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215,
217,
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233,
235,
237
],
[
247
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271
],
[
275
],
[
277
],
[
279
],
[
281
],
[
283
],
[
285
],
[
289
],
[
291
],
[
295
],
[
297
],
[
301
],
[
305
],
[
307,
311
],
[
313
]
] |
25,099 | float32 helper_fdtos(CPUSPARCState *env, float64 src)
{
float32 ret;
clear_float_exceptions(env);
ret = float64_to_float32(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| false | qemu | 7385aed20db5d83979f683b9d0048674411e963c | float32 helper_fdtos(CPUSPARCState *env, float64 src)
{
float32 ret;
clear_float_exceptions(env);
ret = float64_to_float32(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| {
"code": [],
"line_no": []
} | float32 FUNC_0(CPUSPARCState *env, float64 src)
{
float32 ret;
clear_float_exceptions(env);
ret = float64_to_float32(src, &env->fp_status);
check_ieee_exceptions(env);
return ret;
}
| [
"float32 FUNC_0(CPUSPARCState *env, float64 src)\n{",
"float32 ret;",
"clear_float_exceptions(env);",
"ret = float64_to_float32(src, &env->fp_status);",
"check_ieee_exceptions(env);",
"return ret;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
]
] |
25,100 | static void icp_control_init(target_phys_addr_t base)
{
MemoryRegion *io;
io = (MemoryRegion *)g_malloc0(sizeof(MemoryRegion));
memory_region_init_io(io, &icp_control_ops, NULL,
"control", 0x00800000);
memory_region_add_subregion(get_system_memory(), base, io);
/* ??? Save/restore. */
}
| false | qemu | a8170e5e97ad17ca169c64ba87ae2f53850dab4c | static void icp_control_init(target_phys_addr_t base)
{
MemoryRegion *io;
io = (MemoryRegion *)g_malloc0(sizeof(MemoryRegion));
memory_region_init_io(io, &icp_control_ops, NULL,
"control", 0x00800000);
memory_region_add_subregion(get_system_memory(), base, io);
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(target_phys_addr_t VAR_0)
{
MemoryRegion *io;
io = (MemoryRegion *)g_malloc0(sizeof(MemoryRegion));
memory_region_init_io(io, &icp_control_ops, NULL,
"control", 0x00800000);
memory_region_add_subregion(get_system_memory(), VAR_0, io);
}
| [
"static void FUNC_0(target_phys_addr_t VAR_0)\n{",
"MemoryRegion *io;",
"io = (MemoryRegion *)g_malloc0(sizeof(MemoryRegion));",
"memory_region_init_io(io, &icp_control_ops, NULL,\n\"control\", 0x00800000);",
"memory_region_add_subregion(get_system_memory(), VAR_0, io);",
"}"
] | [
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11,
13
],
[
15
],
[
19
]
] |
25,101 | gen_intermediate_code_internal(MoxieCPU *cpu, TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
DisasContext ctx;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
CPUMoxieState *env = &cpu->env;
int num_insns;
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.pc = pc_start;
ctx.saved_pc = -1;
ctx.tb = tb;
ctx.memidx = 0;
ctx.singlestep_enabled = 0;
ctx.bstate = BS_NONE;
num_insns = 0;
gen_tb_start();
do {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (ctx.pc == bp->pc) {
tcg_gen_movi_i32(cpu_pc, ctx.pc);
gen_helper_debug(cpu_env);
ctx.bstate = BS_EXCP;
goto done_generating;
}
}
}
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
}
tcg_ctx.gen_opc_pc[lj] = ctx.pc;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
ctx.opcode = cpu_lduw_code(env, ctx.pc);
ctx.pc += decode_opc(cpu, &ctx);
num_insns++;
if (cs->singlestep_enabled) {
break;
}
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) {
break;
}
} while (ctx.bstate == BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end);
if (cs->singlestep_enabled) {
tcg_gen_movi_tl(cpu_pc, ctx.pc);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
case BS_NONE:
gen_goto_tb(env, &ctx, 0, ctx.pc);
break;
case BS_EXCP:
tcg_gen_exit_tb(0);
break;
case BS_BRANCH:
default:
break;
}
}
done_generating:
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
} else {
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
}
}
| false | qemu | cd42d5b23691ad73edfd6dbcfc935a960a9c5a65 | gen_intermediate_code_internal(MoxieCPU *cpu, TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
DisasContext ctx;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
CPUMoxieState *env = &cpu->env;
int num_insns;
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.pc = pc_start;
ctx.saved_pc = -1;
ctx.tb = tb;
ctx.memidx = 0;
ctx.singlestep_enabled = 0;
ctx.bstate = BS_NONE;
num_insns = 0;
gen_tb_start();
do {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (ctx.pc == bp->pc) {
tcg_gen_movi_i32(cpu_pc, ctx.pc);
gen_helper_debug(cpu_env);
ctx.bstate = BS_EXCP;
goto done_generating;
}
}
}
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
}
tcg_ctx.gen_opc_pc[lj] = ctx.pc;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
ctx.opcode = cpu_lduw_code(env, ctx.pc);
ctx.pc += decode_opc(cpu, &ctx);
num_insns++;
if (cs->singlestep_enabled) {
break;
}
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) {
break;
}
} while (ctx.bstate == BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end);
if (cs->singlestep_enabled) {
tcg_gen_movi_tl(cpu_pc, ctx.pc);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
case BS_NONE:
gen_goto_tb(env, &ctx, 0, ctx.pc);
break;
case BS_EXCP:
tcg_gen_exit_tb(0);
break;
case BS_BRANCH:
default:
break;
}
}
done_generating:
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j) {
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
} else {
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
}
}
| {
"code": [],
"line_no": []
} | FUNC_0(MoxieCPU *VAR_0, TranslationBlock *VAR_1,
bool VAR_2)
{
CPUState *cs = CPU(VAR_0);
DisasContext ctx;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int VAR_3, VAR_4 = -1;
CPUMoxieState *env = &VAR_0->env;
int VAR_5;
pc_start = VAR_1->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.pc = pc_start;
ctx.saved_pc = -1;
ctx.VAR_1 = VAR_1;
ctx.memidx = 0;
ctx.singlestep_enabled = 0;
ctx.bstate = BS_NONE;
VAR_5 = 0;
gen_tb_start();
do {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (ctx.pc == bp->pc) {
tcg_gen_movi_i32(cpu_pc, ctx.pc);
gen_helper_debug(cpu_env);
ctx.bstate = BS_EXCP;
goto done_generating;
}
}
}
if (VAR_2) {
VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (VAR_4 < VAR_3) {
VAR_4++;
while (VAR_4 < VAR_3) {
tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;
}
}
tcg_ctx.gen_opc_pc[VAR_4] = ctx.pc;
tcg_ctx.gen_opc_instr_start[VAR_4] = 1;
tcg_ctx.gen_opc_icount[VAR_4] = VAR_5;
}
ctx.opcode = cpu_lduw_code(env, ctx.pc);
ctx.pc += decode_opc(VAR_0, &ctx);
VAR_5++;
if (cs->singlestep_enabled) {
break;
}
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) {
break;
}
} while (ctx.bstate == BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end);
if (cs->singlestep_enabled) {
tcg_gen_movi_tl(cpu_pc, ctx.pc);
gen_helper_debug(cpu_env);
} else {
switch (ctx.bstate) {
case BS_STOP:
case BS_NONE:
gen_goto_tb(env, &ctx, 0, ctx.pc);
break;
case BS_EXCP:
tcg_gen_exit_tb(0);
break;
case BS_BRANCH:
default:
break;
}
}
done_generating:
gen_tb_end(VAR_1, VAR_5);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (VAR_2) {
VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
VAR_4++;
while (VAR_4 <= VAR_3) {
tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;
}
} else {
VAR_1->size = ctx.pc - pc_start;
VAR_1->icount = VAR_5;
}
}
| [
"FUNC_0(MoxieCPU *VAR_0, TranslationBlock *VAR_1,\nbool VAR_2)\n{",
"CPUState *cs = CPU(VAR_0);",
"DisasContext ctx;",
"target_ulong pc_start;",
"uint16_t *gen_opc_end;",
"CPUBreakpoint *bp;",
"int VAR_3, VAR_4 = -1;",
"CPUMoxieState *env = &VAR_0->env;",
"int VAR_5;",
"pc_start = VAR_1->pc;",
"gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;",
"ctx.pc = pc_start;",
"ctx.saved_pc = -1;",
"ctx.VAR_1 = VAR_1;",
"ctx.memidx = 0;",
"ctx.singlestep_enabled = 0;",
"ctx.bstate = BS_NONE;",
"VAR_5 = 0;",
"gen_tb_start();",
"do {",
"if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {",
"QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {",
"if (ctx.pc == bp->pc) {",
"tcg_gen_movi_i32(cpu_pc, ctx.pc);",
"gen_helper_debug(cpu_env);",
"ctx.bstate = BS_EXCP;",
"goto done_generating;",
"}",
"}",
"}",
"if (VAR_2) {",
"VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;",
"if (VAR_4 < VAR_3) {",
"VAR_4++;",
"while (VAR_4 < VAR_3) {",
"tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;",
"}",
"}",
"tcg_ctx.gen_opc_pc[VAR_4] = ctx.pc;",
"tcg_ctx.gen_opc_instr_start[VAR_4] = 1;",
"tcg_ctx.gen_opc_icount[VAR_4] = VAR_5;",
"}",
"ctx.opcode = cpu_lduw_code(env, ctx.pc);",
"ctx.pc += decode_opc(VAR_0, &ctx);",
"VAR_5++;",
"if (cs->singlestep_enabled) {",
"break;",
"}",
"if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) {",
"break;",
"}",
"} while (ctx.bstate == BS_NONE && tcg_ctx.gen_opc_ptr < gen_opc_end);",
"if (cs->singlestep_enabled) {",
"tcg_gen_movi_tl(cpu_pc, ctx.pc);",
"gen_helper_debug(cpu_env);",
"} else {",
"switch (ctx.bstate) {",
"case BS_STOP:\ncase BS_NONE:\ngen_goto_tb(env, &ctx, 0, ctx.pc);",
"break;",
"case BS_EXCP:\ntcg_gen_exit_tb(0);",
"break;",
"case BS_BRANCH:\ndefault:\nbreak;",
"}",
"}",
"done_generating:\ngen_tb_end(VAR_1, VAR_5);",
"*tcg_ctx.gen_opc_ptr = INDEX_op_end;",
"if (VAR_2) {",
"VAR_3 = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;",
"VAR_4++;",
"while (VAR_4 <= VAR_3) {",
"tcg_ctx.gen_opc_instr_start[VAR_4++] = 0;",
"}",
"} else {",
"VAR_1->size = ctx.pc - pc_start;",
"VAR_1->icount = VAR_5;",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
103
],
[
105
],
[
107
],
[
111
],
[
113
],
[
115
],
[
117
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131,
133,
135
],
[
137
],
[
139,
141
],
[
143
],
[
145,
147,
149
],
[
151
],
[
153
],
[
155,
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
]
] |
25,102 | USBBus *usb_bus_find(int busnr)
{
USBBus *bus;
if (-1 == busnr)
return TAILQ_FIRST(&busses);
TAILQ_FOREACH(bus, &busses, next) {
if (bus->busnr == busnr)
return bus;
}
return NULL;
}
| false | qemu | 72cf2d4f0e181d0d3a3122e04129c58a95da713e | USBBus *usb_bus_find(int busnr)
{
USBBus *bus;
if (-1 == busnr)
return TAILQ_FIRST(&busses);
TAILQ_FOREACH(bus, &busses, next) {
if (bus->busnr == busnr)
return bus;
}
return NULL;
}
| {
"code": [],
"line_no": []
} | USBBus *FUNC_0(int busnr)
{
USBBus *bus;
if (-1 == busnr)
return TAILQ_FIRST(&busses);
TAILQ_FOREACH(bus, &busses, next) {
if (bus->busnr == busnr)
return bus;
}
return NULL;
}
| [
"USBBus *FUNC_0(int busnr)\n{",
"USBBus *bus;",
"if (-1 == busnr)\nreturn TAILQ_FIRST(&busses);",
"TAILQ_FOREACH(bus, &busses, next) {",
"if (bus->busnr == busnr)\nreturn bus;",
"}",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9,
11
],
[
13
],
[
15,
17
],
[
19
],
[
21
],
[
23
]
] |
25,104 | vreader_copy_list(VReaderList *list)
{
VReaderList *new_list = NULL;
VReaderListEntry *current_entry = NULL;
new_list = vreader_list_new();
if (new_list == NULL) {
return NULL;
}
for (current_entry = vreader_list_get_first(list); current_entry;
current_entry = vreader_list_get_next(current_entry)) {
VReader *reader = vreader_list_get_reader(current_entry);
VReaderListEntry *new_entry = vreader_list_entry_new(reader);
vreader_free(reader);
vreader_queue(new_list, new_entry);
}
return new_list;
}
| false | qemu | 1687a089f103f9b7a1b4a1555068054cb46ee9e9 | vreader_copy_list(VReaderList *list)
{
VReaderList *new_list = NULL;
VReaderListEntry *current_entry = NULL;
new_list = vreader_list_new();
if (new_list == NULL) {
return NULL;
}
for (current_entry = vreader_list_get_first(list); current_entry;
current_entry = vreader_list_get_next(current_entry)) {
VReader *reader = vreader_list_get_reader(current_entry);
VReaderListEntry *new_entry = vreader_list_entry_new(reader);
vreader_free(reader);
vreader_queue(new_list, new_entry);
}
return new_list;
}
| {
"code": [],
"line_no": []
} | FUNC_0(VReaderList *VAR_0)
{
VReaderList *new_list = NULL;
VReaderListEntry *current_entry = NULL;
new_list = vreader_list_new();
if (new_list == NULL) {
return NULL;
}
for (current_entry = vreader_list_get_first(VAR_0); current_entry;
current_entry = vreader_list_get_next(current_entry)) {
VReader *reader = vreader_list_get_reader(current_entry);
VReaderListEntry *new_entry = vreader_list_entry_new(reader);
vreader_free(reader);
vreader_queue(new_list, new_entry);
}
return new_list;
}
| [
"FUNC_0(VReaderList *VAR_0)\n{",
"VReaderList *new_list = NULL;",
"VReaderListEntry *current_entry = NULL;",
"new_list = vreader_list_new();",
"if (new_list == NULL) {",
"return NULL;",
"}",
"for (current_entry = vreader_list_get_first(VAR_0); current_entry;",
"current_entry = vreader_list_get_next(current_entry)) {",
"VReader *reader = vreader_list_get_reader(current_entry);",
"VReaderListEntry *new_entry = vreader_list_entry_new(reader);",
"vreader_free(reader);",
"vreader_queue(new_list, new_entry);",
"}",
"return new_list;",
"}"
] | [
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
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
]
] |
25,105 | static int cow_find_streak(const uint8_t *bitmap, int value, int start, int nb_sectors)
{
int streak_value = value ? 0xFF : 0;
int last = MIN(start + nb_sectors, BITS_PER_BITMAP_SECTOR);
int bitnum = start;
while (bitnum < last) {
if ((bitnum & 7) == 0 && bitmap[bitnum / 8] == streak_value) {
bitnum += 8;
continue;
}
if (cow_test_bit(bitnum, bitmap) == value) {
bitnum++;
continue;
}
break;
}
return MIN(bitnum, last) - start;
}
| false | qemu | 550830f9351291c585c963204ad9127998b1c1ce | static int cow_find_streak(const uint8_t *bitmap, int value, int start, int nb_sectors)
{
int streak_value = value ? 0xFF : 0;
int last = MIN(start + nb_sectors, BITS_PER_BITMAP_SECTOR);
int bitnum = start;
while (bitnum < last) {
if ((bitnum & 7) == 0 && bitmap[bitnum / 8] == streak_value) {
bitnum += 8;
continue;
}
if (cow_test_bit(bitnum, bitmap) == value) {
bitnum++;
continue;
}
break;
}
return MIN(bitnum, last) - start;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(const uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3)
{
int VAR_4 = VAR_1 ? 0xFF : 0;
int VAR_5 = MIN(VAR_2 + VAR_3, BITS_PER_BITMAP_SECTOR);
int VAR_6 = VAR_2;
while (VAR_6 < VAR_5) {
if ((VAR_6 & 7) == 0 && VAR_0[VAR_6 / 8] == VAR_4) {
VAR_6 += 8;
continue;
}
if (cow_test_bit(VAR_6, VAR_0) == VAR_1) {
VAR_6++;
continue;
}
break;
}
return MIN(VAR_6, VAR_5) - VAR_2;
}
| [
"static int FUNC_0(const uint8_t *VAR_0, int VAR_1, int VAR_2, int VAR_3)\n{",
"int VAR_4 = VAR_1 ? 0xFF : 0;",
"int VAR_5 = MIN(VAR_2 + VAR_3, BITS_PER_BITMAP_SECTOR);",
"int VAR_6 = VAR_2;",
"while (VAR_6 < VAR_5) {",
"if ((VAR_6 & 7) == 0 && VAR_0[VAR_6 / 8] == VAR_4) {",
"VAR_6 += 8;",
"continue;",
"}",
"if (cow_test_bit(VAR_6, VAR_0) == VAR_1) {",
"VAR_6++;",
"continue;",
"}",
"break;",
"}",
"return MIN(VAR_6, VAR_5) - VAR_2;",
"}"
] | [
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
]
] |
25,106 | static int raw_read_options(QDict *options, BlockDriverState *bs,
BDRVRawState *s, Error **errp)
{
Error *local_err = NULL;
QemuOpts *opts = NULL;
int64_t real_size = 0;
int ret;
real_size = bdrv_getlength(bs->file->bs);
if (real_size < 0) {
error_setg_errno(errp, -real_size, "Could not get image size");
return real_size;
}
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto end;
}
s->offset = qemu_opt_get_size(opts, "offset", 0);
if (s->offset > real_size) {
error_setg(errp, "Offset (%" PRIu64 ") cannot be greater than "
"size of the containing file (%" PRId64 ")",
s->offset, real_size);
ret = -EINVAL;
goto end;
}
if (qemu_opt_find(opts, "size") != NULL) {
s->size = qemu_opt_get_size(opts, "size", 0);
s->has_size = true;
} else {
s->has_size = false;
s->size = real_size - s->offset;
}
/* Check size and offset */
if ((real_size - s->offset) < s->size) {
error_setg(errp, "The sum of offset (%" PRIu64 ") and size "
"(%" PRIu64 ") has to be smaller or equal to the "
" actual size of the containing file (%" PRId64 ")",
s->offset, s->size, real_size);
ret = -EINVAL;
goto end;
}
/* Make sure size is multiple of BDRV_SECTOR_SIZE to prevent rounding
* up and leaking out of the specified area. */
if (s->has_size && !QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) {
error_setg(errp, "Specified size is not multiple of %llu",
BDRV_SECTOR_SIZE);
ret = -EINVAL;
goto end;
}
ret = 0;
end:
qemu_opts_del(opts);
return ret;
}
| false | qemu | 2e6fc7eb1a4af1b127df5f07b8bb28af891946fa | static int raw_read_options(QDict *options, BlockDriverState *bs,
BDRVRawState *s, Error **errp)
{
Error *local_err = NULL;
QemuOpts *opts = NULL;
int64_t real_size = 0;
int ret;
real_size = bdrv_getlength(bs->file->bs);
if (real_size < 0) {
error_setg_errno(errp, -real_size, "Could not get image size");
return real_size;
}
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, options, &local_err);
if (local_err) {
error_propagate(errp, local_err);
ret = -EINVAL;
goto end;
}
s->offset = qemu_opt_get_size(opts, "offset", 0);
if (s->offset > real_size) {
error_setg(errp, "Offset (%" PRIu64 ") cannot be greater than "
"size of the containing file (%" PRId64 ")",
s->offset, real_size);
ret = -EINVAL;
goto end;
}
if (qemu_opt_find(opts, "size") != NULL) {
s->size = qemu_opt_get_size(opts, "size", 0);
s->has_size = true;
} else {
s->has_size = false;
s->size = real_size - s->offset;
}
if ((real_size - s->offset) < s->size) {
error_setg(errp, "The sum of offset (%" PRIu64 ") and size "
"(%" PRIu64 ") has to be smaller or equal to the "
" actual size of the containing file (%" PRId64 ")",
s->offset, s->size, real_size);
ret = -EINVAL;
goto end;
}
if (s->has_size && !QEMU_IS_ALIGNED(s->size, BDRV_SECTOR_SIZE)) {
error_setg(errp, "Specified size is not multiple of %llu",
BDRV_SECTOR_SIZE);
ret = -EINVAL;
goto end;
}
ret = 0;
end:
qemu_opts_del(opts);
return ret;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(QDict *VAR_0, BlockDriverState *VAR_1,
BDRVRawState *VAR_2, Error **VAR_3)
{
Error *local_err = NULL;
QemuOpts *opts = NULL;
int64_t real_size = 0;
int VAR_4;
real_size = bdrv_getlength(VAR_1->file->VAR_1);
if (real_size < 0) {
error_setg_errno(VAR_3, -real_size, "Could not get image size");
return real_size;
}
opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);
qemu_opts_absorb_qdict(opts, VAR_0, &local_err);
if (local_err) {
error_propagate(VAR_3, local_err);
VAR_4 = -EINVAL;
goto end;
}
VAR_2->offset = qemu_opt_get_size(opts, "offset", 0);
if (VAR_2->offset > real_size) {
error_setg(VAR_3, "Offset (%" PRIu64 ") cannot be greater than "
"size of the containing file (%" PRId64 ")",
VAR_2->offset, real_size);
VAR_4 = -EINVAL;
goto end;
}
if (qemu_opt_find(opts, "size") != NULL) {
VAR_2->size = qemu_opt_get_size(opts, "size", 0);
VAR_2->has_size = true;
} else {
VAR_2->has_size = false;
VAR_2->size = real_size - VAR_2->offset;
}
if ((real_size - VAR_2->offset) < VAR_2->size) {
error_setg(VAR_3, "The sum of offset (%" PRIu64 ") and size "
"(%" PRIu64 ") has to be smaller or equal to the "
" actual size of the containing file (%" PRId64 ")",
VAR_2->offset, VAR_2->size, real_size);
VAR_4 = -EINVAL;
goto end;
}
if (VAR_2->has_size && !QEMU_IS_ALIGNED(VAR_2->size, BDRV_SECTOR_SIZE)) {
error_setg(VAR_3, "Specified size is not multiple of %llu",
BDRV_SECTOR_SIZE);
VAR_4 = -EINVAL;
goto end;
}
VAR_4 = 0;
end:
qemu_opts_del(opts);
return VAR_4;
}
| [
"static int FUNC_0(QDict *VAR_0, BlockDriverState *VAR_1,\nBDRVRawState *VAR_2, Error **VAR_3)\n{",
"Error *local_err = NULL;",
"QemuOpts *opts = NULL;",
"int64_t real_size = 0;",
"int VAR_4;",
"real_size = bdrv_getlength(VAR_1->file->VAR_1);",
"if (real_size < 0) {",
"error_setg_errno(VAR_3, -real_size, \"Could not get image size\");",
"return real_size;",
"}",
"opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort);",
"qemu_opts_absorb_qdict(opts, VAR_0, &local_err);",
"if (local_err) {",
"error_propagate(VAR_3, local_err);",
"VAR_4 = -EINVAL;",
"goto end;",
"}",
"VAR_2->offset = qemu_opt_get_size(opts, \"offset\", 0);",
"if (VAR_2->offset > real_size) {",
"error_setg(VAR_3, \"Offset (%\" PRIu64 \") cannot be greater than \"\n\"size of the containing file (%\" PRId64 \")\",\nVAR_2->offset, real_size);",
"VAR_4 = -EINVAL;",
"goto end;",
"}",
"if (qemu_opt_find(opts, \"size\") != NULL) {",
"VAR_2->size = qemu_opt_get_size(opts, \"size\", 0);",
"VAR_2->has_size = true;",
"} else {",
"VAR_2->has_size = false;",
"VAR_2->size = real_size - VAR_2->offset;",
"}",
"if ((real_size - VAR_2->offset) < VAR_2->size) {",
"error_setg(VAR_3, \"The sum of offset (%\" PRIu64 \") and size \"\n\"(%\" PRIu64 \") has to be smaller or equal to the \"\n\" actual size of the containing file (%\" PRId64 \")\",\nVAR_2->offset, VAR_2->size, real_size);",
"VAR_4 = -EINVAL;",
"goto end;",
"}",
"if (VAR_2->has_size && !QEMU_IS_ALIGNED(VAR_2->size, BDRV_SECTOR_SIZE)) {",
"error_setg(VAR_3, \"Specified size is not multiple of %llu\",\nBDRV_SECTOR_SIZE);",
"VAR_4 = -EINVAL;",
"goto end;",
"}",
"VAR_4 = 0;",
"end:\nqemu_opts_del(opts);",
"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
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47
],
[
49,
51,
53
],
[
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
81
],
[
83,
85,
87,
89
],
[
91
],
[
93
],
[
95
],
[
103
],
[
105,
107
],
[
109
],
[
111
],
[
113
],
[
117
],
[
121,
125
],
[
129
],
[
131
]
] |
25,107 | static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
long dstWidth, const uint8_t *src, int srcW,
int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hLumFilterPos;
int16_t *filter = c->hLumFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->lumMmx2FilterCode;
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %5 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t" // i
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#if ARCH_X86_64
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif /* ARCH_X86_64 */
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %5, %%"REG_b" \n\t"
#endif
:: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128;
} else {
#endif /* COMPILE_TEMPLATE_MMX2 */
x86_reg xInc_shr16 = xInc >> 16;
uint16_t xInc_mask = xInc & 0xffff;
x86_reg dstWidth_reg = dstWidth;
//NO MMX just normal asm ...
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t" // i
"xor %%"REG_d", %%"REG_d" \n\t" // xx
"xorl %%ecx, %%ecx \n\t" // xalpha
".p2align 4 \n\t"
"1: \n\t"
"movzbl (%0, %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%0, %%"REG_d"), %%esi \n\t" //src[xx+1]
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t" //xalpha += xInc&0xFFFF
"adc %3, %%"REG_d" \n\t" //xx+= xInc>>16 + carry
"movzbl (%0, %%"REG_d"), %%edi \n\t" //src[xx]
"movzbl 1(%0, %%"REG_d"), %%esi \n\t" //src[xx+1]
FAST_BILINEAR_X86
"movw %%si, 2(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t" //xalpha += xInc&0xFFFF
"adc %3, %%"REG_d" \n\t" //xx+= xInc>>16 + carry
"add $2, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
} //if MMX2 can't be used
#endif
#else
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
xpos+=xInc;
}
#endif /* ARCH_X86 */
}
| false | FFmpeg | d1adad3cca407f493c3637e20ecd4f7124e69212 | static inline void RENAME(hyscale_fast)(SwsContext *c, int16_t *dst,
long dstWidth, const uint8_t *src, int srcW,
int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hLumFilterPos;
int16_t *filter = c->hLumFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->lumMmx2FilterCode;
int i;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %5 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#if ARCH_X86_64
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %5, %%"REG_b" \n\t"
#endif
:: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) dst[i] = src[srcW-1]*128;
} else {
#endif
x86_reg xInc_shr16 = xInc >> 16;
uint16_t xInc_mask = xInc & 0xffff;
x86_reg dstWidth_reg = dstWidth;
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_d", %%"REG_d" \n\t"
"xorl %%ecx, %%ecx \n\t"
".p2align 4 \n\t"
"1: \n\t"
"movzbl (%0, %%"REG_d"), %%edi \n\t"
"movzbl 1(%0, %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"movzbl (%0, %%"REG_d"), %%edi \n\t"
"movzbl 1(%0, %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, 2(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $2, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
}
#endif
#else
int i;
unsigned int xpos=0;
for (i=0;i<dstWidth;i++) {
register unsigned int xx=xpos>>16;
register unsigned int xalpha=(xpos&0xFFFF)>>9;
dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
xpos+=xInc;
}
#endif
}
| {
"code": [],
"line_no": []
} | static inline void FUNC_0(hyscale_fast)(SwsContext *c, int16_t *dst,
long dstWidth, const uint8_t *src, int srcW,
int xInc)
{
#if ARCH_X86
#if COMPILE_TEMPLATE_MMX2
int32_t *filterPos = c->hLumFilterPos;
int16_t *filter = c->hLumFilter;
int canMMX2BeUsed = c->canMMX2BeUsed;
void *mmx2FilterCode= c->lumMmx2FilterCode;
int VAR_0;
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
if (canMMX2BeUsed) {
__asm__ volatile(
#if defined(PIC)
"mov %%"REG_b", %5 \n\t"
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"REG_c" \n\t"
"mov %1, %%"REG_D" \n\t"
"mov %2, %%"REG_d" \n\t"
"mov %3, %%"REG_b" \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
PREFETCH" (%%"REG_c") \n\t"
PREFETCH" 32(%%"REG_c") \n\t"
PREFETCH" 64(%%"REG_c") \n\t"
#if ARCH_X86_64
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"movl (%%"REG_b", %%"REG_a"), %%esi \n\t"\
"add %%"REG_S", %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#else
#define CALL_MMX2_FILTER_CODE \
"movl (%%"REG_b"), %%esi \n\t"\
"call *%4 \n\t"\
"addl (%%"REG_b", %%"REG_a"), %%"REG_c" \n\t"\
"add %%"REG_a", %%"REG_D" \n\t"\
"xor %%"REG_a", %%"REG_a" \n\t"\
#endif
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
CALL_MMX2_FILTER_CODE
#if defined(PIC)
"mov %5, %%"REG_b" \n\t"
#endif
:: "m" (src), "m" (dst), "m" (filter), "m" (filterPos),
"m" (mmx2FilterCode)
#if defined(PIC)
,"m" (ebxsave)
#endif
: "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S, "%"REG_D
#if !defined(PIC)
,"%"REG_b
#endif
);
for (VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--) dst[VAR_0] = src[srcW-1]*128;
} else {
#endif
x86_reg xInc_shr16 = xInc >> 16;
uint16_t xInc_mask = xInc & 0xffff;
x86_reg dstWidth_reg = dstWidth;
__asm__ volatile(
"xor %%"REG_a", %%"REG_a" \n\t"
"xor %%"REG_d", %%"REG_d" \n\t"
"xorl %%ecx, %%ecx \n\t"
".p2align 4 \n\t"
"1: \n\t"
"movzbl (%0, %%"REG_d"), %%edi \n\t"
"movzbl 1(%0, %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, (%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"movzbl (%0, %%"REG_d"), %%edi \n\t"
"movzbl 1(%0, %%"REG_d"), %%esi \n\t"
FAST_BILINEAR_X86
"movw %%si, 2(%%"REG_D", %%"REG_a", 2) \n\t"
"addw %4, %%cx \n\t"
"adc %3, %%"REG_d" \n\t"
"add $2, %%"REG_a" \n\t"
"cmp %2, %%"REG_a" \n\t"
" jb 1b \n\t"
:: "r" (src), "m" (dst), "m" (dstWidth_reg), "m" (xInc_shr16), "m" (xInc_mask)
: "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
);
#if COMPILE_TEMPLATE_MMX2
}
#endif
#else
int VAR_0;
unsigned int VAR_1=0;
for (VAR_0=0;VAR_0<dstWidth;VAR_0++) {
register unsigned int xx=VAR_1>>16;
register unsigned int xalpha=(VAR_1&0xFFFF)>>9;
dst[VAR_0]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;
VAR_1+=xInc;
}
#endif
}
| [
"static inline void FUNC_0(hyscale_fast)(SwsContext *c, int16_t *dst,\nlong dstWidth, const uint8_t *src, int srcW,\nint xInc)\n{",
"#if ARCH_X86\n#if COMPILE_TEMPLATE_MMX2\nint32_t *filterPos = c->hLumFilterPos;",
"int16_t *filter = c->hLumFilter;",
"int canMMX2BeUsed = c->canMMX2BeUsed;",
"void *mmx2FilterCode= c->lumMmx2FilterCode;",
"int VAR_0;",
"#if defined(PIC)\nDECLARE_ALIGNED(8, uint64_t, ebxsave);",
"#endif\nif (canMMX2BeUsed) {",
"__asm__ volatile(\n#if defined(PIC)\n\"mov %%\"REG_b\", %5 \\n\\t\"\n#endif\n\"pxor %%mm7, %%mm7 \\n\\t\"\n\"mov %0, %%\"REG_c\" \\n\\t\"\n\"mov %1, %%\"REG_D\" \\n\\t\"\n\"mov %2, %%\"REG_d\" \\n\\t\"\n\"mov %3, %%\"REG_b\" \\n\\t\"\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\nPREFETCH\" (%%\"REG_c\") \\n\\t\"\nPREFETCH\" 32(%%\"REG_c\") \\n\\t\"\nPREFETCH\" 64(%%\"REG_c\") \\n\\t\"\n#if ARCH_X86_64\n#define CALL_MMX2_FILTER_CODE \\\n\"movl (%%\"REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"movl (%%\"REG_b\", %%\"REG_a\"), %%esi \\n\\t\"\\\n\"add %%\"REG_S\", %%\"REG_c\" \\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\" \\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\\\n#else\n#define CALL_MMX2_FILTER_CODE \\\n\"movl (%%\"REG_b\"), %%esi \\n\\t\"\\\n\"call *%4 \\n\\t\"\\\n\"addl (%%\"REG_b\", %%\"REG_a\"), %%\"REG_c\" \\n\\t\"\\\n\"add %%\"REG_a\", %%\"REG_D\" \\n\\t\"\\\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\\\n#endif\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\nCALL_MMX2_FILTER_CODE\n#if defined(PIC)\n\"mov %5, %%\"REG_b\" \\n\\t\"\n#endif\n:: \"m\" (src), \"m\" (dst), \"m\" (filter), \"m\" (filterPos),\n\"m\" (mmx2FilterCode)\n#if defined(PIC)\n,\"m\" (ebxsave)\n#endif\n: \"%\"REG_a, \"%\"REG_c, \"%\"REG_d, \"%\"REG_S, \"%\"REG_D\n#if !defined(PIC)\n,\"%\"REG_b\n#endif\n);",
"for (VAR_0=dstWidth-1; (VAR_0*xInc)>>16 >=srcW-1; VAR_0--) dst[VAR_0] = src[srcW-1]*128;",
"} else {",
"#endif\nx86_reg xInc_shr16 = xInc >> 16;",
"uint16_t xInc_mask = xInc & 0xffff;",
"x86_reg dstWidth_reg = dstWidth;",
"__asm__ volatile(\n\"xor %%\"REG_a\", %%\"REG_a\" \\n\\t\"\n\"xor %%\"REG_d\", %%\"REG_d\" \\n\\t\"\n\"xorl %%ecx, %%ecx \\n\\t\"\n\".p2align 4 \\n\\t\"\n\"1: \\n\\t\"\n\"movzbl (%0, %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%0, %%\"REG_d\"), %%esi \\n\\t\"\nFAST_BILINEAR_X86\n\"movw %%si, (%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"addw %4, %%cx \\n\\t\"\n\"adc %3, %%\"REG_d\" \\n\\t\"\n\"movzbl (%0, %%\"REG_d\"), %%edi \\n\\t\"\n\"movzbl 1(%0, %%\"REG_d\"), %%esi \\n\\t\"\nFAST_BILINEAR_X86\n\"movw %%si, 2(%%\"REG_D\", %%\"REG_a\", 2) \\n\\t\"\n\"addw %4, %%cx \\n\\t\"\n\"adc %3, %%\"REG_d\" \\n\\t\"\n\"add $2, %%\"REG_a\" \\n\\t\"\n\"cmp %2, %%\"REG_a\" \\n\\t\"\n\" jb 1b \\n\\t\"\n:: \"r\" (src), \"m\" (dst), \"m\" (dstWidth_reg), \"m\" (xInc_shr16), \"m\" (xInc_mask)\n: \"%\"REG_a, \"%\"REG_d, \"%ecx\", \"%\"REG_D, \"%esi\"\n);",
"#if COMPILE_TEMPLATE_MMX2\n}",
"#endif\n#else\nint VAR_0;",
"unsigned int VAR_1=0;",
"for (VAR_0=0;VAR_0<dstWidth;VAR_0++) {",
"register unsigned int xx=VAR_1>>16;",
"register unsigned int xalpha=(VAR_1&0xFFFF)>>9;",
"dst[VAR_0]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha;",
"VAR_1+=xInc;",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
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,
53,
55,
59,
63,
65,
67,
69,
71,
73,
75,
79,
83,
85,
87,
89,
91,
93,
97,
101,
103,
105,
107,
109,
111,
113,
115,
119,
121,
123,
125,
127,
129,
131,
133,
135,
137,
139,
141,
143
],
[
145
],
[
147
],
[
149,
151
],
[
153
],
[
155
],
[
159,
161,
163,
165,
167,
169,
171,
173,
175,
177,
179,
181,
185,
187,
189,
191,
193,
195,
201,
203,
205,
211,
213,
215
],
[
217,
219
],
[
221,
223,
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241,
243
]
] |
25,108 | bool memory_region_is_skip_dump(MemoryRegion *mr)
{
return mr->skip_dump;
}
| false | qemu | 21e00fa55f3fdfcbb20da7c6876c91ef3609b387 | bool memory_region_is_skip_dump(MemoryRegion *mr)
{
return mr->skip_dump;
}
| {
"code": [],
"line_no": []
} | bool FUNC_0(MemoryRegion *mr)
{
return mr->skip_dump;
}
| [
"bool FUNC_0(MemoryRegion *mr)\n{",
"return mr->skip_dump;",
"}"
] | [
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
]
] |
25,109 | static ssize_t nbd_send_reply(int csock, struct nbd_reply *reply)
{
uint8_t buf[4 + 4 + 8];
/* Reply
[ 0 .. 3] magic (NBD_REPLY_MAGIC)
[ 4 .. 7] error (0 == no error)
[ 7 .. 15] handle
*/
cpu_to_be32w((uint32_t*)buf, NBD_REPLY_MAGIC);
cpu_to_be32w((uint32_t*)(buf + 4), reply->error);
cpu_to_be64w((uint64_t*)(buf + 8), reply->handle);
TRACE("Sending response to client");
if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {
LOG("writing to socket failed");
errno = EINVAL;
return -1;
}
return 0;
}
| false | qemu | 185b43386ad999c80bdc58e41b87f05e5b3e8463 | static ssize_t nbd_send_reply(int csock, struct nbd_reply *reply)
{
uint8_t buf[4 + 4 + 8];
cpu_to_be32w((uint32_t*)buf, NBD_REPLY_MAGIC);
cpu_to_be32w((uint32_t*)(buf + 4), reply->error);
cpu_to_be64w((uint64_t*)(buf + 8), reply->handle);
TRACE("Sending response to client");
if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {
LOG("writing to socket failed");
errno = EINVAL;
return -1;
}
return 0;
}
| {
"code": [],
"line_no": []
} | static ssize_t FUNC_0(int csock, struct nbd_reply *reply)
{
uint8_t buf[4 + 4 + 8];
cpu_to_be32w((uint32_t*)buf, NBD_REPLY_MAGIC);
cpu_to_be32w((uint32_t*)(buf + 4), reply->error);
cpu_to_be64w((uint64_t*)(buf + 8), reply->handle);
TRACE("Sending response to client");
if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {
LOG("writing to socket failed");
errno = EINVAL;
return -1;
}
return 0;
}
| [
"static ssize_t FUNC_0(int csock, struct nbd_reply *reply)\n{",
"uint8_t buf[4 + 4 + 8];",
"cpu_to_be32w((uint32_t*)buf, NBD_REPLY_MAGIC);",
"cpu_to_be32w((uint32_t*)(buf + 4), reply->error);",
"cpu_to_be64w((uint64_t*)(buf + 8), reply->handle);",
"TRACE(\"Sending response to client\");",
"if (write_sync(csock, buf, sizeof(buf)) != sizeof(buf)) {",
"LOG(\"writing to socket failed\");",
"errno = EINVAL;",
"return -1;",
"}",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
19
],
[
21
],
[
23
],
[
27
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
]
] |
25,110 | static void switch_tss(CPUX86State *env, int tss_selector,
uint32_t e1, uint32_t e2, int source,
uint32_t next_eip)
{
int tss_limit, tss_limit_max, type, old_tss_limit_max, old_type, v1, v2, i;
target_ulong tss_base;
uint32_t new_regs[8], new_segs[6];
uint32_t new_eflags, new_eip, new_cr3, new_ldt, new_trap;
uint32_t old_eflags, eflags_mask;
SegmentCache *dt;
int index;
target_ulong ptr;
type = (e2 >> DESC_TYPE_SHIFT) & 0xf;
LOG_PCALL("switch_tss: sel=0x%04x type=%d src=%d\n", tss_selector, type,
source);
/* if task gate, we read the TSS segment and we load it */
if (type == 5) {
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0B_NOSEG, tss_selector & 0xfffc);
}
tss_selector = e1 >> 16;
if (tss_selector & 4) {
raise_exception_err(env, EXCP0A_TSS, tss_selector & 0xfffc);
}
if (load_segment(env, &e1, &e2, tss_selector) != 0) {
raise_exception_err(env, EXCP0D_GPF, tss_selector & 0xfffc);
}
if (e2 & DESC_S_MASK) {
raise_exception_err(env, EXCP0D_GPF, tss_selector & 0xfffc);
}
type = (e2 >> DESC_TYPE_SHIFT) & 0xf;
if ((type & 7) != 1) {
raise_exception_err(env, EXCP0D_GPF, tss_selector & 0xfffc);
}
}
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0B_NOSEG, tss_selector & 0xfffc);
}
if (type & 8) {
tss_limit_max = 103;
} else {
tss_limit_max = 43;
}
tss_limit = get_seg_limit(e1, e2);
tss_base = get_seg_base(e1, e2);
if ((tss_selector & 4) != 0 ||
tss_limit < tss_limit_max) {
raise_exception_err(env, EXCP0A_TSS, tss_selector & 0xfffc);
}
old_type = (env->tr.flags >> DESC_TYPE_SHIFT) & 0xf;
if (old_type & 8) {
old_tss_limit_max = 103;
} else {
old_tss_limit_max = 43;
}
/* read all the registers from the new TSS */
if (type & 8) {
/* 32 bit */
new_cr3 = cpu_ldl_kernel(env, tss_base + 0x1c);
new_eip = cpu_ldl_kernel(env, tss_base + 0x20);
new_eflags = cpu_ldl_kernel(env, tss_base + 0x24);
for (i = 0; i < 8; i++) {
new_regs[i] = cpu_ldl_kernel(env, tss_base + (0x28 + i * 4));
}
for (i = 0; i < 6; i++) {
new_segs[i] = cpu_lduw_kernel(env, tss_base + (0x48 + i * 4));
}
new_ldt = cpu_lduw_kernel(env, tss_base + 0x60);
new_trap = cpu_ldl_kernel(env, tss_base + 0x64);
} else {
/* 16 bit */
new_cr3 = 0;
new_eip = cpu_lduw_kernel(env, tss_base + 0x0e);
new_eflags = cpu_lduw_kernel(env, tss_base + 0x10);
for (i = 0; i < 8; i++) {
new_regs[i] = cpu_lduw_kernel(env, tss_base + (0x12 + i * 2)) |
0xffff0000;
}
for (i = 0; i < 4; i++) {
new_segs[i] = cpu_lduw_kernel(env, tss_base + (0x22 + i * 4));
}
new_ldt = cpu_lduw_kernel(env, tss_base + 0x2a);
new_segs[R_FS] = 0;
new_segs[R_GS] = 0;
new_trap = 0;
}
/* XXX: avoid a compiler warning, see
http://support.amd.com/us/Processor_TechDocs/24593.pdf
chapters 12.2.5 and 13.2.4 on how to implement TSS Trap bit */
(void)new_trap;
/* NOTE: we must avoid memory exceptions during the task switch,
so we make dummy accesses before */
/* XXX: it can still fail in some cases, so a bigger hack is
necessary to valid the TLB after having done the accesses */
v1 = cpu_ldub_kernel(env, env->tr.base);
v2 = cpu_ldub_kernel(env, env->tr.base + old_tss_limit_max);
cpu_stb_kernel(env, env->tr.base, v1);
cpu_stb_kernel(env, env->tr.base + old_tss_limit_max, v2);
/* clear busy bit (it is restartable) */
if (source == SWITCH_TSS_JMP || source == SWITCH_TSS_IRET) {
target_ulong ptr;
uint32_t e2;
ptr = env->gdt.base + (env->tr.selector & ~7);
e2 = cpu_ldl_kernel(env, ptr + 4);
e2 &= ~DESC_TSS_BUSY_MASK;
cpu_stl_kernel(env, ptr + 4, e2);
}
old_eflags = cpu_compute_eflags(env);
if (source == SWITCH_TSS_IRET) {
old_eflags &= ~NT_MASK;
}
/* save the current state in the old TSS */
if (type & 8) {
/* 32 bit */
cpu_stl_kernel(env, env->tr.base + 0x20, next_eip);
cpu_stl_kernel(env, env->tr.base + 0x24, old_eflags);
cpu_stl_kernel(env, env->tr.base + (0x28 + 0 * 4), env->regs[R_EAX]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 1 * 4), env->regs[R_ECX]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 2 * 4), env->regs[R_EDX]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 3 * 4), env->regs[R_EBX]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 4 * 4), env->regs[R_ESP]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 5 * 4), env->regs[R_EBP]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 6 * 4), env->regs[R_ESI]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 7 * 4), env->regs[R_EDI]);
for (i = 0; i < 6; i++) {
cpu_stw_kernel(env, env->tr.base + (0x48 + i * 4),
env->segs[i].selector);
}
} else {
/* 16 bit */
cpu_stw_kernel(env, env->tr.base + 0x0e, next_eip);
cpu_stw_kernel(env, env->tr.base + 0x10, old_eflags);
cpu_stw_kernel(env, env->tr.base + (0x12 + 0 * 2), env->regs[R_EAX]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 1 * 2), env->regs[R_ECX]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 2 * 2), env->regs[R_EDX]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 3 * 2), env->regs[R_EBX]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 4 * 2), env->regs[R_ESP]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 5 * 2), env->regs[R_EBP]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 6 * 2), env->regs[R_ESI]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 7 * 2), env->regs[R_EDI]);
for (i = 0; i < 4; i++) {
cpu_stw_kernel(env, env->tr.base + (0x22 + i * 4),
env->segs[i].selector);
}
}
/* now if an exception occurs, it will occurs in the next task
context */
if (source == SWITCH_TSS_CALL) {
cpu_stw_kernel(env, tss_base, env->tr.selector);
new_eflags |= NT_MASK;
}
/* set busy bit */
if (source == SWITCH_TSS_JMP || source == SWITCH_TSS_CALL) {
target_ulong ptr;
uint32_t e2;
ptr = env->gdt.base + (tss_selector & ~7);
e2 = cpu_ldl_kernel(env, ptr + 4);
e2 |= DESC_TSS_BUSY_MASK;
cpu_stl_kernel(env, ptr + 4, e2);
}
/* set the new CPU state */
/* from this point, any exception which occurs can give problems */
env->cr[0] |= CR0_TS_MASK;
env->hflags |= HF_TS_MASK;
env->tr.selector = tss_selector;
env->tr.base = tss_base;
env->tr.limit = tss_limit;
env->tr.flags = e2 & ~DESC_TSS_BUSY_MASK;
if ((type & 8) && (env->cr[0] & CR0_PG_MASK)) {
cpu_x86_update_cr3(env, new_cr3);
}
/* load all registers without an exception, then reload them with
possible exception */
env->eip = new_eip;
eflags_mask = TF_MASK | AC_MASK | ID_MASK |
IF_MASK | IOPL_MASK | VM_MASK | RF_MASK | NT_MASK;
if (!(type & 8)) {
eflags_mask &= 0xffff;
}
cpu_load_eflags(env, new_eflags, eflags_mask);
/* XXX: what to do in 16 bit case? */
env->regs[R_EAX] = new_regs[0];
env->regs[R_ECX] = new_regs[1];
env->regs[R_EDX] = new_regs[2];
env->regs[R_EBX] = new_regs[3];
env->regs[R_ESP] = new_regs[4];
env->regs[R_EBP] = new_regs[5];
env->regs[R_ESI] = new_regs[6];
env->regs[R_EDI] = new_regs[7];
if (new_eflags & VM_MASK) {
for (i = 0; i < 6; i++) {
load_seg_vm(env, i, new_segs[i]);
}
/* in vm86, CPL is always 3 */
cpu_x86_set_cpl(env, 3);
} else {
/* CPL is set the RPL of CS */
cpu_x86_set_cpl(env, new_segs[R_CS] & 3);
/* first just selectors as the rest may trigger exceptions */
for (i = 0; i < 6; i++) {
cpu_x86_load_seg_cache(env, i, new_segs[i], 0, 0, 0);
}
}
env->ldt.selector = new_ldt & ~4;
env->ldt.base = 0;
env->ldt.limit = 0;
env->ldt.flags = 0;
/* load the LDT */
if (new_ldt & 4) {
raise_exception_err(env, EXCP0A_TSS, new_ldt & 0xfffc);
}
if ((new_ldt & 0xfffc) != 0) {
dt = &env->gdt;
index = new_ldt & ~7;
if ((index + 7) > dt->limit) {
raise_exception_err(env, EXCP0A_TSS, new_ldt & 0xfffc);
}
ptr = dt->base + index;
e1 = cpu_ldl_kernel(env, ptr);
e2 = cpu_ldl_kernel(env, ptr + 4);
if ((e2 & DESC_S_MASK) || ((e2 >> DESC_TYPE_SHIFT) & 0xf) != 2) {
raise_exception_err(env, EXCP0A_TSS, new_ldt & 0xfffc);
}
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0A_TSS, new_ldt & 0xfffc);
}
load_seg_cache_raw_dt(&env->ldt, e1, e2);
}
/* load the segments */
if (!(new_eflags & VM_MASK)) {
tss_load_seg(env, R_CS, new_segs[R_CS]);
tss_load_seg(env, R_SS, new_segs[R_SS]);
tss_load_seg(env, R_ES, new_segs[R_ES]);
tss_load_seg(env, R_DS, new_segs[R_DS]);
tss_load_seg(env, R_FS, new_segs[R_FS]);
tss_load_seg(env, R_GS, new_segs[R_GS]);
}
/* check that env->eip is in the CS segment limits */
if (new_eip > env->segs[R_CS].limit) {
/* XXX: different exception if CALL? */
raise_exception_err(env, EXCP0D_GPF, 0);
}
#ifndef CONFIG_USER_ONLY
/* reset local breakpoints */
if (env->dr[7] & DR7_LOCAL_BP_MASK) {
for (i = 0; i < DR7_MAX_BP; i++) {
if (hw_local_breakpoint_enabled(env->dr[7], i) &&
!hw_global_breakpoint_enabled(env->dr[7], i)) {
hw_breakpoint_remove(env, i);
}
}
env->dr[7] &= ~DR7_LOCAL_BP_MASK;
}
#endif
}
| false | qemu | 7848c8d19f8556666df25044bbd5d8b29439c368 | static void switch_tss(CPUX86State *env, int tss_selector,
uint32_t e1, uint32_t e2, int source,
uint32_t next_eip)
{
int tss_limit, tss_limit_max, type, old_tss_limit_max, old_type, v1, v2, i;
target_ulong tss_base;
uint32_t new_regs[8], new_segs[6];
uint32_t new_eflags, new_eip, new_cr3, new_ldt, new_trap;
uint32_t old_eflags, eflags_mask;
SegmentCache *dt;
int index;
target_ulong ptr;
type = (e2 >> DESC_TYPE_SHIFT) & 0xf;
LOG_PCALL("switch_tss: sel=0x%04x type=%d src=%d\n", tss_selector, type,
source);
if (type == 5) {
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0B_NOSEG, tss_selector & 0xfffc);
}
tss_selector = e1 >> 16;
if (tss_selector & 4) {
raise_exception_err(env, EXCP0A_TSS, tss_selector & 0xfffc);
}
if (load_segment(env, &e1, &e2, tss_selector) != 0) {
raise_exception_err(env, EXCP0D_GPF, tss_selector & 0xfffc);
}
if (e2 & DESC_S_MASK) {
raise_exception_err(env, EXCP0D_GPF, tss_selector & 0xfffc);
}
type = (e2 >> DESC_TYPE_SHIFT) & 0xf;
if ((type & 7) != 1) {
raise_exception_err(env, EXCP0D_GPF, tss_selector & 0xfffc);
}
}
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0B_NOSEG, tss_selector & 0xfffc);
}
if (type & 8) {
tss_limit_max = 103;
} else {
tss_limit_max = 43;
}
tss_limit = get_seg_limit(e1, e2);
tss_base = get_seg_base(e1, e2);
if ((tss_selector & 4) != 0 ||
tss_limit < tss_limit_max) {
raise_exception_err(env, EXCP0A_TSS, tss_selector & 0xfffc);
}
old_type = (env->tr.flags >> DESC_TYPE_SHIFT) & 0xf;
if (old_type & 8) {
old_tss_limit_max = 103;
} else {
old_tss_limit_max = 43;
}
if (type & 8) {
new_cr3 = cpu_ldl_kernel(env, tss_base + 0x1c);
new_eip = cpu_ldl_kernel(env, tss_base + 0x20);
new_eflags = cpu_ldl_kernel(env, tss_base + 0x24);
for (i = 0; i < 8; i++) {
new_regs[i] = cpu_ldl_kernel(env, tss_base + (0x28 + i * 4));
}
for (i = 0; i < 6; i++) {
new_segs[i] = cpu_lduw_kernel(env, tss_base + (0x48 + i * 4));
}
new_ldt = cpu_lduw_kernel(env, tss_base + 0x60);
new_trap = cpu_ldl_kernel(env, tss_base + 0x64);
} else {
new_cr3 = 0;
new_eip = cpu_lduw_kernel(env, tss_base + 0x0e);
new_eflags = cpu_lduw_kernel(env, tss_base + 0x10);
for (i = 0; i < 8; i++) {
new_regs[i] = cpu_lduw_kernel(env, tss_base + (0x12 + i * 2)) |
0xffff0000;
}
for (i = 0; i < 4; i++) {
new_segs[i] = cpu_lduw_kernel(env, tss_base + (0x22 + i * 4));
}
new_ldt = cpu_lduw_kernel(env, tss_base + 0x2a);
new_segs[R_FS] = 0;
new_segs[R_GS] = 0;
new_trap = 0;
}
(void)new_trap;
v1 = cpu_ldub_kernel(env, env->tr.base);
v2 = cpu_ldub_kernel(env, env->tr.base + old_tss_limit_max);
cpu_stb_kernel(env, env->tr.base, v1);
cpu_stb_kernel(env, env->tr.base + old_tss_limit_max, v2);
if (source == SWITCH_TSS_JMP || source == SWITCH_TSS_IRET) {
target_ulong ptr;
uint32_t e2;
ptr = env->gdt.base + (env->tr.selector & ~7);
e2 = cpu_ldl_kernel(env, ptr + 4);
e2 &= ~DESC_TSS_BUSY_MASK;
cpu_stl_kernel(env, ptr + 4, e2);
}
old_eflags = cpu_compute_eflags(env);
if (source == SWITCH_TSS_IRET) {
old_eflags &= ~NT_MASK;
}
if (type & 8) {
cpu_stl_kernel(env, env->tr.base + 0x20, next_eip);
cpu_stl_kernel(env, env->tr.base + 0x24, old_eflags);
cpu_stl_kernel(env, env->tr.base + (0x28 + 0 * 4), env->regs[R_EAX]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 1 * 4), env->regs[R_ECX]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 2 * 4), env->regs[R_EDX]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 3 * 4), env->regs[R_EBX]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 4 * 4), env->regs[R_ESP]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 5 * 4), env->regs[R_EBP]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 6 * 4), env->regs[R_ESI]);
cpu_stl_kernel(env, env->tr.base + (0x28 + 7 * 4), env->regs[R_EDI]);
for (i = 0; i < 6; i++) {
cpu_stw_kernel(env, env->tr.base + (0x48 + i * 4),
env->segs[i].selector);
}
} else {
cpu_stw_kernel(env, env->tr.base + 0x0e, next_eip);
cpu_stw_kernel(env, env->tr.base + 0x10, old_eflags);
cpu_stw_kernel(env, env->tr.base + (0x12 + 0 * 2), env->regs[R_EAX]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 1 * 2), env->regs[R_ECX]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 2 * 2), env->regs[R_EDX]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 3 * 2), env->regs[R_EBX]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 4 * 2), env->regs[R_ESP]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 5 * 2), env->regs[R_EBP]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 6 * 2), env->regs[R_ESI]);
cpu_stw_kernel(env, env->tr.base + (0x12 + 7 * 2), env->regs[R_EDI]);
for (i = 0; i < 4; i++) {
cpu_stw_kernel(env, env->tr.base + (0x22 + i * 4),
env->segs[i].selector);
}
}
if (source == SWITCH_TSS_CALL) {
cpu_stw_kernel(env, tss_base, env->tr.selector);
new_eflags |= NT_MASK;
}
if (source == SWITCH_TSS_JMP || source == SWITCH_TSS_CALL) {
target_ulong ptr;
uint32_t e2;
ptr = env->gdt.base + (tss_selector & ~7);
e2 = cpu_ldl_kernel(env, ptr + 4);
e2 |= DESC_TSS_BUSY_MASK;
cpu_stl_kernel(env, ptr + 4, e2);
}
env->cr[0] |= CR0_TS_MASK;
env->hflags |= HF_TS_MASK;
env->tr.selector = tss_selector;
env->tr.base = tss_base;
env->tr.limit = tss_limit;
env->tr.flags = e2 & ~DESC_TSS_BUSY_MASK;
if ((type & 8) && (env->cr[0] & CR0_PG_MASK)) {
cpu_x86_update_cr3(env, new_cr3);
}
env->eip = new_eip;
eflags_mask = TF_MASK | AC_MASK | ID_MASK |
IF_MASK | IOPL_MASK | VM_MASK | RF_MASK | NT_MASK;
if (!(type & 8)) {
eflags_mask &= 0xffff;
}
cpu_load_eflags(env, new_eflags, eflags_mask);
env->regs[R_EAX] = new_regs[0];
env->regs[R_ECX] = new_regs[1];
env->regs[R_EDX] = new_regs[2];
env->regs[R_EBX] = new_regs[3];
env->regs[R_ESP] = new_regs[4];
env->regs[R_EBP] = new_regs[5];
env->regs[R_ESI] = new_regs[6];
env->regs[R_EDI] = new_regs[7];
if (new_eflags & VM_MASK) {
for (i = 0; i < 6; i++) {
load_seg_vm(env, i, new_segs[i]);
}
cpu_x86_set_cpl(env, 3);
} else {
cpu_x86_set_cpl(env, new_segs[R_CS] & 3);
for (i = 0; i < 6; i++) {
cpu_x86_load_seg_cache(env, i, new_segs[i], 0, 0, 0);
}
}
env->ldt.selector = new_ldt & ~4;
env->ldt.base = 0;
env->ldt.limit = 0;
env->ldt.flags = 0;
if (new_ldt & 4) {
raise_exception_err(env, EXCP0A_TSS, new_ldt & 0xfffc);
}
if ((new_ldt & 0xfffc) != 0) {
dt = &env->gdt;
index = new_ldt & ~7;
if ((index + 7) > dt->limit) {
raise_exception_err(env, EXCP0A_TSS, new_ldt & 0xfffc);
}
ptr = dt->base + index;
e1 = cpu_ldl_kernel(env, ptr);
e2 = cpu_ldl_kernel(env, ptr + 4);
if ((e2 & DESC_S_MASK) || ((e2 >> DESC_TYPE_SHIFT) & 0xf) != 2) {
raise_exception_err(env, EXCP0A_TSS, new_ldt & 0xfffc);
}
if (!(e2 & DESC_P_MASK)) {
raise_exception_err(env, EXCP0A_TSS, new_ldt & 0xfffc);
}
load_seg_cache_raw_dt(&env->ldt, e1, e2);
}
if (!(new_eflags & VM_MASK)) {
tss_load_seg(env, R_CS, new_segs[R_CS]);
tss_load_seg(env, R_SS, new_segs[R_SS]);
tss_load_seg(env, R_ES, new_segs[R_ES]);
tss_load_seg(env, R_DS, new_segs[R_DS]);
tss_load_seg(env, R_FS, new_segs[R_FS]);
tss_load_seg(env, R_GS, new_segs[R_GS]);
}
if (new_eip > env->segs[R_CS].limit) {
raise_exception_err(env, EXCP0D_GPF, 0);
}
#ifndef CONFIG_USER_ONLY
if (env->dr[7] & DR7_LOCAL_BP_MASK) {
for (i = 0; i < DR7_MAX_BP; i++) {
if (hw_local_breakpoint_enabled(env->dr[7], i) &&
!hw_global_breakpoint_enabled(env->dr[7], i)) {
hw_breakpoint_remove(env, i);
}
}
env->dr[7] &= ~DR7_LOCAL_BP_MASK;
}
#endif
}
| {
"code": [],
"line_no": []
} | static void FUNC_0(CPUX86State *VAR_0, int VAR_1,
uint32_t VAR_2, uint32_t VAR_3, int VAR_4,
uint32_t VAR_5)
{
int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;
target_ulong tss_base;
uint32_t new_regs[8], new_segs[6];
uint32_t new_eflags, new_eip, new_cr3, new_ldt, new_trap;
uint32_t old_eflags, eflags_mask;
SegmentCache *dt;
int VAR_14;
target_ulong ptr;
VAR_8 = (VAR_3 >> DESC_TYPE_SHIFT) & 0xf;
LOG_PCALL("FUNC_0: sel=0x%04x VAR_8=%d src=%d\n", VAR_1, VAR_8,
VAR_4);
if (VAR_8 == 5) {
if (!(VAR_3 & DESC_P_MASK)) {
raise_exception_err(VAR_0, EXCP0B_NOSEG, VAR_1 & 0xfffc);
}
VAR_1 = VAR_2 >> 16;
if (VAR_1 & 4) {
raise_exception_err(VAR_0, EXCP0A_TSS, VAR_1 & 0xfffc);
}
if (load_segment(VAR_0, &VAR_2, &VAR_3, VAR_1) != 0) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 & 0xfffc);
}
if (VAR_3 & DESC_S_MASK) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 & 0xfffc);
}
VAR_8 = (VAR_3 >> DESC_TYPE_SHIFT) & 0xf;
if ((VAR_8 & 7) != 1) {
raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 & 0xfffc);
}
}
if (!(VAR_3 & DESC_P_MASK)) {
raise_exception_err(VAR_0, EXCP0B_NOSEG, VAR_1 & 0xfffc);
}
if (VAR_8 & 8) {
VAR_7 = 103;
} else {
VAR_7 = 43;
}
VAR_6 = get_seg_limit(VAR_2, VAR_3);
tss_base = get_seg_base(VAR_2, VAR_3);
if ((VAR_1 & 4) != 0 ||
VAR_6 < VAR_7) {
raise_exception_err(VAR_0, EXCP0A_TSS, VAR_1 & 0xfffc);
}
VAR_10 = (VAR_0->tr.flags >> DESC_TYPE_SHIFT) & 0xf;
if (VAR_10 & 8) {
VAR_9 = 103;
} else {
VAR_9 = 43;
}
if (VAR_8 & 8) {
new_cr3 = cpu_ldl_kernel(VAR_0, tss_base + 0x1c);
new_eip = cpu_ldl_kernel(VAR_0, tss_base + 0x20);
new_eflags = cpu_ldl_kernel(VAR_0, tss_base + 0x24);
for (VAR_13 = 0; VAR_13 < 8; VAR_13++) {
new_regs[VAR_13] = cpu_ldl_kernel(VAR_0, tss_base + (0x28 + VAR_13 * 4));
}
for (VAR_13 = 0; VAR_13 < 6; VAR_13++) {
new_segs[VAR_13] = cpu_lduw_kernel(VAR_0, tss_base + (0x48 + VAR_13 * 4));
}
new_ldt = cpu_lduw_kernel(VAR_0, tss_base + 0x60);
new_trap = cpu_ldl_kernel(VAR_0, tss_base + 0x64);
} else {
new_cr3 = 0;
new_eip = cpu_lduw_kernel(VAR_0, tss_base + 0x0e);
new_eflags = cpu_lduw_kernel(VAR_0, tss_base + 0x10);
for (VAR_13 = 0; VAR_13 < 8; VAR_13++) {
new_regs[VAR_13] = cpu_lduw_kernel(VAR_0, tss_base + (0x12 + VAR_13 * 2)) |
0xffff0000;
}
for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {
new_segs[VAR_13] = cpu_lduw_kernel(VAR_0, tss_base + (0x22 + VAR_13 * 4));
}
new_ldt = cpu_lduw_kernel(VAR_0, tss_base + 0x2a);
new_segs[R_FS] = 0;
new_segs[R_GS] = 0;
new_trap = 0;
}
(void)new_trap;
VAR_11 = cpu_ldub_kernel(VAR_0, VAR_0->tr.base);
VAR_12 = cpu_ldub_kernel(VAR_0, VAR_0->tr.base + VAR_9);
cpu_stb_kernel(VAR_0, VAR_0->tr.base, VAR_11);
cpu_stb_kernel(VAR_0, VAR_0->tr.base + VAR_9, VAR_12);
if (VAR_4 == SWITCH_TSS_JMP || VAR_4 == SWITCH_TSS_IRET) {
target_ulong ptr;
uint32_t VAR_3;
ptr = VAR_0->gdt.base + (VAR_0->tr.selector & ~7);
VAR_3 = cpu_ldl_kernel(VAR_0, ptr + 4);
VAR_3 &= ~DESC_TSS_BUSY_MASK;
cpu_stl_kernel(VAR_0, ptr + 4, VAR_3);
}
old_eflags = cpu_compute_eflags(VAR_0);
if (VAR_4 == SWITCH_TSS_IRET) {
old_eflags &= ~NT_MASK;
}
if (VAR_8 & 8) {
cpu_stl_kernel(VAR_0, VAR_0->tr.base + 0x20, VAR_5);
cpu_stl_kernel(VAR_0, VAR_0->tr.base + 0x24, old_eflags);
cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 0 * 4), VAR_0->regs[R_EAX]);
cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 1 * 4), VAR_0->regs[R_ECX]);
cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 2 * 4), VAR_0->regs[R_EDX]);
cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 3 * 4), VAR_0->regs[R_EBX]);
cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 4 * 4), VAR_0->regs[R_ESP]);
cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 5 * 4), VAR_0->regs[R_EBP]);
cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 6 * 4), VAR_0->regs[R_ESI]);
cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 7 * 4), VAR_0->regs[R_EDI]);
for (VAR_13 = 0; VAR_13 < 6; VAR_13++) {
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x48 + VAR_13 * 4),
VAR_0->segs[VAR_13].selector);
}
} else {
cpu_stw_kernel(VAR_0, VAR_0->tr.base + 0x0e, VAR_5);
cpu_stw_kernel(VAR_0, VAR_0->tr.base + 0x10, old_eflags);
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 0 * 2), VAR_0->regs[R_EAX]);
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 1 * 2), VAR_0->regs[R_ECX]);
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 2 * 2), VAR_0->regs[R_EDX]);
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 3 * 2), VAR_0->regs[R_EBX]);
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 4 * 2), VAR_0->regs[R_ESP]);
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 5 * 2), VAR_0->regs[R_EBP]);
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 6 * 2), VAR_0->regs[R_ESI]);
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 7 * 2), VAR_0->regs[R_EDI]);
for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {
cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x22 + VAR_13 * 4),
VAR_0->segs[VAR_13].selector);
}
}
if (VAR_4 == SWITCH_TSS_CALL) {
cpu_stw_kernel(VAR_0, tss_base, VAR_0->tr.selector);
new_eflags |= NT_MASK;
}
if (VAR_4 == SWITCH_TSS_JMP || VAR_4 == SWITCH_TSS_CALL) {
target_ulong ptr;
uint32_t VAR_3;
ptr = VAR_0->gdt.base + (VAR_1 & ~7);
VAR_3 = cpu_ldl_kernel(VAR_0, ptr + 4);
VAR_3 |= DESC_TSS_BUSY_MASK;
cpu_stl_kernel(VAR_0, ptr + 4, VAR_3);
}
VAR_0->cr[0] |= CR0_TS_MASK;
VAR_0->hflags |= HF_TS_MASK;
VAR_0->tr.selector = VAR_1;
VAR_0->tr.base = tss_base;
VAR_0->tr.limit = VAR_6;
VAR_0->tr.flags = VAR_3 & ~DESC_TSS_BUSY_MASK;
if ((VAR_8 & 8) && (VAR_0->cr[0] & CR0_PG_MASK)) {
cpu_x86_update_cr3(VAR_0, new_cr3);
}
VAR_0->eip = new_eip;
eflags_mask = TF_MASK | AC_MASK | ID_MASK |
IF_MASK | IOPL_MASK | VM_MASK | RF_MASK | NT_MASK;
if (!(VAR_8 & 8)) {
eflags_mask &= 0xffff;
}
cpu_load_eflags(VAR_0, new_eflags, eflags_mask);
VAR_0->regs[R_EAX] = new_regs[0];
VAR_0->regs[R_ECX] = new_regs[1];
VAR_0->regs[R_EDX] = new_regs[2];
VAR_0->regs[R_EBX] = new_regs[3];
VAR_0->regs[R_ESP] = new_regs[4];
VAR_0->regs[R_EBP] = new_regs[5];
VAR_0->regs[R_ESI] = new_regs[6];
VAR_0->regs[R_EDI] = new_regs[7];
if (new_eflags & VM_MASK) {
for (VAR_13 = 0; VAR_13 < 6; VAR_13++) {
load_seg_vm(VAR_0, VAR_13, new_segs[VAR_13]);
}
cpu_x86_set_cpl(VAR_0, 3);
} else {
cpu_x86_set_cpl(VAR_0, new_segs[R_CS] & 3);
for (VAR_13 = 0; VAR_13 < 6; VAR_13++) {
cpu_x86_load_seg_cache(VAR_0, VAR_13, new_segs[VAR_13], 0, 0, 0);
}
}
VAR_0->ldt.selector = new_ldt & ~4;
VAR_0->ldt.base = 0;
VAR_0->ldt.limit = 0;
VAR_0->ldt.flags = 0;
if (new_ldt & 4) {
raise_exception_err(VAR_0, EXCP0A_TSS, new_ldt & 0xfffc);
}
if ((new_ldt & 0xfffc) != 0) {
dt = &VAR_0->gdt;
VAR_14 = new_ldt & ~7;
if ((VAR_14 + 7) > dt->limit) {
raise_exception_err(VAR_0, EXCP0A_TSS, new_ldt & 0xfffc);
}
ptr = dt->base + VAR_14;
VAR_2 = cpu_ldl_kernel(VAR_0, ptr);
VAR_3 = cpu_ldl_kernel(VAR_0, ptr + 4);
if ((VAR_3 & DESC_S_MASK) || ((VAR_3 >> DESC_TYPE_SHIFT) & 0xf) != 2) {
raise_exception_err(VAR_0, EXCP0A_TSS, new_ldt & 0xfffc);
}
if (!(VAR_3 & DESC_P_MASK)) {
raise_exception_err(VAR_0, EXCP0A_TSS, new_ldt & 0xfffc);
}
load_seg_cache_raw_dt(&VAR_0->ldt, VAR_2, VAR_3);
}
if (!(new_eflags & VM_MASK)) {
tss_load_seg(VAR_0, R_CS, new_segs[R_CS]);
tss_load_seg(VAR_0, R_SS, new_segs[R_SS]);
tss_load_seg(VAR_0, R_ES, new_segs[R_ES]);
tss_load_seg(VAR_0, R_DS, new_segs[R_DS]);
tss_load_seg(VAR_0, R_FS, new_segs[R_FS]);
tss_load_seg(VAR_0, R_GS, new_segs[R_GS]);
}
if (new_eip > VAR_0->segs[R_CS].limit) {
raise_exception_err(VAR_0, EXCP0D_GPF, 0);
}
#ifndef CONFIG_USER_ONLY
if (VAR_0->dr[7] & DR7_LOCAL_BP_MASK) {
for (VAR_13 = 0; VAR_13 < DR7_MAX_BP; VAR_13++) {
if (hw_local_breakpoint_enabled(VAR_0->dr[7], VAR_13) &&
!hw_global_breakpoint_enabled(VAR_0->dr[7], VAR_13)) {
hw_breakpoint_remove(VAR_0, VAR_13);
}
}
VAR_0->dr[7] &= ~DR7_LOCAL_BP_MASK;
}
#endif
}
| [
"static void FUNC_0(CPUX86State *VAR_0, int VAR_1,\nuint32_t VAR_2, uint32_t VAR_3, int VAR_4,\nuint32_t VAR_5)\n{",
"int VAR_6, VAR_7, VAR_8, VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;",
"target_ulong tss_base;",
"uint32_t new_regs[8], new_segs[6];",
"uint32_t new_eflags, new_eip, new_cr3, new_ldt, new_trap;",
"uint32_t old_eflags, eflags_mask;",
"SegmentCache *dt;",
"int VAR_14;",
"target_ulong ptr;",
"VAR_8 = (VAR_3 >> DESC_TYPE_SHIFT) & 0xf;",
"LOG_PCALL(\"FUNC_0: sel=0x%04x VAR_8=%d src=%d\\n\", VAR_1, VAR_8,\nVAR_4);",
"if (VAR_8 == 5) {",
"if (!(VAR_3 & DESC_P_MASK)) {",
"raise_exception_err(VAR_0, EXCP0B_NOSEG, VAR_1 & 0xfffc);",
"}",
"VAR_1 = VAR_2 >> 16;",
"if (VAR_1 & 4) {",
"raise_exception_err(VAR_0, EXCP0A_TSS, VAR_1 & 0xfffc);",
"}",
"if (load_segment(VAR_0, &VAR_2, &VAR_3, VAR_1) != 0) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 & 0xfffc);",
"}",
"if (VAR_3 & DESC_S_MASK) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 & 0xfffc);",
"}",
"VAR_8 = (VAR_3 >> DESC_TYPE_SHIFT) & 0xf;",
"if ((VAR_8 & 7) != 1) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, VAR_1 & 0xfffc);",
"}",
"}",
"if (!(VAR_3 & DESC_P_MASK)) {",
"raise_exception_err(VAR_0, EXCP0B_NOSEG, VAR_1 & 0xfffc);",
"}",
"if (VAR_8 & 8) {",
"VAR_7 = 103;",
"} else {",
"VAR_7 = 43;",
"}",
"VAR_6 = get_seg_limit(VAR_2, VAR_3);",
"tss_base = get_seg_base(VAR_2, VAR_3);",
"if ((VAR_1 & 4) != 0 ||\nVAR_6 < VAR_7) {",
"raise_exception_err(VAR_0, EXCP0A_TSS, VAR_1 & 0xfffc);",
"}",
"VAR_10 = (VAR_0->tr.flags >> DESC_TYPE_SHIFT) & 0xf;",
"if (VAR_10 & 8) {",
"VAR_9 = 103;",
"} else {",
"VAR_9 = 43;",
"}",
"if (VAR_8 & 8) {",
"new_cr3 = cpu_ldl_kernel(VAR_0, tss_base + 0x1c);",
"new_eip = cpu_ldl_kernel(VAR_0, tss_base + 0x20);",
"new_eflags = cpu_ldl_kernel(VAR_0, tss_base + 0x24);",
"for (VAR_13 = 0; VAR_13 < 8; VAR_13++) {",
"new_regs[VAR_13] = cpu_ldl_kernel(VAR_0, tss_base + (0x28 + VAR_13 * 4));",
"}",
"for (VAR_13 = 0; VAR_13 < 6; VAR_13++) {",
"new_segs[VAR_13] = cpu_lduw_kernel(VAR_0, tss_base + (0x48 + VAR_13 * 4));",
"}",
"new_ldt = cpu_lduw_kernel(VAR_0, tss_base + 0x60);",
"new_trap = cpu_ldl_kernel(VAR_0, tss_base + 0x64);",
"} else {",
"new_cr3 = 0;",
"new_eip = cpu_lduw_kernel(VAR_0, tss_base + 0x0e);",
"new_eflags = cpu_lduw_kernel(VAR_0, tss_base + 0x10);",
"for (VAR_13 = 0; VAR_13 < 8; VAR_13++) {",
"new_regs[VAR_13] = cpu_lduw_kernel(VAR_0, tss_base + (0x12 + VAR_13 * 2)) |\n0xffff0000;",
"}",
"for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {",
"new_segs[VAR_13] = cpu_lduw_kernel(VAR_0, tss_base + (0x22 + VAR_13 * 4));",
"}",
"new_ldt = cpu_lduw_kernel(VAR_0, tss_base + 0x2a);",
"new_segs[R_FS] = 0;",
"new_segs[R_GS] = 0;",
"new_trap = 0;",
"}",
"(void)new_trap;",
"VAR_11 = cpu_ldub_kernel(VAR_0, VAR_0->tr.base);",
"VAR_12 = cpu_ldub_kernel(VAR_0, VAR_0->tr.base + VAR_9);",
"cpu_stb_kernel(VAR_0, VAR_0->tr.base, VAR_11);",
"cpu_stb_kernel(VAR_0, VAR_0->tr.base + VAR_9, VAR_12);",
"if (VAR_4 == SWITCH_TSS_JMP || VAR_4 == SWITCH_TSS_IRET) {",
"target_ulong ptr;",
"uint32_t VAR_3;",
"ptr = VAR_0->gdt.base + (VAR_0->tr.selector & ~7);",
"VAR_3 = cpu_ldl_kernel(VAR_0, ptr + 4);",
"VAR_3 &= ~DESC_TSS_BUSY_MASK;",
"cpu_stl_kernel(VAR_0, ptr + 4, VAR_3);",
"}",
"old_eflags = cpu_compute_eflags(VAR_0);",
"if (VAR_4 == SWITCH_TSS_IRET) {",
"old_eflags &= ~NT_MASK;",
"}",
"if (VAR_8 & 8) {",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + 0x20, VAR_5);",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + 0x24, old_eflags);",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 0 * 4), VAR_0->regs[R_EAX]);",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 1 * 4), VAR_0->regs[R_ECX]);",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 2 * 4), VAR_0->regs[R_EDX]);",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 3 * 4), VAR_0->regs[R_EBX]);",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 4 * 4), VAR_0->regs[R_ESP]);",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 5 * 4), VAR_0->regs[R_EBP]);",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 6 * 4), VAR_0->regs[R_ESI]);",
"cpu_stl_kernel(VAR_0, VAR_0->tr.base + (0x28 + 7 * 4), VAR_0->regs[R_EDI]);",
"for (VAR_13 = 0; VAR_13 < 6; VAR_13++) {",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x48 + VAR_13 * 4),\nVAR_0->segs[VAR_13].selector);",
"}",
"} else {",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + 0x0e, VAR_5);",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + 0x10, old_eflags);",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 0 * 2), VAR_0->regs[R_EAX]);",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 1 * 2), VAR_0->regs[R_ECX]);",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 2 * 2), VAR_0->regs[R_EDX]);",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 3 * 2), VAR_0->regs[R_EBX]);",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 4 * 2), VAR_0->regs[R_ESP]);",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 5 * 2), VAR_0->regs[R_EBP]);",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 6 * 2), VAR_0->regs[R_ESI]);",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x12 + 7 * 2), VAR_0->regs[R_EDI]);",
"for (VAR_13 = 0; VAR_13 < 4; VAR_13++) {",
"cpu_stw_kernel(VAR_0, VAR_0->tr.base + (0x22 + VAR_13 * 4),\nVAR_0->segs[VAR_13].selector);",
"}",
"}",
"if (VAR_4 == SWITCH_TSS_CALL) {",
"cpu_stw_kernel(VAR_0, tss_base, VAR_0->tr.selector);",
"new_eflags |= NT_MASK;",
"}",
"if (VAR_4 == SWITCH_TSS_JMP || VAR_4 == SWITCH_TSS_CALL) {",
"target_ulong ptr;",
"uint32_t VAR_3;",
"ptr = VAR_0->gdt.base + (VAR_1 & ~7);",
"VAR_3 = cpu_ldl_kernel(VAR_0, ptr + 4);",
"VAR_3 |= DESC_TSS_BUSY_MASK;",
"cpu_stl_kernel(VAR_0, ptr + 4, VAR_3);",
"}",
"VAR_0->cr[0] |= CR0_TS_MASK;",
"VAR_0->hflags |= HF_TS_MASK;",
"VAR_0->tr.selector = VAR_1;",
"VAR_0->tr.base = tss_base;",
"VAR_0->tr.limit = VAR_6;",
"VAR_0->tr.flags = VAR_3 & ~DESC_TSS_BUSY_MASK;",
"if ((VAR_8 & 8) && (VAR_0->cr[0] & CR0_PG_MASK)) {",
"cpu_x86_update_cr3(VAR_0, new_cr3);",
"}",
"VAR_0->eip = new_eip;",
"eflags_mask = TF_MASK | AC_MASK | ID_MASK |\nIF_MASK | IOPL_MASK | VM_MASK | RF_MASK | NT_MASK;",
"if (!(VAR_8 & 8)) {",
"eflags_mask &= 0xffff;",
"}",
"cpu_load_eflags(VAR_0, new_eflags, eflags_mask);",
"VAR_0->regs[R_EAX] = new_regs[0];",
"VAR_0->regs[R_ECX] = new_regs[1];",
"VAR_0->regs[R_EDX] = new_regs[2];",
"VAR_0->regs[R_EBX] = new_regs[3];",
"VAR_0->regs[R_ESP] = new_regs[4];",
"VAR_0->regs[R_EBP] = new_regs[5];",
"VAR_0->regs[R_ESI] = new_regs[6];",
"VAR_0->regs[R_EDI] = new_regs[7];",
"if (new_eflags & VM_MASK) {",
"for (VAR_13 = 0; VAR_13 < 6; VAR_13++) {",
"load_seg_vm(VAR_0, VAR_13, new_segs[VAR_13]);",
"}",
"cpu_x86_set_cpl(VAR_0, 3);",
"} else {",
"cpu_x86_set_cpl(VAR_0, new_segs[R_CS] & 3);",
"for (VAR_13 = 0; VAR_13 < 6; VAR_13++) {",
"cpu_x86_load_seg_cache(VAR_0, VAR_13, new_segs[VAR_13], 0, 0, 0);",
"}",
"}",
"VAR_0->ldt.selector = new_ldt & ~4;",
"VAR_0->ldt.base = 0;",
"VAR_0->ldt.limit = 0;",
"VAR_0->ldt.flags = 0;",
"if (new_ldt & 4) {",
"raise_exception_err(VAR_0, EXCP0A_TSS, new_ldt & 0xfffc);",
"}",
"if ((new_ldt & 0xfffc) != 0) {",
"dt = &VAR_0->gdt;",
"VAR_14 = new_ldt & ~7;",
"if ((VAR_14 + 7) > dt->limit) {",
"raise_exception_err(VAR_0, EXCP0A_TSS, new_ldt & 0xfffc);",
"}",
"ptr = dt->base + VAR_14;",
"VAR_2 = cpu_ldl_kernel(VAR_0, ptr);",
"VAR_3 = cpu_ldl_kernel(VAR_0, ptr + 4);",
"if ((VAR_3 & DESC_S_MASK) || ((VAR_3 >> DESC_TYPE_SHIFT) & 0xf) != 2) {",
"raise_exception_err(VAR_0, EXCP0A_TSS, new_ldt & 0xfffc);",
"}",
"if (!(VAR_3 & DESC_P_MASK)) {",
"raise_exception_err(VAR_0, EXCP0A_TSS, new_ldt & 0xfffc);",
"}",
"load_seg_cache_raw_dt(&VAR_0->ldt, VAR_2, VAR_3);",
"}",
"if (!(new_eflags & VM_MASK)) {",
"tss_load_seg(VAR_0, R_CS, new_segs[R_CS]);",
"tss_load_seg(VAR_0, R_SS, new_segs[R_SS]);",
"tss_load_seg(VAR_0, R_ES, new_segs[R_ES]);",
"tss_load_seg(VAR_0, R_DS, new_segs[R_DS]);",
"tss_load_seg(VAR_0, R_FS, new_segs[R_FS]);",
"tss_load_seg(VAR_0, R_GS, new_segs[R_GS]);",
"}",
"if (new_eip > VAR_0->segs[R_CS].limit) {",
"raise_exception_err(VAR_0, EXCP0D_GPF, 0);",
"}",
"#ifndef CONFIG_USER_ONLY\nif (VAR_0->dr[7] & DR7_LOCAL_BP_MASK) {",
"for (VAR_13 = 0; VAR_13 < DR7_MAX_BP; VAR_13++) {",
"if (hw_local_breakpoint_enabled(VAR_0->dr[7], VAR_13) &&\n!hw_global_breakpoint_enabled(VAR_0->dr[7], VAR_13)) {",
"hw_breakpoint_remove(VAR_0, VAR_13);",
"}",
"}",
"VAR_0->dr[7] &= ~DR7_LOCAL_BP_MASK;",
"}",
"#endif\n}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29,
31
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
123
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
139
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
189
],
[
203
],
[
205
],
[
207
],
[
209
],
[
215
],
[
217
],
[
219
],
[
223
],
[
225
],
[
227
],
[
229
],
[
231
],
[
233
],
[
235
],
[
237
],
[
239
],
[
245
],
[
249
],
[
251
],
[
253
],
[
255
],
[
257
],
[
259
],
[
261
],
[
263
],
[
265
],
[
267
],
[
269
],
[
271,
273
],
[
275
],
[
277
],
[
281
],
[
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295
],
[
297
],
[
299
],
[
301
],
[
303,
305
],
[
307
],
[
309
],
[
319
],
[
321
],
[
323
],
[
325
],
[
331
],
[
333
],
[
335
],
[
339
],
[
341
],
[
343
],
[
345
],
[
347
],
[
355
],
[
357
],
[
359
],
[
361
],
[
363
],
[
365
],
[
369
],
[
371
],
[
373
],
[
381
],
[
383,
385
],
[
387
],
[
389
],
[
391
],
[
393
],
[
397
],
[
399
],
[
401
],
[
403
],
[
405
],
[
407
],
[
409
],
[
411
],
[
413
],
[
415
],
[
417
],
[
419
],
[
423
],
[
425
],
[
429
],
[
433
],
[
435
],
[
437
],
[
439
],
[
443
],
[
445
],
[
447
],
[
449
],
[
455
],
[
457
],
[
459
],
[
463
],
[
465
],
[
467
],
[
469
],
[
471
],
[
473
],
[
475
],
[
477
],
[
479
],
[
481
],
[
483
],
[
485
],
[
487
],
[
489
],
[
491
],
[
493
],
[
495
],
[
501
],
[
503
],
[
505
],
[
507
],
[
509
],
[
511
],
[
513
],
[
515
],
[
521
],
[
525
],
[
527
],
[
531,
535
],
[
537
],
[
539,
541
],
[
543
],
[
545
],
[
547
],
[
549
],
[
551
],
[
553,
555
]
] |
25,111 | void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n)
{
int fd, rc;
int i;
fd = kvmppc_get_htab_fd(false, ptex, &error_abort);
i = 0;
while (i < n) {
struct kvm_get_htab_header *hdr;
int m = n < HPTES_PER_GROUP ? n : HPTES_PER_GROUP;
char buf[sizeof(*hdr) + m * HASH_PTE_SIZE_64];
rc = read(fd, buf, sizeof(buf));
if (rc < 0) {
hw_error("kvmppc_read_hptes: Unable to read HPTEs");
}
hdr = (struct kvm_get_htab_header *)buf;
while ((i < n) && ((char *)hdr < (buf + rc))) {
int invalid = hdr->n_invalid;
if (hdr->index != (ptex + i)) {
hw_error("kvmppc_read_hptes: Unexpected HPTE index %"PRIu32
" != (%"HWADDR_PRIu" + %d", hdr->index, ptex, i);
}
memcpy(hptes + i, hdr + 1, HASH_PTE_SIZE_64 * hdr->n_valid);
i += hdr->n_valid;
if ((n - i) < invalid) {
invalid = n - i;
}
memset(hptes + i, 0, invalid * HASH_PTE_SIZE_64);
i += hdr->n_invalid;
hdr = (struct kvm_get_htab_header *)
((char *)(hdr + 1) + HASH_PTE_SIZE_64 * hdr->n_valid);
}
}
close(fd);
}
| false | qemu | a36593e16757e524c1596d93914155bd8acbb90a | void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n)
{
int fd, rc;
int i;
fd = kvmppc_get_htab_fd(false, ptex, &error_abort);
i = 0;
while (i < n) {
struct kvm_get_htab_header *hdr;
int m = n < HPTES_PER_GROUP ? n : HPTES_PER_GROUP;
char buf[sizeof(*hdr) + m * HASH_PTE_SIZE_64];
rc = read(fd, buf, sizeof(buf));
if (rc < 0) {
hw_error("kvmppc_read_hptes: Unable to read HPTEs");
}
hdr = (struct kvm_get_htab_header *)buf;
while ((i < n) && ((char *)hdr < (buf + rc))) {
int invalid = hdr->n_invalid;
if (hdr->index != (ptex + i)) {
hw_error("kvmppc_read_hptes: Unexpected HPTE index %"PRIu32
" != (%"HWADDR_PRIu" + %d", hdr->index, ptex, i);
}
memcpy(hptes + i, hdr + 1, HASH_PTE_SIZE_64 * hdr->n_valid);
i += hdr->n_valid;
if ((n - i) < invalid) {
invalid = n - i;
}
memset(hptes + i, 0, invalid * HASH_PTE_SIZE_64);
i += hdr->n_invalid;
hdr = (struct kvm_get_htab_header *)
((char *)(hdr + 1) + HASH_PTE_SIZE_64 * hdr->n_valid);
}
}
close(fd);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(ppc_hash_pte64_t *VAR_0, hwaddr VAR_1, int VAR_2)
{
int VAR_3, VAR_4;
int VAR_5;
VAR_3 = kvmppc_get_htab_fd(false, VAR_1, &error_abort);
VAR_5 = 0;
while (VAR_5 < VAR_2) {
struct kvm_get_htab_header *VAR_6;
int VAR_7 = VAR_2 < HPTES_PER_GROUP ? VAR_2 : HPTES_PER_GROUP;
char VAR_8[sizeof(*VAR_6) + VAR_7 * HASH_PTE_SIZE_64];
VAR_4 = read(VAR_3, VAR_8, sizeof(VAR_8));
if (VAR_4 < 0) {
hw_error("FUNC_0: Unable to read HPTEs");
}
VAR_6 = (struct kvm_get_htab_header *)VAR_8;
while ((VAR_5 < VAR_2) && ((char *)VAR_6 < (VAR_8 + VAR_4))) {
int VAR_9 = VAR_6->n_invalid;
if (VAR_6->index != (VAR_1 + VAR_5)) {
hw_error("FUNC_0: Unexpected HPTE index %"PRIu32
" != (%"HWADDR_PRIu" + %d", VAR_6->index, VAR_1, VAR_5);
}
memcpy(VAR_0 + VAR_5, VAR_6 + 1, HASH_PTE_SIZE_64 * VAR_6->n_valid);
VAR_5 += VAR_6->n_valid;
if ((VAR_2 - VAR_5) < VAR_9) {
VAR_9 = VAR_2 - VAR_5;
}
memset(VAR_0 + VAR_5, 0, VAR_9 * HASH_PTE_SIZE_64);
VAR_5 += VAR_6->n_invalid;
VAR_6 = (struct kvm_get_htab_header *)
((char *)(VAR_6 + 1) + HASH_PTE_SIZE_64 * VAR_6->n_valid);
}
}
close(VAR_3);
}
| [
"void FUNC_0(ppc_hash_pte64_t *VAR_0, hwaddr VAR_1, int VAR_2)\n{",
"int VAR_3, VAR_4;",
"int VAR_5;",
"VAR_3 = kvmppc_get_htab_fd(false, VAR_1, &error_abort);",
"VAR_5 = 0;",
"while (VAR_5 < VAR_2) {",
"struct kvm_get_htab_header *VAR_6;",
"int VAR_7 = VAR_2 < HPTES_PER_GROUP ? VAR_2 : HPTES_PER_GROUP;",
"char VAR_8[sizeof(*VAR_6) + VAR_7 * HASH_PTE_SIZE_64];",
"VAR_4 = read(VAR_3, VAR_8, sizeof(VAR_8));",
"if (VAR_4 < 0) {",
"hw_error(\"FUNC_0: Unable to read HPTEs\");",
"}",
"VAR_6 = (struct kvm_get_htab_header *)VAR_8;",
"while ((VAR_5 < VAR_2) && ((char *)VAR_6 < (VAR_8 + VAR_4))) {",
"int VAR_9 = VAR_6->n_invalid;",
"if (VAR_6->index != (VAR_1 + VAR_5)) {",
"hw_error(\"FUNC_0: Unexpected HPTE index %\"PRIu32\n\" != (%\"HWADDR_PRIu\" + %d\", VAR_6->index, VAR_1, VAR_5);",
"}",
"memcpy(VAR_0 + VAR_5, VAR_6 + 1, HASH_PTE_SIZE_64 * VAR_6->n_valid);",
"VAR_5 += VAR_6->n_valid;",
"if ((VAR_2 - VAR_5) < VAR_9) {",
"VAR_9 = VAR_2 - VAR_5;",
"}",
"memset(VAR_0 + VAR_5, 0, VAR_9 * HASH_PTE_SIZE_64);",
"VAR_5 += VAR_6->n_invalid;",
"VAR_6 = (struct kvm_get_htab_header *)\n((char *)(VAR_6 + 1) + HASH_PTE_SIZE_64 * VAR_6->n_valid);",
"}",
"}",
"close(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
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
27
],
[
29
],
[
31
],
[
33
],
[
37
],
[
39
],
[
41
],
[
45
],
[
47,
49
],
[
51
],
[
55
],
[
57
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
73,
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
25,112 | void qmp_output_visitor_cleanup(QmpOutputVisitor *v)
{
QStackEntry *e, *tmp;
QTAILQ_FOREACH_SAFE(e, &v->stack, node, tmp) {
QTAILQ_REMOVE(&v->stack, e, node);
g_free(e);
}
qobject_decref(v->root);
g_free(v);
}
| false | qemu | 1830f22a6777cedaccd67a08f675d30f7a85ebfd | void qmp_output_visitor_cleanup(QmpOutputVisitor *v)
{
QStackEntry *e, *tmp;
QTAILQ_FOREACH_SAFE(e, &v->stack, node, tmp) {
QTAILQ_REMOVE(&v->stack, e, node);
g_free(e);
}
qobject_decref(v->root);
g_free(v);
}
| {
"code": [],
"line_no": []
} | void FUNC_0(QmpOutputVisitor *VAR_0)
{
QStackEntry *e, *tmp;
QTAILQ_FOREACH_SAFE(e, &VAR_0->stack, node, tmp) {
QTAILQ_REMOVE(&VAR_0->stack, e, node);
g_free(e);
}
qobject_decref(VAR_0->root);
g_free(VAR_0);
}
| [
"void FUNC_0(QmpOutputVisitor *VAR_0)\n{",
"QStackEntry *e, *tmp;",
"QTAILQ_FOREACH_SAFE(e, &VAR_0->stack, node, tmp) {",
"QTAILQ_REMOVE(&VAR_0->stack, e, node);",
"g_free(e);",
"}",
"qobject_decref(VAR_0->root);",
"g_free(VAR_0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
]
] |
25,114 | static int check_host_key(BDRVSSHState *s, const char *host, int port,
const char *host_key_check)
{
/* host_key_check=no */
if (strcmp(host_key_check, "no") == 0) {
return 0;
}
/* host_key_check=md5:xx:yy:zz:... */
if (strncmp(host_key_check, "md5:", 4) == 0) {
return check_host_key_hash(s, &host_key_check[4],
LIBSSH2_HOSTKEY_HASH_MD5, 16);
}
/* host_key_check=sha1:xx:yy:zz:... */
if (strncmp(host_key_check, "sha1:", 5) == 0) {
return check_host_key_hash(s, &host_key_check[5],
LIBSSH2_HOSTKEY_HASH_SHA1, 20);
}
/* host_key_check=yes */
if (strcmp(host_key_check, "yes") == 0) {
return check_host_key_knownhosts(s, host, port);
}
error_report("unknown host_key_check setting (%s)", host_key_check);
return -EINVAL;
}
| false | qemu | 01c2b265fce921d6460e06f5af4dfb405119cbab | static int check_host_key(BDRVSSHState *s, const char *host, int port,
const char *host_key_check)
{
if (strcmp(host_key_check, "no") == 0) {
return 0;
}
if (strncmp(host_key_check, "md5:", 4) == 0) {
return check_host_key_hash(s, &host_key_check[4],
LIBSSH2_HOSTKEY_HASH_MD5, 16);
}
if (strncmp(host_key_check, "sha1:", 5) == 0) {
return check_host_key_hash(s, &host_key_check[5],
LIBSSH2_HOSTKEY_HASH_SHA1, 20);
}
if (strcmp(host_key_check, "yes") == 0) {
return check_host_key_knownhosts(s, host, port);
}
error_report("unknown host_key_check setting (%s)", host_key_check);
return -EINVAL;
}
| {
"code": [],
"line_no": []
} | static int FUNC_0(BDRVSSHState *VAR_0, const char *VAR_1, int VAR_2,
const char *VAR_3)
{
if (strcmp(VAR_3, "no") == 0) {
return 0;
}
if (strncmp(VAR_3, "md5:", 4) == 0) {
return check_host_key_hash(VAR_0, &VAR_3[4],
LIBSSH2_HOSTKEY_HASH_MD5, 16);
}
if (strncmp(VAR_3, "sha1:", 5) == 0) {
return check_host_key_hash(VAR_0, &VAR_3[5],
LIBSSH2_HOSTKEY_HASH_SHA1, 20);
}
if (strcmp(VAR_3, "yes") == 0) {
return check_host_key_knownhosts(VAR_0, VAR_1, VAR_2);
}
error_report("unknown VAR_3 setting (%VAR_0)", VAR_3);
return -EINVAL;
}
| [
"static int FUNC_0(BDRVSSHState *VAR_0, const char *VAR_1, int VAR_2,\nconst char *VAR_3)\n{",
"if (strcmp(VAR_3, \"no\") == 0) {",
"return 0;",
"}",
"if (strncmp(VAR_3, \"md5:\", 4) == 0) {",
"return check_host_key_hash(VAR_0, &VAR_3[4],\nLIBSSH2_HOSTKEY_HASH_MD5, 16);",
"}",
"if (strncmp(VAR_3, \"sha1:\", 5) == 0) {",
"return check_host_key_hash(VAR_0, &VAR_3[5],\nLIBSSH2_HOSTKEY_HASH_SHA1, 20);",
"}",
"if (strcmp(VAR_3, \"yes\") == 0) {",
"return check_host_key_knownhosts(VAR_0, VAR_1, VAR_2);",
"}",
"error_report(\"unknown VAR_3 setting (%VAR_0)\", VAR_3);",
"return -EINVAL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21,
23
],
[
25
],
[
31
],
[
33,
35
],
[
37
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
]
] |
25,115 | void memory_region_notify_iommu(MemoryRegion *mr,
IOMMUTLBEntry entry)
{
IOMMUNotifier *iommu_notifier;
IOMMUNotifierFlag request_flags;
assert(memory_region_is_iommu(mr));
if (entry.perm & IOMMU_RW) {
request_flags = IOMMU_NOTIFIER_MAP;
} else {
request_flags = IOMMU_NOTIFIER_UNMAP;
}
IOMMU_NOTIFIER_FOREACH(iommu_notifier, mr) {
/*
* Skip the notification if the notification does not overlap
* with registered range.
*/
if (iommu_notifier->start > entry.iova + entry.addr_mask + 1 ||
iommu_notifier->end < entry.iova) {
continue;
}
if (iommu_notifier->notifier_flags & request_flags) {
iommu_notifier->notify(iommu_notifier, &entry);
}
}
}
| false | qemu | bd2bfa4c52e5f4dc6dbaa5be0521aedc31cb53d9 | void memory_region_notify_iommu(MemoryRegion *mr,
IOMMUTLBEntry entry)
{
IOMMUNotifier *iommu_notifier;
IOMMUNotifierFlag request_flags;
assert(memory_region_is_iommu(mr));
if (entry.perm & IOMMU_RW) {
request_flags = IOMMU_NOTIFIER_MAP;
} else {
request_flags = IOMMU_NOTIFIER_UNMAP;
}
IOMMU_NOTIFIER_FOREACH(iommu_notifier, mr) {
if (iommu_notifier->start > entry.iova + entry.addr_mask + 1 ||
iommu_notifier->end < entry.iova) {
continue;
}
if (iommu_notifier->notifier_flags & request_flags) {
iommu_notifier->notify(iommu_notifier, &entry);
}
}
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MemoryRegion *VAR_0,
IOMMUTLBEntry VAR_1)
{
IOMMUNotifier *iommu_notifier;
IOMMUNotifierFlag request_flags;
assert(memory_region_is_iommu(VAR_0));
if (VAR_1.perm & IOMMU_RW) {
request_flags = IOMMU_NOTIFIER_MAP;
} else {
request_flags = IOMMU_NOTIFIER_UNMAP;
}
IOMMU_NOTIFIER_FOREACH(iommu_notifier, VAR_0) {
if (iommu_notifier->start > VAR_1.iova + VAR_1.addr_mask + 1 ||
iommu_notifier->end < VAR_1.iova) {
continue;
}
if (iommu_notifier->notifier_flags & request_flags) {
iommu_notifier->notify(iommu_notifier, &VAR_1);
}
}
}
| [
"void FUNC_0(MemoryRegion *VAR_0,\nIOMMUTLBEntry VAR_1)\n{",
"IOMMUNotifier *iommu_notifier;",
"IOMMUNotifierFlag request_flags;",
"assert(memory_region_is_iommu(VAR_0));",
"if (VAR_1.perm & IOMMU_RW) {",
"request_flags = IOMMU_NOTIFIER_MAP;",
"} else {",
"request_flags = IOMMU_NOTIFIER_UNMAP;",
"}",
"IOMMU_NOTIFIER_FOREACH(iommu_notifier, VAR_0) {",
"if (iommu_notifier->start > VAR_1.iova + VAR_1.addr_mask + 1 ||\niommu_notifier->end < VAR_1.iova) {",
"continue;",
"}",
"if (iommu_notifier->notifier_flags & request_flags) {",
"iommu_notifier->notify(iommu_notifier, &VAR_1);",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
13
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
39,
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
53
],
[
55
]
] |
25,116 | static IOWatchPoll *io_watch_poll_from_source(GSource *source)
{
IOWatchPoll *i;
QTAILQ_FOREACH(i, &io_watch_poll_list, node) {
if (i->src == source) {
return i;
}
}
return NULL;
}
| false | qemu | d185c094b404b4ff392b77d1244c0233da7d53bd | static IOWatchPoll *io_watch_poll_from_source(GSource *source)
{
IOWatchPoll *i;
QTAILQ_FOREACH(i, &io_watch_poll_list, node) {
if (i->src == source) {
return i;
}
}
return NULL;
}
| {
"code": [],
"line_no": []
} | static IOWatchPoll *FUNC_0(GSource *source)
{
IOWatchPoll *i;
QTAILQ_FOREACH(i, &io_watch_poll_list, node) {
if (i->src == source) {
return i;
}
}
return NULL;
}
| [
"static IOWatchPoll *FUNC_0(GSource *source)\n{",
"IOWatchPoll *i;",
"QTAILQ_FOREACH(i, &io_watch_poll_list, node) {",
"if (i->src == source) {",
"return i;",
"}",
"}",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
21
],
[
23
]
] |
25,117 | void memory_region_init_io(MemoryRegion *mr,
Object *owner,
const MemoryRegionOps *ops,
void *opaque,
const char *name,
uint64_t size)
{
memory_region_init(mr, owner, name, size);
mr->ops = ops;
mr->opaque = opaque;
mr->terminates = true;
mr->ram_addr = ~(ram_addr_t)0;
}
| false | qemu | ec05ec26f940564b1e07bf88857035ec27e21dd8 | void memory_region_init_io(MemoryRegion *mr,
Object *owner,
const MemoryRegionOps *ops,
void *opaque,
const char *name,
uint64_t size)
{
memory_region_init(mr, owner, name, size);
mr->ops = ops;
mr->opaque = opaque;
mr->terminates = true;
mr->ram_addr = ~(ram_addr_t)0;
}
| {
"code": [],
"line_no": []
} | void FUNC_0(MemoryRegion *VAR_0,
Object *VAR_1,
const MemoryRegionOps *VAR_2,
void *VAR_3,
const char *VAR_4,
uint64_t VAR_5)
{
memory_region_init(VAR_0, VAR_1, VAR_4, VAR_5);
VAR_0->VAR_2 = VAR_2;
VAR_0->VAR_3 = VAR_3;
VAR_0->terminates = true;
VAR_0->ram_addr = ~(ram_addr_t)0;
}
| [
"void FUNC_0(MemoryRegion *VAR_0,\nObject *VAR_1,\nconst MemoryRegionOps *VAR_2,\nvoid *VAR_3,\nconst char *VAR_4,\nuint64_t VAR_5)\n{",
"memory_region_init(VAR_0, VAR_1, VAR_4, VAR_5);",
"VAR_0->VAR_2 = VAR_2;",
"VAR_0->VAR_3 = VAR_3;",
"VAR_0->terminates = true;",
"VAR_0->ram_addr = ~(ram_addr_t)0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9,
11,
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
23
],
[
25
]
] |
25,118 | static void filter_mb( H264Context *h, int mb_x, int mb_y ) {
MpegEncContext * const s = &h->s;
const int mb_xy= mb_x + mb_y*s->mb_stride;
uint8_t *img_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16;
uint8_t *img_cb = s->current_picture.data[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
uint8_t *img_cr = s->current_picture.data[2] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
int linesize, uvlinesize;
int dir;
#if 0
/* FIXME what's that ? */
if( !s->decode )
return;
#endif
/* FIXME Implement deblocking filter for field MB */
if( h->sps.mb_aff ) {
return;
}
linesize = s->linesize;
uvlinesize = s->uvlinesize;
/* dir : 0 -> vertical edge, 1 -> horizontal edge */
for( dir = 0; dir < 2; dir++ )
{
int start = 0;
int edge;
/* test picture boundary */
if( ( dir == 0 && mb_x == 0 ) || ( dir == 1 && mb_y == 0 ) ) {
start = 1;
}
/* FIXME test slice boundary */
if( h->disable_deblocking_filter_idc == 2 ) {
}
/* Calculate bS */
for( edge = start; edge < 4; edge++ ) {
/* mbn_xy: neighbour macroblock (how that works for field ?) */
int mbn_xy = edge > 0 ? mb_xy : ( dir == 0 ? mb_xy -1 : mb_xy - s->mb_stride );
int bS[4];
int qp;
if( IS_INTRA( s->current_picture.mb_type[mb_xy] ) ||
IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) {
bS[0] = bS[1] = bS[2] = bS[3] = ( edge == 0 ? 4 : 3 );
} else {
int i;
for( i = 0; i < 4; i++ ) {
static const uint8_t block_idx_xy[4][4] = {
{ 0, 2, 8, 10}, { 1, 3, 9, 11},
{ 4, 6, 12, 14}, { 5, 7, 13, 15}
};
int x = dir == 0 ? edge : i;
int y = dir == 0 ? i : edge;
int xn = (x - (dir == 0 ? 1 : 0 ))&0x03;
int yn = (y - (dir == 0 ? 0 : 1 ))&0x03;
if( h->non_zero_count[mb_xy][block_idx_xy[x][y]] != 0 ||
h->non_zero_count[mbn_xy][block_idx_xy[xn][yn]] != 0 ) {
bS[i] = 2;
}
else if( h->slice_type == P_TYPE ) {
const int b8_xy = h->mb2b8_xy[mb_xy]+(y>>1)*h->b8_stride+(x>>1);
const int b8n_xy= h->mb2b8_xy[mbn_xy]+(yn>>1)*h->b8_stride+(xn>>1);
const int b_xy = h->mb2b_xy[mb_xy]+y*h->b_stride+x;
const int bn_xy = h->mb2b_xy[mbn_xy]+yn*h->b_stride+xn;
if( s->current_picture.ref_index[0][b8_xy] != s->current_picture.ref_index[0][b8n_xy] ||
ABS( s->current_picture.motion_val[0][b_xy][0] - s->current_picture.motion_val[0][bn_xy][0] ) >= 4 ||
ABS( s->current_picture.motion_val[0][b_xy][1] - s->current_picture.motion_val[0][bn_xy][1] ) >= 4 )
bS[i] = 1;
else
bS[i] = 0;
}
else {
/* FIXME Add support for B frame */
return;
}
}
}
/* Filter edge */
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
if( dir == 0 ) {
filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( get_chroma_qp( h, s->current_picture.qscale_table[mb_xy] ) +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, chroma_qp );
filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, chroma_qp );
}
} else {
filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( get_chroma_qp( h, s->current_picture.qscale_table[mb_xy] ) +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
}
}
}
}
}
| false | FFmpeg | 53c05b1eacd5f7dbfa3651b45e797adaea0a5ff8 | static void filter_mb( H264Context *h, int mb_x, int mb_y ) {
MpegEncContext * const s = &h->s;
const int mb_xy= mb_x + mb_y*s->mb_stride;
uint8_t *img_y = s->current_picture.data[0] + (mb_y * 16* s->linesize ) + mb_x * 16;
uint8_t *img_cb = s->current_picture.data[1] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
uint8_t *img_cr = s->current_picture.data[2] + (mb_y * 8 * s->uvlinesize) + mb_x * 8;
int linesize, uvlinesize;
int dir;
#if 0
if( !s->decode )
return;
#endif
if( h->sps.mb_aff ) {
return;
}
linesize = s->linesize;
uvlinesize = s->uvlinesize;
for( dir = 0; dir < 2; dir++ )
{
int start = 0;
int edge;
if( ( dir == 0 && mb_x == 0 ) || ( dir == 1 && mb_y == 0 ) ) {
start = 1;
}
if( h->disable_deblocking_filter_idc == 2 ) {
}
for( edge = start; edge < 4; edge++ ) {
int mbn_xy = edge > 0 ? mb_xy : ( dir == 0 ? mb_xy -1 : mb_xy - s->mb_stride );
int bS[4];
int qp;
if( IS_INTRA( s->current_picture.mb_type[mb_xy] ) ||
IS_INTRA( s->current_picture.mb_type[mbn_xy] ) ) {
bS[0] = bS[1] = bS[2] = bS[3] = ( edge == 0 ? 4 : 3 );
} else {
int i;
for( i = 0; i < 4; i++ ) {
static const uint8_t block_idx_xy[4][4] = {
{ 0, 2, 8, 10}, { 1, 3, 9, 11},
{ 4, 6, 12, 14}, { 5, 7, 13, 15}
};
int x = dir == 0 ? edge : i;
int y = dir == 0 ? i : edge;
int xn = (x - (dir == 0 ? 1 : 0 ))&0x03;
int yn = (y - (dir == 0 ? 0 : 1 ))&0x03;
if( h->non_zero_count[mb_xy][block_idx_xy[x][y]] != 0 ||
h->non_zero_count[mbn_xy][block_idx_xy[xn][yn]] != 0 ) {
bS[i] = 2;
}
else if( h->slice_type == P_TYPE ) {
const int b8_xy = h->mb2b8_xy[mb_xy]+(y>>1)*h->b8_stride+(x>>1);
const int b8n_xy= h->mb2b8_xy[mbn_xy]+(yn>>1)*h->b8_stride+(xn>>1);
const int b_xy = h->mb2b_xy[mb_xy]+y*h->b_stride+x;
const int bn_xy = h->mb2b_xy[mbn_xy]+yn*h->b_stride+xn;
if( s->current_picture.ref_index[0][b8_xy] != s->current_picture.ref_index[0][b8n_xy] ||
ABS( s->current_picture.motion_val[0][b_xy][0] - s->current_picture.motion_val[0][bn_xy][0] ) >= 4 ||
ABS( s->current_picture.motion_val[0][b_xy][1] - s->current_picture.motion_val[0][bn_xy][1] ) >= 4 )
bS[i] = 1;
else
bS[i] = 0;
}
else {
return;
}
}
}
qp = ( s->current_picture.qscale_table[mb_xy] + s->current_picture.qscale_table[mbn_xy] + 1 ) >> 1;
if( dir == 0 ) {
filter_mb_edgev( h, &img_y[4*edge], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( get_chroma_qp( h, s->current_picture.qscale_table[mb_xy] ) +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgecv( h, &img_cb[2*edge], uvlinesize, bS, chroma_qp );
filter_mb_edgecv( h, &img_cr[2*edge], uvlinesize, bS, chroma_qp );
}
} else {
filter_mb_edgeh( h, &img_y[4*edge*linesize], linesize, bS, qp );
if( (edge&1) == 0 ) {
int chroma_qp = ( get_chroma_qp( h, s->current_picture.qscale_table[mb_xy] ) +
get_chroma_qp( h, s->current_picture.qscale_table[mbn_xy] ) + 1 ) >> 1;
filter_mb_edgech( h, &img_cb[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
filter_mb_edgech( h, &img_cr[2*edge*uvlinesize], uvlinesize, bS, chroma_qp );
}
}
}
}
}
| {
"code": [],
"line_no": []
} | static void FUNC_0( H264Context *VAR_0, int VAR_1, int VAR_2 ) {
MpegEncContext * const s = &VAR_0->s;
const int VAR_3= VAR_1 + VAR_2*s->mb_stride;
uint8_t *img_y = s->current_picture.data[0] + (VAR_2 * 16* s->VAR_4 ) + VAR_1 * 16;
uint8_t *img_cb = s->current_picture.data[1] + (VAR_2 * 8 * s->VAR_5) + VAR_1 * 8;
uint8_t *img_cr = s->current_picture.data[2] + (VAR_2 * 8 * s->VAR_5) + VAR_1 * 8;
int VAR_4, VAR_5;
int VAR_6;
#if 0
if( !s->decode )
return;
#endif
if( VAR_0->sps.mb_aff ) {
return;
}
VAR_4 = s->VAR_4;
VAR_5 = s->VAR_5;
for( VAR_6 = 0; VAR_6 < 2; VAR_6++ )
{
int VAR_7 = 0;
int VAR_8;
if( ( VAR_6 == 0 && VAR_1 == 0 ) || ( VAR_6 == 1 && VAR_2 == 0 ) ) {
VAR_7 = 1;
}
if( VAR_0->disable_deblocking_filter_idc == 2 ) {
}
for( VAR_8 = VAR_7; VAR_8 < 4; VAR_8++ ) {
int VAR_9 = VAR_8 > 0 ? VAR_3 : ( VAR_6 == 0 ? VAR_3 -1 : VAR_3 - s->mb_stride );
int VAR_10[4];
int VAR_11;
if( IS_INTRA( s->current_picture.mb_type[VAR_3] ) ||
IS_INTRA( s->current_picture.mb_type[VAR_9] ) ) {
VAR_10[0] = VAR_10[1] = VAR_10[2] = VAR_10[3] = ( VAR_8 == 0 ? 4 : 3 );
} else {
int VAR_12;
for( VAR_12 = 0; VAR_12 < 4; VAR_12++ ) {
static const uint8_t VAR_13[4][4] = {
{ 0, 2, 8, 10}, { 1, 3, 9, 11},
{ 4, 6, 12, 14}, { 5, 7, 13, 15}
};
int VAR_14 = VAR_6 == 0 ? VAR_8 : VAR_12;
int VAR_15 = VAR_6 == 0 ? VAR_12 : VAR_8;
int VAR_16 = (VAR_14 - (VAR_6 == 0 ? 1 : 0 ))&0x03;
int VAR_17 = (VAR_15 - (VAR_6 == 0 ? 0 : 1 ))&0x03;
if( VAR_0->non_zero_count[VAR_3][VAR_13[VAR_14][VAR_15]] != 0 ||
VAR_0->non_zero_count[VAR_9][VAR_13[VAR_16][VAR_17]] != 0 ) {
VAR_10[VAR_12] = 2;
}
else if( VAR_0->slice_type == P_TYPE ) {
const int VAR_18 = VAR_0->mb2b8_xy[VAR_3]+(VAR_15>>1)*VAR_0->b8_stride+(VAR_14>>1);
const int VAR_19= VAR_0->mb2b8_xy[VAR_9]+(VAR_17>>1)*VAR_0->b8_stride+(VAR_16>>1);
const int VAR_20 = VAR_0->mb2b_xy[VAR_3]+VAR_15*VAR_0->b_stride+VAR_14;
const int VAR_21 = VAR_0->mb2b_xy[VAR_9]+VAR_17*VAR_0->b_stride+VAR_16;
if( s->current_picture.ref_index[0][VAR_18] != s->current_picture.ref_index[0][VAR_19] ||
ABS( s->current_picture.motion_val[0][VAR_20][0] - s->current_picture.motion_val[0][VAR_21][0] ) >= 4 ||
ABS( s->current_picture.motion_val[0][VAR_20][1] - s->current_picture.motion_val[0][VAR_21][1] ) >= 4 )
VAR_10[VAR_12] = 1;
else
VAR_10[VAR_12] = 0;
}
else {
return;
}
}
}
VAR_11 = ( s->current_picture.qscale_table[VAR_3] + s->current_picture.qscale_table[VAR_9] + 1 ) >> 1;
if( VAR_6 == 0 ) {
filter_mb_edgev( VAR_0, &img_y[4*VAR_8], VAR_4, VAR_10, VAR_11 );
if( (VAR_8&1) == 0 ) {
int VAR_23 = ( get_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_3] ) +
get_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_9] ) + 1 ) >> 1;
filter_mb_edgecv( VAR_0, &img_cb[2*VAR_8], VAR_5, VAR_10, VAR_23 );
filter_mb_edgecv( VAR_0, &img_cr[2*VAR_8], VAR_5, VAR_10, VAR_23 );
}
} else {
filter_mb_edgeh( VAR_0, &img_y[4*VAR_8*VAR_4], VAR_4, VAR_10, VAR_11 );
if( (VAR_8&1) == 0 ) {
int VAR_23 = ( get_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_3] ) +
get_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_9] ) + 1 ) >> 1;
filter_mb_edgech( VAR_0, &img_cb[2*VAR_8*VAR_5], VAR_5, VAR_10, VAR_23 );
filter_mb_edgech( VAR_0, &img_cr[2*VAR_8*VAR_5], VAR_5, VAR_10, VAR_23 );
}
}
}
}
}
| [
"static void FUNC_0( H264Context *VAR_0, int VAR_1, int VAR_2 ) {",
"MpegEncContext * const s = &VAR_0->s;",
"const int VAR_3= VAR_1 + VAR_2*s->mb_stride;",
"uint8_t *img_y = s->current_picture.data[0] + (VAR_2 * 16* s->VAR_4 ) + VAR_1 * 16;",
"uint8_t *img_cb = s->current_picture.data[1] + (VAR_2 * 8 * s->VAR_5) + VAR_1 * 8;",
"uint8_t *img_cr = s->current_picture.data[2] + (VAR_2 * 8 * s->VAR_5) + VAR_1 * 8;",
"int VAR_4, VAR_5;",
"int VAR_6;",
"#if 0\nif( !s->decode )\nreturn;",
"#endif\nif( VAR_0->sps.mb_aff ) {",
"return;",
"}",
"VAR_4 = s->VAR_4;",
"VAR_5 = s->VAR_5;",
"for( VAR_6 = 0; VAR_6 < 2; VAR_6++ )",
"{",
"int VAR_7 = 0;",
"int VAR_8;",
"if( ( VAR_6 == 0 && VAR_1 == 0 ) || ( VAR_6 == 1 && VAR_2 == 0 ) ) {",
"VAR_7 = 1;",
"}",
"if( VAR_0->disable_deblocking_filter_idc == 2 ) {",
"}",
"for( VAR_8 = VAR_7; VAR_8 < 4; VAR_8++ ) {",
"int VAR_9 = VAR_8 > 0 ? VAR_3 : ( VAR_6 == 0 ? VAR_3 -1 : VAR_3 - s->mb_stride );",
"int VAR_10[4];",
"int VAR_11;",
"if( IS_INTRA( s->current_picture.mb_type[VAR_3] ) ||\nIS_INTRA( s->current_picture.mb_type[VAR_9] ) ) {",
"VAR_10[0] = VAR_10[1] = VAR_10[2] = VAR_10[3] = ( VAR_8 == 0 ? 4 : 3 );",
"} else {",
"int VAR_12;",
"for( VAR_12 = 0; VAR_12 < 4; VAR_12++ ) {",
"static const uint8_t VAR_13[4][4] = {",
"{ 0, 2, 8, 10}, { 1, 3, 9, 11},",
"{ 4, 6, 12, 14}, { 5, 7, 13, 15}",
"};",
"int VAR_14 = VAR_6 == 0 ? VAR_8 : VAR_12;",
"int VAR_15 = VAR_6 == 0 ? VAR_12 : VAR_8;",
"int VAR_16 = (VAR_14 - (VAR_6 == 0 ? 1 : 0 ))&0x03;",
"int VAR_17 = (VAR_15 - (VAR_6 == 0 ? 0 : 1 ))&0x03;",
"if( VAR_0->non_zero_count[VAR_3][VAR_13[VAR_14][VAR_15]] != 0 ||\nVAR_0->non_zero_count[VAR_9][VAR_13[VAR_16][VAR_17]] != 0 ) {",
"VAR_10[VAR_12] = 2;",
"}",
"else if( VAR_0->slice_type == P_TYPE ) {",
"const int VAR_18 = VAR_0->mb2b8_xy[VAR_3]+(VAR_15>>1)*VAR_0->b8_stride+(VAR_14>>1);",
"const int VAR_19= VAR_0->mb2b8_xy[VAR_9]+(VAR_17>>1)*VAR_0->b8_stride+(VAR_16>>1);",
"const int VAR_20 = VAR_0->mb2b_xy[VAR_3]+VAR_15*VAR_0->b_stride+VAR_14;",
"const int VAR_21 = VAR_0->mb2b_xy[VAR_9]+VAR_17*VAR_0->b_stride+VAR_16;",
"if( s->current_picture.ref_index[0][VAR_18] != s->current_picture.ref_index[0][VAR_19] ||\nABS( s->current_picture.motion_val[0][VAR_20][0] - s->current_picture.motion_val[0][VAR_21][0] ) >= 4 ||\nABS( s->current_picture.motion_val[0][VAR_20][1] - s->current_picture.motion_val[0][VAR_21][1] ) >= 4 )\nVAR_10[VAR_12] = 1;",
"else\nVAR_10[VAR_12] = 0;",
"}",
"else {",
"return;",
"}",
"}",
"}",
"VAR_11 = ( s->current_picture.qscale_table[VAR_3] + s->current_picture.qscale_table[VAR_9] + 1 ) >> 1;",
"if( VAR_6 == 0 ) {",
"filter_mb_edgev( VAR_0, &img_y[4*VAR_8], VAR_4, VAR_10, VAR_11 );",
"if( (VAR_8&1) == 0 ) {",
"int VAR_23 = ( get_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_3] ) +\nget_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_9] ) + 1 ) >> 1;",
"filter_mb_edgecv( VAR_0, &img_cb[2*VAR_8], VAR_5, VAR_10, VAR_23 );",
"filter_mb_edgecv( VAR_0, &img_cr[2*VAR_8], VAR_5, VAR_10, VAR_23 );",
"}",
"} else {",
"filter_mb_edgeh( VAR_0, &img_y[4*VAR_8*VAR_4], VAR_4, VAR_10, VAR_11 );",
"if( (VAR_8&1) == 0 ) {",
"int VAR_23 = ( get_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_3] ) +\nget_chroma_qp( VAR_0, s->current_picture.qscale_table[VAR_9] ) + 1 ) >> 1;",
"filter_mb_edgech( VAR_0, &img_cb[2*VAR_8*VAR_5], VAR_5, VAR_10, VAR_23 );",
"filter_mb_edgech( VAR_0, &img_cr[2*VAR_8*VAR_5], VAR_5, VAR_10, VAR_23 );",
"}",
"}",
"}",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
45
],
[
47
],
[
49
],
[
51
],
[
57
],
[
59
],
[
61
],
[
65
],
[
67
],
[
73
],
[
77
],
[
79
],
[
81
],
[
85,
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
107
],
[
109
],
[
111
],
[
113
],
[
117,
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
133
],
[
135,
137,
139,
141
],
[
143,
145
],
[
147
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
165
],
[
167
],
[
169
],
[
171
],
[
173,
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189,
191
],
[
193
],
[
195
],
[
197
],
[
199
],
[
201
],
[
203
],
[
205
]
] |
25,120 | void mpeg_motion_internal(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int field_based,
int bottom_field,
int field_select,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
int motion_x,
int motion_y,
int h,
int is_mpeg12,
int mb_y)
{
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int dxy, uvdxy, mx, my, src_x, src_y,
uvsrc_x, uvsrc_y, v_edge_pos;
ptrdiff_t uvlinesize, linesize;
#if 0
if (s->quarter_sample) {
motion_x >>= 1;
motion_y >>= 1;
}
#endif
v_edge_pos = s->v_edge_pos >> field_based;
linesize = s->current_picture.f.linesize[0] << field_based;
uvlinesize = s->current_picture.f.linesize[1] << field_based;
dxy = ((motion_y & 1) << 1) | (motion_x & 1);
src_x = s->mb_x * 16 + (motion_x >> 1);
src_y = (mb_y << (4 - field_based)) + (motion_y >> 1);
if (!is_mpeg12 && s->out_format == FMT_H263) {
if ((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based) {
mx = (motion_x >> 1) | (motion_x & 1);
my = motion_y >> 1;
uvdxy = ((my & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
} else {
uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
uvsrc_x = src_x >> 1;
uvsrc_y = src_y >> 1;
}
// Even chroma mv's are full pel in H261
} else if (!is_mpeg12 && s->out_format == FMT_H261) {
mx = motion_x / 4;
my = motion_y / 4;
uvdxy = 0;
uvsrc_x = s->mb_x * 8 + mx;
uvsrc_y = mb_y * 8 + my;
} else {
if (s->chroma_y_shift) {
mx = motion_x / 2;
my = motion_y / 2;
uvdxy = ((my & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
} else {
if (s->chroma_x_shift) {
// Chroma422
mx = motion_x / 2;
uvdxy = ((motion_y & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = src_y;
} else {
// Chroma444
uvdxy = dxy;
uvsrc_x = src_x;
uvsrc_y = src_y;
}
}
}
ptr_y = ref_picture[0] + src_y * linesize + src_x;
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 16, 0) ||
(unsigned)src_y > FFMAX(v_edge_pos - (motion_y & 1) - h, 0)) {
if (is_mpeg12 ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
av_log(s->avctx, AV_LOG_DEBUG,
"MPEG motion vector out of boundary (%d %d)\n", src_x,
src_y);
return;
}
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y,
s->linesize, s->linesize,
17, 17 + field_based,
src_x, src_y << field_based,
s->h_edge_pos, s->v_edge_pos);
ptr_y = s->edge_emu_buffer;
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = s->edge_emu_buffer + 18 * s->linesize;
s->vdsp.emulated_edge_mc(uvbuf, ptr_cb,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y << field_based,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y << field_based,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr_cb = uvbuf;
ptr_cr = uvbuf + 16;
}
}
/* FIXME use this for field pix too instead of the obnoxious hack which
* changes picture.data */
if (bottom_field) {
dest_y += s->linesize;
dest_cb += s->uvlinesize;
dest_cr += s->uvlinesize;
}
if (field_select) {
ptr_y += s->linesize;
ptr_cb += s->uvlinesize;
ptr_cr += s->uvlinesize;
}
pix_op[0][dxy](dest_y, ptr_y, linesize, h);
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
pix_op[s->chroma_x_shift][uvdxy]
(dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
pix_op[s->chroma_x_shift][uvdxy]
(dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
}
if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
s->out_format == FMT_H261) {
ff_h261_loop_filter(s);
}
}
| true | FFmpeg | f6774f905fb3cfdc319523ac640be30b14c1bc55 | void mpeg_motion_internal(MpegEncContext *s,
uint8_t *dest_y,
uint8_t *dest_cb,
uint8_t *dest_cr,
int field_based,
int bottom_field,
int field_select,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
int motion_x,
int motion_y,
int h,
int is_mpeg12,
int mb_y)
{
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int dxy, uvdxy, mx, my, src_x, src_y,
uvsrc_x, uvsrc_y, v_edge_pos;
ptrdiff_t uvlinesize, linesize;
#if 0
if (s->quarter_sample) {
motion_x >>= 1;
motion_y >>= 1;
}
#endif
v_edge_pos = s->v_edge_pos >> field_based;
linesize = s->current_picture.f.linesize[0] << field_based;
uvlinesize = s->current_picture.f.linesize[1] << field_based;
dxy = ((motion_y & 1) << 1) | (motion_x & 1);
src_x = s->mb_x * 16 + (motion_x >> 1);
src_y = (mb_y << (4 - field_based)) + (motion_y >> 1);
if (!is_mpeg12 && s->out_format == FMT_H263) {
if ((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based) {
mx = (motion_x >> 1) | (motion_x & 1);
my = motion_y >> 1;
uvdxy = ((my & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
} else {
uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
uvsrc_x = src_x >> 1;
uvsrc_y = src_y >> 1;
}
} else if (!is_mpeg12 && s->out_format == FMT_H261) {
mx = motion_x / 4;
my = motion_y / 4;
uvdxy = 0;
uvsrc_x = s->mb_x * 8 + mx;
uvsrc_y = mb_y * 8 + my;
} else {
if (s->chroma_y_shift) {
mx = motion_x / 2;
my = motion_y / 2;
uvdxy = ((my & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = (mb_y << (3 - field_based)) + (my >> 1);
} else {
if (s->chroma_x_shift) {
mx = motion_x / 2;
uvdxy = ((motion_y & 1) << 1) | (mx & 1);
uvsrc_x = s->mb_x * 8 + (mx >> 1);
uvsrc_y = src_y;
} else {
uvdxy = dxy;
uvsrc_x = src_x;
uvsrc_y = src_y;
}
}
}
ptr_y = ref_picture[0] + src_y * linesize + src_x;
ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
if ((unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x & 1) - 16, 0) ||
(unsigned)src_y > FFMAX(v_edge_pos - (motion_y & 1) - h, 0)) {
if (is_mpeg12 ||
s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
s->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
av_log(s->avctx, AV_LOG_DEBUG,
"MPEG motion vector out of boundary (%d %d)\n", src_x,
src_y);
return;
}
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr_y,
s->linesize, s->linesize,
17, 17 + field_based,
src_x, src_y << field_based,
s->h_edge_pos, s->v_edge_pos);
ptr_y = s->edge_emu_buffer;
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = s->edge_emu_buffer + 18 * s->linesize;
s->vdsp.emulated_edge_mc(uvbuf, ptr_cb,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y << field_based,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
s->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,
s->uvlinesize, s->uvlinesize,
9, 9 + field_based,
uvsrc_x, uvsrc_y << field_based,
s->h_edge_pos >> 1, s->v_edge_pos >> 1);
ptr_cb = uvbuf;
ptr_cr = uvbuf + 16;
}
}
if (bottom_field) {
dest_y += s->linesize;
dest_cb += s->uvlinesize;
dest_cr += s->uvlinesize;
}
if (field_select) {
ptr_y += s->linesize;
ptr_cb += s->uvlinesize;
ptr_cr += s->uvlinesize;
}
pix_op[0][dxy](dest_y, ptr_y, linesize, h);
if (!CONFIG_GRAY || !(s->flags & CODEC_FLAG_GRAY)) {
pix_op[s->chroma_x_shift][uvdxy]
(dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
pix_op[s->chroma_x_shift][uvdxy]
(dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
}
if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
s->out_format == FMT_H261) {
ff_h261_loop_filter(s);
}
}
| {
"code": [
" linesize = s->current_picture.f.linesize[0] << field_based;",
" uvlinesize = s->current_picture.f.linesize[1] << field_based;"
],
"line_no": [
57,
59
]
} | void FUNC_0(MpegEncContext *VAR_0,
uint8_t *VAR_1,
uint8_t *VAR_2,
uint8_t *VAR_3,
int VAR_4,
int VAR_5,
int VAR_6,
uint8_t **VAR_7,
VAR_8 (*pix_op)[4],
int VAR_9,
int VAR_10,
int VAR_11,
int VAR_12,
int VAR_13)
{
uint8_t *ptr_y, *ptr_cb, *ptr_cr;
int VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19,
VAR_20, VAR_21, VAR_22;
ptrdiff_t uvlinesize, linesize;
#if 0
if (VAR_0->quarter_sample) {
VAR_9 >>= 1;
VAR_10 >>= 1;
}
#endif
VAR_22 = VAR_0->VAR_22 >> VAR_4;
linesize = VAR_0->current_picture.f.linesize[0] << VAR_4;
uvlinesize = VAR_0->current_picture.f.linesize[1] << VAR_4;
VAR_14 = ((VAR_10 & 1) << 1) | (VAR_9 & 1);
VAR_18 = VAR_0->mb_x * 16 + (VAR_9 >> 1);
VAR_19 = (VAR_13 << (4 - VAR_4)) + (VAR_10 >> 1);
if (!VAR_12 && VAR_0->out_format == FMT_H263) {
if ((VAR_0->workaround_bugs & FF_BUG_HPEL_CHROMA) && VAR_4) {
VAR_16 = (VAR_9 >> 1) | (VAR_9 & 1);
VAR_17 = VAR_10 >> 1;
VAR_15 = ((VAR_17 & 1) << 1) | (VAR_16 & 1);
VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);
VAR_21 = (VAR_13 << (3 - VAR_4)) + (VAR_17 >> 1);
} else {
VAR_15 = VAR_14 | (VAR_10 & 2) | ((VAR_9 & 2) >> 1);
VAR_20 = VAR_18 >> 1;
VAR_21 = VAR_19 >> 1;
}
} else if (!VAR_12 && VAR_0->out_format == FMT_H261) {
VAR_16 = VAR_9 / 4;
VAR_17 = VAR_10 / 4;
VAR_15 = 0;
VAR_20 = VAR_0->mb_x * 8 + VAR_16;
VAR_21 = VAR_13 * 8 + VAR_17;
} else {
if (VAR_0->chroma_y_shift) {
VAR_16 = VAR_9 / 2;
VAR_17 = VAR_10 / 2;
VAR_15 = ((VAR_17 & 1) << 1) | (VAR_16 & 1);
VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);
VAR_21 = (VAR_13 << (3 - VAR_4)) + (VAR_17 >> 1);
} else {
if (VAR_0->chroma_x_shift) {
VAR_16 = VAR_9 / 2;
VAR_15 = ((VAR_10 & 1) << 1) | (VAR_16 & 1);
VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);
VAR_21 = VAR_19;
} else {
VAR_15 = VAR_14;
VAR_20 = VAR_18;
VAR_21 = VAR_19;
}
}
}
ptr_y = VAR_7[0] + VAR_19 * linesize + VAR_18;
ptr_cb = VAR_7[1] + VAR_21 * uvlinesize + VAR_20;
ptr_cr = VAR_7[2] + VAR_21 * uvlinesize + VAR_20;
if ((unsigned)VAR_18 > FFMAX(VAR_0->h_edge_pos - (VAR_9 & 1) - 16, 0) ||
(unsigned)VAR_19 > FFMAX(VAR_22 - (VAR_10 & 1) - VAR_11, 0)) {
if (VAR_12 ||
VAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
VAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
av_log(VAR_0->avctx, AV_LOG_DEBUG,
"MPEG motion vector out of boundary (%d %d)\n", VAR_18,
VAR_19);
return;
}
VAR_0->vdsp.emulated_edge_mc(VAR_0->edge_emu_buffer, ptr_y,
VAR_0->linesize, VAR_0->linesize,
17, 17 + VAR_4,
VAR_18, VAR_19 << VAR_4,
VAR_0->h_edge_pos, VAR_0->VAR_22);
ptr_y = VAR_0->edge_emu_buffer;
if (!CONFIG_GRAY || !(VAR_0->flags & CODEC_FLAG_GRAY)) {
uint8_t *uvbuf = VAR_0->edge_emu_buffer + 18 * VAR_0->linesize;
VAR_0->vdsp.emulated_edge_mc(uvbuf, ptr_cb,
VAR_0->uvlinesize, VAR_0->uvlinesize,
9, 9 + VAR_4,
VAR_20, VAR_21 << VAR_4,
VAR_0->h_edge_pos >> 1, VAR_0->VAR_22 >> 1);
VAR_0->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,
VAR_0->uvlinesize, VAR_0->uvlinesize,
9, 9 + VAR_4,
VAR_20, VAR_21 << VAR_4,
VAR_0->h_edge_pos >> 1, VAR_0->VAR_22 >> 1);
ptr_cb = uvbuf;
ptr_cr = uvbuf + 16;
}
}
if (VAR_5) {
VAR_1 += VAR_0->linesize;
VAR_2 += VAR_0->uvlinesize;
VAR_3 += VAR_0->uvlinesize;
}
if (VAR_6) {
ptr_y += VAR_0->linesize;
ptr_cb += VAR_0->uvlinesize;
ptr_cr += VAR_0->uvlinesize;
}
pix_op[0][VAR_14](VAR_1, ptr_y, linesize, VAR_11);
if (!CONFIG_GRAY || !(VAR_0->flags & CODEC_FLAG_GRAY)) {
pix_op[VAR_0->chroma_x_shift][VAR_15]
(VAR_2, ptr_cb, uvlinesize, VAR_11 >> VAR_0->chroma_y_shift);
pix_op[VAR_0->chroma_x_shift][VAR_15]
(VAR_3, ptr_cr, uvlinesize, VAR_11 >> VAR_0->chroma_y_shift);
}
if (!VAR_12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
VAR_0->out_format == FMT_H261) {
ff_h261_loop_filter(VAR_0);
}
}
| [
"void FUNC_0(MpegEncContext *VAR_0,\nuint8_t *VAR_1,\nuint8_t *VAR_2,\nuint8_t *VAR_3,\nint VAR_4,\nint VAR_5,\nint VAR_6,\nuint8_t **VAR_7,\nVAR_8 (*pix_op)[4],\nint VAR_9,\nint VAR_10,\nint VAR_11,\nint VAR_12,\nint VAR_13)\n{",
"uint8_t *ptr_y, *ptr_cb, *ptr_cr;",
"int VAR_14, VAR_15, VAR_16, VAR_17, VAR_18, VAR_19,\nVAR_20, VAR_21, VAR_22;",
"ptrdiff_t uvlinesize, linesize;",
"#if 0\nif (VAR_0->quarter_sample) {",
"VAR_9 >>= 1;",
"VAR_10 >>= 1;",
"}",
"#endif\nVAR_22 = VAR_0->VAR_22 >> VAR_4;",
"linesize = VAR_0->current_picture.f.linesize[0] << VAR_4;",
"uvlinesize = VAR_0->current_picture.f.linesize[1] << VAR_4;",
"VAR_14 = ((VAR_10 & 1) << 1) | (VAR_9 & 1);",
"VAR_18 = VAR_0->mb_x * 16 + (VAR_9 >> 1);",
"VAR_19 = (VAR_13 << (4 - VAR_4)) + (VAR_10 >> 1);",
"if (!VAR_12 && VAR_0->out_format == FMT_H263) {",
"if ((VAR_0->workaround_bugs & FF_BUG_HPEL_CHROMA) && VAR_4) {",
"VAR_16 = (VAR_9 >> 1) | (VAR_9 & 1);",
"VAR_17 = VAR_10 >> 1;",
"VAR_15 = ((VAR_17 & 1) << 1) | (VAR_16 & 1);",
"VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);",
"VAR_21 = (VAR_13 << (3 - VAR_4)) + (VAR_17 >> 1);",
"} else {",
"VAR_15 = VAR_14 | (VAR_10 & 2) | ((VAR_9 & 2) >> 1);",
"VAR_20 = VAR_18 >> 1;",
"VAR_21 = VAR_19 >> 1;",
"}",
"} else if (!VAR_12 && VAR_0->out_format == FMT_H261) {",
"VAR_16 = VAR_9 / 4;",
"VAR_17 = VAR_10 / 4;",
"VAR_15 = 0;",
"VAR_20 = VAR_0->mb_x * 8 + VAR_16;",
"VAR_21 = VAR_13 * 8 + VAR_17;",
"} else {",
"if (VAR_0->chroma_y_shift) {",
"VAR_16 = VAR_9 / 2;",
"VAR_17 = VAR_10 / 2;",
"VAR_15 = ((VAR_17 & 1) << 1) | (VAR_16 & 1);",
"VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);",
"VAR_21 = (VAR_13 << (3 - VAR_4)) + (VAR_17 >> 1);",
"} else {",
"if (VAR_0->chroma_x_shift) {",
"VAR_16 = VAR_9 / 2;",
"VAR_15 = ((VAR_10 & 1) << 1) | (VAR_16 & 1);",
"VAR_20 = VAR_0->mb_x * 8 + (VAR_16 >> 1);",
"VAR_21 = VAR_19;",
"} else {",
"VAR_15 = VAR_14;",
"VAR_20 = VAR_18;",
"VAR_21 = VAR_19;",
"}",
"}",
"}",
"ptr_y = VAR_7[0] + VAR_19 * linesize + VAR_18;",
"ptr_cb = VAR_7[1] + VAR_21 * uvlinesize + VAR_20;",
"ptr_cr = VAR_7[2] + VAR_21 * uvlinesize + VAR_20;",
"if ((unsigned)VAR_18 > FFMAX(VAR_0->h_edge_pos - (VAR_9 & 1) - 16, 0) ||\n(unsigned)VAR_19 > FFMAX(VAR_22 - (VAR_10 & 1) - VAR_11, 0)) {",
"if (VAR_12 ||\nVAR_0->codec_id == AV_CODEC_ID_MPEG2VIDEO ||\nVAR_0->codec_id == AV_CODEC_ID_MPEG1VIDEO) {",
"av_log(VAR_0->avctx, AV_LOG_DEBUG,\n\"MPEG motion vector out of boundary (%d %d)\\n\", VAR_18,\nVAR_19);",
"return;",
"}",
"VAR_0->vdsp.emulated_edge_mc(VAR_0->edge_emu_buffer, ptr_y,\nVAR_0->linesize, VAR_0->linesize,\n17, 17 + VAR_4,\nVAR_18, VAR_19 << VAR_4,\nVAR_0->h_edge_pos, VAR_0->VAR_22);",
"ptr_y = VAR_0->edge_emu_buffer;",
"if (!CONFIG_GRAY || !(VAR_0->flags & CODEC_FLAG_GRAY)) {",
"uint8_t *uvbuf = VAR_0->edge_emu_buffer + 18 * VAR_0->linesize;",
"VAR_0->vdsp.emulated_edge_mc(uvbuf, ptr_cb,\nVAR_0->uvlinesize, VAR_0->uvlinesize,\n9, 9 + VAR_4,\nVAR_20, VAR_21 << VAR_4,\nVAR_0->h_edge_pos >> 1, VAR_0->VAR_22 >> 1);",
"VAR_0->vdsp.emulated_edge_mc(uvbuf + 16, ptr_cr,\nVAR_0->uvlinesize, VAR_0->uvlinesize,\n9, 9 + VAR_4,\nVAR_20, VAR_21 << VAR_4,\nVAR_0->h_edge_pos >> 1, VAR_0->VAR_22 >> 1);",
"ptr_cb = uvbuf;",
"ptr_cr = uvbuf + 16;",
"}",
"}",
"if (VAR_5) {",
"VAR_1 += VAR_0->linesize;",
"VAR_2 += VAR_0->uvlinesize;",
"VAR_3 += VAR_0->uvlinesize;",
"}",
"if (VAR_6) {",
"ptr_y += VAR_0->linesize;",
"ptr_cb += VAR_0->uvlinesize;",
"ptr_cr += VAR_0->uvlinesize;",
"}",
"pix_op[0][VAR_14](VAR_1, ptr_y, linesize, VAR_11);",
"if (!CONFIG_GRAY || !(VAR_0->flags & CODEC_FLAG_GRAY)) {",
"pix_op[VAR_0->chroma_x_shift][VAR_15]\n(VAR_2, ptr_cb, uvlinesize, VAR_11 >> VAR_0->chroma_y_shift);",
"pix_op[VAR_0->chroma_x_shift][VAR_15]\n(VAR_3, ptr_cr, uvlinesize, VAR_11 >> VAR_0->chroma_y_shift);",
"}",
"if (!VAR_12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&\nVAR_0->out_format == FMT_H261) {",
"ff_h261_loop_filter(VAR_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
] | [
[
1,
3,
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27,
29
],
[
31
],
[
33,
35
],
[
37
],
[
41,
43
],
[
45
],
[
47
],
[
49
],
[
51,
55
],
[
57
],
[
59
],
[
63
],
[
65
],
[
67
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121
],
[
123
],
[
125
],
[
129
],
[
131
],
[
133
],
[
135
],
[
137
],
[
141
],
[
143
],
[
145
],
[
147
],
[
149
],
[
151
],
[
155
],
[
157
],
[
159
],
[
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
],
[
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
245
],
[
247
],
[
249
],
[
251
],
[
253
],
[
257
],
[
261
],
[
263,
265
],
[
267,
269
],
[
271
],
[
273,
275
],
[
277
],
[
279
],
[
281
]
] |
25,121 | static void i6300esb_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->config_read = i6300esb_config_read;
k->config_write = i6300esb_config_write;
k->realize = i6300esb_realize;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_ESB_9;
k->class_id = PCI_CLASS_SYSTEM_OTHER;
dc->reset = i6300esb_reset;
dc->vmsd = &vmstate_i6300esb;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
} | true | qemu | eb7a20a3616085d46aa6b4b4224e15587ec67e6e | static void i6300esb_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->config_read = i6300esb_config_read;
k->config_write = i6300esb_config_write;
k->realize = i6300esb_realize;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_ESB_9;
k->class_id = PCI_CLASS_SYSTEM_OTHER;
dc->reset = i6300esb_reset;
dc->vmsd = &vmstate_i6300esb;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
} | {
"code": [],
"line_no": []
} | static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)
{
DeviceClass *dc = DEVICE_CLASS(VAR_0);
PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0);
k->config_read = i6300esb_config_read;
k->config_write = i6300esb_config_write;
k->realize = i6300esb_realize;
k->vendor_id = PCI_VENDOR_ID_INTEL;
k->device_id = PCI_DEVICE_ID_INTEL_ESB_9;
k->class_id = PCI_CLASS_SYSTEM_OTHER;
dc->reset = i6300esb_reset;
dc->vmsd = &vmstate_i6300esb;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
} | [
"static void FUNC_0(ObjectClass *VAR_0, void *VAR_1)\n{",
"DeviceClass *dc = DEVICE_CLASS(VAR_0);",
"PCIDeviceClass *k = PCI_DEVICE_CLASS(VAR_0);",
"k->config_read = i6300esb_config_read;",
"k->config_write = i6300esb_config_write;",
"k->realize = i6300esb_realize;",
"k->vendor_id = PCI_VENDOR_ID_INTEL;",
"k->device_id = PCI_DEVICE_ID_INTEL_ESB_9;",
"k->class_id = PCI_CLASS_SYSTEM_OTHER;",
"dc->reset = i6300esb_reset;",
"dc->vmsd = &vmstate_i6300esb;",
"set_bit(DEVICE_CATEGORY_MISC, dc->categories);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13
],
[
15
],
[
18
],
[
20
],
[
22
],
[
24
],
[
26
],
[
28
],
[
30
]
] |
25,122 | BlockDriverAIOCB *win32_aio_submit(BlockDriverState *bs,
QEMUWin32AIOState *aio, HANDLE hfile,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
struct QEMUWin32AIOCB *waiocb;
uint64_t offset = sector_num * 512;
DWORD rc;
waiocb = qemu_aio_get(&win32_aiocb_info, bs, cb, opaque);
waiocb->nbytes = nb_sectors * 512;
waiocb->qiov = qiov;
waiocb->is_read = (type == QEMU_AIO_READ);
if (qiov->niov > 1) {
waiocb->buf = qemu_blockalign(bs, qiov->size);
if (type & QEMU_AIO_WRITE) {
iov_to_buf(qiov->iov, qiov->niov, 0, waiocb->buf, qiov->size);
}
waiocb->is_linear = false;
} else {
waiocb->buf = qiov->iov[0].iov_base;
waiocb->is_linear = true;
}
memset(&waiocb->ov, 0, sizeof(waiocb->ov));
waiocb->ov.Offset = (DWORD)offset;
waiocb->ov.OffsetHigh = (DWORD)(offset >> 32);
waiocb->ov.hEvent = event_notifier_get_handle(&aio->e);
aio->count++;
if (type & QEMU_AIO_READ) {
rc = ReadFile(hfile, waiocb->buf, waiocb->nbytes, NULL, &waiocb->ov);
} else {
rc = WriteFile(hfile, waiocb->buf, waiocb->nbytes, NULL, &waiocb->ov);
}
if(rc == 0 && GetLastError() != ERROR_IO_PENDING) {
goto out_dec_count;
}
return &waiocb->common;
out_dec_count:
aio->count--;
qemu_aio_release(waiocb);
return NULL;
}
| true | qemu | 4b6af3d58a73193017926dd59de3b3e7b4890323 | BlockDriverAIOCB *win32_aio_submit(BlockDriverState *bs,
QEMUWin32AIOState *aio, HANDLE hfile,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
struct QEMUWin32AIOCB *waiocb;
uint64_t offset = sector_num * 512;
DWORD rc;
waiocb = qemu_aio_get(&win32_aiocb_info, bs, cb, opaque);
waiocb->nbytes = nb_sectors * 512;
waiocb->qiov = qiov;
waiocb->is_read = (type == QEMU_AIO_READ);
if (qiov->niov > 1) {
waiocb->buf = qemu_blockalign(bs, qiov->size);
if (type & QEMU_AIO_WRITE) {
iov_to_buf(qiov->iov, qiov->niov, 0, waiocb->buf, qiov->size);
}
waiocb->is_linear = false;
} else {
waiocb->buf = qiov->iov[0].iov_base;
waiocb->is_linear = true;
}
memset(&waiocb->ov, 0, sizeof(waiocb->ov));
waiocb->ov.Offset = (DWORD)offset;
waiocb->ov.OffsetHigh = (DWORD)(offset >> 32);
waiocb->ov.hEvent = event_notifier_get_handle(&aio->e);
aio->count++;
if (type & QEMU_AIO_READ) {
rc = ReadFile(hfile, waiocb->buf, waiocb->nbytes, NULL, &waiocb->ov);
} else {
rc = WriteFile(hfile, waiocb->buf, waiocb->nbytes, NULL, &waiocb->ov);
}
if(rc == 0 && GetLastError() != ERROR_IO_PENDING) {
goto out_dec_count;
}
return &waiocb->common;
out_dec_count:
aio->count--;
qemu_aio_release(waiocb);
return NULL;
}
| {
"code": [
" waiocb->buf = qemu_blockalign(bs, qiov->size);"
],
"line_no": [
31
]
} | BlockDriverAIOCB *FUNC_0(BlockDriverState *bs,
QEMUWin32AIOState *aio, HANDLE hfile,
int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
BlockDriverCompletionFunc *cb, void *opaque, int type)
{
struct QEMUWin32AIOCB *VAR_0;
uint64_t offset = sector_num * 512;
DWORD rc;
VAR_0 = qemu_aio_get(&win32_aiocb_info, bs, cb, opaque);
VAR_0->nbytes = nb_sectors * 512;
VAR_0->qiov = qiov;
VAR_0->is_read = (type == QEMU_AIO_READ);
if (qiov->niov > 1) {
VAR_0->buf = qemu_blockalign(bs, qiov->size);
if (type & QEMU_AIO_WRITE) {
iov_to_buf(qiov->iov, qiov->niov, 0, VAR_0->buf, qiov->size);
}
VAR_0->is_linear = false;
} else {
VAR_0->buf = qiov->iov[0].iov_base;
VAR_0->is_linear = true;
}
memset(&VAR_0->ov, 0, sizeof(VAR_0->ov));
VAR_0->ov.Offset = (DWORD)offset;
VAR_0->ov.OffsetHigh = (DWORD)(offset >> 32);
VAR_0->ov.hEvent = event_notifier_get_handle(&aio->e);
aio->count++;
if (type & QEMU_AIO_READ) {
rc = ReadFile(hfile, VAR_0->buf, VAR_0->nbytes, NULL, &VAR_0->ov);
} else {
rc = WriteFile(hfile, VAR_0->buf, VAR_0->nbytes, NULL, &VAR_0->ov);
}
if(rc == 0 && GetLastError() != ERROR_IO_PENDING) {
goto out_dec_count;
}
return &VAR_0->common;
out_dec_count:
aio->count--;
qemu_aio_release(VAR_0);
return NULL;
}
| [
"BlockDriverAIOCB *FUNC_0(BlockDriverState *bs,\nQEMUWin32AIOState *aio, HANDLE hfile,\nint64_t sector_num, QEMUIOVector *qiov, int nb_sectors,\nBlockDriverCompletionFunc *cb, void *opaque, int type)\n{",
"struct QEMUWin32AIOCB *VAR_0;",
"uint64_t offset = sector_num * 512;",
"DWORD rc;",
"VAR_0 = qemu_aio_get(&win32_aiocb_info, bs, cb, opaque);",
"VAR_0->nbytes = nb_sectors * 512;",
"VAR_0->qiov = qiov;",
"VAR_0->is_read = (type == QEMU_AIO_READ);",
"if (qiov->niov > 1) {",
"VAR_0->buf = qemu_blockalign(bs, qiov->size);",
"if (type & QEMU_AIO_WRITE) {",
"iov_to_buf(qiov->iov, qiov->niov, 0, VAR_0->buf, qiov->size);",
"}",
"VAR_0->is_linear = false;",
"} else {",
"VAR_0->buf = qiov->iov[0].iov_base;",
"VAR_0->is_linear = true;",
"}",
"memset(&VAR_0->ov, 0, sizeof(VAR_0->ov));",
"VAR_0->ov.Offset = (DWORD)offset;",
"VAR_0->ov.OffsetHigh = (DWORD)(offset >> 32);",
"VAR_0->ov.hEvent = event_notifier_get_handle(&aio->e);",
"aio->count++;",
"if (type & QEMU_AIO_READ) {",
"rc = ReadFile(hfile, VAR_0->buf, VAR_0->nbytes, NULL, &VAR_0->ov);",
"} else {",
"rc = WriteFile(hfile, VAR_0->buf, VAR_0->nbytes, NULL, &VAR_0->ov);",
"}",
"if(rc == 0 && GetLastError() != ERROR_IO_PENDING) {",
"goto out_dec_count;",
"}",
"return &VAR_0->common;",
"out_dec_count:\naio->count--;",
"qemu_aio_release(VAR_0);",
"return NULL;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5,
7,
9
],
[
11
],
[
13
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
61
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
81
],
[
85,
87
],
[
89
],
[
91
],
[
93
]
] |
25,124 | static av_cold int vp9_decode_free(AVCodecContext *ctx)
{
VP9Context *s = ctx->priv_data;
int i;
for (i = 0; i < 2; i++) {
if (s->frames[i].tf.f->data[0])
vp9_unref_frame(ctx, &s->frames[i]);
av_frame_free(&s->frames[i].tf.f);
}
for (i = 0; i < 8; i++) {
if (s->refs[i].f->data[0])
ff_thread_release_buffer(ctx, &s->refs[i]);
av_frame_free(&s->refs[i].f);
if (s->next_refs[i].f->data[0])
ff_thread_release_buffer(ctx, &s->next_refs[i]);
av_frame_free(&s->next_refs[i].f);
}
av_freep(&s->above_partition_ctx);
av_freep(&s->c_b);
s->c_b_size = 0;
av_freep(&s->b_base);
av_freep(&s->block_base);
return 0;
}
| true | FFmpeg | 5b0fc078191138795e817244555741356f9d12e9 | static av_cold int vp9_decode_free(AVCodecContext *ctx)
{
VP9Context *s = ctx->priv_data;
int i;
for (i = 0; i < 2; i++) {
if (s->frames[i].tf.f->data[0])
vp9_unref_frame(ctx, &s->frames[i]);
av_frame_free(&s->frames[i].tf.f);
}
for (i = 0; i < 8; i++) {
if (s->refs[i].f->data[0])
ff_thread_release_buffer(ctx, &s->refs[i]);
av_frame_free(&s->refs[i].f);
if (s->next_refs[i].f->data[0])
ff_thread_release_buffer(ctx, &s->next_refs[i]);
av_frame_free(&s->next_refs[i].f);
}
av_freep(&s->above_partition_ctx);
av_freep(&s->c_b);
s->c_b_size = 0;
av_freep(&s->b_base);
av_freep(&s->block_base);
return 0;
}
| {
"code": [
" av_freep(&s->above_partition_ctx);",
" av_freep(&s->b_base);",
" av_freep(&s->block_base);"
],
"line_no": [
37,
43,
45
]
} | static av_cold int FUNC_0(AVCodecContext *ctx)
{
VP9Context *s = ctx->priv_data;
int VAR_0;
for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {
if (s->frames[VAR_0].tf.f->data[0])
vp9_unref_frame(ctx, &s->frames[VAR_0]);
av_frame_free(&s->frames[VAR_0].tf.f);
}
for (VAR_0 = 0; VAR_0 < 8; VAR_0++) {
if (s->refs[VAR_0].f->data[0])
ff_thread_release_buffer(ctx, &s->refs[VAR_0]);
av_frame_free(&s->refs[VAR_0].f);
if (s->next_refs[VAR_0].f->data[0])
ff_thread_release_buffer(ctx, &s->next_refs[VAR_0]);
av_frame_free(&s->next_refs[VAR_0].f);
}
av_freep(&s->above_partition_ctx);
av_freep(&s->c_b);
s->c_b_size = 0;
av_freep(&s->b_base);
av_freep(&s->block_base);
return 0;
}
| [
"static av_cold int FUNC_0(AVCodecContext *ctx)\n{",
"VP9Context *s = ctx->priv_data;",
"int VAR_0;",
"for (VAR_0 = 0; VAR_0 < 2; VAR_0++) {",
"if (s->frames[VAR_0].tf.f->data[0])\nvp9_unref_frame(ctx, &s->frames[VAR_0]);",
"av_frame_free(&s->frames[VAR_0].tf.f);",
"}",
"for (VAR_0 = 0; VAR_0 < 8; VAR_0++) {",
"if (s->refs[VAR_0].f->data[0])\nff_thread_release_buffer(ctx, &s->refs[VAR_0]);",
"av_frame_free(&s->refs[VAR_0].f);",
"if (s->next_refs[VAR_0].f->data[0])\nff_thread_release_buffer(ctx, &s->next_refs[VAR_0]);",
"av_frame_free(&s->next_refs[VAR_0].f);",
"}",
"av_freep(&s->above_partition_ctx);",
"av_freep(&s->c_b);",
"s->c_b_size = 0;",
"av_freep(&s->b_base);",
"av_freep(&s->block_base);",
"return 0;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
1,
1,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11
],
[
13,
15
],
[
17
],
[
19
],
[
21
],
[
23,
25
],
[
27
],
[
29,
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
49
],
[
51
]
] |
25,125 | static int sd_create(const char *filename, QemuOpts *opts,
Error **errp)
{
int ret = 0;
uint32_t vid = 0;
char *backing_file = NULL;
char *buf = NULL;
BDRVSheepdogState *s;
char tag[SD_MAX_VDI_TAG_LEN];
uint32_t snapid;
bool prealloc = false;
s = g_malloc0(sizeof(BDRVSheepdogState));
memset(tag, 0, sizeof(tag));
if (strstr(filename, "://")) {
ret = sd_parse_uri(s, filename, s->name, &snapid, tag);
} else {
ret = parse_vdiname(s, filename, s->name, &snapid, tag);
}
if (ret < 0) {
error_setg(errp, "Can't parse filename");
goto out;
}
s->inode.vdi_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
if (!buf || !strcmp(buf, "off")) {
prealloc = false;
} else if (!strcmp(buf, "full")) {
prealloc = true;
} else {
error_setg(errp, "Invalid preallocation mode: '%s'", buf);
ret = -EINVAL;
goto out;
}
g_free(buf);
buf = qemu_opt_get_del(opts, BLOCK_OPT_REDUNDANCY);
if (buf) {
ret = parse_redundancy(s, buf);
if (ret < 0) {
error_setg(errp, "Invalid redundancy mode: '%s'", buf);
goto out;
}
}
if (s->inode.vdi_size > SD_MAX_VDI_SIZE) {
error_setg(errp, "too big image size");
ret = -EINVAL;
goto out;
}
if (backing_file) {
BlockDriverState *bs;
BDRVSheepdogState *base;
BlockDriver *drv;
/* Currently, only Sheepdog backing image is supported. */
drv = bdrv_find_protocol(backing_file, true);
if (!drv || strcmp(drv->protocol_name, "sheepdog") != 0) {
error_setg(errp, "backing_file must be a sheepdog image");
ret = -EINVAL;
goto out;
}
bs = NULL;
ret = bdrv_open(&bs, backing_file, NULL, NULL, BDRV_O_PROTOCOL, NULL,
errp);
if (ret < 0) {
goto out;
}
base = bs->opaque;
if (!is_snapshot(&base->inode)) {
error_setg(errp, "cannot clone from a non snapshot vdi");
bdrv_unref(bs);
ret = -EINVAL;
goto out;
}
s->inode.vdi_id = base->inode.vdi_id;
bdrv_unref(bs);
}
s->aio_context = qemu_get_aio_context();
ret = do_sd_create(s, &vid, 0, errp);
if (ret) {
goto out;
}
if (prealloc) {
ret = sd_prealloc(filename, errp);
}
out:
g_free(backing_file);
g_free(buf);
g_free(s);
return ret;
}
| true | qemu | 5839e53bbc0fec56021d758aab7610df421ed8c8 | static int sd_create(const char *filename, QemuOpts *opts,
Error **errp)
{
int ret = 0;
uint32_t vid = 0;
char *backing_file = NULL;
char *buf = NULL;
BDRVSheepdogState *s;
char tag[SD_MAX_VDI_TAG_LEN];
uint32_t snapid;
bool prealloc = false;
s = g_malloc0(sizeof(BDRVSheepdogState));
memset(tag, 0, sizeof(tag));
if (strstr(filename, ":
ret = sd_parse_uri(s, filename, s->name, &snapid, tag);
} else {
ret = parse_vdiname(s, filename, s->name, &snapid, tag);
}
if (ret < 0) {
error_setg(errp, "Can't parse filename");
goto out;
}
s->inode.vdi_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0);
backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
buf = qemu_opt_get_del(opts, BLOCK_OPT_PREALLOC);
if (!buf || !strcmp(buf, "off")) {
prealloc = false;
} else if (!strcmp(buf, "full")) {
prealloc = true;
} else {
error_setg(errp, "Invalid preallocation mode: '%s'", buf);
ret = -EINVAL;
goto out;
}
g_free(buf);
buf = qemu_opt_get_del(opts, BLOCK_OPT_REDUNDANCY);
if (buf) {
ret = parse_redundancy(s, buf);
if (ret < 0) {
error_setg(errp, "Invalid redundancy mode: '%s'", buf);
goto out;
}
}
if (s->inode.vdi_size > SD_MAX_VDI_SIZE) {
error_setg(errp, "too big image size");
ret = -EINVAL;
goto out;
}
if (backing_file) {
BlockDriverState *bs;
BDRVSheepdogState *base;
BlockDriver *drv;
drv = bdrv_find_protocol(backing_file, true);
if (!drv || strcmp(drv->protocol_name, "sheepdog") != 0) {
error_setg(errp, "backing_file must be a sheepdog image");
ret = -EINVAL;
goto out;
}
bs = NULL;
ret = bdrv_open(&bs, backing_file, NULL, NULL, BDRV_O_PROTOCOL, NULL,
errp);
if (ret < 0) {
goto out;
}
base = bs->opaque;
if (!is_snapshot(&base->inode)) {
error_setg(errp, "cannot clone from a non snapshot vdi");
bdrv_unref(bs);
ret = -EINVAL;
goto out;
}
s->inode.vdi_id = base->inode.vdi_id;
bdrv_unref(bs);
}
s->aio_context = qemu_get_aio_context();
ret = do_sd_create(s, &vid, 0, errp);
if (ret) {
goto out;
}
if (prealloc) {
ret = sd_prealloc(filename, errp);
}
out:
g_free(backing_file);
g_free(buf);
g_free(s);
return ret;
}
| {
"code": [
" s = g_malloc0(sizeof(BDRVSheepdogState));"
],
"line_no": [
25
]
} | static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1,
Error **VAR_2)
{
int VAR_3 = 0;
uint32_t vid = 0;
char *VAR_4 = NULL;
char *VAR_5 = NULL;
BDRVSheepdogState *s;
char VAR_6[SD_MAX_VDI_TAG_LEN];
uint32_t snapid;
bool prealloc = false;
s = g_malloc0(sizeof(BDRVSheepdogState));
memset(VAR_6, 0, sizeof(VAR_6));
if (strstr(VAR_0, ":
VAR_3 = sd_parse_uri(s, VAR_0, s->name, &snapid, VAR_6);
} else {
VAR_3 = parse_vdiname(s, VAR_0, s->name, &snapid, VAR_6);
}
if (VAR_3 < 0) {
error_setg(VAR_2, "Can't parse VAR_0");
goto out;
}
s->inode.vdi_size = qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0);
VAR_4 = qemu_opt_get_del(VAR_1, BLOCK_OPT_BACKING_FILE);
VAR_5 = qemu_opt_get_del(VAR_1, BLOCK_OPT_PREALLOC);
if (!VAR_5 || !strcmp(VAR_5, "off")) {
prealloc = false;
} else if (!strcmp(VAR_5, "full")) {
prealloc = true;
} else {
error_setg(VAR_2, "Invalid preallocation mode: '%s'", VAR_5);
VAR_3 = -EINVAL;
goto out;
}
g_free(VAR_5);
VAR_5 = qemu_opt_get_del(VAR_1, BLOCK_OPT_REDUNDANCY);
if (VAR_5) {
VAR_3 = parse_redundancy(s, VAR_5);
if (VAR_3 < 0) {
error_setg(VAR_2, "Invalid redundancy mode: '%s'", VAR_5);
goto out;
}
}
if (s->inode.vdi_size > SD_MAX_VDI_SIZE) {
error_setg(VAR_2, "too big image size");
VAR_3 = -EINVAL;
goto out;
}
if (VAR_4) {
BlockDriverState *bs;
BDRVSheepdogState *base;
BlockDriver *drv;
drv = bdrv_find_protocol(VAR_4, true);
if (!drv || strcmp(drv->protocol_name, "sheepdog") != 0) {
error_setg(VAR_2, "VAR_4 must be a sheepdog image");
VAR_3 = -EINVAL;
goto out;
}
bs = NULL;
VAR_3 = bdrv_open(&bs, VAR_4, NULL, NULL, BDRV_O_PROTOCOL, NULL,
VAR_2);
if (VAR_3 < 0) {
goto out;
}
base = bs->opaque;
if (!is_snapshot(&base->inode)) {
error_setg(VAR_2, "cannot clone from a non snapshot vdi");
bdrv_unref(bs);
VAR_3 = -EINVAL;
goto out;
}
s->inode.vdi_id = base->inode.vdi_id;
bdrv_unref(bs);
}
s->aio_context = qemu_get_aio_context();
VAR_3 = do_sd_create(s, &vid, 0, VAR_2);
if (VAR_3) {
goto out;
}
if (prealloc) {
VAR_3 = sd_prealloc(VAR_0, VAR_2);
}
out:
g_free(VAR_4);
g_free(VAR_5);
g_free(s);
return VAR_3;
}
| [
"static int FUNC_0(const char *VAR_0, QemuOpts *VAR_1,\nError **VAR_2)\n{",
"int VAR_3 = 0;",
"uint32_t vid = 0;",
"char *VAR_4 = NULL;",
"char *VAR_5 = NULL;",
"BDRVSheepdogState *s;",
"char VAR_6[SD_MAX_VDI_TAG_LEN];",
"uint32_t snapid;",
"bool prealloc = false;",
"s = g_malloc0(sizeof(BDRVSheepdogState));",
"memset(VAR_6, 0, sizeof(VAR_6));",
"if (strstr(VAR_0, \":\nVAR_3 = sd_parse_uri(s, VAR_0, s->name, &snapid, VAR_6);",
"} else {",
"VAR_3 = parse_vdiname(s, VAR_0, s->name, &snapid, VAR_6);",
"}",
"if (VAR_3 < 0) {",
"error_setg(VAR_2, \"Can't parse VAR_0\");",
"goto out;",
"}",
"s->inode.vdi_size = qemu_opt_get_size_del(VAR_1, BLOCK_OPT_SIZE, 0);",
"VAR_4 = qemu_opt_get_del(VAR_1, BLOCK_OPT_BACKING_FILE);",
"VAR_5 = qemu_opt_get_del(VAR_1, BLOCK_OPT_PREALLOC);",
"if (!VAR_5 || !strcmp(VAR_5, \"off\")) {",
"prealloc = false;",
"} else if (!strcmp(VAR_5, \"full\")) {",
"prealloc = true;",
"} else {",
"error_setg(VAR_2, \"Invalid preallocation mode: '%s'\", VAR_5);",
"VAR_3 = -EINVAL;",
"goto out;",
"}",
"g_free(VAR_5);",
"VAR_5 = qemu_opt_get_del(VAR_1, BLOCK_OPT_REDUNDANCY);",
"if (VAR_5) {",
"VAR_3 = parse_redundancy(s, VAR_5);",
"if (VAR_3 < 0) {",
"error_setg(VAR_2, \"Invalid redundancy mode: '%s'\", VAR_5);",
"goto out;",
"}",
"}",
"if (s->inode.vdi_size > SD_MAX_VDI_SIZE) {",
"error_setg(VAR_2, \"too big image size\");",
"VAR_3 = -EINVAL;",
"goto out;",
"}",
"if (VAR_4) {",
"BlockDriverState *bs;",
"BDRVSheepdogState *base;",
"BlockDriver *drv;",
"drv = bdrv_find_protocol(VAR_4, true);",
"if (!drv || strcmp(drv->protocol_name, \"sheepdog\") != 0) {",
"error_setg(VAR_2, \"VAR_4 must be a sheepdog image\");",
"VAR_3 = -EINVAL;",
"goto out;",
"}",
"bs = NULL;",
"VAR_3 = bdrv_open(&bs, VAR_4, NULL, NULL, BDRV_O_PROTOCOL, NULL,\nVAR_2);",
"if (VAR_3 < 0) {",
"goto out;",
"}",
"base = bs->opaque;",
"if (!is_snapshot(&base->inode)) {",
"error_setg(VAR_2, \"cannot clone from a non snapshot vdi\");",
"bdrv_unref(bs);",
"VAR_3 = -EINVAL;",
"goto out;",
"}",
"s->inode.vdi_id = base->inode.vdi_id;",
"bdrv_unref(bs);",
"}",
"s->aio_context = qemu_get_aio_context();",
"VAR_3 = do_sd_create(s, &vid, 0, VAR_2);",
"if (VAR_3) {",
"goto out;",
"}",
"if (prealloc) {",
"VAR_3 = sd_prealloc(VAR_0, VAR_2);",
"}",
"out:\ng_free(VAR_4);",
"g_free(VAR_5);",
"g_free(s);",
"return VAR_3;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3,
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
19
],
[
21
],
[
25
],
[
29
],
[
31,
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
63
],
[
65
],
[
67
],
[
69
],
[
71
],
[
73
],
[
77
],
[
79
],
[
81
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
93
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129
],
[
131
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
],
[
149
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161
],
[
163
],
[
165
],
[
167
],
[
169
],
[
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
185
],
[
187
],
[
189
],
[
191,
193
],
[
195
],
[
197
],
[
199
],
[
201
]
] |
25,126 | static void ics_base_realize(DeviceState *dev, Error **errp)
{
ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev);
ICSState *ics = ICS_BASE(dev);
Object *obj;
Error *err = NULL;
obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err);
if (!obj) {
error_setg(errp, "%s: required link '" ICS_PROP_XICS "' not found: %s",
__func__, error_get_pretty(err));
return;
}
ics->xics = XICS_FABRIC(obj);
if (icsc->realize) {
icsc->realize(ics, errp);
}
}
| true | qemu | a1a6bbde4f6a29368f8f605cea2e73630ec1bc7c | static void ics_base_realize(DeviceState *dev, Error **errp)
{
ICSStateClass *icsc = ICS_BASE_GET_CLASS(dev);
ICSState *ics = ICS_BASE(dev);
Object *obj;
Error *err = NULL;
obj = object_property_get_link(OBJECT(dev), ICS_PROP_XICS, &err);
if (!obj) {
error_setg(errp, "%s: required link '" ICS_PROP_XICS "' not found: %s",
__func__, error_get_pretty(err));
return;
}
ics->xics = XICS_FABRIC(obj);
if (icsc->realize) {
icsc->realize(ics, errp);
}
}
| {
"code": [
" __func__, error_get_pretty(err));",
" __func__, error_get_pretty(err));",
" error_setg(errp, \"%s: required link '\" ICS_PROP_XICS \"' not found: %s\",",
" __func__, error_get_pretty(err));"
],
"line_no": [
21,
21,
19,
21
]
} | static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)
{
ICSStateClass *icsc = ICS_BASE_GET_CLASS(VAR_0);
ICSState *ics = ICS_BASE(VAR_0);
Object *obj;
Error *err = NULL;
obj = object_property_get_link(OBJECT(VAR_0), ICS_PROP_XICS, &err);
if (!obj) {
error_setg(VAR_1, "%s: required link '" ICS_PROP_XICS "' not found: %s",
__func__, error_get_pretty(err));
return;
}
ics->xics = XICS_FABRIC(obj);
if (icsc->realize) {
icsc->realize(ics, VAR_1);
}
}
| [
"static void FUNC_0(DeviceState *VAR_0, Error **VAR_1)\n{",
"ICSStateClass *icsc = ICS_BASE_GET_CLASS(VAR_0);",
"ICSState *ics = ICS_BASE(VAR_0);",
"Object *obj;",
"Error *err = NULL;",
"obj = object_property_get_link(OBJECT(VAR_0), ICS_PROP_XICS, &err);",
"if (!obj) {",
"error_setg(VAR_1, \"%s: required link '\" ICS_PROP_XICS \"' not found: %s\",\n__func__, error_get_pretty(err));",
"return;",
"}",
"ics->xics = XICS_FABRIC(obj);",
"if (icsc->realize) {",
"icsc->realize(ics, VAR_1);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
17
],
[
19,
21
],
[
23
],
[
25
],
[
27
],
[
33
],
[
35
],
[
37
],
[
39
]
] |
25,127 | static int ffm_read_header(AVFormatContext *s)
{
FFMContext *ffm = s->priv_data;
AVStream *st;
AVIOContext *pb = s->pb;
AVCodecContext *codec;
const AVCodecDescriptor *codec_desc;
int i, nb_streams;
uint32_t tag;
/* header */
tag = avio_rl32(pb);
if (tag == MKTAG('F', 'F', 'M', '2'))
return ffm2_read_header(s);
if (tag != MKTAG('F', 'F', 'M', '1'))
ffm->packet_size = avio_rb32(pb);
if (ffm->packet_size != FFM_PACKET_SIZE)
ffm->write_index = avio_rb64(pb);
/* get also filesize */
if (pb->seekable) {
ffm->file_size = avio_size(pb);
if (ffm->write_index && 0)
adjust_write_index(s);
} else {
ffm->file_size = (UINT64_C(1) << 63) - 1;
nb_streams = avio_rb32(pb);
avio_rb32(pb); /* total bitrate */
/* read each stream */
for(i=0;i<nb_streams;i++) {
char rc_eq_buf[128];
st = avformat_new_stream(s, NULL);
if (!st)
avpriv_set_pts_info(st, 64, 1, 1000000);
codec = st->codec;
/* generic info */
codec->codec_id = avio_rb32(pb);
codec_desc = avcodec_descriptor_get(codec->codec_id);
if (!codec_desc) {
av_log(s, AV_LOG_ERROR, "Invalid codec id: %d\n", codec->codec_id);
codec->codec_id = AV_CODEC_ID_NONE;
codec->codec_type = avio_r8(pb); /* codec_type */
if (codec->codec_type != codec_desc->type) {
av_log(s, AV_LOG_ERROR, "Codec type mismatch: expected %d, found %d\n",
codec_desc->type, codec->codec_type);
codec->codec_id = AV_CODEC_ID_NONE;
codec->codec_type = AVMEDIA_TYPE_UNKNOWN;
codec->bit_rate = avio_rb32(pb);
codec->flags = avio_rb32(pb);
codec->flags2 = avio_rb32(pb);
codec->debug = avio_rb32(pb);
/* specific info */
switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
codec->time_base.num = avio_rb32(pb);
codec->time_base.den = avio_rb32(pb);
if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n",
codec->time_base.num, codec->time_base.den);
codec->width = avio_rb16(pb);
codec->height = avio_rb16(pb);
codec->gop_size = avio_rb16(pb);
codec->pix_fmt = avio_rb32(pb);
codec->qmin = avio_r8(pb);
codec->qmax = avio_r8(pb);
codec->max_qdiff = avio_r8(pb);
codec->qcompress = avio_rb16(pb) / 10000.0;
codec->qblur = avio_rb16(pb) / 10000.0;
codec->bit_rate_tolerance = avio_rb32(pb);
avio_get_str(pb, INT_MAX, rc_eq_buf, sizeof(rc_eq_buf));
codec->rc_eq = av_strdup(rc_eq_buf);
codec->rc_max_rate = avio_rb32(pb);
codec->rc_min_rate = avio_rb32(pb);
codec->rc_buffer_size = avio_rb32(pb);
codec->i_quant_factor = av_int2double(avio_rb64(pb));
codec->b_quant_factor = av_int2double(avio_rb64(pb));
codec->i_quant_offset = av_int2double(avio_rb64(pb));
codec->b_quant_offset = av_int2double(avio_rb64(pb));
codec->dct_algo = avio_rb32(pb);
codec->strict_std_compliance = avio_rb32(pb);
codec->max_b_frames = avio_rb32(pb);
codec->mpeg_quant = avio_rb32(pb);
codec->intra_dc_precision = avio_rb32(pb);
codec->me_method = avio_rb32(pb);
codec->mb_decision = avio_rb32(pb);
codec->nsse_weight = avio_rb32(pb);
codec->frame_skip_cmp = avio_rb32(pb);
codec->rc_buffer_aggressivity = av_int2double(avio_rb64(pb));
codec->codec_tag = avio_rb32(pb);
codec->thread_count = avio_r8(pb);
codec->coder_type = avio_rb32(pb);
codec->me_cmp = avio_rb32(pb);
codec->me_subpel_quality = avio_rb32(pb);
codec->me_range = avio_rb32(pb);
codec->keyint_min = avio_rb32(pb);
codec->scenechange_threshold = avio_rb32(pb);
codec->b_frame_strategy = avio_rb32(pb);
codec->qcompress = av_int2double(avio_rb64(pb));
codec->qblur = av_int2double(avio_rb64(pb));
codec->max_qdiff = avio_rb32(pb);
codec->refs = avio_rb32(pb);
break;
case AVMEDIA_TYPE_AUDIO:
codec->sample_rate = avio_rb32(pb);
codec->channels = avio_rl16(pb);
codec->frame_size = avio_rl16(pb);
break;
default:
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
int size = avio_rb32(pb);
codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata)
return AVERROR(ENOMEM);
codec->extradata_size = size;
avio_read(pb, codec->extradata, size);
avcodec_parameters_from_context(st->codecpar, codec);
/* get until end of block reached */
while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached)
avio_r8(pb);
/* init packet demux */
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->frame_offset = 0;
ffm->dts = 0;
ffm->read_state = READ_HEADER;
ffm->first_packet = 1;
return 0;
fail:
ffm_close(s);
return -1;
| true | FFmpeg | 78baa450d9939957f52d5187beb95d763d2f1f18 | static int ffm_read_header(AVFormatContext *s)
{
FFMContext *ffm = s->priv_data;
AVStream *st;
AVIOContext *pb = s->pb;
AVCodecContext *codec;
const AVCodecDescriptor *codec_desc;
int i, nb_streams;
uint32_t tag;
tag = avio_rl32(pb);
if (tag == MKTAG('F', 'F', 'M', '2'))
return ffm2_read_header(s);
if (tag != MKTAG('F', 'F', 'M', '1'))
ffm->packet_size = avio_rb32(pb);
if (ffm->packet_size != FFM_PACKET_SIZE)
ffm->write_index = avio_rb64(pb);
if (pb->seekable) {
ffm->file_size = avio_size(pb);
if (ffm->write_index && 0)
adjust_write_index(s);
} else {
ffm->file_size = (UINT64_C(1) << 63) - 1;
nb_streams = avio_rb32(pb);
avio_rb32(pb);
for(i=0;i<nb_streams;i++) {
char rc_eq_buf[128];
st = avformat_new_stream(s, NULL);
if (!st)
avpriv_set_pts_info(st, 64, 1, 1000000);
codec = st->codec;
codec->codec_id = avio_rb32(pb);
codec_desc = avcodec_descriptor_get(codec->codec_id);
if (!codec_desc) {
av_log(s, AV_LOG_ERROR, "Invalid codec id: %d\n", codec->codec_id);
codec->codec_id = AV_CODEC_ID_NONE;
codec->codec_type = avio_r8(pb);
if (codec->codec_type != codec_desc->type) {
av_log(s, AV_LOG_ERROR, "Codec type mismatch: expected %d, found %d\n",
codec_desc->type, codec->codec_type);
codec->codec_id = AV_CODEC_ID_NONE;
codec->codec_type = AVMEDIA_TYPE_UNKNOWN;
codec->bit_rate = avio_rb32(pb);
codec->flags = avio_rb32(pb);
codec->flags2 = avio_rb32(pb);
codec->debug = avio_rb32(pb);
switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
codec->time_base.num = avio_rb32(pb);
codec->time_base.den = avio_rb32(pb);
if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {
av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n",
codec->time_base.num, codec->time_base.den);
codec->width = avio_rb16(pb);
codec->height = avio_rb16(pb);
codec->gop_size = avio_rb16(pb);
codec->pix_fmt = avio_rb32(pb);
codec->qmin = avio_r8(pb);
codec->qmax = avio_r8(pb);
codec->max_qdiff = avio_r8(pb);
codec->qcompress = avio_rb16(pb) / 10000.0;
codec->qblur = avio_rb16(pb) / 10000.0;
codec->bit_rate_tolerance = avio_rb32(pb);
avio_get_str(pb, INT_MAX, rc_eq_buf, sizeof(rc_eq_buf));
codec->rc_eq = av_strdup(rc_eq_buf);
codec->rc_max_rate = avio_rb32(pb);
codec->rc_min_rate = avio_rb32(pb);
codec->rc_buffer_size = avio_rb32(pb);
codec->i_quant_factor = av_int2double(avio_rb64(pb));
codec->b_quant_factor = av_int2double(avio_rb64(pb));
codec->i_quant_offset = av_int2double(avio_rb64(pb));
codec->b_quant_offset = av_int2double(avio_rb64(pb));
codec->dct_algo = avio_rb32(pb);
codec->strict_std_compliance = avio_rb32(pb);
codec->max_b_frames = avio_rb32(pb);
codec->mpeg_quant = avio_rb32(pb);
codec->intra_dc_precision = avio_rb32(pb);
codec->me_method = avio_rb32(pb);
codec->mb_decision = avio_rb32(pb);
codec->nsse_weight = avio_rb32(pb);
codec->frame_skip_cmp = avio_rb32(pb);
codec->rc_buffer_aggressivity = av_int2double(avio_rb64(pb));
codec->codec_tag = avio_rb32(pb);
codec->thread_count = avio_r8(pb);
codec->coder_type = avio_rb32(pb);
codec->me_cmp = avio_rb32(pb);
codec->me_subpel_quality = avio_rb32(pb);
codec->me_range = avio_rb32(pb);
codec->keyint_min = avio_rb32(pb);
codec->scenechange_threshold = avio_rb32(pb);
codec->b_frame_strategy = avio_rb32(pb);
codec->qcompress = av_int2double(avio_rb64(pb));
codec->qblur = av_int2double(avio_rb64(pb));
codec->max_qdiff = avio_rb32(pb);
codec->refs = avio_rb32(pb);
break;
case AVMEDIA_TYPE_AUDIO:
codec->sample_rate = avio_rb32(pb);
codec->channels = avio_rl16(pb);
codec->frame_size = avio_rl16(pb);
break;
default:
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
int size = avio_rb32(pb);
codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata)
return AVERROR(ENOMEM);
codec->extradata_size = size;
avio_read(pb, codec->extradata, size);
avcodec_parameters_from_context(st->codecpar, codec);
while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached)
avio_r8(pb);
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->frame_offset = 0;
ffm->dts = 0;
ffm->read_state = READ_HEADER;
ffm->first_packet = 1;
return 0;
fail:
ffm_close(s);
return -1;
| {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
FFMContext *ffm = VAR_0->priv_data;
AVStream *st;
AVIOContext *pb = VAR_0->pb;
AVCodecContext *codec;
const AVCodecDescriptor *VAR_1;
int VAR_2, VAR_3;
uint32_t tag;
tag = avio_rl32(pb);
if (tag == MKTAG('F', 'F', 'M', '2'))
return ffm2_read_header(VAR_0);
if (tag != MKTAG('F', 'F', 'M', '1'))
ffm->packet_size = avio_rb32(pb);
if (ffm->packet_size != FFM_PACKET_SIZE)
ffm->write_index = avio_rb64(pb);
if (pb->seekable) {
ffm->file_size = avio_size(pb);
if (ffm->write_index && 0)
adjust_write_index(VAR_0);
} else {
ffm->file_size = (UINT64_C(1) << 63) - 1;
VAR_3 = avio_rb32(pb);
avio_rb32(pb);
for(VAR_2=0;VAR_2<VAR_3;VAR_2++) {
char VAR_4[128];
st = avformat_new_stream(VAR_0, NULL);
if (!st)
avpriv_set_pts_info(st, 64, 1, 1000000);
codec = st->codec;
codec->codec_id = avio_rb32(pb);
VAR_1 = avcodec_descriptor_get(codec->codec_id);
if (!VAR_1) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid codec id: %d\n", codec->codec_id);
codec->codec_id = AV_CODEC_ID_NONE;
codec->codec_type = avio_r8(pb);
if (codec->codec_type != VAR_1->type) {
av_log(VAR_0, AV_LOG_ERROR, "Codec type mismatch: expected %d, found %d\n",
VAR_1->type, codec->codec_type);
codec->codec_id = AV_CODEC_ID_NONE;
codec->codec_type = AVMEDIA_TYPE_UNKNOWN;
codec->bit_rate = avio_rb32(pb);
codec->flags = avio_rb32(pb);
codec->flags2 = avio_rb32(pb);
codec->debug = avio_rb32(pb);
switch(codec->codec_type) {
case AVMEDIA_TYPE_VIDEO:
codec->time_base.num = avio_rb32(pb);
codec->time_base.den = avio_rb32(pb);
if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {
av_log(VAR_0, AV_LOG_ERROR, "Invalid time base %d/%d\n",
codec->time_base.num, codec->time_base.den);
codec->width = avio_rb16(pb);
codec->height = avio_rb16(pb);
codec->gop_size = avio_rb16(pb);
codec->pix_fmt = avio_rb32(pb);
codec->qmin = avio_r8(pb);
codec->qmax = avio_r8(pb);
codec->max_qdiff = avio_r8(pb);
codec->qcompress = avio_rb16(pb) / 10000.0;
codec->qblur = avio_rb16(pb) / 10000.0;
codec->bit_rate_tolerance = avio_rb32(pb);
avio_get_str(pb, INT_MAX, VAR_4, sizeof(VAR_4));
codec->rc_eq = av_strdup(VAR_4);
codec->rc_max_rate = avio_rb32(pb);
codec->rc_min_rate = avio_rb32(pb);
codec->rc_buffer_size = avio_rb32(pb);
codec->i_quant_factor = av_int2double(avio_rb64(pb));
codec->b_quant_factor = av_int2double(avio_rb64(pb));
codec->i_quant_offset = av_int2double(avio_rb64(pb));
codec->b_quant_offset = av_int2double(avio_rb64(pb));
codec->dct_algo = avio_rb32(pb);
codec->strict_std_compliance = avio_rb32(pb);
codec->max_b_frames = avio_rb32(pb);
codec->mpeg_quant = avio_rb32(pb);
codec->intra_dc_precision = avio_rb32(pb);
codec->me_method = avio_rb32(pb);
codec->mb_decision = avio_rb32(pb);
codec->nsse_weight = avio_rb32(pb);
codec->frame_skip_cmp = avio_rb32(pb);
codec->rc_buffer_aggressivity = av_int2double(avio_rb64(pb));
codec->codec_tag = avio_rb32(pb);
codec->thread_count = avio_r8(pb);
codec->coder_type = avio_rb32(pb);
codec->me_cmp = avio_rb32(pb);
codec->me_subpel_quality = avio_rb32(pb);
codec->me_range = avio_rb32(pb);
codec->keyint_min = avio_rb32(pb);
codec->scenechange_threshold = avio_rb32(pb);
codec->b_frame_strategy = avio_rb32(pb);
codec->qcompress = av_int2double(avio_rb64(pb));
codec->qblur = av_int2double(avio_rb64(pb));
codec->max_qdiff = avio_rb32(pb);
codec->refs = avio_rb32(pb);
break;
case AVMEDIA_TYPE_AUDIO:
codec->sample_rate = avio_rb32(pb);
codec->channels = avio_rl16(pb);
codec->frame_size = avio_rl16(pb);
break;
default:
if (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
int VAR_5 = avio_rb32(pb);
codec->extradata = av_mallocz(VAR_5 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata)
return AVERROR(ENOMEM);
codec->extradata_size = VAR_5;
avio_read(pb, codec->extradata, VAR_5);
avcodec_parameters_from_context(st->codecpar, codec);
while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached)
avio_r8(pb);
ffm->packet_ptr = ffm->packet;
ffm->packet_end = ffm->packet;
ffm->frame_offset = 0;
ffm->dts = 0;
ffm->read_state = READ_HEADER;
ffm->first_packet = 1;
return 0;
fail:
ffm_close(VAR_0);
return -1;
| [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"FFMContext *ffm = VAR_0->priv_data;",
"AVStream *st;",
"AVIOContext *pb = VAR_0->pb;",
"AVCodecContext *codec;",
"const AVCodecDescriptor *VAR_1;",
"int VAR_2, VAR_3;",
"uint32_t tag;",
"tag = avio_rl32(pb);",
"if (tag == MKTAG('F', 'F', 'M', '2'))\nreturn ffm2_read_header(VAR_0);",
"if (tag != MKTAG('F', 'F', 'M', '1'))\nffm->packet_size = avio_rb32(pb);",
"if (ffm->packet_size != FFM_PACKET_SIZE)\nffm->write_index = avio_rb64(pb);",
"if (pb->seekable) {",
"ffm->file_size = avio_size(pb);",
"if (ffm->write_index && 0)\nadjust_write_index(VAR_0);",
"} else {",
"ffm->file_size = (UINT64_C(1) << 63) - 1;",
"VAR_3 = avio_rb32(pb);",
"avio_rb32(pb);",
"for(VAR_2=0;VAR_2<VAR_3;VAR_2++) {",
"char VAR_4[128];",
"st = avformat_new_stream(VAR_0, NULL);",
"if (!st)\navpriv_set_pts_info(st, 64, 1, 1000000);",
"codec = st->codec;",
"codec->codec_id = avio_rb32(pb);",
"VAR_1 = avcodec_descriptor_get(codec->codec_id);",
"if (!VAR_1) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid codec id: %d\\n\", codec->codec_id);",
"codec->codec_id = AV_CODEC_ID_NONE;",
"codec->codec_type = avio_r8(pb);",
"if (codec->codec_type != VAR_1->type) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Codec type mismatch: expected %d, found %d\\n\",\nVAR_1->type, codec->codec_type);",
"codec->codec_id = AV_CODEC_ID_NONE;",
"codec->codec_type = AVMEDIA_TYPE_UNKNOWN;",
"codec->bit_rate = avio_rb32(pb);",
"codec->flags = avio_rb32(pb);",
"codec->flags2 = avio_rb32(pb);",
"codec->debug = avio_rb32(pb);",
"switch(codec->codec_type) {",
"case AVMEDIA_TYPE_VIDEO:\ncodec->time_base.num = avio_rb32(pb);",
"codec->time_base.den = avio_rb32(pb);",
"if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {",
"av_log(VAR_0, AV_LOG_ERROR, \"Invalid time base %d/%d\\n\",\ncodec->time_base.num, codec->time_base.den);",
"codec->width = avio_rb16(pb);",
"codec->height = avio_rb16(pb);",
"codec->gop_size = avio_rb16(pb);",
"codec->pix_fmt = avio_rb32(pb);",
"codec->qmin = avio_r8(pb);",
"codec->qmax = avio_r8(pb);",
"codec->max_qdiff = avio_r8(pb);",
"codec->qcompress = avio_rb16(pb) / 10000.0;",
"codec->qblur = avio_rb16(pb) / 10000.0;",
"codec->bit_rate_tolerance = avio_rb32(pb);",
"avio_get_str(pb, INT_MAX, VAR_4, sizeof(VAR_4));",
"codec->rc_eq = av_strdup(VAR_4);",
"codec->rc_max_rate = avio_rb32(pb);",
"codec->rc_min_rate = avio_rb32(pb);",
"codec->rc_buffer_size = avio_rb32(pb);",
"codec->i_quant_factor = av_int2double(avio_rb64(pb));",
"codec->b_quant_factor = av_int2double(avio_rb64(pb));",
"codec->i_quant_offset = av_int2double(avio_rb64(pb));",
"codec->b_quant_offset = av_int2double(avio_rb64(pb));",
"codec->dct_algo = avio_rb32(pb);",
"codec->strict_std_compliance = avio_rb32(pb);",
"codec->max_b_frames = avio_rb32(pb);",
"codec->mpeg_quant = avio_rb32(pb);",
"codec->intra_dc_precision = avio_rb32(pb);",
"codec->me_method = avio_rb32(pb);",
"codec->mb_decision = avio_rb32(pb);",
"codec->nsse_weight = avio_rb32(pb);",
"codec->frame_skip_cmp = avio_rb32(pb);",
"codec->rc_buffer_aggressivity = av_int2double(avio_rb64(pb));",
"codec->codec_tag = avio_rb32(pb);",
"codec->thread_count = avio_r8(pb);",
"codec->coder_type = avio_rb32(pb);",
"codec->me_cmp = avio_rb32(pb);",
"codec->me_subpel_quality = avio_rb32(pb);",
"codec->me_range = avio_rb32(pb);",
"codec->keyint_min = avio_rb32(pb);",
"codec->scenechange_threshold = avio_rb32(pb);",
"codec->b_frame_strategy = avio_rb32(pb);",
"codec->qcompress = av_int2double(avio_rb64(pb));",
"codec->qblur = av_int2double(avio_rb64(pb));",
"codec->max_qdiff = avio_rb32(pb);",
"codec->refs = avio_rb32(pb);",
"break;",
"case AVMEDIA_TYPE_AUDIO:\ncodec->sample_rate = avio_rb32(pb);",
"codec->channels = avio_rl16(pb);",
"codec->frame_size = avio_rl16(pb);",
"break;",
"default:\nif (codec->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {",
"int VAR_5 = avio_rb32(pb);",
"codec->extradata = av_mallocz(VAR_5 + AV_INPUT_BUFFER_PADDING_SIZE);",
"if (!codec->extradata)\nreturn AVERROR(ENOMEM);",
"codec->extradata_size = VAR_5;",
"avio_read(pb, codec->extradata, VAR_5);",
"avcodec_parameters_from_context(st->codecpar, codec);",
"while ((avio_tell(pb) % ffm->packet_size) != 0 && !pb->eof_reached)\navio_r8(pb);",
"ffm->packet_ptr = ffm->packet;",
"ffm->packet_end = ffm->packet;",
"ffm->frame_offset = 0;",
"ffm->dts = 0;",
"ffm->read_state = READ_HEADER;",
"ffm->first_packet = 1;",
"return 0;",
"fail:\nffm_close(VAR_0);",
"return -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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
15
],
[
17
],
[
23
],
[
25,
27
],
[
29,
32
],
[
34,
37
],
[
41
],
[
43
],
[
45,
47
],
[
49
],
[
51
],
[
56
],
[
58
],
[
62
],
[
64
],
[
68
],
[
70,
75
],
[
79
],
[
83
],
[
85
],
[
87
],
[
89
],
[
91
],
[
95
],
[
97
],
[
99,
101
],
[
103
],
[
105
],
[
109
],
[
111
],
[
113
],
[
115
],
[
119
],
[
121,
123
],
[
125
],
[
127
],
[
129,
131
],
[
135
],
[
137
],
[
139
],
[
141
],
[
148
],
[
150
],
[
152
],
[
154
],
[
156
],
[
158
],
[
160
],
[
162
],
[
164
],
[
166
],
[
168
],
[
170
],
[
172
],
[
174
],
[
176
],
[
178
],
[
180
],
[
182
],
[
184
],
[
186
],
[
188
],
[
190
],
[
192
],
[
194
],
[
196
],
[
198
],
[
200
],
[
202
],
[
204
],
[
206
],
[
208
],
[
210
],
[
212
],
[
214
],
[
216
],
[
218
],
[
220
],
[
222
],
[
224
],
[
226,
228
],
[
230
],
[
232
],
[
234
],
[
236,
240
],
[
242
],
[
244
],
[
246,
248
],
[
250
],
[
252
],
[
257
],
[
264,
266
],
[
272
],
[
274
],
[
276
],
[
278
],
[
280
],
[
282
],
[
284
],
[
286,
288
],
[
290
]
] |
25,128 | static void shpc_interrupt_update(PCIDevice *d)
{
SHPCDevice *shpc = d->shpc;
int slot;
int level = 0;
uint32_t serr_int;
uint32_t int_locator = 0;
/* Update interrupt locator register */
for (slot = 0; slot < shpc->nslots; ++slot) {
uint8_t event = shpc->config[SHPC_SLOT_EVENT_LATCH(slot)];
uint8_t disable = shpc->config[SHPC_SLOT_EVENT_SERR_INT_DIS(d, slot)];
uint32_t mask = 1 << SHPC_IDX_TO_LOGICAL(slot);
if (event & ~disable) {
int_locator |= mask;
}
}
serr_int = pci_get_long(shpc->config + SHPC_SERR_INT);
if ((serr_int & SHPC_CMD_DETECTED) && !(serr_int & SHPC_CMD_INT_DIS)) {
int_locator |= SHPC_INT_COMMAND;
}
pci_set_long(shpc->config + SHPC_INT_LOCATOR, int_locator);
level = (!(serr_int & SHPC_INT_DIS) && int_locator) ? 1 : 0;
if (msi_enabled(d) && shpc->msi_requested != level)
msi_notify(d, 0);
else
pci_set_irq(d, level);
shpc->msi_requested = level;
}
| true | qemu | 5820945946b1e221905aa898f2cd97ed825acd47 | static void shpc_interrupt_update(PCIDevice *d)
{
SHPCDevice *shpc = d->shpc;
int slot;
int level = 0;
uint32_t serr_int;
uint32_t int_locator = 0;
for (slot = 0; slot < shpc->nslots; ++slot) {
uint8_t event = shpc->config[SHPC_SLOT_EVENT_LATCH(slot)];
uint8_t disable = shpc->config[SHPC_SLOT_EVENT_SERR_INT_DIS(d, slot)];
uint32_t mask = 1 << SHPC_IDX_TO_LOGICAL(slot);
if (event & ~disable) {
int_locator |= mask;
}
}
serr_int = pci_get_long(shpc->config + SHPC_SERR_INT);
if ((serr_int & SHPC_CMD_DETECTED) && !(serr_int & SHPC_CMD_INT_DIS)) {
int_locator |= SHPC_INT_COMMAND;
}
pci_set_long(shpc->config + SHPC_INT_LOCATOR, int_locator);
level = (!(serr_int & SHPC_INT_DIS) && int_locator) ? 1 : 0;
if (msi_enabled(d) && shpc->msi_requested != level)
msi_notify(d, 0);
else
pci_set_irq(d, level);
shpc->msi_requested = level;
}
| {
"code": [
" uint32_t mask = 1 << SHPC_IDX_TO_LOGICAL(slot);"
],
"line_no": [
25
]
} | static void FUNC_0(PCIDevice *VAR_0)
{
SHPCDevice *shpc = VAR_0->shpc;
int VAR_1;
int VAR_2 = 0;
uint32_t serr_int;
uint32_t int_locator = 0;
for (VAR_1 = 0; VAR_1 < shpc->nslots; ++VAR_1) {
uint8_t event = shpc->config[SHPC_SLOT_EVENT_LATCH(VAR_1)];
uint8_t disable = shpc->config[SHPC_SLOT_EVENT_SERR_INT_DIS(VAR_0, VAR_1)];
uint32_t mask = 1 << SHPC_IDX_TO_LOGICAL(VAR_1);
if (event & ~disable) {
int_locator |= mask;
}
}
serr_int = pci_get_long(shpc->config + SHPC_SERR_INT);
if ((serr_int & SHPC_CMD_DETECTED) && !(serr_int & SHPC_CMD_INT_DIS)) {
int_locator |= SHPC_INT_COMMAND;
}
pci_set_long(shpc->config + SHPC_INT_LOCATOR, int_locator);
VAR_2 = (!(serr_int & SHPC_INT_DIS) && int_locator) ? 1 : 0;
if (msi_enabled(VAR_0) && shpc->msi_requested != VAR_2)
msi_notify(VAR_0, 0);
else
pci_set_irq(VAR_0, VAR_2);
shpc->msi_requested = VAR_2;
}
| [
"static void FUNC_0(PCIDevice *VAR_0)\n{",
"SHPCDevice *shpc = VAR_0->shpc;",
"int VAR_1;",
"int VAR_2 = 0;",
"uint32_t serr_int;",
"uint32_t int_locator = 0;",
"for (VAR_1 = 0; VAR_1 < shpc->nslots; ++VAR_1) {",
"uint8_t event = shpc->config[SHPC_SLOT_EVENT_LATCH(VAR_1)];",
"uint8_t disable = shpc->config[SHPC_SLOT_EVENT_SERR_INT_DIS(VAR_0, VAR_1)];",
"uint32_t mask = 1 << SHPC_IDX_TO_LOGICAL(VAR_1);",
"if (event & ~disable) {",
"int_locator |= mask;",
"}",
"}",
"serr_int = pci_get_long(shpc->config + SHPC_SERR_INT);",
"if ((serr_int & SHPC_CMD_DETECTED) && !(serr_int & SHPC_CMD_INT_DIS)) {",
"int_locator |= SHPC_INT_COMMAND;",
"}",
"pci_set_long(shpc->config + SHPC_INT_LOCATOR, int_locator);",
"VAR_2 = (!(serr_int & SHPC_INT_DIS) && int_locator) ? 1 : 0;",
"if (msi_enabled(VAR_0) && shpc->msi_requested != VAR_2)\nmsi_notify(VAR_0, 0);",
"else\npci_set_irq(VAR_0, VAR_2);",
"shpc->msi_requested = VAR_2;",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
35
],
[
37
],
[
39
],
[
41
],
[
43
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55
],
[
57
]
] |
25,129 | static void usb_mtp_command(MTPState *s, MTPControl *c)
{
MTPData *data_in = NULL;
MTPObject *o;
uint32_t nres = 0, res0 = 0;
/* sanity checks */
if (c->code >= CMD_CLOSE_SESSION && s->session == 0) {
usb_mtp_queue_result(s, RES_SESSION_NOT_OPEN,
c->trans, 0, 0, 0);
return;
}
/* process commands */
switch (c->code) {
case CMD_GET_DEVICE_INFO:
data_in = usb_mtp_get_device_info(s, c);
break;
case CMD_OPEN_SESSION:
if (s->session) {
usb_mtp_queue_result(s, RES_SESSION_ALREADY_OPEN,
c->trans, 1, s->session, 0);
return;
}
if (c->argv[0] == 0) {
usb_mtp_queue_result(s, RES_INVALID_PARAMETER,
c->trans, 0, 0, 0);
return;
}
trace_usb_mtp_op_open_session(s->dev.addr);
s->session = c->argv[0];
usb_mtp_object_alloc(s, s->next_handle++, NULL, s->root);
#ifdef __linux__
if (usb_mtp_inotify_init(s)) {
fprintf(stderr, "usb-mtp: file monitoring init failed\n");
}
#endif
break;
case CMD_CLOSE_SESSION:
trace_usb_mtp_op_close_session(s->dev.addr);
s->session = 0;
s->next_handle = 0;
#ifdef __linux__
usb_mtp_inotify_cleanup(s);
#endif
usb_mtp_object_free(s, QTAILQ_FIRST(&s->objects));
assert(QTAILQ_EMPTY(&s->objects));
break;
case CMD_GET_STORAGE_IDS:
data_in = usb_mtp_get_storage_ids(s, c);
break;
case CMD_GET_STORAGE_INFO:
if (c->argv[0] != QEMU_STORAGE_ID &&
c->argv[0] != 0xffffffff) {
usb_mtp_queue_result(s, RES_INVALID_STORAGE_ID,
c->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_storage_info(s, c);
break;
case CMD_GET_NUM_OBJECTS:
case CMD_GET_OBJECT_HANDLES:
if (c->argv[0] != QEMU_STORAGE_ID &&
c->argv[0] != 0xffffffff) {
usb_mtp_queue_result(s, RES_INVALID_STORAGE_ID,
c->trans, 0, 0, 0);
return;
}
if (c->argv[1] != 0x00000000) {
usb_mtp_queue_result(s, RES_SPEC_BY_FORMAT_UNSUPPORTED,
c->trans, 0, 0, 0);
return;
}
if (c->argv[2] == 0x00000000 ||
c->argv[2] == 0xffffffff) {
o = QTAILQ_FIRST(&s->objects);
} else {
o = usb_mtp_object_lookup(s, c->argv[2]);
}
if (o == NULL) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
if (o->format != FMT_ASSOCIATION) {
usb_mtp_queue_result(s, RES_INVALID_PARENT_OBJECT,
c->trans, 0, 0, 0);
return;
}
usb_mtp_object_readdir(s, o);
if (c->code == CMD_GET_NUM_OBJECTS) {
trace_usb_mtp_op_get_num_objects(s->dev.addr, o->handle, o->path);
nres = 1;
res0 = o->nchildren;
} else {
data_in = usb_mtp_get_object_handles(s, c, o);
}
break;
case CMD_GET_OBJECT_INFO:
o = usb_mtp_object_lookup(s, c->argv[0]);
if (o == NULL) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_object_info(s, c, o);
break;
case CMD_GET_OBJECT:
o = usb_mtp_object_lookup(s, c->argv[0]);
if (o == NULL) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
if (o->format == FMT_ASSOCIATION) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_object(s, c, o);
if (data_in == NULL) {
usb_mtp_queue_result(s, RES_GENERAL_ERROR,
c->trans, 0, 0, 0);
return;
}
break;
case CMD_GET_PARTIAL_OBJECT:
o = usb_mtp_object_lookup(s, c->argv[0]);
if (o == NULL) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
if (o->format == FMT_ASSOCIATION) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_partial_object(s, c, o);
if (data_in == NULL) {
usb_mtp_queue_result(s, RES_GENERAL_ERROR,
c->trans, 0, 0, 0);
return;
}
nres = 1;
res0 = data_in->length;
break;
default:
trace_usb_mtp_op_unknown(s->dev.addr, c->code);
usb_mtp_queue_result(s, RES_OPERATION_NOT_SUPPORTED,
c->trans, 0, 0, 0);
return;
}
/* return results on success */
if (data_in) {
assert(s->data_in == NULL);
s->data_in = data_in;
}
usb_mtp_queue_result(s, RES_OK, c->trans, nres, res0, 0);
}
| true | qemu | 983bff3530782d51c46c8d7c0e17e2a9dfe5fb77 | static void usb_mtp_command(MTPState *s, MTPControl *c)
{
MTPData *data_in = NULL;
MTPObject *o;
uint32_t nres = 0, res0 = 0;
if (c->code >= CMD_CLOSE_SESSION && s->session == 0) {
usb_mtp_queue_result(s, RES_SESSION_NOT_OPEN,
c->trans, 0, 0, 0);
return;
}
switch (c->code) {
case CMD_GET_DEVICE_INFO:
data_in = usb_mtp_get_device_info(s, c);
break;
case CMD_OPEN_SESSION:
if (s->session) {
usb_mtp_queue_result(s, RES_SESSION_ALREADY_OPEN,
c->trans, 1, s->session, 0);
return;
}
if (c->argv[0] == 0) {
usb_mtp_queue_result(s, RES_INVALID_PARAMETER,
c->trans, 0, 0, 0);
return;
}
trace_usb_mtp_op_open_session(s->dev.addr);
s->session = c->argv[0];
usb_mtp_object_alloc(s, s->next_handle++, NULL, s->root);
#ifdef __linux__
if (usb_mtp_inotify_init(s)) {
fprintf(stderr, "usb-mtp: file monitoring init failed\n");
}
#endif
break;
case CMD_CLOSE_SESSION:
trace_usb_mtp_op_close_session(s->dev.addr);
s->session = 0;
s->next_handle = 0;
#ifdef __linux__
usb_mtp_inotify_cleanup(s);
#endif
usb_mtp_object_free(s, QTAILQ_FIRST(&s->objects));
assert(QTAILQ_EMPTY(&s->objects));
break;
case CMD_GET_STORAGE_IDS:
data_in = usb_mtp_get_storage_ids(s, c);
break;
case CMD_GET_STORAGE_INFO:
if (c->argv[0] != QEMU_STORAGE_ID &&
c->argv[0] != 0xffffffff) {
usb_mtp_queue_result(s, RES_INVALID_STORAGE_ID,
c->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_storage_info(s, c);
break;
case CMD_GET_NUM_OBJECTS:
case CMD_GET_OBJECT_HANDLES:
if (c->argv[0] != QEMU_STORAGE_ID &&
c->argv[0] != 0xffffffff) {
usb_mtp_queue_result(s, RES_INVALID_STORAGE_ID,
c->trans, 0, 0, 0);
return;
}
if (c->argv[1] != 0x00000000) {
usb_mtp_queue_result(s, RES_SPEC_BY_FORMAT_UNSUPPORTED,
c->trans, 0, 0, 0);
return;
}
if (c->argv[2] == 0x00000000 ||
c->argv[2] == 0xffffffff) {
o = QTAILQ_FIRST(&s->objects);
} else {
o = usb_mtp_object_lookup(s, c->argv[2]);
}
if (o == NULL) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
if (o->format != FMT_ASSOCIATION) {
usb_mtp_queue_result(s, RES_INVALID_PARENT_OBJECT,
c->trans, 0, 0, 0);
return;
}
usb_mtp_object_readdir(s, o);
if (c->code == CMD_GET_NUM_OBJECTS) {
trace_usb_mtp_op_get_num_objects(s->dev.addr, o->handle, o->path);
nres = 1;
res0 = o->nchildren;
} else {
data_in = usb_mtp_get_object_handles(s, c, o);
}
break;
case CMD_GET_OBJECT_INFO:
o = usb_mtp_object_lookup(s, c->argv[0]);
if (o == NULL) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_object_info(s, c, o);
break;
case CMD_GET_OBJECT:
o = usb_mtp_object_lookup(s, c->argv[0]);
if (o == NULL) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
if (o->format == FMT_ASSOCIATION) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_object(s, c, o);
if (data_in == NULL) {
usb_mtp_queue_result(s, RES_GENERAL_ERROR,
c->trans, 0, 0, 0);
return;
}
break;
case CMD_GET_PARTIAL_OBJECT:
o = usb_mtp_object_lookup(s, c->argv[0]);
if (o == NULL) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
if (o->format == FMT_ASSOCIATION) {
usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE,
c->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_partial_object(s, c, o);
if (data_in == NULL) {
usb_mtp_queue_result(s, RES_GENERAL_ERROR,
c->trans, 0, 0, 0);
return;
}
nres = 1;
res0 = data_in->length;
break;
default:
trace_usb_mtp_op_unknown(s->dev.addr, c->code);
usb_mtp_queue_result(s, RES_OPERATION_NOT_SUPPORTED,
c->trans, 0, 0, 0);
return;
}
if (data_in) {
assert(s->data_in == NULL);
s->data_in = data_in;
}
usb_mtp_queue_result(s, RES_OK, c->trans, nres, res0, 0);
}
| {
"code": [
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__",
"#ifdef __linux__"
],
"line_no": [
65,
65,
65,
65,
65,
65,
65,
65,
65,
65
]
} | static void FUNC_0(MTPState *VAR_0, MTPControl *VAR_1)
{
MTPData *data_in = NULL;
MTPObject *o;
uint32_t nres = 0, res0 = 0;
if (VAR_1->code >= CMD_CLOSE_SESSION && VAR_0->session == 0) {
usb_mtp_queue_result(VAR_0, RES_SESSION_NOT_OPEN,
VAR_1->trans, 0, 0, 0);
return;
}
switch (VAR_1->code) {
case CMD_GET_DEVICE_INFO:
data_in = usb_mtp_get_device_info(VAR_0, VAR_1);
break;
case CMD_OPEN_SESSION:
if (VAR_0->session) {
usb_mtp_queue_result(VAR_0, RES_SESSION_ALREADY_OPEN,
VAR_1->trans, 1, VAR_0->session, 0);
return;
}
if (VAR_1->argv[0] == 0) {
usb_mtp_queue_result(VAR_0, RES_INVALID_PARAMETER,
VAR_1->trans, 0, 0, 0);
return;
}
trace_usb_mtp_op_open_session(VAR_0->dev.addr);
VAR_0->session = VAR_1->argv[0];
usb_mtp_object_alloc(VAR_0, VAR_0->next_handle++, NULL, VAR_0->root);
#ifdef __linux__
if (usb_mtp_inotify_init(VAR_0)) {
fprintf(stderr, "usb-mtp: file monitoring init failed\n");
}
#endif
break;
case CMD_CLOSE_SESSION:
trace_usb_mtp_op_close_session(VAR_0->dev.addr);
VAR_0->session = 0;
VAR_0->next_handle = 0;
#ifdef __linux__
usb_mtp_inotify_cleanup(VAR_0);
#endif
usb_mtp_object_free(VAR_0, QTAILQ_FIRST(&VAR_0->objects));
assert(QTAILQ_EMPTY(&VAR_0->objects));
break;
case CMD_GET_STORAGE_IDS:
data_in = usb_mtp_get_storage_ids(VAR_0, VAR_1);
break;
case CMD_GET_STORAGE_INFO:
if (VAR_1->argv[0] != QEMU_STORAGE_ID &&
VAR_1->argv[0] != 0xffffffff) {
usb_mtp_queue_result(VAR_0, RES_INVALID_STORAGE_ID,
VAR_1->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_storage_info(VAR_0, VAR_1);
break;
case CMD_GET_NUM_OBJECTS:
case CMD_GET_OBJECT_HANDLES:
if (VAR_1->argv[0] != QEMU_STORAGE_ID &&
VAR_1->argv[0] != 0xffffffff) {
usb_mtp_queue_result(VAR_0, RES_INVALID_STORAGE_ID,
VAR_1->trans, 0, 0, 0);
return;
}
if (VAR_1->argv[1] != 0x00000000) {
usb_mtp_queue_result(VAR_0, RES_SPEC_BY_FORMAT_UNSUPPORTED,
VAR_1->trans, 0, 0, 0);
return;
}
if (VAR_1->argv[2] == 0x00000000 ||
VAR_1->argv[2] == 0xffffffff) {
o = QTAILQ_FIRST(&VAR_0->objects);
} else {
o = usb_mtp_object_lookup(VAR_0, VAR_1->argv[2]);
}
if (o == NULL) {
usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,
VAR_1->trans, 0, 0, 0);
return;
}
if (o->format != FMT_ASSOCIATION) {
usb_mtp_queue_result(VAR_0, RES_INVALID_PARENT_OBJECT,
VAR_1->trans, 0, 0, 0);
return;
}
usb_mtp_object_readdir(VAR_0, o);
if (VAR_1->code == CMD_GET_NUM_OBJECTS) {
trace_usb_mtp_op_get_num_objects(VAR_0->dev.addr, o->handle, o->path);
nres = 1;
res0 = o->nchildren;
} else {
data_in = usb_mtp_get_object_handles(VAR_0, VAR_1, o);
}
break;
case CMD_GET_OBJECT_INFO:
o = usb_mtp_object_lookup(VAR_0, VAR_1->argv[0]);
if (o == NULL) {
usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,
VAR_1->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_object_info(VAR_0, VAR_1, o);
break;
case CMD_GET_OBJECT:
o = usb_mtp_object_lookup(VAR_0, VAR_1->argv[0]);
if (o == NULL) {
usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,
VAR_1->trans, 0, 0, 0);
return;
}
if (o->format == FMT_ASSOCIATION) {
usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,
VAR_1->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_object(VAR_0, VAR_1, o);
if (data_in == NULL) {
usb_mtp_queue_result(VAR_0, RES_GENERAL_ERROR,
VAR_1->trans, 0, 0, 0);
return;
}
break;
case CMD_GET_PARTIAL_OBJECT:
o = usb_mtp_object_lookup(VAR_0, VAR_1->argv[0]);
if (o == NULL) {
usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,
VAR_1->trans, 0, 0, 0);
return;
}
if (o->format == FMT_ASSOCIATION) {
usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,
VAR_1->trans, 0, 0, 0);
return;
}
data_in = usb_mtp_get_partial_object(VAR_0, VAR_1, o);
if (data_in == NULL) {
usb_mtp_queue_result(VAR_0, RES_GENERAL_ERROR,
VAR_1->trans, 0, 0, 0);
return;
}
nres = 1;
res0 = data_in->length;
break;
default:
trace_usb_mtp_op_unknown(VAR_0->dev.addr, VAR_1->code);
usb_mtp_queue_result(VAR_0, RES_OPERATION_NOT_SUPPORTED,
VAR_1->trans, 0, 0, 0);
return;
}
if (data_in) {
assert(VAR_0->data_in == NULL);
VAR_0->data_in = data_in;
}
usb_mtp_queue_result(VAR_0, RES_OK, VAR_1->trans, nres, res0, 0);
}
| [
"static void FUNC_0(MTPState *VAR_0, MTPControl *VAR_1)\n{",
"MTPData *data_in = NULL;",
"MTPObject *o;",
"uint32_t nres = 0, res0 = 0;",
"if (VAR_1->code >= CMD_CLOSE_SESSION && VAR_0->session == 0) {",
"usb_mtp_queue_result(VAR_0, RES_SESSION_NOT_OPEN,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"switch (VAR_1->code) {",
"case CMD_GET_DEVICE_INFO:\ndata_in = usb_mtp_get_device_info(VAR_0, VAR_1);",
"break;",
"case CMD_OPEN_SESSION:\nif (VAR_0->session) {",
"usb_mtp_queue_result(VAR_0, RES_SESSION_ALREADY_OPEN,\nVAR_1->trans, 1, VAR_0->session, 0);",
"return;",
"}",
"if (VAR_1->argv[0] == 0) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_PARAMETER,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"trace_usb_mtp_op_open_session(VAR_0->dev.addr);",
"VAR_0->session = VAR_1->argv[0];",
"usb_mtp_object_alloc(VAR_0, VAR_0->next_handle++, NULL, VAR_0->root);",
"#ifdef __linux__\nif (usb_mtp_inotify_init(VAR_0)) {",
"fprintf(stderr, \"usb-mtp: file monitoring init failed\\n\");",
"}",
"#endif\nbreak;",
"case CMD_CLOSE_SESSION:\ntrace_usb_mtp_op_close_session(VAR_0->dev.addr);",
"VAR_0->session = 0;",
"VAR_0->next_handle = 0;",
"#ifdef __linux__\nusb_mtp_inotify_cleanup(VAR_0);",
"#endif\nusb_mtp_object_free(VAR_0, QTAILQ_FIRST(&VAR_0->objects));",
"assert(QTAILQ_EMPTY(&VAR_0->objects));",
"break;",
"case CMD_GET_STORAGE_IDS:\ndata_in = usb_mtp_get_storage_ids(VAR_0, VAR_1);",
"break;",
"case CMD_GET_STORAGE_INFO:\nif (VAR_1->argv[0] != QEMU_STORAGE_ID &&\nVAR_1->argv[0] != 0xffffffff) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_STORAGE_ID,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"data_in = usb_mtp_get_storage_info(VAR_0, VAR_1);",
"break;",
"case CMD_GET_NUM_OBJECTS:\ncase CMD_GET_OBJECT_HANDLES:\nif (VAR_1->argv[0] != QEMU_STORAGE_ID &&\nVAR_1->argv[0] != 0xffffffff) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_STORAGE_ID,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"if (VAR_1->argv[1] != 0x00000000) {",
"usb_mtp_queue_result(VAR_0, RES_SPEC_BY_FORMAT_UNSUPPORTED,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"if (VAR_1->argv[2] == 0x00000000 ||\nVAR_1->argv[2] == 0xffffffff) {",
"o = QTAILQ_FIRST(&VAR_0->objects);",
"} else {",
"o = usb_mtp_object_lookup(VAR_0, VAR_1->argv[2]);",
"}",
"if (o == NULL) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"if (o->format != FMT_ASSOCIATION) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_PARENT_OBJECT,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"usb_mtp_object_readdir(VAR_0, o);",
"if (VAR_1->code == CMD_GET_NUM_OBJECTS) {",
"trace_usb_mtp_op_get_num_objects(VAR_0->dev.addr, o->handle, o->path);",
"nres = 1;",
"res0 = o->nchildren;",
"} else {",
"data_in = usb_mtp_get_object_handles(VAR_0, VAR_1, o);",
"}",
"break;",
"case CMD_GET_OBJECT_INFO:\no = usb_mtp_object_lookup(VAR_0, VAR_1->argv[0]);",
"if (o == NULL) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"data_in = usb_mtp_get_object_info(VAR_0, VAR_1, o);",
"break;",
"case CMD_GET_OBJECT:\no = usb_mtp_object_lookup(VAR_0, VAR_1->argv[0]);",
"if (o == NULL) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"if (o->format == FMT_ASSOCIATION) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"data_in = usb_mtp_get_object(VAR_0, VAR_1, o);",
"if (data_in == NULL) {",
"usb_mtp_queue_result(VAR_0, RES_GENERAL_ERROR,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"break;",
"case CMD_GET_PARTIAL_OBJECT:\no = usb_mtp_object_lookup(VAR_0, VAR_1->argv[0]);",
"if (o == NULL) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"if (o->format == FMT_ASSOCIATION) {",
"usb_mtp_queue_result(VAR_0, RES_INVALID_OBJECT_HANDLE,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"data_in = usb_mtp_get_partial_object(VAR_0, VAR_1, o);",
"if (data_in == NULL) {",
"usb_mtp_queue_result(VAR_0, RES_GENERAL_ERROR,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"nres = 1;",
"res0 = data_in->length;",
"break;",
"default:\ntrace_usb_mtp_op_unknown(VAR_0->dev.addr, VAR_1->code);",
"usb_mtp_queue_result(VAR_0, RES_OPERATION_NOT_SUPPORTED,\nVAR_1->trans, 0, 0, 0);",
"return;",
"}",
"if (data_in) {",
"assert(VAR_0->data_in == NULL);",
"VAR_0->data_in = data_in;",
"}",
"usb_mtp_queue_result(VAR_0, RES_OK, VAR_1->trans, nres, res0, 0);",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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
],
[
15
],
[
17,
19
],
[
21
],
[
23
],
[
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,
111
],
[
113
],
[
115
],
[
117
],
[
119
],
[
121,
123,
125,
127
],
[
129,
131
],
[
133
],
[
135
],
[
137
],
[
139,
141
],
[
143
],
[
145
],
[
147,
149
],
[
151
],
[
153
],
[
155
],
[
157
],
[
159
],
[
161,
163
],
[
165
],
[
167
],
[
169
],
[
171,
173
],
[
175
],
[
177
],
[
179
],
[
181
],
[
183
],
[
185
],
[
187
],
[
189
],
[
191
],
[
193
],
[
195
],
[
197,
199
],
[
201
],
[
203,
205
],
[
207
],
[
209
],
[
211
],
[
213
],
[
215,
217
],
[
219
],
[
221,
223
],
[
225
],
[
227
],
[
229
],
[
231,
233
],
[
235
],
[
237
],
[
239
],
[
241
],
[
243,
245
],
[
247
],
[
249
],
[
251
],
[
253,
255
],
[
257
],
[
259,
261
],
[
263
],
[
265
],
[
267
],
[
269,
271
],
[
273
],
[
275
],
[
277
],
[
279
],
[
281,
283
],
[
285
],
[
287
],
[
289
],
[
291
],
[
293
],
[
295,
297
],
[
299,
301
],
[
303
],
[
305
],
[
311
],
[
313
],
[
315
],
[
317
],
[
319
],
[
321
]
] |
25,131 | static int sdp_read_header(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
RTSPStream *rtsp_st;
int size, i, err;
char *content;
char url[1024];
if (!ff_network_init())
return AVERROR(EIO);
if (s->max_delay < 0) /* Not set by the caller */
s->max_delay = DEFAULT_REORDERING_DELAY;
if (rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)
rt->lower_transport = RTSP_LOWER_TRANSPORT_CUSTOM;
/* read the whole sdp file */
/* XXX: better loading */
content = av_malloc(SDP_MAX_SIZE);
size = avio_read(s->pb, content, SDP_MAX_SIZE - 1);
if (size <= 0) {
av_free(content);
return AVERROR_INVALIDDATA;
}
content[size] ='\0';
err = ff_sdp_parse(s, content);
av_freep(&content);
if (err) goto fail;
/* open each RTP stream */
for (i = 0; i < rt->nb_rtsp_streams; i++) {
char namebuf[50];
rtsp_st = rt->rtsp_streams[i];
if (!(rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)) {
AVDictionary *opts = map_to_opts(rt);
getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, sizeof(rtsp_st->sdp_ip),
namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
ff_url_join(url, sizeof(url), "rtp", NULL,
namebuf, rtsp_st->sdp_port,
"?localport=%d&ttl=%d&connect=%d&write_to_source=%d",
rtsp_st->sdp_port, rtsp_st->sdp_ttl,
rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0,
rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0);
append_source_addrs(url, sizeof(url), "sources",
rtsp_st->nb_include_source_addrs,
rtsp_st->include_source_addrs);
append_source_addrs(url, sizeof(url), "block",
rtsp_st->nb_exclude_source_addrs,
rtsp_st->exclude_source_addrs);
err = ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE,
&s->interrupt_callback, &opts);
av_dict_free(&opts);
if (err < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
}
}
if ((err = ff_rtsp_open_transport_ctx(s, rtsp_st)))
goto fail;
}
return 0;
fail:
ff_rtsp_close_streams(s);
ff_network_close();
return err;
} | true | FFmpeg | 4b030025278ac4adc3616510f36de4c7a113c5fb | static int sdp_read_header(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
RTSPStream *rtsp_st;
int size, i, err;
char *content;
char url[1024];
if (!ff_network_init())
return AVERROR(EIO);
if (s->max_delay < 0)
s->max_delay = DEFAULT_REORDERING_DELAY;
if (rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)
rt->lower_transport = RTSP_LOWER_TRANSPORT_CUSTOM;
content = av_malloc(SDP_MAX_SIZE);
size = avio_read(s->pb, content, SDP_MAX_SIZE - 1);
if (size <= 0) {
av_free(content);
return AVERROR_INVALIDDATA;
}
content[size] ='\0';
err = ff_sdp_parse(s, content);
av_freep(&content);
if (err) goto fail;
for (i = 0; i < rt->nb_rtsp_streams; i++) {
char namebuf[50];
rtsp_st = rt->rtsp_streams[i];
if (!(rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)) {
AVDictionary *opts = map_to_opts(rt);
getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, sizeof(rtsp_st->sdp_ip),
namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
ff_url_join(url, sizeof(url), "rtp", NULL,
namebuf, rtsp_st->sdp_port,
"?localport=%d&ttl=%d&connect=%d&write_to_source=%d",
rtsp_st->sdp_port, rtsp_st->sdp_ttl,
rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0,
rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0);
append_source_addrs(url, sizeof(url), "sources",
rtsp_st->nb_include_source_addrs,
rtsp_st->include_source_addrs);
append_source_addrs(url, sizeof(url), "block",
rtsp_st->nb_exclude_source_addrs,
rtsp_st->exclude_source_addrs);
err = ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE,
&s->interrupt_callback, &opts);
av_dict_free(&opts);
if (err < 0) {
err = AVERROR_INVALIDDATA;
goto fail;
}
}
if ((err = ff_rtsp_open_transport_ctx(s, rtsp_st)))
goto fail;
}
return 0;
fail:
ff_rtsp_close_streams(s);
ff_network_close();
return err;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0)
{
RTSPState *rt = VAR_0->priv_data;
RTSPStream *rtsp_st;
int VAR_1, VAR_2, VAR_3;
char *VAR_4;
char VAR_5[1024];
if (!ff_network_init())
return AVERROR(EIO);
if (VAR_0->max_delay < 0)
VAR_0->max_delay = DEFAULT_REORDERING_DELAY;
if (rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)
rt->lower_transport = RTSP_LOWER_TRANSPORT_CUSTOM;
VAR_4 = av_malloc(SDP_MAX_SIZE);
VAR_1 = avio_read(VAR_0->pb, VAR_4, SDP_MAX_SIZE - 1);
if (VAR_1 <= 0) {
av_free(VAR_4);
return AVERROR_INVALIDDATA;
}
VAR_4[VAR_1] ='\0';
VAR_3 = ff_sdp_parse(VAR_0, VAR_4);
av_freep(&VAR_4);
if (VAR_3) goto fail;
for (VAR_2 = 0; VAR_2 < rt->nb_rtsp_streams; VAR_2++) {
char namebuf[50];
rtsp_st = rt->rtsp_streams[VAR_2];
if (!(rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)) {
AVDictionary *opts = map_to_opts(rt);
getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, sizeof(rtsp_st->sdp_ip),
namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
ff_url_join(VAR_5, sizeof(VAR_5), "rtp", NULL,
namebuf, rtsp_st->sdp_port,
"?localport=%d&ttl=%d&connect=%d&write_to_source=%d",
rtsp_st->sdp_port, rtsp_st->sdp_ttl,
rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0,
rt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0);
append_source_addrs(VAR_5, sizeof(VAR_5), "sources",
rtsp_st->nb_include_source_addrs,
rtsp_st->include_source_addrs);
append_source_addrs(VAR_5, sizeof(VAR_5), "block",
rtsp_st->nb_exclude_source_addrs,
rtsp_st->exclude_source_addrs);
VAR_3 = ffurl_open(&rtsp_st->rtp_handle, VAR_5, AVIO_FLAG_READ_WRITE,
&VAR_0->interrupt_callback, &opts);
av_dict_free(&opts);
if (VAR_3 < 0) {
VAR_3 = AVERROR_INVALIDDATA;
goto fail;
}
}
if ((VAR_3 = ff_rtsp_open_transport_ctx(VAR_0, rtsp_st)))
goto fail;
}
return 0;
fail:
ff_rtsp_close_streams(VAR_0);
ff_network_close();
return VAR_3;
} | [
"static int FUNC_0(AVFormatContext *VAR_0)\n{",
"RTSPState *rt = VAR_0->priv_data;",
"RTSPStream *rtsp_st;",
"int VAR_1, VAR_2, VAR_3;",
"char *VAR_4;",
"char VAR_5[1024];",
"if (!ff_network_init())\nreturn AVERROR(EIO);",
"if (VAR_0->max_delay < 0)\nVAR_0->max_delay = DEFAULT_REORDERING_DELAY;",
"if (rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)\nrt->lower_transport = RTSP_LOWER_TRANSPORT_CUSTOM;",
"VAR_4 = av_malloc(SDP_MAX_SIZE);",
"VAR_1 = avio_read(VAR_0->pb, VAR_4, SDP_MAX_SIZE - 1);",
"if (VAR_1 <= 0) {",
"av_free(VAR_4);",
"return AVERROR_INVALIDDATA;",
"}",
"VAR_4[VAR_1] ='\\0';",
"VAR_3 = ff_sdp_parse(VAR_0, VAR_4);",
"av_freep(&VAR_4);",
"if (VAR_3) goto fail;",
"for (VAR_2 = 0; VAR_2 < rt->nb_rtsp_streams; VAR_2++) {",
"char namebuf[50];",
"rtsp_st = rt->rtsp_streams[VAR_2];",
"if (!(rt->rtsp_flags & RTSP_FLAG_CUSTOM_IO)) {",
"AVDictionary *opts = map_to_opts(rt);",
"getnameinfo((struct sockaddr*) &rtsp_st->sdp_ip, sizeof(rtsp_st->sdp_ip),\nnamebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);",
"ff_url_join(VAR_5, sizeof(VAR_5), \"rtp\", NULL,\nnamebuf, rtsp_st->sdp_port,\n\"?localport=%d&ttl=%d&connect=%d&write_to_source=%d\",\nrtsp_st->sdp_port, rtsp_st->sdp_ttl,\nrt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0,\nrt->rtsp_flags & RTSP_FLAG_RTCP_TO_SOURCE ? 1 : 0);",
"append_source_addrs(VAR_5, sizeof(VAR_5), \"sources\",\nrtsp_st->nb_include_source_addrs,\nrtsp_st->include_source_addrs);",
"append_source_addrs(VAR_5, sizeof(VAR_5), \"block\",\nrtsp_st->nb_exclude_source_addrs,\nrtsp_st->exclude_source_addrs);",
"VAR_3 = ffurl_open(&rtsp_st->rtp_handle, VAR_5, AVIO_FLAG_READ_WRITE,\n&VAR_0->interrupt_callback, &opts);",
"av_dict_free(&opts);",
"if (VAR_3 < 0) {",
"VAR_3 = AVERROR_INVALIDDATA;",
"goto fail;",
"}",
"}",
"if ((VAR_3 = ff_rtsp_open_transport_ctx(VAR_0, rtsp_st)))\ngoto fail;",
"}",
"return 0;",
"fail:\nff_rtsp_close_streams(VAR_0);",
"ff_network_close();",
"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,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
13
],
[
17,
19
],
[
23,
25
],
[
27,
29
],
[
37
],
[
41
],
[
43
],
[
45
],
[
47
],
[
49
],
[
51
],
[
55
],
[
57
],
[
59
],
[
65
],
[
67
],
[
69
],
[
73
],
[
75
],
[
79,
81
],
[
83,
85,
87,
89,
91,
93
],
[
97,
99,
101
],
[
103,
105,
107
],
[
109,
111
],
[
115
],
[
119
],
[
121
],
[
123
],
[
125
],
[
127
],
[
129,
131
],
[
133
],
[
135
],
[
137,
139
],
[
141
],
[
143
],
[
145
]
] |
25,132 | static inline void gen_op_mfspr(DisasContext *ctx)
{
void (*read_cb)(void *opaque, int gprn, int sprn);
uint32_t sprn = SPR(ctx->opcode);
#if !defined(CONFIG_USER_ONLY)
if (ctx->mem_idx == 2)
read_cb = ctx->spr_cb[sprn].hea_read;
else if (ctx->mem_idx)
read_cb = ctx->spr_cb[sprn].oea_read;
else
#endif
read_cb = ctx->spr_cb[sprn].uea_read;
if (likely(read_cb != NULL)) {
if (likely(read_cb != SPR_NOACCESS)) {
(*read_cb)(ctx, rD(ctx->opcode), sprn);
} else {
/* Privilege exception */
/* This is a hack to avoid warnings when running Linux:
* this OS breaks the PowerPC virtualisation model,
* allowing userland application to read the PVR
*/
if (sprn != SPR_PVR) {
qemu_log("Trying to read privileged spr %d %03x at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip);
printf("Trying to read privileged spr %d %03x at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip);
}
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
}
} else {
/* Not defined */
qemu_log("Trying to read invalid spr %d %03x at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip);
printf("Trying to read invalid spr %d %03x at " TARGET_FMT_lx "\n",
sprn, sprn, ctx->nip);
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_SPR);
}
}
| true | qemu | c05541ee191107eb35093fb693e4ec038e60d2c0 | static inline void gen_op_mfspr(DisasContext *ctx)
{
void (*read_cb)(void *opaque, int gprn, int sprn);
uint32_t sprn = SPR(ctx->opcode);
#if !defined(CONFIG_USER_ONLY)
if (ctx->mem_idx == 2)
read_cb = ctx->spr_cb[sprn].hea_read;
else if (ctx->mem_idx)
read_cb = ctx->spr_cb[sprn].oea_read;
else
#endif
read_cb = ctx->spr_cb[sprn].uea_read;
if (likely(read_cb != NULL)) {
if (likely(read_cb != SPR_NOACCESS)) {
(*read_cb)(ctx, rD(ctx->opcode), sprn);
} else {
if (sprn != SPR_PVR) {
qemu_log("Trying to read privileged spr %d %03x at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip);
printf("Trying to read privileged spr %d %03x at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip);
}
gen_inval_exception(ctx, POWERPC_EXCP_PRIV_REG);
}
} else {
qemu_log("Trying to read invalid spr %d %03x at "
TARGET_FMT_lx "\n", sprn, sprn, ctx->nip);
printf("Trying to read invalid spr %d %03x at " TARGET_FMT_lx "\n",
sprn, sprn, ctx->nip);
gen_inval_exception(ctx, POWERPC_EXCP_INVAL_SPR);
}
}
| {
"code": [
" qemu_log(\"Trying to read privileged spr %d %03x at \"",
" TARGET_FMT_lx \"\\n\", sprn, sprn, ctx->nip);",
" printf(\"Trying to read privileged spr %d %03x at \"",
" TARGET_FMT_lx \"\\n\", sprn, sprn, ctx->nip);",
" qemu_log(\"Trying to read invalid spr %d %03x at \"",
" TARGET_FMT_lx \"\\n\", sprn, sprn, ctx->nip);",
" printf(\"Trying to read invalid spr %d %03x at \" TARGET_FMT_lx \"\\n\",",
" sprn, sprn, ctx->nip);",
" sprn, sprn, ctx->nip);"
],
"line_no": [
47,
49,
51,
53,
65,
67,
69,
71,
71
]
} | static inline void FUNC_0(DisasContext *VAR_0)
{
void (*VAR_1)(void *VAR_2, int VAR_3, int VAR_4);
uint32_t VAR_4 = SPR(VAR_0->opcode);
#if !defined(CONFIG_USER_ONLY)
if (VAR_0->mem_idx == 2)
VAR_1 = VAR_0->spr_cb[VAR_4].hea_read;
else if (VAR_0->mem_idx)
VAR_1 = VAR_0->spr_cb[VAR_4].oea_read;
else
#endif
VAR_1 = VAR_0->spr_cb[VAR_4].uea_read;
if (likely(VAR_1 != NULL)) {
if (likely(VAR_1 != SPR_NOACCESS)) {
(*VAR_1)(VAR_0, rD(VAR_0->opcode), VAR_4);
} else {
if (VAR_4 != SPR_PVR) {
qemu_log("Trying to read privileged spr %d %03x at "
TARGET_FMT_lx "\n", VAR_4, VAR_4, VAR_0->nip);
printf("Trying to read privileged spr %d %03x at "
TARGET_FMT_lx "\n", VAR_4, VAR_4, VAR_0->nip);
}
gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);
}
} else {
qemu_log("Trying to read invalid spr %d %03x at "
TARGET_FMT_lx "\n", VAR_4, VAR_4, VAR_0->nip);
printf("Trying to read invalid spr %d %03x at " TARGET_FMT_lx "\n",
VAR_4, VAR_4, VAR_0->nip);
gen_inval_exception(VAR_0, POWERPC_EXCP_INVAL_SPR);
}
}
| [
"static inline void FUNC_0(DisasContext *VAR_0)\n{",
"void (*VAR_1)(void *VAR_2, int VAR_3, int VAR_4);",
"uint32_t VAR_4 = SPR(VAR_0->opcode);",
"#if !defined(CONFIG_USER_ONLY)\nif (VAR_0->mem_idx == 2)\nVAR_1 = VAR_0->spr_cb[VAR_4].hea_read;",
"else if (VAR_0->mem_idx)\nVAR_1 = VAR_0->spr_cb[VAR_4].oea_read;",
"else\n#endif\nVAR_1 = VAR_0->spr_cb[VAR_4].uea_read;",
"if (likely(VAR_1 != NULL)) {",
"if (likely(VAR_1 != SPR_NOACCESS)) {",
"(*VAR_1)(VAR_0, rD(VAR_0->opcode), VAR_4);",
"} else {",
"if (VAR_4 != SPR_PVR) {",
"qemu_log(\"Trying to read privileged spr %d %03x at \"\nTARGET_FMT_lx \"\\n\", VAR_4, VAR_4, VAR_0->nip);",
"printf(\"Trying to read privileged spr %d %03x at \"\nTARGET_FMT_lx \"\\n\", VAR_4, VAR_4, VAR_0->nip);",
"}",
"gen_inval_exception(VAR_0, POWERPC_EXCP_PRIV_REG);",
"}",
"} else {",
"qemu_log(\"Trying to read invalid spr %d %03x at \"\nTARGET_FMT_lx \"\\n\", VAR_4, VAR_4, VAR_0->nip);",
"printf(\"Trying to read invalid spr %d %03x at \" TARGET_FMT_lx \"\\n\",\nVAR_4, VAR_4, VAR_0->nip);",
"gen_inval_exception(VAR_0, POWERPC_EXCP_INVAL_SPR);",
"}",
"}"
] | [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
0,
0,
0,
0,
1,
1,
0,
0,
0
] | [
[
1,
3
],
[
5
],
[
7
],
[
11,
13,
15
],
[
17,
19
],
[
21,
23,
25
],
[
27
],
[
29
],
[
31
],
[
33
],
[
45
],
[
47,
49
],
[
51,
53
],
[
55
],
[
57
],
[
59
],
[
61
],
[
65,
67
],
[
69,
71
],
[
73
],
[
75
],
[
77
]
] |
25,133 | static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
{
MOVMuxContext *mov = s->priv_data;
MOVTrack *track = &mov->tracks[tracknum];
AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
int i, len;
// These properties are required to make QT recognize the chapter track
uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };
track->mode = mov->mode;
track->tag = MKTAG('t','e','x','t');
track->timescale = MOV_TIMESCALE;
track->enc = avcodec_alloc_context3(NULL);
if (!track->enc)
track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
track->enc->extradata = av_malloc(sizeof(chapter_properties));
if (track->enc->extradata == NULL)
track->enc->extradata_size = sizeof(chapter_properties);
memcpy(track->enc->extradata, chapter_properties, sizeof(chapter_properties));
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *c = s->chapters[i];
AVDictionaryEntry *t;
int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
pkt.duration = end - pkt.dts;
if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
len = strlen(t->value);
pkt.size = len + 2;
pkt.data = av_malloc(pkt.size);
AV_WB16(pkt.data, len);
memcpy(pkt.data + 2, t->value, len);
ff_mov_write_packet(s, &pkt);
av_freep(&pkt.data);
}
}
return 0;
} | true | FFmpeg | 4d122b01e4ce539269ee2df193b061772c7374f6 | static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
{
MOVMuxContext *mov = s->priv_data;
MOVTrack *track = &mov->tracks[tracknum];
AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
int i, len;
uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };
track->mode = mov->mode;
track->tag = MKTAG('t','e','x','t');
track->timescale = MOV_TIMESCALE;
track->enc = avcodec_alloc_context3(NULL);
if (!track->enc)
track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
track->enc->extradata = av_malloc(sizeof(chapter_properties));
if (track->enc->extradata == NULL)
track->enc->extradata_size = sizeof(chapter_properties);
memcpy(track->enc->extradata, chapter_properties, sizeof(chapter_properties));
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *c = s->chapters[i];
AVDictionaryEntry *t;
int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
pkt.duration = end - pkt.dts;
if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
len = strlen(t->value);
pkt.size = len + 2;
pkt.data = av_malloc(pkt.size);
AV_WB16(pkt.data, len);
memcpy(pkt.data + 2, t->value, len);
ff_mov_write_packet(s, &pkt);
av_freep(&pkt.data);
}
}
return 0;
} | {
"code": [],
"line_no": []
} | static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)
{
MOVMuxContext *mov = VAR_0->priv_data;
MOVTrack *track = &mov->tracks[VAR_1];
AVPacket pkt = { .stream_index = VAR_1, .flags = AV_PKT_FLAG_KEY };
int VAR_2, VAR_3;
uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };
track->mode = mov->mode;
track->tag = MKTAG('t','e','x','t');
track->timescale = MOV_TIMESCALE;
track->enc = avcodec_alloc_context3(NULL);
if (!track->enc)
track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
track->enc->extradata = av_malloc(sizeof(chapter_properties));
if (track->enc->extradata == NULL)
track->enc->extradata_size = sizeof(chapter_properties);
memcpy(track->enc->extradata, chapter_properties, sizeof(chapter_properties));
for (VAR_2 = 0; VAR_2 < VAR_0->nb_chapters; VAR_2++) {
AVChapter *c = VAR_0->chapters[VAR_2];
AVDictionaryEntry *t;
int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});
pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});
pkt.duration = end - pkt.dts;
if ((t = av_dict_get(c->metadata, "title", NULL, 0))) {
VAR_3 = strlen(t->value);
pkt.size = VAR_3 + 2;
pkt.data = av_malloc(pkt.size);
AV_WB16(pkt.data, VAR_3);
memcpy(pkt.data + 2, t->value, VAR_3);
ff_mov_write_packet(VAR_0, &pkt);
av_freep(&pkt.data);
}
}
return 0;
} | [
"static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{",
"MOVMuxContext *mov = VAR_0->priv_data;",
"MOVTrack *track = &mov->tracks[VAR_1];",
"AVPacket pkt = { .stream_index = VAR_1, .flags = AV_PKT_FLAG_KEY };",
"int VAR_2, VAR_3;",
"uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };",
"track->mode = mov->mode;",
"track->tag = MKTAG('t','e','x','t');",
"track->timescale = MOV_TIMESCALE;",
"track->enc = avcodec_alloc_context3(NULL);",
"if (!track->enc)\ntrack->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;",
"track->enc->extradata = av_malloc(sizeof(chapter_properties));",
"if (track->enc->extradata == NULL)\ntrack->enc->extradata_size = sizeof(chapter_properties);",
"memcpy(track->enc->extradata, chapter_properties, sizeof(chapter_properties));",
"for (VAR_2 = 0; VAR_2 < VAR_0->nb_chapters; VAR_2++) {",
"AVChapter *c = VAR_0->chapters[VAR_2];",
"AVDictionaryEntry *t;",
"int64_t end = av_rescale_q(c->end, c->time_base, (AVRational){1,MOV_TIMESCALE});",
"pkt.pts = pkt.dts = av_rescale_q(c->start, c->time_base, (AVRational){1,MOV_TIMESCALE});",
"pkt.duration = end - pkt.dts;",
"if ((t = av_dict_get(c->metadata, \"title\", NULL, 0))) {",
"VAR_3 = strlen(t->value);",
"pkt.size = VAR_3 + 2;",
"pkt.data = av_malloc(pkt.size);",
"AV_WB16(pkt.data, VAR_3);",
"memcpy(pkt.data + 2, t->value, VAR_3);",
"ff_mov_write_packet(VAR_0, &pkt);",
"av_freep(&pkt.data);",
"}",
"}",
"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
] | [
[
1,
3
],
[
5
],
[
7
],
[
9
],
[
11
],
[
15
],
[
19
],
[
21
],
[
23
],
[
25
],
[
27,
30
],
[
32
],
[
34,
37
],
[
39
],
[
43
],
[
45
],
[
47
],
[
51
],
[
53
],
[
55
],
[
59
],
[
61
],
[
63
],
[
65
],
[
69
],
[
71
],
[
73
],
[
75
],
[
77
],
[
79
],
[
83
],
[
85
]
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.